// File: /workspace/github_cpp_makefile_star2_O3/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
testb $0x8, 0x50(%rsi)
je 0x9167
movq %rsi, %r14
movq %rdi, %rbx
movl 0x54(%rsi), %ebp
movq (%rdi), %rdi
movl $0xffc1, %esi           # imm = 0xFFC1
callq 0x3140
movzbl %al, %eax
cmpl %eax, %ebp
jne 0x90c0
movq 0x600d(%rip), %rdi      # 0xefd8
leaq 0x2123(%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 0x9134
movq 0x10(%rsp), %rdi
movslq 0xc(%rsp), %rax
leaq (%rdi,%rax,8), %rsi
leaq 0x70(%rbx), %rdx
callq 0x9817
movslq 0xc(%rsp), %rcx
shlq $0x3, %rcx
addq 0x10(%rsp), %rcx
cmpq %rcx, %rax
je 0x9134
movq 0x5fa9(%rip), %r15      # 0xefd8
leaq 0x20e7(%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 0x9167
leaq 0x2091(%rip), %rdi      # 0xb139
leaq 0x1d38(%rip), %rsi      # 0xade7
leaq 0x20b2(%rip), %rcx      # 0xb168
movl $0x18e, %edx            # imm = 0x18E
callq 0x3160
testb $0x8, 0x50(%r14)
je 0x9167
movl 0x54(%r14), %ebp
movq (%rbx), %rdi
movl $0xff09, %esi           # imm = 0xFF09
callq 0x3140
movzbl %al, %eax
cmpl %eax, %ebp
jne 0x9167
leaq 0x10(%rbx), %rdi
addq $0x20, %r14
movq %r14, %rsi
callq 0x98c4
testq %rax, %rax
je 0x9175
movq (%rax), %r14
testq %r14, %r14
jne 0x9108
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 0x5e9d(%rip), %r15      # 0xefd8
leaq 0x2058(%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 0x202e(%rip), %rdi      # 0xb1aa
leaq 0x1c64(%rip), %rsi      # 0xade7
leaq 0x1fde(%rip), %rcx      # 0xb168
movl $0x196, %edx            # imm = 0x196
callq 0x3160