// File: /workspace/github_c_makefile_star2_O0/tkln[P]mcwm/mcwm.c
// Function: maximize
int maximize(struct client *client, union cb_arg arg)
{
    uint32_t values[4];
    uint32_t mask = 0;
    int16_t mon_x;
    int16_t mon_y;
    uint16_t mon_width;
    uint16_t mon_height;

    (void) arg;
    
    if (NULL == client)
    {
        PDEBUG("maximize: client was NULL!\n");
        return 0;
    }

    if (NULL == client->monitor)
    {
        mon_x = 0;
        mon_y = 0;
        mon_width = screen->width_in_pixels;
        mon_height = screen->height_in_pixels;
    }
    else
    {
        mon_x = client->monitor->x;
        mon_y = client->monitor->y;
        mon_width = client->monitor->width;
        mon_height = client->monitor->height;                    
    }

    /*
     * Check if maximized already. If so, revert to stored
     * geometry.
     */
    if (client->maxed)
    {
        unmax(client);
        client->maxed = false;
        return 0;
    }

    /* Raise first. Pretty silly to maximize below something else. */
    raisewindow(client->id);
    
    /* FIXME: Store original geom in property as well? */
    client->origsize.x = client->x;
    client->origsize.y = client->y;
    client->origsize.width = client->width;
    client->origsize.height = client->height;
    
    /* Remove borders. */
    values[0] = 0;
    mask = XCB_CONFIG_WINDOW_BORDER_WIDTH;
    xcb_configure_window(conn, client->id, mask, values);
    
    /* Move to top left and resize. */
    client->x = mon_x;
    client->y = mon_y;
    client->width = mon_width;
    client->height = mon_height;
    
    values[0] = client->x;
    values[1] = client->y;
    values[2] = client->width;
    values[3] = client->height;
    xcb_configure_window(conn, client->id, XCB_CONFIG_WINDOW_X
                         | XCB_CONFIG_WINDOW_Y
                         | XCB_CONFIG_WINDOW_WIDTH
                         | XCB_CONFIG_WINDOW_HEIGHT, values);

    xcb_flush(conn);

    client->maxed = true;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rsi, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movl $0x0, -0x34(%rbp)
xorl %eax, %eax
cmpq -0x18(%rbp), %rax
jne 0x3c0b
movl $0x0, -0x4(%rbp)
jmp 0x3db7
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpq 0x38(%rcx), %rax
jne 0x3c43
movw $0x0, -0x36(%rbp)
movw $0x0, -0x38(%rbp)
movq 0x9d1e(%rip), %rax      # 0xd948
movw 0x14(%rax), %ax
movw %ax, -0x3a(%rbp)
movq 0x9d0f(%rip), %rax      # 0xd948
movw 0x16(%rax), %ax
movw %ax, -0x3c(%rbp)
jmp 0x3c83
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x10(%rax), %ax
movw %ax, -0x36(%rbp)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x12(%rax), %ax
movw %ax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x14(%rax), %ax
movw %ax, -0x3a(%rbp)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x16(%rax), %ax
movw %ax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
testb $0x1, 0x31(%rax)
je 0x3caa
movq -0x18(%rbp), %rdi
callq 0x7760
movq -0x18(%rbp), %rax
movb $0x0, 0x31(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3db7
movq -0x18(%rbp), %rax
movl (%rax), %edi
callq 0x6f50
movq -0x18(%rbp), %rax
movw 0x6(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0xe(%rax)
movq -0x18(%rbp), %rax
movw 0x8(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x10(%rax)
movq -0x18(%rbp), %rax
movw 0xa(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x12(%rax)
movq -0x18(%rbp), %rax
movw 0xc(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x14(%rax)
movl $0x0, -0x30(%rbp)
movl $0x10, -0x34(%rbp)
movq 0x9c6e(%rip), %rdi      # 0xd978
movq -0x18(%rbp), %rax
movl (%rax), %esi
movl -0x34(%rbp), %eax
leaq -0x30(%rbp), %rcx
movzwl %ax, %edx
callq 0x3200
movl %eax, -0x40(%rbp)
movw -0x36(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x6(%rax)
movw -0x38(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x8(%rax)
movw -0x3a(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0xa(%rax)
movw -0x3c(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0xc(%rax)
movq -0x18(%rbp), %rax
movswl 0x6(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movswl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movzwl 0xa(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movzwl 0xc(%rax), %eax
movl %eax, -0x24(%rbp)
movq 0x9bf3(%rip), %rdi      # 0xd978
movq -0x18(%rbp), %rax
movl (%rax), %esi
leaq -0x30(%rbp), %rcx
movl $0xf, %edx
callq 0x3200
movl %eax, -0x44(%rbp)
movq 0x9bd5(%rip), %rdi      # 0xd978
callq 0x3140
movq -0x18(%rbp), %rax
movb $0x1, 0x31(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq