// File: /workspace/github_c_makefile_star2_O0/tkln[P]mcwm/mcwm.c
// Function: newwin
void newwin(xcb_window_t win)
{
    struct client *client;

    if (NULL != findclient(win))
    {
        /*
         * We know this window from before. It's trying to map itself
         * on the current workspace, but since it's unmapped it
         * probably belongs on another workspace. We don't like that.
         * Silently ignore.
         */
        return;
    }
    
    /*
     * Set up stuff, like borders, add the window to the client list,
     * et cetera.
     */
    client = setupwin(win);
    if (NULL == client)
    {
        fprintf(stderr, "mcwm: Couldn't set up window. Out of memory.\n");
        return;
    }

    /* Add this window to the current workspace. */
    addtoworkspace(client, curws);

    /*
     * If the client doesn't say the user specified the coordinates
     * for the window we map it where our pointer is instead.
     */
    if (!client->usercoord)
    {
        int16_t pointx;
        int16_t pointy;    
        PDEBUG("Coordinates not set by user. Using pointer: %d,%d.\n",
               pointx, pointy);

        /* Get pointer position so we can move the window to the cursor. */
        if (!getpointer(screen->root, &pointx, &pointy))
        {
            PDEBUG("Failed to get pointer coords!\n");
            pointx = 0;
            pointy = 0;
        }
        
        client->x = pointx;
        client->y = pointy;

        movewindow(client->id, client->x, client->y);
    }
    else
    {
        PDEBUG("User set coordinates.\n");
    }
        
    /* Find the physical output this window will be on if RANDR is active. */
    if (-1 != randrbase)
    {
        client->monitor = findmonbycoord(client->x, client->y);
        if (NULL == client->monitor)
        {
            /*
             * Window coordinates are outside all physical monitors.
             * Choose the first screen.
             */
            if (NULL != monlist)
            {
                client->monitor = monlist->data;
            }
        }
    }
    
    fitonscreen(client);
    
    /* Show window on screen. */
    xcb_map_window(conn, client->id);

    /* Declare window normal. */
    long data[] = { XCB_ICCCM_WM_STATE_NORMAL, XCB_NONE };
    xcb_change_property(conn, XCB_PROP_MODE_REPLACE, client->id,
                              wm_state, wm_state, 32, 2, data);

    /*
     * Move cursor into the middle of the window so we don't lose the
     * pointer to another window.
     */
    xcb_warp_pointer(conn, XCB_NONE, win, 0, 0, 0, 0,
                     client->width / 2, client->height / 2);

    xcb_flush(conn);    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %edi
callq 0x84c0
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x87d2
jmp 0x89b0
movl -0x4(%rbp), %edi
callq 0x8020
movq %rax, -0x10(%rbp)
xorl %eax, %eax
cmpq -0x10(%rbp), %rax
jne 0x8803
movq 0x480b(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x1d8a(%rip), %rsi      # 0xa581
movb $0x0, %al
callq 0x32d0
jmp 0x89b0
movq -0x10(%rbp), %rdi
movl 0x50b3(%rip), %esi      # 0xd8c0
callq 0x6fb0
movq -0x10(%rbp), %rax
testb $0x1, 0x4(%rax)
jne 0x887a
movq 0x5125(%rip), %rax      # 0xd948
movl (%rax), %edi
leaq -0x12(%rbp), %rsi
leaq -0x14(%rbp), %rdx
callq 0x7540
testb $0x1, %al
jne 0x8842
movw $0x0, -0x12(%rbp)
movw $0x0, -0x14(%rbp)
movw -0x12(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x6(%rax)
movw -0x14(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movw 0x6(%rax), %cx
movq -0x10(%rbp), %rax
movzwl %cx, %esi
movzwl 0x8(%rax), %edx
callq 0x7080
jmp 0x887c
jmp 0x887c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl 0x510d(%rip), %eax      # 0xd994
je 0x88d9
movq -0x10(%rbp), %rax
movw 0x6(%rax), %cx
movq -0x10(%rbp), %rax
movswl %cx, %edi
movswl 0x8(%rax), %esi
callq 0x8340
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq 0x38(%rcx), %rax
jne 0x88d7
xorl %eax, %eax
cmpq 0x500f(%rip), %rax      # 0xd8d0
je 0x88d5
movq 0x5006(%rip), %rax      # 0xd8d0
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0x88d7
jmp 0x88d9
movq -0x10(%rbp), %rdi
callq 0x4ac0
movq 0x508f(%rip), %rdi      # 0xd978
movq -0x10(%rbp), %rax
movl (%rax), %esi
callq 0x3410
movl %eax, -0x18(%rbp)
movq 0x1cd2(%rip), %rax      # 0xa5d0
movq %rax, -0x30(%rbp)
movq 0x1ccf(%rip), %rax      # 0xa5d8
movq %rax, -0x28(%rbp)
movq 0x5064(%rip), %rdi      # 0xd978
movq -0x10(%rbp), %rax
movl (%rax), %edx
movl 0x506c(%rip), %ecx      # 0xd98c
movl 0x5065(%rip), %r8d      # 0xd98c
leaq -0x30(%rbp), %rax
xorl %esi, %esi
movl $0x20, %r9d
movl $0x2, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x3510
movl %eax, -0x34(%rbp)
movq 0x502a(%rip), %rdi      # 0xd978
movl -0x4(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movzwl 0xa(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movw %ax, %r10w
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl -0x3c(%rbp), %edx
xorl %r9d, %r9d
movl %r9d, %esi
movl %r9d, %ecx
movl %r9d, %r8d
movl $0x0, (%rsp)
movswl %r10w, %r10d
movl %r10d, 0x8(%rsp)
cwtl
movl %eax, 0x10(%rsp)
callq 0x3050
movl %eax, -0x38(%rbp)
movq 0x4fcd(%rip), %rdi      # 0xd978
callq 0x3140
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)