// File: /workspace/github_c_makefile_star2_O2/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
orl $-0x1, 0xc(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, 0x4(%rsp)
testl %edi, %edi
je 0x2ece5
callq 0x75266
movq 0x2f6285(%rip), %rax    # 0x324f10
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
pushq $0x1
popq %r8
movl %ebp, %edx
movl %ebx, %ecx
callq 0x2ef84
movl %eax, 0xc(%rsp)
testl %eax, %eax
jns 0x2edcc
xorl %r12d, %r12d
leaq 0x68895(%rip), %r13     # 0x97560
cmpq $0x14, %r12
je 0x2ed99
cmpl %ebp, (%r12,%r13)
jl 0x2ed99
addq $0x4, %r12
jmp 0x2eccb
movq 0x2f61d4(%rip), %rbx    # 0x324ec0
callq 0x90f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8400
movl %eax, %ebx
movq 0x2f61a3(%rip), %r14    # 0x324eb0
callq 0x88d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x91b0
testl %eax, %eax
je 0x2eeb0
movq 0x2f617f(%rip), %r14    # 0x324eb8
callq 0x85c0
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
xorl %ebp, %ebp
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xc(%rsp), %r14
pushq $-0x1
popq %r8
movq %rax, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x8970
movslq (%r14), %rax
testq %rax, %rax
js 0x2ec9e
shlq $0x4, %rax
leaq 0x5b3f50(%rip), %rcx    # 0x5e2cd0
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %esi
movl %edx, 0x8(%rsp)
movl %esi, 0x4(%rsp)
movzbl 0x8(%rcx,%rax), %ebp
jmp 0x2ec9e
leaq 0x8(%rsp), %r14
leaq 0x4(%rsp), %r15
pushq $0x1
popq %rbp
cmpq $0x14, %r12
je 0x2edcc
movl (%r12,%r13), %edx
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl %ebp, %r8d
callq 0x2ef84
movl %eax, 0xc(%rsp)
addq $0x4, %r12
testl %eax, %eax
js 0x2eda6
movq 0x2f60e5(%rip), %rdi    # 0x324eb8
callq 0x84e0
leaq 0x5b3ef1(%rip), %rbp    # 0x5e2cd0
addq $0x9, %rbp
leaq 0x4d5946(%rip), %r13    # 0x504730
leaq 0x68605(%rip), %r14     # 0x973f6
leaq 0x30(%rsp), %r15
xorl %r12d, %r12d
movslq (%r13), %rax
cmpq %rax, %r12
jge 0x2eea1
movzbl (%rbp), %eax
cmpl %eax, %ebx
jne 0x2ee95
movl -0x9(%rbp), %edx
movl -0x5(%rbp), %ecx
movzbl -0x1(%rbp), %r8d
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x8f20
movq 0x2f6087(%rip), %rdi    # 0x324eb8
leaq 0x10(%rsp), %rsi
pushq $-0x1
popq %rdx
xorl %ecx, %ecx
movq %r15, %r8
pushq $0x1
popq %r9
xorl %eax, %eax
pushq $-0x1
pushq %r12
callq 0x8aa0
popq %rax
popq %rcx
movl 0xc(%rsp), %eax
cmpq %rax, %r12
jne 0x2ee95
movq %r15, %r13
movl %ebx, %r15d
movq %r14, %rbx
movq 0x2f6048(%rip), %r14    # 0x324eb0
callq 0x88d0
movq %r14, %rdi
movq %rbx, %r14
movl %r15d, %ebx
movq %r13, %r15
leaq 0x4d58b0(%rip), %r13    # 0x504730
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8730
incq %r12
addq $0x10, %rbp
jmp 0x2edf9
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x2ec9e