// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/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;
  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+enc-3;
    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';
  }
  if( u>LARGEST_INT64 ){
    *pNum = SMALLEST_INT64;
  }else if( neg ){
    *pNum = -(i64)u;
  }else{
    *pNum = (i64)u;
  }
  testcase( i==18 );
  testcase( i==19 );
  testcase( i==20 );
  if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr || nonNum ){
    /* zNum is empty or contains non-numeric text or is longer
    ** than 19 digits (thus guaranteeing that it is too large) */
    return 1;
  }else if( i<19*incr ){
    /* Less than 19 digits, so we know that it fits in 64 bits */
    assert( u<=LARGEST_INT64 );
    return 0;
  }else{
    /* zNum is a 19-digit numbers.  Compare it against 9223372036854775808. */
    c = compare2pow63(zNum, incr);
    if( c<0 ){
      /* zNum is less than 9223372036854775808 so it fits */
      assert( u<=LARGEST_INT64 );
      return 0;
    }else if( c>0 ){
      /* zNum is greater than 9223372036854775808 so it overflows */
      return 1;
    }else{
      /* zNum is exactly 9223372036854775808.  Fits if negative.  The
      ** special case 2 overflow if positive */
      assert( u-1==LARGEST_INT64 );
      assert( (*pNum)==SMALLEST_INT64 );
      return neg ? 0 : 2;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %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, -0x50(%rbp)
movzbl -0x1d(%rbp), %eax
cmpl $0x1, %eax
jne 0x1b529
movl $0x1, -0x24(%rbp)
jmp 0x1b5b9
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, -0x51(%rbp)
jge 0x1b560
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x1b569
jmp 0x1b576
jmp 0x1b56b
movl -0x38(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x38(%rbp)
jmp 0x1b53e
movl -0x38(%rbp), %eax
cmpl -0x1c(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
addq %rcx, %rax
movzbl -0x1d(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
addq $-0x3, %rax
movq %rax, -0x50(%rbp)
movzbl -0x1d(%rbp), %ecx
andl $0x1, %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x1b5bb
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq -0x50(%rbp), %rcx
movb %al, -0x52(%rbp)
jae 0x1b5ea
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x8f466(%rip), %rax     # 0xaaa40
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x52(%rbp)
movb -0x52(%rbp), %al
testb $0x1, %al
jne 0x1b5f3
jmp 0x1b606
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x1b5bb
movq -0x10(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x1b657
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x1b636
movl $0x1, -0x34(%rbp)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x1b655
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
jne 0x1b653
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x1b655
jmp 0x1b657
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq -0x50(%rbp), %rcx
movb %al, -0x53(%rbp)
jae 0x1b67e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
sete %al
movb %al, -0x53(%rbp)
movb -0x53(%rbp), %al
testb $0x1, %al
jne 0x1b687
jmp 0x1b69a
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x1b65f
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rcx
movslq -0x38(%rbp), %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq -0x50(%rbp), %rcx
movb %al, -0x54(%rbp)
jae 0x1b6da
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
movl %ecx, -0x3c(%rbp)
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x54(%rbp)
jl 0x1b6da
cmpl $0x39, -0x3c(%rbp)
setle %al
movb %al, -0x54(%rbp)
movb -0x54(%rbp), %al
testb $0x1, %al
jne 0x1b6e3
jmp 0x1b702
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 0x1b6a1
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rax, -0x30(%rbp)
jbe 0x1b725
movq -0x18(%rbp), %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq %rcx, (%rax)
jmp 0x1b749
cmpl $0x0, -0x34(%rbp)
je 0x1b73c
xorl %eax, %eax
movl %eax, %ecx
subq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1b747
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1b749
cmpl $0x0, -0x3c(%rbp)
je 0x1b760
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
addq %rcx, %rax
cmpq -0x50(%rbp), %rax
jb 0x1b781
cmpl $0x0, -0x38(%rbp)
jne 0x1b770
movq -0x48(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x1b781
movl -0x38(%rbp), %eax
imull $0x13, -0x24(%rbp), %ecx
cmpl %ecx, %eax
jg 0x1b781
cmpl $0x0, -0x40(%rbp)
je 0x1b78a
movl $0x1, -0x4(%rbp)
jmp 0x1b7de
movl -0x38(%rbp), %eax
imull $0x13, -0x24(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1b79e
movl $0x0, -0x4(%rbp)
jmp 0x1b7de
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x8b370
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x1b7bc
movl $0x0, -0x4(%rbp)
jmp 0x1b7de
cmpl $0x0, -0x3c(%rbp)
jle 0x1b7cb
movl $0x1, -0x4(%rbp)
jmp 0x1b7de
movl -0x34(%rbp), %edx
movl $0x2, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)