// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/baselayer.c
// Function: osdcmd_listvidmodes
static int osdcmd_listvidmodes(const osdfuncparm_t *parm)
{
	int filterbpp = -1, filterfs = -1, found = 0;

	for (int i = 0; i < parm->numparms; i++) {
		if (strcasecmp(parm->parms[i], "win") == 0) {
			filterfs = 0;
		} else if (strcasecmp(parm->parms[i], "fs") == 0) {
			filterfs = 1;
		} else {
			char *e = NULL;
			long l = strtol(parm->parms[i], &e, 10);
			if (!e || *e != 0) return OSDCMD_SHOWHELP;
			filterbpp = (int)l;
		}
	}

	for (int i = 0; i < validmodecnt; i++) {
		if (filterbpp >= 0 && validmode[i].bpp != filterbpp) continue;
		if (filterfs >= 0 && (validmode[i].fs & 1) != filterfs) continue;
		buildprintf(" %4dx%-4d %d-bit %s\n", validmode[i].xdim, validmode[i].ydim,
			validmode[i].bpp, (validmode[i].fs & 1) ? "fullscreen" : "windowed");
		found++;
	}
	buildprintf("%d modes identified\n", found);
	return OSDCMD_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x2e44d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x83a72(%rip), %rsi     # 0xb1e20
callq 0x67c0
cmpl $0x0, %eax
jne 0x2e3c1
movl $0x0, -0x18(%rbp)
jmp 0x2e43d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x83a4c(%rip), %rsi     # 0xb1e24
callq 0x67c0
cmpl $0x0, %eax
jne 0x2e3eb
movl $0x1, -0x18(%rbp)
jmp 0x2e43b
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x28(%rbp), %rsi
movl $0xa, %edx
callq 0x68a0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2e428
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x2e434
movl $0x1, -0x4(%rbp)
jmp 0x2e55f
movq -0x30(%rbp), %rax
movl %eax, -0x14(%rbp)
jmp 0x2e43d
jmp 0x2e43f
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2e388
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
leaq 0x36bfb2(%rip), %rcx    # 0x39a410
cmpl (%rcx), %eax
jge 0x2e547
cmpl $0x0, -0x14(%rbp)
jl 0x2e48c
movslq -0x34(%rbp), %rcx
leaq 0x447339(%rip), %rax    # 0x4757b0
shlq $0x4, %rcx
addq %rcx, %rax
movzbl 0x8(%rax), %eax
cmpl -0x14(%rbp), %eax
je 0x2e48c
jmp 0x2e539
cmpl $0x0, -0x18(%rbp)
jl 0x2e4b5
movslq -0x34(%rbp), %rcx
leaq 0x447313(%rip), %rax    # 0x4757b0
shlq $0x4, %rcx
addq %rcx, %rax
movzbl 0x9(%rax), %eax
andl $0x1, %eax
cmpl -0x18(%rbp), %eax
je 0x2e4b5
jmp 0x2e539
movslq -0x34(%rbp), %rcx
leaq 0x4472f0(%rip), %rax    # 0x4757b0
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %esi
movslq -0x34(%rbp), %rcx
leaq 0x4472dc(%rip), %rax    # 0x4757b0
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %edx
movslq -0x34(%rbp), %rcx
leaq 0x4472c7(%rip), %rax    # 0x4757b0
shlq $0x4, %rcx
addq %rcx, %rax
movzbl 0x8(%rax), %ecx
movslq -0x34(%rbp), %rdi
leaq 0x4472b1(%rip), %rax    # 0x4757b0
shlq $0x4, %rdi
addq %rdi, %rax
movzbl 0x9(%rax), %edi
andl $0x1, %edi
leaq 0x83928(%rip), %r8      # 0xb1e3c
leaq 0x82a40(%rip), %rax     # 0xb0f5b
cmpl $0x0, %edi
cmovneq %rax, %r8
leaq 0x838fe(%rip), %rdi     # 0xb1e27
movb $0x0, %al
callq 0x37c90
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2e454
movl -0x1c(%rbp), %esi
leaq 0x838f4(%rip), %rdi     # 0xb1e45
movb $0x0, %al
callq 0x37c90
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)