// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/third_party/minizip/zip.c
// Function: zip64local_SearchCentralDir
local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
  unsigned char* buf;
  ZPOS64_T uSizeFile;
  ZPOS64_T uBackRead;
  ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
  ZPOS64_T uPosFound=0;

  if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
    return 0;


  uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);

  if (uMaxBack>uSizeFile)
    uMaxBack = uSizeFile;

  buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
  if (buf==NULL)
    return 0;

  uBackRead = 4;
  while (uBackRead<uMaxBack)
  {
    uLong uReadSize;
    ZPOS64_T uReadPos ;
    int i;
    if (uBackRead+BUFREADCOMMENT>uMaxBack)
      uBackRead = uMaxBack;
    else
      uBackRead+=BUFREADCOMMENT;
    uReadPos = uSizeFile-uBackRead ;

    uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
      (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
    if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
      break;

    if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
      break;

    for (i=(int)uReadSize-3; (i--)>0;)
      if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
        ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
      {
        uPosFound = uReadPos+(unsigned)i;
        break;
      }

    if (uPosFound!=0)
      break;
  }
  free(buf);
  return uPosFound;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0xffff, -0x38(%rbp)    # imm = 0xFFFF
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x2, %ecx
callq 0xc540
cmpq $0x0, %rax
je 0x10f89
movq $0x0, -0x8(%rbp)
jmp 0x11122
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xcf60
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0x10fac
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x404, %edi            # imm = 0x404
callq 0xcaf0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x10fce
movq $0x0, -0x8(%rbp)
jmp 0x11122
movq $0x4, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x11111
movq -0x30(%rbp), %rax
addq $0x400, %rax            # imm = 0x400
cmpq -0x38(%rbp), %rax
jbe 0x10ffe
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x1100c
movq -0x30(%rbp), %rax
addq $0x400, %rax            # imm = 0x400
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rcx
subq -0x50(%rbp), %rcx
movl $0x404, %eax            # imm = 0x404
cmpq %rcx, %rax
jae 0x11035
movl $0x404, %eax            # imm = 0x404
movq %rax, -0x60(%rbp)
jmp 0x11041
movq -0x28(%rbp), %rax
subq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x50(%rbp), %rdx
xorl %ecx, %ecx
callq 0xc540
cmpq $0x0, %rax
je 0x11067
jmp 0x11111
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x38(%rcx), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq *%rax
cmpq -0x48(%rbp), %rax
je 0x11090
jmp 0x11111
movq -0x48(%rbp), %rax
subl $0x3, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x54(%rbp)
cmpl $0x0, %eax
jle 0x11103
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x50, %eax
jne 0x11101
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movzbl 0x1(%rax,%rcx), %eax
cmpl $0x4b, %eax
jne 0x11101
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movzbl 0x2(%rax,%rcx), %eax
cmpl $0x5, %eax
jne 0x11101
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movzbl 0x3(%rax,%rcx), %eax
cmpl $0x6, %eax
jne 0x11101
movq -0x50(%rbp), %rax
movl -0x54(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0x11103
jmp 0x1109a
cmpq $0x0, -0x40(%rbp)
je 0x1110c
jmp 0x11111
jmp 0x10fd6
movq -0x20(%rbp), %rdi
callq 0xc0d0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)