// File: /workspace/github_cpp_makefile_star2_O1/cphinton42[P]hinton-language/src/stb/stb_sprintf.h
// Function: stbsp__real_to_str(char const**, unsigned int*, char*, int*, double, unsigned int)
static stbsp__int32 stbsp__real_to_str( char const * * start, stbsp__uint32 * len, char *out, stbsp__int32 * decimal_pos, double value, stbsp__uint32 frac_digits )
{
  double d;
  stbsp__int64 bits = 0;
  stbsp__int32 expo, e, ng, tens;

  d = value;
  STBSP__COPYFP(bits,d);
  expo = (stbsp__int32) ((bits >> 52) & 2047);
  ng = (stbsp__int32)(bits >> 63);
  if (ng) d=-d;

  if ( expo == 2047 ) // is nan or inf?
  {
    *start = (bits&((((stbsp__uint64)1)<<52)-1)) ? "NaN" : "Inf";
    *decimal_pos =  STBSP__SPECIAL;
    *len = 3;
    return ng;
  } 

  if ( expo == 0 ) // is zero or denormal
  {
    if ((bits<<1)==0) // do zero
    {
      *decimal_pos = 1; 
      *start = out;
      out[0] = '0'; *len = 1;
      return ng;
    }
    // find the right expo for denormals
    {
      stbsp__int64 v = ((stbsp__uint64)1)<<51;
      while ((bits&v)==0) { --expo; v >>= 1; }
    }
  }

  // find the decimal exponent as well as the decimal bits of the value
  {
    double ph,pl;

    // log10 estimate - very specifically tweaked to hit or undershoot by no more than 1 of log10 of all expos 1..2046
    tens=expo-1023; tens = (tens<0)?((tens*617)/2048):(((tens*1233)/4096)+1);

    // move the significant bits into position and stick them into an int 
    stbsp__raise_to_power10( &ph, &pl, d, 18-tens );

    // get full as much precision from double-double as possible
    stbsp__ddtoS64( bits, ph,pl );

    // check if we undershot
    if ( ((stbsp__uint64)bits) >= stbsp__tento19th ) ++tens; 
  }

  // now do the rounding in integer land
  frac_digits = ( frac_digits & 0x80000000 ) ? ( (frac_digits&0x7ffffff) + 1 ) : ( tens + frac_digits );
  if ( ( frac_digits < 24 ) )
  {
    stbsp__uint32 dg = 1; if ((stbsp__uint64)bits >= stbsp__powten[9] ) dg=10; while( (stbsp__uint64)bits >= stbsp__powten[dg] ) { ++dg; if (dg==20) goto noround; }
    if ( frac_digits < dg )
    {
      stbsp__uint64 r;
      // add 0.5 at the right position and round
      e = dg - frac_digits;
      if ( (stbsp__uint32)e >= 24 ) goto noround;
      r = stbsp__powten[e];
      bits = bits + (r/2);
      if ( (stbsp__uint64)bits >= stbsp__powten[dg] ) ++tens;
      bits /= r;
    } 
    noround:;
  }

  // kill long trailing runs of zeros
  if ( bits )
  {
    stbsp__uint32 n;
    for(;;) { if ( bits<=0xffffffff ) break; if (bits%1000) goto donez; bits/=1000; }
    n = (stbsp__uint32)bits;
    while ((n%1000)==0) n/=1000;
    bits=n;
    donez:;
  }

  // convert to string
  out += 64;
  e = 0; 
  for(;;)
  {
    stbsp__uint32 n;
    char * o = out-8;
    // do the conversion in chunks of U32s (avoid most 64-bit divides, worth it, constant denomiators be damned)
    if (bits>=100000000) { n = (stbsp__uint32)( bits % 100000000);  bits /= 100000000; } else {n = (stbsp__uint32)bits; bits = 0; }
    while(n) { out-=2; *(stbsp__uint16*)out=*(stbsp__uint16*)&stbsp__digitpair[(n%100)*2]; n/=100; e+=2; }
    if (bits==0) { if ((e) && (out[0]=='0')) { ++out; --e; } break; }
    while( out!=o ) { *--out ='0'; ++e; }
  }
  
  *decimal_pos = tens;
  *start = out;
  *len = e;
  return ng;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r13
movq %xmm0, %rax
movq %rax, %rdx
shrq $0x34, %rdx
andl $0x7ff, %edx            # imm = 0x7FF
je 0xc28a
cmpl $0x7ff, %edx            # imm = 0x7FF
jne 0xc2ce
movq %rax, %rdx
shlq $0xc, %rdx
leaq 0x5f6f(%rip), %rdx      # 0x121da
leaq 0x5f64(%rip), %r8       # 0x121d6
cmoveq %rdx, %r8
movq %r8, (%rdi)
movl $0x7000, (%rcx)         # imm = 0x7000
movl $0x3, %r15d
jmp 0xc910
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xc2af
jp 0xc2af
movl $0x1, (%rcx)
movq %r13, (%rdi)
movb $0x30, (%r13)
movl $0x1, %r15d
jmp 0xc910
xorl %edx, %edx
btq $0x33, %rax
jb 0xc2ce
movabsq $0x8000000000000, %r9   # imm = 0x8000000000000
xorl %edx, %edx
decl %edx
shrq %r9
testq %rax, %r9
je 0xc2c4
andpd 0x48ca(%rip), %xmm0     # 0x10ba0
leal -0x3ff(%rdx), %r9d
cmpl $0x3fe, %edx            # imm = 0x3FE
jg 0xc2ff
imull $0x269, %r9d, %edx      # imm = 0x269
leal 0x7ff(%rdx), %r15d
testl %edx, %edx
cmovnsl %edx, %r15d
sarl $0xb, %r15d
jmp 0xc30d
imull $0x4d1, %r9d, %r15d     # imm = 0x4D1
shrl $0xc, %r15d
incl %r15d
movl $0x12, %edx
subl %r15d, %edx
cmpl $0x16, %edx
movq %rax, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
ja 0xc39b
movl %edx, %eax
leaq 0x442e(%rip), %rcx      # 0x10760
movsd (%rcx,%rax,8), %xmm1
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movq %xmm0, %rax
movabsq $0x7ffffffff8000000, %rcx # imm = 0x7FFFFFFFF8000000
andq %rax, %rcx
movq %rcx, %xmm3
movq %xmm1, %rax
andq $-0x8000000, %rax       # imm = 0xF8000000
movq %rax, %xmm4
subsd %xmm3, %xmm0
subsd %xmm4, %xmm1
movapd %xmm3, %xmm5
mulsd %xmm4, %xmm5
subsd %xmm2, %xmm5
mulsd %xmm1, %xmm3
addsd %xmm5, %xmm3
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
mulsd %xmm0, %xmm1
addsd %xmm4, %xmm1
movapd %xmm2, %xmm0
jmp 0xc6a4
movl %edx, %ebp
negl %ebp
cmovsl %edx, %ebp
imull $0x2c9, %ebp, %edx      # imm = 0x2C9
shrl $0xe, %edx
cmpl $0xd, %edx
movl $0xd, %r11d
cmovll %edx, %r11d
imull $-0x17, %r11d, %edx
addl %ebp, %edx
cmpl $0x13, %r15d
jl 0xc458
testl %edx, %edx
je 0xc4e9
movslq %edx, %r9
leaq 0x4446(%rip), %rdx      # 0x10820
movsd -0x8(%rdx,%r9,8), %xmm2
movq %xmm0, %rdx
movapd %xmm0, %xmm3
leaq 0x44df(%rip), %r10      # 0x108d0
movsd -0x8(%r10,%r9,8), %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm2, %xmm0
movabsq $0x7ffffffff8000000, %r9 # imm = 0x7FFFFFFFF8000000
andq %rdx, %r9
movq %r9, %xmm4
movq %xmm2, %rdx
andq $-0x8000000, %rdx       # imm = 0xF8000000
movq %rdx, %xmm5
subsd %xmm4, %xmm3
subsd %xmm5, %xmm2
movapd %xmm4, %xmm6
mulsd %xmm5, %xmm6
subsd %xmm0, %xmm6
mulsd %xmm2, %xmm4
addsd %xmm6, %xmm4
mulsd %xmm3, %xmm5
addsd %xmm4, %xmm5
mulsd %xmm3, %xmm2
addsd %xmm5, %xmm2
addsd %xmm2, %xmm1
jmp 0xc4ed
testl %edx, %edx
je 0xc57f
cmpl $0x16, %edx
movl $0x16, %ebx
cmovll %edx, %ebx
movslq %ebx, %r9
leaq 0x42eb(%rip), %r14      # 0x10760
movsd (%r14,%r9,8), %xmm1
movapd %xmm0, %xmm3
mulsd %xmm1, %xmm3
movq %xmm0, %r9
movabsq $0x7ffffffff8000000, %r10 # imm = 0x7FFFFFFFF8000000
andq %r9, %r10
movq %r10, %xmm2
movq %xmm1, %r9
andq $-0x8000000, %r9        # imm = 0xF8000000
movq %r9, %xmm4
subsd %xmm2, %xmm0
subsd %xmm4, %xmm1
movapd %xmm2, %xmm5
mulsd %xmm4, %xmm5
subsd %xmm3, %xmm5
mulsd %xmm1, %xmm2
addsd %xmm5, %xmm2
mulsd %xmm0, %xmm4
addsd %xmm2, %xmm4
mulsd %xmm0, %xmm1
addsd %xmm4, %xmm1
cmpl $0x17, %edx
jge 0xc585
movapd %xmm3, %xmm0
jmp 0xc601
xorpd %xmm1, %xmm1
cmpl $0x17, %ebp
jb 0xc6a4
movapd %xmm0, %xmm2
addsd %xmm1, %xmm2
movl %r11d, %eax
leaq 0x4478(%rip), %rcx      # 0x10980
movq -0x8(%rcx,%rax,8), %xmm3
movq %xmm2, %rcx
movapd %xmm2, %xmm4
subsd %xmm0, %xmm4
subsd %xmm4, %xmm1
movq $-0x8000000, %rdx       # imm = 0xF8000000
andq %rdx, %rcx
movq %rcx, %xmm4
movq %xmm3, %rcx
andq %rdx, %rcx
movq %rcx, %xmm5
movapd %xmm2, %xmm0
mulsd %xmm3, %xmm0
movapd %xmm2, %xmm6
subsd %xmm4, %xmm6
mulsd %xmm3, %xmm1
subsd %xmm5, %xmm3
movapd %xmm4, %xmm7
mulsd %xmm5, %xmm7
subsd %xmm0, %xmm7
mulsd %xmm3, %xmm4
addsd %xmm7, %xmm4
mulsd %xmm6, %xmm5
addsd %xmm4, %xmm5
mulsd %xmm6, %xmm3
leaq 0x4476(%rip), %rcx      # 0x109f0
jmp 0xc68e
xorpd %xmm1, %xmm1
jmp 0xc601
subl %ebx, %edx
movapd %xmm3, %xmm2
addsd %xmm1, %xmm2
movslq %edx, %rdx
movq (%r14,%rdx,8), %xmm4
movq %xmm2, %rdx
movapd %xmm2, %xmm0
subsd %xmm3, %xmm0
subsd %xmm0, %xmm1
movq $-0x8000000, %rsi       # imm = 0xF8000000
andq %rsi, %rdx
movq %rdx, %xmm3
movq %xmm4, %rdx
andq %rsi, %rdx
movq %rdx, %xmm5
movapd %xmm2, %xmm0
mulsd %xmm4, %xmm0
subsd %xmm3, %xmm2
mulsd %xmm4, %xmm1
subsd %xmm5, %xmm4
movapd %xmm3, %xmm6
mulsd %xmm5, %xmm6
subsd %xmm0, %xmm6
mulsd %xmm4, %xmm3
addsd %xmm6, %xmm3
mulsd %xmm2, %xmm5
addsd %xmm3, %xmm5
mulsd %xmm2, %xmm4
addsd %xmm5, %xmm4
addsd %xmm4, %xmm1
cmpl $0x17, %ebp
jb 0xc6a4
movapd %xmm0, %xmm2
addsd %xmm1, %xmm2
movl %r11d, %eax
leaq 0x4444(%rip), %rcx      # 0x10a60
movq -0x8(%rcx,%rax,8), %xmm3
movq %xmm2, %rcx
movapd %xmm2, %xmm4
subsd %xmm0, %xmm4
subsd %xmm4, %xmm1
movq $-0x8000000, %rdx       # imm = 0xF8000000
andq %rdx, %rcx
movq %rcx, %xmm4
movq %xmm3, %rcx
andq %rdx, %rcx
movq %rcx, %xmm5
movapd %xmm2, %xmm0
mulsd %xmm3, %xmm0
movapd %xmm2, %xmm6
subsd %xmm4, %xmm6
mulsd %xmm3, %xmm1
subsd %xmm5, %xmm3
movapd %xmm4, %xmm7
mulsd %xmm5, %xmm7
subsd %xmm0, %xmm7
mulsd %xmm3, %xmm4
addsd %xmm7, %xmm4
mulsd %xmm6, %xmm5
addsd %xmm4, %xmm5
mulsd %xmm6, %xmm3
leaq 0x4442(%rip), %rcx      # 0x10ad0
mulsd -0x8(%rcx,%rax,8), %xmm2
addsd %xmm5, %xmm3
addsd %xmm1, %xmm2
addsd %xmm3, %xmm2
movapd %xmm2, %xmm1
movapd %xmm0, %xmm2
addsd %xmm1, %xmm2
movapd %xmm2, %xmm3
subsd %xmm0, %xmm3
cvttsd2si %xmm2, %rax
subsd %xmm3, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movapd %xmm2, %xmm3
subsd %xmm0, %xmm3
movapd %xmm3, %xmm4
subsd %xmm2, %xmm4
movapd %xmm3, %xmm5
subsd %xmm4, %xmm5
subsd %xmm5, %xmm2
addsd %xmm0, %xmm4
subsd %xmm4, %xmm2
addsd %xmm3, %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %rbp
addq %rax, %rbp
movabsq $0xde0b6b3a763ffff, %rax # imm = 0xDE0B6B3A763FFFF
xorl %ecx, %ecx
cmpq %rax, %rbp
seta %cl
addl %ecx, %r15d
movl %r8d, %ecx
andl $0x7ffffff, %ecx        # imm = 0x7FFFFFF
incl %ecx
leal (%r15,%r8), %eax
testl %r8d, %r8d
cmovsl %ecx, %eax
cmpl $0x17, %eax
ja 0xc78f
xorl %ecx, %ecx
cmpq $0x3b9aca00, %rbp       # imm = 0x3B9ACA00
setae %cl
leal (%rcx,%rcx,8), %edx
leaq 0x3f82(%rip), %rcx      # 0x106c0
leaq (%rcx,%rdx,8), %r8
addq $0x8, %r8
notl %edx
movq (%r8), %rsi
cmpq %rsi, %rbp
jb 0xc75d
decl %edx
addq $0x8, %r8
cmpl $-0x14, %edx
jne 0xc748
jmp 0xc78f
movl %edx, %r8d
negl %r8d
cmpl %r8d, %eax
jae 0xc78f
addl %edx, %eax
negl %eax
cmpl $0x17, %eax
ja 0xc78f
movl %eax, %eax
movq (%rcx,%rax,8), %rcx
movq %rcx, %rax
shrq %rax
addq %rbp, %rax
cmpq %rsi, %rax
sbbl $-0x1, %r15d
xorl %edx, %edx
divq %rcx
movq %rax, %rbp
testq %rbp, %rbp
movq %rdi, 0x8(%rsp)
movq %r15, (%rsp)
je 0xc82c
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, %rbp
jge 0xc7b5
movq %rbp, %rdx
jmp 0xc7fd
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
movabsq $0x1cac083126e978d5, %rsi # imm = 0x1CAC083126E978D5
movabsq $0x4189374bc6a7ef, %r8  # imm = 0x4189374BC6A7EF
movq %rbp, %rax
shrq $0x3, %rax
mulq %rcx
movq %rbp, %rax
imulq %rsi, %rax
rorq $0x3, %rax
cmpq %r8, %rax
ja 0xc82c
shrq $0x4, %rdx
shrq $0x23, %rbp
cmpl $0x7c, %ebp
movq %rdx, %rbp
ja 0xc7d3
imull $0x26e978d5, %edx, %eax # imm = 0x26E978D5
rorl $0x3, %eax
cmpl $0x418937, %eax         # imm = 0x418937
ja 0xc82a
movl %edx, %eax
imulq $0x10624dd3, %rax, %rdx # imm = 0x10624DD3
shrq $0x26, %rdx
imull $0x26e978d5, %edx, %eax # imm = 0x26E978D5
rorl $0x3, %eax
cmpl $0x418938, %eax         # imm = 0x418938
jb 0xc80d
movl %edx, %ebp
addq $0x40, %r13
xorl %r15d, %r15d
movabsq $-0x543388ee7b9e3103, %r12 # imm = 0xABCC77118461CEFD
leaq 0x5cac(%rip), %r14      # 0x124f0
cmpq $0x5f5e100, %rbp        # imm = 0x5F5E100
jl 0xc863
movq %rbp, %rax
mulq %r12
shrq $0x1a, %rdx
imulq $0x5f5e100, %rdx, %rax  # imm = 0x5F5E100
subq %rax, %rbp
jmp 0xc865
xorl %edx, %edx
movq %rbp, %rax
movq %rdx, %rbp
xorl %ebx, %ebx
testl %eax, %eax
je 0xc89e
movl %eax, %ecx
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
shrq $0x25, %rcx
imull $0x64, %ecx, %edx
movl %eax, %esi
subl %edx, %esi
movzwl (%r14,%rsi,2), %edx
movw %dx, -0x2(%r13,%rbx)
addq $-0x2, %rbx
cmpl $0x63, %eax
movl %ecx, %eax
ja 0xc871
subl %ebx, %r15d
testq %rbp, %rbp
je 0xc8d7
cmpq $-0x8, %rbx
je 0xc8c9
leaq -0x8(%r13), %rdi
leaq 0x8(%rbx), %rdx
movl $0x30, %esi
callq 0x3060
addl %ebx, %r15d
addl $0x8, %r15d
movq $-0x8, %rbx
addq %rbx, %r13
testq %rbp, %rbp
jne 0xc844
jmp 0xc8f3
addq %rbx, %r13
testl %r15d, %r15d
je 0xc8ee
cmpb $0x30, (%r13)
jne 0xc8cc
incq %r13
decl %r15d
jmp 0xc8cc
xorl %r15d, %r15d
jmp 0xc8cc
movq 0x10(%rsp), %rax
movq (%rsp), %rcx
movl %ecx, (%rax)
movq 0x8(%rsp), %rax
movq %r13, (%rax)
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rsi
movl %r15d, (%rsi)
sarq $0x3f, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq