	.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, %r15d
	movq	%rdi, %r14
	leaq	L_.str(%rip), %rdi
	callq	_sms_debug
	movq	_SMS_DEVICE_FAMILY2@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_DEVICE_MODE_DVBT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%ecx, (%r14)
	je	LBB0_18
## %bb.1:
	cmpl	%r15d, %eax
	jg	LBB0_3
## %bb.2:
	movq	_DEVICE_MODE_RAW_TUNER@GOTPCREL(%rip), %rax
	cmpl	%r15d, (%rax)
	jle	LBB0_3
## %bb.4:
	movl	40(%r14), %edi
	movl	%r15d, %esi
	callq	_smscore_registry_setmode
	movq	_SMS_DEVICE_NOT_READY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r14)
	jne	LBB0_7
## %bb.5:
	movq	%r14, %rdi
	callq	_smscore_detect_mode
	testl	%eax, %eax
	js	LBB0_6
LBB0_7:
	cmpl	%r15d, 4(%r14)
	jne	LBB0_9
## %bb.8:
	leaq	L_.str.3(%rip), %rdi
	movl	%r15d, %esi
	callq	_sms_info
	xorl	%ebx, %ebx
	jmp	LBB0_29
LBB0_18:
	cmpl	%r15d, %eax
	jg	LBB0_3
## %bb.19:
	movq	_DEVICE_MODE_DVBT_BDA@GOTPCREL(%rip), %rax
	cmpl	%r15d, (%rax)
	jl	LBB0_3
## %bb.20:
	movl	40(%r14), %edi
	movl	%r15d, %esi
	callq	_smscore_registry_setmode
	movq	32(%r14), %rax
	testq	%rax, %rax
	je	LBB0_22
## %bb.21:
	movl	24(%r14), %edi
	leaq	4(%r14), %rsi
	callq	*%rax
LBB0_22:
	xorl	%ebx, %ebx
	cmpl	%r15d, 4(%r14)
	je	LBB0_26
## %bb.23:
	movq	16(%r14), %rax
	testq	%rax, %rax
	je	LBB0_26
## %bb.24:
	movl	24(%r14), %edi
	movl	%r15d, %esi
	callq	*%rax
	movl	%eax, %ebx
	testl	%ebx, %ebx
	jns	LBB0_26
	jmp	LBB0_27
LBB0_3:
	leaq	L_.str.1(%rip), %rdi
	xorl	%ebx, %ebx
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	_sms_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_29
LBB0_9:
	movl	8(%r14), %eax
	btl	%r15d, %eax
	jae	LBB0_10
## %bb.14:
	leaq	L_.str.7(%rip), %rdi
	movl	%r15d, %esi
	callq	_sms_info
	jmp	LBB0_15
LBB0_10:
	movl	40(%r14), %edi
	callq	_smscore_registry_gettype
	movl	%eax, %ebx
	movq	%r14, %rdi
	movl	%r15d, %esi
	movl	%eax, %edx
	callq	_sms_get_fw_name
	movq	%rax, %r12
	movq	%r14, %rdi
	movq	%rax, %rsi
	xorl	%edx, %edx
	callq	_smscore_load_firmware_from_file
	testl	%eax, %eax
	jns	LBB0_12
## %bb.11:
	leaq	L_.str.4(%rip), %rdi
	movl	%eax, %esi
	movq	%r12, %rdx
	callq	_sms_warn
	movq	_smscore_fw_lkup@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movslq	%r15d, %rcx
	movq	(%rax,%rcx,8), %rax
	movl	%ebx, %ecx
	movq	(%rax,%rcx,8), %r12
	movq	%r14, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_smscore_load_firmware_from_file
	testl	%eax, %eax
	js	LBB0_13
LBB0_12:
	leaq	L_.str.6(%rip), %rdi
	movq	%r12, %rsi
	callq	_sms_log
LBB0_15:
	movq	_SMS_DMA_ALIGNMENT@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	$16, %rdi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movq	_GFP_DMA@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	orl	(%rax), %esi
	callq	_kmalloc
	testq	%rax, %rax
	je	LBB0_17
## %bb.16:
	movq	%rax, %r12
	movq	%rax, %rdi
	callq	_SMS_ALIGN_ADDRESS
	movq	%rax, %rbx
	leaq	8(%rax), %rdi
	movq	_MSG_SMS_INIT_DEVICE_REQ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$16, %edx
	callq	_SMS_INIT_MSG
	movq	(%rbx), %rax
	movl	%r15d, (%rax)
	movl	8(%rbx), %edx
	leaq	44(%r14), %rcx
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_smscore_sendrequest_and_wait
	movl	%eax, %ebx
	movq	%r12, %rdi
	callq	_kfree
	testl	%ebx, %ebx
	js	LBB0_27
LBB0_26:
	movl	%r15d, 4(%r14)
	movq	_SMS_DEVICE_NOT_READY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	notl	%eax
	andl	%eax, (%r14)
	jmp	LBB0_29
LBB0_17:
	leaq	L_.str.8(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_sms_err
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	testl	%ebx, %ebx
	jns	LBB0_26
LBB0_27:
	leaq	L_.str.9(%rip), %rdi
	jmp	LBB0_28
LBB0_6:
	movl	%eax, %ebx
	leaq	L_.str.2(%rip), %rdi
LBB0_28:
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	_sms_err
LBB0_29:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_13:
	movl	%eax, %ebx
	leaq	L_.str.5(%rip), %rdi
	movl	%eax, %esi
	movq	%r12, %rdx
	callq	_sms_warn
	jmp	LBB0_29
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"set device mode to %d"

	.comm	_SMS_DEVICE_FAMILY2,4,2         ## @SMS_DEVICE_FAMILY2
	.comm	_DEVICE_MODE_DVBT,4,2           ## @DEVICE_MODE_DVBT
	.comm	_DEVICE_MODE_RAW_TUNER,4,2      ## @DEVICE_MODE_RAW_TUNER
L_.str.1:                               ## @.str.1
	.asciz	"invalid mode specified %d"

	.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"

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

L_.str.4:                               ## @.str.4
	.asciz	"error %d loading firmware: %s, trying again with default firmware"

	.comm	_smscore_fw_lkup,8,3            ## @smscore_fw_lkup
L_.str.5:                               ## @.str.5
	.asciz	"error %d loading firmware: %s"

L_.str.6:                               ## @.str.6
	.asciz	"firmware download success: %s"

L_.str.7:                               ## @.str.7
	.asciz	"mode %d supported by running firmware"

	.comm	_SMS_DMA_ALIGNMENT,8,3          ## @SMS_DMA_ALIGNMENT
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_GFP_DMA,4,2                    ## @GFP_DMA
	.comm	_MSG_SMS_INIT_DEVICE_REQ,4,2    ## @MSG_SMS_INIT_DEVICE_REQ
L_.str.8:                               ## @.str.8
	.asciz	"Could not allocate buffer for init device message."

	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_DEVICE_MODE_DVBT_BDA,4,2       ## @DEVICE_MODE_DVBT_BDA
L_.str.9:                               ## @.str.9
	.asciz	"return error code %d."

.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
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_sms_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_DVBT@GOTPAGE
Lloh6:
	ldr	x8, [x8, _DEVICE_MODE_DVBT@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	tst	w10, w9
	b.eq	LBB0_6
; %bb.1:
Lloh8:
	adrp	x9, _DEVICE_MODE_RAW_TUNER@GOTPAGE
Lloh9:
	ldr	x9, [x9, _DEVICE_MODE_RAW_TUNER@GOTPAGEOFF]
Lloh10:
	ldr	w9, [x9]
	cmp	w8, w19
	ccmp	w9, w19, #4, le
	b.le	LBB0_8
; %bb.2:
	ldr	w0, [x20, #40]
	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.ne	LBB0_4
; %bb.3:
	mov	x0, x20
	bl	_smscore_detect_mode
	tbnz	w0, #31, LBB0_25
LBB0_4:
	ldr	w8, [x20, #4]
	cmp	w8, w19
	b.ne	LBB0_14
; %bb.5:
Lloh14:
	adrp	x0, l_.str.3@PAGE
Lloh15:
	add	x0, x0, l_.str.3@PAGEOFF
	mov	x1, x19
	bl	_sms_info
	mov	w21, #0
	b	LBB0_27
LBB0_6:
Lloh16:
	adrp	x9, _DEVICE_MODE_DVBT_BDA@GOTPAGE
Lloh17:
	ldr	x9, [x9, _DEVICE_MODE_DVBT_BDA@GOTPAGEOFF]
Lloh18:
	ldr	w9, [x9]
	cmp	w8, w19
	ccmp	w9, w19, #8, le
	b.ge	LBB0_9
; %bb.7:
                                        ; kill: def $w19 killed $w19 killed $x19 def $x19
LBB0_8:
	str	x19, [sp]
Lloh19:
	adrp	x0, l_.str.1@PAGE
Lloh20:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_sms_err
Lloh21:
	adrp	x8, _EINVAL@GOTPAGE
Lloh22:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh23:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_27
LBB0_9:
	ldr	w0, [x20, #40]
	mov	x1, x19
	bl	_smscore_registry_setmode
	ldr	x8, [x20, #32]
	cbz	x8, LBB0_11
; %bb.10:
	ldr	w0, [x20, #24]
	add	x1, x20, #4
	blr	x8
LBB0_11:
	ldr	w8, [x20, #4]
	cmp	w8, w19
	b.eq	LBB0_16
; %bb.12:
	ldr	x8, [x20, #16]
	cbz	x8, LBB0_16
; %bb.13:
	ldr	w0, [x20, #24]
	mov	x1, x19
	blr	x8
	mov	x21, x0
	tbz	w21, #31, LBB0_22
	b	LBB0_24
LBB0_14:
	ldr	w8, [x20, #8]
	lsr	w8, w8, w19
	tbz	w8, #0, LBB0_17
; %bb.15:
Lloh24:
	adrp	x0, l_.str.7@PAGE
Lloh25:
	add	x0, x0, l_.str.7@PAGEOFF
	mov	x1, x19
	bl	_sms_info
	b	LBB0_20
LBB0_16:
	mov	w21, #0
	b	LBB0_22
LBB0_17:
	ldr	w0, [x20, #40]
	bl	_smscore_registry_gettype
	mov	x21, x0
	mov	x0, x20
	mov	x1, x19
	mov	x2, x21
	bl	_sms_get_fw_name
	mov	x22, x0
	mov	x0, x20
	mov	x1, x22
	mov	x2, #0
	bl	_smscore_load_firmware_from_file
	tbz	w0, #31, LBB0_19
; %bb.18:
	mov	x1, x0
Lloh26:
	adrp	x0, l_.str.4@PAGE
Lloh27:
	add	x0, x0, l_.str.4@PAGEOFF
	mov	x2, x22
	bl	_sms_warn
Lloh28:
	adrp	x8, _smscore_fw_lkup@GOTPAGE
Lloh29:
	ldr	x8, [x8, _smscore_fw_lkup@GOTPAGEOFF]
Lloh30:
	ldr	x8, [x8]
	ldr	x8, [x8, w19, sxtw #3]
	ldr	x22, [x8, w21, uxtw #3]
	mov	x0, x20
	mov	x1, x22
	mov	x2, #0
	bl	_smscore_load_firmware_from_file
	tbnz	w0, #31, LBB0_28
LBB0_19:
Lloh31:
	adrp	x0, l_.str.6@PAGE
Lloh32:
	add	x0, x0, l_.str.6@PAGEOFF
	mov	x1, x22
	bl	_sms_log
LBB0_20:
Lloh33:
	adrp	x8, _SMS_DMA_ALIGNMENT@GOTPAGE
Lloh34:
	ldr	x8, [x8, _SMS_DMA_ALIGNMENT@GOTPAGEOFF]
Lloh35:
	ldr	x8, [x8]
Lloh36:
	adrp	x9, _GFP_KERNEL@GOTPAGE
Lloh37:
	ldr	x9, [x9, _GFP_KERNEL@GOTPAGEOFF]
	add	x0, x8, #16
Lloh38:
	ldr	w8, [x9]
Lloh39:
	adrp	x9, _GFP_DMA@GOTPAGE
Lloh40:
	ldr	x9, [x9, _GFP_DMA@GOTPAGEOFF]
Lloh41:
	ldr	w9, [x9]
	orr	w1, w9, w8
	bl	_kmalloc
	cbz	x0, LBB0_23
; %bb.21:
	mov	x22, x0
	bl	_SMS_ALIGN_ADDRESS
	mov	x21, x0
	add	x0, x0, #8
Lloh42:
	adrp	x8, _MSG_SMS_INIT_DEVICE_REQ@GOTPAGE
Lloh43:
	ldr	x8, [x8, _MSG_SMS_INIT_DEVICE_REQ@GOTPAGEOFF]
Lloh44:
	ldr	w1, [x8]
	mov	w2, #16
	bl	_SMS_INIT_MSG
	ldr	x8, [x21]
	str	w19, [x8]
	ldr	w2, [x21, #8]
	add	x3, x20, #44
	mov	x0, x20
	mov	x1, x21
	bl	_smscore_sendrequest_and_wait
	mov	x21, x0
	mov	x0, x22
	bl	_kfree
	tbnz	w21, #31, LBB0_24
LBB0_22:
Lloh45:
	adrp	x8, _SMS_DEVICE_NOT_READY@GOTPAGE
Lloh46:
	ldr	x8, [x8, _SMS_DEVICE_NOT_READY@GOTPAGEOFF]
Lloh47:
	ldr	w8, [x8]
	ldr	w9, [x20]
	bic	w8, w9, w8
	stp	w8, w19, [x20]
	b	LBB0_27
LBB0_23:
Lloh48:
	adrp	x0, l_.str.8@PAGE
Lloh49:
	add	x0, x0, l_.str.8@PAGEOFF
	bl	_sms_err
Lloh50:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh51:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh52:
	ldr	w8, [x8]
	neg	w21, w8
	tbz	w21, #31, LBB0_22
LBB0_24:
	mov	x8, x21
	str	x8, [sp]
Lloh53:
	adrp	x0, l_.str.9@PAGE
Lloh54:
	add	x0, x0, l_.str.9@PAGEOFF
	b	LBB0_26
LBB0_25:
	mov	x21, x0
	str	x21, [sp]
Lloh55:
	adrp	x0, l_.str.2@PAGE
Lloh56:
	add	x0, x0, l_.str.2@PAGEOFF
LBB0_26:
	bl	_sms_err
LBB0_27:
	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
LBB0_28:
	mov	x21, x0
Lloh57:
	adrp	x0, l_.str.5@PAGE
Lloh58:
	add	x0, x0, l_.str.5@PAGEOFF
	mov	x1, x21
	mov	x2, x22
	bl	_sms_warn
	b	LBB0_27
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpAdd	Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh39, Lloh40, Lloh41
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpLdrGotLdr	Lloh42, Lloh43, Lloh44
	.loh AdrpLdrGotLdr	Lloh45, Lloh46, Lloh47
	.loh AdrpLdrGotLdr	Lloh50, Lloh51, Lloh52
	.loh AdrpAdd	Lloh48, Lloh49
	.loh AdrpAdd	Lloh53, Lloh54
	.loh AdrpAdd	Lloh55, Lloh56
	.loh AdrpAdd	Lloh57, Lloh58
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"set device mode to %d"

	.comm	_SMS_DEVICE_FAMILY2,4,2         ; @SMS_DEVICE_FAMILY2
	.comm	_DEVICE_MODE_DVBT,4,2           ; @DEVICE_MODE_DVBT
	.comm	_DEVICE_MODE_RAW_TUNER,4,2      ; @DEVICE_MODE_RAW_TUNER
l_.str.1:                               ; @.str.1
	.asciz	"invalid mode specified %d"

	.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"

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

l_.str.4:                               ; @.str.4
	.asciz	"error %d loading firmware: %s, trying again with default firmware"

	.comm	_smscore_fw_lkup,8,3            ; @smscore_fw_lkup
l_.str.5:                               ; @.str.5
	.asciz	"error %d loading firmware: %s"

l_.str.6:                               ; @.str.6
	.asciz	"firmware download success: %s"

l_.str.7:                               ; @.str.7
	.asciz	"mode %d supported by running firmware"

	.comm	_SMS_DMA_ALIGNMENT,8,3          ; @SMS_DMA_ALIGNMENT
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_GFP_DMA,4,2                    ; @GFP_DMA
	.comm	_MSG_SMS_INIT_DEVICE_REQ,4,2    ; @MSG_SMS_INIT_DEVICE_REQ
l_.str.8:                               ; @.str.8
	.asciz	"Could not allocate buffer for init device message."

	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_DEVICE_MODE_DVBT_BDA,4,2       ; @DEVICE_MODE_DVBT_BDA
l_.str.9:                               ; @.str.9
	.asciz	"return error code %d."

.subsections_via_symbols
