// File: /workspace/github_c_makefile_star2_O3/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 0x243de
movslq %edx, %r9
addq %rdi, %r9
movl $0x1, %r8d
movl $0x1, %r14d
jmp 0x24433
movl $0x3, %r9d
movl $0x3, %eax
subl %ecx, %eax
movl $0x1, %r8d
cmpl %edx, %eax
jge 0x24417
subl %ecx, %r9d
movslq %r9d, %rax
movslq %edx, %r8
movb (%rdi,%rax), %dl
testb %dl, %dl
jne 0x2440e
addq $0x2, %rax
cmpq %r8, %rax
jl 0x243fe
xorl %r8d, %r8d
testb %dl, %dl
sete %r8b
cltq
addq %rdi, %rax
movzbl %cl, %edx
leaq (%rdx,%rax), %r9
addq $-0x3, %r9
andl $0x1, %ecx
addq %rcx, %rdi
movl $0x2, %r14d
xorl %eax, %eax
cmpq %r9, %rdi
jae 0x24862
leaq 0x51b6b(%rip), %r15     # 0x75fb0
movzbl (%rdi), %r10d
testb $0x1, (%r10,%r15)
je 0x2445d
addq %r14, %rdi
cmpq %r9, %rdi
jb 0x24445
jmp 0x24862
leal -0x2b(%r10), %eax
xorl %ecx, %ecx
testb $-0x3, %al
movl $0x0, %eax
cmoveq %r14, %rax
addq %rax, %rdi
cmpq %r9, %rdi
jae 0x24487
xorl %ecx, %ecx
cmpb $0x30, (%rdi)
jne 0x24487
addq %r14, %rdi
incl %ecx
cmpq %r9, %rdi
jb 0x24478
xorl %eax, %eax
cmpq %r9, %rdi
jae 0x244c8
movabsq $0xccccccccccccccb, %r11 # imm = 0xCCCCCCCCCCCCCCB
xorl %edx, %edx
movzbl (%rdi), %ebx
leaq -0x30(%rbx), %r12
cmpq $0x9, %r12
ja 0x244ca
cmpq %r11, %rdx
jge 0x244ca
movsbq %bl, %rbx
leaq (%rdx,%rdx,4), %rdx
leaq (%rbx,%rdx,2), %rdx
addq $-0x30, %rdx
addq %r14, %rdi
incl %ecx
cmpq %r9, %rdi
jb 0x2449a
jmp 0x244ca
xorl %edx, %edx
movl $0x1, %r12d
cmpq %r9, %rdi
jae 0x244f5
xorl %eax, %eax
movzbl (%rdi), %r11d
leaq -0x3a(%r11), %rbx
cmpq $-0xa, %rbx
jb 0x24573
addq %r14, %rdi
incl %eax
cmpq %r9, %rdi
jb 0x244d7
addl %eax, %ecx
xorl %r11d, %r11d
movl $0x1, %ebx
testq %rdx, %rdx
je 0x24562
imull %r12d, %r11d
addl %eax, %r11d
js 0x24630
movabsq $0xccccccccccccccb, %rax # imm = 0xCCCCCCCCCCCCCCB
incq %rax
cmpq %rax, %rdx
movl %ebx, -0x2c(%rbp)
jge 0x24670
testl %r11d, %r11d
je 0x24670
movabsq $0x147ae147ae147ad, %rax # imm = 0x147AE147AE147AD
movl %r11d, %ebx
movq %rdx, %r14
leal -0x1(%rbx), %r15d
addq %rdx, %rdx
leaq (%rdx,%rdx,4), %rdx
cmpq %rax, %r14
jg 0x24673
cmpl $0x1, %ebx
movl %r15d, %ebx
ja 0x2453e
jmp 0x24673
testl %ecx, %ecx
jne 0x2471a
xorpd %xmm0, %xmm0
jmp 0x24722
addl %eax, %ecx
cmpb $0x2e, %r11b
jne 0x245d5
addq %r14, %rdi
cmpq %r9, %rdi
jae 0x245d0
movabsq $0xccccccccccccccb, %r11 # imm = 0xCCCCCCCCCCCCCCB
movzbl (%rdi), %ebx
leaq -0x30(%rbx), %r13
cmpq $0x9, %r13
ja 0x245d0
cmpq %r11, %rdx
jge 0x245d0
movsbq %bl, %rbx
leaq (%rdx,%rdx,4), %rdx
leaq (%rbx,%rdx,2), %rdx
addq $-0x30, %rdx
incl %ecx
decl %eax
addq %r14, %rdi
cmpq %r9, %rdi
jb 0x2458d
jmp 0x245d0
movzbl (%rdi), %r11d
addq $-0x3a, %r11
cmpq $-0xa, %r11
jb 0x245d5
addq %r14, %rdi
incl %ecx
cmpq %r9, %rdi
jb 0x245bd
xorl %r11d, %r11d
cmpq %r9, %rdi
jae 0x244f8
movzbl (%rdi), %r11d
orl $0x20, %r11d
cmpl $0x65, %r11d
jne 0x24816
addq %r14, %rdi
xorl %r11d, %r11d
movl $0x1, %r12d
cmpq %r9, %rdi
jae 0x2489b
movb $0x1, %bl
movl %ebx, -0x34(%rbp)
movzbl (%rdi), %ebx
cmpl $0x2b, %ebx
je 0x2486d
cmpl $0x2d, %ebx
jne 0x24870
addq %r14, %rdi
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x24870
movl %r11d, %r14d
negl %r14d
movabsq $-0x3333333333333333, %r12 # imm = 0xCCCCCCCCCCCCCCCD
movq %rdx, %rax
imulq %r12, %rax
movabsq $0x1999999999999998, %r13 # imm = 0x1999999999999998
addq %r13, %rax
rorq %rax
cmpq %r13, %rax
jbe 0x247b9
movq %rdx, %rax
negq %rax
cmpb $0x2d, %r10b
cmovneq %rdx, %rax
jmp 0x24690
movl %r11d, %r15d
movq %rdx, %rax
negq %rax
cmpb $0x2d, %r10b
cmovneq %rdx, %rax
testl %r15d, %r15d
je 0x24735
movl %r15d, %r14d
movl -0x2c(%rbp), %ebx
leal -0x134(%r14), %edx
cmpl $0x21, %edx
ja 0x246f6
fld1
cmpl $0x134, %r14d           # imm = 0x134
je 0x246cf
fstp %st(0)
decl %r14d
fld1
fmuls 0x54bb4(%rip)           # 0x79268
imull $0x3f2b3885, %r14d, %edx # imm = 0x3F2B3885
addl $0x1a98ef4, %edx        # imm = 0x1A98EF4
rorl $0x2, %edx
decl %r14d
cmpl $0xd4c77a, %edx         # imm = 0xD4C77A
ja 0x246ae
movq %rax, -0x50(%rbp)
fildll -0x50(%rbp)
testl %r11d, %r11d
js 0x24802
fmulp %st, %st(1)
fstpl -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
mulsd 0x54bcf(%rip), %xmm0    # 0x792c0
jmp 0x24846
cmpl $0x155, %r14d           # imm = 0x155
jbe 0x24742
cvtsi2sd %rax, %xmm0
testl %r11d, %r11d
js 0x24832
mulsd 0x54ba3(%rip), %xmm0    # 0x792b8
jmp 0x24846
movsd 0x54ba6(%rip), %xmm0    # 0x792c8
cmpb $0x2d, %r10b
je 0x24846
xorpd %xmm0, %xmm0
jmp 0x24846
cvtsi2sd %rax, %xmm0
movl -0x2c(%rbp), %ebx
jmp 0x24846
imull $0xffff8ba3, %r14d, %edx # imm = 0xFFFF8BA3
rorw %dx
movzwl %dx, %edx
fld1
cmpl $0xba3, %edx            # imm = 0xBA3
jb 0x24786
fstp %st(0)
fld1
fmuls 0x54b05(%rip)           # 0x79268
imull $0xba2e8ba3, %r14d, %edx # imm = 0xBA2E8BA3
decl %r14d
addl $0x51745d17, %edx       # imm = 0x51745D17
rorl %edx
cmpl $0xba2e8bb, %edx        # imm = 0xBA2E8BB
jae 0x2475d
leal 0x1(%r14), %edx
cmpl $0x2, %edx
jl 0x2479a
addl $0x16, %r14d
fmull 0x54b20(%rip)           # 0x792b0
addl $-0x16, %r14d
cmpl $0x16, %r14d
ja 0x2478a
movq %rax, -0x68(%rbp)
fildll -0x68(%rbp)
testl %r11d, %r11d
js 0x2483c
fmulp %st, %st(1)
fstpl -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
jmp 0x24846
movl %ebx, -0x2c(%rbp)
movabsq $0x6666666666666667, %rbx # imm = 0x6666666666666667
movq %rdx, %rax
imulq %rbx
leal -0x1(%r14), %r15d
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x2, %rdx
addq %rax, %rdx
movq %rdx, %rax
imulq %r12, %rax
addq %r13, %rax
rorq %rax
cmpq %r13, %rax
ja 0x24673
cmpl $0x1, %r14d
movl %r15d, %r14d
ja 0x247c6
jmp 0x24673
fdivp %st, %st(1)
fstpl -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
divsd 0x54aac(%rip), %xmm0    # 0x792c0
jmp 0x24846
movb $0x1, %r11b
movl %r11d, -0x34(%rbp)
xorl %r11d, %r11d
movl $0x1, %r12d
movl $0x1, -0x2c(%rbp)
jmp 0x248ed
andpd 0x54b76(%rip), %xmm0    # 0x793b0
jmp 0x24846
fdivp %st, %st(1)
fstpl -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %r8d
movsd %xmm0, (%rsi)
cmpq %r9, %rdi
cmovbl %eax, %r8d
testl %ebx, %ebx
cmovel %ebx, %r8d
movl %r8d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %r14, %rdi
cmpq %r9, %rdi
jae 0x2489b
movl %r12d, -0x30(%rbp)
movzbl (%rdi), %r12d
leaq -0x3a(%r12), %rbx
xorl %r11d, %r11d
cmpq $-0xa, %rbx
jae 0x248a2
movl $0x0, -0x34(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x248e9
xorl %ebx, %ebx
jmp 0x244fd
addq %r14, %rdi
xorl %r11d, %r11d
movq %rdi, %rbx
movq %rbx, %rdi
movl $0x2710, %r13d          # imm = 0x2710
cmpl %r13d, %r11d
leal (%r11,%r11,4), %r11d
movsbl %r12b, %ebx
leal -0x30(%rbx,%r11,2), %r11d
cmovgel %r13d, %r11d
movl $0x1, -0x2c(%rbp)
cmpq %r9, %rdi
jae 0x248e9
movzbl (%rdi), %r12d
movq %r12, %r13
addq $-0x3a, %r13
leaq (%rdi,%r14), %rbx
cmpq $-0xa, %r13
jae 0x248ab
movl -0x30(%rbp), %r12d
testl %ecx, %ecx
sete %bl
movl -0x34(%rbp), %r13d
xorb $0x1, %r13b
orb %bl, %r13b
jne 0x24928
movl $0x1, %ebx
cmpq %r9, %rdi
jae 0x244fd
movzbl (%rdi), %ebx
testb $0x1, (%rbx,%r15)
je 0x244f8
addq %r14, %rdi
cmpq %r9, %rdi
jb 0x2490d
jmp 0x244f8
movl -0x2c(%rbp), %ebx
jmp 0x244fd