	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function gp2ap020a00f_write_event_threshold
_gp2ap020a00f_write_event_threshold:    ## @gp2ap020a00f_write_event_threshold
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r15d
	movq	%rdi, %r14
	testl	%edx, %edx
	je	LBB0_1
## %bb.2:
	movq	_GP2AP020A00F_FLAG_LUX_MODE_HI@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	12(%r14), %rsi
	callq	_test_bit
	movq	(%r14), %rcx
	movl	%r15d, %edx
	movl	(%rcx,%rdx,4), %ecx
	testq	%rax, %rax
	je	LBB0_6
## %bb.3:
	movq	_GP2AP020A00F_THRESH_PL@GOTPCREL(%rip), %rax
	cmpl	%r15d, (%rax)
	je	LBB0_6
## %bb.4:
	movq	_GP2AP020A00F_THRESH_PH@GOTPCREL(%rip), %rax
	cmpl	%r15d, (%rax)
	je	LBB0_6
## %bb.5:
	leal	15(%rcx), %edi
	testl	%ecx, %ecx
	cmovnsl	%ecx, %edi
	sarl	$4, %edi
	jmp	LBB0_7
LBB0_1:
	xorl	%edi, %edi
	jmp	LBB0_7
LBB0_6:
	cmpl	$16000, %ecx                    ## imm = 0x3E80
	movl	$16000, %edi                    ## imm = 0x3E80
	cmovll	%ecx, %edi
LBB0_7:
	callq	_cpu_to_le16
	movq	%rax, -32(%rbp)
	movl	8(%r14), %ebx
	movl	%r15d, %edi
	callq	_GP2AP020A00F_THRESH_REG
	leaq	-32(%rbp), %rdx
	movl	%ebx, %edi
	movl	%eax, %esi
	movl	$2, %ecx
	callq	_regmap_bulk_write
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_GP2AP020A00F_FLAG_LUX_MODE_HI,4,2 ## @GP2AP020A00F_FLAG_LUX_MODE_HI
	.comm	_GP2AP020A00F_THRESH_PL,4,2     ## @GP2AP020A00F_THRESH_PL
	.comm	_GP2AP020A00F_THRESH_PH,4,2     ## @GP2AP020A00F_THRESH_PH
	.no_dead_strip	_gp2ap020a00f_write_event_threshold
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function gp2ap020a00f_write_event_threshold
_gp2ap020a00f_write_event_threshold:    ; @gp2ap020a00f_write_event_threshold
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x1
	mov	x20, x0
	cbz	w2, LBB0_3
; %bb.1:
Lloh0:
	adrp	x8, _GP2AP020A00F_FLAG_LUX_MODE_HI@GOTPAGE
Lloh1:
	ldr	x8, [x8, _GP2AP020A00F_FLAG_LUX_MODE_HI@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
	add	x1, x20, #12
	bl	_test_bit
Lloh3:
	adrp	x8, _GP2AP020A00F_THRESH_PL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _GP2AP020A00F_THRESH_PL@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x8]
Lloh6:
	adrp	x8, _GP2AP020A00F_THRESH_PH@GOTPAGE
Lloh7:
	ldr	x8, [x8, _GP2AP020A00F_THRESH_PH@GOTPAGEOFF]
Lloh8:
	ldr	w10, [x8]
	ldr	x8, [x20]
	ldr	w8, [x8, w19, uxtw #2]
	cmp	x0, #0
	ccmp	w9, w19, #4, ne
	ccmp	w10, w19, #4, ne
	b.ne	LBB0_4
; %bb.2:
	mov	w9, #16000
	cmp	w8, w9
	csel	w0, w8, w9, lt
	b	LBB0_5
LBB0_3:
	mov	w0, #0
	b	LBB0_5
LBB0_4:
	add	w9, w8, #15
	cmp	w8, #0
	csel	w8, w9, w8, lt
	asr	w0, w8, #4
LBB0_5:
	bl	_cpu_to_le16
	str	x0, [sp, #8]
	ldr	w20, [x20, #8]
	mov	x0, x19
	bl	_GP2AP020A00F_THRESH_REG
	mov	x1, x0
	add	x2, sp, #8
	mov	x0, x20
	mov	w3, #2
	bl	_regmap_bulk_write
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_GP2AP020A00F_FLAG_LUX_MODE_HI,4,2 ; @GP2AP020A00F_FLAG_LUX_MODE_HI
	.comm	_GP2AP020A00F_THRESH_PL,4,2     ; @GP2AP020A00F_THRESH_PL
	.comm	_GP2AP020A00F_THRESH_PH,4,2     ; @GP2AP020A00F_THRESH_PH
	.no_dead_strip	_gp2ap020a00f_write_event_threshold
.subsections_via_symbols
