// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
callq 0xc770
movq %rax, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x2e9df
movl $0x1, -0x2c(%rbp)
jmp 0x2ec46
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xd8(%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2ea8a
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
callq 0xcdf0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x2ea2c
movl $0x1, -0x2c(%rbp)
jmp 0x2ec46
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0x238, %edx            # imm = 0x238
callq 0xc980
movq -0x40(%rbp), %rax
movq $0x0, 0x230(%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
addq $0x230, %rcx            # imm = 0x230
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x2ea79
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x2e9f9
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xe0(%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2eb35
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
callq 0xcdf0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x2ead7
movl $0x1, -0x2c(%rbp)
jmp 0x2ec46
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl $0x238, %edx            # imm = 0x238
callq 0xc980
movq -0x50(%rbp), %rax
movq $0x0, 0x230(%rax)
movq -0x50(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
addq $0x230, %rcx            # imm = 0x230
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x2eb24
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x2eaa4
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movzwl 0xc4(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movzwl 0xc6(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movzwl 0xc8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movzwl 0xbe(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xd8(%rax), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xe0(%rax), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movb 0xd4(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x34(%rax)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rdx
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xceb0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x2ec06
movl $0x3, -0x2c(%rbp)
jmp 0x2ec46
movq -0x10(%rbp), %rdi
callq 0xcad0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq -0x18(%rbp), %rdx
leaq -0x20(%rbp), %rcx
leaq 0x391bb(%rip), %r8      # 0x67de4
callq 0x2fd50
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xc460
movq -0x18(%rbp), %rdi
callq 0xc0d0
movq -0x10(%rbp), %rdi
callq 0xc600
movl -0x2c(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)