// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/third_party/minizip/zip.c
// Function: Write_LocalFileHeader
local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) {
  /* write the local header */
  int err;
  uInt size_filename = (uInt)strlen(filename);
  uInt size_extrafield = size_extrafield_local;

  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC, 4);

  if (err==ZIP_OK)
  {
    if(zi->ci.zip64)
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */
    else
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */
  }

  if (err==ZIP_OK)
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2);

  if (err==ZIP_OK)
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2);

  if (err==ZIP_OK)
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);

  // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later
  if (err==ZIP_OK)
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */
  if (err==ZIP_OK)
  {
    if(zi->ci.zip64)
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */
    else
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */
  }
  if (err==ZIP_OK)
  {
    if(zi->ci.zip64)
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* uncompressed size, unknown */
    else
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */
  }

  if (err==ZIP_OK)
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2);

  if(zi->ci.zip64)
  {
    size_extrafield += 20;
  }

  if (err==ZIP_OK)
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield,2);

  if ((err==ZIP_OK) && (size_filename > 0))
  {
    if (ZWRITE64(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename)
      err = ZIP_ERRNO;
  }

  if ((err==ZIP_OK) && (size_extrafield_local > 0))
  {
    if (ZWRITE64(zi->z_filefunc, zi->filestream, extrafield_local, size_extrafield_local) != size_extrafield_local)
      err = ZIP_ERRNO;
  }


  if ((err==ZIP_OK) && (zi->ci.zip64))
  {
      // write the Zip64 extended info
      short HeaderID = 1;
      short DataSize = 16;
      ZPOS64_T CompressedSize = 0;
      ZPOS64_T UncompressedSize = 0;

      // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
      zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);

      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2);
      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2);

      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
  }

  return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0xc4e0
movl %eax, -0x28(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0x4034b50, %edx        # imm = 0x4034B50
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xed0a
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1013c(%rax)
je 0xecea
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0x2d, %edx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
jmp 0xed08
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0x14, %edx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
jmp 0xed0a
cmpl $0x0, -0x24(%rbp)
jne 0xed34
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rdx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xed5e
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x8(%rbp), %rax
movslq 0x120(%rax), %rdx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xed88
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x10128(%rax), %rdx
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xedab
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xedfd
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1013c(%rax)
je 0xedde
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
jmp 0xedfb
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
jmp 0xedfd
cmpl $0x0, -0x24(%rbp)
jne 0xee4f
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1013c(%rax)
je 0xee30
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
jmp 0xee4d
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
jmp 0xee4f
cmpl $0x0, -0x24(%rbp)
jne 0xee73
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl -0x28(%rbp), %eax
movl %eax, %edx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1013c(%rax)
je 0xee89
movl -0x2c(%rbp), %eax
addl $0x14, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xeead
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl -0x2c(%rbp), %eax
movl %eax, %edx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xeeeb
cmpl $0x0, -0x28(%rbp)
jbe 0xeeeb
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x38(%rcx), %rdi
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rsi
movq -0x10(%rbp), %rdx
movl -0x28(%rbp), %ecx
callq *%rax
movl -0x28(%rbp), %ecx
cmpq %rcx, %rax
je 0xeee9
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
jmp 0xeeeb
cmpl $0x0, -0x24(%rbp)
jne 0xef29
cmpl $0x0, -0x14(%rbp)
jbe 0xef29
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x38(%rcx), %rdi
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rsi
movq -0x20(%rbp), %rdx
movl -0x14(%rbp), %ecx
callq *%rax
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
je 0xef27
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
jmp 0xef29
cmpl $0x0, -0x24(%rbp)
jne 0xeff5
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1013c(%rax)
je 0xeff5
movw $0x1, -0x2e(%rbp)
movw $0x10, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0xcf60
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10140(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movswq -0x2e(%rbp), %rdx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movswq -0x30(%rbp), %rdx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x40(%rbp), %rdx
movl $0x8, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x38(%rbp), %rdx
movl $0x8, %ecx
callq 0x102c0
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop