// File: /workspace/github_c_makefile_star2_O1/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, 0x14(%rsp)
movl %eax, 0x8(%rsp)
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, 0x1c(%rsp)
movl %eax, 0x18(%rsp)
testl %edi, %edi
je 0x1e6d8
callq 0x6c714
movq 0x15e9ca(%rip), %rax    # 0x17d080
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, 0x1c(%rsp)
movl 0x8(%rax), %eax
jmp 0x1e7fd
movq 0x15e991(%rip), %rbx    # 0x17d070
callq 0x6c10
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6140
movq %rax, %rdi
callq 0x62d0
movl %eax, %ebx
movq 0x15e960(%rip), %r15    # 0x17d060
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 0x1e75a
movq 0x15e93d(%rip), %r15    # 0x17d068
callq 0x6440
movq %r15, %rdi
movq %rax, %rsi
callq 0x6140
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rcx
movq %rax, %rdi
movl $0x1, %edx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x66b0
movslq 0x8(%rsp), %rax
testq %rax, %rax
js 0x1e785
shlq $0x4, %rax
leaq 0x41c6e1(%rip), %rcx    # 0x43ae50
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %esi
movl %edx, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movzbl 0x8(%rcx,%rax), %ebp
jmp 0x1e787
xorl %ebp, %ebp
movq 0x15e8c2(%rip), %rdi    # 0x17d050
movq %r14, %rsi
callq 0x6140
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x6cc0
testl %eax, %eax
je 0x1e7dd
movq 0x15e8aa(%rip), %r14    # 0x17d058
callq 0x6440
movq %r14, %rdi
movq %rax, %rsi
callq 0x6140
leaq 0x20(%rsp), %rsi
leaq 0x14(%rsp), %rcx
movq %rax, %rdi
movl $0x1, %edx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x66b0
movslq 0x14(%rsp), %rax
testq %rax, %rax
js 0x1e801
shlq $0x4, %rax
leaq 0x41c65e(%rip), %rcx    # 0x43ae50
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %eax
movl %edx, 0x1c(%rsp)
movl %eax, 0x18(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x1ea44
movl %eax, 0x8(%rsp)
leaq 0x1c(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x8, %edx
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x1ea44
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, 0x14(%rsp)
cmpl $0x0, 0x8(%rsp)
jns 0x1e8b5
leaq 0x563cd(%rip), %rcx     # 0x74c20
xorl %eax, %eax
cmpl %ebp, (%rcx)
jl 0x1e86b
incq %rax
addq $0x4, %rcx
cmpq $0x5, %rax
jne 0x1e855
movl $0x5, %eax
cmpl $0x5, %eax
je 0x1e8b5
movl %eax, %r12d
shlq $0x2, %r12
leaq 0x563a2(%rip), %r13     # 0x74c20
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 0x1ea44
movl %eax, 0x8(%rsp)
testl %eax, %eax
jns 0x1e8b5
leaq 0x4(%r12), %rax
cmpq $0x10, %r12
movq %rax, %r12
jne 0x1e888
movq 0x15e7ac(%rip), %rdi    # 0x17d068
callq 0x6370
movq 0x15e790(%rip), %rdi    # 0x17d058
callq 0x6370
leaq 0x33dfdc(%rip), %r13    # 0x35c8b0
cmpl $0x0, (%r13)
jle 0x1ea2b
leaq 0x41c56a(%rip), %r14    # 0x43ae50
addq $0x9, %r14
leaq 0x40(%rsp), %r15
leaq 0x20(%rsp), %rbp
xorl %r12d, %r12d
movzbl (%r14), %eax
cmpl %eax, %ebx
jne 0x1ea17
movl -0x9(%r14), %edx
movl -0x5(%r14), %ecx
movzbl -0x1(%r14), %r8d
movq %r15, %rdi
leaq 0x562e7(%rip), %rsi     # 0x74c01
xorl %eax, %eax
callq 0x6b00
movq 0x15e740(%rip), %rdi    # 0x17d068
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 0x1e982
movq %rbp, %r13
movq 0x15e703(%rip), %rbp    # 0x17d060
callq 0x6640
movq %rbp, %rdi
movq %r13, %rbp
leaq 0x33df41(%rip), %r13    # 0x35c8b0
movq %rax, %rsi
callq 0x6140
movq %rax, %rdi
movq %rbp, %rsi
callq 0x6510
cmpb $0x8, -0x1(%r14)
jne 0x1ea17
movl -0x9(%r14), %edx
cmpl $0x280, %edx            # imm = 0x280
jl 0x1ea17
movl -0x5(%r14), %ecx
cmpl $0x1e0, %ecx            # imm = 0x1E0
jl 0x1ea17
movq %r15, %rdi
leaq 0x56262(%rip), %rsi     # 0x74c11
xorl %eax, %eax
callq 0x6b00
movq 0x15e69b(%rip), %rdi    # 0x17d058
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 0x14(%rsp), %eax
cmpq %rax, %r12
jne 0x1ea17
movq %rbp, %r13
movq 0x15e65e(%rip), %rbp    # 0x17d050
callq 0x6640
movq %rbp, %rdi
movq %r13, %rbp
leaq 0x33deac(%rip), %r13    # 0x35c8b0
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 0x1e8f7
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq