// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movl %esi, %r15d
movl %edi, %r10d
movq 0x666f(%rip), %rcx      # 0xb780
movl 0x5c(%rcx), %r11d
movl %edi, %r9d
testl %r11d, %r11d
je 0x5128
movq 0x6664(%rip), %rax      # 0xb788
movl 0x34(%rax), %r9d
movq 0x18(%rcx), %rax
testq %rax, %rax
je 0x517f
xorl %ebp, %ebp
movq 0x662e(%rip), %rdx      # 0xb768
xorl %esi, %esi
cmpb $0x0, 0x1b(%rax)
jne 0x5174
cmpb $0x0, 0x1c(%rax)
jne 0x5174
cmpb $0x0, 0x1a(%rax)
jne 0x5174
cmpb $0x0, 0x19(%rax)
jne 0x5174
cmpb $0x0, 0x1d(%rax)
jne 0x5174
movl 0x24(%rax), %edi
cmpl 0x104(%rdx), %edi
jne 0x5174
xorl %edi, %edi
testq %rbp, %rbp
setne %dil
cmoveq %rax, %rbp
addl %edi, %esi
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x513c
jmp 0x5183
xorl %esi, %esi
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x55ad
movq 0x65f5(%rip), %rax      # 0xb788
movl 0x34(%rax), %r8d
testl %esi, %esi
je 0x51d7
movl %r9d, 0x8(%rsp)
cvtsi2sd %r8d, %xmm0
cvtss2sd 0x58(%rcx), %xmm1
mulsd 0x2e56(%rip), %xmm0     # 0x8008
addsd %xmm1, %xmm0
xorl %r9d, %r9d
cmpl $0x2, %esi
jl 0x522c
movl 0x60(%rcx), %edi
movl 0x8(%rsp), %eax
subl %edi, %eax
cltd
idivl %esi
addl %edi, %edx
movq %rdx, 0x30(%rsp)
movl %eax, 0x8(%rsp)
jmp 0x5235
movl 0x20(%rbp), %esi
movl 0x40(%rbp), %eax
xorl %edx, %edx
testl %eax, %eax
cmovgl %eax, %edx
movq 0x6565(%rip), %rdi      # 0xb750
movl 0x64(%rcx), %eax
addl %eax, %r15d
addl %eax, %edx
addl %edx, %edx
subl %edx, %r8d
subl %edx, %r10d
leaq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl %r15d, 0x4(%rcx)
movl %r8d, 0x8(%rcx)
movl %r10d, 0xc(%rcx)
movq 0x38(%rbp), %rdx
movq %rdx, 0x30(%rbp)
movl %eax, 0x38(%rbp)
movl %r15d, 0x3c(%rbp)
movl $0xf, %edx
callq 0x32c0
jmp 0x55ad
movq $0x0, 0x30(%rsp)
cvttsd2si %xmm0, %r14d
movl 0x20(%rbp), %esi
movl 0x40(%rbp), %eax
testl %eax, %eax
cmovgl %eax, %r9d
movq 0x6503(%rip), %rdi      # 0xb750
testl %r11d, %r11d
movl %r11d, 0xc(%rsp)
movq %r15, 0x38(%rsp)
je 0x52a4
movq %r10, %rbx
leal (%r15,%r10), %eax
subl %r14d, %eax
cmpb $0x0, 0x69(%rcx)
cmovel %r15d, %eax
movl 0x64(%rcx), %edx
addl %edx, %eax
addl %edx, %r9d
addl %r9d, %r9d
subl %r9d, %r8d
movl %r14d, %r10d
subl %r9d, %r10d
leaq 0x10(%rsp), %rcx
movl %edx, (%rcx)
movl %eax, 0x4(%rcx)
movl %r8d, 0x8(%rcx)
movl %r10d, 0xc(%rcx)
movq 0x38(%rbp), %r8
movq %r8, 0x30(%rbp)
movl %edx, 0x38(%rbp)
movl %eax, 0x3c(%rbp)
jmp 0x52f1
cmpb $0x1, 0x69(%rcx)
jne 0x52b3
subl %r14d, %r8d
addl 0x64(%rcx), %r8d
jmp 0x52b7
movl 0x64(%rcx), %r8d
movl 0x64(%rcx), %eax
leal (%rax,%r15), %edx
addl %eax, %r9d
addl %r9d, %r9d
movl %r14d, %eax
subl %r9d, %eax
movq %r10, %rbx
subl %r9d, %r10d
leaq 0x10(%rsp), %rcx
movl %r8d, (%rcx)
movl %edx, 0x4(%rcx)
movl %eax, 0x8(%rcx)
movl %r10d, 0xc(%rcx)
movq 0x38(%rbp), %rax
movq %rax, 0x30(%rbp)
movl %r8d, 0x38(%rbp)
movl %edx, 0x3c(%rbp)
movl $0xf, %edx
callq 0x32c0
movq 0x8(%rbp), %r12
testq %r12, %r12
sete %r15b
je 0x535c
movq 0x6459(%rip), %rax      # 0xb768
movq %rbx, %r8
movl 0xc(%rsp), %r9d
cmpb $0x0, 0x1b(%r12)
jne 0x534c
cmpb $0x0, 0x1c(%r12)
jne 0x534c
cmpb $0x0, 0x1a(%r12)
jne 0x534c
cmpb $0x0, 0x19(%r12)
jne 0x534c
cmpb $0x0, 0x1d(%r12)
jne 0x534c
movl 0x24(%r12), %ecx
cmpl 0x104(%rax), %ecx
je 0x5364
movq 0x8(%r12), %r12
testq %r12, %r12
sete %r15b
jne 0x5317
jmp 0x5364
movq %rbx, %r8
movl 0xc(%rsp), %r9d
movl 0x40(%r12), %eax
xorl %r13d, %r13d
testl %eax, %eax
cmovlel %r13d, %eax
testl %r9d, %r9d
jne 0x538b
movq 0x6402(%rip), %rcx      # 0xb780
cmpb $0x1, 0x69(%rcx)
movl %r14d, %r13d
jne 0x538b
movl 0x64(%rcx), %r13d
testl %r9d, %r9d
jne 0x539b
movq 0x63f1(%rip), %rcx      # 0xb788
movl 0x34(%rcx), %r8d
addl %eax, %eax
movq 0x63dc(%rip), %rdx      # 0xb780
movl 0x64(%rdx), %ecx
subl %eax, %r8d
subl %ecx, %r8d
subl %r14d, %r8d
movl 0x8(%rsp), %r10d
subl %eax, %r10d
subl %ecx, %r10d
movq 0x638e(%rip), %rdi      # 0xb750
movl 0x20(%r12), %esi
testl %r9d, %r9d
movq %r8, 0x40(%rsp)
movl %r10d, 0x2c(%rsp)
je 0x5425
addl %ecx, %r13d
cmpb $0x0, 0x69(%rdx)
cmovnel %ecx, %r14d
addl 0x38(%rsp), %r14d
movq 0x30(%rsp), %rbp
movl %ebp, %eax
subl %ecx, %eax
addl %r10d, %eax
leaq 0x10(%rsp), %rcx
movl %r13d, (%rcx)
movl %r14d, 0x4(%rcx)
movl %eax, 0x8(%rcx)
movl %r8d, 0xc(%rcx)
movq 0x38(%r12), %rax
movq %rax, 0x30(%r12)
movl %r13d, 0x38(%r12)
movl %r14d, 0x3c(%r12)
movl $0xf, %edx
callq 0x32c0
jmp 0x546a
movq 0x38(%rsp), %r14
addl %ecx, %r14d
movq 0x30(%rsp), %rbp
movl %ebp, %eax
subl %ecx, %eax
addl %r10d, %eax
leaq 0x10(%rsp), %rcx
movl %r13d, (%rcx)
movl %r14d, 0x4(%rcx)
movl %r8d, 0x8(%rcx)
movl %eax, 0xc(%rcx)
movq 0x38(%r12), %rax
movq %rax, 0x30(%r12)
movl %r13d, 0x38(%r12)
movl %r14d, 0x3c(%r12)
movl $0xf, %edx
callq 0x32c0
addl 0x8(%rsp), %ebp
movq 0x630b(%rip), %rax      # 0xb780
movl 0x64(%rax), %eax
leal (%rbp,%r13), %ebx
subl %eax, %ebx
addl %r14d, %ebp
subl %eax, %ebp
movl 0xc(%rsp), %edx
testl %edx, %edx
cmovel %r13d, %ebx
cmovnel %r14d, %ebp
testb $0x1, %r15b
je 0x549d
xorl %r12d, %r12d
jmp 0x54a2
movq 0x8(%r12), %r12
movq 0x40(%rsp), %r8
testq %r12, %r12
je 0x55ad
leaq 0x10(%rsp), %r15
cmpb $0x0, 0x1b(%r12)
jne 0x559f
cmpb $0x0, 0x1c(%r12)
jne 0x559f
cmpb $0x0, 0x1a(%r12)
jne 0x559f
cmpb $0x0, 0x19(%r12)
jne 0x559f
cmpb $0x0, 0x1d(%r12)
jne 0x559f
movl 0x24(%r12), %eax
movq 0x626b(%rip), %rcx      # 0xb768
cmpl 0x104(%rcx), %eax
jne 0x559f
movq 0x6240(%rip), %rdi      # 0xb750
movl 0x20(%r12), %esi
testl %edx, %edx
je 0x555b
movl %ebx, 0x10(%rsp)
movl %ebp, 0x14(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x18(%rsp)
movl %r8d, 0x1c(%rsp)
movq 0x38(%r12), %rax
movq %rax, 0x30(%r12)
movl %ebx, 0x38(%r12)
movl %ebp, 0x3c(%r12)
movl $0xf, %edx
movq %r15, %rcx
movq %r8, %r14
callq 0x32c0
movq %r14, %r8
addl 0x8(%rsp), %ebx
jmp 0x559b
movl %ebx, 0x10(%rsp)
movl %ebp, 0x14(%rsp)
movl %r8d, 0x18(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x38(%r12), %rax
movq %rax, 0x30(%r12)
movl %ebx, 0x38(%r12)
movl %ebp, 0x3c(%r12)
movl $0xf, %edx
movq %r15, %rcx
movq %r8, %r14
callq 0x32c0
movq %r14, %r8
addl 0x8(%rsp), %ebp
movl 0xc(%rsp), %edx
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x54b5
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq