	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mga_vga_mode_valid
_mga_vga_mode_valid:                    ## @mga_vga_mode_valid
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r15
	movq	%rdi, %r14
	movq	16(%rdi), %rax
	movq	(%rax), %rbx
	movq	%rbx, %rdi
	callq	_IS_G200_SE
	testq	%rax, %rax
	je	LBB0_5
## %bb.1:
	movl	(%rbx), %eax
	cmpl	$2, %eax
	je	LBB0_9
## %bb.2:
	cmpl	$1, %eax
	jne	LBB0_27
## %bb.3:
	cmpl	$1600, (%r15)                   ## imm = 0x640
	jg	LBB0_4
## %bb.36:
	cmpl	$1200, 4(%r15)                  ## imm = 0x4B0
	jg	LBB0_37
## %bb.38:
	movq	%r15, %rdi
	movl	$32, %esi
	callq	_mga_vga_calculate_mode_bandwidth
	cmpl	$24985600, %eax                 ## imm = 0x17D4000
	jle	LBB0_12
	jmp	LBB0_39
LBB0_5:
	movq	8(%rbx), %rax
	movq	_G200_WB@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_28
## %bb.6:
	cmpl	$1280, (%r15)                   ## imm = 0x500
	jg	LBB0_4
## %bb.7:
	cmpl	$1024, 4(%r15)                  ## imm = 0x400
	jg	LBB0_37
## %bb.8:
	movq	%r15, %rdi
	movl	$32, %esi
	callq	_mga_vga_calculate_mode_bandwidth
	cmpl	$32642048, %eax                 ## imm = 0x1F21400
	jle	LBB0_12
	jmp	LBB0_39
LBB0_9:
	cmpl	$1920, (%r15)                   ## imm = 0x780
	jle	LBB0_10
LBB0_4:
	movq	_MODE_VIRTUAL_X@GOTPCREL(%rip), %rax
	jmp	LBB0_46
LBB0_28:
	movq	_G200_EV@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_31
## %bb.29:
	movq	%r15, %rdi
	movl	$32, %esi
	callq	_mga_vga_calculate_mode_bandwidth
	cmpl	$33484800, %eax                 ## imm = 0x1FEF000
	jg	LBB0_39
## %bb.30:
	movq	8(%rbx), %rax
LBB0_31:
	movq	_G200_EH@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_34
## %bb.32:
	movq	%r15, %rdi
	movl	$32, %esi
	callq	_mga_vga_calculate_mode_bandwidth
	cmpl	$38400000, %eax                 ## imm = 0x249F000
	jg	LBB0_39
## %bb.33:
	movq	8(%rbx), %rax
LBB0_34:
	movq	_G200_ER@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_12
LBB0_27:
	movq	%r15, %rdi
	movl	$32, %esi
	callq	_mga_vga_calculate_mode_bandwidth
	cmpl	$56320000, %eax                 ## imm = 0x35B6000
	jle	LBB0_12
LBB0_39:
	movq	_MODE_BANDWIDTH@GOTPCREL(%rip), %rax
	jmp	LBB0_46
LBB0_10:
	cmpl	$1200, 4(%r15)                  ## imm = 0x4B0
	jle	LBB0_11
LBB0_37:
	movq	_MODE_VIRTUAL_Y@GOTPCREL(%rip), %rax
	jmp	LBB0_46
LBB0_11:
	movq	%r15, %rdi
	movl	$32, %esi
	callq	_mga_vga_calculate_mode_bandwidth
	cmpl	$30822400, %eax                 ## imm = 0x1D65000
	jg	LBB0_39
LBB0_12:
	movl	(%r15), %ecx
	movq	_MODE_H_ILLEGAL@GOTPCREL(%rip), %rax
	testb	$7, %cl
	jne	LBB0_46
## %bb.13:
	testb	$7, 8(%r15)
	jne	LBB0_46
## %bb.14:
	testb	$7, 12(%r15)
	jne	LBB0_46
## %bb.15:
	testb	$7, 16(%r15)
	jne	LBB0_46
## %bb.16:
	movq	_MODE_BAD@GOTPCREL(%rip), %rax
	cmpl	$2048, 20(%r15)                 ## imm = 0x800
	jg	LBB0_46
## %bb.17:
	cmpl	$4096, 24(%r15)                 ## imm = 0x1000
	jg	LBB0_46
## %bb.18:
	cmpl	$4096, 28(%r15)                 ## imm = 0x1000
	jg	LBB0_46
## %bb.19:
	cmpl	$4096, 32(%r15)                 ## imm = 0x1000
	jg	LBB0_46
## %bb.20:
	cmpl	$2048, 36(%r15)                 ## imm = 0x800
	jg	LBB0_46
## %bb.21:
	cmpl	$4096, 40(%r15)                 ## imm = 0x1000
	jg	LBB0_46
## %bb.22:
	cmpl	$4096, 44(%r15)                 ## imm = 0x1000
	jg	LBB0_46
## %bb.23:
	cmpl	$4096, 48(%r15)                 ## imm = 0x1000
	jg	LBB0_46
## %bb.24:
	cmpl	$0, (%r14)
	je	LBB0_40
## %bb.25:
	cmpq	$0, 8(%r14)
	je	LBB0_42
## %bb.26:
	movl	4(%r14), %esi
	leal	7(%rsi), %edx
	testl	%esi, %esi
	cmovnsl	%esi, %edx
	sarl	$3, %edx
	jmp	LBB0_43
LBB0_40:
	imull	4(%r15), %ecx
	shll	$2, %ecx
	cmpl	16(%rbx), %ecx
	jle	LBB0_45
## %bb.41:
	movq	_MODE_BAD@GOTPCREL(%rip), %rax
	jmp	LBB0_46
LBB0_42:
	movl	$4, %edx
LBB0_43:
	imull	%ecx, %edx
	imull	4(%r15), %edx
	cmpl	16(%rbx), %edx
	jle	LBB0_45
## %bb.44:
	movl	$0, (%r14)
	jmp	LBB0_46
LBB0_45:
	movq	_MODE_OK@GOTPCREL(%rip), %rax
LBB0_46:
	movl	(%rax), %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MODE_VIRTUAL_X,4,2             ## @MODE_VIRTUAL_X
	.comm	_MODE_VIRTUAL_Y,4,2             ## @MODE_VIRTUAL_Y
	.comm	_MODE_BANDWIDTH,4,2             ## @MODE_BANDWIDTH
	.comm	_G200_WB,8,3                    ## @G200_WB
	.comm	_G200_EV,8,3                    ## @G200_EV
	.comm	_G200_EH,8,3                    ## @G200_EH
	.comm	_G200_ER,8,3                    ## @G200_ER
	.comm	_MODE_H_ILLEGAL,4,2             ## @MODE_H_ILLEGAL
	.comm	_MODE_BAD,4,2                   ## @MODE_BAD
	.comm	_MODE_OK,4,2                    ## @MODE_OK
	.no_dead_strip	_mga_vga_mode_valid
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mga_vga_mode_valid
_mga_vga_mode_valid:                    ; @mga_vga_mode_valid
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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	x21, x1
	mov	x19, x0
	ldr	x8, [x0, #16]
	ldr	x20, [x8]
	mov	x0, x20
	bl	_IS_G200_SE
	cbz	x0, LBB0_6
; %bb.1:
	ldr	w8, [x20]
	cmp	w8, #2
	b.eq	LBB0_10
; %bb.2:
	cmp	w8, #1
	b.ne	LBB0_19
; %bb.3:
	ldr	w8, [x21]
	cmp	w8, #1600
	b.gt	LBB0_11
; %bb.4:
	ldr	w8, [x21, #4]
	cmp	w8, #1200
	b.gt	LBB0_22
; %bb.5:
	mov	x0, x21
	mov	w1, #32
	bl	_mga_vga_calculate_mode_bandwidth
	mov	w8, #16384
	movk	w8, #381, lsl #16
	cmp	w0, w8
	b.le	LBB0_24
	b	LBB0_20
LBB0_6:
	ldr	x8, [x20, #8]
Lloh0:
	adrp	x9, _G200_WB@GOTPAGE
Lloh1:
	ldr	x9, [x9, _G200_WB@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_12
; %bb.7:
	ldr	w8, [x21]
	cmp	w8, #1280
	b.gt	LBB0_11
; %bb.8:
	ldr	w8, [x21, #4]
	cmp	w8, #1024
	b.gt	LBB0_22
; %bb.9:
	mov	x0, x21
	mov	w1, #32
	bl	_mga_vga_calculate_mode_bandwidth
	mov	w8, #5120
	movk	w8, #498, lsl #16
	cmp	w0, w8
	b.le	LBB0_24
	b	LBB0_20
LBB0_10:
	ldr	w8, [x21]
	cmp	w8, #1920
	b.le	LBB0_21
LBB0_11:
Lloh3:
	adrp	x8, _MODE_VIRTUAL_X@GOTPAGE
Lloh4:
	ldr	x8, [x8, _MODE_VIRTUAL_X@GOTPAGEOFF]
	b	LBB0_29
LBB0_12:
Lloh5:
	adrp	x9, _G200_EV@GOTPAGE
Lloh6:
	ldr	x9, [x9, _G200_EV@GOTPAGEOFF]
Lloh7:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_15
; %bb.13:
	mov	x0, x21
	mov	w1, #32
	bl	_mga_vga_calculate_mode_bandwidth
	mov	w8, #61440
	movk	w8, #510, lsl #16
	cmp	w0, w8
	b.gt	LBB0_20
; %bb.14:
	ldr	x8, [x20, #8]
LBB0_15:
Lloh8:
	adrp	x9, _G200_EH@GOTPAGE
Lloh9:
	ldr	x9, [x9, _G200_EH@GOTPAGEOFF]
Lloh10:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_18
; %bb.16:
	mov	x0, x21
	mov	w1, #32
	bl	_mga_vga_calculate_mode_bandwidth
	mov	w8, #61440
	movk	w8, #510, lsl #16
	add	w8, w8, #1200, lsl #12          ; =4915200
	cmp	w0, w8
	b.gt	LBB0_20
; %bb.17:
	ldr	x8, [x20, #8]
LBB0_18:
Lloh11:
	adrp	x9, _G200_ER@GOTPAGE
Lloh12:
	ldr	x9, [x9, _G200_ER@GOTPAGEOFF]
Lloh13:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_24
LBB0_19:
	mov	x0, x21
	mov	w1, #32
	bl	_mga_vga_calculate_mode_bandwidth
	mov	w8, #24576
	movk	w8, #859, lsl #16
	cmp	w0, w8
	b.le	LBB0_24
LBB0_20:
Lloh14:
	adrp	x8, _MODE_BANDWIDTH@GOTPAGE
Lloh15:
	ldr	x8, [x8, _MODE_BANDWIDTH@GOTPAGEOFF]
	b	LBB0_29
LBB0_21:
	ldr	w8, [x21, #4]
	cmp	w8, #1200
	b.le	LBB0_23
LBB0_22:
Lloh16:
	adrp	x8, _MODE_VIRTUAL_Y@GOTPAGE
Lloh17:
	ldr	x8, [x8, _MODE_VIRTUAL_Y@GOTPAGEOFF]
	b	LBB0_29
LBB0_23:
	mov	x0, x21
	mov	w1, #32
	bl	_mga_vga_calculate_mode_bandwidth
	mov	w8, #16384
	movk	w8, #381, lsl #16
	add	w8, w8, #1425, lsl #12          ; =5836800
	cmp	w0, w8
	b.gt	LBB0_20
LBB0_24:
	ldr	w9, [x21]
	tst	w9, #0x7
	b.ne	LBB0_28
; %bb.25:
	ldrb	w8, [x21, #8]
	tst	w8, #0x7
	b.ne	LBB0_28
; %bb.26:
	ldrb	w8, [x21, #12]
	tst	w8, #0x7
	b.ne	LBB0_28
; %bb.27:
	ldrb	w8, [x21, #16]
	tst	w8, #0x7
	b.eq	LBB0_30
LBB0_28:
Lloh18:
	adrp	x8, _MODE_H_ILLEGAL@GOTPAGE
Lloh19:
	ldr	x8, [x8, _MODE_H_ILLEGAL@GOTPAGEOFF]
LBB0_29:
	ldr	w0, [x8]
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
LBB0_30:
	ldr	w8, [x21, #20]
	cmp	w8, #2048
	b.gt	LBB0_37
; %bb.31:
	ldr	w8, [x21, #24]
	cmp	w8, #1, lsl #12                 ; =4096
	b.gt	LBB0_37
; %bb.32:
	ldr	w8, [x21, #28]
	cmp	w8, #1, lsl #12                 ; =4096
	b.gt	LBB0_37
; %bb.33:
	ldr	w8, [x21, #32]
	cmp	w8, #1, lsl #12                 ; =4096
	b.gt	LBB0_37
; %bb.34:
	ldr	w8, [x21, #36]
	cmp	w8, #2048
	b.gt	LBB0_37
; %bb.35:
	ldr	w8, [x21, #40]
	cmp	w8, #1, lsl #12                 ; =4096
	b.gt	LBB0_37
; %bb.36:
	ldr	w8, [x21, #44]
	cmp	w8, #1, lsl #12                 ; =4096
	b.le	LBB0_38
LBB0_37:
Lloh20:
	adrp	x8, _MODE_BAD@GOTPAGE
Lloh21:
	ldr	x8, [x8, _MODE_BAD@GOTPAGEOFF]
	b	LBB0_29
LBB0_38:
	ldr	w10, [x21, #48]
Lloh22:
	adrp	x8, _MODE_BAD@GOTPAGE
Lloh23:
	ldr	x8, [x8, _MODE_BAD@GOTPAGEOFF]
	cmp	w10, #1, lsl #12                ; =4096
	b.gt	LBB0_29
; %bb.39:
	ldr	w10, [x19]
	cbz	w10, LBB0_42
; %bb.40:
	ldr	x8, [x19, #8]
	cbz	x8, LBB0_43
; %bb.41:
	ldr	w8, [x19, #4]
	add	w10, w8, #7
	cmp	w8, #0
	csel	w8, w10, w8, lt
	asr	w8, w8, #3
	b	LBB0_44
LBB0_42:
	ldr	w10, [x21, #4]
	mul	w9, w9, w10
	ldr	w10, [x20, #16]
Lloh24:
	adrp	x11, _MODE_OK@GOTPAGE
Lloh25:
	ldr	x11, [x11, _MODE_OK@GOTPAGEOFF]
	cmp	w10, w9, lsl #2
	csel	x8, x8, x11, lt
	b	LBB0_29
LBB0_43:
	mov	w8, #4
LBB0_44:
	ldr	w10, [x21, #4]
	mul	w8, w8, w9
	mul	w8, w8, w10
	ldr	w9, [x20, #16]
	cmp	w8, w9
	b.le	LBB0_46
; %bb.45:
	str	wzr, [x19]
	b	LBB0_37
LBB0_46:
Lloh26:
	adrp	x8, _MODE_OK@GOTPAGE
Lloh27:
	ldr	x8, [x8, _MODE_OK@GOTPAGEOFF]
	b	LBB0_29
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.comm	_MODE_VIRTUAL_X,4,2             ; @MODE_VIRTUAL_X
	.comm	_MODE_VIRTUAL_Y,4,2             ; @MODE_VIRTUAL_Y
	.comm	_MODE_BANDWIDTH,4,2             ; @MODE_BANDWIDTH
	.comm	_G200_WB,8,3                    ; @G200_WB
	.comm	_G200_EV,8,3                    ; @G200_EV
	.comm	_G200_EH,8,3                    ; @G200_EH
	.comm	_G200_ER,8,3                    ; @G200_ER
	.comm	_MODE_H_ILLEGAL,4,2             ; @MODE_H_ILLEGAL
	.comm	_MODE_BAD,4,2                   ; @MODE_BAD
	.comm	_MODE_OK,4,2                    ; @MODE_OK
	.no_dead_strip	_mga_vga_mode_valid
.subsections_via_symbols
