#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*/ strcpy(char *, 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)) {
    strcpy(buf, "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 == '-') {
        strcpy(buf, "-Inf");
      } else {
        strcpy(buf, "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    185e <my_double2str+0x71e>
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     12a9 <my_double2str+0x169>
mov    -0x10(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    185e <my_double2str+0x71e>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1495 <my_double2str+0x355>
jmp    12c0 <my_double2str+0x180>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xd39(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x55(%rbp)
jb     12e9 <my_double2str+0x1a9>
cmpl   $0x15e,-0x3c(%rbp)
setle  %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    12f9 <my_double2str+0x1b9>
jmp    1319 <my_double2str+0x1d9>
movsd  0xd37(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x3c(%rbp)
jmp    12c0 <my_double2str+0x180>
jmp    131e <my_double2str+0x1de>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xce3(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x56(%rbp)
jb     1347 <my_double2str+0x207>
cmpl   $0x15e,-0x3c(%rbp)
setle  %al
mov    %al,-0x56(%rbp)
mov    -0x56(%rbp),%al
test   $0x1,%al
jne    1357 <my_double2str+0x217>
jmp    1377 <my_double2str+0x237>
movsd  0xcc1(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
jmp    131e <my_double2str+0x1de>
jmp    137c <my_double2str+0x23c>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xc8d(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x57(%rbp)
jb     13a5 <my_double2str+0x265>
cmpl   $0x15e,-0x3c(%rbp)
setle  %al
mov    %al,-0x57(%rbp)
mov    -0x57(%rbp),%al
test   $0x1,%al
jne    13b5 <my_double2str+0x275>
jmp    13d5 <my_double2str+0x295>
movsd  0xc73(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    137c <my_double2str+0x23c>
jmp    13da <my_double2str+0x29a>
movsd  0xc3e(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    140d <my_double2str+0x2cd>
movsd  0xc1b(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x3c(%rbp)
jmp    13da <my_double2str+0x29a>
jmp    1412 <my_double2str+0x2d2>
movsd  0xc0e(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1445 <my_double2str+0x305>
movsd  0xbeb(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    1412 <my_double2str+0x2d2>
cmpl   $0x15e,-0x3c(%rbp)
jle    1490 <my_double2str+0x350>
movsbl -0x31(%rbp),%eax
cmp    $0x2d,%eax
jne    1474 <my_double2str+0x334>
mov    -0x10(%rbp),%rdi
lea    0xbda(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1484 <my_double2str+0x344>
mov    -0x10(%rbp),%rdi
lea    0xbc6(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    185e <my_double2str+0x71e>
jmp    1495 <my_double2str+0x355>
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     1502 <my_double2str+0x3c2>
movsd  -0x48(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xb40(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     14fd <my_double2str+0x3bd>
movsd  0xb46(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1502 <my_double2str+0x3c2>
movsbl -0x32(%rbp),%eax
cmp    $0x0,%eax
jne    1551 <my_double2str+0x411>
cmpb   $0x0,-0x4c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x4a(%rbp)
cmpl   $0xfffffffc,-0x3c(%rbp)
jl     1536 <my_double2str+0x3f6>
mov    -0x3c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    153f <my_double2str+0x3ff>
movb   $0x2,-0x32(%rbp)
jmp    154c <my_double2str+0x40c>
mov    -0x24(%rbp),%eax
sub    -0x3c(%rbp),%eax
mov    %eax,-0x24(%rbp)
movb   $0x1,-0x32(%rbp)
jmp    1555 <my_double2str+0x415>
movb   $0x0,-0x4a(%rbp)
movsbl -0x32(%rbp),%eax
cmp    $0x2,%eax
jne    156e <my_double2str+0x42e>
movl   $0x0,-0x40(%rbp)
jmp    1574 <my_double2str+0x434>
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     15b8 <my_double2str+0x478>
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    15d9 <my_double2str+0x499>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x30,(%rax)
jmp    161b <my_double2str+0x4db>
jmp    15de <my_double2str+0x49e>
cmpl   $0x0,-0x40(%rbp)
jl     1616 <my_double2str+0x4d6>
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    15de <my_double2str+0x49e>
jmp    161b <my_double2str+0x4db>
cmpb   $0x0,-0x4b(%rbp)
je     1637 <my_double2str+0x4f7>
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    1684 <my_double2str+0x544>
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    1640 <my_double2str+0x500>
jmp    1689 <my_double2str+0x549>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
jle    16c2 <my_double2str+0x582>
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    1689 <my_double2str+0x549>
movsbl -0x4a(%rbp),%eax
cmp    $0x0,%eax
je     176e <my_double2str+0x62e>
movsbl -0x4b(%rbp),%eax
cmp    $0x0,%eax
je     176e <my_double2str+0x62e>
jmp    16e1 <my_double2str+0x5a1>
mov    -0x30(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x30,%eax
jne    170a <my_double2str+0x5ca>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,-0x1(%rax)
jmp    16e1 <my_double2str+0x5a1>
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    1769 <my_double2str+0x629>
cmpb   $0x0,-0x4d(%rbp)
je     1751 <my_double2str+0x611>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x30,(%rax)
jmp    1764 <my_double2str+0x624>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,-0x1(%rax)
jmp    1769 <my_double2str+0x629>
jmp    176e <my_double2str+0x62e>
movsbl -0x49(%rbp),%eax
cmp    $0x0,%eax
jne    1788 <my_double2str+0x648>
movsbl -0x32(%rbp),%eax
cmp    $0x2,%eax
jne    1850 <my_double2str+0x710>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x65,(%rax)
cmpl   $0x0,-0x3c(%rbp)
jge    17c3 <my_double2str+0x683>
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    17d5 <my_double2str+0x695>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x2b,(%rax)
cmpl   $0x64,-0x3c(%rbp)
jl     180e <my_double2str+0x6ce>
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    %rdi,%r12
shr    %rsi
add    $0xfffffffffffffff6,%rsi
cmp    $0x14,%rsi
mov    $0x14,%edx
cmovb  %esi,%edx
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1185 <my_double2str+0x45>
movapd %xmm0,%xmm1
jmp    1191 <my_double2str+0x51>
movapd 0xe73(%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  0xe45(%rip),%xmm2
movsd  0xe45(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   (%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     1276 <my_double2str+0x136>
lea    0xde7(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcpy@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 0xd89(%rip),%xmm2
jb     12c7 <my_double2str+0x187>
xor    %ecx,%ecx
movsd  0xd85(%rip),%xmm0
movsd  0xd75(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
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),%rsi
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),%rsi
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 %373
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 %84
81: ; preds = %77
%82 = load i8*, i8** %5
%83 = call i32 @strcpy(i8* %82, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %373
84: ; preds = %77
%85 = load double, double* %7
%86 = fcmp ogt double %85, 0.000000e+00
br i1 %86, label %87, label %162
87: ; preds = %84
br label %88
88: ; preds = %96, %87
%89 = load double, double* %7
%90 = fcmp oge double %89, 1.000000e+32
br i1 %90, label %91, label %94
91: ; preds = %88
%92 = load i32, i32* %13
%93 = icmp sle i32 %92, 350
br label %94
94: ; preds = %91, %88
%95 = phi i1 [ false, %88 ], [ %93, %91 ]
br i1 %95, label %96, label %101
96: ; preds = %94
%97 = load double, double* %7
%98 = fmul double %97, 1.000000e-32
store double %98, double* %7
%99 = load i32, i32* %13
%100 = add nsw i32 %99, 32
store i32 %100, i32* %13
br label %88
101: ; preds = %94
br label %102
102: ; preds = %110, %101
%103 = load double, double* %7
%104 = fcmp oge double %103, 1.000000e+08
br i1 %104, label %105, label %108
105: ; preds = %102
%106 = load i32, i32* %13
%107 = icmp sle i32 %106, 350
br label %108
108: ; preds = %105, %102
%109 = phi i1 [ false, %102 ], [ %107, %105 ]
br i1 %109, label %110, label %115
110: ; preds = %108
%111 = load double, double* %7
%112 = fmul double %111, 1.000000e-08
store double %112, double* %7
%113 = load i32, i32* %13
%114 = add nsw i32 %113, 8
store i32 %114, i32* %13
br label %102
115: ; preds = %108
br label %116
116: ; preds = %124, %115
%117 = load double, double* %7
%118 = fcmp oge double %117, 1.000000e+01
br i1 %118, label %119, label %122
119: ; preds = %116
%120 = load i32, i32* %13
%121 = icmp sle i32 %120, 350
br label %122
122: ; preds = %119, %116
%123 = phi i1 [ false, %116 ], [ %121, %119 ]
br i1 %123, label %124, label %129
124: ; preds = %122
%125 = load double, double* %7
%126 = fmul double %125, 1.000000e-01
store double %126, double* %7
%127 = load i32, i32* %13
%128 = add nsw i32 %127, 1
store i32 %128, i32* %13
br label %116
129: ; preds = %122
br label %130
130: ; preds = %133, %129
%131 = load double, double* %7
%132 = fcmp olt double %131, 1.000000e-08
br i1 %132, label %133, label %138
133: ; preds = %130
%134 = load double, double* %7
%135 = fmul double %134, 1.000000e+08
store double %135, double* %7
%136 = load i32, i32* %13
%137 = sub nsw i32 %136, 8
store i32 %137, i32* %13
br label %130
138: ; preds = %130
br label %139
139: ; preds = %142, %138
%140 = load double, double* %7
%141 = fcmp olt double %140, 1.000000e+00
br i1 %141, label %142, label %147
142: ; preds = %139
%143 = load double, double* %7
%144 = fmul double %143, 1.000000e+01
store double %144, double* %7
%145 = load i32, i32* %13
%146 = add nsw i32 %145, -1
store i32 %146, i32* %13
br label %139
147: ; preds = %139
%148 = load i32, i32* %13
%149 = icmp sgt i32 %148, 350
br i1 %149, label %150, label %161
150: ; preds = %147
%151 = load i8, i8* %10
%152 = sext i8 %151 to i32
%153 = icmp eq i32 %152, 45
br i1 %153, label %154, label %157
154: ; preds = %150
%155 = load i8*, i8** %5
%156 = call i32 @strcpy(i8* %155, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %160
157: ; preds = %150
%158 = load i8*, i8** %5
%159 = call i32 @strcpy(i8* %158, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %160
160: ; preds = %157, %154
store i32 0, i32* %4
br label %373
161: ; preds = %147
br label %162
162: ; preds = %161, %84
%163 = load i8*, i8** %5
store i8* %163, i8** %9
%164 = load i8, i8* %11
%165 = sext i8 %164 to i32
%166 = icmp eq i32 %165, 2
%167 = zext i1 %166 to i32
%168 = trunc i32 %167 to i8
store i8 %168, i8* %16
%169 = load i8, i8* %11
%170 = sext i8 %169 to i32
%171 = icmp ne i32 %170, 1
br i1 %171, label %172, label %184
172: ; preds = %162
%173 = load double, double* %15
%174 = load double, double* %7
%175 = fadd double %174, %173
store double %175, double* %7
%176 = load double, double* %7
%177 = fcmp oge double %176, 1.000000e+01
br i1 %177, label %178, label %183
178: ; preds = %172
%179 = load double, double* %7
%180 = fmul double %179, 1.000000e-01
store double %180, double* %7
%181 = load i32, i32* %13
%182 = add nsw i32 %181, 1
store i32 %182, i32* %13
br label %183
183: ; preds = %178, %172
br label %184
184: ; preds = %183, %162
%185 = load i8, i8* %11
%186 = sext i8 %185 to i32
%187 = icmp eq i32 %186, 0
br i1 %187, label %188, label %206
188: ; preds = %184
%189 = load i8, i8* %19
%190 = icmp ne i8 %189, 0
%191 = xor i1 %190, true
%192 = zext i1 %191 to i32
%193 = trunc i32 %192 to i8
store i8 %193, i8* %17
%194 = load i32, i32* %13
%195 = icmp slt i32 %194, -4
br i1 %195, label %200, label %196
196: ; preds = %188
%197 = load i32, i32* %13
%198 = load i32, i32* %8
%199 = icmp sgt i32 %197, %198
br i1 %199, label %200, label %201
200: ; preds = %196, %188
store i8 2, i8* %11
br label %205
201: ; preds = %196
%202 = load i32, i32* %8
%203 = load i32, i32* %13
%204 = sub nsw i32 %202, %203
store i32 %204, i32* %8
store i8 1, i8* %11
br label %205
205: ; preds = %201, %200
br label %207
206: ; preds = %184
store i8 0, i8* %17
br label %207
207: ; preds = %206, %205
%208 = load i8, i8* %11
%209 = sext i8 %208 to i32
%210 = icmp eq i32 %209, 2
br i1 %210, label %211, label %212
211: ; preds = %207
store i32 0, i32* %14
br label %214
212: ; preds = %207
%213 = load i32, i32* %13
store i32 %213, i32* %14
br label %214
214: ; preds = %212, %211
store i32 0, i32* %21
%215 = load i32, i32* %8
%216 = icmp sgt i32 %215, 0
%217 = zext i1 %216 to i64
%218 = select i1 %216, i32 1, i32 0
%219 = load i8, i8* %19
%220 = sext i8 %219 to i32
%221 = or i32 %218, %220
%222 = load i8, i8* %20
%223 = sext i8 %222 to i32
%224 = or i32 %221, %223
%225 = trunc i32 %224 to i8
store i8 %225, i8* %18
%226 = load i8, i8* %10
%227 = icmp ne i8 %226, 0
br i1 %227, label %228, label %232
228: ; preds = %214
%229 = load i8, i8* %10
%230 = load i8*, i8** %9
%231 = getelementptr inbounds i8, i8* %230, i32 1
store i8* %231, i8** %9
store i8 %229, i8* %230
br label %232
232: ; preds = %228, %214
%233 = load i32, i32* %14
%234 = icmp slt i32 %233, 0
br i1 %234, label %235, label %238
235: ; preds = %232
%236 = load i8*, i8** %9
%237 = getelementptr inbounds i8, i8* %236, i32 1
store i8* %237, i8** %9
store i8 48, i8* %236
br label %251
238: ; preds = %232
br label %239
239: ; preds = %247, %238
%240 = load i32, i32* %14
%241 = icmp sge i32 %240, 0
br i1 %241, label %242, label %250
242: ; preds = %239
%243 = call i8* @getdigit(double* %7, i32* %21)
%244 = ptrtoint i8* %243 to i8
%245 = load i8*, i8** %9
%246 = getelementptr inbounds i8, i8* %245, i32 1
store i8* %246, i8** %9
store i8 %244, i8* %245
br label %247
247: ; preds = %242
%248 = load i32, i32* %14
%249 = add nsw i32 %248, -1
store i32 %249, i32* %14
br label %239
250: ; preds = %239
br label %251
251: ; preds = %250, %235
%252 = load i8, i8* %18
%253 = icmp ne i8 %252, 0
br i1 %253, label %254, label %257
254: ; preds = %251
%255 = load i8*, i8** %9
%256 = getelementptr inbounds i8, i8* %255, i32 1
store i8* %256, i8** %9
store i8 46, i8* %255
br label %257
257: ; preds = %254, %251
%258 = load i32, i32* %14
%259 = add nsw i32 %258, 1
store i32 %259, i32* %14
br label %260
260: ; preds = %270, %257
%261 = load i32, i32* %14
%262 = icmp slt i32 %261, 0
br i1 %262, label %263, label %275
263: ; preds = %260
%264 = load i32, i32* %8
%265 = icmp sgt i32 %264, 0
%266 = zext i1 %265 to i32
%267 = call i32 @assert(i32 %266)
%268 = load i8*, i8** %9
%269 = getelementptr inbounds i8, i8* %268, i32 1
store i8* %269, i8** %9
store i8 48, i8* %268
br label %270
270: ; preds = %263
%271 = load i32, i32* %8
%272 = add nsw i32 %271, -1
store i32 %272, i32* %8
%273 = load i32, i32* %14
%274 = add nsw i32 %273, 1
store i32 %274, i32* %14
br label %260
275: ; preds = %260
br label %276
276: ; preds = %280, %275
%277 = load i32, i32* %8
%278 = add nsw i32 %277, -1
store i32 %278, i32* %8
%279 = icmp sgt i32 %277, 0
br i1 %279, label %280, label %285
280: ; preds = %276
%281 = call i8* @getdigit(double* %7, i32* %21)
%282 = ptrtoint i8* %281 to i8
%283 = load i8*, i8** %9
%284 = getelementptr inbounds i8, i8* %283, i32 1
store i8* %284, i8** %9
store i8 %282, i8* %283
br label %276
285: ; preds = %276
%286 = load i8, i8* %17
%287 = sext i8 %286 to i32
%288 = icmp ne i32 %287, 0
br i1 %288, label %289, label %325
289: ; preds = %285
%290 = load i8, i8* %18
%291 = sext i8 %290 to i32
%292 = icmp ne i32 %291, 0
br i1 %292, label %293, label %325
293: ; preds = %289
br label %294
294: ; preds = %300, %293
%295 = load i8*, i8** %9
%296 = getelementptr inbounds i8, i8* %295, i64 -1
%297 = load i8, i8* %296
%298 = sext i8 %297 to i32
%299 = icmp eq i32 %298, 48
br i1 %299, label %300, label %303
300: ; preds = %294
%301 = load i8*, i8** %9
%302 = getelementptr inbounds i8, i8* %301, i32 -1
store i8* %302, i8** %9
store i8 0, i8* %302
br label %294
303: ; preds = %294
%304 = load i8*, i8** %9
%305 = load i8*, i8** %5
%306 = icmp ugt i8* %304, %305
%307 = zext i1 %306 to i32
%308 = call i32 @assert(i32 %307)
%309 = load i8*, i8** %9
%310 = getelementptr inbounds i8, i8* %309, i64 -1
%311 = load i8, i8* %310
%312 = sext i8 %311 to i32
%313 = icmp eq i32 %312, 46
br i1 %313, label %314, label %324
314: ; preds = %303
%315 = load i8, i8* %20
%316 = icmp ne i8 %315, 0
br i1 %316, label %317, label %320
317: ; preds = %314
%318 = load i8*, i8** %9
%319 = getelementptr inbounds i8, i8* %318, i32 1
store i8* %319, i8** %9
store i8 48, i8* %318
br label %323
320: ; preds = %314
%321 = load i8*, i8** %9
%322 = getelementptr inbounds i8, i8* %321, i32 -1
store i8* %322, i8** %9
store i8 0, i8* %322
br label %323
323: ; preds = %320, %317
br label %324
324: ; preds = %323, %303
br label %325
325: ; preds = %324, %289, %285
%326 = load i8, i8* %16
%327 = sext i8 %326 to i32
%328 = icmp ne i32 %327, 0
br i1 %328, label %333, label %329
329: ; preds = %325
%330 = load i8, i8* %11
%331 = sext i8 %330 to i32
%332 = icmp eq i32 %331, 2
br i1 %332, label %333, label %371
333: ; preds = %329, %325
%334 = load i8*, i8** %9
%335 = getelementptr inbounds i8, i8* %334, i32 1
store i8* %335, i8** %9
store i8 101, i8* %334
%336 = load i32, i32* %13
%337 = icmp slt i32 %336, 0
br i1 %337, label %338, label %343
338: ; preds = %333
%339 = load i8*, i8** %9
%340 = getelementptr inbounds i8, i8* %339, i32 1
store i8* %340, i8** %9
store i8 45, i8* %339
%341 = load i32, i32* %13
%342 = sub nsw i32 0, %341
store i32 %342, i32* %13
br label %346
343: ; preds = %333
%344 = load i8*, i8** %9
%345 = getelementptr inbounds i8, i8* %344, i32 1
store i8* %345, i8** %9
store i8 43, i8* %344
br label %346
346: ; preds = %343, %338
%347 = load i32, i32* %13
%348 = icmp sge i32 %347, 100
br i1 %348, label %349, label %358
349: ; preds = %346
%350 = load i32, i32* %13
%351 = sdiv i32 %350, 100
%352 = add nsw i32 %351, 48
%353 = trunc i32 %352 to i8
%354 = load i8*, i8** %9
%355 = getelementptr inbounds i8, i8* %354, i32 1
store i8* %355, i8** %9
store i8 %353, i8* %354
%356 = load i32, i32* %13
%357 = srem i32 %356, 100
store i32 %357, i32* %13
br label %358
358: ; preds = %349, %346
%359 = load i32, i32* %13
%360 = sdiv i32 %359, 10
%361 = add nsw i32 %360, 48
%362 = trunc i32 %361 to i8
%363 = load i8*, i8** %9
%364 = getelementptr inbounds i8, i8* %363, i32 1
store i8* %364, i8** %9
store i8 %362, i8* %363
%365 = load i32, i32* %13
%366 = srem i32 %365, 10
%367 = add nsw i32 %366, 48
%368 = trunc i32 %367 to i8
%369 = load i8*, i8** %9
%370 = getelementptr inbounds i8, i8* %369, i32 1
store i8* %370, i8** %9
store i8 %368, i8* %369
br label %371
371: ; preds = %358, %329
%372 = load i8*, i8** %9
store i8 0, i8* %372
store i32 0, i32* %4
br label %373
373: ; preds = %371, %160, %81, %24
%374 = load i32, i32* %4
ret i32 %374
}

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 @strcpy(i8* %0, 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 @strcpy(i8* %0, 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 @strcpy(i8* %0, 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
}