	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function tvaudio_setmode
_tvaudio_setmode:                       ## @tvaudio_setmode
	.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
	movq	%rsi, %r15
	movq	%rdi, %r14
	movq	(%rdi), %rax
	movq	(%rax), %rax
	movq	_V4L2_STD_NTSC@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	movl	$102502, %eax                   ## imm = 0x19066
	movl	$122880, %r12d                  ## imm = 0x1E000
	cmovel	%eax, %r12d
	movq	_audio_clock_tweak@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	leal	1023(%rax), %ecx
	xorl	%ebx, %ebx
	cmpl	$2047, %ecx                     ## imm = 0x7FF
	cmovbl	%eax, %ebx
	testq	%rdx, %rdx
	je	LBB0_2
## %bb.1:
	movl	12(%r15), %r10d
	movslq	(%r15), %r8
	imulq	$274877907, %r8, %rcx           ## imm = 0x10624DD3
	movq	%rcx, %rsi
	shrq	$63, %rsi
	sarq	$38, %rcx
	addl	%esi, %ecx
	imull	$1000, %ecx, %esi               ## imm = 0x3E8
	subl	%esi, %r8d
	movslq	4(%r15), %rax
	imulq	$274877907, %rax, %r9           ## imm = 0x10624DD3
	movq	%r9, %rsi
	shrq	$63, %rsi
	sarq	$38, %r9
	addl	%esi, %r9d
	imull	$1000, %r9d, %esi               ## imm = 0x3E8
	subl	%esi, %eax
	subq	$8, %rsp
	leaq	L_.str(%rip), %rdi
	movq	%rdx, %rsi
	movl	%r10d, %edx
                                        ## kill: def $ecx killed $ecx killed $rcx
                                        ## kill: def $r8d killed $r8d killed $r8
                                        ## kill: def $r9d killed $r9d killed $r9
	pushq	%rbx
	pushq	%r12
	pushq	%rax
	callq	_dprintk
	addq	$32, %rsp
LBB0_2:
	addl	%r12d, %ebx
	movq	_SAA7134_AUDIO_CLOCKS_PER_FIELD0@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movzbl	%bl, %esi
	callq	_saa_writeb
	movq	_SAA7134_AUDIO_CLOCKS_PER_FIELD1@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movzbl	%bh, %esi
	callq	_saa_writeb
	movq	_SAA7134_AUDIO_CLOCKS_PER_FIELD2@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	shrl	$16, %ebx
	movl	%ebx, %esi
	callq	_saa_writeb
	movl	(%r15), %esi
	movl	4(%r15), %edx
	movq	%r14, %rdi
	callq	_tvaudio_setcarrier
	movl	8(%r15), %eax
	addl	$-128, %eax
	cmpl	$5, %eax
	ja	LBB0_4
## %bb.3:
	movl	$59, %ecx
	btl	%eax, %ecx
	jb	LBB0_5
LBB0_4:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	cltq
	leaq	l_switch.table.tvaudio_setmode(%rip), %rcx
	movl	(%rcx,%rax,4), %esi
	leaq	l_switch.table.tvaudio_setmode.1(%rip), %rcx
	movl	(%rcx,%rax,4), %ebx
	leaq	l_switch.table.tvaudio_setmode.2(%rip), %rcx
	movl	(%rcx,%rax,4), %r12d
	leaq	l_switch.table.tvaudio_setmode.3(%rip), %rcx
	movq	(%rcx,%rax,8), %r13
	leaq	l_switch.table.tvaudio_setmode.4(%rip), %rcx
	movl	(%rcx,%rax,4), %r15d
	leaq	l_switch.table.tvaudio_setmode.5(%rip), %rcx
	movq	(%rcx,%rax,8), %rcx
	movq	%rcx, -48(%rbp)                 ## 8-byte Spill
	leaq	l_switch.table.tvaudio_setmode.6(%rip), %rcx
	movl	(%rcx,%rax,4), %r14d
	movq	_SAA7134_DEMODULATOR@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_saa_writeb
	movq	_SAA7134_DCXO_IDENT_CTRL@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%ebx, %esi
	callq	_saa_writeb
	movq	_SAA7134_FM_DEEMPHASIS@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%r12d, %esi
	callq	_saa_writeb
	movl	(%r13), %edi
	movl	%r15d, %esi
	callq	_saa_writeb
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	movl	%r14d, %esi
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_saa_writeb                     ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_V4L2_STD_NTSC,8,3              ## @V4L2_STD_NTSC
	.comm	_audio_clock_tweak,4,2          ## @audio_clock_tweak
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"tvaudio_setmode: %s %s [%d.%03d/%d.%03d MHz] acpf=%d%+d\n"

	.comm	_SAA7134_AUDIO_CLOCKS_PER_FIELD0,4,2 ## @SAA7134_AUDIO_CLOCKS_PER_FIELD0
	.comm	_SAA7134_AUDIO_CLOCKS_PER_FIELD1,4,2 ## @SAA7134_AUDIO_CLOCKS_PER_FIELD1
	.comm	_SAA7134_AUDIO_CLOCKS_PER_FIELD2,4,2 ## @SAA7134_AUDIO_CLOCKS_PER_FIELD2
	.comm	_SAA7134_DEMODULATOR,4,2        ## @SAA7134_DEMODULATOR
	.comm	_SAA7134_DCXO_IDENT_CTRL,4,2    ## @SAA7134_DCXO_IDENT_CTRL
	.comm	_SAA7134_FM_DEEMPHASIS,4,2      ## @SAA7134_FM_DEEMPHASIS
	.comm	_SAA7134_FM_DEMATRIX,4,2        ## @SAA7134_FM_DEMATRIX
	.comm	_SAA7134_STEREO_DAC_OUTPUT_SELECT,4,2 ## @SAA7134_STEREO_DAC_OUTPUT_SELECT
	.comm	_SAA7134_NICAM_CONFIG,4,2       ## @SAA7134_NICAM_CONFIG
	.no_dead_strip	_tvaudio_setmode
	.section	__TEXT,__const
	.p2align	2                               ## @switch.table.tvaudio_setmode
l_switch.table.tvaudio_setmode:
	.long	16                              ## 0x10
	.long	18                              ## 0x12
	.long	0                               ## 0x0
	.long	0                               ## 0x0
	.long	0                               ## 0x0
	.long	0                               ## 0x0

	.p2align	2                               ## @switch.table.tvaudio_setmode.1
l_switch.table.tvaudio_setmode.1:
	.long	0                               ## 0x0
	.long	0                               ## 0x0
	.long	0                               ## 0x0
	.long	0                               ## 0x0
	.long	1                               ## 0x1
	.long	0                               ## 0x0

	.p2align	2                               ## @switch.table.tvaudio_setmode.2
l_switch.table.tvaudio_setmode.2:
	.long	68                              ## 0x44
	.long	68                              ## 0x44
	.long	34                              ## 0x22
	.long	34                              ## 0x22
	.long	34                              ## 0x22
	.long	34                              ## 0x22

	.section	__DATA,__const
	.p2align	3                               ## @switch.table.tvaudio_setmode.3
l_switch.table.tvaudio_setmode.3:
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_FM_DEMATRIX
	.quad	_SAA7134_FM_DEMATRIX
	.quad	_SAA7134_FM_DEMATRIX
	.quad	_SAA7134_FM_DEMATRIX

	.section	__TEXT,__const
	.p2align	2                               ## @switch.table.tvaudio_setmode.4
l_switch.table.tvaudio_setmode.4:
	.long	161                             ## 0xa1
	.long	161                             ## 0xa1
	.long	128                             ## 0x80
	.long	128                             ## 0x80
	.long	128                             ## 0x80
	.long	128                             ## 0x80

	.section	__DATA,__const
	.p2align	3                               ## @switch.table.tvaudio_setmode.5
l_switch.table.tvaudio_setmode.5:
	.quad	_SAA7134_NICAM_CONFIG
	.quad	_SAA7134_NICAM_CONFIG
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT

	.section	__TEXT,__const
	.p2align	2                               ## @switch.table.tvaudio_setmode.6
l_switch.table.tvaudio_setmode.6:
	.long	0                               ## 0x0
	.long	0                               ## 0x0
	.long	160                             ## 0xa0
	.long	160                             ## 0xa0
	.long	160                             ## 0xa0
	.long	160                             ## 0xa0

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function tvaudio_setmode
_tvaudio_setmode:                       ; @tvaudio_setmode
	.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	x19, x1
	mov	x20, x0
	ldr	x8, [x0]
Lloh0:
	adrp	x9, _V4L2_STD_NTSC@GOTPAGE
Lloh1:
	ldr	x9, [x9, _V4L2_STD_NTSC@GOTPAGEOFF]
	ldr	x8, [x8]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	mov	w8, #122880
	mov	w9, #36966
	movk	w9, #1, lsl #16
	csel	w21, w9, w8, eq
Lloh3:
	adrp	x8, _audio_clock_tweak@GOTPAGE
Lloh4:
	ldr	x8, [x8, _audio_clock_tweak@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	add	w9, w8, #1023
	cmp	w9, #2047
	csel	w22, w8, wzr, lo
	cbz	x2, LBB0_2
; %bb.1:
	ldr	w8, [x19, #12]
	mov	w9, #19923
	movk	w9, #4194, lsl #16
	ldp	w10, w11, [x19]
	smull	x12, w10, w9
	lsr	x13, x12, #63
	asr	x12, x12, #38
	add	w3, w12, w13
	mov	w12, #1000
	msub	w4, w3, w12, w10
	smull	x9, w11, w9
	lsr	x10, x9, #63
	asr	x9, x9, #38
	add	w5, w9, w10
	msub	w6, w5, w12, w11
	str	w22, [sp]
Lloh6:
	adrp	x0, l_.str@PAGE
Lloh7:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x2
	mov	x2, x8
	mov	x7, x21
	bl	_dprintk
LBB0_2:
	add	w21, w22, w21
Lloh8:
	adrp	x8, _SAA7134_AUDIO_CLOCKS_PER_FIELD0@GOTPAGE
Lloh9:
	ldr	x8, [x8, _SAA7134_AUDIO_CLOCKS_PER_FIELD0@GOTPAGEOFF]
Lloh10:
	ldr	w0, [x8]
	and	w1, w21, #0xff
	bl	_saa_writeb
Lloh11:
	adrp	x8, _SAA7134_AUDIO_CLOCKS_PER_FIELD1@GOTPAGE
Lloh12:
	ldr	x8, [x8, _SAA7134_AUDIO_CLOCKS_PER_FIELD1@GOTPAGEOFF]
Lloh13:
	ldr	w0, [x8]
	ubfx	w1, w21, #8, #8
	bl	_saa_writeb
Lloh14:
	adrp	x8, _SAA7134_AUDIO_CLOCKS_PER_FIELD2@GOTPAGE
Lloh15:
	ldr	x8, [x8, _SAA7134_AUDIO_CLOCKS_PER_FIELD2@GOTPAGEOFF]
Lloh16:
	ldr	w0, [x8]
	lsr	w1, w21, #16
	bl	_saa_writeb
	ldp	w1, w2, [x19]
	mov	x0, x20
	bl	_tvaudio_setcarrier
	ldr	w8, [x19, #8]
	sub	w8, w8, #128
	cmp	w8, #5
	b.hi	LBB0_4
; %bb.3:
	mov	w9, #59
	lsr	w9, w9, w8
	tbnz	w9, #0, LBB0_5
LBB0_4:
	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
LBB0_5:
                                        ; kill: def $w8 killed $w8 killed $x8 def $x8
	sbfiz	x9, x8, #2, #32
Lloh17:
	adrp	x10, l_switch.table.tvaudio_setmode@PAGE
Lloh18:
	add	x10, x10, l_switch.table.tvaudio_setmode@PAGEOFF
	ldr	w1, [x10, x9]
Lloh19:
	adrp	x10, l_switch.table.tvaudio_setmode.1@PAGE
Lloh20:
	add	x10, x10, l_switch.table.tvaudio_setmode.1@PAGEOFF
	ldr	w19, [x10, x9]
Lloh21:
	adrp	x10, l_switch.table.tvaudio_setmode.2@PAGE
Lloh22:
	add	x10, x10, l_switch.table.tvaudio_setmode.2@PAGEOFF
	ldr	w20, [x10, x9]
	sbfiz	x8, x8, #3, #32
Lloh23:
	adrp	x10, l_switch.table.tvaudio_setmode.3@PAGE
Lloh24:
	add	x10, x10, l_switch.table.tvaudio_setmode.3@PAGEOFF
	ldr	x23, [x10, x8]
Lloh25:
	adrp	x10, l_switch.table.tvaudio_setmode.4@PAGE
Lloh26:
	add	x10, x10, l_switch.table.tvaudio_setmode.4@PAGEOFF
	ldr	w21, [x10, x9]
Lloh27:
	adrp	x10, l_switch.table.tvaudio_setmode.5@PAGE
Lloh28:
	add	x10, x10, l_switch.table.tvaudio_setmode.5@PAGEOFF
	ldr	x24, [x10, x8]
Lloh29:
	adrp	x8, l_switch.table.tvaudio_setmode.6@PAGE
Lloh30:
	add	x8, x8, l_switch.table.tvaudio_setmode.6@PAGEOFF
	ldr	w22, [x8, x9]
Lloh31:
	adrp	x8, _SAA7134_DEMODULATOR@GOTPAGE
Lloh32:
	ldr	x8, [x8, _SAA7134_DEMODULATOR@GOTPAGEOFF]
Lloh33:
	ldr	w0, [x8]
	bl	_saa_writeb
Lloh34:
	adrp	x8, _SAA7134_DCXO_IDENT_CTRL@GOTPAGE
Lloh35:
	ldr	x8, [x8, _SAA7134_DCXO_IDENT_CTRL@GOTPAGEOFF]
Lloh36:
	ldr	w0, [x8]
	mov	x1, x19
	bl	_saa_writeb
Lloh37:
	adrp	x8, _SAA7134_FM_DEEMPHASIS@GOTPAGE
Lloh38:
	ldr	x8, [x8, _SAA7134_FM_DEEMPHASIS@GOTPAGEOFF]
Lloh39:
	ldr	w0, [x8]
	mov	x1, x20
	bl	_saa_writeb
	ldr	w0, [x23]
	mov	x1, x21
	bl	_saa_writeb
	ldr	w0, [x24]
	mov	x1, 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
	b	_saa_writeb
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh17, Lloh18
	.cfi_endproc
                                        ; -- End function
	.comm	_V4L2_STD_NTSC,8,3              ; @V4L2_STD_NTSC
	.comm	_audio_clock_tweak,4,2          ; @audio_clock_tweak
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"tvaudio_setmode: %s %s [%d.%03d/%d.%03d MHz] acpf=%d%+d\n"

	.comm	_SAA7134_AUDIO_CLOCKS_PER_FIELD0,4,2 ; @SAA7134_AUDIO_CLOCKS_PER_FIELD0
	.comm	_SAA7134_AUDIO_CLOCKS_PER_FIELD1,4,2 ; @SAA7134_AUDIO_CLOCKS_PER_FIELD1
	.comm	_SAA7134_AUDIO_CLOCKS_PER_FIELD2,4,2 ; @SAA7134_AUDIO_CLOCKS_PER_FIELD2
	.comm	_SAA7134_DEMODULATOR,4,2        ; @SAA7134_DEMODULATOR
	.comm	_SAA7134_DCXO_IDENT_CTRL,4,2    ; @SAA7134_DCXO_IDENT_CTRL
	.comm	_SAA7134_FM_DEEMPHASIS,4,2      ; @SAA7134_FM_DEEMPHASIS
	.comm	_SAA7134_FM_DEMATRIX,4,2        ; @SAA7134_FM_DEMATRIX
	.comm	_SAA7134_STEREO_DAC_OUTPUT_SELECT,4,2 ; @SAA7134_STEREO_DAC_OUTPUT_SELECT
	.comm	_SAA7134_NICAM_CONFIG,4,2       ; @SAA7134_NICAM_CONFIG
	.no_dead_strip	_tvaudio_setmode
	.section	__TEXT,__const
	.p2align	2                               ; @switch.table.tvaudio_setmode
l_switch.table.tvaudio_setmode:
	.long	16                              ; 0x10
	.long	18                              ; 0x12
	.long	0                               ; 0x0
	.long	0                               ; 0x0
	.long	0                               ; 0x0
	.long	0                               ; 0x0

	.p2align	2                               ; @switch.table.tvaudio_setmode.1
l_switch.table.tvaudio_setmode.1:
	.long	0                               ; 0x0
	.long	0                               ; 0x0
	.long	0                               ; 0x0
	.long	0                               ; 0x0
	.long	1                               ; 0x1
	.long	0                               ; 0x0

	.p2align	2                               ; @switch.table.tvaudio_setmode.2
l_switch.table.tvaudio_setmode.2:
	.long	68                              ; 0x44
	.long	68                              ; 0x44
	.long	34                              ; 0x22
	.long	34                              ; 0x22
	.long	34                              ; 0x22
	.long	34                              ; 0x22

	.section	__DATA,__const
	.p2align	3                               ; @switch.table.tvaudio_setmode.3
l_switch.table.tvaudio_setmode.3:
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_FM_DEMATRIX
	.quad	_SAA7134_FM_DEMATRIX
	.quad	_SAA7134_FM_DEMATRIX
	.quad	_SAA7134_FM_DEMATRIX

	.section	__TEXT,__const
	.p2align	2                               ; @switch.table.tvaudio_setmode.4
l_switch.table.tvaudio_setmode.4:
	.long	161                             ; 0xa1
	.long	161                             ; 0xa1
	.long	128                             ; 0x80
	.long	128                             ; 0x80
	.long	128                             ; 0x80
	.long	128                             ; 0x80

	.section	__DATA,__const
	.p2align	3                               ; @switch.table.tvaudio_setmode.5
l_switch.table.tvaudio_setmode.5:
	.quad	_SAA7134_NICAM_CONFIG
	.quad	_SAA7134_NICAM_CONFIG
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT
	.quad	_SAA7134_STEREO_DAC_OUTPUT_SELECT

	.section	__TEXT,__const
	.p2align	2                               ; @switch.table.tvaudio_setmode.6
l_switch.table.tvaudio_setmode.6:
	.long	0                               ; 0x0
	.long	0                               ; 0x0
	.long	160                             ; 0xa0
	.long	160                             ; 0xa0
	.long	160                             ; 0xa0
	.long	160                             ; 0xa0

.subsections_via_symbols
