// File: /workspace/github_c_makefile_star2_O2/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 0x7638(%rip), %rbx      # 0xc8d8
cmpq $0x0, (%rbx)
je 0x52e8
leaq 0x311e(%rip), %rsi      # 0x83cb
leaq 0x331c(%rip), %rdx      # 0x85d0
leaq 0x331e(%rip), %r8       # 0x85d9
pushq $0x3
popq %rdi
movl $0xc0, %ecx
xorl %eax, %eax
callq 0x50dd
movq (%rbx), %rdi
callq 0x383d
testq %rax, %rax
je 0x52e0
movl (%rax), %edi
callq 0x6d04
jmp 0x52ca
movq (%rbx), %rdi
callq 0x391a
leaq 0x75d9(%rip), %r15      # 0xc8c8
cmpq $0x0, (%r15)
je 0x53c3
leaq 0x30cb(%rip), %rsi      # 0x83cb
leaq 0x32c9(%rip), %rdx      # 0x85d0
leaq 0x32e6(%rip), %r8       # 0x85f4
pushq $0x3
popq %rdi
movl $0xcb, %ecx
xorl %eax, %eax
callq 0x50dd
movq (%r15), %rdi
callq 0x383d
testq %rax, %rax
je 0x53c3
movq %rax, %rbx
movq (%rax), %rdi
callq 0x3060
movq 0x8(%rbx), %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x5380
callq 0x383d
testq %rax, %rax
je 0x5377
movq %rax, %r14
movq 0x8(%rax), %rdi
callq 0x3060
movq (%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
jmp 0x534b
movq 0x10(%rbx), %rdi
callq 0x391a
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
jne 0x53ab
jmp 0x531d
movq %rax, %r14
movq (%rax), %rdi
callq 0x3060
movq 0x8(%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x18(%rbx), %rdi
callq 0x383d
testq %rax, %rax
jne 0x538b
movq 0x18(%rbx), %rdi
callq 0x391a
jmp 0x531d
leaq 0x74e6(%rip), %r14      # 0xc8b0
cmpq $0x0, (%r14)
je 0x5427
leaq 0x2ff4(%rip), %rsi      # 0x83cb
leaq 0x31f2(%rip), %rdx      # 0x85d0
leaq 0x322b(%rip), %r8       # 0x8610
pushq $0x3
popq %rdi
movl $0xe6, %ecx
xorl %eax, %eax
callq 0x50dd
movq (%r14), %rdi
callq 0x383d
testq %rax, %rax
je 0x541f
movq %rax, %rbx
movq (%rax), %rdi
callq 0x3060
movq 0x8(%rbx), %rdi
callq 0x3060
movq %rbx, %rdi
callq 0x3060
jmp 0x53f4
movq (%r14), %rdi
callq 0x391a
leaq 0x74a2(%rip), %r15      # 0xc8d0
cmpq $0x0, (%r15)
je 0x54bc
leaq 0x2f8c(%rip), %rsi      # 0x83cb
leaq 0x318a(%rip), %rdx      # 0x85d0
leaq 0x31e4(%rip), %r8       # 0x8631
pushq $0x3
popq %rdi
movl $0xf2, %ecx
xorl %eax, %eax
callq 0x50dd
movq (%r15), %rdi
callq 0x383d
testq %rax, %rax
je 0x54b4
movq %rax, %rbx
movq (%rax), %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
jne 0x549f
jmp 0x545c
movq %rax, %r14
movq (%rax), %rdi
callq 0x3060
movq 0x8(%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
callq 0x383d
testq %rax, %rax
jne 0x547f
movq 0x10(%rbx), %rdi
callq 0x391a
jmp 0x545c
movq (%r15), %rdi
callq 0x391a
callq 0x6fc4
callq 0x71e2
callq 0x49bb
movq 0x73e6(%rip), %rdi      # 0xc8b8
popq %rbx
popq %r14
popq %r15
jmp 0x3060