// File: /workspace/github_c_makefile_star2_O1/Paxa[P]fast_excel/libxlsxwriter/third_party/minizip/zip.c
// Function: zipClose
extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
    zip64_internal* zi;
    int err = 0;
    uLong size_centraldir = 0;
    ZPOS64_T centraldir_pos_inzip;
    ZPOS64_T pos;

    if (file == NULL)
        return ZIP_PARAMERROR;

    zi = (zip64_internal*)file;

    if (zi->in_opened_file_inzip == 1)
    {
        err = zipCloseFileInZip (file);
    }

#ifndef NO_ADDFILEINEXISTINGZIP
    if (global_comment==NULL)
        global_comment = zi->globalcomment;
#endif

    centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);

    if (err==ZIP_OK)
    {
        linkedlist_datablock_internal* ldi = zi->central_dir.first_block;
        while (ldi!=NULL)
        {
            if ((err==ZIP_OK) && (ldi->filled_in_this_block>0))
            {
                if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->filled_in_this_block) != ldi->filled_in_this_block)
                    err = ZIP_ERRNO;
            }

            size_centraldir += ldi->filled_in_this_block;
            ldi = ldi->next_datablock;
        }
    }
    free_linkedlist(&(zi->central_dir));

    pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
    if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
    {
      ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
      Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);

      Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos);
    }

    if (err==ZIP_OK)
      err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);

    if(err == ZIP_OK)
      err = Write_GlobalComment(zi, global_comment);

    if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0)
        if (err == ZIP_OK)
            err = ZIP_ERRNO;

#ifndef NO_ADDFILEINEXISTINGZIP
    free(zi->globalcomment);
#endif
    free(zi);

    return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x12283
