	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_smscore_set_device_mode        ## -- Begin function smscore_set_device_mode
	.p2align	4, 0x90
_smscore_set_device_mode:               ## @smscore_set_device_mode
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %ebx
	movq	%rdi, %r14
	leaq	L_.str(%rip), %rdi
	xorl	%eax, %eax
	callq	_pr_debug
	movq	_SMS_DEVICE_FAMILY2@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_DEVICE_MODE_NONE@GOTPCREL(%rip), %rax
	cmpl	%ebx, (%rax)
	setl	%dl
	movq	_DEVICE_MODE_MAX@GOTPCREL(%rip), %rax
	cmpl	%ebx, (%rax)
	setg	%al
	andb	%dl, %al
	testl	%ecx, (%r14)
	je	LBB0_16
## %bb.1:
	testb	%al, %al
	je	LBB0_2
## %bb.3:
	movl	48(%r14), %edi
	movl	%ebx, %esi
	callq	_smscore_registry_setmode
	movq	_SMS_DEVICE_NOT_READY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	xorl	%r15d, %r15d
	testl	%eax, (%r14)
	jne	LBB0_7
## %bb.4:
	movq	%r14, %rdi
	callq	_smscore_detect_mode
	movl	%eax, %r15d
	testl	%eax, %eax
	js	LBB0_5
LBB0_7:
	cmpl	%ebx, 4(%r14)
	jne	LBB0_9
## %bb.8:
	leaq	L_.str.3(%rip), %rdi
	xorl	%r15d, %r15d
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	_pr_debug
	jmp	LBB0_27
LBB0_16:
	testb	%al, %al
	je	LBB0_2
## %bb.17:
	movl	48(%r14), %edi
	movl	%ebx, %esi
	callq	_smscore_registry_setmode
	movq	40(%r14), %rax
	testq	%rax, %rax
	je	LBB0_19
## %bb.18:
	movl	32(%r14), %edi
	leaq	4(%r14), %rsi
	callq	*%rax
LBB0_19:
	xorl	%r15d, %r15d
	cmpl	%ebx, 4(%r14)
	je	LBB0_23
## %bb.20:
	movq	16(%r14), %rax
	testq	%rax, %rax
	je	LBB0_23
## %bb.21:
	movl	32(%r14), %edi
	movl	%ebx, %esi
	callq	*%rax
	movl	%eax, %r15d
	jmp	LBB0_22
LBB0_2:
	leaq	L_.str.1(%rip), %rdi
	movl	%ebx, %esi
	callq	_pr_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r15d, %r15d
	subl	(%rax), %r15d
	jmp	LBB0_27
LBB0_9:
	movl	8(%r14), %eax
	btl	%ebx, %eax
	jae	LBB0_10
## %bb.12:
	leaq	L_.str.5(%rip), %rdi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	_pr_debug
	jmp	LBB0_13
LBB0_10:
	movq	%r14, %rdi
	movl	%ebx, %esi
	xorl	%edx, %edx
	callq	_smscore_load_firmware_from_file
	movl	%eax, %r15d
	testl	%eax, %eax
	js	LBB0_13
## %bb.11:
	leaq	L_.str.4(%rip), %rdi
	xorl	%eax, %eax
	callq	_pr_debug
LBB0_13:
	cmpl	$2048, 12(%r14)                 ## imm = 0x800
	jl	LBB0_22
## %bb.14:
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_smscore_init_device
	movl	%eax, %r15d
	testl	%eax, %eax
	jns	LBB0_23
## %bb.15:
	leaq	L_.str.6(%rip), %rdi
	movl	%r15d, %esi
	callq	_pr_err
	leaq	L_.str.7(%rip), %rdi
	jmp	LBB0_6
LBB0_22:
	testl	%r15d, %r15d
	js	LBB0_25
LBB0_23:
	movl	%ebx, 4(%r14)
	movq	_SMS_DEVICE_NOT_READY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	notl	%eax
	andl	%eax, (%r14)
	movq	_SMS_DMA_ALIGNMENT@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	$16, %rdi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	24(%r14), %esi
	orl	(%rax), %esi
	callq	_kmalloc
	testq	%rax, %rax
	je	LBB0_26
## %bb.24:
	movq	%rax, %r12
	movq	%rax, %rdi
	callq	_SMS_ALIGN_ADDRESS
	movq	%rax, %r15
	leaq	8(%rax), %rdi
	movq	_MSG_SMS_INIT_DEVICE_REQ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$16, %edx
	callq	_SMS_INIT_MSG
	movq	(%r15), %rax
	movl	%ebx, (%rax)
	movl	8(%r15), %edx
	leaq	28(%r14), %rcx
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_smscore_sendrequest_and_wait
	movl	%eax, %r15d
	movq	%r12, %rdi
	callq	_kfree
	testl	%r15d, %r15d
	js	LBB0_25
LBB0_26:
	leaq	L_.str.8(%rip), %rdi
	xorl	%eax, %eax
	callq	_pr_debug
	jmp	LBB0_27
LBB0_25:
	leaq	L_.str.7(%rip), %rdi
	jmp	LBB0_6
LBB0_5:
	leaq	L_.str.2(%rip), %rdi
LBB0_6:
	movl	%r15d, %esi
	callq	_pr_err
LBB0_27:
	movl	%r15d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"set device mode to %d\n"

	.comm	_SMS_DEVICE_FAMILY2,4,2         ## @SMS_DEVICE_FAMILY2
	.comm	_DEVICE_MODE_NONE,4,2           ## @DEVICE_MODE_NONE
	.comm	_DEVICE_MODE_MAX,4,2            ## @DEVICE_MODE_MAX
L_.str.1:                               ## @.str.1
	.asciz	"invalid mode specified %d\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_SMS_DEVICE_NOT_READY,4,2       ## @SMS_DEVICE_NOT_READY
L_.str.2:                               ## @.str.2
	.asciz	"mode detect failed %d\n"

L_.str.3:                               ## @.str.3
	.asciz	"device mode %d already set\n"

L_.str.4:                               ## @.str.4
	.asciz	"firmware download success\n"

L_.str.5:                               ## @.str.5
	.asciz	"mode %d is already supported by running firmware\n"

L_.str.6:                               ## @.str.6
	.asciz	"device init failed, rc %d.\n"

	.comm	_SMS_DMA_ALIGNMENT,8,3          ## @SMS_DMA_ALIGNMENT
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_MSG_SMS_INIT_DEVICE_REQ,4,2    ## @MSG_SMS_INIT_DEVICE_REQ
L_.str.7:                               ## @.str.7
	.asciz	"return error code %d.\n"

L_.str.8:                               ## @.str.8
	.asciz	"Success setting device mode.\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_smscore_set_device_mode        ; -- Begin function smscore_set_device_mode
	.p2align	2
_smscore_set_device_mode:               ; @smscore_set_device_mode
	.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	x19, x1
	mov	x20, x0
	str	x19, [sp]
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_pr_debug
Lloh2:
	adrp	x8, _SMS_DEVICE_FAMILY2@GOTPAGE
Lloh3:
	ldr	x8, [x8, _SMS_DEVICE_FAMILY2@GOTPAGEOFF]
	ldr	w9, [x20]
Lloh4:
	ldr	w10, [x8]
Lloh5:
	adrp	x8, _DEVICE_MODE_NONE@GOTPAGE
