// File: /workspace/github_cpp_makefile_star2_O3/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 %rcx, %r14
movq %rdx, %r13
movq %xmm0, %r11
movq %r11, %rax
shrq $0x34, %rax
andl $0x7ff, %eax            # imm = 0x7FF
je 0xc0e4
cmpl $0x7ff, %eax            # imm = 0x7FF
jne 0xc12c
movq %r11, %rax
shlq $0xc, %rax
leaq 0x6091(%rip), %rax      # 0x12155
leaq 0x6086(%rip), %rcx      # 0x12151
cmoveq %rax, %rcx
movq %rcx, (%rdi)
movl $0x7000, (%r14)         # imm = 0x7000
movl $0x3, %r15d
jmp 0xc76c
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xc10a
jp 0xc10a
movl $0x1, (%r14)
movq %r13, (%rdi)
movb $0x30, (%r13)
movl $0x1, %r15d
jmp 0xc76c
movl $0xfffffc01, %ecx       # imm = 0xFFFFFC01
btq $0x33, %r11
jb 0xc139
movabsq $0x8000000000000, %rcx  # imm = 0x8000000000000
xorl %eax, %eax
decl %eax
shrq %rcx
testq %r11, %rcx
je 0xc122
leal -0x3ff(%rax), %ecx
cmpl $0x3fe, %eax            # imm = 0x3FE
jg 0xc149
imull $0xfffffd97, %ecx, %r15d # imm = 0xFFFFFD97
shrl $0xb, %r15d
negl %r15d
jmp 0xc157
imull $0x4d1, %ecx, %r15d     # imm = 0x4D1
shrl $0xc, %r15d
incl %r15d
andpd 0x4a41(%rip), %xmm0     # 0x10ba0
movl $0x12, %eax
subl %r15d, %eax
cmpl $0x16, %eax
ja 0xc1de
movl %eax, %eax
leaq 0x45eb(%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 0xc4de
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
imull $0x2c9, %ecx, %edx      # imm = 0x2C9
shrl $0xe, %edx
cmpl $0xd, %edx
movl $0xd, %eax
cmovbl %edx, %eax
imull $-0x17, %eax, %edx
addl %ecx, %edx
cmpl $0x13, %r15d
jl 0xc298
testl %edx, %edx
je 0xc329
movslq %edx, %r9
leaq 0x4606(%rip), %rdx      # 0x10820
movsd -0x8(%rdx,%r9,8), %xmm2
movq %xmm0, %rdx
movapd %xmm0, %xmm3
leaq 0x469f(%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 0xc32d
testl %edx, %edx
je 0xc3be
cmpl $0x16, %edx
movl $0x16, %ebp
cmovll %edx, %ebp
movslq %ebp, %r9
leaq 0x44ab(%rip), %rbx      # 0x10760
movsd (%rbx,%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 0xc3c4
movapd %xmm3, %xmm0
jmp 0xc43c
xorpd %xmm1, %xmm1
cmpl $0x17, %ecx
jb 0xc4de
movapd %xmm0, %xmm2
addsd %xmm1, %xmm2
movapd %xmm2, %xmm4
subsd %xmm0, %xmm4
movl %eax, %eax
leaq 0x4631(%rip), %rcx      # 0x10980
movq -0x8(%rcx,%rax,8), %xmm3
movq %xmm2, %rcx
subsd %xmm4, %xmm1
movq $-0x8000000, %rdx       # imm = 0xF8000000
andq %rdx, %rcx
movq %rcx, %xmm4
movq %xmm3, %rcx
movapd %xmm2, %xmm0
mulsd %xmm3, %xmm0
andq %rdx, %rcx
movq %rcx, %xmm5
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 0x4637(%rip), %rcx      # 0x109f0
jmp 0xc4c8
xorpd %xmm1, %xmm1
jmp 0xc43c
subl %ebp, %edx
movapd %xmm3, %xmm2
addsd %xmm1, %xmm2
movapd %xmm2, %xmm0
subsd %xmm3, %xmm0
movq (%rbx,%rdx,8), %xmm4
movq %xmm2, %rdx
subsd %xmm0, %xmm1
movq $-0x8000000, %r9        # imm = 0xF8000000
andq %r9, %rdx
movq %rdx, %xmm3
movq %xmm4, %rdx
movapd %xmm2, %xmm0
mulsd %xmm4, %xmm0
andq %r9, %rdx
movq %rdx, %xmm5
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, %ecx
jb 0xc4de
movapd %xmm0, %xmm2
addsd %xmm1, %xmm2
movapd %xmm2, %xmm4
subsd %xmm0, %xmm4
movl %eax, %eax
leaq 0x4602(%rip), %rcx      # 0x10a60
movq -0x8(%rcx,%rax,8), %xmm3
movq %xmm2, %rcx
subsd %xmm4, %xmm1
movq $-0x8000000, %rdx       # imm = 0xF8000000
andq %rdx, %rcx
movq %rcx, %xmm4
movq %xmm3, %rcx
movapd %xmm2, %xmm0
mulsd %xmm3, %xmm0
andq %rdx, %rcx
movq %rcx, %xmm5
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 0x4608(%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, %rcx
addq %rax, %rcx
movabsq $0xde0b6b3a763ffff, %rax # imm = 0xDE0B6B3A763FFFF
xorl %edx, %edx
cmpq %rax, %rcx
seta %dl
addl %edx, %r15d
movl %r8d, %edx
andl $0x7ffffff, %edx        # imm = 0x7FFFFFF
incl %edx
leal (%r15,%r8), %eax
testl %r8d, %r8d
cmovsl %edx, %eax
cmpl $0x17, %eax
ja 0xc5ce
xorl %edx, %edx
cmpq $0x3b9aca00, %rcx       # imm = 0x3B9ACA00
setae %dl
leal (%rdx,%rdx,8), %r9d
leaq 0x4147(%rip), %rdx      # 0x106c0
leaq (%rdx,%r9,8), %r8
addq $0x8, %r8
notl %r9d
movq (%r8), %r10
cmpq %r10, %rcx
jb 0xc59b
decl %r9d
addq $0x8, %r8
cmpl $-0x14, %r9d
jne 0xc584
jmp 0xc5ce
movl %r9d, %r8d
negl %r8d
cmpl %r8d, %eax
jae 0xc5ce
addl %r9d, %eax
negl %eax
cmpl $0x17, %eax
ja 0xc5ce
movl %eax, %eax
movq (%rdx,%rax,8), %r8
movq %r8, %rax
shrq %rax
addq %rcx, %rax
cmpq %r10, %rax
sbbl $-0x1, %r15d
xorl %edx, %edx
divq %r8
movq %rax, %rcx
testq %rcx, %rcx
movq %r11, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %r14, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq %r15, (%rsp)
je 0xc5ff
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, %rcx
jge 0xc603
movq %rcx, %rdx
jmp 0xc64b
xorl %ecx, %ecx
jmp 0xc67a
movabsq $0x20c49ba5e353f7cf, %r9 # imm = 0x20C49BA5E353F7CF
movabsq $0x1cac083126e978d5, %r10 # imm = 0x1CAC083126E978D5
movabsq $0x4189374bc6a7ef, %r8  # imm = 0x4189374BC6A7EF
movq %rcx, %rax
shrq $0x3, %rax
mulq %r9
movq %rcx, %rax
imulq %r10, %rax
rorq $0x3, %rax
cmpq %r8, %rax
ja 0xc67a
shrq $0x4, %rdx
shrq $0x23, %rcx
cmpl $0x7c, %ecx
movq %rdx, %rcx
ja 0xc621
imull $0x26e978d5, %edx, %eax # imm = 0x26E978D5
rorl $0x3, %eax
cmpl $0x418937, %eax         # imm = 0x418937
ja 0xc678
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 0xc65b
movl %edx, %ecx
leaq 0x40(%r13), %r12
addq $0x3e, %r13
leaq 0x5de7(%rip), %rbx      # 0x12470
xorl %r15d, %r15d
cmpq $0x5f5e100, %rcx        # imm = 0x5F5E100
jl 0xc6bd
movq %rcx, %rax
movabsq $-0x543388ee7b9e3103, %rdx # imm = 0xABCC77118461CEFD
mulq %rdx
movq %rdx, %rbp
shrq $0x1a, %rbp
imulq $0x5f5e100, %rbp, %rax  # imm = 0x5F5E100
subq %rax, %rcx
jne 0xc6c6
xorl %r14d, %r14d
jmp 0xc703
movl $0x0, %ebp
testl %ecx, %ecx
je 0xc732
xorl %r14d, %r14d
movl %ecx, %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
shrq $0x25, %rax
imull $0x64, %eax, %edx
movl %ecx, %esi
subl %edx, %esi
movzwl (%rbx,%rsi,2), %edx
movw %dx, (%r13,%r14)
addq $-0x2, %r14
cmpl $0x63, %ecx
movl %eax, %ecx
ja 0xc6c9
testq %rbp, %rbp
je 0xc72d
movl %r15d, %r15d
subq %r14, %r15
cmpq $-0x8, %r14
je 0xc71d
leaq -0x8(%r12), %rdi
leaq 0x8(%r14), %rdx
movl $0x30, %esi
callq 0x3060
addl %r14d, %r15d
addl $0x8, %r15d
addq $-0x8, %r12
addq $-0x8, %r13
movq %rbp, %rcx
jmp 0xc68c
subl %r14d, %r15d
jmp 0xc735
xorl %r14d, %r14d
addq %r14, %r12
testl %r15d, %r15d
movq 0x20(%rsp), %r11
movq 0x18(%rsp), %rsi
je 0xc756
cmpb $0x30, (%r12)
jne 0xc759
incq %r12
decl %r15d
jmp 0xc759
xorl %r15d, %r15d
movq 0x10(%rsp), %rax
movq (%rsp), %rcx
movl %ecx, (%rax)
movq 0x8(%rsp), %rax
movq %r12, (%rax)
movl %r15d, (%rsi)
sarq $0x3f, %r11
movl %r11d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq