// File: /workspace/github_c_makefile_star2_O1/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: write_image_files
STATIC lxw_error
_write_image_files(lxw_packager *self)
{
    lxw_workbook *workbook = self->workbook;
    lxw_sheet *sheet;
    lxw_worksheet *worksheet;
    lxw_object_properties *object_props;
    lxw_error err;
    FILE *image_stream;

    char filename[LXW_FILENAME_LENGTH] = { 0 };
    uint32_t index = 1;

    STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
        if (sheet->is_chartsheet)
            continue;
        else
            worksheet = sheet->u.worksheet;

        if (STAILQ_EMPTY(worksheet->image_props))
            continue;

        STAILQ_FOREACH(object_props, worksheet->image_props, list_pointers) {

            if (object_props->is_duplicate)
                continue;

            lxw_snprintf(filename, LXW_FILENAME_LENGTH,
                         "xl/media/image%d.%s", index++,
                         object_props->extension);

            if (!object_props->is_image_buffer) {
                /* Check that the image file exists and can be opened. */
                image_stream = lxw_fopen(object_props->filename, "rb");
                if (!image_stream) {
                    LXW_WARN_FORMAT1("Error adding image to xlsx file: file "
                                     "doesn't exist or can't be opened: %s.",
                                     object_props->filename);
                    return LXW_ERROR_CREATING_TMPFILE;
                }

                err = _add_file_to_zip(self, image_stream, filename);
                fclose(image_stream);
            }
            else {
                err = _add_buffer_to_zip(self,
                                         object_props->image_buffer,
                                         object_props->image_buffer_size,
                                         filename);
            }

            RETURN_ON_ERROR(err);
        }
    }

    return LXW_NO_ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, (%rsp)
movq 0x8(%rdi), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq 0x8(%rax), %rax
movq (%rax), %rbx
testq %rbx, %rbx
je 0x21f25
movl $0x1, %ebp
leaq 0x2120c(%rip), %r14     # 0x4305f
leaq 0x10(%rsp), %r15
cmpb $0x0, (%rbx)
jne 0x21f18
movq 0x8(%rbx), %rax
movq 0x60(%rax), %rax
movq (%rax), %r13
testq %r13, %r13
je 0x21f18
movq %rbx, 0x8(%rsp)
cmpb $0x0, 0x98(%r13)
jne 0x21f08
movq 0x78(%r13), %r8
movl $0x80, %esi
movq %r15, %rdi
movq %r14, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xc570
cmpb $0x0, 0x51(%r13)
je 0x21ec0
movq 0x58(%r13), %rsi
movq 0x60(%r13), %rdx
movq (%rsp), %rdi
movq %r15, %rcx
callq 0x224d6
movl %eax, %r12d
jmp 0x21f01
movl %ebp, %ebx
movq %r14, %rbp
movq 0x20(%r13), %rdi
leaq 0x1e130(%rip), %rsi     # 0x40000
callq 0xc250
testq %rax, %rax
je 0x21f3d
movq %rax, %r14
movq (%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x22673
movl %eax, %r12d
movq %r14, %rdi
callq 0xc420
movq %rbp, %r14
movl %ebx, %ebp
movq 0x8(%rsp), %rbx
testl %r12d, %r12d
jne 0x21f28
incl %ebp
movq 0xb8(%r13), %r13
testq %r13, %r13
jne 0x21e7a
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0x21e58
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0xdc97
movl $0x3, %r12d
jmp 0x21f28