movq %rsi, %r14
movq %rdi, %rbx
xorl %r12d, %r12d
cmpl $0x1, 0x70(%rdi)
jne 0x11e08
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc410
movl %eax, %r12d
testq %r14, %r14
jne 0x11e14
movq 0x10170(%rbx), %r14
movq %r14, 0x10(%rsp)
movq 0x58(%rbx), %rsi
movq %rbx, %rdi
callq 0xceb0
movq %rax, %r15
xorl %ebp, %ebp
testl %r12d, %r12d
jne 0x11e7f
movq 0x60(%rbx), %r14
xorl %r12d, %r12d
testq %r14, %r14
je 0x11e7f
xorl %ebp, %ebp
testl %r12d, %r12d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jne 0x11e73
movq 0x10(%r14), %rcx
testq %rcx, %rcx
je 0x11e70
movq 0x38(%rbx), %rdi
movq 0x58(%rbx), %rsi
leaq 0x20(%r14), %rdx
callq *0x10(%rbx)
xorl %r12d, %r12d
cmpq 0x10(%r14), %rax
setne %r12b
negl %r12d
jmp 0x11e73
xorl %r12d, %r12d
addq 0x10(%r14), %rbp
movq (%r14), %r14
testq %r14, %r14
jne 0x11e3d
leaq 0x60(%rbx), %r13
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x11e9c
movq (%rdi), %r14
callq 0xc0c0
movq %r14, %rdi
testq %r14, %r14
jne 0x11e8c
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movq %r15, %rax
subq 0x10160(%rbx), %rax
cmpq %r14, %rax
ja 0x11eca
cmpq $0x10000, 0x10168(%rbx) # imm = 0x10000
jb 0x121d5
movq 0x58(%rbx), %rsi
movq %rbx, %rdi
callq 0xceb0
movq %rax, %r13
movq 0x58(%rbx), %rsi
movl $0x6064b50, %eax        # imm = 0x6064B50
xorl %ecx, %ecx
movb %al, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x4, %rcx
jne 0x11ee4
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x4, %ecx
callq *0x10(%rbx)
cmpq $0x4, %rax
setne %al
jne 0x11f38
movq 0x58(%rbx), %rsi
movb $0x2c, %cl
xorl %eax, %eax
movb %cl, (%rsp,%rax)
incq %rax
xorl %ecx, %ecx
cmpq $0x8, %rax
jne 0x11f14
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x8, %ecx
callq *0x10(%rbx)
cmpq $0x8, %rax
setne %al
testb %al, %al
jne 0x11f68
movq 0x58(%rbx), %rsi
movb $0x2d, %cl
xorl %eax, %eax
movb %cl, (%rsp,%rax)
incq %rax
xorl %ecx, %ecx
cmpq $0x2, %rax
jne 0x11f44
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x2, %ecx
callq *0x10(%rbx)
cmpq $0x2, %rax
setne %al
testb %al, %al
jne 0x11f98
movq 0x58(%rbx), %rsi
movb $0x2d, %cl
xorl %eax, %eax
movb %cl, (%rsp,%rax)
incq %rax
xorl %ecx, %ecx
cmpq $0x2, %rax
jne 0x11f74
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x2, %ecx
callq *0x10(%rbx)
cmpq $0x2, %rax
setne %al
testb %al, %al
jne 0x11fbc
movq 0x58(%rbx), %rsi
movq %rsp, %rdx
movl $0x0, (%rdx)
movq 0x38(%rbx), %rdi
movl $0x4, %ecx
callq *0x10(%rbx)
cmpq $0x4, %rax
setne %al
testb %al, %al
jne 0x11fe0
movq 0x58(%rbx), %rsi
movq %rsp, %rdx
movl $0x0, (%rdx)
movq 0x38(%rbx), %rdi
movl $0x4, %ecx
callq *0x10(%rbx)
cmpq $0x4, %rax
setne %al
testb %al, %al
jne 0x1202b
movq 0x58(%rbx), %rsi
movq 0x10168(%rbx), %rax
xorl %ecx, %ecx
movq %rax, %rdx
movb %dl, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x8, %rcx
jne 0x11ff1
cmpq $0x100, %rdx            # imm = 0x100
jb 0x12015
movq $-0x1, (%rsp)
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x8, %ecx
callq *0x10(%rbx)
cmpq $0x8, %rax
setne %al
testb %al, %al
jne 0x12076
movq 0x58(%rbx), %rsi
movq 0x10168(%rbx), %rax
xorl %ecx, %ecx
movq %rax, %rdx
movb %dl, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x8, %rcx
jne 0x1203c
cmpq $0x100, %rdx            # imm = 0x100
jb 0x12060
movq $-0x1, (%rsp)
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x8, %ecx
callq *0x10(%rbx)
cmpq $0x8, %rax
setne %al
testb %al, %al
jne 0x120bd
movq 0x58(%rbx), %rsi
xorl %eax, %eax
movq %rbp, %rcx
movq %rcx, %rdx
movb %dl, (%rsp,%rax)
shrq $0x8, %rcx
incq %rax
cmpq $0x8, %rax
jne 0x12083
cmpq $0x100, %rdx            # imm = 0x100
jb 0x120a7
movq $-0x1, (%rsp)
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x8, %ecx
callq *0x10(%rbx)
cmpq $0x8, %rax
setne %al
testb %al, %al
jne 0x12104
movq %r15, %rax
subq 0x10160(%rbx), %rax
movq 0x58(%rbx), %rsi
xorl %ecx, %ecx
movq %rax, %rdx
movb %dl, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x8, %rcx
jne 0x120d1
cmpq $0x100, %rdx            # imm = 0x100
jb 0x120f5
movq $-0x1, (%rsp)
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x8, %ecx
callq *0x10(%rbx)
movq 0x10160(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rbx), %rsi
movl $0x7064b50, %eax        # imm = 0x7064B50
xorl %ecx, %ecx
movb %al, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x4, %rcx
jne 0x1211b
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x4, %ecx
callq *0x10(%rbx)
cmpq $0x4, %rax
setne %al
jne 0x12163
movq 0x58(%rbx), %rsi
movq %rsp, %rdx
movl $0x0, (%rdx)
movq 0x38(%rbx), %rdi
movl $0x4, %ecx
callq *0x10(%rbx)
cmpq $0x4, %rax
setne %al
testb %al, %al
jne 0x121ac
subq 0x8(%rsp), %r13
movq 0x58(%rbx), %rsi
xorl %eax, %eax
movq %r13, %rcx
movb %cl, (%rsp,%rax)
shrq $0x8, %r13
incq %rax
cmpq $0x8, %rax
jne 0x12172
cmpq $0x100, %rcx            # imm = 0x100
jb 0x12196
movq $-0x1, (%rsp)
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x8, %ecx
callq *0x10(%rbx)
cmpq $0x8, %rax
setne %al
testb %al, %al
jne 0x121d5
movq 0x58(%rbx), %rsi
movb $0x1, %cl
xorl %eax, %eax
movb %cl, (%rsp,%rax)
incq %rax
xorl %ecx, %ecx
cmpq $0x4, %rax
jne 0x121b8
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x4, %ecx
callq *0x10(%rbx)
testl %r12d, %r12d
jne 0x123e2
movq 0x58(%rbx), %rsi
movl $0x6054b50, %eax        # imm = 0x6054B50
xorl %ecx, %ecx
movb %al, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x4, %rcx
jne 0x121e9
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x4, %ecx
callq *0x10(%rbx)
cmpq $0x4, %rax
setne %al
jne 0x12230
movq 0x58(%rbx), %rsi
movq %rsp, %rdx
movw $0x0, (%rdx)
movq 0x38(%rbx), %rdi
movl $0x2, %ecx
callq *0x10(%rbx)
cmpq $0x2, %rax
setne %al
testb %al, %al
jne 0x12253
movq 0x58(%rbx), %rsi
movq %rsp, %rdx
movw $0x0, (%rdx)
movq 0x38(%rbx), %rdi
movl $0x2, %ecx
callq *0x10(%rbx)
cmpq $0x2, %rax
setne %al
testb %al, %al
jne 0x122c7
movq 0x10168(%rbx), %rax
movq 0x58(%rbx), %rsi
cmpq $0xffff, %rax           # imm = 0xFFFF
jb 0x1228d
movl $0xffff, %eax           # imm = 0xFFFF
xorl %ecx, %ecx
movb %al, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x2, %rcx
jne 0x12271
jmp 0x122b1
movl $0xffffff9a, %ebp       # imm = 0xFFFFFF9A
jmp 0x1249e
xorl %ecx, %ecx
movq %rax, %rdx
movb %dl, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x2, %rcx
jne 0x1228f
cmpq $0x100, %rdx            # imm = 0x100
jb 0x122b1
movw $0xffff, (%rsp)         # imm = 0xFFFF
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x2, %ecx
callq *0x10(%rbx)
cmpq $0x2, %rax
setne %al
testb %al, %al
jne 0x12331
movq 0x10168(%rbx), %rax
movq 0x58(%rbx), %rsi
cmpq $0xffff, %rax           # imm = 0xFFFF
jb 0x122f7
movl $0xffff, %eax           # imm = 0xFFFF
xorl %ecx, %ecx
movb %al, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x2, %rcx
jne 0x122e5
jmp 0x1231b
xorl %ecx, %ecx
movq %rax, %rdx
movb %dl, (%rsp,%rcx)
shrq $0x8, %rax
incq %rcx
cmpq $0x2, %rcx
jne 0x122f9
cmpq $0x100, %rdx            # imm = 0x100
jb 0x1231b
movw $0xffff, (%rsp)         # imm = 0xFFFF
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x2, %ecx
callq *0x10(%rbx)
cmpq $0x2, %rax
setne %al
testb %al, %al
jne 0x12374
movq 0x58(%rbx), %rsi
xorl %eax, %eax
movq %rbp, %rcx
movb %cl, (%rsp,%rax)
shrq $0x8, %rbp
incq %rax
cmpq $0x4, %rax
jne 0x1233b
cmpq $0x100, %rcx            # imm = 0x100
jb 0x1235e
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x4, %ecx
callq *0x10(%rbx)
cmpq $0x4, %rax
setne %al
testb %al, %al
jne 0x123db
subq 0x10160(%rbx), %r15
movq 0x58(%rbx), %rsi
cmpq %r14, %r15
jbe 0x123a0
incq %r14
xorl %eax, %eax
movb %r14b, (%rsp,%rax)
shrq $0x8, %r14
incq %rax
cmpq $0x4, %rax
jne 0x1238d
jmp 0x123c5
xorl %eax, %eax
movq %r15, %rcx
movb %cl, (%rsp,%rax)
shrq $0x8, %r15
incq %rax
cmpq $0x4, %rax
jne 0x123a2
cmpq $0x100, %rcx            # imm = 0x100
jb 0x123c5
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x4, %ecx
callq *0x10(%rbx)
cmpq $0x4, %rax
setne %al
movzbl %al, %r12d
negl %r12d
testl %r12d, %r12d
jne 0x1246e
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x123ff
movq %r14, %rdi
callq 0xc480
jmp 0x12401
xorl %eax, %eax
movq 0x58(%rbx), %rsi
movl %eax, %r15d
xorl %eax, %eax
movq %r15, %rcx
movq %rcx, %rdx
movb %dl, (%rsp,%rax)
shrq $0x8, %rcx
incq %rax
cmpq $0x2, %rax
jne 0x1240d
cmpq $0x100, %rdx            # imm = 0x100
jb 0x1242f
movw $0xffff, (%rsp)         # imm = 0xFFFF
movq 0x38(%rbx), %rdi
movq %rsp, %rdx
movl $0x2, %ecx
callq *0x10(%rbx)
cmpq $0x2, %rax
setne %cl
testq %r15, %r15
je 0x12467
cmpq $0x2, %rax
jne 0x12467
movq 0x38(%rbx), %rdi
movq 0x58(%rbx), %rsi
movq %r14, %rdx
movq %r15, %rcx
callq *0x10(%rbx)
cmpq %r15, %rax
setne %cl
movzbl %cl, %r12d
negl %r12d
movq 0x38(%rbx), %rdi
movq 0x58(%rbx), %rsi
callq *0x28(%rbx)
xorl %ebp, %ebp
cmpl $0x1, %r12d
sbbl %ebp, %ebp
orl %r12d, %ebp
testl %eax, %eax
cmovel %r12d, %ebp
movq 0x10170(%rbx), %rdi
callq 0xc0c0
movq %rbx, %rdi
callq 0xc0c0
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq