// File: /workspace/github_c_makefile_star2_O2/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
orl $-0x1, 0x1c(%rsp)
orl $-0x1, 0x8(%rsp)
andl $0x0, 0x10(%rsp)
andl $0x0, 0xc(%rsp)
andl $0x0, 0x18(%rsp)
andl $0x0, 0x14(%rsp)
testl %edi, %edi
je 0x1c5f8
callq 0x62cee
movq 0x15ab18(%rip), %rax    # 0x177080
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
pushq $0x1
popq %r14
movl %ebp, %edx
movl %ebx, %ecx
movl %r14d, %r8d
callq 0x1c8dc
movl %eax, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x14(%rsp), %rsi
pushq $0x8
popq %rdx
movl %ebx, %ecx
movl %r14d, %r8d
callq 0x1c8dc
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, 0x1c(%rsp)
cmpl $0x0, 0x8(%rsp)
jns 0x1c6e2
xorl %r12d, %r12d
leaq 0x4e672(%rip), %r13     # 0x6ac50
cmpq $0x14, %r12
je 0x1c6af
cmpl %ebp, (%r12,%r13)
jl 0x1c6af
addq $0x4, %r12
jmp 0x1c5de
movq 0x15aa71(%rip), %rbx    # 0x177070
callq 0x6c10
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6140
movq %rax, %rdi
callq 0x62d0
movl %eax, %ebx
movq 0x15aa40(%rip), %r15    # 0x177060
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 0x1c853
movq 0x15aa19(%rip), %r15    # 0x177068
callq 0x6440
movq %r15, %rdi
movq %rax, %rsi
callq 0x6140
xorl %ebp, %ebp
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0x8(%rsp), %r15
pushq $-0x1
popq %r8
movq %rax, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x66b0
movslq (%r15), %rax
testq %rax, %rax
js 0x1c855
shlq $0x4, %rax
leaq 0x4187ba(%rip), %rcx    # 0x434e50
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %esi
movl %edx, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movzbl 0x8(%rcx,%rax), %ebp
jmp 0x1c855
leaq 0x10(%rsp), %r14
leaq 0xc(%rsp), %r15
pushq $0x1
popq %rbp
cmpq $0x14, %r12
je 0x1c6e2
movl (%r12,%r13), %edx
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl %ebp, %r8d
callq 0x1c8dc
movl %eax, 0x8(%rsp)
addq $0x4, %r12
testl %eax, %eax
js 0x1c6bc
movq 0x15a97f(%rip), %rdi    # 0x177068
callq 0x6370
movq 0x15a963(%rip), %rdi    # 0x177058
callq 0x6370
leaq 0x41874f(%rip), %rbp    # 0x434e50
addq $0x9, %rbp
leaq 0x33a1a4(%rip), %r13    # 0x3568b0
leaq 0x40(%rsp), %r15
leaq 0x20(%rsp), %r14
xorl %r12d, %r12d
movslq (%r13), %rax
cmpq %rax, %r12
jge 0x1c841
movzbl (%rbp), %eax
cmpl %eax, %ebx
jne 0x1c835
movl -0x9(%rbp), %edx
movl -0x5(%rbp), %ecx
movzbl -0x1(%rbp), %r8d
movq %r15, %rdi
leaq 0x4e4e2(%rip), %rsi     # 0x6ac29
xorl %eax, %eax
callq 0x6b00
movq 0x15a913(%rip), %rdi    # 0x177068
movq %r14, %rsi
pushq $-0x1
popq %rdx
xorl %ecx, %ecx
movq %r15, %r8
pushq $0x1
popq %r9
xorl %eax, %eax
pushq $-0x1
pushq %r12
callq 0x6780
popq %rax
popq %rcx
movl 0x8(%rsp), %eax
cmpq %rax, %r12
jne 0x1c7a9
movq %r14, %r13
movq 0x15a8dc(%rip), %r14    # 0x177060
callq 0x6640
movq %r14, %rdi
movq %r13, %r14
leaq 0x33a11a(%rip), %r13    # 0x3568b0
movq %rax, %rsi
callq 0x6140
movq %rax, %rdi
movq %r14, %rsi
callq 0x6510
cmpb $0x8, -0x1(%rbp)
jne 0x1c835
movl -0x9(%rbp), %edx
cmpl $0x280, %edx            # imm = 0x280
jl 0x1c835
movl -0x5(%rbp), %ecx
cmpl $0x1e0, %ecx            # imm = 0x1E0
jl 0x1c835
movq %r15, %rdi
leaq 0x4e466(%rip), %rsi     # 0x6ac39
xorl %eax, %eax
callq 0x6b00
movq 0x15a877(%rip), %rdi    # 0x177058
movq %r14, %rsi
pushq $-0x1
popq %rdx
xorl %ecx, %ecx
movq %r15, %r8
pushq $0x1
popq %r9
xorl %eax, %eax
pushq $-0x1
pushq %r12
callq 0x6780
popq %rax
popq %rcx
movl 0x1c(%rsp), %eax
cmpq %rax, %r12
jne 0x1c835
movq %r14, %r13
movq 0x15a840(%rip), %r14    # 0x177050
callq 0x6640
movq %r14, %rdi
movq %r13, %r14
leaq 0x33a08e(%rip), %r13    # 0x3568b0
movq %rax, %rsi
callq 0x6140
movq %rax, %rdi
movq %r14, %rsi
callq 0x6510
incq %r12
addq $0x10, %rbp
jmp 0x1c719
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
movq 0x15a7f4(%rip), %rdi    # 0x177050
movq %r14, %rsi
callq 0x6140
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x6cc0
testl %eax, %eax
je 0x1c589
movq 0x15a7d8(%rip), %r14    # 0x177058
callq 0x6440
movq %r14, %rdi
movq %rax, %rsi
callq 0x6140
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0x1c(%rsp), %r14
pushq $-0x1
popq %r8
movq %rax, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x66b0
movslq (%r14), %rax
testq %rax, %rax
js 0x1c589
shlq $0x4, %rax
leaq 0x41858b(%rip), %rcx    # 0x434e50
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %eax
movl %edx, 0x18(%rsp)
jmp 0x1c585