	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function idt_csr_write
_idt_csr_write:                         ## @idt_csr_write
	.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
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edx, %r14d
	movl	%esi, %r12d
	movq	%rdi, %rbx
	movq	32(%rdi), %r15
	movq	_CCODE_CSR@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	(%rdi), %eax
	movl	%eax, -64(%rbp)
	leaq	-80(%rbp), %rax
	movq	%rax, -56(%rbp)
	addq	$24, %rdi
	movq	%rdi, -48(%rbp)                 ## 8-byte Spill
	callq	_mutex_lock
	movq	_CSR_WR_CNT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -60(%rbp)
	movq	_CSR_OP_WRITE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	4(%rbx), %eax
	movl	%eax, -80(%rbp)
	movl	%r12d, %edi
	callq	_cpu_to_le16
	movl	%eax, -72(%rbp)
	movl	%r14d, %edi
	callq	_cpu_to_le32
	movl	%eax, -76(%rbp)
	leaq	-64(%rbp), %rsi
	movq	%rbx, %rdi
	callq	*8(%rbx)
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movl	%eax, %r13d
	movl	%r12d, %edi
	callq	_CSR_REAL_ADDR
	leaq	L_.str(%rip), %rsi
	movq	%r15, %rdi
	movl	%eax, %edx
	movl	%r14d, %ecx
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_10
LBB0_2:
	movq	_CSR_WRRD_CNT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -60(%rbp)
	movq	_CSR_OP_READ@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	4(%rbx), %eax
	movl	%eax, -80(%rbp)
	leaq	-64(%rbp), %rsi
	movq	%rbx, %rdi
	callq	*8(%rbx)
	testl	%eax, %eax
	je	LBB0_5
## %bb.3:
	movl	%eax, %r13d
	movl	%r12d, %edi
	callq	_CSR_REAL_ADDR
	leaq	L_.str.1(%rip), %rsi
	jmp	LBB0_4
LBB0_5:
	movq	_CSR_RD_CNT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -60(%rbp)
	leaq	-64(%rbp), %rsi
	movq	%rbx, %rdi
	callq	*16(%rbx)
	testl	%eax, %eax
	je	LBB0_7
## %bb.6:
	movl	%eax, %r13d
	movl	%r12d, %edi
	callq	_CSR_REAL_ADDR
	leaq	L_.str.2(%rip), %rsi
LBB0_4:
	movq	%r15, %rdi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_dev_err
LBB0_10:
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	movl	%r13d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_7:
	movq	_CSR_RERR@GOTPCREL(%rip), %rax
	movq	_CSR_WERR@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	orl	(%rax), %ecx
	testl	%ecx, -80(%rbp)
	je	LBB0_8
## %bb.9:
	leaq	L_.str.3(%rip), %rsi
	xorl	%r13d, %r13d
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EREMOTEIO@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_10
LBB0_8:
	xorl	%r13d, %r13d
	jmp	LBB0_10
	.cfi_endproc
                                        ## -- End function
	.comm	_CCODE_CSR,4,2                  ## @CCODE_CSR
	.comm	_CSR_WR_CNT,4,2                 ## @CSR_WR_CNT
	.comm	_CSR_OP_WRITE,4,2               ## @CSR_OP_WRITE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to write 0x%04x: 0x%04x to csr"

	.comm	_CSR_WRRD_CNT,4,2               ## @CSR_WRRD_CNT
	.comm	_CSR_OP_READ,4,2                ## @CSR_OP_READ
L_.str.1:                               ## @.str.1
	.asciz	"Failed to init csr address 0x%04x"

	.comm	_CSR_RD_CNT,4,2                 ## @CSR_RD_CNT
L_.str.2:                               ## @.str.2
	.asciz	"Failed to read csr 0x%04x"

	.comm	_CSR_RERR,4,2                   ## @CSR_RERR
	.comm	_CSR_WERR,4,2                   ## @CSR_WERR
