// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/third_party/minizip/zip.c
// Function: Write_EndOfCentralDirectoryRecord
local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
  int err = ZIP_OK;

  /*signature*/
  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4);

  if (err==ZIP_OK) /* number of this disk */
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);

  if (err==ZIP_OK) /* number of the disk with the start of the central directory */
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);

  if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
  {
    {
      if(zi->number_entry >= 0xFFFF)
        err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
      else
        err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
    }
  }

  if (err==ZIP_OK) /* total number of entries in the central dir */
  {
    if(zi->number_entry >= 0xFFFF)
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
    else
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
  }

  if (err==ZIP_OK) /* size of the central directory */
    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4);

  if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */
  {
    ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
    if(pos >= 0xffffffff)
    {
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4);
    }
    else
      err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writing_offset),4);
  }

   return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0x6054b50, %edx        # imm = 0x6054B50
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1088c
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x108af
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1090c
movq -0x8(%rbp), %rax
cmpq $0xffff, 0x10168(%rax) # imm = 0xFFFF
jb 0x108e6
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0xffff, %edx           # imm = 0xFFFF
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
jmp 0x1090a
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x10168(%rax), %rdx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
jmp 0x1090c
cmpl $0x0, -0x1c(%rbp)
jne 0x10969
movq -0x8(%rbp), %rax
cmpq $0xffff, 0x10168(%rax) # imm = 0xFFFF
jb 0x10943
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0xffff, %edx           # imm = 0xFFFF
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
jmp 0x10967
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x10168(%rax), %rdx
movl $0x2, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
jmp 0x10969
cmpl $0x0, -0x1c(%rbp)
jne 0x1098c
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x10(%rbp), %rdx
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x109fa
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
subq 0x10160(%rcx), %rax
movq %rax, -0x28(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x28(%rbp)
jb 0x109d0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
jmp 0x109f8
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x8(%rbp), %rax
subq 0x10160(%rax), %rdx
movl $0x4, %ecx
callq 0x102c0
movl %eax, -0x1c(%rbp)
jmp 0x109fa
movl -0x1c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)