#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void *getdigit(double *, int *);
scalar_t__ isnan(double);
int /*<<< orphan*/ snprintf(char *, size_t, char *);
int my_double2str(char *buf, size_t bufsize, double realvalue) {
  int precision = -1;
  char *bufpt;
  char prefix;
  char xtype = 0;
  int idx, exp, e2;
  double rounder;
  char flag_exp;
  char flag_rtz;
  char flag_dp;
  char flag_alternateform = 0;
  char flag_altform2 = 0;
  int nsd;
  if (bufsize < 8)
    return -1;
  if (precision < 0)
    precision = 20;
  if (precision > bufsize / 2 - 10)
    precision = bufsize / 2 - 10;
  if (realvalue < 0.0) {
    realvalue = -realvalue;
    prefix = '-';
  } else {
    prefix = 0;
  }
  if (xtype == 0 && precision > 0)
    precision--;
  for (idx = precision, rounder = 0.5; idx > 0; idx--, rounder *= 0.1) {
  }
  if (xtype == 1)
    realvalue += rounder;
  exp = 0;
  if (isnan(realvalue)) {
    snprintf(buf, bufsize, "NaN");
    return 0;
  }
  if (realvalue > 0.0) {
    while (realvalue >= 1e32 && exp <= 350) {
      realvalue *= 1e-32;
      exp += 32;
    }
    while (realvalue >= 1e8 && exp <= 350) {
      realvalue *= 1e-8;
      exp += 8;
    }
    while (realvalue >= 10.0 && exp <= 350) {
      realvalue *= 0.1;
      exp++;
    }
    while (realvalue < 1e-8) {
      realvalue *= 1e8;
      exp -= 8;
    }
    while (realvalue < 1.0) {
      realvalue *= 10.0;
      exp--;
    }
    if (exp > 350) {
      if (prefix == '-') {
        snprintf(buf, bufsize, "-Inf");
      } else {
        snprintf(buf, bufsize, "Inf");
      }
      return 0;
    }
  }
  bufpt = buf;
  flag_exp = xtype == 2;
  if (xtype != 1) {
    realvalue += rounder;
    if (realvalue >= 10.0) {
      realvalue *= 0.1;
      exp++;
    }
  }
  if (xtype == 0) {
    flag_rtz = !flag_alternateform;
    if (exp < -4 || exp > precision) {
      xtype = 2;
    } else {
      precision = precision - exp;
      xtype = 1;
    }
  } else {
    flag_rtz = 0;
  }
  if (xtype == 2) {
    e2 = 0;
  } else {
    e2 = exp;
  }
  nsd = 0;
  flag_dp = (precision > 0 ? 1 : 0) | flag_alternateform | flag_altform2;
  if (prefix) {
    *(bufpt++) = prefix;
  }
  if (e2 < 0) {
    *(bufpt++) = '0';
  } else {
    for (; e2 >= 0; e2--) {
      *(bufpt++) = getdigit(&realvalue, &nsd);
    }
  }
  if (flag_dp) {
    *(bufpt++) = '.';
  }
  for (e2++; e2 < 0; precision--, e2++) {
    assert(precision > 0);
    *(bufpt++) = '0';
  }
  while ((precision--) > 0) {
    *(bufpt++) = getdigit(&realvalue, &nsd);
  }
  if (flag_rtz && flag_dp) {
    while (bufpt[-1] == '0')
      *(--bufpt) = 0;
    assert(bufpt > buf);
    if (bufpt[-1] == '.') {
      if (flag_altform2) {
        *(bufpt++) = '0';
      } else {
        *(--bufpt) = 0;
      }
    }
  }
  if (flag_exp || xtype == 2) {
    *(bufpt++) = 'e';
    if (exp < 0) {
      *(bufpt++) = '-';
      exp = -exp;
    } else {
      *(bufpt++) = '+';
    }
    if (exp >= 100) {
      *(bufpt++) = (char)((exp / 100) + '0');
      exp %= 100;
    }
    *(bufpt++) = (char)(exp / 10 + '0');
    *(bufpt++) = (char)(exp % 10 + '0');
  }
  *bufpt = 0;
  return 0;
}


