// File: tomfunkhouser[P]gaps/pkgs/fglut/freeglut_structure.c
// Function: fgCreateWindow
SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
                            GLboolean positionUse, int x, int y,
                            GLboolean sizeUse, int w, int h,
                            GLboolean gameMode, GLboolean isMenu )
{
    /* Have the window object created */
    SFG_Window *window = (SFG_Window *)calloc( sizeof(SFG_Window), 1 );

#if TARGET_HOST_UNIX_X11
    window->Window.FBConfig = NULL;
#endif
    fghClearCallBacks( window );

    /* Initialize the object properties */
    window->ID = ++fgStructure.WindowID;
    window->State.OldHeight = window->State.OldWidth = -1;

    fgListInit( &window->Children );
    if( parent )
    {
        fgListAppend( &parent->Children, &window->Node );
        window->Parent = parent;
    }
    else
        fgListAppend( &fgStructure.Windows, &window->Node );

    /* Set the default mouse cursor and reset the modifiers value */
    window->State.Cursor    = GLUT_CURSOR_INHERIT;

    window->IsMenu = isMenu;

    window->State.IgnoreKeyRepeat = GL_FALSE;
    window->State.KeyRepeating    = GL_FALSE;
    window->State.IsFullscreen    = GL_FALSE;

    /*
     * Open the window now. The fgOpenWindow() function is system
     * dependant, and resides in freeglut_window.c. Uses fgState.
     */
    fgOpenWindow( window, title, positionUse, x, y, sizeUse, w, h, gameMode,
                  (GLboolean)(parent ? GL_TRUE : GL_FALSE) );

    return window;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movb %r9b, %al
movb 0x88(%rsp), %r9b
movb 0x80(%rsp), %r9b
movl 0x78(%rsp), %r9d
movl 0x70(%rsp), %r9d
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movb %dl, 0x3f(%rsp)
movl %ecx, 0x38(%rsp)
movl %r8d, 0x34(%rsp)
movb %al, 0x33(%rsp)
movl $0x178, %edi            # imm = 0x178
movl $0x1, %esi
callq 0x226a0
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0x1826a0
movl 0x7d9bc(%rip), %ecx     # 0x1fff30
addl $0x1, %ecx
movl %ecx, 0x7d9b3(%rip)     # 0x1fff30
movq 0x28(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x28(%rsp), %rax
movl $0xffffffff, 0x40(%rax) # imm = 0xFFFFFFFF
movq 0x28(%rsp), %rax
movl $0xffffffff, 0x44(%rax) # imm = 0xFFFFFFFF
movq 0x28(%rsp), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x1826e0
cmpq $0x0, 0x48(%rsp)
je 0x1825df
movq 0x48(%rsp), %rdi
addq $0x160, %rdi            # imm = 0x160
movq 0x28(%rsp), %rsi
callq 0x182700
movq 0x48(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x158(%rax)
jmp 0x1825f0
movq 0x28(%rsp), %rsi
leaq 0x7d8f5(%rip), %rdi     # 0x1ffee0
callq 0x182700
movq 0x28(%rsp), %rax
movl $0x64, 0x4c(%rax)
movb 0x88(%rsp), %cl
movq 0x28(%rsp), %rax
movb %cl, 0x170(%rax)
movq 0x28(%rsp), %rax
movb $0x0, 0x68(%rax)
movq 0x28(%rsp), %rax
movb $0x0, 0x69(%rax)
movq 0x28(%rsp), %rax
movb $0x0, 0x6b(%rax)
movq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
movb 0x3f(%rsp), %dl
movl 0x38(%rsp), %ecx
movl 0x34(%rsp), %r8d
movb 0x33(%rsp), %r9b
movl 0x70(%rsp), %ebx
movl 0x78(%rsp), %r11d
movb 0x80(%rsp), %r10b
movq 0x48(%rsp), %r14
xorl %eax, %eax
movl $0x1, %ebp
cmpq $0x0, %r14
cmovnel %ebp, %eax
movzbl %dl, %edx
movzbl %r9b, %r9d
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x10(%rsp)
movzbl %al, %eax
movl %eax, 0x18(%rsp)
callq 0x183930
movq 0x28(%rsp), %rax
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax,%rax)