// File: /workspace/github_c_makefile_star2_O1/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 %r15d, %r15d
movq %r15, 0x10(%rsp)
movq %r15, 0x8(%rsp)
testq %rax, %rax
je 0x2176d
movq 0x8(%r14), %rax
movq 0xd8(%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rbp
testq %rbp, %rbp
je 0x216f7
xorl %r15d, %r15d
movq 0x8(%rbp), %r13
callq 0xcd40
movq %rax, %r12
testq %rax, %rax
je 0x216df
movl $0x238, %edx            # imm = 0x238
movq %r12, %rdi
movq %r13, %rsi
callq 0xc900
leaq 0x230(%r12), %rax
movq $0x0, 0x230(%r12)
movq 0x20(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq %r12, (%rcx)
movq 0x20(%rbx), %rcx
movq %rax, 0x8(%rcx)
jmp 0x216e5
movl $0x1, %r15d
testq %r12, %r12
je 0x21825
movq 0x10(%rbp), %rbp
testq %rbp, %rbp
jne 0x21695
movq 0x8(%r14), %rax
movq 0xe0(%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rbp
testq %rbp, %rbp
je 0x21778
movq 0x8(%rbp), %r13
callq 0xcd40
movq %rax, %r12
testq %rax, %rax
je 0x21758
movl $0x238, %edx            # imm = 0x238
movq %r12, %rdi
movq %r13, %rsi
callq 0xc900
leaq 0x230(%r12), %rax
movq $0x0, 0x230(%r12)
movq 0x28(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq %r12, (%rcx)
movq 0x28(%rbx), %rcx
movq %rax, 0x8(%rcx)
jmp 0x2175e
movl $0x1, %r15d
testq %r12, %r12
je 0x21825
movq 0x10(%rbp), %rbp
jmp 0x21709
movl $0x1, %r15d
jmp 0x21825
movq 0x8(%r14), %rax
movzwl 0xc4(%rax), %ecx
movl %ecx, 0x8(%rbx)
movzwl 0xc6(%rax), %ecx
movl %ecx, 0x18(%rbx)
movzwl 0xc8(%rax), %ecx
movl %ecx, 0x1c(%rbx)
movzwl 0xbe(%rax), %ecx
movl %ecx, 0x14(%rbx)
movq 0xd8(%rax), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, 0xc(%rbx)
movq 0xe0(%rax), %rcx
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 0x2181f
movq %rbx, %rdi
callq 0xca30
movq (%rbx), %rsi
leaq 0x20790(%rip), %r8      # 0x41f84
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rdx
callq 0x22482
movl %eax, %r15d
movq (%rbx), %rdi
callq 0xc420
movq (%r12), %rdi
callq 0xc0c0
jmp 0x21825
movl $0x3, %r15d
movq %rbx, %rdi
callq 0xc5a0
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq