	.file	"298811.c"
	.intel_syntax noprefix
	.text
	.section	.rodata
.LC0:
	.string	"rb"
	.text
	.globl	read_binary_file
	.type	read_binary_file, @function
read_binary_file:
.LFB6:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 32
	mov	QWORD PTR -24[rbp], rdi
	mov	QWORD PTR -32[rbp], rsi
	mov	rax, QWORD PTR -24[rbp]
	lea	rsi, .LC0[rip]
	mov	rdi, rax
	call	fopen@PLT
	mov	QWORD PTR -8[rbp], rax
	cmp	QWORD PTR -8[rbp], 0
	jne	.L2
	mov	eax, 0
	jmp	.L3
.L2:
	mov	rax, QWORD PTR -8[rbp]
	mov	edx, 2
	mov	esi, 0
	mov	rdi, rax
	call	fseek@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	ftell@PLT
	mov	rdx, rax
	mov	rax, QWORD PTR -32[rbp]
	mov	QWORD PTR 16[rax], rdx
	mov	rax, QWORD PTR -8[rbp]
	mov	edx, 0
	mov	esi, 0
	mov	rdi, rax
	call	fseek@PLT
	mov	rax, QWORD PTR -32[rbp]
	mov	rax, QWORD PTR 16[rax]
	mov	rdi, rax
	call	malloc@PLT
	mov	rdx, rax
	mov	rax, QWORD PTR -32[rbp]
	mov	QWORD PTR [rax], rdx
	mov	rax, QWORD PTR -32[rbp]
	mov	rdx, QWORD PTR 16[rax]
	mov	rax, QWORD PTR -32[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rcx, QWORD PTR -8[rbp]
	mov	esi, 1
	mov	rdi, rax
	call	fread@PLT
	mov	rdx, QWORD PTR -32[rbp]
	mov	rdx, QWORD PTR 16[rdx]
	cmp	rax, rdx
	je	.L4
	mov	rax, QWORD PTR -32[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rdi, rax
	call	free@PLT
	mov	rax, QWORD PTR -32[rbp]
	mov	QWORD PTR [rax], 0
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	fclose@PLT
	mov	eax, 0
	jmp	.L3
.L4:
	mov	rax, QWORD PTR -32[rbp]
	mov	QWORD PTR 8[rax], 0
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	fclose@PLT
	mov	eax, 1
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	read_binary_file, .-read_binary_file
	.section	.rodata
.LC1:
	.string	"wb"
	.text
	.globl	write_binary_file
	.type	write_binary_file, @function
write_binary_file:
.LFB7:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 32
	mov	QWORD PTR -24[rbp], rdi
	mov	QWORD PTR -32[rbp], rsi
	mov	rax, QWORD PTR -24[rbp]
	lea	rsi, .LC1[rip]
	mov	rdi, rax
	call	fopen@PLT
	mov	QWORD PTR -8[rbp], rax
	cmp	QWORD PTR -8[rbp], 0
	jne	.L6
	mov	eax, 0
	jmp	.L7
.L6:
	mov	rax, QWORD PTR -32[rbp]
	mov	rdx, QWORD PTR 16[rax]
	mov	rax, QWORD PTR -32[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rcx, QWORD PTR -8[rbp]
	mov	esi, 1
	mov	rdi, rax
	call	fwrite@PLT
	mov	rdx, QWORD PTR -32[rbp]
	mov	rdx, QWORD PTR 16[rdx]
	cmp	rax, rdx
	je	.L8
	mov	eax, 0
	jmp	.L7
.L8:
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	fclose@PLT
	mov	eax, 1
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	write_binary_file, .-write_binary_file
	.globl	free_stream
	.type	free_stream, @function
free_stream:
.LFB8:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 16
	mov	QWORD PTR -8[rbp], rdi
	cmp	QWORD PTR -8[rbp], 0
	je	.L10
	mov	rax, QWORD PTR -8[rbp]
	mov	rax, QWORD PTR [rax]
	test	rax, rax
	je	.L10
	mov	rax, QWORD PTR -8[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rdi, rax
	call	free@PLT
.L10:
	mov	rax, QWORD PTR -8[rbp]
	mov	QWORD PTR [rax], 0
	mov	rax, QWORD PTR -8[rbp]
	mov	QWORD PTR 8[rax], 0
	mov	rax, QWORD PTR -8[rbp]
	mov	QWORD PTR 16[rax], 0
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	free_stream, .-free_stream
	.globl	expand_stream
	.type	expand_stream, @function
expand_stream:
.LFB9:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 16
	mov	QWORD PTR -8[rbp], rdi
	mov	QWORD PTR -16[rbp], rsi
	mov	rax, QWORD PTR -8[rbp]
	mov	rax, QWORD PTR 16[rax]
	cmp	QWORD PTR -16[rbp], rax
	jbe	.L14
	mov	rax, QWORD PTR -8[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rdx, QWORD PTR -16[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	realloc@PLT
	mov	rdx, QWORD PTR -8[rbp]
	mov	QWORD PTR [rdx], rax
	mov	rax, QWORD PTR -8[rbp]
	mov	rcx, QWORD PTR 16[rax]
	mov	rax, QWORD PTR -16[rbp]
	sub	rax, rcx
	mov	rdx, rax
	mov	rax, QWORD PTR -8[rbp]
	mov	rcx, QWORD PTR [rax]
	mov	rax, QWORD PTR -8[rbp]
	mov	rax, QWORD PTR 16[rax]
	add	rax, rcx
	mov	esi, 0
	mov	rdi, rax
	call	memset@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	rdx, QWORD PTR -16[rbp]
	mov	QWORD PTR 16[rax], rdx
	jmp	.L11
.L14:
	nop
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	expand_stream, .-expand_stream
	.globl	patch_hunk
	.type	patch_hunk, @function
patch_hunk:
.LFB10:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 48
	mov	QWORD PTR -24[rbp], rdi
	mov	QWORD PTR -32[rbp], rsi
	mov	QWORD PTR -40[rbp], rdx
	mov	DWORD PTR -8[rbp], 0
	mov	DWORD PTR -4[rbp], 0
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR 16[rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, 5
	cmp	rdx, rax
	jnb	.L16
	mov	rax, QWORD PTR -40[rbp]
	mov	BYTE PTR [rax], 1
	mov	eax, 1
	jmp	.L17
.L16:
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, rdx
	movzx	eax, BYTE PTR [rax]
	movzx	eax, al
	sal	eax, 16
	mov	ecx, eax
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, 1
	add	rax, rdx
	movzx	eax, BYTE PTR [rax]
	movzx	eax, al
	sal	eax, 8
	or	ecx, eax
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, 2
	add	rax, rdx
	movzx	eax, BYTE PTR [rax]
	movzx	eax, al
	or	eax, ecx
	mov	DWORD PTR -8[rbp], eax
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	lea	rdx, 3[rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR 8[rax], rdx
	cmp	DWORD PTR -8[rbp], 4542278
	jne	.L18
	mov	rax, QWORD PTR -40[rbp]
	mov	BYTE PTR [rax], 1
	mov	eax, 1
	jmp	.L17
.L18:
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, rdx
	movzx	eax, BYTE PTR [rax]
	movzx	eax, al
	sal	eax, 8
	mov	ecx, eax
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, 1
	add	rax, rdx
	movzx	eax, BYTE PTR [rax]
	movzx	eax, al
	or	eax, ecx
	mov	DWORD PTR -4[rbp], eax
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	lea	rdx, 2[rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR 8[rax], rdx
	cmp	DWORD PTR -4[rbp], 0
	jne	.L19
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR 16[rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, 3
	cmp	rdx, rax
	jnb	.L20
	mov	eax, 0
	jmp	.L17
.L20:
	mov	BYTE PTR -9[rbp], 0
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, rdx
	movzx	eax, BYTE PTR [rax]
	movzx	eax, al
	sal	eax, 8
	mov	ecx, eax
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, 1
	add	rax, rdx
	movzx	eax, BYTE PTR [rax]
	movzx	eax, al
	or	eax, ecx
	mov	DWORD PTR -4[rbp], eax
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	lea	rdx, 2[rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR 8[rax], rdx
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	add	rax, rdx
	movzx	eax, BYTE PTR [rax]
	mov	BYTE PTR -9[rbp], al
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	lea	rdx, 1[rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR 8[rax], rdx
	mov	edx, DWORD PTR -8[rbp]
	mov	eax, DWORD PTR -4[rbp]
	add	eax, edx
	mov	edx, eax
	mov	rax, QWORD PTR -32[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	expand_stream
	jmp	.L21
.L22:
	mov	rax, QWORD PTR -32[rbp]
	mov	rcx, QWORD PTR [rax]
	mov	eax, DWORD PTR -8[rbp]
	lea	edx, 1[rax]
	mov	DWORD PTR -8[rbp], edx
	mov	eax, eax
	lea	rdx, [rcx+rax]
	movzx	eax, BYTE PTR -9[rbp]
	mov	BYTE PTR [rdx], al
.L21:
	mov	eax, DWORD PTR -4[rbp]
	lea	edx, -1[rax]
	mov	DWORD PTR -4[rbp], edx
	test	eax, eax
	jne	.L22
	jmp	.L23
.L19:
	mov	rax, QWORD PTR -24[rbp]
	mov	rdx, QWORD PTR 16[rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rcx, QWORD PTR 8[rax]
	mov	eax, DWORD PTR -4[rbp]
	add	rax, rcx
	cmp	rdx, rax
	jnb	.L24
	mov	eax, 0
	jmp	.L17
.L24:
	mov	edx, DWORD PTR -8[rbp]
	mov	eax, DWORD PTR -4[rbp]
	add	eax, edx
	mov	edx, eax
	mov	rax, QWORD PTR -32[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	expand_stream
	jmp	.L25
.L26:
	mov	rax, QWORD PTR -24[rbp]
	mov	rsi, QWORD PTR [rax]
	mov	rax, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR 8[rax]
	lea	rcx, 1[rax]
	mov	rdx, QWORD PTR -24[rbp]
	mov	QWORD PTR 8[rdx], rcx
	lea	rcx, [rsi+rax]
	mov	rax, QWORD PTR -32[rbp]
	mov	rsi, QWORD PTR [rax]
	mov	eax, DWORD PTR -8[rbp]
	lea	edx, 1[rax]
	mov	DWORD PTR -8[rbp], edx
	mov	eax, eax
	lea	rdx, [rsi+rax]
	movzx	eax, BYTE PTR [rcx]
	mov	BYTE PTR [rdx], al
.L25:
	mov	eax, DWORD PTR -4[rbp]
	lea	edx, -1[rax]
	mov	DWORD PTR -4[rbp], edx
	test	eax, eax
	jne	.L26
.L23:
	mov	eax, 1
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	patch_hunk, .-patch_hunk
	.section	.rodata
	.align 8
.LC2:
	.string	"Usage: %s patchfile infile outfile\n"
.LC3:
	.string	"Failed to open %s\n"
.LC4:
	.string	"PATCH"
.LC5:
	.string	"%s is not an IPS patch file!\n"
	.align 8
.LC6:
	.string	"Failed to patch, invalid hunk."
.LC7:
	.string	"Failed to write %s\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 96
	mov	DWORD PTR -84[rbp], edi
	mov	QWORD PTR -96[rbp], rsi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	mov	QWORD PTR -64[rbp], 0
	mov	QWORD PTR -56[rbp], 0
	mov	QWORD PTR -48[rbp], 0
	mov	QWORD PTR -32[rbp], 0
	mov	QWORD PTR -24[rbp], 0
	mov	QWORD PTR -16[rbp], 0
	cmp	DWORD PTR -84[rbp], 4
	je	.L28
	mov	rax, QWORD PTR -96[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rsi, rax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	jmp	.L29
.L28:
	mov	rax, QWORD PTR -96[rbp]
	add	rax, 8
	mov	rax, QWORD PTR [rax]
	lea	rdx, -64[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	read_binary_file
	xor	eax, 1
	test	al, al
	je	.L30
	mov	rax, QWORD PTR -96[rbp]
	add	rax, 8
	mov	rax, QWORD PTR [rax]
	mov	rsi, rax
	lea	rdi, .LC3[rip]
	mov	eax, 0
	call	printf@PLT
	jmp	.L29
.L30:
	mov	rax, QWORD PTR -64[rbp]
	mov	edx, 5
	mov	rsi, rax
	lea	rdi, .LC4[rip]
	call	strncmp@PLT
	test	eax, eax
	je	.L31
	mov	rax, QWORD PTR -96[rbp]
	add	rax, 8
	mov	rax, QWORD PTR [rax]
	mov	rsi, rax
	lea	rdi, .LC5[rip]
	mov	eax, 0
	call	printf@PLT
	jmp	.L29
.L31:
	mov	rax, QWORD PTR -56[rbp]
	add	rax, 5
	mov	QWORD PTR -56[rbp], rax
	mov	rax, QWORD PTR -96[rbp]
	add	rax, 16
	mov	rax, QWORD PTR [rax]
	lea	rdx, -32[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	read_binary_file
	xor	eax, 1
	test	al, al
	je	.L32
	mov	rax, QWORD PTR -96[rbp]
	add	rax, 16
	mov	rax, QWORD PTR [rax]
	mov	rsi, rax
	lea	rdi, .LC3[rip]
	mov	eax, 0
	call	printf@PLT
	jmp	.L29
.L32:
	mov	BYTE PTR -65[rbp], 0
	jmp	.L33
.L34:
	lea	rdx, -65[rbp]
	lea	rcx, -32[rbp]
	lea	rax, -64[rbp]
	mov	rsi, rcx
	mov	rdi, rax
	call	patch_hunk
	xor	eax, 1
	test	al, al
	je	.L33
	lea	rdi, .LC6[rip]
	call	puts@PLT
	jmp	.L29
.L33:
	movzx	eax, BYTE PTR -65[rbp]
	xor	eax, 1
	test	al, al
	jne	.L34
	mov	rax, QWORD PTR -96[rbp]
	add	rax, 24
	mov	rax, QWORD PTR [rax]
	lea	rdx, -32[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	write_binary_file
	xor	eax, 1
	test	al, al
	je	.L35
	mov	rax, QWORD PTR -96[rbp]
	add	rax, 24
	mov	rax, QWORD PTR [rax]
	mov	rsi, rax
	lea	rdi, .LC7[rip]
	mov	eax, 0
	call	printf@PLT
	jmp	.L29
.L35:
	lea	rax, -64[rbp]
	mov	rdi, rax
	call	free_stream
	lea	rax, -32[rbp]
	mov	rdi, rax
	call	free_stream
	mov	eax, 0
	jmp	.L37
.L29:
	lea	rax, -64[rbp]
	mov	rdi, rax
	call	free_stream
	lea	rax, -32[rbp]
	mov	rdi, rax
	call	free_stream
	mov	eax, 1
.L37:
	mov	rcx, QWORD PTR -8[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 6
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"298811.c"
	.text
	.section	.rodata
	.align	2
.LC0:
	.ascii	"rb\000"
	.text
	.align	2
	.global	read_binary_file
	.syntax unified
	.arm
	.fpu softvfp
	.type	read_binary_file, %function
read_binary_file:
	@ args = 0, pretend = 0, frame = 16
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #16
	str	r0, [fp, #-16]
	str	r1, [fp, #-20]
	ldr	r1, .L5
	ldr	r0, [fp, #-16]
	bl	fopen
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	cmp	r3, #0
	bne	.L2
	mov	r3, #0
	b	.L3
.L2:
	mov	r2, #2
	mov	r1, #0
	ldr	r0, [fp, #-8]
	bl	fseek
	ldr	r0, [fp, #-8]
	bl	ftell
	mov	r3, r0
	mov	r2, r3
	ldr	r3, [fp, #-20]
	str	r2, [r3, #8]
	mov	r2, #0
	mov	r1, #0
	ldr	r0, [fp, #-8]
	bl	fseek
	ldr	r3, [fp, #-20]
	ldr	r3, [r3, #8]
	mov	r0, r3
	bl	malloc
	mov	r3, r0
	mov	r2, r3
	ldr	r3, [fp, #-20]
	str	r2, [r3]
	ldr	r3, [fp, #-20]
	ldr	r0, [r3]
	ldr	r3, [fp, #-20]
	ldr	r2, [r3, #8]
	ldr	r3, [fp, #-8]
	mov	r1, #1
	bl	fread
	mov	r2, r0
	ldr	r3, [fp, #-20]
	ldr	r3, [r3, #8]
	cmp	r2, r3
	beq	.L4
	ldr	r3, [fp, #-20]
	ldr	r3, [r3]
	mov	r0, r3
	bl	free
	ldr	r3, [fp, #-20]
	mov	r2, #0
	str	r2, [r3]
	ldr	r0, [fp, #-8]
	bl	fclose
	mov	r3, #0
	b	.L3
.L4:
	ldr	r3, [fp, #-20]
	mov	r2, #0
	str	r2, [r3, #4]
	ldr	r0, [fp, #-8]
	bl	fclose
	mov	r3, #1
.L3:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L6:
	.align	2
.L5:
	.word	.LC0
	.size	read_binary_file, .-read_binary_file
	.section	.rodata
	.align	2
.LC1:
	.ascii	"wb\000"
	.text
	.align	2
	.global	write_binary_file
	.syntax unified
	.arm
	.fpu softvfp
	.type	write_binary_file, %function
write_binary_file:
	@ args = 0, pretend = 0, frame = 16
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #16
	str	r0, [fp, #-16]
	str	r1, [fp, #-20]
	ldr	r1, .L11
	ldr	r0, [fp, #-16]
	bl	fopen
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	cmp	r3, #0
	bne	.L8
	mov	r3, #0
	b	.L9
.L8:
	ldr	r3, [fp, #-20]
	ldr	r0, [r3]
	ldr	r3, [fp, #-20]
	ldr	r2, [r3, #8]
	ldr	r3, [fp, #-8]
	mov	r1, #1
	bl	fwrite
	mov	r2, r0
	ldr	r3, [fp, #-20]
	ldr	r3, [r3, #8]
	cmp	r2, r3
	beq	.L10
	mov	r3, #0
	b	.L9
.L10:
	ldr	r0, [fp, #-8]
	bl	fclose
	mov	r3, #1
.L9:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L12:
	.align	2
.L11:
	.word	.LC1
	.size	write_binary_file, .-write_binary_file
	.align	2
	.global	free_stream
	.syntax unified
	.arm
	.fpu softvfp
	.type	free_stream, %function
free_stream:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #8
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	cmp	r3, #0
	beq	.L14
	ldr	r3, [fp, #-8]
	ldr	r3, [r3]
	cmp	r3, #0
	beq	.L14
	ldr	r3, [fp, #-8]
	ldr	r3, [r3]
	mov	r0, r3
	bl	free
.L14:
	ldr	r3, [fp, #-8]
	mov	r2, #0
	str	r2, [r3]
	ldr	r3, [fp, #-8]
	mov	r2, #0
	str	r2, [r3, #4]
	ldr	r3, [fp, #-8]
	mov	r2, #0
	str	r2, [r3, #8]
	nop
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	free_stream, .-free_stream
	.align	2
	.global	expand_stream
	.syntax unified
	.arm
	.fpu softvfp
	.type	expand_stream, %function
expand_stream:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #8
	str	r0, [fp, #-8]
	str	r1, [fp, #-12]
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #8]
	ldr	r2, [fp, #-12]
	cmp	r2, r3
	bls	.L18
	ldr	r3, [fp, #-8]
	ldr	r3, [r3]
	ldr	r1, [fp, #-12]
	mov	r0, r3
	bl	realloc
	mov	r2, r0
	ldr	r3, [fp, #-8]
	str	r2, [r3]
	ldr	r3, [fp, #-8]
	ldr	r2, [r3]
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #8]
	add	r0, r2, r3
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #8]
	ldr	r2, [fp, #-12]
	sub	r3, r2, r3
	mov	r2, r3
	mov	r1, #0
	bl	memset
	ldr	r3, [fp, #-8]
	ldr	r2, [fp, #-12]
	str	r2, [r3, #8]
	b	.L15
.L18:
	nop
.L15:
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	expand_stream, .-expand_stream
	.align	2
	.global	patch_hunk
	.syntax unified
	.arm
	.fpu softvfp
	.type	patch_hunk, %function
patch_hunk:
	@ args = 0, pretend = 0, frame = 32
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #32
	str	r0, [fp, #-24]
	str	r1, [fp, #-28]
	str	r2, [fp, #-32]
	mov	r3, #0
	str	r3, [fp, #-12]
	mov	r3, #0
	str	r3, [fp, #-8]
	ldr	r3, [fp, #-24]
	ldr	r2, [r3, #8]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r3, r3, #5
	cmp	r2, r3
	bcs	.L20
	ldr	r3, [fp, #-32]
	mov	r2, #1
	strb	r2, [r3]
	mov	r3, #1
	b	.L21
.L20:
	ldr	r3, [fp, #-24]
	ldr	r2, [r3]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r3, r2, r3
	ldrb	r3, [r3]	@ zero_extendqisi2
	lsl	r2, r3, #16
	ldr	r3, [fp, #-24]
	ldr	r1, [r3]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r3, r3, #1
	add	r3, r1, r3
	ldrb	r3, [r3]	@ zero_extendqisi2
	lsl	r3, r3, #8
	orr	r3, r2, r3
	ldr	r2, [fp, #-24]
	ldr	r1, [r2]
	ldr	r2, [fp, #-24]
	ldr	r2, [r2, #4]
	add	r2, r2, #2
	add	r2, r1, r2
	ldrb	r2, [r2]	@ zero_extendqisi2
	orr	r3, r3, r2
	str	r3, [fp, #-12]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r2, r3, #3
	ldr	r3, [fp, #-24]
	str	r2, [r3, #4]
	ldr	r3, [fp, #-12]
	ldr	r2, .L31
	cmp	r3, r2
	bne	.L22
	ldr	r3, [fp, #-32]
	mov	r2, #1
	strb	r2, [r3]
	mov	r3, #1
	b	.L21
.L22:
	ldr	r3, [fp, #-24]
	ldr	r2, [r3]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r3, r2, r3
	ldrb	r3, [r3]	@ zero_extendqisi2
	lsl	r3, r3, #8
	ldr	r2, [fp, #-24]
	ldr	r1, [r2]
	ldr	r2, [fp, #-24]
	ldr	r2, [r2, #4]
	add	r2, r2, #1
	add	r2, r1, r2
	ldrb	r2, [r2]	@ zero_extendqisi2
	orr	r3, r3, r2
	str	r3, [fp, #-8]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r2, r3, #2
	ldr	r3, [fp, #-24]
	str	r2, [r3, #4]
	ldr	r3, [fp, #-8]
	cmp	r3, #0
	bne	.L23
	ldr	r3, [fp, #-24]
	ldr	r2, [r3, #8]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r3, r3, #3
	cmp	r2, r3
	bcs	.L24
	mov	r3, #0
	b	.L21
.L24:
	mov	r3, #0
	strb	r3, [fp, #-13]
	ldr	r3, [fp, #-24]
	ldr	r2, [r3]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r3, r2, r3
	ldrb	r3, [r3]	@ zero_extendqisi2
	lsl	r3, r3, #8
	ldr	r2, [fp, #-24]
	ldr	r1, [r2]
	ldr	r2, [fp, #-24]
	ldr	r2, [r2, #4]
	add	r2, r2, #1
	add	r2, r1, r2
	ldrb	r2, [r2]	@ zero_extendqisi2
	orr	r3, r3, r2
	str	r3, [fp, #-8]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r2, r3, #2
	ldr	r3, [fp, #-24]
	str	r2, [r3, #4]
	ldr	r3, [fp, #-24]
	ldr	r2, [r3]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r3, r2, r3
	ldrb	r3, [r3]
	strb	r3, [fp, #-13]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r2, r3, #1
	ldr	r3, [fp, #-24]
	str	r2, [r3, #4]
	ldr	r2, [fp, #-12]
	ldr	r3, [fp, #-8]
	add	r3, r2, r3
	mov	r1, r3
	ldr	r0, [fp, #-28]
	bl	expand_stream
	b	.L25
.L26:
	ldr	r3, [fp, #-28]
	ldr	r2, [r3]
	ldr	r3, [fp, #-12]
	add	r1, r3, #1
	str	r1, [fp, #-12]
	add	r3, r2, r3
	ldrb	r2, [fp, #-13]
	strb	r2, [r3]
.L25:
	ldr	r3, [fp, #-8]
	sub	r2, r3, #1
	str	r2, [fp, #-8]
	cmp	r3, #0
	bne	.L26
	b	.L27
.L23:
	ldr	r3, [fp, #-24]
	ldr	r2, [r3, #8]
	ldr	r3, [fp, #-24]
	ldr	r1, [r3, #4]
	ldr	r3, [fp, #-8]
	add	r3, r1, r3
	cmp	r2, r3
	bcs	.L28
	mov	r3, #0
	b	.L21
.L28:
	ldr	r2, [fp, #-12]
	ldr	r3, [fp, #-8]
	add	r3, r2, r3
	mov	r1, r3
	ldr	r0, [fp, #-28]
	bl	expand_stream
	b	.L29
.L30:
	ldr	r3, [fp, #-24]
	ldr	r2, [r3]
	ldr	r3, [fp, #-24]
	ldr	r3, [r3, #4]
	add	r0, r3, #1
	ldr	r1, [fp, #-24]
	str	r0, [r1, #4]
	add	r2, r2, r3
	ldr	r3, [fp, #-28]
	ldr	r1, [r3]
	ldr	r3, [fp, #-12]
	add	r0, r3, #1
	str	r0, [fp, #-12]
	add	r3, r1, r3
	ldrb	r2, [r2]	@ zero_extendqisi2
	strb	r2, [r3]
.L29:
	ldr	r3, [fp, #-8]
	sub	r2, r3, #1
	str	r2, [fp, #-8]
	cmp	r3, #0
	bne	.L30
.L27:
	mov	r3, #1
.L21:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L32:
	.align	2
.L31:
	.word	4542278
	.size	patch_hunk, .-patch_hunk
	.section	.rodata
	.align	2
.LC2:
	.ascii	"Usage: %s patchfile infile outfile\012\000"
	.align	2
.LC3:
	.ascii	"Failed to open %s\012\000"
	.align	2
.LC4:
	.ascii	"PATCH\000"
	.align	2
.LC5:
	.ascii	"%s is not an IPS patch file!\012\000"
	.align	2
.LC6:
	.ascii	"Failed to patch, invalid hunk.\000"
	.align	2
.LC7:
	.ascii	"Failed to write %s\012\000"
	.align	2
.LC8:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 40
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #40
	str	r0, [fp, #-40]
	str	r1, [fp, #-44]
	ldr	r3, .L45
	ldr	r3, [r3]
	str	r3, [fp, #-8]
	mov	r3,#0
	sub	r3, fp, #32
	mov	r2, #0
	str	r2, [r3]
	str	r2, [r3, #4]
	str	r2, [r3, #8]
	sub	r3, fp, #20
	mov	r2, #0
	str	r2, [r3]
	str	r2, [r3, #4]
	str	r2, [r3, #8]
	ldr	r3, [fp, #-40]
	cmp	r3, #4
	beq	.L34
	ldr	r3, [fp, #-44]
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L45+4
	bl	printf
	b	.L35
.L34:
	ldr	r3, [fp, #-44]
	add	r3, r3, #4
	ldr	r3, [r3]
	sub	r2, fp, #32
	mov	r1, r2
	mov	r0, r3
	bl	read_binary_file
	mov	r3, r0
	eor	r3, r3, #1
	and	r3, r3, #255
	cmp	r3, #0
	beq	.L36
	ldr	r3, [fp, #-44]
	add	r3, r3, #4
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L45+8
	bl	printf
	b	.L35
.L36:
	ldr	r3, [fp, #-32]
	mov	r2, #5
	mov	r1, r3
	ldr	r0, .L45+12
	bl	strncmp
	mov	r3, r0
	cmp	r3, #0
	beq	.L37
	ldr	r3, [fp, #-44]
	add	r3, r3, #4
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L45+16
	bl	printf
	b	.L35
.L37:
	ldr	r3, [fp, #-28]
	add	r3, r3, #5
	str	r3, [fp, #-28]
	ldr	r3, [fp, #-44]
	add	r3, r3, #8
	ldr	r3, [r3]
	sub	r2, fp, #20
	mov	r1, r2
	mov	r0, r3
	bl	read_binary_file
	mov	r3, r0
	eor	r3, r3, #1
	and	r3, r3, #255
	cmp	r3, #0
	beq	.L38
	ldr	r3, [fp, #-44]
	add	r3, r3, #8
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L45+8
	bl	printf
	b	.L35
.L38:
	mov	r3, #0
	strb	r3, [fp, #-33]
	b	.L39
.L40:
	sub	r2, fp, #33
	sub	r1, fp, #20
	sub	r3, fp, #32
	mov	r0, r3
	bl	patch_hunk
	mov	r3, r0
	eor	r3, r3, #1
	and	r3, r3, #255
	cmp	r3, #0
	beq	.L39
	ldr	r0, .L45+20
	bl	puts
	b	.L35
.L39:
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	eor	r3, r3, #1
	and	r3, r3, #255
	cmp	r3, #0
	bne	.L40
	ldr	r3, [fp, #-44]
	add	r3, r3, #12
	ldr	r3, [r3]
	sub	r2, fp, #20
	mov	r1, r2
	mov	r0, r3
	bl	write_binary_file
	mov	r3, r0
	eor	r3, r3, #1
	and	r3, r3, #255
	cmp	r3, #0
	beq	.L41
	ldr	r3, [fp, #-44]
	add	r3, r3, #12
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L45+24
	bl	printf
	b	.L35
.L41:
	sub	r3, fp, #32
	mov	r0, r3
	bl	free_stream
	sub	r3, fp, #20
	mov	r0, r3
	bl	free_stream
	mov	r3, #0
	b	.L43
.L35:
	sub	r3, fp, #32
	mov	r0, r3
	bl	free_stream
	sub	r3, fp, #20
	mov	r0, r3
	bl	free_stream
	mov	r3, #1
.L43:
	ldr	r2, .L45
	ldr	r1, [r2]
	ldr	r2, [fp, #-8]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L44
	bl	__stack_chk_fail
.L44:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L46:
	.align	2
.L45:
	.word	.LC8
	.word	.LC2
	.word	.LC3
	.word	.LC4
	.word	.LC5
	.word	.LC6
	.word	.LC7
	.size	main, .-main
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
