// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: add_file_to_zip
STATIC lxw_error
_add_file_to_zip(lxw_packager *self, FILE * file, const char *filename)
{
    int16_t error = ZIP_OK;
    size_t size_read;

    error = zipOpenNewFileInZip4_64(self->zipfile,
                                    filename,
                                    &self->zipfile_info,
                                    NULL, 0, NULL, 0, NULL,
                                    Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0,
                                    -MAX_WBITS, DEF_MEM_LEVEL,
                                    Z_DEFAULT_STRATEGY, NULL, 0, 0, 0,
                                    self->use_zip64);

    if (error != ZIP_OK) {
        LXW_ERROR("Error adding member to zipfile");
        RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
    }

    fflush(file);
    rewind(file);

    size_read = fread((void *) self->buffer, 1, self->buffer_size, file);

    while (size_read) {

        if (size_read < self->buffer_size) {
            if (ferror(file)) {
                LXW_ERROR("Error reading member file data");
                RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
            }
        }

        error = zipWriteInFileInZip(self->zipfile,
                                    self->buffer, (unsigned int) size_read);

        if (error < 0) {
            LXW_ERROR("Error in writing member in the zipfile");
            RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
        }

        size_read =
            fread((void *) (void *) self->buffer, 1, self->buffer_size, file);
    }

    error = zipCloseFileInZip(self->zipfile);
    if (error != ZIP_OK) {
        LXW_ERROR("Error in closing member in the zipfile");
        RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
    }

    return LXW_NO_ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
leaq 0x28(%rbx), %rax
movzbl 0x78(%rbx), %ecx
movl %ecx, 0x60(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rsp)
movups %xmm0, 0x40(%rsp)
xorl %ecx, %ecx
movl %ecx, 0x38(%rsp)
movl $0x8, %esi
movl %esi, 0x30(%rsp)
movl %ecx, 0x20(%rsp)
movl %esi, 0x10(%rsp)
movl %ecx, (%rsp)
movl $0xfffffff1, 0x28(%rsp) # imm = 0xFFFFFFF1
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rsp)
movq %rdx, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xc730
movl %eax, %r15d
shll $0x10, %r15d
jne 0x22805
movl %eax, %ebp
movq %r14, %rdi
callq 0xca60
movq %r14, %rdi
callq 0xc500
movq 0x10(%rbx), %rdx
movq 0x60(%rbx), %rdi
movl $0x1, %esi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x227e8
movq %rax, %r15
cmpq 0x10(%rbx), %r15
jae 0x227ac
movq %r14, %rdi
callq 0xc2b0
testl %eax, %eax
jne 0x228e0
movq 0x20(%rbx), %rdi
movq 0x60(%rbx), %rsi
movl %r15d, %edx
callq 0xc100
movl %eax, %r15d
shll $0x10, %r15d
js 0x22869
movl %eax, %ebp
movq 0x10(%rbx), %rdx
movq 0x60(%rbx), %rdi
movl $0x1, %esi
movq %r14, %rcx
callq 0xc2f0
movq %rax, %r15
testq %rax, %rax
jne 0x22796
movq 0x20(%rbx), %rdi
callq 0xc1f0
movl %eax, %ebx
xorl %eax, %eax
shll $0x10, %ebx
jne 0x22824
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x347ec(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x20625(%rip), %rsi     # 0x42e3b
leaq 0x20443(%rip), %rdx     # 0x42c60
movl $0x6fc, %ecx            # imm = 0x6FC
jmp 0x22886
movq 0x347cd(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x2066e(%rip), %rsi     # 0x42ea3
leaq 0x20424(%rip), %rdx     # 0x42c60
movl $0x71c, %ecx            # imm = 0x71C
xorl %eax, %eax
callq 0xc870
cmpl $0xff99ffff, %ebx       # imm = 0xFF99FFFF
jg 0x228ce
cmpl $0xff980000, %ebx       # imm = 0xFF980000
je 0x2291e
cmpl $0xff990000, %ebx       # imm = 0xFF990000
je 0x228ac
jmp 0x22940
movq 0x34788(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x205f1(%rip), %rsi     # 0x42e6b
leaq 0x203df(%rip), %rdx     # 0x42c60
movl $0x712, %ecx            # imm = 0x712
xorl %eax, %eax
callq 0xc870
cmpl $0xff99ffff, %r15d      # imm = 0xFF99FFFF
jg 0x228b6
cmpl $0xff980000, %r15d      # imm = 0xFF980000
je 0x2291e
cmpl $0xff990000, %r15d      # imm = 0xFF990000
jne 0x22940
movl $0x7, %eax
jmp 0x227fa
cmpl $0xffff0000, %r15d      # imm = 0xFFFF0000
je 0x2294a
cmpl $0xff9a0000, %r15d      # imm = 0xFF9A0000
je 0x22936
jmp 0x22940
cmpl $0xffff0000, %ebx       # imm = 0xFFFF0000
je 0x2294a
cmpl $0xff9a0000, %ebx       # imm = 0xFF9A0000
je 0x22936
jmp 0x22940
movq 0x34711(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x205ea(%rip), %rsi     # 0x42edb
leaq 0x20368(%rip), %rdx     # 0x42c60
movl $0x709, %ecx            # imm = 0x709
xorl %eax, %eax
callq 0xc870
movzwl %bp, %eax
cmpl $0xff99, %eax           # imm = 0xFF99
jg 0x22928
cmpl $0xff98, %eax           # imm = 0xFF98
je 0x2291e
cmpl $0xff99, %eax           # imm = 0xFF99
je 0x228ac
jmp 0x22940
movl $0x8, %eax
jmp 0x227fa
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x2294a
cmpl $0xff9a, %eax           # imm = 0xFF9A
jne 0x22940
movl $0x6, %eax
jmp 0x227fa
movl $0x9, %eax
jmp 0x227fa
movl $0x5, %eax
jmp 0x227fa