	.file	"extr_turris-mox-rwtm.c_mox_hwrng_read.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	mox_hwrng_read, @function
mox_hwrng_read:
.LFB0:
	.cfi_startproc
	endbr64
	push	r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	push	r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	push	r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	push	rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	mov	rbp, rsi
	push	rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	mov	ebx, 4096
	sub	rsp, 32
	.cfi_def_cfa_offset 80
	mov	r14, QWORD PTR [rdi]
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 24[rsp], rax
	xor	eax, eax
	mov	eax, DWORD PTR MBOX_CMD_GET_RANDOM[rip]
	cmp	rdx, 4096
	cmovbe	rbx, rdx
	lea	r13, 4[r14]
	mov	DWORD PTR 8[rsp], eax
	mov	rax, QWORD PTR [rsp]
	mov	rdi, r13
	mov	DWORD PTR [rax], 1
	mov	edx, DWORD PTR [r14]
	mov	DWORD PTR 4[rax], edx
	lea	edx, 3[rbx]
	and	edx, -4
	mov	DWORD PTR 8[rax], edx
	test	ecx, ecx
	jne	.L2
	call	mutex_trylock@PLT
	mov	r12d, DWORD PTR EBUSY[rip]
	neg	r12d
	test	eax, eax
	je	.L1
.L3:
	mov	edi, DWORD PTR 20[r14]
	mov	rsi, rsp
	call	mbox_send_message@PLT
	mov	r12d, eax
	test	eax, eax
	js	.L5
	lea	rdi, 16[r14]
	call	wait_for_completion_interruptible@PLT
	mov	r12d, eax
	test	eax, eax
	js	.L5
	mov	esi, DWORD PTR 12[r14]
	mov	edi, DWORD PTR MBOX_CMD_GET_RANDOM[rip]
	call	mox_get_status@PLT
	mov	r12d, eax
	test	eax, eax
	js	.L5
	mov	esi, DWORD PTR 8[r14]
	mov	rdx, rbx
	mov	rdi, rbp
	mov	r12d, ebx
	call	memcpy@PLT
	.p2align 4,,10
	.p2align 3
.L5:
	mov	rdi, r13
	call	mutex_unlock@PLT
.L1:
	mov	rax, QWORD PTR 24[rsp]
	xor	rax, QWORD PTR fs:40
	jne	.L9
	add	rsp, 32
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	mov	eax, r12d
	pop	rbx
	.cfi_def_cfa_offset 40
	pop	rbp
	.cfi_def_cfa_offset 32
	pop	r12
	.cfi_def_cfa_offset 24
	pop	r13
	.cfi_def_cfa_offset 16
	pop	r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	.cfi_restore_state
	call	mutex_lock@PLT
	jmp	.L3
.L9:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	mox_hwrng_read, .-mox_hwrng_read
	.comm	MBOX_CMD_GET_RANDOM,4,4
	.comm	EBUSY,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.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, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_turris-mox-rwtm.c_mox_hwrng_read.c"
	.text
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	mox_hwrng_read, %function
mox_hwrng_read:
	@ args = 0, pretend = 0, frame = 16
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, lr}
	ldr	r7, [r0]
	cmp	r2, #4096
	mov	r0, #1
	movcc	r5, r2
	movcs	r5, #4096
	mov	r6, r7
	ldr	r9, .L11
	sub	sp, sp, #20
	ldr	r2, [sp, #4]
	ldr	ip, [r9]
	ldr	lr, .L11+4
	cmp	r3, #0
	ldr	lr, [lr]
	str	lr, [sp, #12]
	mov	lr,#0
	str	ip, [sp, #8]
	str	r0, [r2]
	ldr	ip, [r6], #4
	add	r0, r5, #3
	bic	r0, r0, #3
	str	r0, [r2, #8]
	mov	r8, r1
	mov	r0, r6
	str	ip, [r2, #4]
	bne	.L2
	bl	mutex_trylock
	cmp	r0, #0
	beq	.L9
.L3:
	ldr	r0, [r7, #20]
	add	r1, sp, #4
	bl	mbox_send_message
	subs	r4, r0, #0
	blt	.L5
	add	r0, r7, #16
	bl	wait_for_completion_interruptible
	subs	r4, r0, #0
	blt	.L5
	ldr	r0, [r9]
	ldr	r1, [r7, #12]
	bl	mox_get_status
	subs	r4, r0, #0
	blt	.L5
	mov	r0, r8
	mov	r2, r5
	ldr	r1, [r7, #8]
	bl	memcpy
	mov	r4, r5
.L5:
	mov	r0, r6
	bl	mutex_unlock
.L1:
	ldr	r3, .L11+4
	ldr	r2, [r3]
	ldr	r3, [sp, #12]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L10
	mov	r0, r4
	add	sp, sp, #20
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, pc}
.L2:
	bl	mutex_lock
	b	.L3
.L9:
	ldr	r3, .L11+8
	ldr	r4, [r3]
	rsb	r4, r4, #0
	b	.L1
.L10:
	bl	__stack_chk_fail
.L12:
	.align	2
.L11:
	.word	MBOX_CMD_GET_RANDOM
	.word	.LC0
	.word	EBUSY
	.size	mox_hwrng_read, .-mox_hwrng_read
	.comm	MBOX_CMD_GET_RANDOM,4,4
	.comm	EBUSY,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