L_.str.3:                               ## @.str.3
	.asciz	"IDT failed to perform CSR r/w"

	.comm	_EREMOTEIO,4,2                  ## @EREMOTEIO
	.no_dead_strip	_idt_csr_write
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function idt_csr_write
_idt_csr_write:                         ; @idt_csr_write
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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, x2
	mov	x21, x1
	mov	x23, x0
	ldr	x20, [x0, #32]
	ldr	w8, [x0]
Lloh0:
	adrp	x9, _CCODE_CSR@GOTPAGE
Lloh1:
	ldr	x9, [x9, _CCODE_CSR@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	orr	w8, w9, w8
	str	w8, [sp, #16]
	add	x8, sp, #32
	str	x8, [sp, #24]
	add	x19, x0, #24
	mov	x0, x19
	bl	_mutex_lock
Lloh3:
	adrp	x8, _CSR_WR_CNT@GOTPAGE
Lloh4:
	ldr	x8, [x8, _CSR_WR_CNT@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	str	w8, [sp, #20]
	ldr	w8, [x23, #4]
Lloh6:
	adrp	x9, _CSR_OP_WRITE@GOTPAGE
Lloh7:
	ldr	x9, [x9, _CSR_OP_WRITE@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	orr	w8, w9, w8
	str	w8, [sp, #32]
	mov	x0, x21
	bl	_cpu_to_le16
	str	w0, [sp, #40]
	mov	x0, x24
	bl	_cpu_to_le32
	str	w0, [sp, #36]
	ldr	x8, [x23, #8]
	add	x1, sp, #16
	mov	x0, x23
	blr	x8
	cbz	w0, LBB0_2
; %bb.1:
	mov	x22, x0
	mov	x0, x21
	bl	_CSR_REAL_ADDR
                                        ; kill: def $w0 killed $w0 def $x0
	stp	x0, x24, [sp]
Lloh9:
	adrp	x1, l_.str@PAGE
Lloh10:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_6
LBB0_2:
Lloh11:
	adrp	x8, _CSR_WRRD_CNT@GOTPAGE
Lloh12:
	ldr	x8, [x8, _CSR_WRRD_CNT@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
	str	w8, [sp, #20]
	ldr	w8, [x23, #4]
Lloh14:
	adrp	x9, _CSR_OP_READ@GOTPAGE
Lloh15:
	ldr	x9, [x9, _CSR_OP_READ@GOTPAGEOFF]
Lloh16:
	ldr	w9, [x9]
	orr	w8, w9, w8
	str	w8, [sp, #32]
	ldr	x8, [x23, #8]
	add	x1, sp, #16
	mov	x0, x23
	blr	x8
	cbz	w0, LBB0_4
; %bb.3:
	mov	x22, x0
	mov	x0, x21
	bl	_CSR_REAL_ADDR
                                        ; kill: def $w0 killed $w0 def $x0
	str	x0, [sp]
Lloh17:
	adrp	x1, l_.str.1@PAGE
Lloh18:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_6
LBB0_4:
Lloh19:
	adrp	x8, _CSR_RD_CNT@GOTPAGE
Lloh20:
	ldr	x8, [x8, _CSR_RD_CNT@GOTPAGEOFF]
Lloh21:
	ldr	w8, [x8]
	str	w8, [sp, #20]
	ldr	x8, [x23, #16]
	add	x1, sp, #16
	mov	x0, x23
	blr	x8
	cbz	w0, LBB0_8
; %bb.5:
	mov	x22, x0
	mov	x0, x21
	bl	_CSR_REAL_ADDR
                                        ; kill: def $w0 killed $w0 def $x0
	str	x0, [sp]
Lloh22:
	adrp	x1, l_.str.2@PAGE
Lloh23:
	add	x1, x1, l_.str.2@PAGEOFF
LBB0_6:
	mov	x0, x20
	bl	_dev_err
LBB0_7:
	mov	x0, x19
	bl	_mutex_unlock
	mov	x0, x22
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_8:
	ldr	w8, [sp, #32]
Lloh24:
	adrp	x9, _CSR_RERR@GOTPAGE
Lloh25:
	ldr	x9, [x9, _CSR_RERR@GOTPAGEOFF]
Lloh26:
	ldr	w9, [x9]
Lloh27:
	adrp	x10, _CSR_WERR@GOTPAGE
Lloh28:
	ldr	x10, [x10, _CSR_WERR@GOTPAGEOFF]
Lloh29:
	ldr	w10, [x10]
	orr	w9, w10, w9
	tst	w9, w8
	b.eq	LBB0_10
; %bb.9:
Lloh30:
	adrp	x1, l_.str.3@PAGE
Lloh31:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x20
	bl	_dev_err
Lloh32:
	adrp	x8, _EREMOTEIO@GOTPAGE
Lloh33:
	ldr	x8, [x8, _EREMOTEIO@GOTPAGEOFF]
Lloh34:
	ldr	w8, [x8]
	neg	w22, w8
	b	LBB0_7
LBB0_10:
	mov	w22, #0
	b	LBB0_7
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpAdd	Lloh30, Lloh31
	.cfi_endproc
                                        ; -- End function
	.comm	_CCODE_CSR,4,2                  ; @CCODE_CSR
	.comm	_CSR_WR_CNT,4,2                 ; @CSR_WR_CNT
	.comm	_CSR_OP_WRITE,4,2               ; @CSR_OP_WRITE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to write 0x%04x: 0x%04x to csr"

	.comm	_CSR_WRRD_CNT,4,2               ; @CSR_WRRD_CNT
	.comm	_CSR_OP_READ,4,2                ; @CSR_OP_READ
l_.str.1:                               ; @.str.1
	.asciz	"Failed to init csr address 0x%04x"

	.comm	_CSR_RD_CNT,4,2                 ; @CSR_RD_CNT
l_.str.2:                               ; @.str.2
	.asciz	"Failed to read csr 0x%04x"

	.comm	_CSR_RERR,4,2                   ; @CSR_RERR
	.comm	_CSR_WERR,4,2                   ; @CSR_WERR
l_.str.3:                               ; @.str.3
	.asciz	"IDT failed to perform CSR r/w"

	.comm	_EREMOTEIO,4,2                  ; @EREMOTEIO
	.no_dead_strip	_idt_csr_write
.subsections_via_symbols
