// File: /workspace/github_c_makefile_star2_O1/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 0x22791
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 0x22774
movq %rax, %r15
cmpq 0x10(%rbx), %r15
jae 0x22738
movq %r14, %rdi
callq 0xc2b0
testl %eax, %eax
jne 0x2286c
movq 0x20(%rbx), %rdi
movq 0x60(%rbx), %rsi
movl %r15d, %edx
callq 0xc100
movl %eax, %r15d
shll $0x10, %r15d
js 0x227f5
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 0x22722
movq 0x20(%rbx), %rdi
callq 0xc1f0
movl %eax, %ebx
xorl %eax, %eax
shll $0x10, %ebx
jne 0x227b0
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x33860(%rip), %rax     # 0x55ff8
movq (%rax), %rdi
leaq 0x20689(%rip), %rsi     # 0x42e2b
leaq 0x204a7(%rip), %rdx     # 0x42c50
movl $0x6fc, %ecx            # imm = 0x6FC
jmp 0x22812
movq 0x33841(%rip), %rax     # 0x55ff8
movq (%rax), %rdi
leaq 0x206d2(%rip), %rsi     # 0x42e93
leaq 0x20488(%rip), %rdx     # 0x42c50
movl $0x71c, %ecx            # imm = 0x71C
xorl %eax, %eax
callq 0xc870
cmpl $0xff99ffff, %ebx       # imm = 0xFF99FFFF
jg 0x2285a
cmpl $0xff980000, %ebx       # imm = 0xFF980000
je 0x228aa
cmpl $0xff990000, %ebx       # imm = 0xFF990000
je 0x22838
jmp 0x228cc
movq 0x337fc(%rip), %rax     # 0x55ff8
movq (%rax), %rdi
leaq 0x20655(%rip), %rsi     # 0x42e5b
leaq 0x20443(%rip), %rdx     # 0x42c50
movl $0x712, %ecx            # imm = 0x712
xorl %eax, %eax
callq 0xc870
cmpl $0xff99ffff, %r15d      # imm = 0xFF99FFFF
jg 0x22842
cmpl $0xff980000, %r15d      # imm = 0xFF980000
je 0x228aa
cmpl $0xff990000, %r15d      # imm = 0xFF990000
jne 0x228cc
movl $0x7, %eax
jmp 0x22786
cmpl $0xffff0000, %r15d      # imm = 0xFFFF0000
je 0x228d6
cmpl $0xff9a0000, %r15d      # imm = 0xFF9A0000
je 0x228c2
jmp 0x228cc
cmpl $0xffff0000, %ebx       # imm = 0xFFFF0000
je 0x228d6
cmpl $0xff9a0000, %ebx       # imm = 0xFF9A0000
je 0x228c2
jmp 0x228cc
movq 0x33785(%rip), %rax     # 0x55ff8
movq (%rax), %rdi
leaq 0x2064e(%rip), %rsi     # 0x42ecb
leaq 0x203cc(%rip), %rdx     # 0x42c50
movl $0x709, %ecx            # imm = 0x709
xorl %eax, %eax
callq 0xc870
movzwl %bp, %eax
cmpl $0xff99, %eax           # imm = 0xFF99
jg 0x228b4
cmpl $0xff98, %eax           # imm = 0xFF98
je 0x228aa
cmpl $0xff99, %eax           # imm = 0xFF99
je 0x22838
jmp 0x228cc
movl $0x8, %eax
jmp 0x22786
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x228d6
cmpl $0xff9a, %eax           # imm = 0xFF9A
jne 0x228cc
movl $0x6, %eax
jmp 0x22786
movl $0x9, %eax
jmp 0x22786
movl $0x5, %eax
jmp 0x22786