// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: write_app_file
STATIC lxw_error
_write_app_file(lxw_packager *self)
{
    lxw_workbook *workbook = self->workbook;
    lxw_sheet *sheet;
    lxw_worksheet *worksheet;
    lxw_chartsheet *chartsheet;
    lxw_defined_name *defined_name;
    lxw_app *app;
    char *buffer = NULL;
    size_t buffer_size = 0;
    uint32_t named_range_count = 0;
    char *autofilter;
    char *has_range;
    char number[LXW_ATTR_32] = { 0 };
    lxw_error err = LXW_NO_ERROR;

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

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

    if (self->workbook->num_worksheets) {
        lxw_snprintf(number, LXW_ATTR_32, "%d",
                     self->workbook->num_worksheets);
        lxw_app_add_heading_pair(app, "Worksheets", number);
    }

    if (self->workbook->num_chartsheets) {
        lxw_snprintf(number, LXW_ATTR_32, "%d",
                     self->workbook->num_chartsheets);
        lxw_app_add_heading_pair(app, "Charts", number);
    }

    STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
        if (!sheet->is_chartsheet) {
            worksheet = sheet->u.worksheet;
            lxw_app_add_part_name(app, worksheet->name);
        }
    }

    STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
        if (sheet->is_chartsheet) {
            chartsheet = sheet->u.chartsheet;
            lxw_app_add_part_name(app, chartsheet->name);
        }
    }

    /* Add the Named Ranges parts. */
    TAILQ_FOREACH(defined_name, workbook->defined_names, list_pointers) {

        has_range = strchr(defined_name->formula, '!');
        autofilter = strstr(defined_name->app_name, "_FilterDatabase");

        /* Only store defined names with ranges (except for autofilters). */
        if (has_range && !autofilter) {
            lxw_app_add_part_name(app, defined_name->app_name);
            named_range_count++;
        }
    }

    /* Add the Named Range heading pairs. */
    if (named_range_count) {
        lxw_snprintf(number, LXW_ATTR_32, "%d", named_range_count);
        lxw_app_add_heading_pair(app, "Named Ranges", number);
    }

    /* Set the app/doc properties. */
    app->properties = workbook->properties;

    app->doc_security = workbook->read_only;

    lxw_app_assemble_xml_file(app);

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

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

mem_error:
    lxw_app_free(app);

    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0xc6a0
movl $0x0, -0x84(%rbp)
callq 0xcba0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x2faab
movl $0x1, -0x84(%rbp)
jmp 0x2fd36
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rdx
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xceb0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x2fae3
movl $0x3, -0x84(%rbp)
jmp 0x2fd36
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpw $0x0, 0xb2(%rax)
je 0x2fb2f
leaq -0x80(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movzwl 0xb2(%rax), %ecx
movl $0x20, %esi
leaq 0x3b768(%rip), %rdx     # 0x6b27c
movb $0x0, %al
callq 0xc5d0
movq -0x38(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x394e4(%rip), %rsi     # 0x6900e
callq 0xc1f0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpw $0x0, 0xb4(%rax)
je 0x2fb7b
leaq -0x80(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movzwl 0xb4(%rax), %ecx
movl $0x20, %esi
leaq 0x3b71c(%rip), %rdx     # 0x6b27c
movb $0x0, %al
callq 0xc5d0
movq -0x38(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x394a3(%rip), %rsi     # 0x69019
callq 0xc1f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2fbca
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x2fbba
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0xb8(%rax), %rsi
callq 0xd040
jmp 0x2fbbc
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x2fb8a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2fc16
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
je 0x2fc06
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0xd040
jmp 0x2fc08
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x2fbd9
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x2fc9e
movq -0x30(%rbp), %rdi
addq $0x103, %rdi            # imm = 0x103
movl $0x21, %esi
callq 0xc520
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rdi
addq $0x83, %rdi
leaq 0x3c578(%rip), %rsi     # 0x6c1cf
callq 0xd130
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x2fc8b
cmpq $0x0, -0x58(%rbp)
jne 0x2fc8b
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x83, %rsi
callq 0xd040
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2fc8d
movq -0x30(%rbp), %rax
movq 0x288(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x2fc25
cmpl $0x0, -0x4c(%rbp)
je 0x2fcd2
leaq -0x80(%rbp), %rdi
movl -0x4c(%rbp), %ecx
movl $0x20, %esi
leaq 0x3b5c5(%rip), %rdx     # 0x6b27c
movb $0x0, %al
callq 0xc5d0
movq -0x38(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x39353(%rip), %rsi     # 0x69020
callq 0xc1f0
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movb 0xce(%rax), %cl
movq -0x38(%rbp), %rax
movb %cl, 0x28(%rax)
movq -0x38(%rbp), %rdi
callq 0xc310
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
leaq -0x40(%rbp), %rdx
leaq -0x48(%rbp), %rcx
leaq 0x38028(%rip), %r8      # 0x67d3e
callq 0x2fd50
movl %eax, -0x84(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0xc460
movq -0x40(%rbp), %rdi
callq 0xc0d0
movq -0x38(%rbp), %rdi
callq 0xcd30
movl -0x84(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop