// File: /workspace/github_c_makefile_star2_O0/stetre[P]moonglfw/src/window.c
// Function: CreateWindow
static int CreateWindow(lua_State *L)
    {
    win_t *win, *share_win=NULL;
    mon_t *mon;
    intptr_t id;
    int width = luaL_checkinteger(L, 1);
    int height = luaL_checkinteger(L, 2);
    const char* title = luaL_optstring(L, 3, "");
    GLFWmonitor* monitor = testmonitor(L, 4, &mon) ? mon->monitor : NULL;
    GLFWwindow* share = testwindow(L, 5, &share_win) ? share_win->window : NULL;

    win = win_new();
    if(!win)
        return luaL_error(L, "cannot create window");
    
#ifdef MACOS
     glfw.WindowHint(GLFW_OPENGL_FORWARD_COMPAT,GLFW_TRUE); 
     glfw.WindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE); 
#endif
    win->window = glfw.CreateWindow(width, height, title, monitor, share);
    if(win->window == NULL)
        {
        win_free(win);
        return luaL_error(L, "cannot create window");
        }
    /* this will allow us to retrieve the win_t* from the GLFWwindow*: */
    id = win->id;
    win->share_id =  share_win ? share_win->id : -1;
    glfw.SetWindowUserPointer(win->window, (void*)id);
    lua_pushinteger(L, win->id);
    return 1;
    }

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq $0x0, 0x48(%rsp)
movq 0x58(%rsp), %rdi
movl $0x1, %esi
callq 0x53c0
movl %eax, 0x34(%rsp)
movq 0x58(%rsp), %rdi
movl $0x2, %esi
callq 0x53c0
movl %eax, 0x30(%rsp)
movq 0x58(%rsp), %rdi
movl $0x3, %esi
leaq 0x3785(%rip), %rdx      # 0x1e31e
xorl %eax, %eax
movl %eax, %ecx
callq 0x5250
movq %rax, 0x28(%rsp)
movq 0x58(%rsp), %rdi
movl $0x4, %esi
leaq 0x40(%rsp), %rdx
callq 0x54d0
cmpl $0x0, %eax
je 0x1abd0
movq 0x40(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x1abd9
xorl %eax, %eax
movq %rax, 0x10(%rsp)
jmp 0x1abd9
movq 0x10(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x58(%rsp), %rdi
movl $0x5, %esi
leaq 0x48(%rsp), %rdx
callq 0x5530
cmpl $0x0, %eax
je 0x1ac0c
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x1ac15
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x1ac15
movq 0x8(%rsp), %rax
movq %rax, 0x18(%rsp)
callq 0x53e0
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x50(%rsp)
jne 0x1ac4d
movq 0x58(%rsp), %rdi
leaq 0x4912(%rip), %rsi      # 0x1f54f
movb $0x0, %al
callq 0x5590
movl %eax, 0x64(%rsp)
jmp 0x1ad23
movq 0x9394(%rip), %rax      # 0x23fe8
movq 0x90(%rax), %rax
movl 0x34(%rsp), %edi
movl 0x30(%rsp), %esi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %r8
callq *%rax
movq %rax, %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x50(%rsp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x1acaf
movq 0x50(%rsp), %rdi
callq 0x5230
movq 0x58(%rsp), %rdi
leaq 0x48ad(%rip), %rsi      # 0x1f54f
movb $0x0, %al
callq 0x5590
movl %eax, 0x64(%rsp)
jmp 0x1ad23
movq 0x50(%rsp), %rax
movslq 0x20(%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x1acd3
movq 0x48(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x1acde
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x4(%rsp)
jmp 0x1acde
movl 0x4(%rsp), %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0x30(%rax)
movq 0x92f7(%rip), %rax      # 0x23fe8
movq 0x148(%rax), %rax
movq 0x50(%rsp), %rcx
movq 0x28(%rcx), %rdi
movq 0x38(%rsp), %rsi
callq *%rax
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %rax
movslq 0x20(%rax), %rsi
callq 0x5300
movl $0x1, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopl (%rax)