// File: /workspace/github_c_makefile_star2_O2/ukontainer[P]sqlite-bench/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;  /* True if input contains UTF16 with high byte non-zero */

  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^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<((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) ){
      if( s<((LARGEST_INT64-9)/10) ){
        s = s*10 + (*z - '0');
        d--;
      }
      z+=incr; nDigits++;
    }
  }
  if( z>=zEnd ) goto do_atof_calc;

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

    /* 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 */
  return z==zEnd && nDigits>0 && eValid && nonNum==0;
#else
  return !sqlite3Atoi64(z, pResult, length, enc);
#endif /* SQLITE_OMIT_FLOATING_POINT */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
andq $0x0, (%rsi)
cmpl $0x1, %ecx
jne 0x4208fe
pushq $0x1
popq %rax
pushq $0x1
popq %rbx
movq %r14, %rcx
jmp 0x42092f
pushq $0x3
popq %rdi
subl %ecx, %edi
movslq %edx, %rax
movslq %edi, %rdx
cmpq %rax, %rdx
jge 0x42091b
cmpb $0x0, (%r14,%rdx)
jne 0x42091b
addq $0x2, %rdx
jmp 0x420909
xorl %ebx, %ebx
cmpq %rax, %rdx
setge %bl
xorl $0x1, %edx
andl $0x1, %ecx
addq %r14, %rcx
pushq $0x2
popq %rax
movslq %edx, %rdx
addq %rdx, %r14
leaq 0x119b94(%rip), %rdx    # 0x53a4d0
cmpq %r14, %rcx
jae 0x420951
movzbl (%rcx), %r8d
testb $0x1, (%r8,%rdx)
je 0x420958
addq %rax, %rcx
jmp 0x42093c
xorl %eax, %eax
jmp 0x420be4
movabsq $0xccccccccccccccb, %r9 # imm = 0xCCCCCCCCCCCCCCB
leal -0x2b(%r8), %edi
xorl %ebp, %ebp
testb $-0x3, %dil
movl $0x0, %edi
cmoveq %rax, %rdi
leaq (%rcx,%rdi), %r12
addq %rax, %rcx
addq %rdi, %rcx
xorl %r15d, %r15d
cmpq %r14, %r12
jae 0x4209b6
movzbl (%r12), %edi
leaq -0x30(%rdi), %r10
cmpq $0x9, %r10
ja 0x4209b6
cmpq %r9, %rbp
jge 0x4209b6
movsbq %dil, %rdi
imulq $0xa, %rbp, %r10
leaq (%r10,%rdi), %rbp
addq $-0x30, %rbp
addq %rax, %r12
incl %r15d
addq %rax, %rcx
jmp 0x420982
xorl %edi, %edi
movq %rsi, 0x8(%rsp)
movl %ebx, 0x4(%rsp)
cmpq %r14, %r12
jae 0x4209df
movzbl (%r12), %r10d
leaq -0x3a(%r10), %r11
cmpq $-0xa, %r11
jb 0x4209e7
addq %rax, %r12
incl %edi
addq %rax, %rcx
jmp 0x4209c1
addl %edi, %r15d
jmp 0x420a6e
addl %edi, %r15d
cmpb $0x2e, %r10b
jne 0x420a25
cmpq %r14, %rcx
jae 0x420a22
movzbl (%rcx), %r10d
leaq -0x3a(%r10), %r11
cmpq $-0xa, %r11
jb 0x420a22
cmpq %r9, %rbp
jge 0x420a1a
movsbq %r10b, %r10
imulq $0xa, %rbp, %r11
leaq (%r11,%r10), %rbp
addq $-0x30, %rbp
decl %edi
incl %r15d
addq %rax, %rcx
jmp 0x4209f0
movq %rcx, %r12
cmpq %r14, %r12
jae 0x420a6e
movzbl (%r12), %ecx
orl $0x20, %ecx
cmpl $0x65, %ecx
jne 0x420b6d
addq %rax, %r12
cmpq %r14, %r12
jae 0x420b7a
movzbl (%r12), %r10d
pushq $0x1
popq %rcx
cmpl $0x2b, %r10d
je 0x420bf3
cmpl $0x2d, %r10d
jne 0x420bf6
addq %rax, %r12
pushq $-0x1
popq %rcx
jmp 0x420bf6
movb $0x1, %sil
xorl %ebx, %ebx
pushq $0x1
popq %rcx
testq %rbp, %rbp
je 0x420ab1
imull %ecx, %ebx
addl %edi, %ebx
movl %ebx, %edi
negl %edi
cmovsl %ebx, %edi
pushq $0xa
popq %rcx
testl %edi, %edi
jle 0x420ac4
testl %ebx, %ebx
js 0x420a9d
cmpq %r9, %rbp
jg 0x420ae0
imulq $0xa, %rbp, %rbp
jmp 0x420aad
movq %rbp, %rax
cqto
idivq %rcx
testq %rdx, %rdx
jne 0x420ae0
movq %rax, %rbp
decl %edi
jmp 0x420a8a
cmpb $0x2d, %r8b
je 0x420b4a
xorpd %xmm0, %xmm0
jmp 0x420bc2
movq %rbp, %r13
negq %r13
cmpb $0x2d, %r8b
cmovneq %rbp, %r13
testl %edi, %edi
jne 0x420b32
cvtsi2sd %r13, %xmm0
jmp 0x420bc2
movq %rbp, %r13
negq %r13
cmpb $0x2d, %r8b
cmovneq %rbp, %r13
cmpl $0x134, %edi            # imm = 0x134
jb 0x420b32
cmpl $0x155, %edi            # imm = 0x155
ja 0x420b86
movl %esi, %ebp
addl $0xfffffecc, %edi       # imm = 0xFFFFFECC
callq 0x420c4d
movq %r13, 0x20(%rsp)
fildll 0x20(%rsp)
testl %ebx, %ebx
js 0x420b99
fmulp %st, %st(1)
fstpl 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
mulsd 0x11d950(%rip), %xmm0   # 0x53e480
jmp 0x420bad
movl %esi, %ebp
callq 0x420c4d
movq %r13, 0x30(%rsp)
fildll 0x30(%rsp)
testl %ebx, %ebx
js 0x420b54
fmulp %st, %st(1)
jmp 0x420b56
movsd 0x11d936(%rip), %xmm0   # 0x53e488
jmp 0x420bc2
fdivp %st, %st(1)
movq 0x8(%rsp), %rcx
movl 0x4(%rsp), %eax
movl %ebp, %esi
fstpl 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
jmp 0x420bcb
movb $0x1, %sil
xorl %ebx, %ebx
pushq $0x1
popq %rcx
jmp 0x420c43
xorl %ebx, %ebx
pushq $0x1
popq %rcx
xorl %esi, %esi
jmp 0x420a76
cvtsi2sd %r13, %xmm0
testl %ebx, %ebx
js 0x420bba
mulsd 0x11d8e1(%rip), %xmm0   # 0x53e478
jmp 0x420bc2
fdivp %st, %st(1)
fstpl 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
divsd 0x11d8d3(%rip), %xmm0   # 0x53e480
movq 0x8(%rsp), %rcx
movl 0x4(%rsp), %eax
movl %ebp, %esi
jmp 0x420bcb
andpd 0x11d81e(%rip), %xmm0   # 0x53e3e0
movq 0x8(%rsp), %rcx
movl 0x4(%rsp), %eax
xorl %edx, %edx
testl %r15d, %r15d
cmovlel %edx, %eax
cmpq %r14, %r12
cmovnel %edx, %eax
movsd %xmm0, (%rcx)
testb $0x1, %sil
cmovel %edx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rax, %r12
xorl %ebx, %ebx
movl $0x2710, %r10d          # imm = 0x2710
xorl %esi, %esi
cmpq %r14, %r12
jae 0x420c43
movzbl (%r12), %r11d
leaq -0x3a(%r11), %r13
cmpq $-0xa, %r13
jb 0x420c43
movsbl %r11b, %r11d
imull $0xa, %ebx, %r13d
cmpl %r10d, %ebx
leal -0x30(%r13,%r11), %ebx
cmovgel %r10d, %ebx
addq %rax, %r12
movb $0x1, %sil
jmp 0x420c00
movzbl (%r12), %r10d
testb $0x1, (%r10,%rdx)
je 0x420a76
addq %rax, %r12
cmpq %r14, %r12
jb 0x420c30
jmp 0x420a76