// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/startgtk_editor.c
// Function: populate_video_modes
static void populate_video_modes(gboolean firsttime)
{
    int i, mode2d = -1, mode3d = -1;
    int xdim = 0, ydim = 0, bpp = 0, fullscreen = 0;
    int xdim2d = 0, ydim2d = 0;
    char modestr[64];
    int cd[] = { 32, 24, 16, 15, 8, 0 };
    GtkTreeIter iter;

    if (firsttime) {
        getvalidmodes();
        xdim = settings->xdim3d;
        ydim = settings->ydim3d;
        bpp  = settings->bpp3d;
        fullscreen = settings->fullscreen;

        xdim2d = settings->xdim2d;
        ydim2d = settings->ydim2d;
    } else {
        // Read back the current resolution information selected in the combobox.
        fullscreen = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(controls.fullscreencheck));
        if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(controls.vmode3dcombo), &iter)) {
            gtk_tree_model_get(GTK_TREE_MODEL(controls.vmode3dlist), &iter, 1 /*index*/, &mode3d, -1);
        }
        if (mode3d >= 0) {
            xdim = validmode[mode3d].xdim;
            ydim = validmode[mode3d].ydim;
            bpp = validmode[mode3d].bpp;
        }
        if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(controls.vmode2dcombo), &iter)) {
            gtk_tree_model_get(GTK_TREE_MODEL(controls.vmode2dlist), &iter, 1 /*index*/, &mode2d, -1);
        }
        if (mode2d >= 0) {
            xdim2d = validmode[mode2d].xdim;
            ydim2d = validmode[mode2d].ydim;
        }
    }

    // Find an ideal match.
    mode3d = checkvideomode(&xdim, &ydim, bpp, fullscreen, 1);
    mode2d = checkvideomode(&xdim2d, &ydim2d, 8, fullscreen, 1);
    if (mode2d < 0) {
        mode2d = 0;
    }
    if (mode3d < 0) {
        for (i=0; cd[i]; ) { if (cd[i] >= bpp) i++; else break; }
        for ( ; cd[i]; i++) {
            mode3d = checkvideomode(&xdim, &ydim, cd[i], fullscreen, 1);
            if (mode3d < 0) continue;
            break;
        }
    }

    // Repopulate the list.
    gtk_list_store_clear(controls.vmode3dlist);
    gtk_list_store_clear(controls.vmode2dlist);
    for (i = 0; i < validmodecnt; i++) {
        if (validmode[i].fs != fullscreen) continue;

        sprintf(modestr, "%d \xc3\x97 %d %d-bpp",
            validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
        gtk_list_store_insert_with_values(controls.vmode3dlist,
            &iter, -1,
            0, modestr, 1, i, -1);
        if (i == mode3d) {
            gtk_combo_box_set_active_iter(GTK_COMBO_BOX(controls.vmode3dcombo), &iter);
        }

        if (validmode[i].bpp == 8 && validmode[i].xdim >= 640 && validmode[i].ydim >= 480) {
            sprintf(modestr, "%d \xc3\x97 %d",
                validmode[i].xdim, validmode[i].ydim);
            gtk_list_store_insert_with_values(controls.vmode2dlist,
                &iter, -1,
                0, modestr, 1, i, -1);
            if (i == mode2d) {
                gtk_combo_box_set_active_iter(GTK_COMBO_BOX(controls.vmode2dcombo), &iter);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x1c(%rsp)
movl %eax, 0x8(%rsp)
xorl %ebp, %ebp
movl %ebp, 0x10(%rsp)
movl %ebp, 0xc(%rsp)
movl %ebp, 0x18(%rsp)
movl %ebp, 0x14(%rsp)
testl %edi, %edi
je 0x1ebc1
callq 0x6e442
movq 0x15f552(%rip), %rax    # 0x17e080
movl 0xc(%rax), %ecx
movl %ecx, 0x10(%rsp)
movl 0x10(%rax), %ecx
movl %ecx, 0xc(%rsp)
movl 0x14(%rax), %ebp
movl (%rax), %ebx
movl 0x4(%rax), %ecx
movl %ecx, 0x18(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x14(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x1eec0
movl %eax, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x14(%rsp), %rsi
movl $0x8, %edx
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x1eec0
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, 0x1c(%rsp)
cmpl $0x0, 0x8(%rsp)
jns 0x1ed30
xorl %r12d, %r12d
leaq 0x57168(%rip), %r13     # 0x75d10
cmpl %ebp, (%r12,%r13)
jl 0x1ecf3
addq $0x4, %r12
cmpq $0x14, %r12
jne 0x1eba8
jmp 0x1ed30
movq 0x15f4a8(%rip), %rbx    # 0x17e070
callq 0x6c10
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6140
movq %rax, %rdi
callq 0x62d0
movl %eax, %ebx
movq 0x15f477(%rip), %r15    # 0x17e060
callq 0x6640
movq %rax, %r14
movq %r15, %rdi
movq %rax, %rsi
callq 0x6140
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x6cc0
testl %eax, %eax
je 0x1ec6f
movq 0x15f454(%rip), %r15    # 0x17e068
callq 0x6440
movq %r15, %rdi
movq %rax, %rsi
callq 0x6140
xorl %ebp, %ebp
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %r15
movq %rax, %rdi
movl $0x1, %edx
movq %r15, %rcx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x66b0
movslq (%r15), %rax
testq %rax, %rax
js 0x1ec6f
shlq $0x4, %rax
leaq 0x41d1f5(%rip), %rcx    # 0x43be50
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %esi
movl %edx, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movzbl 0x8(%rcx,%rax), %ebp
movq 0x15f3da(%rip), %rdi    # 0x17e050
movq %r14, %rsi
callq 0x6140
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x6cc0
testl %eax, %eax
je 0x1eb4f
movq 0x15f3be(%rip), %r14    # 0x17e058
callq 0x6440
movq %r14, %rdi
movq %rax, %rsi
callq 0x6140
leaq 0x20(%rsp), %rsi
leaq 0x1c(%rsp), %r14
movq %rax, %rdi
movl $0x1, %edx
movq %r14, %rcx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x66b0
movslq (%r14), %rax
testq %rax, %rax
js 0x1eb4f
shlq $0x4, %rax
leaq 0x41d16d(%rip), %rcx    # 0x43be50
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %eax
movl %edx, 0x18(%rsp)
jmp 0x1eb4b
cmpq $0x14, %r12
je 0x1ed30
leaq 0x10(%rsp), %r14
leaq 0xc(%rsp), %r15
movl (%r12,%r13), %edx
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x1eec0
movl %eax, 0x8(%rsp)
testl %eax, %eax
jns 0x1ed30
leaq 0x4(%r12), %rax
cmpq $0x10, %r12
movq %rax, %r12
jne 0x1ed03
movq 0x15f331(%rip), %rdi    # 0x17e068
callq 0x6370
movq 0x15f315(%rip), %rdi    # 0x17e058
callq 0x6370
leaq 0x33eb61(%rip), %r13    # 0x35d8b0
cmpl $0x0, (%r13)
jle 0x1eea6
leaq 0x41d0ef(%rip), %r14    # 0x43be50
addq $0x9, %r14
leaq 0x40(%rsp), %r15
leaq 0x20(%rsp), %rbp
xorl %r12d, %r12d
movzbl (%r14), %eax
cmpl %eax, %ebx
jne 0x1ee92
movl -0x9(%r14), %edx
movl -0x5(%r14), %ecx
movzbl -0x1(%r14), %r8d
movq %r15, %rdi
leaq 0x56f54(%rip), %rsi     # 0x75ce9
xorl %eax, %eax
callq 0x6b00
movq 0x15f2c5(%rip), %rdi    # 0x17e068
movq %rbp, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movq %r15, %r8
movl $0x1, %r9d
xorl %eax, %eax
pushq $-0x1
pushq %r12
callq 0x6780
addq $0x10, %rsp
movl 0x8(%rsp), %eax
cmpq %rax, %r12
jne 0x1edfd
movq %rbp, %r13
movq 0x15f288(%rip), %rbp    # 0x17e060
callq 0x6640
movq %rbp, %rdi
movq %r13, %rbp
leaq 0x33eac6(%rip), %r13    # 0x35d8b0
movq %rax, %rsi
callq 0x6140
movq %rax, %rdi
movq %rbp, %rsi
callq 0x6510
cmpb $0x8, -0x1(%r14)
jne 0x1ee92
movl -0x9(%r14), %edx
cmpl $0x280, %edx            # imm = 0x280
jl 0x1ee92
movl -0x5(%r14), %ecx
cmpl $0x1e0, %ecx            # imm = 0x1E0
jl 0x1ee92
movq %r15, %rdi
leaq 0x56ecf(%rip), %rsi     # 0x75cf9
xorl %eax, %eax
callq 0x6b00
movq 0x15f220(%rip), %rdi    # 0x17e058
movq %rbp, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movq %r15, %r8
movl $0x1, %r9d
xorl %eax, %eax
pushq $-0x1
pushq %r12
callq 0x6780
addq $0x10, %rsp
movl 0x1c(%rsp), %eax
cmpq %rax, %r12
jne 0x1ee92
movq %rbp, %r13
movq 0x15f1e3(%rip), %rbp    # 0x17e050
callq 0x6640
movq %rbp, %rdi
movq %r13, %rbp
leaq 0x33ea31(%rip), %r13    # 0x35d8b0
movq %rax, %rsi
callq 0x6140
movq %rax, %rdi
movq %rbp, %rsi
callq 0x6510
incq %r12
movslq (%r13), %rax
addq $0x10, %r14
cmpq %rax, %r12
jl 0x1ed72
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq