// File: /workspace/github_c_makefile_star2_O3/tkln[P]mcwm/mcwm.c
// Function: setupkeys
int setupkeys(void)
{
    xcb_key_symbols_t *keysyms;
    unsigned i;
    
    /* Get all the keysymbols. */
    keysyms = xcb_key_symbols_alloc(conn);

    /*
     * Find out what keys generates our MODKEY mask. Unfortunately it
     * might be several keys.
     */
    if (NULL != modkeys.keycodes)
    {
        free(modkeys.keycodes);
    }
    modkeys = getmodkeys(MODKEY);

    if (0 == modkeys.len)
    {
        fprintf(stderr, "We couldn't find any keycodes to our main modifier "
                "key!\n");
        return -1;
    }

    for (i = 0; i < modkeys.len; i ++)
    {
        /*
         * Grab the keys that are bound to MODKEY mask with any other
         * modifier.
         */
        xcb_grab_key(conn, 1, screen->root, XCB_MOD_MASK_ANY,
                     modkeys.keycodes[i],
                     XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);    
    }
    
    /* Now grab the rest of the keys with the MODKEY modifier. */
    for (i = 0; i < sizeof(keys)/sizeof(keys[0]); i ++)
    {
        if (XK_VoidSymbol == keys[i].keysym)
        {
            keys[i].keycode = 0;
            continue;
        }

        keys[i].keycode = keysymtokeycode(keys[i].keysym, keysyms);        
        if (0 == keys[i].keycode)
        {
            /* Couldn't set up keys! */
    
            /* Get rid of key symbols. */
            xcb_key_symbols_free(keysyms);

            return -1;
        }
            
        /* Grab other keys with a modifier mask. */
        xcb_grab_key(conn, 1, screen->root, MODKEY, keys[i].keycode,
                     XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);

        /*
         * XXX Also grab it's shifted counterpart. A bit ugly here
         * because we grab all of them not just the ones we want.
         */
        xcb_grab_key(conn, 1, screen->root, MODKEY | SHIFTMOD,
                     keys[i].keycode,
                     XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
    } /* for */

    /* Need this to take effect NOW! */
    xcb_flush(conn);
    
    /* Get rid of the key symbols table. */
    xcb_key_symbols_free(keysyms);
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq 0x5941(%rip), %rdi      # 0xa978
callq 0x3130
movq %rax, %rbx
movq 0x58ea(%rip), %rdi      # 0xa930
testq %rdi, %rdi
je 0x5050
callq 0x3040
movq 0x5921(%rip), %rdi      # 0xa978
callq 0x3590
movq 0x5915(%rip), %rdi      # 0xa978
movl %eax, %esi
xorl %edx, %edx
callq 0x3560
testq %rax, %rax
je 0x5219
movq %rax, %r14
movzbl 0x1(%rax), %edi
movl $0x1, %esi
callq 0x3260
testq %rax, %rax
je 0x5219
movq %rax, %r15
movq %r14, %rdi
callq 0x30b0
xorl %ecx, %ecx
xorl %ebp, %ebp
cmpl $0x6, %ecx
jne 0x50ce
movzbl 0x1(%r14), %edx
testq %rdx, %rdx
je 0x50ce
leaq (%rdx,%rdx,2), %rsi
leaq (%rax,%rsi,2), %rsi
xorl %edi, %edi
movb (%rsi,%rdi), %r8b
testb %r8b, %r8b
je 0x50c6
movb %r8b, (%r15,%rdi)
incl %ebp
incq %rdi
cmpq %rdi, %rdx
jne 0x50b7
incl %ecx
cmpl $0x8, %ecx
jne 0x509e
movq %r14, %rdi
callq 0x3040
movq %r15, 0x584c(%rip)      # 0xa930
movl %ebp, 0x584e(%rip)      # 0xa938
testl %ebp, %ebp
je 0x522e
xorl %r14d, %r14d
movq 0x587c(%rip), %rdi      # 0xa978
movq 0x5845(%rip), %rax      # 0xa948
movl (%rax), %edx
movq 0x5824(%rip), %rax      # 0xa930
movzbl (%rax,%r14), %r8d
movl $0x1, (%rsp)
movl $0x1, %esi
movl $0x8000, %ecx           # imm = 0x8000
movl $0x1, %r9d
callq 0x32f0
incq %r14
movl 0x5802(%rip), %eax      # 0xa938
cmpq %rax, %r14
jb 0x50f5
movl $0x4, %r14d
leaq 0x5198(%rip), %r15      # 0xa2e0
movl $0x1, %ebp
movl -0x4(%r14,%r15), %esi
cmpl $0xffffff, %esi         # imm = 0xFFFFFF
jne 0x5164
movb $0x0, (%r14,%r15)
jmp 0x51e6
movq %rbx, %rdi
callq 0x32c0
testq %rax, %rax
je 0x5245
movb (%rax), %r12b
movq %rax, %rdi
callq 0x3040
movb %r12b, (%r14,%r15)
testb %r12b, %r12b
je 0x520f
movq 0x57e4(%rip), %rdi      # 0xa978
movq 0x57ad(%rip), %rax      # 0xa948
movl (%rax), %edx
movl %ebp, (%rsp)
movzbl %r12b, %r8d
movl $0x1, %esi
movl $0x40, %ecx
movl $0x1, %r9d
callq 0x32f0
movq 0x57b8(%rip), %rdi      # 0xa978
movq 0x5781(%rip), %rax      # 0xa948
movl (%rax), %edx
movzbl (%r14,%r15), %r8d
movl %ebp, (%rsp)
movl $0x1, %esi
movl $0x41, %ecx
movl $0x1, %r9d
callq 0x32f0
addq $0x28, %r14
cmpq $0x5cc, %r14            # imm = 0x5CC
jne 0x514d
movq 0x577a(%rip), %rdi      # 0xa978
callq 0x3150
movq %rbx, %rdi
callq 0x33b0
xorl %eax, %eax
jmp 0x5238
movq %rbx, %rdi
callq 0x33b0
jmp 0x5233
movq $0x0, 0x570c(%rip) # 0xa930
movl $0x0, 0x570a(%rip)      # 0xa938
callq 0x3622
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x35fd