// File: /workspace/github_c_makefile_star2_O0/comfies[P]custard/src/xcb/ewmh.c
// Function: initialize_ewmh
unsigned short initialize_ewmh() {
    ewmh_window = xcb_generate_id(xcb_connection);

    unsigned int events[1] = {
        XCB_EVENT_MASK_POINTER_MOTION
    };

    xcb_create_window(xcb_connection, XCB_COPY_FROM_PARENT, ewmh_window,
        xcb_screen->root, 0, 0,
        xcb_screen->width_in_pixels, xcb_screen->height_in_pixels, 0,
        XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT,
        XCB_CW_EVENT_MASK, events);

    ewmh_connection = (xcb_ewmh_connection_t*)calloc(1,
        sizeof(xcb_ewmh_connection_t));

    xcb_intern_atom_cookie_t *initialize_atoms_cookie;
    initialize_atoms_cookie = xcb_ewmh_init_atoms(xcb_connection,
        ewmh_connection);

    if (!xcb_ewmh_init_atoms_replies(ewmh_connection, initialize_atoms_cookie,
        NULL)) {
        log_fatal("Unable to initialize atoms");
        free(ewmh_connection);
        return 0;
    }

    xcb_ewmh_set_wm_pid(ewmh_connection, ewmh_window, getpid());
    xcb_ewmh_set_wm_name(ewmh_connection, ewmh_window, 7, "custard");
    xcb_ewmh_set_supporting_wm_check(ewmh_connection, xcb_screen->root,
        ewmh_window);
    xcb_ewmh_set_supporting_wm_check(ewmh_connection, ewmh_window, ewmh_window);

    xcb_atom_t supported_atoms[] = {
        ewmh_connection->_NET_WM_NAME,
        ewmh_connection->_NET_ACTIVE_WINDOW,
        ewmh_connection->_NET_SUPPORTED,
        ewmh_connection->_NET_SUPPORTING_WM_CHECK,
        ewmh_connection->_NET_WM_PID,
        ewmh_connection->_NET_WM_STATE,
        ewmh_connection->_NET_CLOSE_WINDOW,
        ewmh_connection->_NET_WM_ACTION_CLOSE,
        ewmh_connection->_NET_WM_WINDOW_TYPE,
        ewmh_connection->_NET_WM_WINDOW_TYPE_DOCK,
        ewmh_connection->_NET_WM_WINDOW_TYPE_TOOLBAR,
        ewmh_connection->_NET_WM_WINDOW_TYPE_MENU,
        ewmh_connection->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
        ewmh_connection->_NET_WM_WINDOW_TYPE_POPUP_MENU,
        ewmh_connection->_NET_WM_WINDOW_TYPE_DIALOG,
        ewmh_connection->_NET_WM_WINDOW_TYPE_DESKTOP,
        ewmh_connection->_NET_WM_WINDOW_TYPE_SPLASH,
        ewmh_connection->_NET_WM_WINDOW_TYPE_DND,
        ewmh_connection->WM_PROTOCOLS
    };

    xcb_ewmh_set_supported(ewmh_connection, 0,
        sizeof(supported_atoms) / sizeof*(supported_atoms) + 1,
        supported_atoms);

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
leaq 0x4e06(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
callq 0x3230
movl %eax, 0x4e18(%rip)      # 0xd918
movl 0x1cfa(%rip), %eax      # 0xa800
movl %eax, -0x8(%rbp)
leaq 0x4de8(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movl 0x4dff(%rip), %edx      # 0xd918
leaq 0x4de0(%rip), %rax      # 0xd900
movq (%rax), %rax
movl (%rax), %ecx
leaq 0x4dd4(%rip), %rax      # 0xd900
movq (%rax), %rax
movw 0x14(%rax), %r11w
leaq 0x4dc5(%rip), %rax      # 0xd900
movq (%rax), %rax
movw 0x16(%rax), %r10w
leaq -0x8(%rbp), %rax
xorl %r9d, %r9d
movl %r9d, %esi
movl %r9d, %r8d
movzwl %r11w, %r11d
movl %r11d, (%rsp)
movzwl %r10w, %r10d
movl %r10d, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x800, 0x28(%rsp)      # imm = 0x800
movq %rax, 0x30(%rsp)
callq 0x3150
movl %eax, -0xc(%rbp)
movl $0x1, %edi
movl $0x168, %esi            # imm = 0x168
callq 0x3350
movq %rax, 0x4d7c(%rip)      # 0xd920
leaq 0x4d4d(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movq 0x4d6b(%rip), %rsi      # 0xd920
callq 0x31d0
movq %rax, -0x18(%rbp)
movq 0x4d5b(%rip), %rdi      # 0xd920
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x36e0
cmpb $0x0, %al
jne 0x8c13
movl $0x1, %edi
leaq 0x1c22(%rip), %rsi      # 0xa804
leaq 0x1c2a(%rip), %rdx      # 0xa813
movl $0x22, %ecx
leaq 0x1c2e(%rip), %r8       # 0xa823
movb $0x0, %al
callq 0x5bf0
movq 0x4d1d(%rip), %rdi      # 0xd920
callq 0x3060
movw $0x0, -0x2(%rbp)
jmp 0x8dea
movq 0x4d06(%rip), %rax      # 0xd920
movq %rax, -0x90(%rbp)
movl 0x4cf1(%rip), %eax      # 0xd918
movl %eax, -0x88(%rbp)
callq 0x3190
movq -0x90(%rbp), %rdi
movl -0x88(%rbp), %esi
movl %eax, %edx
callq 0x35f0
movl %eax, -0x1c(%rbp)
movq 0x4cd0(%rip), %rdi      # 0xd920
movl 0x4cc2(%rip), %esi      # 0xd918
movl $0x7, %edx
leaq 0x1760(%rip), %rcx      # 0xa3c2
callq 0x3260
movl %eax, -0x20(%rbp)
movq 0x4caf(%rip), %rdi      # 0xd920
leaq 0x4c88(%rip), %rax      # 0xd900
movq (%rax), %rax
movl (%rax), %esi
movl 0x4c95(%rip), %edx      # 0xd918
callq 0x36c0
movl %eax, -0x24(%rbp)
movq 0x4c8e(%rip), %rdi      # 0xd920
movl 0x4c80(%rip), %esi      # 0xd918
movl 0x4c7a(%rip), %edx      # 0xd918
callq 0x36c0
movl %eax, -0x28(%rbp)
movq 0x4c73(%rip), %rax      # 0xd920
movl 0x6c(%rax), %eax
movl %eax, -0x80(%rbp)
movq 0x4c66(%rip), %rax      # 0xd920
movl 0x40(%rax), %eax
movl %eax, -0x7c(%rbp)
movq 0x4c59(%rip), %rax      # 0xd920
movl 0x20(%rax), %eax
movl %eax, -0x78(%rbp)
movq 0x4c4c(%rip), %rax      # 0xd920
movl 0x48(%rax), %eax
movl %eax, -0x74(%rbp)
movq 0x4c3f(%rip), %rax      # 0xd920
movl 0x9c(%rax), %eax
movl %eax, -0x70(%rbp)
movq 0x4c2f(%rip), %rax      # 0xd920
movl 0x84(%rax), %eax
movl %eax, -0x6c(%rbp)
movq 0x4c1f(%rip), %rax      # 0xd920
movl 0x58(%rax), %eax
movl %eax, -0x68(%rbp)
movq 0x4c12(%rip), %rax      # 0xd920
movl 0x15c(%rax), %eax
movl %eax, -0x64(%rbp)
movq 0x4c02(%rip), %rax      # 0xd920
movl 0x80(%rax), %eax
movl %eax, -0x60(%rbp)
movq 0x4bf2(%rip), %rax      # 0xd920
movl 0xd4(%rax), %eax
movl %eax, -0x5c(%rbp)
movq 0x4be2(%rip), %rax      # 0xd920
movl 0xd8(%rax), %eax
movl %eax, -0x58(%rbp)
movq 0x4bd2(%rip), %rax      # 0xd920
movl 0xdc(%rax), %eax
movl %eax, -0x54(%rbp)
movq 0x4bc2(%rip), %rax      # 0xd920
movl 0xec(%rax), %eax
movl %eax, -0x50(%rbp)
movq 0x4bb2(%rip), %rax      # 0xd920
movl 0xf0(%rax), %eax
movl %eax, -0x4c(%rbp)
movq 0x4ba2(%rip), %rax      # 0xd920
movl 0xe8(%rax), %eax
movl %eax, -0x48(%rbp)
movq 0x4b92(%rip), %rax      # 0xd920
movl 0xd0(%rax), %eax
movl %eax, -0x44(%rbp)
movq 0x4b82(%rip), %rax      # 0xd920
movl 0xe4(%rax), %eax
movl %eax, -0x40(%rbp)
movq 0x4b72(%rip), %rax      # 0xd920
movl 0x100(%rax), %eax
movl %eax, -0x3c(%rbp)
movq 0x4b62(%rip), %rax      # 0xd920
movl 0xc8(%rax), %eax
movl %eax, -0x38(%rbp)
movq 0x4b52(%rip), %rdi      # 0xd920
leaq -0x80(%rbp), %rcx
xorl %esi, %esi
movl $0x14, %edx
callq 0x3570
movl %eax, -0x84(%rbp)
movw $0x1, -0x2(%rbp)
movw -0x2(%rbp), %ax
addq $0xd0, %rsp
popq %rbp
retq
nopw (%rax,%rax)