// File: /workspace/github_c_makefile_star2_O1/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 0x2917(%rip), %rsi      # 0x81f2
callq 0x71f7
movl (%rax), %r13d
cmpl $0x3, %r13d
movl $0x3, %r12d
cmovbl %r13d, %r12d
movl $0x0, 0x14(%rsp)
testl %r13d, %r13d
je 0x59af
leaq 0x6fe7(%rip), %rax      # 0xc8f0
movl (%rax), %eax
cmpl (%rbx), %eax
leaq 0x278d(%rip), %rsi      # 0x80a1
leaq 0x2742(%rip), %rax      # 0x805d
leaq 0x2750(%rip), %r14      # 0x8072
cmoveq %rax, %r14
movq %rbx, %rdi
callq 0x71f7
movzwl (%rax), %ebp
leaq 0x2751(%rip), %rsi      # 0x8089
movq %rbx, %rdi
callq 0x71f7
movl (%rax), %r15d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x71f7
movl (%rax), %r14d
movw %bp, 0xe(%rsp)
testw %bp, %bp
movl %r15d, 0x10(%rsp)
movl %r15d, %ebp
cmovel %r14d, %ebp
leaq 0x288e(%rip), %rsi      # 0x81fa
movq %rbx, %rdi
callq 0x71f7
movl (%rax), %r15d
leaq 0x288e(%rip), %rsi      # 0x820c
movq %rbx, %rdi
callq 0x71f7
cmpl $0x1, %r15d
adcl $0x0, %r15d
cmpl $0x1, %r13d
jne 0x59d0
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 0x5a06
movl 0x4(%rbx), %edi
leaq 0x14(%rsp), %rdx
movl $0x10, %esi
callq 0x7690
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 0x5aac