// File: /workspace/github_c_makefile_star2_O0/tkln[P]mcwm/mcwm.c
// Function: setupwin
struct client *setupwin(xcb_window_t win)
{
    uint32_t mask = 0;    
    uint32_t values[2];
    struct item *item;
    struct client *client;
    xcb_size_hints_t hints;
    uint32_t ws;
    
    /* Set default border color. */
    values[0] = conf.unfocuscol;
    xcb_change_window_attributes(conn, win, XCB_CW_BORDER_PIXEL, values);

    /* Subscribe to events we want to know about in this window. */
    mask = XCB_CW_EVENT_MASK;
    values[0] = XCB_EVENT_MASK_ENTER_WINDOW;
    xcb_change_window_attributes_checked(conn, win, mask, values);

    /*
     * Add this window to the X Save Set, that is, the windows that
     * will be automatically restored if we die.
     */
    xcb_change_save_set(conn, XCB_SET_MODE_INSERT, win);

    xcb_flush(conn);
    
    /* Remember window and store a few things about it. */
    
    item = additem(&winlist);
    
    if (NULL == item)
    {
        PDEBUG("newwin: Out of memory.\n");
        return NULL;
    }

    client = malloc(sizeof (struct client));
    if (NULL == client)
    {
        PDEBUG("newwin: Out of memory.\n");
        return NULL;
    }

    item->data = client;
    
    /* Initialize client. */
    client->id = win;
    client->usercoord = false;
    client->x = 0;
    client->y = 0;
    client->width = 0;
    client->height = 0;
    client->min_width = 0;
    client->min_height = 0;
    client->max_width = screen->width_in_pixels;
    client->max_height = screen->height_in_pixels;
    client->base_width = 0;
    client->base_height = 0;
    client->width_inc = 1;
    client->height_inc = 1;
    client->vertmaxed = false;
    client->maxed = false;
    client->fixed = false;
    client->monitor = NULL;

    client->winitem = item;

    for (ws = 0; ws < WORKSPACES; ws ++)
    {
        client->wsitem[ws] = NULL;
    }
    
    PDEBUG("Adding window %d\n", client->id);

    setborders(client, conf.borderwidth);

    /* Get window geometry. */
    if (!getgeom(client->id, &client->x, &client->y, &client->width,
                 &client->height))
    {
        fprintf(stderr, "Couldn't get geometry in initial setup of window.\n");
    }
    
    /*
     * Get the window's incremental size step, if any.
     */
    if (!xcb_icccm_get_wm_normal_hints_reply(
            conn, xcb_icccm_get_wm_normal_hints_unchecked(
                conn, win), &hints, NULL))
    {
        PDEBUG("Couldn't get size hints.\n");
    }

    /*
     * The user specified the position coordinates. Remember that so
     * we can use geometry later.
     */
    if (hints.flags & XCB_ICCCM_SIZE_HINT_US_POSITION)
    {
        client->usercoord = true;
    }

    if (hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE)
    {
        client->min_width = hints.min_width;
        client->min_height = hints.min_height;
    }
    
    if (hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)
    {
        
        client->max_width = hints.max_width;
        client->max_height = hints.max_height;
    }
    
    if (hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)
    {
        client->width_inc = hints.width_inc;
        client->height_inc = hints.height_inc;

        PDEBUG("widht_inc %d\nheight_inc %d\n", client->width_inc,
               client->height_inc);
    }

    if (hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE)
    {
        client->base_width = hints.base_width;
        client->base_height = hints.base_height;
    }

    return client;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl %edi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl 0x5931(%rip), %eax      # 0xd96c
movl %eax, -0x18(%rbp)
movq 0x5933(%rip), %rdi      # 0xd978
movl -0xc(%rbp), %esi
leaq -0x18(%rbp), %rcx
movl $0x8, %edx
callq 0x30e0
movl %eax, -0x78(%rbp)
movl $0x800, -0x10(%rbp)     # imm = 0x800
movl $0x10, -0x18(%rbp)
movq 0x590a(%rip), %rdi      # 0xd978
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
leaq -0x18(%rbp), %rcx
callq 0x33c0
movl %eax, -0x7c(%rbp)
movq 0x58f1(%rip), %rdi      # 0xd978
movl -0xc(%rbp), %edx
xorl %esi, %esi
callq 0x3170
movl %eax, -0x80(%rbp)
movq 0x58dd(%rip), %rdi      # 0xd978
callq 0x3140
leaq 0x5821(%rip), %rdi      # 0xd8c8
callq 0x9480
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq -0x20(%rbp), %rax
jne 0x80c5
movq $0x0, -0x8(%rbp)
jmp 0x832c
movl $0x98, %edi
callq 0x3350
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq -0x28(%rbp), %rax
jne 0x80e8
movq $0x0, -0x8(%rbp)
jmp 0x832c
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl -0xc(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x28(%rbp), %rax
movw $0x0, 0x6(%rax)
movq -0x28(%rbp), %rax
movw $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movw $0x0, 0xa(%rax)
movq -0x28(%rbp), %rax
movw $0x0, 0xc(%rax)
movq -0x28(%rbp), %rax
movw $0x0, 0x16(%rax)
movq -0x28(%rbp), %rax
movw $0x0, 0x18(%rax)
movq 0x5801(%rip), %rax      # 0xd948
movw 0x14(%rax), %cx
movq -0x28(%rbp), %rax
movw %cx, 0x1a(%rax)
movq 0x57ee(%rip), %rax      # 0xd948
movw 0x16(%rax), %cx
movq -0x28(%rbp), %rax
movw %cx, 0x1c(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x20(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x24(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x30(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x31(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x32(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x40(%rax)
movl $0x0, -0x74(%rbp)
cmpl $0xa, -0x74(%rbp)
jae 0x81ea
movq -0x28(%rbp), %rax
movl -0x74(%rbp), %ecx
movq $0x0, 0x48(%rax,%rcx,8)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x81c9
movq -0x28(%rbp), %rdi
movl 0x575c(%rip), %esi      # 0xd950
callq 0x7020
movq -0x28(%rbp), %rax
movl (%rax), %edi
movq -0x28(%rbp), %rsi
addq $0x6, %rsi
movq -0x28(%rbp), %rdx
addq $0x8, %rdx
movq -0x28(%rbp), %rcx
addq $0xa, %rcx
movq -0x28(%rbp), %r8
addq $0xc, %r8
callq 0x8520
testb $0x1, %al
jne 0x8240
movq 0x4dc9(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x2277(%rip), %rsi      # 0xa4b0
movb $0x0, %al
callq 0x32d0
movq 0x5731(%rip), %rax      # 0xd978
movq %rax, -0x90(%rbp)
movq 0x5723(%rip), %rdi      # 0xd978
movl -0xc(%rbp), %esi
callq 0x31e0
movq -0x90(%rbp), %rdi
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %esi
leaq -0x70(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x3400
cmpb $0x0, %al
jne 0x8283
jmp 0x8283
movl -0x70(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8296
movq -0x28(%rbp), %rax
movb $0x1, 0x4(%rax)
movl -0x70(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x82bd
movl -0x5c(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x16(%rax)
movl -0x58(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x18(%rax)
movl -0x70(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x82e4
movl -0x54(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x1a(%rax)
movl -0x50(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x1c(%rax)
movl -0x70(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x8303
movl -0x4c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x48(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x24(%rax)
movl -0x70(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x8324
movl -0x34(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x28(%rax)
movl -0x30(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)