// File: /workspace/github_c_makefile_star2_O2/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:
andq $0x0, (%rsi)
movslq %edx, %r11
cmpl $0x1, %ecx
jne 0x21004
addq %rdi, %r11
movl $0x1, %r10d
movabsq $0x1, %r9
jmp 0x2106d
movl $0x3, %eax
subl %ecx, %eax
movslq %eax, %r9
movzbl %cl, %eax
movq %rax, %r8
shlq $0x20, %r8
movabsq $0x300000000, %rdx      # imm = 0x300000000
subq %r8, %rdx
movabsq $0x200000000, %r8       # imm = 0x200000000
cmpq %r11, %r9
jge 0x21044
cmpb $0x0, (%rdi,%r9)
jne 0x21044
addq $0x2, %r9
addq %r8, %rdx
jmp 0x2102f
xorl %r10d, %r10d
cmpq %r11, %r9
setge %r10b
sarq $0x20, %rdx
addq %rdi, %rdx
leaq (%rax,%rdx), %r11
addq $-0x3, %r11
andl $0x1, %ecx
addq %rcx, %rdi
movabsq $0x2, %r9
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0x46eef(%rip), %r12     # 0x67f70
cmpq %r11, %rdi
jae 0x21095
movzbl (%rdi), %ebx
testb $0x1, (%rbx,%r12)
je 0x2109d
addq %r9, %rdi
jmp 0x21081
xorl %r10d, %r10d
jmp 0x213b6
leal -0x2b(%rbx), %eax
xorl %ecx, %ecx
testb $-0x3, %al
movl $0x0, %eax
cmoveq %r9, %rax
leaq (%rdi,%rax), %r15
addq %r9, %rdi
addq %rax, %rdi
cmpq %r11, %r15
jae 0x210cc
cmpb $0x30, (%r15)
jne 0x210cc
addq %r9, %r15
incl %ecx
addq %r9, %rdi
jmp 0x210b7
movabsq $0xccccccccccccccb, %rax # imm = 0xCCCCCCCCCCCCCCB
xorl %r8d, %r8d
cmpq %r11, %r15
jae 0x2110a
movzbl (%r15), %r14d
leaq -0x30(%r14), %rdx
cmpq $0x9, %rdx
ja 0x2110a
cmpq %rax, %r8
jge 0x2110a
movsbq %r14b, %rdx
imulq $0xa, %r8, %r8
addq %rdx, %r8
addq $-0x30, %r8
addq %r9, %r15
incl %ecx
addq %r9, %rdi
jmp 0x210d9
movq %rsi, -0x38(%rbp)
xorl %r14d, %r14d
xorl %r13d, %r13d
cmpq %r11, %r15
jae 0x21134
movzbl (%r15), %esi
leaq -0x3a(%rsi), %rdx
cmpq $-0xa, %rdx
jb 0x2113c
addq %r9, %r15
incl %ecx
incl %r13d
addq %r9, %rdi
jmp 0x21114
movq %r15, %rdi
jmp 0x211c3
cmpb $0x2e, %sil
jne 0x2117e
xorl %esi, %esi
cmpq %r11, %rdi
jae 0x2120d
movzbl (%rdi), %r15d
leaq -0x30(%r15), %rdx
cmpq $0x9, %rdx
ja 0x2120d
cmpq %rax, %r8
jge 0x2120d
movsbq %r15b, %rdx
imulq $0xa, %r8, %r8
addq %rdx, %r8
addq $-0x30, %r8
addq %r9, %rdi
decl %esi
jmp 0x21144
movq %r15, %rdi
cmpq %r11, %rdi
jae 0x211c3
movzbl (%rdi), %edx
orl $0x20, %edx
cmpl $0x65, %edx
jne 0x2134d
addq %r9, %rdi
cmpq %r11, %rdi
jae 0x21360
movzbl (%rdi), %edx
cmpl $0x2b, %edx
je 0x213c4
cmpl $0x2d, %edx
jne 0x213c7
addq %r9, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
jmp 0x213cc
movl $0x1, %edx
movl %edx, %r15d
testq %r8, %r8
je 0x211fc
imull %edx, %r14d
addl %r13d, %r14d
js 0x21233
incq %rax
movl %r14d, %r9d
movl %r14d, %edx
addl $-0x1, %edx
setb %sil
cmpq %rax, %r8
jge 0x2125d
testb %sil, %sil
je 0x2125d
imulq $0xa, %r8, %r8
movl %edx, %r9d
jmp 0x211e2
testl %ecx, %ecx
jne 0x212ec
xorpd %xmm0, %xmm0
jmp 0x212f4
addl %esi, %r13d
subl %esi, %ecx
cmpq %r11, %rdi
jae 0x21181
movzbl (%rdi), %edx
addq $-0x3a, %rdx
cmpq $-0xa, %rdx
jb 0x21181
addq %r9, %rdi
incl %ecx
jmp 0x21212
movabsq $0xa, %rsi
movl %r14d, %r9d
movq %r8, %rax
cqto
idivq %rsi
testq %rdx, %rdx
jne 0x2125a
testl %r9d, %r9d
je 0x2125a
incl %r9d
movq %rax, %r8
jmp 0x21240
negl %r9d
movq %r8, %r12
negq %r12
cmpb $0x2d, %bl
cmovneq %r8, %r12
testl %r9d, %r9d
je 0x21297
leal -0x134(%r9), %eax
cmpl $0x21, %eax
ja 0x212a1
fld1
movl $0x134, %esi            # imm = 0x134
movl %r9d, %eax
cltd
idivl %esi
testl %edx, %edx
je 0x212c5
fmuls 0x4a0ea(%rip)           # 0x6b37c
decl %r9d
jmp 0x21282
cvtsi2sd %r12, %xmm0
jmp 0x21398
cmpl $0x155, %r9d            # imm = 0x155
jbe 0x2130a
cvtsi2sd %r12, %xmm0
testl %r14d, %r14d
js 0x21384
mulsd 0x4a008(%rip), %xmm0    # 0x6b2c8
jmp 0x21398
movq %r12, -0x58(%rbp)
fildll -0x58(%rbp)
testl %r14d, %r14d
js 0x21370
fmulp %st, %st(1)
fstpl -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
mulsd 0x49fe9(%rip), %xmm0    # 0x6b2d0
jmp 0x21398
movsd 0x49fe4(%rip), %xmm0    # 0x6b2d8
movq -0x38(%rbp), %rdx
cmpb $0x2d, %bl
je 0x2139c
xorpd %xmm0, %xmm0
jmp 0x2139c
fld1
movl $0x16, %esi
movl %r9d, %eax
cltd
idivl %esi
testl %edx, %edx
je 0x21330
fmuls 0x4a05b(%rip)           # 0x6b37c
decl %r9d
jmp 0x21311
fmull 0x49f94(%rip)           # 0x6b2c0
addl $-0x16, %r9d
testl %r9d, %r9d
jg 0x21326
movq %r12, -0x70(%rbp)
fildll -0x70(%rbp)
testl %r14d, %r14d
js 0x2138e
fmulp %st, %st(1)
fstpl -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
jmp 0x21398
xorl %r14d, %r14d
movl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %edx, %r15d
jmp 0x21418
xorl %r14d, %r14d
movl $0x1, %edx
xorl %r15d, %r15d
jmp 0x211cb
fdivp %st, %st(1)
fstpl -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
divsd 0x49f4e(%rip), %xmm0    # 0x6b2d0
jmp 0x21398
andpd 0x4a034(%rip), %xmm0    # 0x6b3c0
jmp 0x21398
fdivp %st, %st(1)
fstpl -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
movq -0x38(%rbp), %rdx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %r10d
cmpq %r11, %rdi
cmovbl %eax, %r10d
movsd %xmm0, (%rdx)
testl %r15d, %r15d
cmovel %r15d, %r10d
movl %r10d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %r9, %rdi
movl $0x1, %edx
movl %edx, -0x2c(%rbp)
movl %r10d, -0x3c(%rbp)
xorl %r14d, %r14d
movl $0x2710, %esi           # imm = 0x2710
xorl %r15d, %r15d
cmpq %r11, %rdi
jae 0x21414
movl %r15d, %r10d
movzbl (%rdi), %edx
leaq -0x3a(%rdx), %r15
cmpq $-0xa, %r15
jb 0x21411
movsbl %dl, %edx
imull $0xa, %r14d, %r15d
cmpl %esi, %r14d
leal -0x30(%r15,%rdx), %r14d
cmovgel %esi, %r14d
addq %r9, %rdi
movl $0x1, %r15d
jmp 0x213de
movl %r10d, %r15d
movl -0x3c(%rbp), %r10d
testl %ecx, %ecx
sete %dl
testl %r15d, %r15d
sete %sil
orb %dl, %sil
jne 0x21443
movl $0x1, %r15d
cmpq %r11, %rdi
jae 0x21443
movzbl (%rdi), %edx
testb $0x1, (%rdx,%r12)
je 0x21443
addq %r9, %rdi
jmp 0x2142f
movl -0x2c(%rbp), %edx
jmp 0x211cb