// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/startgtk_game.c
// Function: populate_video_modes
static void populate_video_modes(gboolean firsttime)
{
    int i, mode3d = -1;
    int xdim = 0, ydim = 0, bpp = 0, fullscreen = 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;
    } 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;
        }
    }

    // Find an ideal match.
    mode3d = checkvideomode(&xdim, &ydim, bpp, fullscreen, 1);
    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);
    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);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movl %ebp, 0x8(%rsp)
movl %ebp, 0x4(%rsp)
testl %edi, %edi
je 0x32949
callq 0x8218e
movq 0x2fc622(%rip), %rax    # 0x32ef10
movl 0x4(%rax), %ecx
movl %ecx, 0x8(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x4(%rsp)
movl (%rax), %ebx
movl 0xc(%rax), %ebp
leaq 0x8(%rsp), %rdi
leaq 0x4(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x32bf8
movl %eax, 0xc(%rsp)
testl %eax, %eax
jns 0x32a3e
xorl %r12d, %r12d
leaq 0x72d70(%rip), %r13     # 0xa56a0
cmpl %ebp, (%r12,%r13)
jl 0x32a01
addq $0x4, %r12
cmpq $0x14, %r12
jne 0x32930
jmp 0x32a3e
movq 0x2fc570(%rip), %rbx    # 0x32eec0
callq 0x90f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8400
movl %eax, %ebx
movq 0x2fc53f(%rip), %r14    # 0x32eeb0
callq 0x88d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x91b0
testl %eax, %eax
je 0x32901
movq 0x2fc51b(%rip), %r14    # 0x32eeb8
callq 0x85c0
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
xorl %ebp, %ebp
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %r14
movq %rax, %rdi
movl $0x1, %edx
movq %r14, %rcx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x8970
movslq (%r14), %rax
testq %rax, %rax
js 0x32901
shlq $0x4, %rax
leaq 0x5ba2e8(%rip), %rcx    # 0x5eccd0
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %esi
movl %edx, 0x8(%rsp)
movl %esi, 0x4(%rsp)
movzbl 0x8(%rcx,%rax), %ebp
jmp 0x32901
cmpq $0x14, %r12
je 0x32a3e
leaq 0x8(%rsp), %r14
leaq 0x4(%rsp), %r15
movl (%r12,%r13), %edx
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x32bf8
movl %eax, 0xc(%rsp)
testl %eax, %eax
jns 0x32a3e
leaq 0x4(%r12), %rax
cmpq $0x10, %r12
movq %rax, %r12
jne 0x32a11
movq 0x2fc473(%rip), %rdi    # 0x32eeb8
callq 0x84e0
leaq 0x4dbcdf(%rip), %rbp    # 0x50e730
cmpl $0x0, (%rbp)
jle 0x32b1e
leaq 0x5ba26e(%rip), %r14    # 0x5eccd0
addq $0x9, %r14
leaq 0x72ac9(%rip), %r13     # 0xa5536
leaq 0x30(%rsp), %r15
xorl %r12d, %r12d
movzbl (%r14), %eax
cmpl %eax, %ebx
jne 0x32b0a
movl -0x9(%r14), %edx
movl -0x5(%r14), %ecx
movzbl -0x1(%r14), %r8d
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x8f20
movq 0x2fc416(%rip), %rdi    # 0x32eeb8
leaq 0x10(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movq %r15, %r8
movl $0x1, %r9d
xorl %eax, %eax
pushq $-0x1
pushq %r12
callq 0x8aa0
addq $0x10, %rsp
movl 0xc(%rsp), %eax
cmpq %rax, %r12
jne 0x32b0a
movl %ebx, %r15d
movq %rbp, %rbx
movq %r13, %rbp
movq 0x2fc3d1(%rip), %r13    # 0x32eeb0
callq 0x88d0
movq %r13, %rdi
movq %rbp, %r13
movq %rbx, %rbp
movl %r15d, %ebx
leaq 0x30(%rsp), %r15
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8730
incq %r12
movslq (%rbp), %rax
addq $0x10, %r14
cmpq %rax, %r12
jl 0x32a75
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq