// File: /workspace/github_cpp_makefile_star2_O1/nishalkulkarni[P]fluid-wm/fluid_wm.cpp
// Function: WindowManager::OnKeyPress(XKeyEvent const&)
void WindowManager::OnKeyPress(const XKeyEvent& e)
{
    if ((e.state & MODKEY) && (e.keycode == XKeysymToKeycode(display_, XK_F4))) {
        // alt + f4: Close window.
        std::cout << "fewnlkewlhntkerjnhtrkjhntkrjnhktrnhj\n\n\n";
        Atom* supported_protocols;
        int num_supported_protocols;
        if (XGetWMProtocols(display_,
                e.window,
                &supported_protocols,
                &num_supported_protocols)
            && (::std::find(supported_protocols,
                    supported_protocols + num_supported_protocols,
                    WM_DELETE_WINDOW)
                != supported_protocols + num_supported_protocols)) {
            std::cout << "Gracefully deleting window " << e.window;

            XEvent msg;
            memset(&msg, 0, sizeof(msg));
            msg.xclient.type = ClientMessage;
            msg.xclient.message_type = WM_PROTOCOLS;
            msg.xclient.window = e.window;
            msg.xclient.format = 32;
            msg.xclient.data.l[0] = WM_DELETE_WINDOW;

            assert(XSendEvent(display_, e.window, false, 0, &msg));
        } else {
            std::cout << "Killing window " << e.window;
            XKillClient(display_, e.window);
        }
    } else if ((e.state & MODKEY) && (e.keycode == XKeysymToKeycode(display_, XK_Tab))) {
        // alt + tab: Switch window.
        auto i = clients_.find(e.window);
        assert(i != clients_.end());
        ++i;
        if (i == clients_.end()) {
            i = clients_.begin();
        }

        XRaiseWindow(display_, i->second);
        XSetInputFocus(display_, i->first, RevertToPointerRoot, CurrentTime);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testb $0x8, 0x50(%rsi)
je 0x911f
movl 0x54(%r14), %ebp
movq (%rbx), %rdi
movl $0xffc1, %esi           # imm = 0xFFC1
callq 0x3140
movzbl %al, %eax
cmpl %eax, %ebp
jne 0x911f
movq 0x5fae(%rip), %rdi      # 0xefd8
leaq 0x20c4(%rip), %rsi      # 0xb0f5
movl $0x27, %edx
callq 0x32a0
movq (%rbx), %rdi
movq 0x20(%r14), %rsi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
callq 0x3270
testl %eax, %eax
je 0x91ae
movq 0x10(%rsp), %rdi
movslq 0xc(%rsp), %rax
leaq (%rdi,%rax,8), %rsi
leaq 0x70(%rbx), %rdx
callq 0x988c
movslq 0xc(%rsp), %rcx
shlq $0x3, %rcx
addq 0x10(%rsp), %rcx
cmpq %rcx, %rax
je 0x91ae
movq 0x5f4a(%rip), %r15      # 0xefd8
leaq 0x2088(%rip), %rsi      # 0xb11d
movl $0x1b, %edx
movq %r15, %rdi
callq 0x32a0
movq 0x20(%r14), %rsi
movq %r15, %rdi
callq 0x3170
leaq 0x18(%rsp), %r15
movl $0xc0, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x3120
movl $0x21, (%r15)
movq 0x68(%rbx), %rax
movq %rax, 0x28(%r15)
movq 0x20(%r14), %rsi
movq %rsi, 0x20(%r15)
movl $0x20, 0x30(%r15)
movq 0x70(%rbx), %rax
movq %rax, 0x38(%r15)
movq (%rbx), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x3050
testl %eax, %eax
jne 0x91e1
leaq 0x2032(%rip), %rdi      # 0xb139
leaq 0x1cd9(%rip), %rsi      # 0xade7
leaq 0x2053(%rip), %rcx      # 0xb168
movl $0x18e, %edx            # imm = 0x18E
callq 0x3160
testb $0x8, 0x50(%r14)
je 0x91e1
movl 0x54(%r14), %ebp
movq (%rbx), %rdi
movl $0xff09, %esi           # imm = 0xFF09
callq 0x3140
movzbl %al, %eax
cmpl %eax, %ebp
jne 0x91e1
leaq 0x10(%rbx), %rdi
movq 0x20(%r14), %rcx
addq $0x20, %r14
xorl %r15d, %r15d
movq %rcx, %rax
xorl %edx, %edx
divq 0x18(%rbx)
movq %rdx, %rsi
movq %r14, %rdx
callq 0x9430
testq %rax, %rax
je 0x9171
movq (%rax), %r15
testq %r15, %r15
je 0x91ef
movq (%r15), %r14
testq %r14, %r14
jne 0x9182
movq 0x20(%rbx), %r14
movq (%rbx), %rdi
movq 0x10(%r14), %rsi
callq 0x3290
movq (%rbx), %rdi
movq 0x8(%r14), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
addq $0xd8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x31c0
movq 0x5e23(%rip), %r15      # 0xefd8
leaq 0x1fde(%rip), %rsi      # 0xb19a
movl $0xf, %edx
movq %r15, %rdi
callq 0x32a0
movq 0x20(%r14), %rsi
movq %r15, %rdi
callq 0x3170
movq (%rbx), %rdi
movq 0x20(%r14), %rsi
callq 0x3420
addq $0xd8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1fb4(%rip), %rdi      # 0xb1aa
leaq 0x1bea(%rip), %rsi      # 0xade7
leaq 0x1f64(%rip), %rcx      # 0xb168
movl $0x196, %edx            # imm = 0x196
callq 0x3160