Lloh6:
	ldr	x8, [x8, _DEVICE_MODE_NONE@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	cmp	w8, w19
Lloh8:
	adrp	x8, _DEVICE_MODE_MAX@GOTPAGE
Lloh9:
	ldr	x8, [x8, _DEVICE_MODE_MAX@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	ccmp	w8, w19, #4, lt
	cset	w8, gt
	and	w9, w10, w9
	cbz	w9, LBB0_4
; %bb.1:
	tbz	w8, #0, LBB0_10
; %bb.2:
	ldr	w0, [x20, #48]
	mov	x1, x19
	bl	_smscore_registry_setmode
	ldr	w8, [x20]
Lloh11:
	adrp	x9, _SMS_DEVICE_NOT_READY@GOTPAGE
Lloh12:
	ldr	x9, [x9, _SMS_DEVICE_NOT_READY@GOTPAGEOFF]
Lloh13:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_12
; %bb.3:
	mov	w21, #0
	b	LBB0_13
LBB0_4:
	tbz	w8, #0, LBB0_10
; %bb.5:
	ldr	w0, [x20, #48]
	mov	x1, x19
	bl	_smscore_registry_setmode
	ldr	x8, [x20, #40]
	cbz	x8, LBB0_7
; %bb.6:
	ldr	w0, [x20, #32]
	add	x1, x20, #4
	blr	x8
LBB0_7:
	ldr	w8, [x20, #4]
	cmp	w8, w19
	b.eq	LBB0_11
; %bb.8:
	ldr	x8, [x20, #16]
	cbz	x8, LBB0_11
; %bb.9:
	ldr	w0, [x20, #32]
	mov	x1, x19
	blr	x8
	mov	x21, x0
	b	LBB0_23
LBB0_10:
Lloh14:
	adrp	x0, l_.str.1@PAGE
Lloh15:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x1, x19
	bl	_pr_err
Lloh16:
	adrp	x8, _EINVAL@GOTPAGE
Lloh17:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_30
LBB0_11:
	mov	w21, #0
	b	LBB0_24
LBB0_12:
	mov	x0, x20
	bl	_smscore_detect_mode
	mov	x21, x0
	tbnz	w0, #31, LBB0_28
LBB0_13:
	ldr	w8, [x20, #4]
	cmp	w8, w19
	b.ne	LBB0_15
; %bb.14:
                                        ; kill: def $w19 killed $w19 killed $x19 def $x19
	str	x19, [sp]
Lloh19:
	adrp	x0, l_.str.3@PAGE
Lloh20:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_pr_debug
	mov	w21, #0
	b	LBB0_30
LBB0_15:
	ldr	w8, [x20, #8]
	lsr	w8, w8, w19
	tbz	w8, #0, LBB0_17
; %bb.16:
	mov	x8, x19
	str	x8, [sp]
Lloh21:
	adrp	x0, l_.str.5@PAGE
Lloh22:
	add	x0, x0, l_.str.5@PAGEOFF
	b	LBB0_19
LBB0_17:
	mov	x0, x20
	mov	x1, x19
	mov	x2, #0
	bl	_smscore_load_firmware_from_file
	mov	x21, x0
	tbnz	w0, #31, LBB0_20
; %bb.18:
Lloh23:
	adrp	x0, l_.str.4@PAGE
Lloh24:
	add	x0, x0, l_.str.4@PAGEOFF
LBB0_19:
	bl	_pr_debug
LBB0_20:
	ldr	w8, [x20, #12]
	cmp	w8, #2048
	b.lt	LBB0_23
; %bb.21:
	mov	x0, x20
	mov	x1, x19
	bl	_smscore_init_device
	mov	x21, x0
	tbz	w0, #31, LBB0_24
; %bb.22:
Lloh25:
	adrp	x0, l_.str.6@PAGE
Lloh26:
	add	x0, x0, l_.str.6@PAGEOFF
	mov	x1, x21
	bl	_pr_err
	b	LBB0_27
LBB0_23:
	tbnz	w21, #31, LBB0_27
LBB0_24:
Lloh27:
	adrp	x8, _SMS_DEVICE_NOT_READY@GOTPAGE
Lloh28:
	ldr	x8, [x8, _SMS_DEVICE_NOT_READY@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	ldr	w9, [x20]
	bic	w8, w9, w8
	stp	w8, w19, [x20]
Lloh30:
	adrp	x8, _SMS_DMA_ALIGNMENT@GOTPAGE
Lloh31:
	ldr	x8, [x8, _SMS_DMA_ALIGNMENT@GOTPAGEOFF]
Lloh32:
	ldr	x8, [x8]
	add	x0, x8, #16
Lloh33:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh34:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh35:
	ldr	w8, [x8]
	ldr	w9, [x20, #24]
	orr	w1, w9, w8
	bl	_kmalloc
	cbz	x0, LBB0_26
; %bb.25:
	mov	x22, x0
	bl	_SMS_ALIGN_ADDRESS
	mov	x21, x0
	add	x0, x0, #8
Lloh36:
	adrp	x8, _MSG_SMS_INIT_DEVICE_REQ@GOTPAGE
Lloh37:
	ldr	x8, [x8, _MSG_SMS_INIT_DEVICE_REQ@GOTPAGEOFF]
Lloh38:
	ldr	w1, [x8]
	mov	w2, #16
	bl	_SMS_INIT_MSG
	ldr	x8, [x21]
	str	w19, [x8]
	ldr	w2, [x21, #8]
	add	x3, x20, #28
	mov	x0, x20
	mov	x1, x21
	bl	_smscore_sendrequest_and_wait
	mov	x21, x0
	mov	x0, x22
	bl	_kfree
	tbnz	w21, #31, LBB0_27
LBB0_26:
Lloh39:
	adrp	x0, l_.str.8@PAGE
Lloh40:
	add	x0, x0, l_.str.8@PAGEOFF
	bl	_pr_debug
	b	LBB0_30
LBB0_27:
Lloh41:
	adrp	x0, l_.str.7@PAGE
Lloh42:
	add	x0, x0, l_.str.7@PAGEOFF
	b	LBB0_29
LBB0_28:
Lloh43:
	adrp	x0, l_.str.2@PAGE
Lloh44:
	add	x0, x0, l_.str.2@PAGEOFF
LBB0_29:
	mov	x1, x21
	bl	_pr_err
LBB0_30:
	mov	x0, x21
	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	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpAdd	Lloh39, Lloh40
	.loh AdrpAdd	Lloh41, Lloh42
	.loh AdrpAdd	Lloh43, Lloh44
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"set device mode to %d\n"

	.comm	_SMS_DEVICE_FAMILY2,4,2         ; @SMS_DEVICE_FAMILY2
	.comm	_DEVICE_MODE_NONE,4,2           ; @DEVICE_MODE_NONE
	.comm	_DEVICE_MODE_MAX,4,2            ; @DEVICE_MODE_MAX
l_.str.1:                               ; @.str.1
	.asciz	"invalid mode specified %d\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_SMS_DEVICE_NOT_READY,4,2       ; @SMS_DEVICE_NOT_READY
l_.str.2:                               ; @.str.2
	.asciz	"mode detect failed %d\n"

l_.str.3:                               ; @.str.3
	.asciz	"device mode %d already set\n"

l_.str.4:                               ; @.str.4
	.asciz	"firmware download success\n"

l_.str.5:                               ; @.str.5
	.asciz	"mode %d is already supported by running firmware\n"

l_.str.6:                               ; @.str.6
	.asciz	"device init failed, rc %d.\n"

	.comm	_SMS_DMA_ALIGNMENT,8,3          ; @SMS_DMA_ALIGNMENT
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_MSG_SMS_INIT_DEVICE_REQ,4,2    ; @MSG_SMS_INIT_DEVICE_REQ
l_.str.7:                               ; @.str.7
	.asciz	"return error code %d.\n"

l_.str.8:                               ; @.str.8
	.asciz	"Success setting device mode.\n"

.subsections_via_symbols
