// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0xc6a0
movl $0x1, -0xc4(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2f5c3
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x2f470
jmp 0x2f5b2
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x60(%rax), %rax
cmpq $0x0, (%rax)
jne 0x2f48f
jmp 0x2f5b2
movq -0x28(%rbp), %rax
movq 0x60(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x2f5b0
movq -0x30(%rbp), %rax
cmpb $0x0, 0x98(%rax)
je 0x2f4bb
jmp 0x2f59c
leaq -0xc0(%rbp), %rdi
movl -0xc4(%rbp), %ecx
movl %ecx, %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
movq -0x30(%rbp), %rax
movq 0x78(%rax), %r8
movl $0x80, %esi
leaq 0x399ac(%rip), %rdx     # 0x68e93
movb $0x0, %al
callq 0xc5d0
movq -0x30(%rbp), %rax
cmpb $0x0, 0x51(%rax)
jne 0x2f565
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x36af9(%rip), %rsi     # 0x66000
callq 0xc280
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x2f543
movq 0x4dada(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0x39977(%rip), %rsi     # 0x68ea7
movb $0x0, %al
callq 0xc8f0
movl $0x3, -0x4(%rbp)
jmp 0x2f5ca
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0x30060
movl %eax, -0x34(%rbp)
movq -0x40(%rbp), %rdi
callq 0xc460
jmp 0x2f588
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rdx
leaq -0xc0(%rbp), %rcx
callq 0x2fdc0
movl %eax, -0x34(%rbp)
jmp 0x2f58a
cmpl $0x0, -0x34(%rbp)
je 0x2f598
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2f5ca
jmp 0x2f59a
jmp 0x2f59c
movq -0x30(%rbp), %rax
movq 0xb8(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x2f49e
jmp 0x2f5b2
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x2f457
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)