// File: /workspace/github_c_makefile_star2_O0/tkln[P]mcwm/mcwm.c
// Function: configurerequest
void configurerequest(xcb_configure_request_event_t *e)
{
    struct client *client;
    struct winconf wc;
    int16_t mon_x;
    int16_t mon_y;
    uint16_t mon_width;
    uint16_t mon_height;

    PDEBUG("event: Configure request. mask = %d\n", e->value_mask);

    /* Find the client. */
    if ((client = findclient(e->window)))
    {
        /* Find monitor position and size. */
        if (NULL == client || 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;
        }

#if 0
        /*
         * We ignore moves the user haven't initiated, that is do
         * nothing on XCB_CONFIG_WINDOW_X and XCB_CONFIG_WINDOW_Y
         * ConfigureRequests.
         *
         * Code here if we ever change our minds or if you, dear user,
         * wants this functionality.
         */
        
        if (e->value_mask & XCB_CONFIG_WINDOW_X)
        {
            /* Don't move window if maximized. Don't move off the screen. */
            if (!client->maxed && e->x > 0)
            {
                client->x = e->x;
            }
        }

        if (e->value_mask & XCB_CONFIG_WINDOW_Y)
        {
            /*
             * Don't move window if maximized. Don't move off the
             * screen.
             */
            if (!client->maxed && !client->vertmaxed && e->y > 0)
            {
                client->y = e->y;
            }
        }
#endif
        
        if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH)
        {
            /* Don't resize if maximized. */
            if (!client->maxed)
            {
                client->width = e->width;
            }
        }

        if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
        {
            /* Don't resize if maximized. */            
            if (!client->maxed && !client->vertmaxed)
            {
                client->height = e->height;
            }
        }

        /*
         * XXX Do we really need to pass on sibling and stack mode
         * configuration? Do we want to?
         */
        if (e->value_mask & XCB_CONFIG_WINDOW_SIBLING)
        {
            uint32_t values[1];

            values[0] = e->sibling;
            xcb_configure_window(conn, e->window,
                                 XCB_CONFIG_WINDOW_SIBLING,
                                 values);
            xcb_flush(conn);
            
        }

        if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE)
        {
            uint32_t values[1];
            
            values[0] = e->stack_mode;
            xcb_configure_window(conn, e->window,
                                 XCB_CONFIG_WINDOW_STACK_MODE,
                                 values);
            xcb_flush(conn);
        }

        /* Check if window fits on screen after resizing. */

        if (client->x + client->width + 2 * conf.borderwidth
            > mon_x + mon_width)
        {
            /*
             * See if it fits if we move away the window from the
             * right edge of the screen.
             */
            client->x = mon_x + mon_width
                - (client->width + 2 * conf.borderwidth);

            /*
             * If we moved over the left screen edge, move back and
             * fit exactly on screen.
             */
            if (client->x < mon_x)
            {
                client->x = mon_x;
                client->width = mon_width - 2 * conf.borderwidth;
            }            
        }
        
        if (client->y + client->height + 2 * conf.borderwidth
            > mon_y + mon_height)
        {
            /*
             * See if it fits if we move away the window from the
             * bottom edge.
             */
            client->y = mon_y + mon_height
                - (client->height + 2 * conf.borderwidth);

            /*
             * If we moved over the top screen edge, move back and fit
             * on screen.
             */
            if (client->y < mon_y)
            {
                PDEBUG("over the edge: y < %d\n", mon_y);
                client->y = mon_y;
                client->height = mon_height - 2 * conf.borderwidth;
            }
        }
        
        moveresize(client->id, client->x, client->y, client->width,
                   client->height);
    }
    else
    {
        PDEBUG("We don't know about this window yet.\n");

        /*
         * Unmapped window. Just pass all options except border
         * width.
         */
        wc.x = e->x;
        wc.y = e->y;
        wc.width = e->width;
        wc.height = e->height;
        wc.sibling = e->sibling;
        wc.stackmode = e->stack_mode;

        configwin(e->window, e->value_mask, wc);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x84c0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x90ce
xorl %eax, %eax
cmpq -0x10(%rbp), %rax
je 0x8e2a
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq 0x38(%rcx), %rax
jne 0x8e56
movw $0x0, -0x2a(%rbp)
movw $0x0, -0x2c(%rbp)
movq 0x4b0b(%rip), %rax      # 0xd948
movw 0x14(%rax), %ax
movw %ax, -0x2e(%rbp)
movq 0x4afc(%rip), %rax      # 0xd948
movw 0x16(%rax), %ax
movw %ax, -0x30(%rbp)
jmp 0x8e96
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x10(%rax), %ax
movw %ax, -0x2a(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x12(%rax), %ax
movw %ax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x14(%rax), %ax
movw %ax, -0x2e(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x16(%rax), %ax
movw %ax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x8ec2
movq -0x10(%rbp), %rax
testb $0x1, 0x31(%rax)
jne 0x8ec0
movq -0x8(%rbp), %rax
movw 0x14(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xa(%rax)
jmp 0x8ec2
movq -0x8(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x8ef8
movq -0x10(%rbp), %rax
testb $0x1, 0x31(%rax)
jne 0x8ef6
movq -0x10(%rbp), %rax
testb $0x1, 0x30(%rax)
jne 0x8ef6
movq -0x8(%rbp), %rax
movw 0x16(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8ef8
movq -0x8(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x8f3d
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x34(%rbp)
movq 0x4a5f(%rip), %rdi      # 0xd978
movq -0x8(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0x34(%rbp), %rcx
movl $0x20, %edx
callq 0x3200
movl %eax, -0x38(%rbp)
movq 0x4a40(%rip), %rdi      # 0xd978
callq 0x3140
movq -0x8(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x8f83
movq -0x8(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x3c(%rbp)
movq 0x4a19(%rip), %rdi      # 0xd978
movq -0x8(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0x3c(%rbp), %rcx
movl $0x40, %edx
callq 0x3200
movl %eax, -0x40(%rbp)
movq 0x49fa(%rip), %rdi      # 0xd978
callq 0x3140
movq -0x10(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x10(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movl 0x49b5(%rip), %ecx      # 0xd950
shll %ecx
addl %ecx, %eax
movswl -0x2a(%rbp), %ecx
movzwl -0x2e(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jle 0x900d
movswl -0x2a(%rbp), %eax
movzwl -0x2e(%rbp), %ecx
addl %ecx, %eax
movq -0x10(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
movl 0x498b(%rip), %edx      # 0xd950
shll %edx
addl %edx, %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x6(%rax)
movq -0x10(%rbp), %rax
movswl 0x6(%rax), %eax
movswl -0x2a(%rbp), %ecx
cmpl %ecx, %eax
jge 0x900b
movw -0x2a(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x6(%rax)
movzwl -0x2e(%rbp), %eax
movl 0x4954(%rip), %ecx      # 0xd950
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0xa(%rax)
jmp 0x900d
movq -0x10(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movl 0x492b(%rip), %ecx      # 0xd950
shll %ecx
addl %ecx, %eax
movswl -0x2c(%rbp), %ecx
movzwl -0x30(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jle 0x9097
movswl -0x2c(%rbp), %eax
movzwl -0x30(%rbp), %ecx
addl %ecx, %eax
movq -0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
movl 0x4901(%rip), %edx      # 0xd950
shll %edx
addl %edx, %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x8(%rax)
movq -0x10(%rbp), %rax
movswl 0x8(%rax), %eax
movswl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x9095
movw -0x2c(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x8(%rax)
movzwl -0x30(%rbp), %eax
movl 0x48ca(%rip), %ecx      # 0xd950
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x9097
movq -0x10(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movw 0x6(%rax), %si
movq -0x10(%rbp), %rax
movw 0x8(%rax), %dx
movq -0x10(%rbp), %rax
movw 0xa(%rax), %cx
movq -0x10(%rbp), %rax
movzwl %si, %esi
movzwl %dx, %edx
movzwl %cx, %ecx
movzwl 0xc(%rax), %r8d
callq 0x91c0
jmp 0x9141
movq -0x8(%rbp), %rax
movw 0x10(%rax), %ax
movw %ax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movw 0x12(%rax), %ax
movw %ax, -0x26(%rbp)
movq -0x8(%rbp), %rax
movw 0x14(%rax), %ax
movw %ax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movw 0x16(%rax), %ax
movw %ax, -0x22(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x8(%rbp), %rcx
leaq -0x28(%rbp), %rax
movzwl 0x1a(%rcx), %esi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl 0x10(%rax), %eax
movl %eax, 0x10(%rsp)
callq 0x9240
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)