	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function opt3001_write_event_value
_opt3001_write_event_value:             ## @opt3001_write_event_value
	.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	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%r9d, %r13d
	movl	%ecx, %r15d
	callq	_iio_priv
	testl	%r13d, %r13d
	js	LBB0_1
## %bb.2:
	movq	%rax, %r12
	movl	16(%rbp), %ebx
	movq	%rax, %r14
	addq	$16, %r14
	movq	%r14, %rdi
	callq	_mutex_lock
	leaq	-44(%rbp), %rcx
	movq	%r12, %rdi
	movl	%r13d, %esi
	movl	%ebx, %edx
	callq	_opt3001_find_scale
	testl	%eax, %eax
	js	LBB0_3
## %bb.4:
	imull	$1000, %r13d, %eax              ## imm = 0x3E8
	movslq	16(%rbp), %rcx
	imulq	$274877907, %rcx, %rcx          ## imm = 0x10624DD3
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$38, %rcx
	addl	%edx, %ecx
	addl	%eax, %ecx
	movslq	%ecx, %rax
	imulq	$1717986919, %rax, %rax         ## imm = 0x66666667
	movq	%rax, %rcx
	shrq	$63, %rcx
	sarq	$34, %rax
	addl	%ecx, %eax
	movl	-44(%rbp), %ecx
	sarl	%cl, %eax
	cmpl	$129, %r15d
	je	LBB0_8
## %bb.5:
	cmpl	$128, %r15d
	jne	LBB0_7
## %bb.6:
	movq	_OPT3001_HIGH_LIMIT@GOTPCREL(%rip), %rdx
	movl	(%rdx), %r15d
	movl	%eax, (%r12)
	movl	-44(%rbp), %edx
	movl	%edx, 4(%r12)
	jmp	LBB0_9
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_12
LBB0_3:
	movl	%eax, %ebx
	movl	20(%r12), %edi
	leaq	L_.str(%rip), %rsi
	movl	%r13d, %edx
	movl	16(%rbp), %ecx
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_11
LBB0_8:
	movq	_OPT3001_LOW_LIMIT@GOTPCREL(%rip), %rdx
	movl	(%rdx), %r15d
	movl	%eax, 8(%r12)
	movl	%ecx, 12(%r12)
LBB0_9:
	shll	$12, %ecx
	orl	%eax, %ecx
	movl	24(%r12), %edi
	movl	%r15d, %esi
	movl	%ecx, %edx
	callq	_i2c_smbus_write_word_swapped
	movl	%eax, %ebx
	testl	%eax, %eax
	jns	LBB0_11
## %bb.10:
	movl	20(%r12), %edi
	leaq	L_.str.1(%rip), %rsi
	movl	%r15d, %edx
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_11
LBB0_7:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_11:
	movq	%r14, %rdi
	callq	_mutex_unlock
LBB0_12:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"can't find scale for %d.%06u\n"

	.comm	_OPT3001_HIGH_LIMIT,4,2         ## @OPT3001_HIGH_LIMIT
	.comm	_OPT3001_LOW_LIMIT,4,2          ## @OPT3001_LOW_LIMIT
L_.str.1:                               ## @.str.1
	.asciz	"failed to write register %02x\n"

	.no_dead_strip	_opt3001_write_event_value
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function opt3001_write_event_value
_opt3001_write_event_value:             ; @opt3001_write_event_value
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x24, x6
	mov	x23, x5
	mov	x21, x3
	bl	_iio_priv
	tbnz	w23, #31, LBB0_5
; %bb.1:
	mov	x20, x0
	add	x19, x0, #16
	mov	x0, x19
	bl	_mutex_lock
	add	x3, sp, #12
	mov	x0, x20
	mov	x1, x23
	mov	x2, x24
	bl	_opt3001_find_scale
	tbnz	w0, #31, LBB0_6
; %bb.2:
	mov	w8, #1000
	mov	w9, #19923
	movk	w9, #4194, lsl #16
	smull	x9, w24, w9
	lsr	x10, x9, #63
	asr	x9, x9, #38
	add	w9, w9, w10
	madd	w8, w23, w8, w9
	mov	w9, #26215
	movk	w9, #26214, lsl #16
	smull	x8, w8, w9
	lsr	x9, x8, #63
	asr	x8, x8, #34
	add	w9, w8, w9
	ldr	w8, [sp, #12]
	asr	w9, w9, w8
	cmp	w21, #129
	b.eq	LBB0_7
; %bb.3:
	cmp	w21, #128
	b.ne	LBB0_11
; %bb.4:
Lloh0:
	adrp	x10, _OPT3001_HIGH_LIMIT@GOTPAGE
Lloh1:
	ldr	x10, [x10, _OPT3001_HIGH_LIMIT@GOTPAGEOFF]
Lloh2:
	ldr	w21, [x10]
	str	w9, [x20]
	ldr	w10, [sp, #12]
	str	w10, [x20, #4]
	b	LBB0_8
LBB0_5:
Lloh3:
	adrp	x8, _EINVAL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	neg	w22, w8
	b	LBB0_13
LBB0_6:
	mov	x22, x0
	ldr	w0, [x20, #20]
	str	x24, [sp]
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x23
	b	LBB0_10
LBB0_7:
Lloh8:
	adrp	x10, _OPT3001_LOW_LIMIT@GOTPAGE
Lloh9:
	ldr	x10, [x10, _OPT3001_LOW_LIMIT@GOTPAGEOFF]
Lloh10:
	ldr	w21, [x10]
	stp	w9, w8, [x20, #8]
LBB0_8:
	orr	w2, w9, w8, lsl #12
	ldr	w0, [x20, #24]
	mov	x1, x21
	bl	_i2c_smbus_write_word_swapped
	mov	x22, x0
	tbz	w0, #31, LBB0_12
; %bb.9:
	ldr	w0, [x20, #20]
Lloh11:
	adrp	x1, l_.str.1@PAGE
Lloh12:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x2, x21
LBB0_10:
	bl	_dev_err
	b	LBB0_12
LBB0_11:
Lloh13:
	adrp	x8, _EINVAL@GOTPAGE
Lloh14:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
	neg	w22, w8
LBB0_12:
	mov	x0, x19
	bl	_mutex_unlock
LBB0_13:
	mov	x0, x22
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"can't find scale for %d.%06u\n"

	.comm	_OPT3001_HIGH_LIMIT,4,2         ; @OPT3001_HIGH_LIMIT
	.comm	_OPT3001_LOW_LIMIT,4,2          ; @OPT3001_LOW_LIMIT
l_.str.1:                               ; @.str.1
	.asciz	"failed to write register %02x\n"

	.no_dead_strip	_opt3001_write_event_value
.subsections_via_symbols
