// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
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)
andl $0x0, 0x38(%rsp)
andl $0x0, 0x20(%rsp)
orl $-0x1, 0x18(%rsp)
pushq $0x8
popq %r13
andq $0x0, 0x8(%rsp)
movl %r13d, 0x30(%rsp)
andl $0x0, (%rsp)
movl %r13d, 0x10(%rsp)
movl $0xfffffff1, 0x28(%rsp) # imm = 0xFFFFFFF1
movq %rdx, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xc790
movl %eax, %r15d
shll $0x10, %r15d
jne 0x1f603
movl %eax, %ebp
movq %r14, %rdi
callq 0xcac0
movq %r14, %rdi
callq 0xc540
pushq $0x1
popq %r15
movq 0x10(%rbx), %rdx
movq 0x60(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x1f5e2
movq %rax, %r12
cmpq 0x10(%rbx), %rax
jae 0x1f56c
movq %r14, %rdi
callq 0xc2d0
testl %eax, %eax
jne 0x1f6a7
movq 0x20(%rbx), %rdi
movq 0x60(%rbx), %rsi
movl %r12d, %edx
callq 0xc110
movl %eax, %ebp
movl %eax, %r12d
shll $0x10, %r12d
jns 0x1f537
movq 0x33a6a(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x208d3(%rip), %rsi     # 0x3fe6b
leaq 0x206c1(%rip), %rdx     # 0x3fc60
movl $0x712, %ecx            # imm = 0x712
xorl %eax, %eax
callq 0xc8d0
cmpl $0xff980000, %r12d      # imm = 0xFF980000
je 0x1f6fe
cmpl $0xff990000, %r12d      # imm = 0xFF990000
je 0x1f6f2
cmpl $0xffff0000, %r12d      # imm = 0xFFFF0000
je 0x1f6f6
cmpl $0xff9a0000, %r12d      # imm = 0xFF9A0000
je 0x1f657
pushq $0x9
jmp 0x1f6f8
movq 0x20(%rbx), %rdi
callq 0xc210
movl %eax, %ebx
xorl %eax, %eax
shll $0x10, %ebx
jne 0x1f65e
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x339ee(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x20827(%rip), %rsi     # 0x3fe3b
leaq 0x20645(%rip), %rdx     # 0x3fc60
movl $0x6fc, %ecx            # imm = 0x6FC
xorl %eax, %eax
callq 0xc8d0
cmpl $0xff980000, %r15d      # imm = 0xFF980000
je 0x1f6fe
cmpl $0xff990000, %r15d      # imm = 0xFF990000
je 0x1f6f2
cmpl $0xffff0000, %r15d      # imm = 0xFFFF0000
je 0x1f6f6
cmpl $0xff9a0000, %r15d      # imm = 0xFF9A0000
jne 0x1f5db
pushq $0x6
jmp 0x1f6f8
movq 0x33993(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x20834(%rip), %rsi     # 0x3fea3
leaq 0x205ea(%rip), %rdx     # 0x3fc60
movl $0x71c, %ecx            # imm = 0x71C
xorl %eax, %eax
callq 0xc8d0
cmpl $0xff980000, %ebx       # imm = 0xFF980000
je 0x1f6fe
cmpl $0xff990000, %ebx       # imm = 0xFF990000
je 0x1f6f2
cmpl $0xffff0000, %ebx       # imm = 0xFFFF0000
je 0x1f6f6
cmpl $0xff9a0000, %ebx       # imm = 0xFF9A0000
je 0x1f657
jmp 0x1f5db
movq 0x3394a(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x20823(%rip), %rsi     # 0x3fedb
leaq 0x205a1(%rip), %rdx     # 0x3fc60
movl $0x709, %ecx            # imm = 0x709
xorl %eax, %eax
callq 0xc8d0
cmpw $-0x68, %bp
je 0x1f6fe
movzwl %bp, %eax
cmpl $0xff99, %eax           # imm = 0xFF99
je 0x1f6f2
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1f6f6
cmpl $0xff9a, %eax           # imm = 0xFF9A
je 0x1f657
jmp 0x1f5db
pushq $0x7
jmp 0x1f6f8
pushq $0x5
popq %rax
jmp 0x1f5f4
movl %r13d, %eax
jmp 0x1f5f4
nop