// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: write_styles_file
STATIC lxw_error
_write_styles_file(lxw_packager *self)
{
    lxw_styles *styles = lxw_styles_new();
    char *buffer = NULL;
    size_t buffer_size = 0;
    lxw_hash_element *hash_element;
    lxw_error err = LXW_NO_ERROR;

    if (!styles) {
        err = LXW_ERROR_MEMORY_MALLOC_FAILED;
        goto mem_error;
    }

    /* Copy the unique and in-use formats from the workbook to the styles
     * xf_format list. */
    LXW_FOREACH_ORDERED(hash_element, self->workbook->used_xf_formats) {
        lxw_format *workbook_format = (lxw_format *) hash_element->value;
        lxw_format *style_format = lxw_format_new();

        if (!style_format) {
            err = LXW_ERROR_MEMORY_MALLOC_FAILED;
            goto mem_error;
        }

        memcpy(style_format, workbook_format, sizeof(lxw_format));
        STAILQ_INSERT_TAIL(styles->xf_formats, style_format, list_pointers);
    }

    /* Copy the unique and in-use dxf formats from the workbook to the styles
     * dxf_format list. */
    LXW_FOREACH_ORDERED(hash_element, self->workbook->used_dxf_formats) {
        lxw_format *workbook_format = (lxw_format *) hash_element->value;
        lxw_format *style_format = lxw_format_new();

        if (!style_format) {
            err = LXW_ERROR_MEMORY_MALLOC_FAILED;
            goto mem_error;
        }

        memcpy(style_format, workbook_format, sizeof(lxw_format));
        STAILQ_INSERT_TAIL(styles->dxf_formats, style_format, list_pointers);
    }

    styles->font_count = self->workbook->font_count;
    styles->border_count = self->workbook->border_count;
    styles->fill_count = self->workbook->fill_count;
    styles->num_format_count = self->workbook->num_format_count;
    styles->xf_count = self->workbook->used_xf_formats->unique_count;
    styles->dxf_count = self->workbook->used_dxf_formats->unique_count;
    styles->has_comments = self->workbook->has_comments;

    styles->file = lxw_get_filehandle(&buffer, &buffer_size, self->tmpdir);
    if (!styles->file) {
        err = LXW_ERROR_CREATING_TMPFILE;
        goto mem_error;
    }

    lxw_styles_assemble_xml_file(styles);

    err = _add_to_zip(self, styles->file, &buffer, &buffer_size,
                      "xl/styles.xml");

    fclose(styles->file);
    free(buffer);

mem_error:
    lxw_styles_free(styles);

    return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
callq 0xc6f0
movq %rax, %rbx
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movl $0x1, %ebp
testq %rbx, %rbx
je 0x21890
movq 0x8(%r14), %rax
movq 0xd8(%rax), %rcx
movq 0x10(%rcx), %rcx
movq (%rcx), %r13
testq %r13, %r13
je 0x2177d
movq 0x8(%r13), %r12
callq 0xcd40
testq %rax, %rax
je 0x21890
movq %rax, %r15
movl $0x230, %edx            # imm = 0x230
movq %rax, %rdi
movq %r12, %rsi
callq 0xc900
movq %r15, %rax
addq $0x230, %rax            # imm = 0x230
movq $0x0, 0x230(%r15)
movq 0x20(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq %r15, (%rcx)
movq 0x20(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x10(%r13), %r13
testq %r13, %r13
jne 0x21724
movq 0x8(%r14), %rax
movq 0xe0(%rax), %rcx
movq 0x10(%rcx), %rdx
movq (%rdx), %r13
testq %r13, %r13
je 0x217f0
movq 0x8(%r13), %r12
callq 0xcd40
testq %rax, %rax
je 0x21890
movq %rax, %r15
movl $0x230, %edx            # imm = 0x230
movq %rax, %rdi
movq %r12, %rsi
callq 0xc900
movq %r15, %rax
addq $0x230, %rax            # imm = 0x230
movq $0x0, 0x230(%r15)
movq 0x28(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq %r15, (%rcx)
movq 0x28(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x10(%r13), %r13
testq %r13, %r13
jne 0x21790
movq 0x8(%r14), %rax
movq 0xe0(%rax), %rcx
movzwl 0xc4(%rax), %edx
movl %edx, 0x8(%rbx)
movd 0xc6(%rax), %xmm0
pxor %xmm1, %xmm1
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movq %xmm0, 0x18(%rbx)
movzwl 0xbe(%rax), %edx
movl %edx, 0x14(%rbx)
movq 0xd8(%rax), %rdx
movl 0x8(%rdx), %edx
movl %edx, 0xc(%rbx)
movl 0x8(%rcx), %ecx
movl %ecx, 0x10(%rbx)
movb 0xd4(%rax), %al
movb %al, 0x34(%rbx)
movq 0x70(%r14), %rdx
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xce00
movq %rax, (%rbx)
testq %rax, %rax
je 0x2188b
movq %rbx, %rdi
callq 0xca30
movq (%rbx), %rsi
leaq 0x20732(%rip), %r8      # 0x41f94
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x224f6
movl %eax, %ebp
movq (%rbx), %rdi
callq 0xc420
movq (%r15), %rdi
callq 0xc0c0
jmp 0x21890
movl $0x3, %ebp
movq %rbx, %rdi
callq 0xc5a0
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq