// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/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;
  /* 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 nDigit = 0;  /* Number of digits processed */
  int eType = 1;   /* 1: pure integer,  2+: fractional  -1 or less: bad UTF16 */

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

  if( enc==SQLITE_UTF8 ){
    incr = 1;
    zEnd = z + length;
  }else{
    int i;
    incr = 2;
    length &= ~1;
    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
    testcase( enc==SQLITE_UTF16LE );
    testcase( enc==SQLITE_UTF16BE );
    for(i=3-enc; i<length && z[i]==0; i+=2){}
    if( i<length ) eType = -100;
    zEnd = &z[i^1];
    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;
  }

  /* copy max significant digits to significand */
  while( z<zEnd && sqlite3Isdigit(*z) ){
    s = s*10 + (*z - '0');
    z+=incr; nDigit++;
    if( s>=((LARGEST_INT64-9)/10) ){
      /* skip non-significant significand digits
      ** (increase exponent by d to shift decimal left) */
      while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; d++; }
    }
  }
  if( z>=zEnd ) goto do_atof_calc;

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

  /* if exponent is present */
  if( *z=='e' || *z=='E' ){
    z+=incr;
    eValid = 0;
    eType++;

    /* This branch is needed to avoid a (harmless) buffer overread.  The
    ** special comment alerts the mutation tester that the correct answer
    ** is obtained even if the branch is omitted */
    if( z>=zEnd ) goto do_atof_calc;              /*PREVENTS-HARMLESS-OVERREAD*/

    /* 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 */
  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( s==0 ) {
    /* In the IEEE 754 standard, zero is signed. */
    result = sign<0 ? -(double)0 : (double)0;
  } else {
    /* Attempt to reduce exponent.
    **
    ** Branches that are not required for the correct answer but which only
    ** help to obtain the correct answer faster are marked with special
    ** comments, as a hint to the mutation tester.
    */
    while( e>0 ){                                       /*OPTIMIZATION-IF-TRUE*/
      if( esign>0 ){
        if( s>=(LARGEST_INT64/10) ) break;             /*OPTIMIZATION-IF-FALSE*/
        s *= 10;
      }else{
        if( s%10!=0 ) break;                           /*OPTIMIZATION-IF-FALSE*/
        s /= 10;
      }
      e--;
    }

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

    if( e==0 ){                                         /*OPTIMIZATION-IF-TRUE*/
      result = (double)s;
    }else{
      /* attempt to handle extremely small/large numbers better */
      if( e>307 ){                                      /*OPTIMIZATION-IF-TRUE*/
        if( e<342 ){                                    /*OPTIMIZATION-IF-TRUE*/
          LONGDOUBLE_TYPE scale = sqlite3Pow10(e-308);
          if( esign<0 ){
            result = s / scale;
            result /= 1.0e+308;
          }else{
            result = s * scale;
            result *= 1.0e+308;
          }
        }else{ assert( e>=342 );
          if( esign<0 ){
            result = 0.0*s;
          }else{
#ifdef INFINITY
            result = INFINITY*s;
#else
            result = 1e308*1e308*s;  /* Infinity */
#endif
          }
        }
      }else{
        LONGDOUBLE_TYPE scale = sqlite3Pow10(e);
        if( esign<0 ){
          result = s / scale;
        }else{
          result = s * scale;
        }
      }
    }
  }

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

  /* return true if number and no extra non-whitespace chracters after */
  if( z==zEnd && nDigit>0 && eValid && eType>0 ){
    return eType;
  }else if( eType>=2 && (eType==3 || eValid) && nDigit>0 ){
    return -1;
  }else{
    return 0;
  }
#else
  return !sqlite3Atoi64(z, pResult, length, enc);
#endif /* SQLITE_OMIT_FLOATING_POINT */
}

