// File: /workspace/github_c_makefile_star2_O0/tkln[P]mcwm/mcwm.c
// Function: focusnext
int focusnext(struct client *cli, const union cb_arg arg)
{
    struct client *client = NULL;
    (void) cli;
    
#if DEBUG
    if (NULL != focuswin)
    {
        PDEBUG("Focus now in win %d\n", focuswin->id);
    }
#endif

    if (NULL == wslist[curws])
    {
        PDEBUG("No windows to focus on in this workspace.\n");
        return 0;
    }
    
    if (MCWM_TABBING != mode)
    {
        /*
         * Remember what we last focused on. We need this when the
         * MODKEY is released and we move the last focused window in
         * the tabbing order list.
         */        
        lastfocuswin = focuswin;
        mode = MCWM_TABBING;

        PDEBUG("Began tabbing.\n");        
    }
    
    /* If we currently have no focus focus first in list. */
    if (NULL == focuswin || NULL == focuswin->wsitem[curws])
    {
        PDEBUG("Focusing first in list: %p\n", wslist[curws]);
        client = wslist[curws]->data;

        if (NULL != focuswin && NULL == focuswin->wsitem[curws])
        {
            PDEBUG("XXX Our focused window %d isn't on this workspace!\n",
                   focuswin->id);
        }
    }
    else
    {
        if (arg.b)
        {
            if (NULL == focuswin->wsitem[curws]->prev)
            {
                /*
                 * We were at the head of list. Focusing on last
                 * window in list unless we were already there.
                 */
                struct item *last = wslist[curws];
                while (NULL != last->next)
                    last = last->next;
                if (focuswin->wsitem[curws] != last->data)
                {
                    PDEBUG("Beginning of list. Focusing last in list: %p\n",
                           last);
                    client = last->data;
                }
            }
            else
            {
                /* Otherwise, focus the next in list. */
                PDEBUG("Tabbing. Focusing next: %p.\n",
                       focuswin->wsitem[curws]->prev);
                client = focuswin->wsitem[curws]->prev->data;
            }
        }
        else
        {
            if (NULL == focuswin->wsitem[curws]->next)
            {
                /*
                 * We were at the end of list. Focusing on first window in
                 * list unless we were already there.
                 */
                if (focuswin->wsitem[curws] != wslist[curws]->data)
                {
                    PDEBUG("End of list. Focusing first in list: %p\n",
                           wslist[curws]);
                    client = wslist[curws]->data;
                }
            }
            else
            {
                /* Otherwise, focus the next in list. */
                PDEBUG("Tabbing. Focusing next: %p.\n",
                       focuswin->wsitem[curws]->next);            
                client = focuswin->wsitem[curws]->next->data;
            }
        }
    } /* if NULL focuswin */

    if (NULL != client)
    {
        /*
         * Raise window if it's occluded, then warp pointer into it and
         * set keyboard focus to it.
         */
        uint32_t values[] = { XCB_STACK_MODE_TOP_IF };    

        xcb_configure_window(conn, client->id, XCB_CONFIG_WINDOW_STACK_MODE,
                             values);
        xcb_warp_pointer(conn, XCB_NONE, client->id, 0, 0, 0, 0,
                         client->width / 2, client->height / 2);
        setfocus(client);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rsi, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl 0x9ae2(%rip), %eax      # 0xd8c0
movl %eax, %edx
xorl %eax, %eax
leaq 0x9af7(%rip), %rcx      # 0xd8e0
cmpq (%rcx,%rdx,8), %rax
jne 0x3dfb
movl $0x0, -0x4(%rbp)
jmp 0x4047
movl $0x4, %eax
cmpl 0x9ad2(%rip), %eax      # 0xd8d8
je 0x3e20
movq 0x9b31(%rip), %rax      # 0xd940
movq %rax, 0x9b8a(%rip)      # 0xd9a0
movl $0x4, 0x9ab8(%rip)      # 0xd8d8
xorl %eax, %eax
cmpq 0x9b17(%rip), %rax      # 0xd940
je 0x3e43
movq 0x9b0e(%rip), %rcx      # 0xd940
movl 0x9a88(%rip), %eax      # 0xd8c0
movl %eax, %edx
xorl %eax, %eax
cmpq 0x48(%rcx,%rdx,8), %rax
jne 0x3e87
movl 0x9a77(%rip), %eax      # 0xd8c0
movl %eax, %ecx
leaq 0x9a8e(%rip), %rax      # 0xd8e0
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq 0x9ada(%rip), %rax      # 0xd940
je 0x3e82
movq 0x9ad1(%rip), %rcx      # 0xd940
movl 0x9a4b(%rip), %eax      # 0xd8c0
movl %eax, %edx
xorl %eax, %eax
cmpq 0x48(%rcx,%rdx,8), %rax
jne 0x3e82
jmp 0x3e82
jmp 0x3fa4
testb $0x1, -0x10(%rbp)
je 0x3f23
movq 0x9aa8(%rip), %rax      # 0xd940
movl 0x9a22(%rip), %ecx      # 0xd8c0
movq 0x48(%rax,%rcx,8), %rcx
xorl %eax, %eax
cmpq 0x8(%rcx), %rax
jne 0x3f04
movl 0x9a0f(%rip), %eax      # 0xd8c0
movl %eax, %ecx
leaq 0x9a26(%rip), %rax      # 0xd8e0
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq 0x10(%rcx), %rax
je 0x3edc
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x3ec2
movq 0x9a5d(%rip), %rax      # 0xd940
movl 0x99d7(%rip), %ecx      # 0xd8c0
movq 0x48(%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
je 0x3f02
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x3f21
movq 0x9a35(%rip), %rax      # 0xd940
movl 0x99af(%rip), %ecx      # 0xd8c0
movq 0x48(%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x3fa2
movq 0x9a16(%rip), %rax      # 0xd940
movl 0x9990(%rip), %ecx      # 0xd8c0
movq 0x48(%rax,%rcx,8), %rcx
xorl %eax, %eax
cmpq 0x10(%rcx), %rax
jne 0x3f83
movq 0x99fc(%rip), %rax      # 0xd940
movl 0x9976(%rip), %ecx      # 0xd8c0
movq 0x48(%rax,%rcx,8), %rax
movl 0x996b(%rip), %ecx      # 0xd8c0
movl %ecx, %edx
leaq 0x9982(%rip), %rcx      # 0xd8e0
movq (%rcx,%rdx,8), %rcx
cmpq (%rcx), %rax
je 0x3f81
movl 0x9953(%rip), %eax      # 0xd8c0
movl %eax, %ecx
leaq 0x996a(%rip), %rax      # 0xd8e0
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x3fa0
movq 0x99b6(%rip), %rax      # 0xd940
movl 0x9930(%rip), %ecx      # 0xd8c0
movq 0x48(%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x3fa2
jmp 0x3fa4
xorl %eax, %eax
cmpq -0x20(%rbp), %rax
je 0x4040
movl 0x65fe(%rip), %eax      # 0xa5b4
movl %eax, -0x2c(%rbp)
movq 0x99b8(%rip), %rdi      # 0xd978
movq -0x20(%rbp), %rax
movl (%rax), %esi
leaq -0x2c(%rbp), %rcx
movl $0x40, %edx
callq 0x3200
movl %eax, -0x30(%rbp)
movq 0x999a(%rip), %rdi      # 0xd978
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movzwl 0xa(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movw %ax, %r10w
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl -0x38(%rbp), %edx
xorl %r9d, %r9d
movl %r9d, %esi
movl %r9d, %ecx
movl %r9d, %r8d
movl $0x0, (%rsp)
movswl %r10w, %r10d
movl %r10d, 0x8(%rsp)
cwtl
movl %eax, 0x10(%rsp)
callq 0x3050
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rdi
callq 0x71c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq