// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq 0x575f(%rip), %rcx      # 0xa780
movl 0x5c(%rcx), %r10d
testl %r10d, %r10d
movq 0x5759(%rip), %rax      # 0xa788
movl 0x34(%rax), %r8d
movl %r8d, %ebp
cmovel %edi, %ebp
movq 0x18(%rcx), %rax
testq %rax, %rax
je 0x5451
movl %esi, %r14d
movl %edi, %ebx
cvtsi2sd %r8d, %xmm0
cvtss2sd 0x58(%rcx), %xmm1
mulsd 0x1fc3(%rip), %xmm0     # 0x7020
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r11d
xorl %r13d, %r13d
movq 0x56f8(%rip), %rdx      # 0xa768
xorl %esi, %esi
cmpb $0x0, 0x1b(%rax)
jne 0x50aa
cmpb $0x0, 0x1c(%rax)
jne 0x50aa
cmpb $0x0, 0x1a(%rax)
jne 0x50aa
cmpb $0x0, 0x19(%rax)
jne 0x50aa
cmpb $0x0, 0x1d(%rax)
jne 0x50aa
movl 0x24(%rax), %edi
cmpl 0x104(%rdx), %edi
jne 0x50aa
xorl %edi, %edi
testq %r13, %r13
setne %dil
cmoveq %rax, %r13
addl %edi, %esi
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x5072
testq %r13, %r13
je 0x5451
testl %esi, %esi
je 0x50dc
xorl %r9d, %r9d
cmpl $0x2, %esi
jl 0x5132
movl 0x60(%rcx), %edi
subl %edi, %ebp
movl %ebp, %eax
cltd
idivl %esi
movl %edx, %r15d
addl %edi, %r15d
movl %eax, %ebp
jmp 0x5135
movl 0x20(%r13), %esi
movl 0x40(%r13), %eax
xorl %edx, %edx
testl %eax, %eax
cmovgl %eax, %edx
movq 0x565e(%rip), %rdi      # 0xa750
movl 0x64(%rcx), %eax
addl %eax, %r14d
addl %eax, %edx
addl %edx, %edx
subl %edx, %r8d
subl %edx, %ebx
leaq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl %r14d, 0x4(%rcx)
movl %r8d, 0x8(%rcx)
movl %ebx, 0xc(%rcx)
movq 0x38(%r13), %rdx
movq %rdx, 0x30(%r13)
movl %eax, 0x38(%r13)
movl %r14d, 0x3c(%r13)
movl $0xf, %edx
callq 0x32c0
jmp 0x5451
xorl %r15d, %r15d
movl 0x20(%r13), %esi
movl 0x40(%r13), %eax
testl %eax, %eax
cmovgl %eax, %r9d
movq 0x5606(%rip), %rdi      # 0xa750
testl %r10d, %r10d
movl %r10d, 0xc(%rsp)
movq %r14, 0x30(%rsp)
je 0x51a3
leal (%r14,%rbx), %eax
subl %r11d, %eax
cmpb $0x0, 0x69(%rcx)
cmovel %r14d, %eax
movl 0x64(%rcx), %edx
addl %edx, %eax
addl %edx, %r9d
addl %r9d, %r9d
subl %r9d, %r8d
movq %r11, %r12
movl %r11d, %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(%r13), %r8
movq %r8, 0x30(%r13)
movl %edx, 0x38(%r13)
movl %eax, 0x3c(%r13)
jmp 0x51f5
cmpb $0x1, 0x69(%rcx)
jne 0x51b4
subl %r11d, %r8d
movl 0x64(%rcx), %eax
addl %eax, %r8d
jmp 0x51ba
movl 0x64(%rcx), %eax
movl %eax, %r8d
leal (%rax,%r14), %edx
addl %eax, %r9d
addl %r9d, %r9d
movq %r11, %r12
movl %r11d, %eax
subl %r9d, %eax
movl %ebx, %r10d
subl %r9d, %r10d
leaq 0x10(%rsp), %rcx
movl %r8d, (%rcx)
movl %edx, 0x4(%rcx)
movl %eax, 0x8(%rcx)
movl %r10d, 0xc(%rcx)
movq 0x38(%r13), %rax
movq %rax, 0x30(%r13)
movl %r8d, 0x38(%r13)
movl %edx, 0x3c(%r13)
movl $0xf, %edx
callq 0x32c0
movq 0x8(%r13), %r14
movl $0x40, %eax
xorl %r10d, %r10d
testq %r14, %r14
movl 0xc(%rsp), %r8d
movq %r12, %r13
je 0x525b
movq 0x5549(%rip), %rcx      # 0xa768
cmpb $0x0, 0x1b(%r14)
jne 0x5252
cmpb $0x0, 0x1c(%r14)
jne 0x5252
cmpb $0x0, 0x1a(%r14)
jne 0x5252
cmpb $0x0, 0x19(%r14)
jne 0x5252
cmpb $0x0, 0x1d(%r14)
jne 0x5252
movl 0x24(%r14), %edx
cmpl 0x104(%rcx), %edx
je 0x5460
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x521f
xorl %r14d, %r14d
movl (%rax), %ecx
testl %ecx, %ecx
cmovlel %r10d, %ecx
movq 0x5513(%rip), %rax      # 0xa780
testl %r8d, %r8d
jne 0x5289
cmpb $0x1, 0x69(%rax)
movl %r13d, %r10d
jne 0x527f
movl 0x64(%rax), %r10d
movq 0x5502(%rip), %rdx      # 0xa788
movl 0x34(%rdx), %ebx
addl %ecx, %ecx
movl 0x64(%rax), %edx
subl %ecx, %ebx
subl %edx, %ebx
subl %r13d, %ebx
movl %ebp, %esi
subl %ecx, %esi
movl %esi, %ecx
subl %edx, %ecx
movq 0x54ac(%rip), %rdi      # 0xa750
movl 0x20(%r14), %esi
testl %r8d, %r8d
movl %ecx, 0x2c(%rsp)
je 0x530d
addl %edx, %r10d
cmpb $0x0, 0x69(%rax)
cmovnel %edx, %r13d
addl 0x30(%rsp), %r13d
movl %r15d, %eax
subl %edx, %eax
addl %ecx, %eax
leaq 0x10(%rsp), %rcx
movl %r10d, (%rcx)
movl %r13d, 0x4(%rcx)
movl %eax, 0x8(%rcx)
movl %ebx, 0xc(%rcx)
movq 0x38(%r14), %rax
movq %rax, 0x30(%r14)
movl %r10d, 0x38(%r14)
movl %r13d, 0x3c(%r14)
movl $0xf, %edx
movq %r10, %r12
callq 0x32c0
addl %ebp, %r15d
movq 0x547f(%rip), %rax      # 0xa780
addl %r12d, %r15d
subl 0x64(%rax), %r15d
movl %r15d, %r12d
jmp 0x535f
movq 0x30(%rsp), %r13
addl %edx, %r13d
movl %r15d, %eax
subl %edx, %eax
addl %ecx, %eax
leaq 0x10(%rsp), %rcx
movl %r10d, (%rcx)
movl %r13d, 0x4(%rcx)
movl %ebx, 0x8(%rcx)
movl %eax, 0xc(%rcx)
movq 0x38(%r14), %rax
movq %rax, 0x30(%r14)
movl %r10d, 0x38(%r14)
movl %r13d, 0x3c(%r14)
movl $0xf, %edx
movq %r10, %r12
callq 0x32c0
addl %ebp, %r15d
movq 0x542b(%rip), %rax      # 0xa780
addl %r13d, %r15d
subl 0x64(%rax), %r15d
movl %r15d, %r13d
movq 0x8(%r14), %r15
testq %r15, %r15
movl 0xc(%rsp), %edx
je 0x5451
leaq 0x10(%rsp), %r14
cmpb $0x0, 0x1b(%r15)
jne 0x5444
cmpb $0x0, 0x1c(%r15)
jne 0x5444
cmpb $0x0, 0x1a(%r15)
jne 0x5444
cmpb $0x0, 0x19(%r15)
jne 0x5444
cmpb $0x0, 0x1d(%r15)
jne 0x5444
movl 0x24(%r15), %eax
movq 0x53b1(%rip), %rcx      # 0xa768
cmpl 0x104(%rcx), %eax
jne 0x5444
movq 0x5386(%rip), %rdi      # 0xa750
movl 0x20(%r15), %esi
testl %edx, %edx
je 0x540a
movl %r12d, 0x10(%rsp)
movl %r13d, 0x14(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x18(%rsp)
movl %ebx, 0x1c(%rsp)
movq 0x38(%r15), %rax
movq %rax, 0x30(%r15)
movl %r12d, 0x38(%r15)
movl %r13d, 0x3c(%r15)
movl $0xf, %edx
movq %r14, %rcx
callq 0x32c0
addl %ebp, %r12d
jmp 0x5440
movl %r12d, 0x10(%rsp)
movl %r13d, 0x14(%rsp)
movl %ebx, 0x18(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x38(%r15), %rax
movq %rax, 0x30(%r15)
movl %r12d, 0x38(%r15)
movl %r13d, 0x3c(%r15)
movl $0xf, %edx
movq %r14, %rcx
callq 0x32c0
addl %ebp, %r13d
movl 0xc(%rsp), %edx
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x5375
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40(%r14), %rax
jmp 0x525e