// File: /workspace/github_c_makefile_star2_O1/kaugm[P]mmwm/mmwm.c
// Function: update_current
void update_current(client *newfocus)   // newfocus may be NULL
{
    if(!M_HEAD) {                // empty desktop. no clients
        nada();
        return;
    }

    if(!newfocus) {
        if(M_PREVFOCUS)
            M_CURRENT = M_PREVFOCUS;
        else
            M_CURRENT = M_HEAD;
        M_PREVFOCUS = M_GETPREV(M_CURRENT);             // get previous client in list, may be NULL
    }
    else {
        if(newfocus == M_PREVFOCUS) {
            M_CURRENT = M_PREVFOCUS;
            M_PREVFOCUS = M_GETPREV(M_CURRENT);         // get previous client in list, may be NULL
        }
        else {
            M_PREVFOCUS = M_CURRENT;
            M_CURRENT = newfocus;
        }
    }

    if(!M_CURRENT) {  // there is really really really nothing to focus.
        nada();
        return;
    }

	/* Setting window borders: xcb_border_width -----> client_borders(c) */
    for (client *c = M_HEAD; c; c = M_GETNEXT(c)) {
        if (!c->isfullscreen) {
            xcb_change_window_attributes(dis, c->win, XCB_CW_BORDER_PIXEL,
                                    (c == M_CURRENT ? &win_focus : &win_unfocus));
            xcb_border_width(dis, c->win, client_borders(c));
        }
    }

    tile();

    for (client *c = M_HEAD; c; c = M_GETNEXT(c)) {
        if (c->isfullscreen) {
//            xcb_border_width(dis, c->win, 0);
            xcb_lower_window(dis, c->win);
//            xcb_move_resize(dis, c->win, 0, 0,
//                            screen->width_in_pixels, screen->height_in_pixels, &c->position_info);
            break;
        }
    }

    client *rl = NULL;
    for (client *c = M_HEAD; c; c = M_GETNEXT(c)) {
        if (c->ismaximized || c->isfloating || c->istransient || c->type != ewmh->_NET_WM_WINDOW_TYPE_NORMAL) {
            if (c == M_CURRENT) {
                rl = c;
                continue;
            }
        }
        xcb_raise_window(dis, c->win);
    }
    if(rl)
        xcb_raise_window(dis, rl->win);

    if (check_head(&aliens)) {
        alien *a;
        for (a=(alien *)get_head(&aliens); a; a=(alien *)get_next(&a->link)) {
            if (M_CURRENT->isfullscreen
             && a->type != ewmh->_NET_WM_WINDOW_TYPE_NOTIFICATION)
                continue;
            xcb_raise_window(dis, a->win);
        }
    }

    if (M_CURRENT) {
        if (M_CURRENT->setfocus) {
            xcb_change_property(dis, XCB_PROP_MODE_REPLACE, screen->root,
                                ewmh->_NET_ACTIVE_WINDOW, XCB_ATOM_WINDOW, 32, 1,
                                &M_CURRENT->win);
            xcb_set_input_focus(dis, XCB_INPUT_FOCUS_POINTER_ROOT, M_CURRENT->win,
                                XCB_CURRENT_TIME);
            DEBUG("xcb_set_input_focus();");
        }
        else {
            sendevent(M_CURRENT->win, wmatoms[WM_TAKE_FOCUS]);
            DEBUG("send WM_TAKE_FOCUS");
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq 0x79a2(%rip), %rax      # 0xb780
movq 0x18(%rax), %r14
testq %r14, %r14
je 0x3ec9
movq 0x38(%rax), %rcx
testq %rdi, %rdi
je 0x3e07
cmpq %rdi, %rcx
je 0x3e14
movq 0x30(%rax), %rcx
movq %rcx, 0x38(%rax)
movq %rdi, 0x30(%rax)
jmp 0x3e28
testq %rcx, %rcx
cmoveq %r14, %rcx
movq %rcx, 0x30(%rax)
jmp 0x3e21
movq %rcx, 0x30(%rax)
testq %rcx, %rcx
je 0x40ce
movq (%rcx), %rcx
movq %rcx, 0x38(%rax)
cmpq $0x0, 0x30(%rax)
je 0x3ec9
leaq 0x7996(%rip), %r15      # 0xb7d0
leaq 0x7993(%rip), %r12      # 0xb7d4
xorl %ebp, %ebp
leaq 0xc(%rsp), %rbx
cmpb $0x0, 0x1b(%r14)
jne 0x3e9b
movq 0x78fa(%rip), %rdi      # 0xb750
movq 0x7923(%rip), %rax      # 0xb780
cmpq 0x30(%rax), %r14
movl 0x20(%r14), %esi
movq %r12, %rcx
cmoveq %r15, %rcx
movl $0x8, %edx
callq 0x30f0
movq 0x78d3(%rip), %rdi      # 0xb750
movl 0x20(%r14), %esi
movl 0x40(%r14), %eax
testl %eax, %eax
cmovlel %ebp, %eax
movl %eax, 0xc(%rsp)
movl $0x10, %edx
movq %rbx, %rcx
callq 0x32c0
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x3e48
callq 0x5013
movq 0x78d0(%rip), %rax      # 0xb780
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x3f3e
cmpb $0x1, 0x1b(%rax)
je 0x3f1f
movq 0x8(%rax), %rax
jmp 0x3eb4
movq 0x7880(%rip), %rdi      # 0xb750
movq 0x7899(%rip), %rax      # 0xb770
movl (%rax), %esi
movq 0x7888(%rip), %rax      # 0xb768
movl 0x40(%rax), %edx
callq 0x3670
movq 0x7861(%rip), %rdi      # 0xb750
movq 0x787a(%rip), %rax      # 0xb770
movl (%rax), %edx
movl $0x1, %esi
xorl %ecx, %ecx
callq 0x3590
movq 0x7875(%rip), %rax      # 0xb780
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x782a(%rip), %rdi      # 0xb750
movl 0x20(%rax), %esi
leaq 0xc(%rsp), %rcx
movl $0x1, (%rcx)
movl $0x40, %edx
callq 0x32c0
movq 0x783b(%rip), %rax      # 0xb780
movq 0x18(%rax), %r14
testq %r14, %r14
je 0x3fbf
xorl %r15d, %r15d
leaq 0xc(%rsp), %rbx
cmpb $0x0, 0x1c(%r14)
jne 0x3f7e
cmpb $0x0, 0x1a(%r14)
jne 0x3f7e
cmpb $0x0, 0x19(%r14)
jne 0x3f7e
movl 0x24(%r14), %eax
movq 0x77f2(%rip), %rcx      # 0xb768
cmpl 0x104(%rcx), %eax
je 0x3f8e
movq 0x77fb(%rip), %rcx      # 0xb780
movq %r14, %rax
cmpq 0x30(%rcx), %r14
je 0x3fb1
movq 0x77bb(%rip), %rdi      # 0xb750
movl 0x20(%r14), %esi
movl $0x0, 0xc(%rsp)
movl $0x40, %edx
movq %rbx, %rcx
callq 0x32c0
movq %r15, %rax
movq 0x8(%r14), %r14
movq %rax, %r15
testq %r14, %r14
jne 0x3f56
jmp 0x3fc1
xorl %eax, %eax
testq %rax, %rax
je 0x3fe5
movq 0x7783(%rip), %rdi      # 0xb750
movl 0x20(%rax), %esi
leaq 0xc(%rsp), %rcx
movl $0x0, (%rcx)
movl $0x40, %edx
callq 0x32c0
movq 0x77a4(%rip), %r14      # 0xb790
testq %r14, %r14
je 0x4043
leaq 0xc(%rsp), %rbx
movq 0x7783(%rip), %rax      # 0xb780
movq 0x30(%rax), %rax
cmpb $0x1, 0x1b(%rax)
jne 0x401a
movl 0x1c(%r14), %eax
movq 0x7756(%rip), %rcx      # 0xb768
cmpl 0xf8(%rcx), %eax
jne 0x403a
movq 0x772f(%rip), %rdi      # 0xb750
movl 0x18(%r14), %esi
movl $0x0, 0xc(%rsp)
movl $0x40, %edx
movq %rbx, %rcx
callq 0x32c0
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x3ff6
movq 0x7736(%rip), %rax      # 0xb780
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x3f12
cmpb $0x1, 0x44(%rax)
jne 0x40bb
movq 0x76ec(%rip), %rdi      # 0xb750
movq 0x7705(%rip), %rcx      # 0xb770
movl (%rcx), %edx
movq 0x76f4(%rip), %rcx      # 0xb768
movl 0x40(%rcx), %ecx
addq $0x20, %rax
xorl %esi, %esi
movl $0x21, %r8d
movl $0x20, %r9d
pushq %rax
pushq $0x1
callq 0x35d0
addq $0x10, %rsp
movq 0x76b4(%rip), %rdi      # 0xb750
movq 0x76dd(%rip), %rax      # 0xb780
movq 0x30(%rax), %rax
movl 0x20(%rax), %edx
movl $0x1, %esi
xorl %ecx, %ecx
callq 0x3590
jmp 0x3f12
movl 0x20(%rax), %edi
movl 0x7728(%rip), %esi      # 0xb7ec
callq 0x503b
jmp 0x3f12
xorl %ecx, %ecx
jmp 0x3e24