// Assembly:
movq $0x0, (%rsi)
xorl %eax, %eax
testl %edx, %edx
je 0x29c3e8
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
cmpb $0x1, %cl
jne 0x29bfa6
movl $0x1, %r14d
movl $0x1, %r8d
movq %rdi, %r10
jmp 0x29bffd
movzbl %cl, %r10d
andl $-0x2, %edx
movl $0x3, %r9d
movl $0x3, %ecx
subl %r10d, %ecx
movl $0x1, %r8d
cmpl %edx, %ecx
jge 0x29bfeb
subl %r10d, %r9d
movslq %r9d, %rcx
movslq %edx, %rdx
cmpb $0x0, (%rdi,%rcx)
jne 0x29bfe5
addq $0x2, %rcx
cmpq %rdx, %rcx
jl 0x29bfce
movl $0x1, %r8d
jmp 0x29bfeb
movl $0xffffff9c, %r8d       # imm = 0xFFFFFF9C
xorl $0x1, %ecx
andl $0x1, %r10d
addq %rdi, %r10
movl $0x2, %r14d
movl %ecx, %edx
movslq %edx, %rcx
addq %rcx, %rdi
cmpq %rdi, %r10
setb %cl
jae 0x29c3de
movzbl (%r10), %edx
leaq 0x13eba6(%rip), %r15    # 0x3dabc0
testb $0x1, (%rdx,%r15)
je 0x29c036
addq %r14, %r10
cmpq %rdi, %r10
setb %cl
jae 0x29c3de
movzbl (%r10), %edx
jmp 0x29c01a
testb %cl, %cl
je 0x29c3de
movb (%r10), %dl
leal -0x2b(%rdx), %eax
xorl %ecx, %ecx
testb $-0x3, %al
movl $0x0, %r9d
cmoveq %r14, %r9
addq %r10, %r9
movl $0x1, %eax
cmpq %rdi, %r9
setb %bpl
movq %rdx, -0x30(%rsp)
jae 0x29c082
movzbl (%r9), %ebx
leaq -0x3a(%rbx), %rcx
xorl %r11d, %r11d
cmpq $-0xa, %rcx
jae 0x29c094
xorl %r10d, %r10d
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x29c0fb
xorl %edx, %edx
xorl %r11d, %r11d
movl $0x1, %ebp
xorl %r10d, %r10d
jmp 0x29c1a6
xorl %ecx, %ecx
movabsq $0xccccccccccccccb, %r12 # imm = 0xCCCCCCCCCCCCCCB
decq %r12
xorl %edx, %edx
xorl %r10d, %r10d
leaq (%rcx,%rcx,4), %rcx
movsbq %bl, %rbx
leaq (%rbx,%rcx,2), %rcx
addq $-0x30, %rcx
addq %r14, %r9
cmpq %r12, %rcx
jle 0x29c0da
cmpq %rdi, %r9
jae 0x29c0da
movzbl (%r9), %ebx
addq $-0x3a, %rbx
cmpq $-0xa, %rbx
jb 0x29c0da
addq %r14, %r9
incl %edx
jmp 0x29c0c0
incl %r10d
cmpq %rdi, %r9
setb %bpl
jae 0x29c19e
movzbl (%r9), %ebx
movq %rbx, %r13
addq $-0x3a, %r13
cmpq $-0xa, %r13
jae 0x29c0a8
testb %bpl, %bpl
je 0x29c1a1
cmpb $0x2e, (%r9)
jne 0x29c150
incl %r8d
addq %r14, %r9
cmpq %rdi, %r9
jae 0x29c150
movabsq $0xccccccccccccccb, %rbx # imm = 0xCCCCCCCCCCCCCCB
movzbl (%r9), %r12d
leaq -0x3a(%r12), %r13
cmpq $-0xa, %r13
jb 0x29c150
cmpq %rbx, %rcx
jge 0x29c148
movsbq %r12b, %r12
leaq (%rcx,%rcx,4), %rcx
leaq (%r12,%rcx,2), %rcx
addq $-0x30, %rcx
decl %edx
incl %r10d
addq %r14, %r9
cmpq %rdi, %r9
jb 0x29c11f
cmpq %rdi, %r9
jae 0x29c1a1
movzbl (%r9), %eax
orl $0x20, %eax
cmpl $0x65, %eax
jne 0x29c3e9
addq %r14, %r9
incl %r8d
cmpq %rdi, %r9
jae 0x29c3f8
movzbl (%r9), %r11d
movl $0x1, %eax
cmpl $0x2b, %r11d
je 0x29c407
cmpl $0x2d, %r11d
jne 0x29c40a
addq %r14, %r9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x29c40a
xorl %r11d, %r11d
movl $0x1, %ebp
testq %rcx, %rcx
je 0x29c286
imull %eax, %r11d
addl %edx, %r11d
movl %r11d, %r14d
negl %r14d
cmovsl %r11d, %r14d
jae 0x29c235
movabsq $0xccccccccccccccb, %r15 # imm = 0xCCCCCCCCCCCCCCB
movabsq $0x6666666666666667, %r12 # imm = 0x6666666666666667
movabsq $-0x3333333333333333, %r13 # imm = 0xCCCCCCCCCCCCCCCD
movabsq $0x1999999999999998, %rbx # imm = 0x1999999999999998
testl %r11d, %r11d
js 0x29c1fd
cmpq %r15, %rcx
jg 0x29c235
addq %rcx, %rcx
leaq (%rcx,%rcx,4), %rcx
jmp 0x29c226
movq %rcx, %rax
imulq %r12
movq %rcx, %rax
imulq %r13, %rax
addq %rbx, %rax
rorq %rax
cmpq %rbx, %rax
ja 0x29c235
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x2, %rdx
addq %rax, %rdx
movq %rdx, %rcx
leal -0x1(%r14), %edx
cmpl $0x1, %r14d
movl %edx, %r14d
jg 0x29c1ea
jmp 0x29c238
movl %r14d, %edx
movq %rcx, %rax
negq %rax
cmpb $0x2d, -0x30(%rsp)
cmovneq %rcx, %rax
testl %edx, %edx
je 0x29c295
cmpl $0x134, %edx            # imm = 0x134
jl 0x29c29f
cmpl $0x155, %edx            # imm = 0x155
jg 0x29c2ca
leal -0x134(%rdx), %ecx
testb $0x1, %dl
fld1
flds 0x142d00(%rip)          # 0x3def6c
fld %st(0)
fcmove %st(2), %st
fstp %st(2)
cmpl $0x2, %ecx
jae 0x29c32d
fstp %st(0)
fldz
fldz
jmp 0x29c34d
cmpb $0x2d, -0x30(%rsp)
je 0x29c2bd
xorps %xmm0, %xmm0
jmp 0x29c398
cvtsi2sd %rax, %xmm0
jmp 0x29c398
testb $0x1, %dl
fld1
flds 0x142cc2(%rip)          # 0x3def6c
fld %st(0)
fcmove %st(2), %st
fstp %st(2)
cmpl $0x1, %edx
jne 0x29c2e9
fstp %st(0)
fldz
fldz
jmp 0x29c309
movsd 0x142c03(%rip), %xmm0   # 0x3deec8
jmp 0x29c398
testl %r11d, %r11d
js 0x29c375
cvtsi2ss %rax, %xmm0
mulss 0x142c94(%rip), %xmm0   # 0x3def74
cvtss2sd %xmm0, %xmm0
jmp 0x29c398
movl %edx, %ecx
fldz
fxch %st(2)
fstp %st(2)
sarl %ecx
fmul %st, %st(0)
testb $0x2, %dl
fld %st(1)
fmul %st(1), %st
fcmove %st(2), %st
fstp %st(2)
fld %st(1)
movl %ecx, %edx
cmpl $0x1, %ecx
ja 0x29c2ef
fstp %st(1)
fstp %st(0)
movq %rax, -0x8(%rsp)
fildll -0x8(%rsp)
testl %r11d, %r11d
js 0x29c31f
fmulp %st, %st(1)
jmp 0x29c321
fdivp %st, %st(1)
fstpl -0x10(%rsp)
movsd -0x10(%rsp), %xmm0
jmp 0x29c398
movl %ecx, %edx
fldz
fxch %st(2)
fstp %st(2)
sarl %edx
fmul %st, %st(0)
testb $0x2, %cl
fld %st(1)
fmul %st(1), %st
fcmove %st(2), %st
fstp %st(2)
fld %st(1)
movl %edx, %ecx
cmpl $0x1, %edx
ja 0x29c333
fstp %st(1)
fstp %st(0)
movq %rax, -0x18(%rsp)
fildll -0x18(%rsp)
testl %r11d, %r11d
js 0x29c384
fmulp %st, %st(1)
fstpl -0x20(%rsp)
movsd -0x20(%rsp), %xmm0
mulsd 0x142b4d(%rip), %xmm0   # 0x3deec0
jmp 0x29c398
cvtsi2sd %rax, %xmm0
andpd 0xbc6fe(%rip), %xmm0    # 0x358a80
jmp 0x29c398
fdivp %st, %st(1)
fstpl -0x28(%rsp)
movsd -0x28(%rsp), %xmm0
divsd 0x142b28(%rip), %xmm0   # 0x3deec0
movsd %xmm0, (%rsi)
cmpq %rdi, %r9
sete %al
testl %r10d, %r10d
setg %cl
andb %al, %cl
andb %bpl, %cl
testl %r8d, %r8d
setg %al
testb %al, %cl
je 0x29c3bc
movl %r8d, %eax
jmp 0x29c3de
cmpl $0x2, %r8d
jl 0x29c3dc
testl %ebp, %ebp
sete %al
cmpl $0x3, %r8d
setne %cl
testb %cl, %al
jne 0x29c3dc
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %r10d, %r10d
jg 0x29c3de
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r11d, %r11d
movl $0x1, %eax
movl $0x1, %ebp
jmp 0x29c473
xorl %r11d, %r11d
movl $0x1, %eax
xorl %ebp, %ebp
jmp 0x29c1a6
addq %r14, %r9
xorl %r11d, %r11d
cmpq %rdi, %r9
jae 0x29c428
movl %eax, -0x34(%rsp)
movzbl (%r9), %eax
leaq -0x3a(%rax), %rbx
cmpq $-0xa, %rbx
jae 0x29c42c
xorl %ebp, %ebp
jmp 0x29c46f
xorl %ebp, %ebp
jmp 0x29c473
addq %r14, %r9
xorl %r11d, %r11d
movl $0x2710, %ebx           # imm = 0x2710
movq %r9, %r13
movl $0x1, %ebp
movq %r13, %r9
cmpl %ebx, %r11d
leal (%r11,%r11,4), %r11d
movsbl %al, %eax
leal -0x30(%rax,%r11,2), %r11d
cmovgel %ebx, %r11d
cmpq %rdi, %r13
jae 0x29c46f
movzbl (%r9), %eax
movq %rax, %r12
addq $-0x3a, %r12
leaq (%r9,%r14), %r13
cmpq $-0xa, %r12
jae 0x29c43f
movl -0x34(%rsp), %eax
cmpq %rdi, %r9
jae 0x29c1a6
movl %eax, %ebx
movzbl (%r9), %eax
testb $0x1, (%rax,%r15)
je 0x29c491
addq %r14, %r9
cmpq %rdi, %r9
jb 0x29c47e
movl %ebx, %eax
jmp 0x29c1a6