// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/third_party/minizip/zip.c
// Function: zipOpen3
extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) {
    zip64_internal ziinit;
    zip64_internal* zi;
    int err=ZIP_OK;

    ziinit.z_filefunc.zseek32_file = NULL;
    ziinit.z_filefunc.ztell32_file = NULL;
    if (pzlib_filefunc64_32_def==NULL)
        fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
    else
        ziinit.z_filefunc = *pzlib_filefunc64_32_def;

    ziinit.filestream = ZOPEN64(ziinit.z_filefunc,
                  pathname,
                  (append == APPEND_STATUS_CREATE) ?
                  (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) :
                    (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING));

    if (ziinit.filestream == NULL)
        return NULL;

    if (append == APPEND_STATUS_CREATEAFTER)
        ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END);

    ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream);
    ziinit.in_opened_file_inzip = 0;
    ziinit.ci.stream_initialised = 0;
    ziinit.number_entry = 0;
    ziinit.add_position_when_writing_offset = 0;
    init_linkedlist(&(ziinit.central_dir));



    zi = (zip64_internal*)ALLOC(sizeof(zip64_internal));
    if (zi==NULL)
    {
        ZCLOSE64(ziinit.z_filefunc,ziinit.filestream);
        return NULL;
    }

    /* now we add file in a zipfile */
#    ifndef NO_ADDFILEINEXISTINGZIP
    ziinit.globalcomment = NULL;
    if (append == APPEND_STATUS_ADDINZIP)
    {
      // Read and Cache Central Directory Records
      err = LoadCentralDirectoryRecord(&ziinit);
    }

    if (globalcomment)
    {
      *globalcomment = ziinit.globalcomment;
    }
#    endif /* !NO_ADDFILEINEXISTINGZIP*/

    if (err != ZIP_OK)
    {
#    ifndef NO_ADDFILEINEXISTINGZIP
        free(ziinit.globalcomment);
#    endif /* !NO_ADDFILEINEXISTINGZIP*/
        free(zi);
        return NULL;
    }
    else
    {
        *zi = ziinit;
        return (zipFile)zi;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x101b0, %rsp          # imm = 0x101B0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x101ac(%rbp)
movq $0x0, -0x10150(%rbp)
movq $0x0, -0x10158(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xd9cf
leaq -0x101a0(%rbp), %rdi
callq 0xc070
jmp 0xd9e4
leaq -0x101a0(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x58, %edx
callq 0xc980
leaq -0x101a0(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %ecx
movl $0x7, %edx
movl $0xb, %eax
cmpl $0x0, %ecx
cmovel %eax, %edx
callq 0xd160
movq %rax, -0x10148(%rbp)
cmpq $0x0, -0x10148(%rbp)
jne 0xda25
movq $0x0, -0x8(%rbp)
jmp 0xdb4b
cmpl $0x1, -0x14(%rbp)
jne 0xda47
leaq -0x101a0(%rbp), %rdi
movq -0x10148(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x2, %ecx
callq 0xc540
leaq -0x101a0(%rbp), %rdi
movq -0x10148(%rbp), %rsi
callq 0xcf60
movq %rax, -0x48(%rbp)
movl $0x0, -0x10130(%rbp)
movl $0x0, -0x100b8(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x101a0(%rbp), %rdi
addq $0x60, %rdi
callq 0xdb60
movl $0x10178, %edi          # imm = 0x10178
callq 0xcaf0
movq %rax, -0x101a8(%rbp)
cmpq $0x0, -0x101a8(%rbp)
jne 0xdace
movq -0x10178(%rbp), %rax
movq -0x10168(%rbp), %rdi
movq -0x10148(%rbp), %rsi
callq *%rax
movq $0x0, -0x8(%rbp)
jmp 0xdb4b
movq $0x0, -0x30(%rbp)
cmpl $0x2, -0x14(%rbp)
jne 0xdaee
leaq -0x101a0(%rbp), %rdi
callq 0xdb90
movl %eax, -0x101ac(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xdb00
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x0, -0x101ac(%rbp)
je 0xdb28
movq -0x30(%rbp), %rdi
callq 0xc0d0
movq -0x101a8(%rbp), %rdi
callq 0xc0d0
movq $0x0, -0x8(%rbp)
jmp 0xdb4b
movq -0x101a8(%rbp), %rdi
leaq -0x101a0(%rbp), %rsi
movl $0x10178, %edx          # imm = 0x10178
callq 0xc980
movq -0x101a8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x101b0, %rsp          # imm = 0x101B0
popq %rbp
retq
nopl (%rax,%rax)