// File: /workspace/github_c_makefile_star2_O1/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 0x751c(%rip), %rbx      # 0xc8e8
cmpq $0x0, (%rbx)
je 0x5416
leaq 0x2ff6(%rip), %rsi      # 0x83cf
leaq 0x31f4(%rip), %rdx      # 0x85d4
leaq 0x31f6(%rip), %r8       # 0x85dd
movl $0x3, %edi
movl $0xc0, %ecx
xorl %eax, %eax
callq 0x5206
movq (%rbx), %rdi
callq 0x3851
testq %rax, %rax
je 0x540e
movl (%rax), %edi
callq 0x716b
jmp 0x53f8
movq (%rbx), %rdi
callq 0x3932
leaq 0x74bb(%rip), %r15      # 0xc8d8
cmpq $0x0, (%r15)
je 0x551c
leaq 0x2fa1(%rip), %rsi      # 0x83cf
leaq 0x319f(%rip), %rdx      # 0x85d4
leaq 0x31bc(%rip), %r8       # 0x85f8
movl $0x3, %edi
movl $0xcb, %ecx
xorl %eax, %eax
callq 0x5206
movq (%r15), %rdi
callq 0x3851
testq %rax, %rax
je 0x551c
movq %rax, %rbx
movq (%rbx), %rdi
callq 0x3060
movq 0x8(%rbx), %rdi
callq 0x3060
cmpq $0x0, 0x10(%rbx)
je 0x54bd
movq 0x10(%rbx), %rdi
callq 0x3851
testq %rax, %rax
je 0x54b4
movq %rax, %r14
movq 0x8(%r14), %rdi
callq 0x3060
movq (%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
callq 0x3851
movq %rax, %r14
testq %rax, %rax
jne 0x548a
movq 0x10(%rbx), %rdi
callq 0x3932
cmpq $0x0, 0x18(%rbx)
je 0x5508
movq 0x18(%rbx), %rdi
callq 0x3851
testq %rax, %rax
je 0x54ff
movq %rax, %r14
movq (%r14), %rdi
callq 0x3060
movq 0x8(%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x18(%rbx), %rdi
callq 0x3851
movq %rax, %r14
testq %rax, %rax
jne 0x54d5
movq 0x18(%rbx), %rdi
callq 0x3932
movq (%r15), %rdi
callq 0x3851
movq %rax, %rbx
testq %rax, %rax
jne 0x5461
leaq 0x739d(%rip), %r14      # 0xc8c0
cmpq $0x0, (%r14)
je 0x5590
leaq 0x2e9f(%rip), %rsi      # 0x83cf
leaq 0x309d(%rip), %rdx      # 0x85d4
leaq 0x30d6(%rip), %r8       # 0x8614
movl $0x3, %edi
movl $0xe6, %ecx
xorl %eax, %eax
callq 0x5206
movq (%r14), %rdi
callq 0x3851
testq %rax, %rax
je 0x5588
movq %rax, %rbx
movq (%rbx), %rdi
callq 0x3060
movq 0x8(%rbx), %rdi
callq 0x3060
movq %rbx, %rdi
callq 0x3060
movq (%r14), %rdi
callq 0x3851
movq %rax, %rbx
testq %rax, %rax
jne 0x555f
movq (%r14), %rdi
callq 0x3932
leaq 0x7349(%rip), %r15      # 0xc8e0
cmpq $0x0, (%r15)
je 0x5642
leaq 0x2e27(%rip), %rsi      # 0x83cf
leaq 0x3025(%rip), %rdx      # 0x85d4
leaq 0x307f(%rip), %r8       # 0x8635
movl $0x3, %edi
movl $0xf2, %ecx
xorl %eax, %eax
callq 0x5206
movq (%r15), %rdi
callq 0x3851
testq %rax, %rax
je 0x563a
movq %rax, %rbx
movq (%rbx), %rdi
callq 0x3060
cmpq $0x0, 0x10(%rbx)
je 0x562a
movq 0x10(%rbx), %rdi
callq 0x3851
testq %rax, %rax
je 0x5621
movq %rax, %r14
movq (%r14), %rdi
callq 0x3060
movq 0x8(%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq 0x10(%rbx), %rdi
callq 0x3851
movq %rax, %r14
testq %rax, %rax
jne 0x55f7
movq 0x10(%rbx), %rdi
callq 0x3932
movq (%r15), %rdi
callq 0x3851
movq %rax, %rbx
testq %rax, %rax
jne 0x55d7
movq (%r15), %rdi
callq 0x3932
callq 0x7440
callq 0x766e
callq 0x4a9a
movq 0x7270(%rip), %rdi      # 0xc8c8
popq %rbx
popq %r14
popq %r15
jmp 0x3060