x86 assembly (clang, -O0):
<my_double2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movb   $0x0,-0x32(%rbp)
movb   $0x0,-0x4c(%rbp)
movb   $0x0,-0x4d(%rbp)
cmpq   $0x8,-0x18(%rbp)
jae    117f <my_double2str+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    186a <my_double2str+0x72a>
cmpl   $0x0,-0x24(%rbp)
jge    1190 <my_double2str+0x50>
movl   $0x14,-0x24(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x18(%rbp),%rcx
shr    $0x1,%rcx
sub    $0xa,%rcx
cmp    %rcx,%rax
jbe    11b8 <my_double2str+0x78>
mov    -0x18(%rbp),%rax
shr    $0x1,%rax
sub    $0xa,%rax
mov    %eax,-0x24(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f0 <my_double2str+0xb0>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x2d,-0x31(%rbp)
jmp    11f4 <my_double2str+0xb4>
movb   $0x0,-0x31(%rbp)
movsbl -0x32(%rbp),%eax
cmp    $0x0,%eax
jne    1214 <my_double2str+0xd4>
cmpl   $0x0,-0x24(%rbp)
jle    1214 <my_double2str+0xd4>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
movsd  0xdde(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x0,-0x38(%rbp)
jle    1256 <my_double2str+0x116>
jmp    1236 <my_double2str+0xf6>
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
movsd  0xde9(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1227 <my_double2str+0xe7>
movsbl -0x32(%rbp),%eax
cmp    $0x1,%eax
jne    1272 <my_double2str+0x132>
movsd  -0x48(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x3c(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <isnan@plt>
cmp    $0x0,%rax
je     12ad <my_double2str+0x16d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xda4(%rip),%rdx
call   1030 <snprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    186a <my_double2str+0x72a>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    14a1 <my_double2str+0x361>
jmp    12c4 <my_double2str+0x184>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xd35(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x55(%rbp)
jb     12ed <my_double2str+0x1ad>
cmpl   $0x15e,-0x3c(%rbp)
setle  %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    12fd <my_double2str+0x1bd>
jmp    131d <my_double2str+0x1dd>
movsd  0xd33(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x3c(%rbp)
jmp    12c4 <my_double2str+0x184>
jmp    1322 <my_double2str+0x1e2>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xcdf(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x56(%rbp)
jb     134b <my_double2str+0x20b>
cmpl   $0x15e,-0x3c(%rbp)
setle  %al
mov    %al,-0x56(%rbp)
mov    -0x56(%rbp),%al
test   $0x1,%al
jne    135b <my_double2str+0x21b>
jmp    137b <my_double2str+0x23b>
movsd  0xcbd(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
jmp    1322 <my_double2str+0x1e2>
jmp    1380 <my_double2str+0x240>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xc89(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x57(%rbp)
jb     13a9 <my_double2str+0x269>
cmpl   $0x15e,-0x3c(%rbp)
setle  %al
mov    %al,-0x57(%rbp)
mov    -0x57(%rbp),%al
test   $0x1,%al
jne    13b9 <my_double2str+0x279>
jmp    13d9 <my_double2str+0x299>
movsd  0xc6f(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1380 <my_double2str+0x240>
jmp    13de <my_double2str+0x29e>
movsd  0xc3a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1411 <my_double2str+0x2d1>
movsd  0xc17(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x3c(%rbp)
jmp    13de <my_double2str+0x29e>
jmp    1416 <my_double2str+0x2d6>
movsd  0xc0a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1449 <my_double2str+0x309>
movsd  0xbe7(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    1416 <my_double2str+0x2d6>
cmpl   $0x15e,-0x3c(%rbp)
jle    149c <my_double2str+0x35c>
movsbl -0x31(%rbp),%eax
cmp    $0x2d,%eax
jne    147c <my_double2str+0x33c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xbd2(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1490 <my_double2str+0x350>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xbba(%rip),%rdx
call   1030 <snprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    186a <my_double2str+0x72a>
jmp    14a1 <my_double2str+0x361>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movsbl -0x32(%rbp),%eax
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x49(%rbp)
movsbl -0x32(%rbp),%eax
cmp    $0x1,%eax
je     150e <my_double2str+0x3ce>
movsd  -0x48(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xb34(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1509 <my_double2str+0x3c9>
movsd  0xb3a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    150e <my_double2str+0x3ce>
movsbl -0x32(%rbp),%eax
cmp    $0x0,%eax
jne    155d <my_double2str+0x41d>
cmpb   $0x0,-0x4c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x4a(%rbp)
cmpl   $0xfffffffc,-0x3c(%rbp)
jl     1542 <my_double2str+0x402>
mov    -0x3c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    154b <my_double2str+0x40b>
movb   $0x2,-0x32(%rbp)
jmp    1558 <my_double2str+0x418>
mov    -0x24(%rbp),%eax
sub    -0x3c(%rbp),%eax
mov    %eax,-0x24(%rbp)
movb   $0x1,-0x32(%rbp)
jmp    1561 <my_double2str+0x421>
movb   $0x0,-0x4a(%rbp)
movsbl -0x32(%rbp),%eax
cmp    $0x2,%eax
jne    157a <my_double2str+0x43a>
movl   $0x0,-0x40(%rbp)
jmp    1580 <my_double2str+0x440>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x24(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovg  %ecx,%eax
movsbl -0x4c(%rbp),%ecx
or     %ecx,%eax
movsbl -0x4d(%rbp),%ecx
or     %ecx,%eax
mov    %al,-0x4b(%rbp)
cmpb   $0x0,-0x31(%rbp)
je     15c4 <my_double2str+0x484>
mov    -0x31(%rbp),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
cmpl   $0x0,-0x40(%rbp)
jge    15e5 <my_double2str+0x4a5>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x30,(%rax)
jmp    1627 <my_double2str+0x4e7>
jmp    15ea <my_double2str+0x4aa>
cmpl   $0x0,-0x40(%rbp)
jl     1622 <my_double2str+0x4e2>
lea    -0x20(%rbp),%rdi
lea    -0x54(%rbp),%rsi
call   1040 <getdigit@plt>
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x40(%rbp)
jmp    15ea <my_double2str+0x4aa>
jmp    1627 <my_double2str+0x4e7>
cmpb   $0x0,-0x4b(%rbp)
je     1643 <my_double2str+0x503>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x2e,(%rax)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    1690 <my_double2str+0x550>
cmpl   $0x0,-0x24(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x30,(%rax)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    164c <my_double2str+0x50c>
jmp    1695 <my_double2str+0x555>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
jle    16ce <my_double2str+0x58e>
lea    -0x20(%rbp),%rdi
lea    -0x54(%rbp),%rsi
call   1040 <getdigit@plt>
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    1695 <my_double2str+0x555>
movsbl -0x4a(%rbp),%eax
cmp    $0x0,%eax
je     177a <my_double2str+0x63a>
movsbl -0x4b(%rbp),%eax
cmp    $0x0,%eax
je     177a <my_double2str+0x63a>
jmp    16ed <my_double2str+0x5ad>
mov    -0x30(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x30,%eax
jne    1716 <my_double2str+0x5d6>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,-0x1(%rax)
jmp    16ed <my_double2str+0x5ad>
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x30(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2e,%eax
jne    1775 <my_double2str+0x635>
cmpb   $0x0,-0x4d(%rbp)
je     175d <my_double2str+0x61d>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x30,(%rax)
jmp    1770 <my_double2str+0x630>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,-0x1(%rax)
jmp    1775 <my_double2str+0x635>
jmp    177a <my_double2str+0x63a>
movsbl -0x49(%rbp),%eax
cmp    $0x0,%eax
jne    1794 <my_double2str+0x654>
movsbl -0x32(%rbp),%eax
cmp    $0x2,%eax
jne    185c <my_double2str+0x71c>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x65,(%rax)
cmpl   $0x0,-0x3c(%rbp)
jge    17cf <my_double2str+0x68f>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x2d,(%rax)
xor    %eax,%eax
sub    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    17e1 <my_double2str+0x6a1>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x2b,(%rax)
cmpl   $0x64,-0x3c(%rbp)
jl     181a <my_double2str+0x6da>
mov    -0x3c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x3c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x3c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_double2str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    $0xffffffff,%eax
cmp    $0x8,%rsi
jb     15d9 <my_double2str+0x499>
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rsi,%rax
shr    %rax
add    $0xfffffffffffffff6,%rax
cmp    $0x14,%rax
mov    $0x14,%edx
cmovb  %eax,%edx
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     118b <my_double2str+0x4b>
movapd %xmm0,%xmm1
jmp    1197 <my_double2str+0x57>
movapd 0xe6d(%rip),%xmm1
xorpd  %xmm0,%xmm1
mov    $0x2d,%r13d
cmovbe %ebp,%r13d
mov    %edx,%eax
sub    $0x1,%eax
cmovae %eax,%ebp
test   %ebp,%ebp
movapd %xmm0,0x30(%rsp)
je     11f4 <my_double2str+0xb4>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
mov    %edx,%esi
sub    %ecx,%esi
not    %ecx
add    %edx,%ecx
and    $0x7,%esi
je     11fe <my_double2str+0xbe>
xor    %edx,%edx
movsd  0xe3f(%rip),%xmm2
movsd  0xe3f(%rip),%xmm0
nopl   0x0(%rax)
mulsd  %xmm0,%xmm2
add    $0x1,%edx
cmp    %edx,%esi
jne    11e0 <my_double2str+0xa0>
sub    %edx,%eax
cmp    $0x7,%ecx
jae    120b <my_double2str+0xcb>
jmp    1248 <my_double2str+0x108>
movsd  0xe14(%rip),%xmm2
jmp    1248 <my_double2str+0x108>
movsd  0xe0a(%rip),%xmm2
cmp    $0x7,%ecx
jb     1248 <my_double2str+0x108>
add    $0xffffffff,%eax
movsd  0xe02(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
add    $0xfffffff8,%eax
cmp    $0xfffffffe,%eax
jb     1220 <my_double2str+0xe0>
movsd  %xmm2,0x40(%rsp)
movapd %xmm1,%xmm0
movapd %xmm1,0x10(%rsp)
call   1060 <isnan@plt>
test   %rax,%rax
je     1279 <my_double2str+0x139>
lea    0xde7(%rip),%rdx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <snprintf@plt>
jmp    15d7 <my_double2str+0x497>
xor    %r15d,%r15d
xorpd  %xmm0,%xmm0
movapd 0x10(%rsp),%xmm2
ucomisd %xmm0,%xmm2
jbe    13d3 <my_double2str+0x293>
xor    %eax,%eax
ucomisd 0xd86(%rip),%xmm2
jb     12c7 <my_double2str+0x187>
xor    %ecx,%ecx
movsd  0xd82(%rip),%xmm0
movsd  0xd72(%rip),%xmm1
xchg   %ax,%ax
mulsd  %xmm0,%xmm2
lea    0x20(%rcx),%eax
ucomisd %xmm1,%xmm2
jb     12c7 <my_double2str+0x187>
cmp    $0x13f,%ecx
mov    %eax,%ecx
jb     12b0 <my_double2str+0x170>
ucomisd 0xd61(%rip),%xmm2
jb     1308 <my_double2str+0x1c8>
cmp    $0x15e,%eax
ja     1308 <my_double2str+0x1c8>
movsd  0xd58(%rip),%xmm0
movsd  0xd48(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
mulsd  %xmm0,%xmm2
lea    0x8(%rax),%ecx
ucomisd %xmm1,%xmm2
jb     130a <my_double2str+0x1ca>
cmp    $0x157,%eax
mov    %ecx,%eax
jb     12f0 <my_double2str+0x1b0>
jmp    130a <my_double2str+0x1ca>
mov    %eax,%ecx
ucomisd 0xd2e(%rip),%xmm2
jb     134b <my_double2str+0x20b>
cmp    $0x15e,%ecx
ja     134b <my_double2str+0x20b>
movsd  0xcf4(%rip),%xmm0
movsd  0xd14(%rip),%xmm1
nopl   0x0(%rax)
mulsd  %xmm0,%xmm2
lea    0x1(%rcx),%r15d
ucomisd %xmm1,%xmm2
jb     134e <my_double2str+0x20e>
cmp    $0x15e,%ecx
mov    %r15d,%ecx
jb     1330 <my_double2str+0x1f0>
jmp    134e <my_double2str+0x20e>
mov    %ecx,%r15d
movsd  0xce2(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    137e <my_double2str+0x23e>
movsd  0xccc(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mulsd  %xmm1,%xmm2
add    $0xfffffff8,%r15d
ucomisd %xmm2,%xmm0
ja     1370 <my_double2str+0x230>
movsd  0xcc2(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    13ae <my_double2str+0x26e>
movsd  0xcac(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mulsd  %xmm1,%xmm2
add    $0xffffffff,%r15d
ucomisd %xmm2,%xmm0
ja     13a0 <my_double2str+0x260>
cmp    $0x15f,%r15d
jl     13d3 <my_double2str+0x293>
xorpd  %xmm0,%xmm0
ucomisd 0x30(%rsp),%xmm0
jbe    1595 <my_double2str+0x455>
lea    0xc86(%rip),%rdx
jmp    1269 <my_double2str+0x129>
movsd  0x40(%rsp),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
ucomisd 0xc55(%rip),%xmm0
movapd 0x30(%rsp),%xmm1
jb     1405 <my_double2str+0x2c5>
mulsd  0xc1d(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x1,%r15d
cmp    $0xfffffffc,%r15d
setl   %al
cmp    %r15d,%ebp
setl   %cl
xor    %r14d,%r14d
or     %al,%cl
mov    %cl,0x10(%rsp)
cmove  %r15d,%r14d
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
movl   $0x0,0x4(%rsp)
mov    %r12,%rbx
jbe    143d <my_double2str+0x2fd>
lea    0x1(%r12),%rbx
mov    %r13b,(%r12)
sub    %r14d,%ebp
test   %r14d,%r14d
js     14c0 <my_double2str+0x380>
mov    %ebp,0x30(%rsp)
add    $0x1,%r14d
lea    0x8(%rsp),%rbp
lea    0x4(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1040 <getdigit@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0xffffffff,%r14d
jne    1460 <my_double2str+0x320>
mov    $0xffffffff,%r14d
mov    0x30(%rsp),%ebp
test   %ebp,%ebp
jle    148c <my_double2str+0x34c>
movb   $0x2e,(%rbx)
add    $0x1,%rbx
cmp    $0xffffffff,%r14d
mov    %r12,0x28(%rsp)
je     14cd <my_double2str+0x38d>
add    $0x1,%r14d
mov    %ebp,%r12d
xchg   %ax,%ax
xor    %edi,%edi
test   %r12d,%r12d
setg   %dil
call   1050 <assert@plt>
movb   $0x30,(%rbx)
add    $0x1,%rbx
add    $0xffffffff,%r12d
inc    %r14d
jne    14a0 <my_double2str+0x360>
jmp    14d0 <my_double2str+0x390>
movb   $0x30,(%rbx)
add    $0x1,%rbx
test   %ebp,%ebp
jg     1485 <my_double2str+0x345>
jmp    148c <my_double2str+0x34c>
mov    %ebp,%r12d
mov    %ebp,%r14d
test   %r12d,%r12d
jle    150b <my_double2str+0x3cb>
add    $0x1,%r12d
lea    0x8(%rsp),%rbp
lea    0x4(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1040 <getdigit@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0xffffffff,%r12d
cmp    $0x1,%r12d
ja     14f0 <my_double2str+0x3b0>
test   %r14d,%r14d
jle    1559 <my_double2str+0x419>
lea    -0x1(%rbx),%rbp
cmpb   $0x30,-0x1(%rbx)
jne    1532 <my_double2str+0x3f2>
nopw   0x0(%rax,%rax,1)
movb   $0x0,0x0(%rbp)
cmpb   $0x30,-0x1(%rbp)
lea    -0x1(%rbp),%rbp
je     1520 <my_double2str+0x3e0>
lea    0x1(%rbp),%rbx
mov    0x28(%rsp),%rax
mov    0x10(%rsp),%r14b
xor    %edi,%edi
cmp    %rax,%rbx
seta   %dil
call   1050 <assert@plt>
cmpb   $0x2e,0x0(%rbp)
jne    155e <my_double2str+0x41e>
movb   $0x0,0x0(%rbp)
mov    %rbp,%rbx
jmp    155e <my_double2str+0x41e>
mov    0x10(%rsp),%r14b
test   %r14b,%r14b
je     15d4 <my_double2str+0x494>
movb   $0x65,(%rbx)
test   %r15d,%r15d
js     15a1 <my_double2str+0x461>
movb   $0x2b,0x1(%rbx)
cmp    $0x64,%r15d
jb     15ae <my_double2str+0x46e>
mov    %r15d,%eax
imul   $0x51eb851f,%rax,%rax
shr    $0x25,%rax
lea    0x30(%rax),%ecx
mov    %cl,0x2(%rbx)
add    $0x3,%rbx
imul   $0x64,%eax,%eax
sub    %eax,%r15d
jmp    15b2 <my_double2str+0x472>
lea    0xab9(%rip),%rdx
jmp    1269 <my_double2str+0x129>
movb   $0x2d,0x1(%rbx)
neg    %r15d
cmp    $0x64,%r15d
jae    1575 <my_double2str+0x435>
add    $0x2,%rbx
movzbl %r15b,%eax
imul   $0xcd,%eax,%ecx
shr    $0xb,%ecx
lea    0x30(%rcx),%edx
mov    %dl,(%rbx)
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
or     $0x30,%al
mov    %al,0x1(%rbx)
add    $0x2,%rbx
movb   $0x0,(%rbx)
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"NaN\00"
@.str.1 = [5 x i8] c"-Inf\00"
@.str.2 = [4 x i8] c"Inf\00"
define i32 @my_double2str(i8* %0, i64 %1, double %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca double
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca i8
%17 = alloca i8
%18 = alloca i8
%19 = alloca i8
%20 = alloca i8
%21 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store double %2, double* %7
store i32 -1, i32* %8
store i8 0, i8* %11
store i8 0, i8* %19
store i8 0, i8* %20
%22 = load i64, i64* %6
%23 = icmp ult i64 %22, 8
br i1 %23, label %24, label %25
24: ; preds = %3
store i32 -1, i32* %4
br label %376
25: ; preds = %3
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 20, i32* %8
br label %29
29: ; preds = %28, %25
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = load i64, i64* %6
%33 = udiv i64 %32, 2
%34 = sub i64 %33, 10
%35 = icmp ugt i64 %31, %34
br i1 %35, label %36, label %41
36: ; preds = %29
%37 = load i64, i64* %6
%38 = udiv i64 %37, 2
%39 = sub i64 %38, 10
%40 = trunc i64 %39 to i32
store i32 %40, i32* %8
br label %41
41: ; preds = %36, %29
%42 = load double, double* %7
%43 = fcmp olt double %42, 0.000000e+00
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load double, double* %7
%46 = fneg double %45
store double %46, double* %7
store i8 45, i8* %10
br label %48
47: ; preds = %41
store i8 0, i8* %10
br label %48
48: ; preds = %47, %44
%49 = load i8, i8* %11
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %48
%53 = load i32, i32* %8
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load i32, i32* %8
%57 = add nsw i32 %56, -1
store i32 %57, i32* %8
br label %58
58: ; preds = %55, %52, %48
%59 = load i32, i32* %8
store i32 %59, i32* %12
store double 5.000000e-01, double* %15
br label %60
60: ; preds = %64, %58
%61 = load i32, i32* %12
%62 = icmp sgt i32 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %60
br label %64
64: ; preds = %63
%65 = load i32, i32* %12
%66 = add nsw i32 %65, -1
store i32 %66, i32* %12
%67 = load double, double* %15
%68 = fmul double %67, 1.000000e-01
store double %68, double* %15
br label %60
69: ; preds = %60
%70 = load i8, i8* %11
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = load double, double* %15
%75 = load double, double* %7
%76 = fadd double %75, %74
store double %76, double* %7
br label %77
77: ; preds = %73, %69
store i32 0, i32* %13
%78 = load double, double* %7
%79 = call i64 @isnan(double %78)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %77
%82 = load i8*, i8** %5
%83 = load i64, i64* %6
%84 = call i32 @snprintf(i8* %82, i64 %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %376
85: ; preds = %77
%86 = load double, double* %7
%87 = fcmp ogt double %86, 0.000000e+00
br i1 %87, label %88, label %165
88: ; preds = %85
br label %89
89: ; preds = %97, %88
%90 = load double, double* %7
%91 = fcmp oge double %90, 1.000000e+32
br i1 %91, label %92, label %95
92: ; preds = %89
%93 = load i32, i32* %13
%94 = icmp sle i32 %93, 350
br label %95
95: ; preds = %92, %89
%96 = phi i1 [ false, %89 ], [ %94, %92 ]
br i1 %96, label %97, label %102
97: ; preds = %95
%98 = load double, double* %7
%99 = fmul double %98, 1.000000e-32
store double %99, double* %7
%100 = load i32, i32* %13
%101 = add nsw i32 %100, 32
store i32 %101, i32* %13
br label %89
102: ; preds = %95
br label %103
103: ; preds = %111, %102
%104 = load double, double* %7
%105 = fcmp oge double %104, 1.000000e+08
br i1 %105, label %106, label %109
106: ; preds = %103
%107 = load i32, i32* %13
%108 = icmp sle i32 %107, 350
br label %109
109: ; preds = %106, %103
%110 = phi i1 [ false, %103 ], [ %108, %106 ]
br i1 %110, label %111, label %116
111: ; preds = %109
%112 = load double, double* %7
%113 = fmul double %112, 1.000000e-08
store double %113, double* %7
%114 = load i32, i32* %13
%115 = add nsw i32 %114, 8
store i32 %115, i32* %13
br label %103
116: ; preds = %109
br label %117
117: ; preds = %125, %116
%118 = load double, double* %7
%119 = fcmp oge double %118, 1.000000e+01
br i1 %119, label %120, label %123
120: ; preds = %117
%121 = load i32, i32* %13
%122 = icmp sle i32 %121, 350
br label %123
123: ; preds = %120, %117
%124 = phi i1 [ false, %117 ], [ %122, %120 ]
br i1 %124, label %125, label %130
125: ; preds = %123
%126 = load double, double* %7
%127 = fmul double %126, 1.000000e-01
store double %127, double* %7
%128 = load i32, i32* %13
%129 = add nsw i32 %128, 1
store i32 %129, i32* %13
br label %117
130: ; preds = %123
br label %131
131: ; preds = %134, %130
%132 = load double, double* %7
%133 = fcmp olt double %132, 1.000000e-08
br i1 %133, label %134, label %139
134: ; preds = %131
%135 = load double, double* %7
%136 = fmul double %135, 1.000000e+08
store double %136, double* %7
%137 = load i32, i32* %13
%138 = sub nsw i32 %137, 8
store i32 %138, i32* %13
br label %131
139: ; preds = %131
br label %140
140: ; preds = %143, %139
%141 = load double, double* %7
%142 = fcmp olt double %141, 1.000000e+00
br i1 %142, label %143, label %148
143: ; preds = %140
%144 = load double, double* %7
%145 = fmul double %144, 1.000000e+01
store double %145, double* %7
%146 = load i32, i32* %13
%147 = add nsw i32 %146, -1
store i32 %147, i32* %13
br label %140
148: ; preds = %140
%149 = load i32, i32* %13
%150 = icmp sgt i32 %149, 350
br i1 %150, label %151, label %164
151: ; preds = %148
%152 = load i8, i8* %10
%153 = sext i8 %152 to i32
%154 = icmp eq i32 %153, 45
br i1 %154, label %155, label %159
155: ; preds = %151
%156 = load i8*, i8** %5
%157 = load i64, i64* %6
%158 = call i32 @snprintf(i8* %156, i64 %157, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %163
159: ; preds = %151
%160 = load i8*, i8** %5
%161 = load i64, i64* %6
%162 = call i32 @snprintf(i8* %160, i64 %161, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %163
163: ; preds = %159, %155
store i32 0, i32* %4
br label %376
164: ; preds = %148
br label %165
165: ; preds = %164, %85
%166 = load i8*, i8** %5
store i8* %166, i8** %9
%167 = load i8, i8* %11
%168 = sext i8 %167 to i32
%169 = icmp eq i32 %168, 2
%170 = zext i1 %169 to i32
%171 = trunc i32 %170 to i8
store i8 %171, i8* %16
%172 = load i8, i8* %11
%173 = sext i8 %172 to i32
%174 = icmp ne i32 %173, 1
br i1 %174, label %175, label %187
175: ; preds = %165
%176 = load double, double* %15
%177 = load double, double* %7
%178 = fadd double %177, %176
store double %178, double* %7
%179 = load double, double* %7
%180 = fcmp oge double %179, 1.000000e+01
br i1 %180, label %181, label %186
181: ; preds = %175
%182 = load double, double* %7
%183 = fmul double %182, 1.000000e-01
store double %183, double* %7
%184 = load i32, i32* %13
%185 = add nsw i32 %184, 1
store i32 %185, i32* %13
br label %186
186: ; preds = %181, %175
br label %187
187: ; preds = %186, %165
%188 = load i8, i8* %11
%189 = sext i8 %188 to i32
%190 = icmp eq i32 %189, 0
br i1 %190, label %191, label %209
191: ; preds = %187
%192 = load i8, i8* %19
%193 = icmp ne i8 %192, 0
%194 = xor i1 %193, true
%195 = zext i1 %194 to i32
%196 = trunc i32 %195 to i8
store i8 %196, i8* %17
%197 = load i32, i32* %13
%198 = icmp slt i32 %197, -4
br i1 %198, label %203, label %199
199: ; preds = %191
%200 = load i32, i32* %13
%201 = load i32, i32* %8
%202 = icmp sgt i32 %200, %201
br i1 %202, label %203, label %204
203: ; preds = %199, %191
store i8 2, i8* %11
br label %208
204: ; preds = %199
%205 = load i32, i32* %8
%206 = load i32, i32* %13
%207 = sub nsw i32 %205, %206
store i32 %207, i32* %8
store i8 1, i8* %11
br label %208
208: ; preds = %204, %203
br label %210
209: ; preds = %187
store i8 0, i8* %17
br label %210
210: ; preds = %209, %208
%211 = load i8, i8* %11
%212 = sext i8 %211 to i32
%213 = icmp eq i32 %212, 2
br i1 %213, label %214, label %215
214: ; preds = %210
store i32 0, i32* %14
br label %217
215: ; preds = %210
%216 = load i32, i32* %13
store i32 %216, i32* %14
br label %217
217: ; preds = %215, %214
store i32 0, i32* %21
%218 = load i32, i32* %8
%219 = icmp sgt i32 %218, 0
%220 = zext i1 %219 to i64
%221 = select i1 %219, i32 1, i32 0
%222 = load i8, i8* %19
%223 = sext i8 %222 to i32
%224 = or i32 %221, %223
%225 = load i8, i8* %20
%226 = sext i8 %225 to i32
%227 = or i32 %224, %226
%228 = trunc i32 %227 to i8
store i8 %228, i8* %18
%229 = load i8, i8* %10
%230 = icmp ne i8 %229, 0
br i1 %230, label %231, label %235
231: ; preds = %217
%232 = load i8, i8* %10
%233 = load i8*, i8** %9
%234 = getelementptr inbounds i8, i8* %233, i32 1
store i8* %234, i8** %9
store i8 %232, i8* %233
br label %235
235: ; preds = %231, %217
%236 = load i32, i32* %14
%237 = icmp slt i32 %236, 0
br i1 %237, label %238, label %241
238: ; preds = %235
%239 = load i8*, i8** %9
%240 = getelementptr inbounds i8, i8* %239, i32 1
store i8* %240, i8** %9
store i8 48, i8* %239
br label %254
241: ; preds = %235
br label %242
242: ; preds = %250, %241
%243 = load i32, i32* %14
%244 = icmp sge i32 %243, 0
br i1 %244, label %245, label %253
245: ; preds = %242
%246 = call i8* @getdigit(double* %7, i32* %21)
%247 = ptrtoint i8* %246 to i8
%248 = load i8*, i8** %9
%249 = getelementptr inbounds i8, i8* %248, i32 1
store i8* %249, i8** %9
store i8 %247, i8* %248
br label %250
250: ; preds = %245
%251 = load i32, i32* %14
%252 = add nsw i32 %251, -1
store i32 %252, i32* %14
br label %242
253: ; preds = %242
br label %254
254: ; preds = %253, %238
%255 = load i8, i8* %18
%256 = icmp ne i8 %255, 0
br i1 %256, label %257, label %260
257: ; preds = %254
%258 = load i8*, i8** %9
%259 = getelementptr inbounds i8, i8* %258, i32 1
store i8* %259, i8** %9
store i8 46, i8* %258
br label %260
260: ; preds = %257, %254
%261 = load i32, i32* %14
%262 = add nsw i32 %261, 1
store i32 %262, i32* %14
br label %263
263: ; preds = %273, %260
%264 = load i32, i32* %14
%265 = icmp slt i32 %264, 0
br i1 %265, label %266, label %278
266: ; preds = %263
%267 = load i32, i32* %8
%268 = icmp sgt i32 %267, 0
%269 = zext i1 %268 to i32
%270 = call i32 @assert(i32 %269)
%271 = load i8*, i8** %9
%272 = getelementptr inbounds i8, i8* %271, i32 1
store i8* %272, i8** %9
store i8 48, i8* %271
br label %273
273: ; preds = %266
%274 = load i32, i32* %8
%275 = add nsw i32 %274, -1
store i32 %275, i32* %8
%276 = load i32, i32* %14
%277 = add nsw i32 %276, 1
store i32 %277, i32* %14
br label %263
278: ; preds = %263
br label %279
279: ; preds = %283, %278
%280 = load i32, i32* %8
%281 = add nsw i32 %280, -1
store i32 %281, i32* %8
%282 = icmp sgt i32 %280, 0
br i1 %282, label %283, label %288
283: ; preds = %279
%284 = call i8* @getdigit(double* %7, i32* %21)
%285 = ptrtoint i8* %284 to i8
%286 = load i8*, i8** %9
%287 = getelementptr inbounds i8, i8* %286, i32 1
store i8* %287, i8** %9
store i8 %285, i8* %286
br label %279
288: ; preds = %279
%289 = load i8, i8* %17
%290 = sext i8 %289 to i32
%291 = icmp ne i32 %290, 0
br i1 %291, label %292, label %328
292: ; preds = %288
%293 = load i8, i8* %18
%294 = sext i8 %293 to i32
%295 = icmp ne i32 %294, 0
br i1 %295, label %296, label %328
296: ; preds = %292
br label %297
297: ; preds = %303, %296
%298 = load i8*, i8** %9
%299 = getelementptr inbounds i8, i8* %298, i64 -1
%300 = load i8, i8* %299
%301 = sext i8 %300 to i32
%302 = icmp eq i32 %301, 48
br i1 %302, label %303, label %306
303: ; preds = %297
%304 = load i8*, i8** %9
%305 = getelementptr inbounds i8, i8* %304, i32 -1
store i8* %305, i8** %9
store i8 0, i8* %305
br label %297
306: ; preds = %297
%307 = load i8*, i8** %9
%308 = load i8*, i8** %5
%309 = icmp ugt i8* %307, %308
%310 = zext i1 %309 to i32
%311 = call i32 @assert(i32 %310)
%312 = load i8*, i8** %9
%313 = getelementptr inbounds i8, i8* %312, i64 -1
%314 = load i8, i8* %313
%315 = sext i8 %314 to i32
%316 = icmp eq i32 %315, 46
br i1 %316, label %317, label %327
317: ; preds = %306
%318 = load i8, i8* %20
%319 = icmp ne i8 %318, 0
br i1 %319, label %320, label %323
320: ; preds = %317
%321 = load i8*, i8** %9
%322 = getelementptr inbounds i8, i8* %321, i32 1
store i8* %322, i8** %9
store i8 48, i8* %321
br label %326
323: ; preds = %317
%324 = load i8*, i8** %9
%325 = getelementptr inbounds i8, i8* %324, i32 -1
store i8* %325, i8** %9
store i8 0, i8* %325
br label %326
326: ; preds = %323, %320
br label %327
327: ; preds = %326, %306
br label %328
328: ; preds = %327, %292, %288
%329 = load i8, i8* %16
%330 = sext i8 %329 to i32
%331 = icmp ne i32 %330, 0
br i1 %331, label %336, label %332
332: ; preds = %328
%333 = load i8, i8* %11
%334 = sext i8 %333 to i32
%335 = icmp eq i32 %334, 2
br i1 %335, label %336, label %374
336: ; preds = %332, %328
%337 = load i8*, i8** %9
%338 = getelementptr inbounds i8, i8* %337, i32 1
store i8* %338, i8** %9
store i8 101, i8* %337
%339 = load i32, i32* %13
%340 = icmp slt i32 %339, 0
br i1 %340, label %341, label %346
341: ; preds = %336
%342 = load i8*, i8** %9
%343 = getelementptr inbounds i8, i8* %342, i32 1
store i8* %343, i8** %9
store i8 45, i8* %342
%344 = load i32, i32* %13
%345 = sub nsw i32 0, %344
store i32 %345, i32* %13
br label %349
346: ; preds = %336
%347 = load i8*, i8** %9
%348 = getelementptr inbounds i8, i8* %347, i32 1
store i8* %348, i8** %9
store i8 43, i8* %347
br label %349
349: ; preds = %346, %341
%350 = load i32, i32* %13
%351 = icmp sge i32 %350, 100
br i1 %351, label %352, label %361
352: ; preds = %349
%353 = load i32, i32* %13
%354 = sdiv i32 %353, 100
%355 = add nsw i32 %354, 48
%356 = trunc i32 %355 to i8
%357 = load i8*, i8** %9
%358 = getelementptr inbounds i8, i8* %357, i32 1
store i8* %358, i8** %9
store i8 %356, i8* %357
%359 = load i32, i32* %13
%360 = srem i32 %359, 100
store i32 %360, i32* %13
br label %361
361: ; preds = %352, %349
%362 = load i32, i32* %13
%363 = sdiv i32 %362, 10
%364 = add nsw i32 %363, 48
%365 = trunc i32 %364 to i8
%366 = load i8*, i8** %9
%367 = getelementptr inbounds i8, i8* %366, i32 1
store i8* %367, i8** %9
store i8 %365, i8* %366
%368 = load i32, i32* %13
%369 = srem i32 %368, 10
%370 = add nsw i32 %369, 48
%371 = trunc i32 %370 to i8
%372 = load i8*, i8** %9
%373 = getelementptr inbounds i8, i8* %372, i32 1
store i8* %373, i8** %9
store i8 %371, i8* %372
br label %374
374: ; preds = %361, %332
%375 = load i8*, i8** %9
store i8 0, i8* %375
store i32 0, i32* %4
br label %376
376: ; preds = %374, %163, %81, %24
%377 = load i32, i32* %4
ret i32 %377
}

LLVM IR (-O2):
@.str = [4 x i8] c"NaN\00"
@.str.1 = [5 x i8] c"-Inf\00"
@.str.2 = [4 x i8] c"Inf\00"
define i32 @my_double2str(i8* %0, i64 %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = icmp ult i64 %1, 8
br i1 %7, label %246, label %8
8: ; preds = %3
%9 = lshr i64 %1, 1
%10 = add nsw i64 %9, -10
%11 = icmp ult i64 %10, 20
%12 = select i1 %11, i64 %10, i64 20
%13 = trunc i64 %12 to i32
%14 = fcmp olt double %2, 0.000000e+00
%15 = fneg double %2
%16 = select i1 %14, double %15, double %2
%17 = select i1 %14, i8 45, i8 0
%18 = icmp eq i32 %13, 0
%19 = add nsw i32 %13, -1
%20 = select i1 %18, i32 0, i32 %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %57, label %22
22: ; preds = %8
%23 = icmp ne i32 %19, 0
%24 = zext i1 %23 to i32
%25 = sub nsw i32 %13, %24
%26 = xor i32 %24, -1
%27 = add nsw i32 %26, %13
%28 = and i32 %25, 7
%29 = icmp eq i32 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %22, %30
%31 = phi double [ %35, %30 ], [ 5.000000e-01, %22 ]
%32 = phi i32 [ %34, %30 ], [ %19, %22 ]
%33 = phi i32 [ %36, %30 ], [ 0, %22 ]
%34 = add nsw i32 %32, -1
%35 = fmul double %31, 1.000000e-01
%36 = add i32 %33, 1
%37 = icmp eq i32 %36, %28
br i1 %37, label %38, label %30
38: ; preds = %30, %22
%39 = phi double [ 5.000000e-01, %22 ], [ %35, %30 ]
%40 = phi i32 [ %19, %22 ], [ %34, %30 ]
%41 = phi double [ undef, %22 ], [ %35, %30 ]
%42 = icmp ult i32 %27, 7
br i1 %42, label %57, label %43
43: ; preds = %38, %43
%44 = phi double [ %54, %43 ], [ %39, %38 ]
%45 = phi i32 [ %53, %43 ], [ %40, %38 ]
%46 = fmul double %44, 1.000000e-01
%47 = fmul double %46, 1.000000e-01
%48 = fmul double %47, 1.000000e-01
%49 = fmul double %48, 1.000000e-01
%50 = fmul double %49, 1.000000e-01
%51 = fmul double %50, 1.000000e-01
%52 = fmul double %51, 1.000000e-01
%53 = add nsw i32 %45, -8
%54 = fmul double %52, 1.000000e-01
%55 = add i32 %45, -9
%56 = icmp ult i32 %55, -2
br i1 %56, label %43, label %57
57: ; preds = %38, %43, %8
%58 = phi double [ 5.000000e-01, %8 ], [ %41, %38 ], [ %54, %43 ]
%59 = tail call i64 @isnan(double %16)
%60 = icmp eq i64 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %57
%62 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %246
63: ; preds = %57
%64 = fcmp ogt double %16, 0.000000e+00
br i1 %64, label %65, label %132
65: ; preds = %63
%66 = fcmp ult double %16, 1.000000e+32
br i1 %66, label %67, label %73
67: ; preds = %73, %65
%68 = phi double [ %16, %65 ], [ %76, %73 ]
%69 = phi i32 [ 0, %65 ], [ %77, %73 ]
%70 = fcmp oge double %68, 1.000000e+08
%71 = icmp ult i32 %69, 351
%72 = select i1 %70, i1 %71, i1 false
br i1 %72, label %87, label %81
73: ; preds = %65, %73
%74 = phi i32 [ %77, %73 ], [ 0, %65 ]
%75 = phi double [ %76, %73 ], [ %16, %65 ]
%76 = fmul double %75, 1.000000e-32
%77 = add nuw nsw i32 %74, 32
%78 = fcmp oge double %76, 1.000000e+32
%79 = icmp ult i32 %74, 319
%80 = select i1 %78, i1 %79, i1 false
br i1 %80, label %73, label %67
81: ; preds = %87, %67
%82 = phi double [ %68, %67 ], [ %90, %87 ]
%83 = phi i32 [ %69, %67 ], [ %91, %87 ]
%84 = fcmp oge double %82, 1.000000e+01
%85 = icmp ult i32 %83, 351
%86 = select i1 %84, i1 %85, i1 false
br i1 %86, label %99, label %95
87: ; preds = %67, %87
%88 = phi i32 [ %91, %87 ], [ %69, %67 ]
%89 = phi double [ %90, %87 ], [ %68, %67 ]
%90 = fmul double %89, 1.000000e-08
%91 = add nuw nsw i32 %88, 8
%92 = fcmp oge double %90, 1.000000e+08
%93 = icmp ult i32 %88, 343
%94 = select i1 %92, i1 %93, i1 false
br i1 %94, label %87, label %81
95: ; preds = %99, %81
%96 = phi double [ %82, %81 ], [ %102, %99 ]
%97 = phi i32 [ %83, %81 ], [ %103, %99 ]
%98 = fcmp olt double %96, 1.000000e-08
br i1 %98, label %107, label %113
99: ; preds = %81, %99
%100 = phi i32 [ %103, %99 ], [ %83, %81 ]
%101 = phi double [ %102, %99 ], [ %82, %81 ]
%102 = fmul double %101, 1.000000e-01
%103 = add nuw nsw i32 %100, 1
%104 = fcmp oge double %102, 1.000000e+01
%105 = icmp ult i32 %100, 350
%106 = select i1 %104, i1 %105, i1 false
br i1 %106, label %99, label %95
107: ; preds = %95, %107
%108 = phi i32 [ %111, %107 ], [ %97, %95 ]
%109 = phi double [ %110, %107 ], [ %96, %95 ]
%110 = fmul double %109, 1.000000e+08
%111 = add nsw i32 %108, -8
%112 = fcmp olt double %110, 1.000000e-08
br i1 %112, label %107, label %113
113: ; preds = %107, %95
%114 = phi double [ %96, %95 ], [ %110, %107 ]
%115 = phi i32 [ %97, %95 ], [ %111, %107 ]
%116 = fcmp olt double %114, 1.000000e+00
br i1 %116, label %117, label %123
117: ; preds = %113, %117
%118 = phi i32 [ %121, %117 ], [ %115, %113 ]
%119 = phi double [ %120, %117 ], [ %114, %113 ]
%120 = fmul double %119, 1.000000e+01
%121 = add nsw i32 %118, -1
%122 = fcmp olt double %120, 1.000000e+00
br i1 %122, label %117, label %123
123: ; preds = %117, %113
%124 = phi double [ %114, %113 ], [ %120, %117 ]
%125 = phi i32 [ %115, %113 ], [ %121, %117 ]
%126 = icmp sgt i32 %125, 350
br i1 %126, label %127, label %132
127: ; preds = %123
br i1 %14, label %128, label %130
128: ; preds = %127
%129 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %246
130: ; preds = %127
%131 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %246
132: ; preds = %63, %123
%133 = phi double [ %124, %123 ], [ %16, %63 ]
%134 = phi i32 [ %125, %123 ], [ 0, %63 ]
%135 = fadd double %58, %133
store double %135, double* %4
%136 = fcmp ult double %135, 1.000000e+01
br i1 %136, label %140, label %137
137: ; preds = %132
%138 = fmul double %135, 1.000000e-01
store double %138, double* %4
%139 = add nsw i32 %134, 1
br label %140
140: ; preds = %137, %132
%141 = phi i32 [ %139, %137 ], [ %134, %132 ]
%142 = icmp slt i32 %141, -4
%143 = icmp slt i32 %20, %141
%144 = select i1 %142, i1 true, i1 %143
%145 = select i1 %144, i32 0, i32 %141
%146 = sub nsw i32 %20, %145
store i32 0, i32* %5
%147 = icmp sgt i32 %146, 0
br i1 %14, label %148, label %150
148: ; preds = %140
%149 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %17, i8* %0
br label %150
150: ; preds = %148, %140
%151 = phi i8* [ %149, %148 ], [ %0, %140 ]
%152 = icmp slt i32 %145, 0
br i1 %152, label %153, label %155
153: ; preds = %150
%154 = getelementptr inbounds i8, i8* %151, i64 1
store i8 48, i8* %151
br label %164
155: ; preds = %150, %155
%156 = phi i8* [ %161, %155 ], [ %151, %150 ]
%157 = phi i32 [ %162, %155 ], [ %145, %150 ]
%158 = call i8* @getdigit(double* %4, i32* %5)
%159 = ptrtoint i8* %158 to i64
%160 = trunc i64 %159 to i8
%161 = getelementptr inbounds i8, i8* %156, i64 1
store i8 %160, i8* %156
%162 = add nsw i32 %157, -1
%163 = icmp eq i32 %157, 0
br i1 %163, label %164, label %155
164: ; preds = %155, %153
%165 = phi i32 [ %145, %153 ], [ -1, %155 ]
%166 = phi i8* [ %154, %153 ], [ %161, %155 ]
br i1 %147, label %167, label %169
167: ; preds = %164
%168 = getelementptr inbounds i8, i8* %166, i64 1
store i8 46, i8* %166
br label %169
169: ; preds = %167, %164
%170 = phi i8* [ %168, %167 ], [ %166, %164 ]
%171 = icmp eq i32 %165, -1
br i1 %171, label %172, label %176
172: ; preds = %176, %169
%173 = phi i8* [ %170, %169 ], [ %184, %176 ]
%174 = phi i32 [ %146, %169 ], [ %185, %176 ]
%175 = icmp sgt i32 %174, 0
br i1 %175, label %187, label %196
176: ; preds = %169, %176
%177 = phi i32 [ %185, %176 ], [ %146, %169 ]
%178 = phi i8* [ %184, %176 ], [ %170, %169 ]
%179 = phi i32 [ %180, %176 ], [ %165, %169 ]
%180 = add nuw i32 %179, 1
%181 = icmp sgt i32 %177, 0
%182 = zext i1 %181 to i32
%183 = call i32 @assert(i32 %182)
%184 = getelementptr inbounds i8, i8* %178, i64 1
store i8 48, i8* %178
%185 = add nsw i32 %177, -1
%186 = icmp eq i32 %180, -1
br i1 %186, label %172, label %176
187: ; preds = %172, %187
%188 = phi i32 [ %190, %187 ], [ %174, %172 ]
%189 = phi i8* [ %194, %187 ], [ %173, %172 ]
%190 = add nsw i32 %188, -1
%191 = call i8* @getdigit(double* %4, i32* %5)
%192 = ptrtoint i8* %191 to i64
%193 = trunc i64 %192 to i8
%194 = getelementptr inbounds i8, i8* %189, i64 1
store i8 %193, i8* %189
%195 = icmp ugt i32 %188, 1
br i1 %195, label %187, label %196
196: ; preds = %187, %172
%197 = phi i8* [ %173, %172 ], [ %194, %187 ]
br i1 %147, label %198, label %216
198: ; preds = %196
%199 = getelementptr inbounds i8, i8* %197, i64 -1
%200 = load i8, i8* %199
%201 = icmp eq i8 %200, 48
br i1 %201, label %202, label %207
202: ; preds = %198, %202
%203 = phi i8* [ %204, %202 ], [ %199, %198 ]
store i8 0, i8* %203
%204 = getelementptr inbounds i8, i8* %203, i64 -1
%205 = load i8, i8* %204
%206 = icmp eq i8 %205, 48
br i1 %206, label %202, label %207
207: ; preds = %202, %198
%208 = phi i8* [ %197, %198 ], [ %203, %202 ]
%209 = phi i8* [ %199, %198 ], [ %204, %202 ]
%210 = icmp ugt i8* %208, %0
%211 = zext i1 %210 to i32
%212 = call i32 @assert(i32 %211)
%213 = load i8, i8* %209
%214 = icmp eq i8 %213, 46
br i1 %214, label %215, label %216
215: ; preds = %207
store i8 0, i8* %209
br label %216
216: ; preds = %207, %215, %196
%217 = phi i8* [ %209, %215 ], [ %208, %207 ], [ %197, %196 ]
br i1 %144, label %218, label %244
218: ; preds = %216
%219 = getelementptr inbounds i8, i8* %217, i64 1
store i8 101, i8* %217
%220 = icmp slt i32 %141, 0
br i1 %220, label %221, label %223
221: ; preds = %218
store i8 45, i8* %219
%222 = sub nsw i32 0, %141
br label %224
223: ; preds = %218
store i8 43, i8* %219
br label %224
224: ; preds = %223, %221
%225 = phi i32 [ %222, %221 ], [ %141, %223 ]
%226 = getelementptr inbounds i8, i8* %217, i64 2
%227 = icmp ugt i32 %225, 99
br i1 %227, label %228, label %234
228: ; preds = %224
%229 = udiv i32 %225, 100
%230 = trunc i32 %229 to i8
%231 = add i8 %230, 48
%232 = getelementptr inbounds i8, i8* %217, i64 3
store i8 %231, i8* %226
%233 = urem i32 %225, 100
br label %234
234: ; preds = %228, %224
%235 = phi i32 [ %233, %228 ], [ %225, %224 ]
%236 = phi i8* [ %232, %228 ], [ %226, %224 ]
%237 = trunc i32 %235 to i8
%238 = udiv i8 %237, 10
%239 = add nuw nsw i8 %238, 48
%240 = getelementptr inbounds i8, i8* %236, i64 1
store i8 %239, i8* %236
%241 = urem i8 %237, 10
%242 = or i8 %241, 48
%243 = getelementptr inbounds i8, i8* %236, i64 2
store i8 %242, i8* %240
br label %244
244: ; preds = %216, %234
%245 = phi i8* [ %243, %234 ], [ %217, %216 ]
store i8 0, i8* %245
br label %246
246: ; preds = %128, %130, %3, %244, %61
%247 = phi i32 [ 0, %61 ], [ 0, %244 ], [ -1, %3 ], [ 0, %130 ], [ 0, %128 ]
ret i32 %247
}