// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3AtoF
SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
#ifndef SQLITE_OMIT_FLOATING_POINT
  int incr;
  const char *zEnd = z + length;
  /* sign * significand * (10 ^ (esign * exponent)) */
  int sign = 1;    /* sign of significand */
  i64 s = 0;       /* significand */
  int d = 0;       /* adjust exponent for shifting decimal point */
  int esign = 1;   /* sign of exponent */
  int e = 0;       /* exponent */
  int eValid = 1;  /* True exponent is either not used or is well-formed */
  double result;
  int nDigits = 0;
  int nonNum = 0;

  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
  *pResult = 0.0;   /* Default return value, in case of an error */

  if( enc==SQLITE_UTF8 ){
    incr = 1;
  }else{
    int i;
    incr = 2;
    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
    for(i=3-enc; i<length && z[i]==0; i+=2){}
    nonNum = i<length;
    zEnd = z+i+enc-3;
    z += (enc&1);
  }

  /* skip leading spaces */
  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
  if( z>=zEnd ) return 0;

  /* get sign of significand */
  if( *z=='-' ){
    sign = -1;
    z+=incr;
  }else if( *z=='+' ){
    z+=incr;
  }

  /* skip leading zeroes */
  while( z<zEnd && z[0]=='0' ) z+=incr, nDigits++;

  /* copy max significant digits to significand */
  while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
    s = s*10 + (*z - '0');
    z+=incr, nDigits++;
  }

  /* skip non-significant significand digits
  ** (increase exponent by d to shift decimal left) */
  while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++, d++;
  if( z>=zEnd ) goto do_atof_calc;

  /* if decimal point is present */
  if( *z=='.' ){
    z+=incr;
    /* copy digits from after decimal to significand
    ** (decrease exponent by d to shift decimal right) */
    while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
      s = s*10 + (*z - '0');
      z+=incr, nDigits++, d--;
    }
    /* skip non-significant digits */
    while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++;
  }
  if( z>=zEnd ) goto do_atof_calc;

  /* if exponent is present */
  if( *z=='e' || *z=='E' ){
    z+=incr;
    eValid = 0;
    if( z>=zEnd ) goto do_atof_calc;
    /* get sign of exponent */
    if( *z=='-' ){
      esign = -1;
      z+=incr;
    }else if( *z=='+' ){
      z+=incr;
    }
    /* copy digits to exponent */
    while( z<zEnd && sqlite3Isdigit(*z) ){
      e = e<10000 ? (e*10 + (*z - '0')) : 10000;
      z+=incr;
      eValid = 1;
    }
  }

  /* skip trailing spaces */
  if( nDigits && eValid ){
    while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
  }

do_atof_calc:
  /* adjust exponent by d, and update sign */
  e = (e*esign) + d;
  if( e<0 ) {
    esign = -1;
    e *= -1;
  } else {
    esign = 1;
  }

  /* if 0 significand */
  if( !s ) {
    /* In the IEEE 754 standard, zero is signed.
    ** Add the sign if we've seen at least one digit */
    result = (sign<0 && nDigits) ? -(double)0 : (double)0;
  } else {
    /* attempt to reduce exponent */
    if( esign>0 ){
      while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10;
    }else{
      while( !(s%10) && e>0 ) e--,s/=10;
    }

    /* adjust the sign of significand */
    s = sign<0 ? -s : s;

    /* if exponent, scale significand as appropriate
    ** and store in result. */
    if( e ){
      LONGDOUBLE_TYPE scale = 1.0;
      /* attempt to handle extremely small/large numbers better */
      if( e>307 && e<342 ){
        while( e%308 ) { scale *= 1.0e+1; e -= 1; }
        if( esign<0 ){
          result = s / scale;
          result /= 1.0e+308;
        }else{
          result = s * scale;
          result *= 1.0e+308;
        }
      }else if( e>=342 ){
        if( esign<0 ){
          result = 0.0*s;
        }else{
          result = 1e308*1e308*s;  /* Infinity */
        }
      }else{
        /* 1.0e+22 is the largest power of 10 than can be 
        ** represented exactly. */
        while( e%22 ) { scale *= 1.0e+1; e -= 1; }
        while( e>0 ) { scale *= 1.0e+22; e -= 22; }
        if( esign<0 ){
          result = s / scale;
        }else{
          result = s * scale;
        }
      }
    } else {
      result = (double)s;
    }
  }

  /* store the result */
  *pResult = result;

  /* return true if number and no extra non-whitespace chracters after */
  return z>=zEnd && nDigits>0 && eValid && nonNum==0;
