// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3Atoi64
SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){
  int incr;
  u64 u = 0;
  int neg = 0; /* assume positive */
  int i;
  int c = 0;
  int nonNum = 0;  /* True if input contains UTF16 with high byte non-zero */
  int rc;          /* Baseline return code */
  const char *zStart;
  const char *zEnd = zNum + length;
  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
  if( enc==SQLITE_UTF8 ){
    incr = 1;
  }else{
    incr = 2;
    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
    for(i=3-enc; i<length && zNum[i]==0; i+=2){}
    nonNum = i<length;
    zEnd = &zNum[i^1];
    zNum += (enc&1);
  }
  while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr;
  if( zNum<zEnd ){
    if( *zNum=='-' ){
      neg = 1;
      zNum+=incr;
    }else if( *zNum=='+' ){
      zNum+=incr;
    }
  }
  zStart = zNum;
  while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */
  for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){
    u = u*10 + c - '0';
  }
  testcase( i==18*incr );
  testcase( i==19*incr );
  testcase( i==20*incr );
  if( u>LARGEST_INT64 ){
    /* This test and assignment is needed only to suppress UB warnings
    ** from clang and -fsanitize=undefined.  This test and assignment make
    ** the code a little larger and slower, and no harm comes from omitting
    ** them, but we must appaise the undefined-behavior pharisees. */
    *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;
  }else if( neg ){
    *pNum = -(i64)u;
  }else{
    *pNum = (i64)u;
  }
  rc = 0;
  if( i==0 && zStart==zNum ){    /* No digits */
    rc = -1;
  }else if( nonNum ){            /* UTF16 with high-order bytes non-zero */
    rc = 1;
  }else if( &zNum[i]<zEnd ){     /* Extra bytes at the end */
    int jj = i;
    do{
      if( !sqlite3Isspace(zNum[jj]) ){
        rc = 1;          /* Extra non-space text after the integer */
        break;
      }
      jj += incr;
    }while( &zNum[jj]<zEnd );
  }
  if( i<19*incr ){
    /* Less than 19 digits, so we know that it fits in 64 bits */
    assert( u<=LARGEST_INT64 );
    return rc;
  }else{
    /* zNum is a 19-digit numbers.  Compare it against 9223372036854775808. */
    c = i>19*incr ? 1 : compare2pow63(zNum, incr);
    if( c<0 ){
      /* zNum is less than 9223372036854775808 so it fits */
      assert( u<=LARGEST_INT64 );
      return rc;
    }else{
      *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;
      if( c>0 ){
        /* zNum is greater than 9223372036854775808 so it overflows */
        return 2;
      }else{
        /* zNum is exactly 9223372036854775808.  Fits if negative.  The
        ** special case 2 overflow if positive */
        assert( u-1==LARGEST_INT64 );
        return neg ? rc : 3;
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movb %al, -0x1d(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movzbl -0x1d(%rbp), %eax
cmpl $0x1, %eax
jne 0x3efba9
movl $0x1, -0x24(%rbp)
jmp 0x3efc30
movl $0x2, -0x24(%rbp)
movzbl -0x1d(%rbp), %ecx
movl $0x3, %eax
subl %ecx, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x5d(%rbp)
jge 0x3efbe0
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x5d(%rbp)
movb -0x5d(%rbp), %al
testb $0x1, %al
jne 0x3efbe9
jmp 0x3efbf6
jmp 0x3efbeb
movl -0x38(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x38(%rbp)
jmp 0x3efbbe
movl -0x38(%rbp), %eax
cmpl -0x1c(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
xorl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movzbl -0x1d(%rbp), %ecx
andl $0x1, %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x3efc32
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq -0x58(%rbp), %rcx
movb %al, -0x5e(%rbp)
jae 0x3efc61
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x1b6f7f(%rip), %rax    # 0x5a6bd0
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x5e(%rbp)
movb -0x5e(%rbp), %al
testb $0x1, %al
jne 0x3efc6a
jmp 0x3efc7d
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x3efc32
movq -0x10(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x3efcce
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x3efcad
movl $0x1, -0x34(%rbp)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x3efccc
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
jne 0x3efcca
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x3efccc
jmp 0x3efcce
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq -0x58(%rbp), %rcx
movb %al, -0x5f(%rbp)
jae 0x3efcf5
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
sete %al
movb %al, -0x5f(%rbp)
movb -0x5f(%rbp), %al
testb $0x1, %al
jne 0x3efcfe
jmp 0x3efd11
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x3efcd6
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rcx
movslq -0x38(%rbp), %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq -0x58(%rbp), %rcx
movb %al, -0x60(%rbp)
jae 0x3efd51
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
movl %ecx, -0x3c(%rbp)
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x60(%rbp)
jl 0x3efd51
cmpl $0x39, -0x3c(%rbp)
setle %al
movb %al, -0x60(%rbp)
movb -0x60(%rbp), %al
testb $0x1, %al
jne 0x3efd5a
jmp 0x3efd79
imulq $0xa, -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
addq %rcx, %rax
subq $0x30, %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x3efd18
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rax, -0x30(%rbp)
jbe 0x3efdb0
movl -0x34(%rbp), %edx
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
cmpl $0x0, %edx
cmovneq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x3efdd4
cmpl $0x0, -0x34(%rbp)
je 0x3efdc7
xorl %eax, %eax
movl %eax, %ecx
subq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x3efdd2
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x3efdd4
movl $0x0, -0x44(%rbp)
cmpl $0x0, -0x38(%rbp)
jne 0x3efdf4
movq -0x50(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0x3efdf4
movl $0xffffffff, -0x44(%rbp) # imm = 0xFFFFFFFF
jmp 0x3efe64
cmpl $0x0, -0x40(%rbp)
je 0x3efe03
movl $0x1, -0x44(%rbp)
jmp 0x3efe62
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
addq %rcx, %rax
cmpq -0x58(%rbp), %rax
jae 0x3efe60
movl -0x38(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x1b6da1(%rip), %rax    # 0x5a6bd0
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x3efe44
movl $0x1, -0x44(%rbp)
jmp 0x3efe5e
movl -0x24(%rbp), %eax
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
addq %rcx, %rax
cmpq -0x58(%rbp), %rax
jb 0x3efe1a
jmp 0x3efe60
jmp 0x3efe62
jmp 0x3efe64
movl -0x38(%rbp), %eax
imull $0x13, -0x24(%rbp), %ecx
cmpl %ecx, %eax
jge 0x3efe7a
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3eff04
movl -0x38(%rbp), %eax
imull $0x13, -0x24(%rbp), %ecx
cmpl %ecx, %eax
jle 0x3efe8f
movl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x3efe9e
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x3eff10
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x3efeb2
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3eff04
movl -0x34(%rbp), %edx
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
cmpl $0x0, %edx
cmovneq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x0, -0x3c(%rbp)
jle 0x3efee6
movl $0x2, -0x4(%rbp)
jmp 0x3eff04
cmpl $0x0, -0x34(%rbp)
je 0x3efef4
movl -0x44(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0x3efefe
movl $0x3, %eax
movl %eax, -0x68(%rbp)
jmp 0x3efefe
movl -0x68(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)