	.file	"670736.c"
	.intel_syntax noprefix
	.text
	.local	stay_alive
	.comm	stay_alive,4,4
	.section	.rodata
	.align 8
.LC0:
	.string	"Usage: %s opt=read/write device_file [\"secret-msg\"]\n opt = 'r' => we shall issue the read(2), retrieving the 'secret' form the driver\n opt = 'w' => we shall issue the write(2), writing the secret message <secret-msg>\n  (max %d bytes)\n"
	.text
	.type	usage, @function
usage:
.LFB6:
	.cfi_startproc
	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	rax, QWORD PTR stderr[rip]
	mov	rdx, QWORD PTR -8[rbp]
	mov	ecx, 128
	lea	rsi, .LC0[rip]
	mov	rdi, rax
	mov	eax, 0
	call	fprintf@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	usage, .-usage
	.section	.rodata
	.align 8
.LC1:
	.string	"%s: too big a secret (%zu bytes); pl restrict to %d bytes max\n"
.LC2:
	.string	"%s: open(2) on %s failed\n"
.LC3:
	.string	"open"
.LC4:
	.string	"read-only"
.LC5:
	.string	"write-only"
	.align 8
.LC6:
	.string	"Device file %s opened (in %s mode): fd=%d\n"
.LC7:
	.string	"%s: out of memory!\n"
.LC8:
	.string	"read failed"
.LC9:
	.string	"Tip: see kernel log\n"
.LC10:
	.string	"%s: read %zd bytes from %s\n"
.LC11:
	.string	"The 'secret' is:\n \"%.*s\"\n"
.LC12:
	.string	"write failed"
.LC13:
	.string	"%s: wrote %zd bytes to %s\n"
	.align 8
.LC14:
	.string	"%s:%d: stayin' alive (in pause()) ... \n"
	.text
	.globl	main
	.type	main, @function
main:
.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, 64
	mov	DWORD PTR -52[rbp], edi
	mov	QWORD PTR -64[rbp], rsi
	mov	BYTE PTR -33[rbp], 114
	mov	DWORD PTR -32[rbp], 0
	mov	QWORD PTR -16[rbp], 0
	mov	QWORD PTR -24[rbp], 0
	cmp	DWORD PTR -52[rbp], 2
	jg	.L3
	mov	rax, QWORD PTR -64[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rdi, rax
	call	usage
	mov	edi, 1
	call	exit@PLT
.L3:
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 8
	mov	rax, QWORD PTR [rax]
	movzx	eax, BYTE PTR [rax]
	mov	BYTE PTR -33[rbp], al
	cmp	BYTE PTR -33[rbp], 114
	je	.L4
	cmp	BYTE PTR -33[rbp], 119
	je	.L4
	mov	rax, QWORD PTR -64[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rdi, rax
	call	usage
	mov	edi, 1
	call	exit@PLT
.L4:
	cmp	BYTE PTR -33[rbp], 119
	jne	.L5
	cmp	DWORD PTR -52[rbp], 4
	jne	.L6
.L5:
	cmp	BYTE PTR -33[rbp], 114
	jne	.L7
	cmp	DWORD PTR -52[rbp], 3
	je	.L7
.L6:
	mov	rax, QWORD PTR -64[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rdi, rax
	call	usage
	mov	edi, 1
	call	exit@PLT
.L7:
	cmp	BYTE PTR -33[rbp], 119
	jne	.L8
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 24
	mov	rax, QWORD PTR [rax]
	mov	esi, 128
	mov	rdi, rax
	call	strnlen@PLT
	cmp	rax, 128
	jbe	.L8
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 24
	mov	rax, QWORD PTR [rax]
	mov	esi, 128
	mov	rdi, rax
	call	strnlen@PLT
	mov	rcx, rax
	mov	rax, QWORD PTR -64[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR stderr[rip]
	mov	r8d, 128
	lea	rsi, .LC1[rip]
	mov	rdi, rax
	mov	eax, 0
	call	fprintf@PLT
	mov	edi, 1
	call	exit@PLT
.L8:
	cmp	BYTE PTR -33[rbp], 119
	jne	.L9
	mov	DWORD PTR -32[rbp], 1
.L9:
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 16
	mov	rax, QWORD PTR [rax]
	mov	ecx, DWORD PTR -32[rbp]
	mov	edx, 0
	mov	esi, ecx
	mov	rdi, rax
	mov	eax, 0
	call	open@PLT
	mov	DWORD PTR -28[rbp], eax
	cmp	DWORD PTR -28[rbp], -1
	jne	.L10
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 16
	mov	rcx, QWORD PTR [rax]
	mov	rax, QWORD PTR -64[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR stderr[rip]
	lea	rsi, .LC2[rip]
	mov	rdi, rax
	mov	eax, 0
	call	fprintf@PLT
	lea	rdi, .LC3[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L10:
	cmp	DWORD PTR -32[rbp], 0
	jne	.L11
	lea	rax, .LC4[rip]
	jmp	.L12
.L11:
	lea	rax, .LC5[rip]
.L12:
	mov	rdx, QWORD PTR -64[rbp]
	add	rdx, 16
	mov	rsi, QWORD PTR [rdx]
	mov	edx, DWORD PTR -28[rbp]
	mov	ecx, edx
	mov	rdx, rax
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	printf@PLT
	cmp	BYTE PTR -33[rbp], 119
	jne	.L13
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 24
	mov	rax, QWORD PTR [rax]
	mov	esi, 128
	mov	rdi, rax
	call	strnlen@PLT
	add	rax, 1
	mov	QWORD PTR -24[rbp], rax
	cmp	QWORD PTR -24[rbp], 128
	jbe	.L14
	mov	QWORD PTR -24[rbp], 128
	jmp	.L14
.L13:
	mov	QWORD PTR -24[rbp], 128
.L14:
	mov	rax, QWORD PTR -24[rbp]
	mov	rdi, rax
	call	malloc@PLT
	mov	QWORD PTR -16[rbp], rax
	cmp	QWORD PTR -16[rbp], 0
	jne	.L15
	mov	rax, QWORD PTR -64[rbp]
	mov	rdx, QWORD PTR [rax]
	mov	rax, QWORD PTR stderr[rip]
	lea	rsi, .LC7[rip]
	mov	rdi, rax
	mov	eax, 0
	call	fprintf@PLT
	mov	eax, DWORD PTR -28[rbp]
	mov	edi, eax
	call	close@PLT
	mov	edi, 1
	call	exit@PLT
.L15:
	cmp	BYTE PTR -33[rbp], 114
	jne	.L16
	mov	rdx, QWORD PTR -24[rbp]
	mov	rcx, QWORD PTR -16[rbp]
	mov	eax, DWORD PTR -28[rbp]
	mov	rsi, rcx
	mov	edi, eax
	call	read@PLT
	mov	QWORD PTR -8[rbp], rax
	cmp	QWORD PTR -8[rbp], 0
	jns	.L17
	lea	rdi, .LC8[rip]
	call	perror@PLT
	mov	rax, QWORD PTR stderr[rip]
	mov	rcx, rax
	mov	edx, 20
	mov	esi, 1
	lea	rdi, .LC9[rip]
	call	fwrite@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	rdi, rax
	call	free@PLT
	mov	eax, DWORD PTR -28[rbp]
	mov	edi, eax
	call	close@PLT
	mov	edi, 1
	call	exit@PLT
.L17:
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 16
	mov	rcx, QWORD PTR [rax]
	mov	rax, QWORD PTR -64[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rdx, QWORD PTR -8[rbp]
	mov	rsi, rax
	lea	rdi, .LC10[rip]
	mov	eax, 0
	call	printf@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	ecx, eax
	mov	rax, QWORD PTR -16[rbp]
	mov	rdx, rax
	mov	esi, ecx
	lea	rdi, .LC11[rip]
	mov	eax, 0
	call	printf@PLT
	jmp	.L18
.L16:
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 24
	mov	rcx, QWORD PTR [rax]
	mov	rdx, QWORD PTR -24[rbp]
	mov	rax, QWORD PTR -16[rbp]
	mov	rsi, rcx
	mov	rdi, rax
	call	strncpy@PLT
	mov	rdx, QWORD PTR -24[rbp]
	mov	rcx, QWORD PTR -16[rbp]
	mov	eax, DWORD PTR -28[rbp]
	mov	rsi, rcx
	mov	edi, eax
	call	write@PLT
	mov	QWORD PTR -8[rbp], rax
	cmp	QWORD PTR -8[rbp], 0
	jns	.L19
	lea	rdi, .LC12[rip]
	call	perror@PLT
	mov	rax, QWORD PTR stderr[rip]
	mov	rcx, rax
	mov	edx, 20
	mov	esi, 1
	lea	rdi, .LC9[rip]
	call	fwrite@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	rdi, rax
	call	free@PLT
	mov	eax, DWORD PTR -28[rbp]
	mov	edi, eax
	call	close@PLT
	mov	edi, 1
	call	exit@PLT
.L19:
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 16
	mov	rcx, QWORD PTR [rax]
	mov	rax, QWORD PTR -64[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rdx, QWORD PTR -8[rbp]
	mov	rsi, rax
	lea	rdi, .LC13[rip]
	mov	eax, 0
	call	printf@PLT
.L18:
	mov	eax, DWORD PTR stay_alive[rip]
	test	eax, eax
	je	.L20
	call	getpid@PLT
	mov	edx, eax
	mov	rax, QWORD PTR -64[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rsi, rax
	lea	rdi, .LC14[rip]
	mov	eax, 0
	call	printf@PLT
	call	pause@PLT
.L20:
	mov	rax, QWORD PTR -16[rbp]
	mov	rdi, rax
	call	free@PLT
	mov	eax, DWORD PTR -28[rbp]
	mov	edi, eax
	call	close@PLT
	mov	edi, 0
	call	exit@PLT
	.cfi_endproc
.LFE7:
	.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	"670736.c"
	.text
	.local	stay_alive
	.comm	stay_alive,4,4
	.section	.rodata
	.align	2
.LC0:
	.ascii	"Usage: %s opt=read/write device_file [\"secret-msg\""
	.ascii	"]\012 opt = 'r' => we shall issue the read(2), retr"
	.ascii	"ieving the 'secret' form the driver\012 opt = 'w' ="
	.ascii	"> we shall issue the write(2), writing the secret m"
	.ascii	"essage <secret-msg>\012  (max %d bytes)\012\000"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	usage, %function
usage:
	@ 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, .L2
	ldr	r0, [r3]
	mov	r3, #128
	ldr	r2, [fp, #-8]
	ldr	r1, .L2+4
	bl	fprintf
	nop
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L3:
	.align	2
.L2:
	.word	stderr
	.word	.LC0
	.size	usage, .-usage
	.section	.rodata
	.align	2
.LC1:
	.ascii	"%s: too big a secret (%zu bytes); pl restrict to %d"
	.ascii	" bytes max\012\000"
	.align	2
.LC2:
	.ascii	"%s: open(2) on %s failed\012\000"
	.align	2
.LC3:
	.ascii	"open\000"
	.align	2
.LC4:
	.ascii	"read-only\000"
	.align	2
.LC5:
	.ascii	"write-only\000"
	.align	2
.LC6:
	.ascii	"Device file %s opened (in %s mode): fd=%d\012\000"
	.align	2
.LC7:
	.ascii	"%s: out of memory!\012\000"
	.align	2
.LC8:
	.ascii	"read failed\000"
	.align	2
.LC9:
	.ascii	"Tip: see kernel log\012\000"
	.align	2
.LC10:
	.ascii	"%s: read %zd bytes from %s\012\000"
	.align	2
.LC11:
	.ascii	"The 'secret' is:\012 \"%.*s\"\012\000"
	.align	2
.LC12:
	.ascii	"write failed\000"
	.align	2
.LC13:
	.ascii	"%s: wrote %zd bytes to %s\012\000"
	.align	2
.LC14:
	.ascii	"%s:%d: stayin' alive (in pause()) ... \012\000"
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 32
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, r5, fp, lr}
	add	fp, sp, #12
	sub	sp, sp, #40
	str	r0, [fp, #-40]
	str	r1, [fp, #-44]
	mov	r3, #114
	strb	r3, [fp, #-33]
	mov	r3, #0
	str	r3, [fp, #-32]
	mov	r3, #0
	str	r3, [fp, #-24]
	mov	r3, #0
	str	r3, [fp, #-28]
	ldr	r3, [fp, #-40]
	cmp	r3, #2
	bgt	.L5
	ldr	r3, [fp, #-44]
	ldr	r3, [r3]
	mov	r0, r3
	bl	usage
	mov	r0, #1
	bl	exit
.L5:
	ldr	r3, [fp, #-44]
	add	r3, r3, #4
	ldr	r3, [r3]
	ldrb	r3, [r3]
	strb	r3, [fp, #-33]
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	cmp	r3, #114
	beq	.L6
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	cmp	r3, #119
	beq	.L6
	ldr	r3, [fp, #-44]
	ldr	r3, [r3]
	mov	r0, r3
	bl	usage
	mov	r0, #1
	bl	exit
.L6:
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	cmp	r3, #119
	bne	.L7
	ldr	r3, [fp, #-40]
	cmp	r3, #4
	bne	.L8
.L7:
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	cmp	r3, #114
	bne	.L9
	ldr	r3, [fp, #-40]
	cmp	r3, #3
	beq	.L9
.L8:
	ldr	r3, [fp, #-44]
	ldr	r3, [r3]
	mov	r0, r3
	bl	usage
	mov	r0, #1
	bl	exit
.L9:
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	cmp	r3, #119
	bne	.L10
	ldr	r3, [fp, #-44]
	add	r3, r3, #12
	ldr	r3, [r3]
	mov	r1, #128
	mov	r0, r3
	bl	strnlen
	mov	r3, r0
	cmp	r3, #128
	bls	.L10
	ldr	r3, .L23
	ldr	r4, [r3]
	ldr	r3, [fp, #-44]
	ldr	r5, [r3]
	ldr	r3, [fp, #-44]
	add	r3, r3, #12
	ldr	r3, [r3]
	mov	r1, #128
	mov	r0, r3
	bl	strnlen
	mov	r3, r0
	mov	r2, #128
	str	r2, [sp]
	mov	r2, r5
	ldr	r1, .L23+4
	mov	r0, r4
	bl	fprintf
	mov	r0, #1
	bl	exit
.L10:
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	cmp	r3, #119
	bne	.L11
	mov	r3, #1
	str	r3, [fp, #-32]
.L11:
	ldr	r3, [fp, #-44]
	add	r3, r3, #8
	ldr	r3, [r3]
	mov	r2, #0
	ldr	r1, [fp, #-32]
	mov	r0, r3
	bl	open
	str	r0, [fp, #-20]
	ldr	r3, [fp, #-20]
	cmn	r3, #1
	bne	.L12
	ldr	r3, .L23
	ldr	r0, [r3]
	ldr	r3, [fp, #-44]
	ldr	r2, [r3]
	ldr	r3, [fp, #-44]
	add	r3, r3, #8
	ldr	r3, [r3]
	ldr	r1, .L23+8
	bl	fprintf
	ldr	r0, .L23+12
	bl	perror
	mov	r0, #1
	bl	exit
.L12:
	ldr	r3, [fp, #-44]
	add	r3, r3, #8
	ldr	r1, [r3]
	ldr	r3, [fp, #-32]
	cmp	r3, #0
	bne	.L13
	ldr	r2, .L23+16
	b	.L14
.L13:
	ldr	r2, .L23+20
.L14:
	ldr	r3, [fp, #-20]
	ldr	r0, .L23+24
	bl	printf
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	cmp	r3, #119
	bne	.L15
	ldr	r3, [fp, #-44]
	add	r3, r3, #12
	ldr	r3, [r3]
	mov	r1, #128
	mov	r0, r3
	bl	strnlen
	mov	r3, r0
	add	r3, r3, #1
	str	r3, [fp, #-28]
	ldr	r3, [fp, #-28]
	cmp	r3, #128
	bls	.L16
	mov	r3, #128
	str	r3, [fp, #-28]
	b	.L16
.L15:
	mov	r3, #128
	str	r3, [fp, #-28]
.L16:
	ldr	r0, [fp, #-28]
	bl	malloc
	mov	r3, r0
	str	r3, [fp, #-24]
	ldr	r3, [fp, #-24]
	cmp	r3, #0
	bne	.L17
	ldr	r3, .L23
	ldr	r0, [r3]
	ldr	r3, [fp, #-44]
	ldr	r3, [r3]
	mov	r2, r3
	ldr	r1, .L23+28
	bl	fprintf
	ldr	r0, [fp, #-20]
	bl	close
	mov	r0, #1
	bl	exit
.L17:
	ldrb	r3, [fp, #-33]	@ zero_extendqisi2
	cmp	r3, #114
	bne	.L18
	ldr	r2, [fp, #-28]
	ldr	r1, [fp, #-24]
	ldr	r0, [fp, #-20]
	bl	read
	str	r0, [fp, #-16]
	ldr	r3, [fp, #-16]
	cmp	r3, #0
	bge	.L19
	ldr	r0, .L23+32
	bl	perror
	ldr	r3, .L23
	ldr	r3, [r3]
	mov	r2, #20
	mov	r1, #1
	ldr	r0, .L23+36
	bl	fwrite
	ldr	r0, [fp, #-24]
	bl	free
	ldr	r0, [fp, #-20]
	bl	close
	mov	r0, #1
	bl	exit
.L19:
	ldr	r3, [fp, #-44]
	ldr	r1, [r3]
	ldr	r3, [fp, #-44]
	add	r3, r3, #8
	ldr	r3, [r3]
	ldr	r2, [fp, #-16]
	ldr	r0, .L23+40
	bl	printf
	ldr	r2, [fp, #-24]
	ldr	r1, [fp, #-16]
	ldr	r0, .L23+44
	bl	printf
	b	.L20
.L18:
	ldr	r3, [fp, #-44]
	add	r3, r3, #12
	ldr	r3, [r3]
	ldr	r2, [fp, #-28]
	mov	r1, r3
	ldr	r0, [fp, #-24]
	bl	strncpy
	ldr	r2, [fp, #-28]
	ldr	r1, [fp, #-24]
	ldr	r0, [fp, #-20]
	bl	write
	str	r0, [fp, #-16]
	ldr	r3, [fp, #-16]
	cmp	r3, #0
	bge	.L21
	ldr	r0, .L23+48
	bl	perror
	ldr	r3, .L23
	ldr	r3, [r3]
	mov	r2, #20
	mov	r1, #1
	ldr	r0, .L23+36
	bl	fwrite
	ldr	r0, [fp, #-24]
	bl	free
	ldr	r0, [fp, #-20]
	bl	close
	mov	r0, #1
	bl	exit
.L21:
	ldr	r3, [fp, #-44]
	ldr	r1, [r3]
	ldr	r3, [fp, #-44]
	add	r3, r3, #8
	ldr	r3, [r3]
	ldr	r2, [fp, #-16]
	ldr	r0, .L23+52
	bl	printf
.L20:
	ldr	r3, .L23+56
	ldr	r3, [r3]
	cmp	r3, #0
	beq	.L22
	ldr	r3, [fp, #-44]
	ldr	r4, [r3]
	bl	getpid
	mov	r3, r0
	mov	r2, r3
	mov	r1, r4
	ldr	r0, .L23+60
	bl	printf
	bl	pause
.L22:
	ldr	r0, [fp, #-24]
	bl	free
	ldr	r0, [fp, #-20]
	bl	close
	mov	r0, #0
	bl	exit
.L24:
	.align	2
.L23:
	.word	stderr
	.word	.LC1
	.word	.LC2
	.word	.LC3
	.word	.LC4
	.word	.LC5
	.word	.LC6
	.word	.LC7
	.word	.LC8
	.word	.LC9
	.word	.LC10
	.word	.LC11
	.word	.LC12
	.word	.LC13
	.word	stay_alive
	.word	.LC14
	.size	main, .-main
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