#else
  return !sqlite3Atoi64(z, pResult, length, enc);
#endif /* SQLITE_OMIT_FLOATING_POINT */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq $0x0, (%rsi)
cmpl $0x1, %ecx
jne 0x248d5
movslq %edx, %r8
addq %rdi, %r8
movl $0x1, %ecx
movl $0x1, %ebx
jmp 0x24944
movl $0x3, %r8d
subl %ecx, %r8d
movzbl %cl, %eax
cmpl %edx, %r8d
setge %r9b
jge 0x24927
movl %ecx, %r10d
movl $0x3, %r8d
subq %r10, %r8
cmpb $0x0, (%rdi,%r8)
jne 0x24927
movslq %edx, %rdx
movl $0x5, %r8d
subq %rax, %r8
cmpq %rdx, %r8
setge %r9b
jge 0x24927
leaq 0x2(%r8), %r10
cmpb $0x0, (%rdi,%r8)
movq %r10, %r8
je 0x24909
addl $-0x2, %r10d
movl %r10d, %r8d
movslq %r8d, %rdx
addq %rdi, %rdx
leaq (%rax,%rdx), %r8
addq $-0x3, %r8
andl $0x1, %ecx
addq %rcx, %rdi
movzbl %r9b, %ecx
movl $0x2, %ebx
xorl %eax, %eax
cmpq %r8, %rdi
setb %dl
jae 0x24d7b
movzbl (%rdi), %r9d
leaq 0x51603(%rip), %r14     # 0x75f60
testb $0x1, (%r9,%r14)
je 0x24979
addq %rbx, %rdi
cmpq %r8, %rdi
setb %dl
jae 0x24d7b
movzbl (%rdi), %r9d
jmp 0x2495d
testb %dl, %dl
je 0x24d7b
movb (%rdi), %r11b
leal -0x2b(%r11), %eax
xorl %r9d, %r9d
testb $-0x3, %al
movl $0x0, %r10d
cmoveq %rbx, %r10
addq %rdi, %r10
cmpq %r8, %r10
jae 0x249b3
xorl %r9d, %r9d
cmpb $0x30, (%r10)
jne 0x249b3
addq %rbx, %r10
incl %r9d
cmpq %r8, %r10
jb 0x249a2
xorl %eax, %eax
cmpq %r8, %r10
jae 0x249f6
movabsq $0xccccccccccccccb, %rdi # imm = 0xCCCCCCCCCCCCCCB
xorl %edx, %edx
movzbl (%r10), %r15d
leaq -0x30(%r15), %r12
cmpq $0x9, %r12
ja 0x249f8
cmpq %rdi, %rdx
jge 0x249f8
movsbq %r15b, %r15
leaq (%rdx,%rdx,4), %rdx
leaq (%r15,%rdx,2), %rdx
addq $-0x30, %rdx
addq %rbx, %r10
incl %r9d
cmpq %r8, %r10
jb 0x249c6
jmp 0x249f8
xorl %edx, %edx
movl $0x1, %r12d
cmpq %r8, %r10
setb %r15b
jae 0x24a1b
movzbl (%r10), %eax
addq $-0x3a, %rax
xorl %edi, %edi
cmpq $-0xa, %rax
jae 0x24a22
xorl %eax, %eax
jmp 0x24a53
xorl %edi, %edi
jmp 0x24b11
xorl %r13d, %r13d
addq %rbx, %r10
leal 0x1(%r13), %eax
cmpq %r8, %r10
setb %r15b
jae 0x24c76
movzbl (%r10), %r12d
addq $-0x3a, %r12
movl %eax, %r13d
cmpq $-0xa, %r12
jae 0x24a25
addl %eax, %r9d
movl $0x1, %r12d
testb %r15b, %r15b
je 0x24b11
cmpb $0x2e, (%r10)
jne 0x24ac6
addq %rbx, %r10
cmpq %r8, %r10
jae 0x24aa5
movabsq $0xccccccccccccccb, %r15 # imm = 0xCCCCCCCCCCCCCCB
movzbl (%r10), %r12d
leaq -0x30(%r12), %r13
cmpq $0x9, %r13
ja 0x24aa5
cmpq %r15, %rdx
jge 0x24aa5
movsbq %r12b, %r12
leaq (%rdx,%rdx,4), %rdx
leaq (%r12,%rdx,2), %rdx
addq $-0x30, %rdx
incl %r9d
decl %eax
addq %rbx, %r10
cmpq %r8, %r10
jb 0x24a74
movl $0x1, %r12d
cmpq %r8, %r10
jae 0x24ac6
movzbl (%r10), %r15d
addq $-0x3a, %r15
cmpq $-0xa, %r15
jb 0x24ac6
addq %rbx, %r10
incl %r9d
jmp 0x24aab
cmpq %r8, %r10
jae 0x24b11
movzbl (%r10), %edi
orl $0x20, %edi
cmpl $0x65, %edi
jne 0x24d86
addq %rbx, %r10
cmpq %r8, %r10
jae 0x24da0
movzbl (%r10), %edi
movl $0x1, %r12d
cmpl $0x2b, %edi
je 0x24db0
cmpl $0x2d, %edi
jne 0x24db3
addq %rbx, %r10
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x24db3
movl $0x1, %r15d
testq %rdx, %rdx
je 0x24b6f
movl %r15d, -0x30(%rbp)
movq %r11, %r15
imull %r12d, %edi
addl %eax, %edi
movl %edi, %ebx
negl %ebx
cmovsl %edi, %ebx
testl %edi, %edi
js 0x24b81
movabsq $0xccccccccccccccb, %rax # imm = 0xCCCCCCCCCCCCCCB
incq %rax
cmpq %rax, %rdx
jge 0x24bab
testl %edi, %edi
je 0x24bab
movabsq $0x147ae147ae147ad, %r14 # imm = 0x147AE147AE147AD
movq %rdx, %r11
leal -0x1(%rbx), %eax
addq %rdx, %rdx
leaq (%rdx,%rdx,4), %rdx
cmpq %r14, %r11
jg 0x24bad
cmpl $0x1, %ebx
movl %eax, %ebx
jg 0x24b54
jmp 0x24bad
testl %r9d, %r9d
jne 0x24c5b
xorpd %xmm0, %xmm0
jmp 0x24c63
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
movq %rdx, %rax
imulq %r14, %rax
movabsq $0x1999999999999998, %r12 # imm = 0x1999999999999998
addq %r12, %rax
rorq %rax
cmpq %r12, %rax
jbe 0x24cf5
movl %ebx, %eax
movq %rdx, %rbx
negq %rbx
cmpb $0x2d, %r15b
cmovneq %rdx, %rbx
testl %eax, %eax
je 0x24c2c
leal -0x134(%rax), %edx
cmpl $0x21, %edx
movl -0x30(%rbp), %r15d
ja 0x24c3a
imull $0x3f2b3885, %eax, %edx # imm = 0x3F2B3885
rorl $0x2, %edx
fld1
cmpl $0xd4c77c, %edx         # imm = 0xD4C77C
jb 0x24c06
fstp %st(0)
decl %eax
fld1
fmuls 0x5467b(%rip)           # 0x79268
imull $0x3f2b3885, %eax, %edx # imm = 0x3F2B3885
addl $0x1a98ef4, %edx        # imm = 0x1A98EF4
rorl $0x2, %edx
decl %eax
cmpl $0xd4c77a, %edx         # imm = 0xD4C77A
ja 0x24be7
movq %rbx, -0x50(%rbp)
fildll -0x50(%rbp)
testl %edi, %edi
js 0x24d38
fmulp %st, %st(1)
fstpl -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
mulsd 0x54699(%rip), %xmm0    # 0x792c0
jmp 0x24d60
cvtsi2sd %rbx, %xmm0
movl -0x30(%rbp), %r15d
jmp 0x24d60
cmpl $0x155, %eax            # imm = 0x155
jle 0x24c8f
cvtsi2sd %rbx, %xmm0
testl %edi, %edi
js 0x24d4c
mulsd 0x54662(%rip), %xmm0    # 0x792b8
jmp 0x24d60
movsd 0x54665(%rip), %xmm0    # 0x792c8
cmpb $0x2d, %r11b
je 0x24d60
xorpd %xmm0, %xmm0
jmp 0x24d60
addl %r13d, %r9d
incl %r9d
xorl %edi, %edi
movl $0x1, %r15d
movl $0x1, %r12d
jmp 0x24b17
imull $0xba2e8ba3, %eax, %edx # imm = 0xBA2E8BA3
addl $0xba2e8ba, %edx        # imm = 0xBA2E8BA
rorl %edx
fld1
cmpl $0xba2e8bb, %edx        # imm = 0xBA2E8BB
jb 0x24cc9
fstp %st(0)
fld1
fmuls 0x545b7(%rip)           # 0x79268
imull $0xba2e8ba3, %eax, %edx # imm = 0xBA2E8BA3
decl %eax
addl $0x51745d17, %edx       # imm = 0x51745D17
rorl %edx
cmpl $0xba2e8bb, %edx        # imm = 0xBA2E8BB
jae 0x24cab
testl %eax, %eax
jle 0x24cde
addl $0x16, %eax
fmull 0x545da(%rip)           # 0x792b0
addl $-0x16, %eax
cmpl $0x16, %eax
jg 0x24cd0
movq %rbx, -0x68(%rbp)
fildll -0x68(%rbp)
testl %edi, %edi
js 0x24d56
fmulp %st, %st(1)
fstpl -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
jmp 0x24d60
movabsq $0x6666666666666667, %r13 # imm = 0x6666666666666667
movq %rdx, %rax
imulq %r13
leal -0x1(%rbx), %eax
movq %rdx, %r11
shrq $0x3f, %r11
sarq $0x2, %rdx
addq %r11, %rdx
movq %rdx, %r11
imulq %r14, %r11
addq %r12, %r11
rorq %r11
cmpq %r12, %r11
ja 0x24bad
cmpl $0x1, %ebx
movl %eax, %ebx
jg 0x24cff
jmp 0x24bad
fdivp %st, %st(1)
fstpl -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
divsd 0x54576(%rip), %xmm0    # 0x792c0
jmp 0x24d60
andpd 0x5465c(%rip), %xmm0    # 0x793b0
jmp 0x24d60
fdivp %st, %st(1)
fstpl -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
xorl %eax, %eax
testl %r9d, %r9d
cmovlel %eax, %ecx
movsd %xmm0, (%rsi)
cmpq %r8, %r10
cmovbl %eax, %ecx
testl %r15d, %r15d
cmovel %r15d, %ecx
movl %ecx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r11, -0x30(%rbp)
xorl %edi, %edi
movl $0x1, %r12d
movb $0x1, %r13b
movl $0x1, %r15d
jmp 0x24e25
xorl %edi, %edi
movl $0x1, %r12d
xorl %r15d, %r15d
jmp 0x24b17
addq %rbx, %r10
movq %r11, -0x30(%rbp)
xorl %edi, %edi
cmpq %r8, %r10
jae 0x24dce
movzbl (%r10), %r11d
leaq -0x3a(%r11), %r15
xorl %edi, %edi
cmpq $-0xa, %r15
jae 0x24dd6
xorl %r13d, %r13d
xorl %r15d, %r15d
jmp 0x24e25
movl %r12d, -0x34(%rbp)
addq %rbx, %r10
xorl %edi, %edi
movq %r10, %r12
movq %r12, %r10
movl $0x2710, %r15d          # imm = 0x2710
cmpl %r15d, %edi
leal (%rdi,%rdi,4), %edi
movsbl %r11b, %r11d
leal -0x30(%r11,%rdi,2), %edi
cmovgel %r15d, %edi
movl $0x1, %r15d
cmpq %r8, %r12
jae 0x24e1e
movzbl (%r10), %r11d
movq %r11, %r13
addq $-0x3a, %r13
leaq (%r10,%rbx), %r12
cmpq $-0xa, %r13
jae 0x24de2
movl -0x34(%rbp), %r12d
movb $0x1, %r13b
testl %r9d, %r9d
sete %r11b
xorb $0x1, %r13b
orb %r11b, %r13b
jne 0x24e50
movl $0x1, %r15d
cmpq %r8, %r10
jae 0x24e50
movzbl (%r10), %r11d
testb $0x1, (%r11,%r14)
je 0x24e50
addq %rbx, %r10
jmp 0x24e3b
movq -0x30(%rbp), %r11
jmp 0x24b17