// File: /workspace/github_c_makefile_star2_O3/comfies[P]custard/src/wm/custard.c
// Function: finalize
void finalize() {
    /* Free used memory for windows */
    if (windows) {
        log_debug("Freeing memory for windows");
        window_t *window;
        while ((window = vector_iterator(windows)))
            unmanage_window(window->id);
        deconstruct_vector(windows);
    }

    kv_pair_t *kv_pair;
    monitor_t *monitor;
    labeled_grid_geometry_t *labeled_geometry;
    if (monitors) {
        log_debug("Freeing memory for monitors");
        while ((monitor = vector_iterator(monitors))) {
            free(monitor->name);
            free(monitor->geometry);

            if (monitor->geometries) {
                while ((labeled_geometry = vector_iterator(
                    monitor->geometries))) {
                    free(labeled_geometry->label);
                    free(labeled_geometry->geometry);
                    free(labeled_geometry);
                }
                deconstruct_vector(monitor->geometries);
            }

            if (monitor->configuration) {
                while ((kv_pair = vector_iterator(monitor->configuration))) {
                    free(kv_pair->key);
                    free(kv_pair->value);
                    free(kv_pair);
                }
                deconstruct_vector(monitor->configuration);
            }
        }
    }

    if (configuration) {
        log_debug("Freeing memory for configuration");
        while ((kv_pair = vector_iterator(configuration))) {
            free(kv_pair->key);
            free(kv_pair->value);
            free(kv_pair);
        }
        deconstruct_vector(configuration);
    }

    /* Free rules, if any */

    if (rules) {
        log_debug("Freeing memory for rules");
        rule_t *rule;
        while ((rule = vector_iterator(rules))) {
            free(rule->expression);

            if (rule->rules) {
                while ((kv_pair = vector_iterator(rule->rules))) {
                    free(kv_pair->key);
                    free(kv_pair->value);
                    free(kv_pair);
                }
                deconstruct_vector(rule->rules);
            }
        }
        deconstruct_vector(rules);
    }

    finalize_xcb();
    finalize_ewmh();
    finalize_socket();

    free(rc_path);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0x754c(%rip), %rbx      # 0xc8e8
cmpq $0x0, (%rbx)
je 0x53e6
leaq 0x3022(%rip), %rsi      # 0x83cb
leaq 0x3220(%rip), %rdx      # 0x85d0
leaq 0x3222(%rip), %r8       # 0x85d9
movl $0x3, %edi
movl $0xc0, %ecx
xorl %eax, %eax
callq 0x51d6
movq (%rbx), %rdi
callq 0x3849
testq %rax, %rax
je 0x53de
movl (%rax), %edi
callq 0x7132
jmp 0x53c8
movq (%rbx), %rdi
callq 0x392e
leaq 0x74eb(%rip), %r15      # 0xc8d8
cmpq $0x0, (%r15)
je 0x54e8
leaq 0x2fcd(%rip), %rsi      # 0x83cb
leaq 0x31cb(%rip), %rdx      # 0x85d0
leaq 0x31e8(%rip), %r8       # 0x85f4
movl $0x3, %edi
movl $0xcb, %ecx
xorl %eax, %eax
callq 0x51d6
movq (%r15), %rdi
callq 0x3849
testq %rax, %rax
je 0x54e8
movq %rax, %rbx
movq (%rbx), %rdi
callq 0x3060
movq 0x8(%rbx), %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x548b
callq 0x3849
testq %rax, %rax
je 0x5482
movq %rax, %r14
movq 0x8(%r14), %rdi
callq 0x3060
movq (%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
callq 0x3849
movq %rax, %r14
testq %rax, %rax
jne 0x5458
movq 0x10(%rbx), %rdi
callq 0x392e
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x54d4
callq 0x3849
testq %rax, %rax
je 0x54cb
movq %rax, %r14
movq (%r14), %rdi
callq 0x3060
movq 0x8(%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x18(%rbx), %rdi
callq 0x3849
movq %rax, %r14
testq %rax, %rax
jne 0x54a1
movq 0x18(%rbx), %rdi
callq 0x392e
movq (%r15), %rdi
callq 0x3849
movq %rax, %rbx
testq %rax, %rax
jne 0x5431
leaq 0x73d1(%rip), %r14      # 0xc8c0
cmpq $0x0, (%r14)
je 0x555c
leaq 0x2ecf(%rip), %rsi      # 0x83cb
leaq 0x30cd(%rip), %rdx      # 0x85d0
leaq 0x3106(%rip), %r8       # 0x8610
movl $0x3, %edi
movl $0xe6, %ecx
xorl %eax, %eax
callq 0x51d6
movq (%r14), %rdi
callq 0x3849
testq %rax, %rax
je 0x5554
movq %rax, %rbx
movq (%rbx), %rdi
callq 0x3060
movq 0x8(%rbx), %rdi
callq 0x3060
movq %rbx, %rdi
callq 0x3060
movq (%r14), %rdi
callq 0x3849
movq %rax, %rbx
testq %rax, %rax
jne 0x552b
movq (%r14), %rdi
callq 0x392e
leaq 0x737d(%rip), %r15      # 0xc8e0
cmpq $0x0, (%r15)
je 0x560c
leaq 0x2e57(%rip), %rsi      # 0x83cb
leaq 0x3055(%rip), %rdx      # 0x85d0
leaq 0x30af(%rip), %r8       # 0x8631
movl $0x3, %edi
movl $0xf2, %ecx
xorl %eax, %eax
callq 0x51d6
movq (%r15), %rdi
callq 0x3849
testq %rax, %rax
je 0x5604
movq %rax, %rbx
movq (%rbx), %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x55f4
callq 0x3849
testq %rax, %rax
je 0x55eb
movq %rax, %r14
movq (%r14), %rdi
callq 0x3060
movq 0x8(%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
callq 0x3849
movq %rax, %r14
testq %rax, %rax
jne 0x55c1
movq 0x10(%rbx), %rdi
callq 0x392e
movq (%r15), %rdi
callq 0x3849
movq %rax, %rbx
testq %rax, %rax
jne 0x55a3
movq (%r15), %rdi
callq 0x392e
callq 0x740e
callq 0x762d
callq 0x4a6d
movq 0x72a6(%rip), %rdi      # 0xc8c8
popq %rbx
popq %r14
popq %r15
jmp 0x3060