// File: /workspace/github_c_makefile_star2_O2/kaugm[P]mmwm/mmwm.c
// Function: stack
void stack(int hh, int cy)
{
    client *c = NULL, *t = NULL; bool b = M_MODE;
    int n = 0, d = 0, z = b ? M_WW : hh,
        ma = M_WW * MASTER_SIZE + M_MASTER_SIZE;

    /* count stack windows and grab first non-floating, non-maximize window */
    for (t = M_HEAD; t; t = M_GETNEXT(t)) {
        if (!ISFMFTM(t)) {
            if (c)
                ++n;
            else
                c = t;
        }
    }

    /*
     * if there is only one window, it should cover the available screen space
     * if there is only one stack window (n == 1) then we don't care about
     * growth if more than one stack windows (n > 1) on screen then adjustments
     * may be needed
     *   - d is the num of pixels than remain when spliting
     *   the available width/height to the number of windows
     *   - z is the clients' height/width
     *
     *      ----------  -.    --------------------.
     *      |   |----| --|--> growth               `}--> first client will get
     *      |   |    |   |                          |    (z+d) height/width
     *      |   |----|   }--> screen height - hh  --'
     *      |   |    | }-|--> client height - z
     *      ----------  -'
     *
     *     ->  piece of art by c00kiemon5ter o.O om nom nom nom nom
     *
     *     what we do is, remove the growth from the screen height   : (z -
     *     growth) and then divide that space with the windows on the stack  :
     *     (z - growth)/n so all windows have equal height/width (z)
     *     : growth is left out and will later be added to the first's client
     *     height/width before that, there will be cases when the num of
     *     windows is not perfectly divided with then available screen
     *     height/width (ie 100px scr. height, and 3 windows) so we get that
     *     remaining space and merge growth to it (d) : (z - growth) % n +
     *     growth finally we know each client's height, and how many pixels
     *     should be added to the first stack window so that it satisfies
     *     growth, and doesn't create gaps
     *     on the bottom of the screen.
     */
    if (!c) {
        return;
    } else if (!n) {
        int borders = client_borders(c);
        xcb_move_resize(dis, c->win, M_GAPS, cy + M_GAPS,
                        M_WW - 2 * (borders + M_GAPS),
                        hh - 2 * (borders + M_GAPS), &c->position_info);
        return;
    } else if (n > 1) {
        d = (z - M_GROWTH) % n + M_GROWTH; z = (z - M_GROWTH) / n;
    }

    /* tile the first non-floating, non-maximize window to cover the master area */
    int borders = client_borders(c);
    if (b)
        xcb_move_resize(dis, c->win, M_GAPS,
                        M_INVERT ? (cy + hh - ma + M_GAPS) : (cy + M_GAPS),
                        M_WW - 2 * (borders + M_GAPS),
                        ma - 2 * (borders + M_GAPS), &c->position_info);
    else
        xcb_move_resize(dis, c->win, M_INVERT ? (M_WW - ma + M_GAPS) : M_GAPS,
                        cy + M_GAPS,
                        ma - 2 * (borders + M_GAPS),
                        hh - 2 * (borders + M_GAPS), &c->position_info);

    /* tile the next non-floating, non-maximize (first) stack window with growth|d */
    for (c = M_GETNEXT(c); c && ISFMFTM(c); c = M_GETNEXT(c));
    borders = client_borders(c);
    int cx = b ? 0 : (M_INVERT ? M_GAPS : ma),
        cw = (b ? hh : M_WW) - 2 * borders - ma - M_GAPS,
        ch = z - 2 * borders - M_GAPS;
    if (b)
        xcb_move_resize(dis, c->win, cx += M_GAPS, cy += M_INVERT ? M_GAPS : ma,
                        ch - M_GAPS + d, cw, &c->position_info);
    else
        xcb_move_resize(dis, c->win, cx, cy += M_GAPS, cw, ch - M_GAPS + d, &c->position_info);

    /* tile the rest of the non-floating, non-maximize stack windows */
    for (b ? (cx += z + d - M_GAPS) : (cy += z + d - M_GAPS),
         c = M_GETNEXT(c); c; c = M_GETNEXT(c)) {
        if (ISFMFTM(c))
            continue;
        if (b) {
            xcb_move_resize(dis, c->win, cx, cy, ch, cw, &c->position_info); cx += z;
        } else {
            xcb_move_resize(dis, c->win, cx, cy, cw, ch, &c->position_info); cy += z;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edi, %ebx
movq 0x58f8(%rip), %r9       # 0xa780
movl 0x5c(%r9), %r11d
testl %r11d, %r11d
movq 0x58f2(%rip), %rax      # 0xa788
movl 0x34(%rax), %r8d
movl %r8d, %eax
cmovel %edi, %eax
cvtsi2sd %r8d, %xmm0
cvtss2sd 0x58(%r9), %xmm1
movl %esi, %r13d
mulsd 0x216a(%rip), %xmm0     # 0x7020
addsd %xmm1, %xmm0
leaq 0x18(%r9), %rdi
xorl %ecx, %ecx
movq 0x58a1(%rip), %rdx      # 0xa768
xorl %r15d, %r15d
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x4f10
cmpb $0x0, 0x1b(%rdi)
jne 0x4f0a
cmpb $0x0, 0x1c(%rdi)
jne 0x4f0a
cmpb $0x0, 0x1a(%rdi)
jne 0x4f0a
cmpb $0x0, 0x19(%rdi)
jne 0x4f0a
cmpb $0x0, 0x1d(%rdi)
jne 0x4f0a
movl 0x24(%rdi), %esi
cmpl 0x104(%rdx), %esi
jne 0x4f0a
xorl %esi, %esi
testq %r15, %r15
setne %sil
cmoveq %rdi, %r15
addl %esi, %ecx
addq $0x8, %rdi
jmp 0x4eca
testq %r15, %r15
je 0x4f6b
testl %ecx, %ecx
je 0x4f32
xorl %r10d, %r10d
cmpl $0x2, %ecx
jl 0x4f7a
movl 0x60(%r9), %esi
subl %esi, %eax
cltd
idivl %ecx
movl %edx, %r12d
addl %esi, %r12d
jmp 0x4f7d
movl 0x20(%r15), %esi
movl 0x40(%r15), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movq 0x5808(%rip), %rdi      # 0xa750
movl 0x64(%r9), %edx
addl %edx, %r13d
addl %edx, %ecx
addl %ecx, %ecx
subl %ecx, %r8d
subl %ecx, %ebx
addq $0x30, %r15
movq %r15, (%rsp)
movl %r13d, %ecx
movl %ebx, %r9d
callq 0x3bfd
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
cvttsd2si %xmm0, %ebp
movl 0x20(%r15), %esi
movl 0x40(%r15), %ecx
testl %ecx, %ecx
cmovgl %ecx, %r10d
movq 0x57ba(%rip), %rdi      # 0xa750
testl %r11d, %r11d
movl %r11d, 0x14(%rsp)
movl %eax, 0x24(%rsp)
movq %rbx, 0x18(%rsp)
je 0x4fda
leal (%rbx,%r13), %ecx
subl %ebp, %ecx
cmpb $0x0, 0x69(%r9)
cmovel %r13d, %ecx
movl 0x64(%r9), %edx
addl %edx, %ecx
addl %edx, %r10d
addl %r10d, %r10d
subl %r10d, %r8d
movq %rbp, %r14
movl %ebp, %r9d
subl %r10d, %r9d
leaq 0x30(%r15), %rax
movq %rax, (%rsp)
jmp 0x5020
movq %rbp, %r14
cmpb $0x1, 0x69(%r9)
jne 0x4ff3
movq %r14, %rdx
subl %edx, %r8d
movl 0x64(%r9), %eax
addl %eax, %r8d
jmp 0x4ffd
movl 0x64(%r9), %eax
movl %eax, %r8d
movq %r14, %rdx
leal (%rax,%r13), %ecx
addl %eax, %r10d
addl %r10d, %r10d
movl %edx, %eax
subl %r10d, %eax
movl %ebx, %r9d
subl %r10d, %r9d
leaq 0x30(%r15), %rdx
movq %rdx, (%rsp)
movl %r8d, %edx
movl %eax, %r8d
callq 0x3bfd
movq 0x573c(%rip), %rax      # 0xa768
movl 0x14(%rsp), %r8d
movq 0x8(%r15), %r15
testq %r15, %r15
je 0x5069
cmpb $0x0, 0x1b(%r15)
jne 0x5031
cmpb $0x0, 0x1c(%r15)
jne 0x5031
cmpb $0x0, 0x1a(%r15)
jne 0x5031
cmpb $0x0, 0x19(%r15)
jne 0x5031
cmpb $0x0, 0x1d(%r15)
jne 0x5031
movl 0x24(%r15), %ecx
cmpl 0x104(%rax), %ecx
jne 0x5031
movl 0x40(%r15), %edi
xorl %r10d, %r10d
testl %edi, %edi
cmovlel %r10d, %edi
movq 0x5703(%rip), %rax      # 0xa780
testl %r8d, %r8d
movq %r14, %rcx
jne 0x50a1
cmpb $0x1, 0x69(%rax)
movl %ecx, %r10d
jne 0x5092
movl 0x64(%rax), %r10d
movq 0x56ef(%rip), %rdx      # 0xa788
movl 0x34(%rdx), %edx
movq %rdx, 0x18(%rsp)
addl %edi, %edi
movl 0x64(%rax), %edx
movq 0x18(%rsp), %r14
subl %edi, %r14d
subl %edx, %r14d
subl %ecx, %r14d
movl 0x24(%rsp), %ebp
movl %ebp, %ebx
subl %edi, %ebx
subl %edx, %ebx
movq 0x568b(%rip), %rdi      # 0xa750
movl 0x20(%r15), %esi
testl %r8d, %r8d
je 0x5120
addl %edx, %r10d
cmpb $0x0, 0x69(%rax)
cmovnel %edx, %ecx
addl %r13d, %ecx
movq %rcx, 0x18(%rsp)
movl %r12d, %r8d
subl %edx, %r8d
addl %ebx, %r8d
leaq 0x30(%r15), %rax
movq %rax, (%rsp)
movl %r10d, %edx
movl %r14d, %r9d
movl %ebx, %r13d
movl %r10d, %ebx
callq 0x3bfd
addl %ebp, %r12d
movq 0x5674(%rip), %rax      # 0xa780
addl %ebx, %r12d
movl %r13d, %ebx
movq 0x18(%rsp), %r13
subl 0x64(%rax), %r12d
movl %r12d, %edx
jmp 0x515f
addl %edx, %r13d
movl %r12d, %r9d
subl %edx, %r9d
addl %ebx, %r9d
leaq 0x30(%r15), %rax
movq %rax, (%rsp)
movl %r10d, %edx
movl %r13d, %ecx
movl %r14d, %r8d
movl %r10d, 0x18(%rsp)
callq 0x3bfd
movl 0x18(%rsp), %edx
addl %ebp, %r12d
movq 0x562b(%rip), %rax      # 0xa780
addl %r13d, %r12d
subl 0x64(%rax), %r12d
movl %r12d, %r13d
movl 0x14(%rsp), %r8d
movq 0x8(%r15), %r15
testq %r15, %r15
je 0x4f6b
cmpb $0x0, 0x1b(%r15)
jne 0x5164
cmpb $0x0, 0x1c(%r15)
jne 0x5164
cmpb $0x0, 0x1a(%r15)
jne 0x5164
cmpb $0x0, 0x19(%r15)
jne 0x5164
cmpb $0x0, 0x1d(%r15)
jne 0x5164
movl 0x24(%r15), %eax
movq 0x55c9(%rip), %rcx      # 0xa768
cmpl 0x104(%rcx), %eax
jne 0x5164
leaq 0x30(%r15), %rax
movq 0x559e(%rip), %rdi      # 0xa750
movl 0x20(%r15), %esi
testl %r8d, %r8d
je 0x51d7
movq %rax, (%rsp)
movl %r13d, %ecx
movl %ebx, %r8d
movl %r14d, %r9d
movl %edx, %r12d
callq 0x3bfd
movl %r12d, %edx
addl %ebp, %edx
jmp 0x515f
movq %rax, (%rsp)
movl %r13d, %ecx
movl %r14d, %r8d
movl %ebx, %r9d
movl %edx, %r12d
callq 0x3bfd
movl %r12d, %edx
addl %ebp, %r13d
jmp 0x515f