// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3dab(%rip), %rsi      # 0xa1f2
callq 0x8740
movl (%rax), %eax
movl %eax, -0xc(%rbp)
cmpl $0x3, -0xc(%rbp)
jbe 0x645e
movl $0x3, -0xc(%rbp)
leaq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x32e0
cmpl $0x0, -0xc(%rbp)
jne 0x648e
movq -0x8(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0x10(%rbp), %rdx
movl $0x10, %esi
callq 0x8e50
jmp 0x659d
movw $0x0, -0x12(%rbp)
leaq 0x7455(%rip), %rax      # 0xd8f0
movl (%rax), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x64ab
movw $0x1, -0x12(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3beb(%rip), %rsi      # 0xa0a1
callq 0x8740
movw (%rax), %ax
movw %ax, -0x14(%rbp)
leaq 0x3ba9(%rip), %rax      # 0xa072
movq %rax, -0x20(%rbp)
cmpw $0x0, -0x12(%rbp)
je 0x64df
leaq 0x3b82(%rip), %rax      # 0xa05d
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3b9f(%rip), %rsi      # 0xa089
callq 0x8740
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x8740
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpw $0x0, -0x14(%rbp)
je 0x651f
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3cd0(%rip), %rsi      # 0xa1fa
callq 0x8740
movl (%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3ccd(%rip), %rsi      # 0xa20c
callq 0x8740
movl (%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x6556
movl $0x1, -0x30(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x6563
movl $0x1, -0x34(%rbp)
cmpl $0x1, -0xc(%rbp)
jne 0x657d
movq -0x8(%rbp), %rax
movl 0x4(%rax), %edi
movl -0x30(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x65b0
jmp 0x659d
movq -0x8(%rbp), %rax
movl 0x4(%rax), %edi
movl -0x34(%rbp), %esi
movl -0x30(%rbp), %edx
movl -0xc(%rbp), %eax
movl -0x28(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movzwl %ax, %r9d
callq 0x6610
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)