	.file	"extr_cx25821-medusa-video.c_medusa_set_brightness.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.globl	medusa_set_brightness
	.type	medusa_set_brightness, @function
medusa_set_brightness:
.LFB0:
	.cfi_startproc
	endbr64
	push	r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	mov	r12d, esi
	push	rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	mov	rbp, rdi
	push	rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	mov	ebx, edx
	sub	rsp, 16
	.cfi_def_cfa_offset 48
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 8[rsp], rax
	xor	eax, eax
	mov	DWORD PTR [rsp], 0
	mov	DWORD PTR 4[rsp], 0
	call	mutex_lock@PLT
	mov	esi, DWORD PTR VIDEO_PROCAMP_MAX[rip]
	cmp	esi, r12d
	jl	.L2
	mov	edi, DWORD PTR VIDEO_PROCAMP_MIN[rip]
	cmp	edi, r12d
	jg	.L2
	mov	r8d, DWORD PTR SIGNED_BYTE_MAX[rip]
	mov	r9, rsp
	mov	edx, r12d
	sal	ebx, 9
	mov	ecx, DWORD PTR SIGNED_BYTE_MIN[rip]
	movsx	rbx, ebx
	call	mapM@PLT
	mov	edi, DWORD PTR [rsp]
	mov	esi, 8
	mov	r12d, eax
	call	convert_to_twos@PLT
	mov	rsi, QWORD PTR VDEC_A_BRITE_CTRL[rip]
	mov	rdi, QWORD PTR 8[rbp]
	lea	rdx, 4[rsp]
	mov	DWORD PTR [rsp], eax
	add	rsi, rbx
	call	cx25821_i2c_read@PLT
	mov	edx, DWORD PTR [rsp]
	mov	rdi, QWORD PTR 8[rbp]
	xor	al, al
	add	rbx, QWORD PTR VDEC_A_BRITE_CTRL[rip]
	or	edx, eax
	mov	rsi, rbx
	call	cx25821_i2c_write@PLT
	mov	rdi, rbp
	or	r12d, eax
	call	mutex_unlock@PLT
.L1:
	mov	rax, QWORD PTR 8[rsp]
	xor	rax, QWORD PTR fs:40
	jne	.L8
	add	rsp, 16
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	mov	eax, r12d
	pop	rbx
	.cfi_def_cfa_offset 24
	pop	rbp
	.cfi_def_cfa_offset 16
	pop	r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	.cfi_restore_state
	mov	rdi, rbp
	mov	r12d, -1
	call	mutex_unlock@PLT
	jmp	.L1
.L8:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	medusa_set_brightness, .-medusa_set_brightness
	.comm	VIDEO_PROCAMP_MIN,4,4
	.comm	VIDEO_PROCAMP_MAX,4,4
	.comm	VDEC_A_BRITE_CTRL,8,8
	.comm	SIGNED_BYTE_MIN,4,4
	.comm	SIGNED_BYTE_MAX,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_cx25821-medusa-video.c_medusa_set_brightness.c"
	.text
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	medusa_set_brightness
	.syntax unified
	.arm
	.fpu softvfp
	.type	medusa_set_brightness, %function
medusa_set_brightness:
	@ args = 0, pretend = 0, frame = 16
	@ frame_needed = 0, uses_anonymous_args = 0
	mov	r3, #0
	push	{r4, r5, r6, r7, lr}
	mov	r5, r1
	mov	r4, r2
	ldr	r2, .L9
	sub	sp, sp, #28
	ldr	r2, [r2]
	str	r2, [sp, #20]
	mov	r2,#0
	mov	r6, r0
	str	r3, [sp, #12]
	str	r3, [sp, #16]
	bl	mutex_lock
	ldr	r3, .L9+4
	ldr	r1, [r3]
	cmp	r1, r5
	blt	.L2
	ldr	r3, .L9+8
	ldr	r0, [r3]
	cmp	r0, r5
	bgt	.L2
	ldr	r2, .L9+12
	ldr	r3, .L9+16
	ldr	lr, [r2]
	add	ip, sp, #12
	str	lr, [sp]
	mov	r2, r5
	ldr	r3, [r3]
	str	ip, [sp, #4]
	bl	mapM
	mov	r1, #8
	mov	r7, r0
	ldr	r0, [sp, #12]
	bl	convert_to_twos
	mov	r3, r0
	ldr	r5, .L9+20
	add	r2, sp, #16
	ldr	r1, [r5]
	ldr	r0, [r6, #4]
	add	r1, r1, r4, lsl #9
	str	r3, [sp, #12]
	bl	cx25821_i2c_read
	ldr	r1, [r5]
	ldr	r2, [sp, #12]
	lsl	r4, r4, #9
	bic	r0, r0, #255
	add	r1, r4, r1
	orr	r2, r0, r2
	ldr	r0, [r6, #4]
	bl	cx25821_i2c_write
	mov	r4, r0
	mov	r0, r6
	orr	r4, r7, r4
	bl	mutex_unlock
.L1:
	ldr	r3, .L9
	ldr	r2, [r3]
	ldr	r3, [sp, #20]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L8
	mov	r0, r4
	add	sp, sp, #28
	@ sp needed
	pop	{r4, r5, r6, r7, pc}
.L2:
	mov	r0, r6
	bl	mutex_unlock
	mvn	r4, #0
	b	.L1
.L8:
	bl	__stack_chk_fail
.L10:
	.align	2
.L9:
	.word	.LC0
	.word	VIDEO_PROCAMP_MAX
	.word	VIDEO_PROCAMP_MIN
	.word	SIGNED_BYTE_MAX
	.word	SIGNED_BYTE_MIN
	.word	VDEC_A_BRITE_CTRL
	.size	medusa_set_brightness, .-medusa_set_brightness
	.comm	VIDEO_PROCAMP_MIN,4,4
	.comm	VIDEO_PROCAMP_MAX,4,4
	.comm	VDEC_A_BRITE_CTRL,4,4
	.comm	SIGNED_BYTE_MIN,4,4
	.comm	SIGNED_BYTE_MAX,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
