// File: /workspace/github_c_makefile_star2_O2/comfies[P]custard/src/wm/decorations.c
// Function: decorate
void decorate(window_t *window) {
    // Mostly preprocessing

    unsigned int border_type = get_setting_from_window_rules(window,
        "borders")->number;

    if (border_type > 3)
        border_type = 3;

    unsigned int values[1] = { 0 };

    if (!border_type) {
        configure_window(window->parent,
            XCB_CONFIG_WINDOW_BORDER_WIDTH, values);
        return;
    }

    /* Focus */

    unsigned short window_is_focused = 0;
    if (focused_window == window->id)
        window_is_focused = 1;

    /* Color */

    unsigned short inverted_borders = get_setting_from_window_rules(window,
        "border.colors.flipped")->boolean;

    char *color_setting = "border.color.unfocused";
    if (window_is_focused)
        color_setting = "border.color.focused";

    color_t background_color = get_setting_from_window_rules(window,
        "border.color.background")->color;

    color_t primary_color = get_setting_from_window_rules(window,
        color_setting)->color;
    color_t secondary_color = background_color;

    if (inverted_borders) {
        secondary_color = primary_color;
        primary_color = background_color;
    }

    /* Size */

    unsigned int outer_size = get_setting_from_window_rules(window,
        "border.size.outer")->number;
    unsigned int inner_size = get_setting_from_window_rules(window,
        "border.size.inner")->number;

    if (!outer_size)
        outer_size = 1;

    if (!inner_size)
        inner_size = 1;

    /* Which border method? */

    if (border_type == 1) {
        single_border(window->parent, outer_size, primary_color);
        return;
    }

    /* Multiborder */

    multi_border(window->parent, inner_size, outer_size,
        primary_color, secondary_color, border_type);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x2ab0(%rip), %rsi      # 0x81ee
callq 0x6d83
movl (%rax), %r13d
cmpl $0x3, %r13d
pushq $0x3
popq %r12
cmovbl %r13d, %r12d
andl $0x0, 0x14(%rsp)
testl %r13d, %r13d
je 0x580d
leaq 0x7179(%rip), %rax      # 0xc8e0
movl (%rax), %eax
cmpl (%rbx), %eax
leaq 0x292d(%rip), %rsi      # 0x809f
leaq 0x28e2(%rip), %rax      # 0x805b
leaq 0x28f0(%rip), %r14      # 0x8070
cmoveq %rax, %r14
movq %rbx, %rdi
callq 0x6d83
movzwl (%rax), %ebp
leaq 0x28f1(%rip), %rsi      # 0x8087
movq %rbx, %rdi
callq 0x6d83
movl (%rax), %r15d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6d83
movl (%rax), %r14d
movw %bp, 0xe(%rsp)
testw %bp, %bp
movl %r15d, 0x10(%rsp)
movl %r15d, %ebp
cmovel %r14d, %ebp
leaq 0x2a2c(%rip), %rsi      # 0x81f6
movq %rbx, %rdi
callq 0x6d83
movl (%rax), %r15d
leaq 0x2a2c(%rip), %rsi      # 0x8208
movq %rbx, %rdi
callq 0x6d83
cmpl $0x1, %r15d
adcl $0x0, %r15d
cmpl $0x1, %r13d
jne 0x582c
movl 0x4(%rbx), %edi
movl %r15d, %esi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5862
movl 0x4(%rbx), %edi
pushq $0x10
popq %rsi
leaq 0x14(%rsp), %rdx
callq 0x7204
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpw $0x0, 0xe(%rsp)
cmovel 0x10(%rsp), %r14d
movl (%rax), %esi
cmpl $0x1, %esi
adcl $0x0, %esi
movl 0x4(%rbx), %edi
movzwl %r12w, %r9d
movl %r15d, %edx
movl %ebp, %ecx
movl %r14d, %r8d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x58ab