	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_medusa_set_brightness          ## -- Begin function medusa_set_brightness
	.p2align	4, 0x90
_medusa_set_brightness:                 ## @medusa_set_brightness
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edx, %ebx
	movl	%esi, %edx
	movl	$0, -36(%rbp)
	movl	$0, -40(%rbp)
	movq	_VIDEO_PROCAMP_MAX@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$-1, %eax
	cmpl	%edx, %esi
	jl	LBB0_3
## %bb.1:
	movq	%rdi, %r14
	movq	_VIDEO_PROCAMP_MIN@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	cmpl	%edx, %edi
	jg	LBB0_3
## %bb.2:
	movq	_SIGNED_BYTE_MIN@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_SIGNED_BYTE_MAX@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	leaq	-36(%rbp), %r9
	callq	_mapM
	movl	%eax, %r15d
	movl	-36(%rbp), %edi
	movl	$8, %esi
	callq	_convert_to_twos
	movl	%eax, -36(%rbp)
	movq	(%r14), %rdi
	movq	_VDEC_A_BRITE_CTRL@GOTPCREL(%rip), %r12
	shll	$9, %ebx
	movslq	%ebx, %rbx
	movq	(%r12), %rsi
	addq	%rbx, %rsi
	leaq	-40(%rbp), %rdx
	callq	_cx25821_i2c_read
	andl	$-256, %eax
	movq	(%r14), %rdi
	addq	(%r12), %rbx
	orl	-36(%rbp), %eax
	movq	%rbx, %rsi
	movl	%eax, %edx
	callq	_cx25821_i2c_write
	orl	%r15d, %eax
LBB0_3:
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_VIDEO_PROCAMP_MAX,4,2          ## @VIDEO_PROCAMP_MAX
	.comm	_VIDEO_PROCAMP_MIN,4,2          ## @VIDEO_PROCAMP_MIN
	.comm	_SIGNED_BYTE_MIN,4,2            ## @SIGNED_BYTE_MIN
	.comm	_SIGNED_BYTE_MAX,4,2            ## @SIGNED_BYTE_MAX
	.comm	_VDEC_A_BRITE_CTRL,8,3          ## @VDEC_A_BRITE_CTRL
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_medusa_set_brightness          ; -- Begin function medusa_set_brightness
	.p2align	2
_medusa_set_brightness:                 ; @medusa_set_brightness
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	mov	x20, x2
	mov	x2, x1
	str	xzr, [sp, #8]
Lloh0:
	adrp	x8, _VIDEO_PROCAMP_MAX@GOTPAGE
Lloh1:
	ldr	x8, [x8, _VIDEO_PROCAMP_MAX@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	cmp	w1, w2
	b.lt	LBB0_2
; %bb.1:
	mov	x19, x0
Lloh3:
	adrp	x8, _VIDEO_PROCAMP_MIN@GOTPAGE
Lloh4:
	ldr	x8, [x8, _VIDEO_PROCAMP_MIN@GOTPAGEOFF]
Lloh5:
	ldr	w0, [x8]
	cmp	w0, w2
	b.le	LBB0_3
LBB0_2:
	mov	w0, #-1
	b	LBB0_4
LBB0_3:
Lloh6:
	adrp	x8, _SIGNED_BYTE_MIN@GOTPAGE
Lloh7:
	ldr	x8, [x8, _SIGNED_BYTE_MIN@GOTPAGEOFF]
Lloh8:
	ldr	w3, [x8]
Lloh9:
	adrp	x8, _SIGNED_BYTE_MAX@GOTPAGE
Lloh10:
	ldr	x8, [x8, _SIGNED_BYTE_MAX@GOTPAGEOFF]
Lloh11:
	ldr	w4, [x8]
	add	x5, sp, #12
	bl	_mapM
	mov	x21, x0
	ldr	w0, [sp, #12]
	mov	w1, #8
	bl	_convert_to_twos
	str	w0, [sp, #12]
	ldr	x0, [x19]
Lloh12:
	adrp	x22, _VDEC_A_BRITE_CTRL@GOTPAGE
Lloh13:
	ldr	x22, [x22, _VDEC_A_BRITE_CTRL@GOTPAGEOFF]
	ldr	x8, [x22]
	lsl	w9, w20, #9
	sxtw	x20, w9
	add	x1, x8, x20
	add	x2, sp, #8
	bl	_cx25821_i2c_read
	and	w8, w0, #0xffffff00
	ldr	x0, [x19]
	ldr	x9, [x22]
	add	x1, x9, x20
	ldr	w9, [sp, #12]
	orr	w2, w9, w8
	bl	_cx25821_i2c_write
	orr	w0, w0, w21
LBB0_4:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.cfi_endproc
                                        ; -- End function
	.comm	_VIDEO_PROCAMP_MAX,4,2          ; @VIDEO_PROCAMP_MAX
	.comm	_VIDEO_PROCAMP_MIN,4,2          ; @VIDEO_PROCAMP_MIN
	.comm	_SIGNED_BYTE_MIN,4,2            ; @SIGNED_BYTE_MIN
	.comm	_SIGNED_BYTE_MAX,4,2            ; @SIGNED_BYTE_MAX
	.comm	_VDEC_A_BRITE_CTRL,8,3          ; @VDEC_A_BRITE_CTRL
.subsections_via_symbols
