// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x103b2
movl $0xffffff9a, -0x4(%rbp) # imm = 0xFFFFFF9A
jmp 0x10571
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x1, 0x70(%rax)
jne 0x103d0
movq -0x10(%rbp), %rdi
callq 0xc220
movl %eax, -0x24(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x103e6
movq -0x20(%rbp), %rax
movq 0x10170(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0xcf60
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x10485
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x10483
cmpl $0x0, -0x24(%rbp)
jne 0x10466
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jbe 0x10466
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x38(%rcx), %rdi
movq -0x20(%rbp), %rcx
movq 0x58(%rcx), %rsi
movq -0x48(%rbp), %rdx
addq $0x20, %rdx
movq -0x48(%rbp), %rcx
movq 0x10(%rcx), %rcx
callq *%rax
movq -0x48(%rbp), %rcx
cmpq 0x10(%rcx), %rax
je 0x10464
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
jmp 0x10466
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x10411
jmp 0x10485
movq -0x20(%rbp), %rdi
addq $0x60, %rdi
callq 0x10580
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
subq 0x10160(%rcx), %rax
movq %rax, -0x40(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x40(%rbp)
jae 0x104c1
movq -0x20(%rbp), %rax
cmpq $0xffff, 0x10168(%rax) # imm = 0xFFFF
jbe 0x104f4
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0xcf60
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x105c0
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x10770
cmpl $0x0, -0x24(%rbp)
jne 0x1050e
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x10830
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x10524
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x10a10
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x38(%rcx), %rdi
movq -0x20(%rbp), %rcx
movq 0x58(%rcx), %rsi
callq *%rax
cmpl $0x0, %eax
je 0x10552
cmpl $0x0, -0x24(%rbp)
jne 0x10550
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
jmp 0x10552
movq -0x20(%rbp), %rax
movq 0x10170(%rax), %rdi
callq 0xc0d0
movq -0x20(%rbp), %rdi
callq 0xc0d0
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)