// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movl %r9d, %r12d
movq %r12, 0x28(%rsp)
movl %r8d, 0xc(%rsp)
movl %ecx, 0x20(%rsp)
movl %edx, %ebx
movl %esi, %ebp
movl %edi, %r13d
leaq 0x7010(%rip), %r15      # 0xc8e8
movq (%r15), %rdi
movl %r13d, %esi
callq 0x33f0
movl %eax, 0x18(%rsp)
movq (%r15), %rdi
callq 0x3230
movl %eax, %r14d
movq (%r15), %rdi
callq 0x3230
leal -0x1(%r12), %r15d
movl %ebx, 0x14(%rsp)
imull %ebx, %r15d
movl %ebp, 0x10(%rsp)
addl %ebp, %r15d
movl %r14d, %ebp
movl %eax, %r14d
leaq 0x8(%rsp), %rdx
movl %r15d, (%rdx)
pushq $0x10
popq %rsi
movl %r13d, 0x24(%rsp)
movl %r13d, %edi
callq 0x7204
leaq 0x6fb5(%rip), %r12      # 0xc8e8
movq (%r12), %rdi
movl 0x18(%rsp), %esi
xorl %edx, %edx
callq 0x32c0
leal (%r15,%r15), %esi
movzwl 0x12(%rax), %edx
addw %si, %dx
movq %rax, 0x18(%rsp)
addw 0x10(%rax), %si
movq (%r12), %rdi
leaq 0x6f8f(%rip), %rcx      # 0xc8f0
movq (%rcx), %rcx
movl (%rcx), %ecx
movzwl %si, %ebx
movzwl %dx, %r13d
pushq $0x20
popq %rsi
movl %ebp, %edx
movl %ebx, %r8d
movl %r13d, %r9d
callq 0x3470
movq (%r12), %rdi
movl %r14d, %esi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x31e0
movl 0xc(%rsp), %edi
callq 0x56bf
leaq 0x8(%rsp), %rcx
movl %eax, 0xc(%rsp)
movl %eax, (%rcx)
movq (%r12), %rdi
pushq $0x4
popq %r12
movl %r14d, %esi
movl %r12d, %edx
callq 0x33d0
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %r8
movaps %xmm0, (%r8)
movaps %xmm0, 0x10(%r8)
movw %bx, 0x4(%r8)
movw %r13w, 0x6(%r8)
leaq 0x6f0f(%rip), %r13      # 0xc8e8
movq (%r13), %rdi
movl %ebp, %esi
movl %r14d, %edx
movl %r12d, %ecx
callq 0x32a0
movl 0x20(%rsp), %edi
callq 0x56bf
leaq 0x8(%rsp), %rcx
movl %eax, (%rcx)
movq (%r13), %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x33d0
cmpl $0x2, 0x28(%rsp)
jne 0x5a2c
movl %ebp, %edi
movl %r14d, %esi
movl 0x10(%rsp), %edx
movl 0x14(%rsp), %ecx
movl %r15d, %r8d
movq 0x18(%rsp), %r9
callq 0x5aa4
jmp 0x5a4e
movl %ebp, %edi
movl %r14d, %esi
movl 0x10(%rsp), %edx
movl 0x14(%rsp), %ecx
movl %r15d, %r8d
movq 0x18(%rsp), %r9
callq 0x5b4e
movl 0xc(%rsp), %eax
movl %eax, 0x8(%rsp)
movq (%r13), %rdi
pushq $0x2
popq %rdx
leaq 0x8(%rsp), %rbx
movl 0x24(%rsp), %r15d
movl %r15d, %esi
movq %rbx, %rcx
callq 0x3170
movl %ebp, (%rbx)
movq (%r13), %rdi
pushq $0x4
popq %rdx
movl %r15d, %esi
movq %rbx, %rcx
callq 0x3170
movq (%r13), %rdi
movl %ebp, %esi
callq 0x3140
movq (%r13), %rdi
movl %r14d, %esi
callq 0x3220
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq