// File: /workspace/github_c_makefile_star2_O0/comfies[P]custard/src/xcb/window.c
// Function: close_window
void close_window(xcb_window_t window_id) {
    xcb_get_property_cookie_t protocols_cookie;
    protocols_cookie = xcb_icccm_get_wm_protocols(xcb_connection, window_id,
        ewmh_connection->WM_PROTOCOLS);

    xcb_intern_atom_cookie_t delete_cookie;
    delete_cookie = xcb_intern_atom(xcb_connection, 0, 16, "WM_DELETE_WINDOW");

    xcb_icccm_get_wm_protocols_reply_t protocols;
    xcb_icccm_get_wm_protocols_reply(xcb_connection, protocols_cookie,
        &protocols, NULL);

    xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(xcb_connection,
        delete_cookie, NULL);

    if (reply) {
        for (unsigned int index = 0; index < protocols.atoms_len; index++) {
            if (protocols.atoms[index] == reply->atom) {

                xcb_client_message_event_t event = {
                    .response_type = XCB_CLIENT_MESSAGE,
                    .format        = 32,
                    .sequence      = 0,
                    .window        = window_id,
                    .type          = ewmh_connection->WM_PROTOCOLS,
                    .data.data32   = {
                        reply->atom, XCB_CURRENT_TIME
                    }
                };

                xcb_send_event(xcb_connection, 0, window_id,
                    XCB_EVENT_MASK_NO_EVENT, (char*)&event);
                xcb_icccm_get_wm_protocols_reply_wipe(&protocols);

                log_debug("Window(%08x) closed(WM_PROTOCOLS)", window_id);
                return;
            }
        }
    }

    xcb_icccm_get_wm_protocols_reply_wipe(&protocols);
    xcb_kill_client(xcb_connection, window_id);

    log_debug("Window(%08x) closed(xcb_kill_client)", window_id);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x4(%rbp)
leaq 0x47e6(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movl -0x4(%rbp), %esi
leaq 0x4801(%rip), %rax      # 0xd920
movq (%rax), %rax
movl 0xc8(%rax), %edx
callq 0x3100
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x8(%rbp)
leaq 0x47bb(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
xorl %esi, %esi
movl $0x10, %edx
leaq 0x17c6(%rip), %rcx      # 0xa914
callq 0x32d0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq 0x4795(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movl -0x8(%rbp), %esi
leaq -0x30(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x31b0
leaq 0x477b(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movl -0x10(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x34d0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x926e
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jae 0x926c
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x925c
movb $0x21, -0x5c(%rbp)
movb $0x20, -0x5b(%rbp)
movw $0x0, -0x5a(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x58(%rbp)
leaq 0x4740(%rip), %rax      # 0xd920
movq (%rax), %rax
movl 0xc8(%rax), %eax
movl %eax, -0x54(%rbp)
leaq -0x5c(%rbp), %rdi
addq $0xc, %rdi
xorl %esi, %esi
movl $0x14, %edx
callq 0x32e0
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x50(%rbp)
leaq 0x46e7(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movl -0x4(%rbp), %edx
xorl %ecx, %ecx
leaq -0x5c(%rbp), %r8
movl %ecx, %esi
callq 0x3580
movl %eax, -0x60(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x30f0
movl -0x4(%rbp), %r9d
movl $0x3, %edi
leaq 0x15fe(%rip), %rsi      # 0xa83e
leaq 0x16de(%rip), %rdx      # 0xa925
movl $0x65, %ecx
leaq 0x16df(%rip), %r8       # 0xa932
movb $0x0, %al
callq 0x5bf0
jmp 0x92b6
jmp 0x925e
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x91a2
jmp 0x926e
leaq -0x30(%rbp), %rdi
callq 0x30f0
leaq 0x467a(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movl -0x4(%rbp), %esi
callq 0x36a0
movl %eax, -0x64(%rbp)
movl -0x4(%rbp), %r9d
movl $0x3, %edi
leaq 0x15a2(%rip), %rsi      # 0xa83e
leaq 0x1682(%rip), %rdx      # 0xa925
movl $0x6e, %ecx
leaq 0x16a5(%rip), %r8       # 0xa954
movb $0x0, %al
callq 0x5bf0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)