// File: /workspace/github_c_makefile_star2_O0/tkln[P]mcwm/mcwm.c
// Function: snapwindow
void snapwindow(struct client *client, int snap_mode)
{
    struct item *item;
    struct client *win;
    int16_t mon_x;
    int16_t mon_y;
    uint16_t mon_width;
    uint16_t mon_height;

    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;
    }
    /*
     * Go through all windows on current workspace.
     */
    for (item = wslist[curws]; item != NULL; item = item->next)
    {
        win = item->data;

        if (client == win)
        {
            continue;
        }

        if (snap_mode == MCWM_MOVE)
        {
            if (abs((win->x +win->width) - client->x) < conf.snapmargin)
            {
                if (client->y + client->height > win->y
                    && client->y < win->y + win->height)
                {
                    client->x = (win->x + win->width) + (2 * conf.borderwidth);
                }
            }

            if (abs((win->y +win->height) - client->y) < conf.snapmargin)
            {
                if (client->x + client->width >win->x
                    && client->x < win->x + win->width)
                {
                    client->y = (win->y + win->height) + (2 * conf.borderwidth);
                }
            }

            if (abs((client->x + client->width) - win->x) < conf.snapmargin)
            {
                if (client->y + client->height > win->y
                    && client->y < win->y + win->height)
                {
                    client->x = (win->x - client->width)
                        - (2 * conf.borderwidth);
                }
            }

            if (abs((client->y + client->height) - win->y) < conf.snapmargin)
            {
                if (client->x + client->width >win->x
                    && client->x < win->x + win->width)
                {
                    client->y = (win->y - client->height)
                        - (2 * conf.borderwidth);
                }
            }

        } /* mcwm_move */
        else if (snap_mode == MCWM_RESIZE)
        {
            if (abs((client->x + client->width) - win->x) < conf.snapmargin)
            {
                if (client->y + client->height > win->y
                    && client->y < win->y + win->height)
                {
                    client->width = (win->x - client->x)
                        - (2 * conf.borderwidth);
                }
            }

            if (abs((client->y + client->height) - win->y) < conf.snapmargin)
            {
                if (client->x + client->width >win->x
                    && client->x < win->x + win->width)
                {
                    client->height = (win->y - client->y)
                        - (2 * conf.borderwidth);
                }
            }
        } /* mcwm_resize */
    } /* for */

    /* monitor border */
    if (snap_mode == MCWM_MOVE) {

        if (abs(client->x - mon_x) < conf.snapmargin)
        {
            client->x = mon_x;
        }

        if (abs(client->y - mon_y) < conf.snapmargin)
        {
            client->y = mon_y;
        }

        if (abs((client->x + client->width) - mon_width) < conf.snapmargin)
        {
            client->x = (mon_width - client->width);
        }

        if (abs((client->y + client->height) - mon_height) < conf.snapmargin)
        {
            client->y = (mon_height - client->height);
        }
    }
    else if (snap_mode == MCWM_RESIZE)
    {
        if (abs((client->width + client->x) - mon_width) < conf.snapmargin)
        {
            client->width = mon_width;
        }
        if (abs((client->height + client->y) - mon_height) < conf.snapmargin)
        {
            client->height = mon_height;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpq 0x38(%rcx), %rax
jne 0x4e73
movw $0x0, -0x22(%rbp)
movw $0x0, -0x24(%rbp)
movq 0x8aee(%rip), %rax      # 0xd948
movw 0x14(%rax), %ax
movw %ax, -0x26(%rbp)
movq 0x8adf(%rip), %rax      # 0xd948
movw 0x16(%rax), %ax
movw %ax, -0x28(%rbp)
jmp 0x4eb3
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x10(%rax), %ax
movw %ax, -0x22(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x12(%rax), %ax
movw %ax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x14(%rax), %ax
movw %ax, -0x26(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movw 0x16(%rax), %ax
movw %ax, -0x28(%rbp)
movl 0x8a07(%rip), %eax      # 0xd8c0
movl %eax, %ecx
leaq 0x8a1e(%rip), %rax      # 0xd8e0
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x527f
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x4eef
jmp 0x526e
cmpl $0x2, -0xc(%rbp)
jne 0x513e
movq -0x20(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x20(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movq -0x8(%rbp), %rcx
movswl 0x6(%rcx), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x8a32(%rip), %eax      # 0xd954
jge 0x4f89
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jle 0x4f87
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x20(%rbp), %rcx
movswl 0x8(%rcx), %ecx
movq -0x20(%rbp), %rdx
movzwl 0xc(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x4f87
movq -0x20(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x20(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movl 0x89d8(%rip), %ecx      # 0xd950
shll %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x6(%rax)
jmp 0x4f89
movq -0x20(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x20(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movq -0x8(%rbp), %rcx
movswl 0x8(%rcx), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x89a2(%rip), %eax      # 0xd954
jge 0x5019
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x6(%rcx), %ecx
cmpl %ecx, %eax
jle 0x5017
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x20(%rbp), %rcx
movswl 0x6(%rcx), %ecx
movq -0x20(%rbp), %rdx
movzwl 0xa(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x5017
movq -0x20(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x20(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movl 0x8948(%rip), %ecx      # 0xd950
shll %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x8(%rax)
jmp 0x5019
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x6(%rcx), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x8912(%rip), %eax      # 0xd954
jge 0x50a9
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jle 0x50a7
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x20(%rbp), %rcx
movswl 0x8(%rcx), %ecx
movq -0x20(%rbp), %rdx
movzwl 0xc(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x50a7
movq -0x20(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
subl %ecx, %eax
movl 0x88b8(%rip), %ecx      # 0xd950
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x6(%rax)
jmp 0x50a9
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x8(%rcx), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x8882(%rip), %eax      # 0xd954
jge 0x5139
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x6(%rcx), %ecx
cmpl %ecx, %eax
jle 0x5137
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x20(%rbp), %rcx
movswl 0x6(%rcx), %ecx
movq -0x20(%rbp), %rdx
movzwl 0xa(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x5137
movq -0x20(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
subl %ecx, %eax
movl 0x8828(%rip), %ecx      # 0xd950
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x8(%rax)
jmp 0x5139
jmp 0x526c
cmpl $0x3, -0xc(%rbp)
jne 0x526a
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x6(%rcx), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x87e3(%rip), %eax      # 0xd954
jge 0x51d8
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jle 0x51d6
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x20(%rbp), %rcx
movswl 0x8(%rcx), %ecx
movq -0x20(%rbp), %rdx
movzwl 0xc(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x51d6
movq -0x20(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x8(%rbp), %rcx
movswl 0x6(%rcx), %ecx
subl %ecx, %eax
movl 0x8789(%rip), %ecx      # 0xd950
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0xa(%rax)
jmp 0x51d8
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x8(%rcx), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x8753(%rip), %eax      # 0xd954
jge 0x5268
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x6(%rcx), %ecx
cmpl %ecx, %eax
jle 0x5266
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x20(%rbp), %rcx
movswl 0x6(%rcx), %ecx
movq -0x20(%rbp), %rdx
movzwl 0xa(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x5266
movq -0x20(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movswl 0x8(%rcx), %ecx
subl %ecx, %eax
movl 0x86f9(%rip), %ecx      # 0xd950
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x5268
jmp 0x526a
jmp 0x526c
jmp 0x526e
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x4eca
cmpl $0x2, -0xc(%rbp)
jne 0x535d
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movswl -0x22(%rbp), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x86b0(%rip), %eax      # 0xd954
jge 0x52b2
movw -0x22(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x6(%rax)
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movswl -0x24(%rbp), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x8687(%rip), %eax      # 0xd954
jge 0x52db
movw -0x24(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x8(%rax)
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movzwl -0x26(%rbp), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x8654(%rip), %eax      # 0xd954
jge 0x531b
movzwl -0x26(%rbp), %eax
movq -0x8(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x6(%rax)
movq -0x8(%rbp), %rax
movswl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl %ecx, %eax
movzwl -0x28(%rbp), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x8614(%rip), %eax      # 0xd954
jge 0x535b
movzwl -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x8(%rax)
jmp 0x53cd
cmpl $0x3, -0xc(%rbp)
jne 0x53cb
movq -0x8(%rbp), %rax
movzwl 0xa(%rax), %eax
movq -0x8(%rbp), %rcx
movswl 0x6(%rcx), %ecx
addl %ecx, %eax
movzwl -0x26(%rbp), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x85cc(%rip), %eax      # 0xd954
jge 0x5396
movw -0x26(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0xa(%rax)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
movq -0x8(%rbp), %rcx
movswl 0x8(%rcx), %ecx
addl %ecx, %eax
movzwl -0x28(%rbp), %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl 0x8599(%rip), %eax      # 0xd954
jge 0x53c9
movw -0x28(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x53cb
jmp 0x53cd
popq %rbp
retq
nop