// File: /workspace/github_c_makefile_star2_O0/comfies[P]custard/src/wm/custard.c
// Function: manage_pre_existing_windows
void manage_pre_existing_windows() {
    unsigned int index = 0;
    xcb_query_tree_cookie_t query_cookie;
    query_cookie = xcb_query_tree(xcb_connection,
        xcb_screen->root);

    xcb_query_tree_reply_t *tree_reply;
    tree_reply = xcb_query_tree_reply(xcb_connection, query_cookie, NULL);

    if (!tree_reply)
        return;

    window_t *window = NULL;
    xcb_window_t child;
    xcb_window_t *children = xcb_query_tree_children(tree_reply);
    unsigned int number_of_children = (unsigned int)
        xcb_query_tree_children_length(tree_reply);

    for (; index < number_of_children; index++) {
        child = children[index];

        if (window_should_be_managed(child)) {
            window = manage_window(child);
            map_window(child);
            xcb_grab_button(xcb_connection, 0, child,
                XCB_EVENT_MASK_BUTTON_PRESS,
                XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
                XCB_NONE, XCB_NONE,  XCB_BUTTON_INDEX_ANY, XCB_MOD_MASK_ANY);
            decorate(window);
            log_debug("Pre-existing window(%08x) managed",
                child, window->workspace);
        }

    }

    if (window) {
    // Raise and focus the last window
        focused_window = window->id;
        xcb_ungrab_button(xcb_connection,
            XCB_BUTTON_INDEX_ANY, focused_window, XCB_MOD_MASK_ANY);
        raise_window(window->parent);
        focus_window(window->id);
        decorate(window);
    }

    apply();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
leaq 0x77d2(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
leaq 0x77d0(%rip), %rax      # 0xd900
movq (%rax), %rax
movl (%rax), %esi
callq 0x3270
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x8(%rbp)
leaq 0x77ae(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movl -0x8(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x3340
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6169
jmp 0x62b7
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x32f0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3420
movl %eax, -0x34(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x625a
movq -0x30(%rbp), %rax
movl -0x4(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edi
callq 0x7e30
cmpw $0x0, %ax
je 0x624a
movl -0x24(%rbp), %edi
callq 0x8130
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %edi
callq 0x8ec0
leaq 0x7728(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
movl -0x24(%rbp), %edx
xorl %esi, %esi
movl $0x4, %ecx
movl $0x1, %r9d
movl %r9d, %r8d
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x8000, 0x18(%rsp)     # imm = 0x8000
callq 0x3370
movl %eax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x6430
movl -0x24(%rbp), %r9d
movq -0x20(%rbp), %rax
movl 0x24(%rax), %eax
movl $0x3, %edi
leaq 0x4184(%rip), %rsi      # 0xa3b1
leaq 0x4344(%rip), %rdx      # 0xa578
movl $0xab, %ecx
leaq 0x4354(%rip), %r8       # 0xa594
movl %eax, (%rsp)
movb $0x0, %al
callq 0x5bf0
jmp 0x624c
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x618a
cmpq $0x0, -0x20(%rbp)
je 0x62b2
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0x7682(%rip), %rax      # 0xd8f0
movl %ecx, (%rax)
leaq 0x7681(%rip), %rax      # 0xd8f8
movq (%rax), %rdi
leaq 0x766f(%rip), %rax      # 0xd8f0
movl (%rax), %edx
xorl %esi, %esi
movl $0x8000, %ecx           # imm = 0x8000
callq 0x3510
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x9030
movq -0x20(%rbp), %rax
movl (%rax), %edi
callq 0x8f60
movq -0x20(%rbp), %rdi
callq 0x6430
callq 0x8ac0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)