// File: /workspace/github_c_makefile_star2_O1/comfies[P]custard/src/wm/decorations.c
// Function: multi_border
void multi_border(xcb_window_t window,
    unsigned int inner_size, unsigned int outer_size,
    color_t primary_color, color_t secondary_color,
    unsigned short border_type) {

    unsigned int values[1];

    xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry(xcb_connection,
        window);
    xcb_get_geometry_reply_t *geometry;

    xcb_pixmap_t pixmap = xcb_generate_id(xcb_connection);
    xcb_gcontext_t graphics_context = xcb_generate_id(xcb_connection);

    unsigned int border_size = (outer_size * (border_type - 1)) + inner_size;

    values[0] = border_size;
    configure_window(window, XCB_CONFIG_WINDOW_BORDER_WIDTH, values);

    geometry = xcb_get_geometry_reply(xcb_connection, geometry_cookie, NULL);

    unsigned short height = (unsigned short)((border_size * 2) +
        geometry->height);
    unsigned short width = (unsigned short)((border_size * 2) +
        geometry->width);

    xcb_create_pixmap(xcb_connection, 32, pixmap, xcb_screen->root,
        width, height);
    xcb_create_gc(xcb_connection, graphics_context, pixmap, 0, NULL);

    values[0] = get_raw_color_value(secondary_color);
    xcb_change_gc(xcb_connection, graphics_context,
        XCB_GC_FOREGROUND, values);

    xcb_rectangle_t outer_border[4] = { { 0, 0, width, height } };
    xcb_poly_fill_rectangle(xcb_connection, pixmap, graphics_context,
        4, outer_border);

    values[0] = get_raw_color_value(primary_color);
    xcb_change_gc(xcb_connection, graphics_context,
        XCB_GC_FOREGROUND, values);

    if (border_type == 2)
        double_border_transient(pixmap, graphics_context,
            inner_size, outer_size, border_size, geometry);
    else {
        triple_border_transient(pixmap, graphics_context,
            inner_size, outer_size, border_size, geometry);
        values[0] = get_raw_color_value(secondary_color);
    }

    xcb_change_window_attributes(xcb_connection, window,
        XCB_CW_BACK_PIXEL, values);

    values[0] = pixmap;
    xcb_change_window_attributes(xcb_connection, window,
        XCB_CW_BORDER_PIXMAP, values);

    xcb_free_pixmap(xcb_connection, pixmap);
    xcb_free_gc(xcb_connection, graphics_context);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, %r13d
movq %r13, 0x38(%rsp)
movl %r8d, %ebx
movq %rcx, 0x30(%rsp)
movl %edx, %r12d
movl %esi, %ebp
movl %edi, %r14d
leaq 0x6e1f(%rip), %r15      # 0xc8f8
movq (%r15), %rdi
movl %r14d, %esi
callq 0x3400
movl %eax, 0x10(%rsp)
movq (%r15), %rdi
callq 0x3230
movl %eax, 0xc(%rsp)
movq (%r15), %rdi
callq 0x3230
movl %eax, 0x1c(%rsp)
leal -0x1(%r13), %r15d
movl %r12d, 0x8(%rsp)
imull %r12d, %r15d
movl %ebp, 0x4(%rsp)
addl %ebp, %r15d
movq %rsp, %rdx
movl %r15d, (%rdx)
movl %r14d, 0x24(%rsp)
movl %r14d, %edi
movl $0x10, %esi
callq 0x7690
leaq 0x6dc5(%rip), %r14      # 0xc8f8
movq (%r14), %rdi
movl 0x10(%rsp), %esi
xorl %edx, %edx
callq 0x32c0
movq %r15, 0x10(%rsp)
leal (%r15,%r15), %esi
movzwl 0x12(%rax), %edx
addw %si, %dx
movq %rax, 0x28(%rsp)
addw 0x10(%rax), %si
movq (%r14), %rdi
leaq 0x6d9c(%rip), %rcx      # 0xc900
movq (%rcx), %rcx
movl (%rcx), %ecx
movzwl %si, %ebp
movzwl %dx, %r9d
movl %r9d, 0x20(%rsp)
movl $0x20, %esi
movl 0xc(%rsp), %r15d
movl %r15d, %edx
movl %ebp, %r8d
callq 0x3480
movq (%r14), %rdi
movl 0x1c(%rsp), %r13d
movl %r13d, %esi
movl %r15d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x31e0
movl %ebx, %edx
shrl $0x8, %edx
movl %ebx, %eax
shrl $0x10, %eax
movl %ebx, %ecx
shrl $0x18, %ecx
movl $0xff000000, %r12d      # imm = 0xFF000000
movl %ebx, %esi
andl %r12d, %esi
movl $0xff, %r14d
andl %r14d, %ebx
imull %ecx, %ebx
imulq $0x1010102, %rbx, %rdi  # imm = 0x1010102
shrq $0x20, %rdi
shll $0x10, %edi
orl %esi, %edi
andl %r14d, %edx
imull %ecx, %edx
imulq $0x1010102, %rdx, %rdx  # imm = 0x1010102
shrq $0x20, %rdx
shll $0x8, %edx
andl %r14d, %eax
imull %ecx, %eax
imulq $0x1010102, %rax, %rbx  # imm = 0x1010102
shrq $0x20, %rbx
orl %edi, %ebx
orl %edx, %ebx
movq %rsp, %rcx
movl %ebx, (%rcx)
leaq 0x6ceb(%rip), %r15      # 0xc8f8
movq (%r15), %rdi
movl %r13d, %esi
movl $0x4, %edx
callq 0x33d0
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %r8
movaps %xmm0, (%r8)
movaps %xmm0, 0x10(%r8)
movw %bp, 0x4(%r8)
movl 0x20(%rsp), %eax
movw %ax, 0x6(%r8)
movq (%r15), %rdi
movl 0xc(%rsp), %esi
movl %esi, %ebp
movl %r13d, %edx
movl $0x4, %ecx
callq 0x32a0
movq 0x30(%rsp), %rsi
movl %esi, %edx
shrl $0x8, %edx
movl %esi, %eax
shrl $0x10, %eax
movl %esi, %ecx
shrl $0x18, %ecx
andl %esi, %r12d
andl %r14d, %esi
imull %ecx, %esi
imulq $0x1010102, %rsi, %rsi  # imm = 0x1010102
shrq $0x20, %rsi
shll $0x10, %esi
orl %r12d, %esi
andl %r14d, %edx
imull %ecx, %edx
imulq $0x1010102, %rdx, %rdx  # imm = 0x1010102
shrq $0x20, %rdx
shll $0x8, %edx
andl %r14d, %eax
imull %ecx, %eax
imulq $0x1010102, %rax, %rax  # imm = 0x1010102
shrq $0x20, %rax
orl %esi, %eax
orl %edx, %eax
movq %rsp, %rcx
movl %eax, (%rcx)
movq (%r15), %rdi
movl %r13d, %esi
movl $0x4, %edx
callq 0x33d0
cmpl $0x2, 0x38(%rsp)
jne 0x5ce6
movl %ebp, %r12d
movl %ebp, %edi
movl %r13d, %esi
movl 0x4(%rsp), %edx
movl 0x8(%rsp), %ecx
movq 0x10(%rsp), %r8
movq 0x28(%rsp), %r9
callq 0x5d5b
jmp 0x5d08
movl %ebp, %r12d
movl %ebp, %edi
movl %r13d, %esi
movl 0x4(%rsp), %edx
movl 0x8(%rsp), %ecx
movq 0x10(%rsp), %r8
movq 0x28(%rsp), %r9
callq 0x5e07
movl %ebx, (%rsp)
movq (%r15), %rdi
movq %rsp, %rbx
movl 0x24(%rsp), %ebp
movl %ebp, %esi
movl $0x2, %edx
movq %rbx, %rcx
callq 0x3170
movl %r12d, (%rbx)
movq (%r15), %rdi
movl %ebp, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x3170
movq (%r15), %rdi
movl %r12d, %esi
callq 0x3140
movq (%r15), %rdi
movl %r13d, %esi
callq 0x3220
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq