// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: lxw_packager_new
lxw_packager *
lxw_packager_new(const char *filename, const char *tmpdir, uint8_t use_zip64)
{
    zlib_filefunc_def filefunc;
    lxw_packager *packager = calloc(1, sizeof(lxw_packager));
    GOTO_LABEL_ON_MEM_ERROR(packager, mem_error);

    packager->buffer = calloc(1, LXW_ZIP_BUFFER_SIZE);
    GOTO_LABEL_ON_MEM_ERROR(packager->buffer, mem_error);

    packager->filename = NULL;
    packager->tmpdir = tmpdir;

    if (filename) {
        packager->filename = lxw_strdup(filename);
        GOTO_LABEL_ON_MEM_ERROR(packager->filename, mem_error);
    }

    packager->buffer_size = LXW_ZIP_BUFFER_SIZE;
    packager->use_zip64 = use_zip64;

    /* Initialize the zip_fileinfo struct to Jan 1 1980 like Excel. */
    packager->zipfile_info.tmz_date.tm_sec = 0;
    packager->zipfile_info.tmz_date.tm_min = 0;
    packager->zipfile_info.tmz_date.tm_hour = 0;
    packager->zipfile_info.tmz_date.tm_mday = 1;
    packager->zipfile_info.tmz_date.tm_mon = 0;
    packager->zipfile_info.tmz_date.tm_year = 1980;
    packager->zipfile_info.dosDate = 0;
    packager->zipfile_info.internal_fa = 0;
    packager->zipfile_info.external_fa = 0;

    packager->output_buffer = NULL;
    packager->output_buffer_size = 0;

    /* Create a zip container for the xlsx file. */
    if (packager->filename) {
#ifdef _WIN32
        packager->zipfile = _open_zipfile_win32(packager->filename);
#else
        packager->zipfile = zipOpen(packager->filename, 0);
#endif
    }
    else {
        fill_fopen_filefunc(&filefunc);
        filefunc.opaque = packager;
        filefunc.zopen_file = _fopen_memstream;
        filefunc.zclose_file = _fclose_memstream;
        packager->zipfile = zipOpen2(packager->filename, 0, NULL, &filefunc);
    }

    if (packager->zipfile == NULL)
        goto mem_error;

    return packager;

mem_error:
    lxw_packager_free(packager);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
movl $0x1, %edi
movl $0x80, %esi
callq 0xc870
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x2c578
movq 0x50aa2(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x39b70(%rip), %rsi     # 0x660d0
leaq 0x3c51d(%rip), %rdx     # 0x68a84
movl $0xb1, %ecx
movb $0x0, %al
callq 0xc8f0
jmp 0x2c750
jmp 0x2c57a
movl $0x1, %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0xc870
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jne 0x2c5c8
movq 0x50a52(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x39b20(%rip), %rsi     # 0x660d0
leaq 0x3c4cd(%rip), %rdx     # 0x68a84
movl $0xb4, %ecx
movb $0x0, %al
callq 0xc8f0
jmp 0x2c750
jmp 0x2c5ca
movq -0x68(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x18(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x70(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x2c635
movq -0x10(%rbp), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0x2c631
movq 0x509e9(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x39ab7(%rip), %rsi     # 0x660d0
leaq 0x3c464(%rip), %rdx     # 0x68a84
movl $0xbb, %ecx
movb $0x0, %al
callq 0xc8f0
jmp 0x2c750
jmp 0x2c633
jmp 0x2c635
movq -0x68(%rbp), %rax
movq $0x4000, 0x10(%rax)     # imm = 0x4000
movb -0x19(%rbp), %cl
movq -0x68(%rbp), %rax
movb %cl, 0x78(%rax)
movq -0x68(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x68(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x68(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x68(%rbp), %rax
movl $0x1, 0x34(%rax)
movq -0x68(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x68(%rbp), %rax
movl $0x7bc, 0x3c(%rax)      # imm = 0x7BC
movq -0x68(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x68(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x68(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x68(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x68(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x2c6f0
movq -0x68(%rbp), %rax
movq 0x58(%rax), %rdi
xorl %esi, %esi
callq 0xc970
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x2c739
leaq -0x60(%rbp), %rdi
callq 0xc6d0
movq -0x68(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x68(%rip), %rax        # 0x2c770
movq %rax, -0x60(%rbp)
leaq 0x9d(%rip), %rax        # 0x2c7b0
movq %rax, -0x38(%rbp)
movq -0x68(%rbp), %rax
movq 0x58(%rax), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
leaq -0x60(%rbp), %rcx
callq 0xd0c0
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x2c746
jmp 0x2c750
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2c761
movq -0x68(%rbp), %rdi
callq 0xccf0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)