#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 */
char *__format_double_frac(long double, int, int);
char *__format_double_int(long double, int);
char *__format_int(long double, int);
int /*<<< orphan*/ floorl(long double);
int /*<<< orphan*/ free(char *);
scalar_t__ isinf(long double);
scalar_t__ isnan(long double);
long double log10l(long double);
long double modfl(long double, long double *);
long double powl(int, int /*<<< orphan*/);
char *strdup(char *);
char *strvcat(char *, char *, char *, ...);
char *__format_double(long double value, int flags, int precision) {
  char *int_part;
  char *dec_part;
  char *string;
  long double i;
  if (isnan(value)) {
    if (flags & 0x10) {
      return strdup("NAN");
    } else {
      return strdup("nan");
    }
  }
  if (isinf(value)) {
    if (flags & 0x10) {
      if (value < 0) {
        return strdup("-INF");
      } else {
        if (flags & 0x01) {
          return strdup("+INF");
        } else {
          return strdup("INF");
        }
      }
    } else {
      if (value < 0) {
        return strdup("-inf");
      } else {
        if (flags & 0x01) {
          return strdup("+inf");
        } else {
          return strdup("inf");
        }
      }
    }
  }
  if (flags & 0x80 || (flags & 0x100 && value > 1000000000)) {
    i = log10l(value);
    value /= powl(10, floorl(i));
    int_part = __format_double(value, flags & ~(0x80), precision);
    dec_part = __format_int(i, flags | 0x01);
    string = strvcat(int_part, (flags & 0x10) ? "E" : "e", dec_part, NULL);
    free(int_part);
    free(dec_part);
  } else {
    value = modfl(value, &i);
    if (value > 2000000000) {
      int_part = __format_double_int(i, flags);
    } else {
      int_part = __format_int(i, flags);
    }
    dec_part = __format_double_frac(value, flags, precision);
    if (i == 0.0 && value < 0) {
      if (value != 0.0 || flags & 0x04) {
        string = strvcat("-", int_part, ".", dec_part, NULL);
      } else {
        string = strvcat("-", int_part, NULL);
      }
    } else {
      if (value != 0.0 || flags & 0x04) {
        string = strvcat(int_part, ".", dec_part, NULL);
      } else {
        string = strdup(int_part);
      }
    }
    free(int_part);
    free(dec_part);
  }
  return string;
}


x86 assembly (clang, -O0):
<__format_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    %esi,-0x28(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1080 <isnan@plt>
cmp    $0x0,%rax
je     1234 <__format_double+0x64>
mov    -0x24(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     121f <__format_double+0x4f>
lea    0xdf7(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1599 <__format_double+0x3c9>
lea    0xde6(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1599 <__format_double+0x3c9>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   10f0 <isinf@plt>
cmp    $0x0,%rax
je     131e <__format_double+0x14e>
mov    -0x24(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     12bc <__format_double+0xec>
fldt   -0x20(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    1283 <__format_double+0xb3>
jmp    126e <__format_double+0x9e>
lea    0xd9b(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1599 <__format_double+0x3c9>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     12a7 <__format_double+0xd7>
lea    0xd7c(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1599 <__format_double+0x3c9>
lea    0xd68(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1599 <__format_double+0x3c9>
fldt   -0x20(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    12e5 <__format_double+0x115>
jmp    12d0 <__format_double+0x100>
lea    0xd43(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1599 <__format_double+0x3c9>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1309 <__format_double+0x139>
lea    0xd24(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1599 <__format_double+0x3c9>
lea    0xd10(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1599 <__format_double+0x3c9>
mov    -0x24(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    135a <__format_double+0x18a>
mov    -0x24(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     1408 <__format_double+0x238>
fldt   -0x20(%rbp)
flds   0xcb7(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1408 <__format_double+0x238>
jmp    135a <__format_double+0x18a>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   10b0 <log10l@plt>
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   10d0 <floorl@plt>
mov    %eax,%esi
mov    $0xa,%edi
call   1040 <powl@plt>
fldt   -0x20(%rbp)
fdivp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
mov    -0x24(%rbp),%edi
and    $0xffffff7f,%edi
mov    -0x28(%rbp),%esi
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <__format_double@plt>
mov    %rax,-0x30(%rbp)
fldt   -0x50(%rbp)
mov    -0x24(%rbp),%edi
or     $0x1,%edi
mov    %rsp,%rax
fstpt  (%rax)
call   10a0 <__format_int@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%ecx
and    $0x10,%ecx
lea    0xc56(%rip),%rsi
lea    0xc4d(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x38(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   10c0 <strvcat@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    1591 <__format_double+0x3c1>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    -0x50(%rbp),%rdi
call   1060 <modfl@plt>
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
flds   0xbdf(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    144f <__format_double+0x27f>
jmp    1436 <__format_double+0x266>
fldt   -0x50(%rbp)
mov    -0x24(%rbp),%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1070 <__format_double_int@plt>
mov    %rax,-0x30(%rbp)
jmp    1463 <__format_double+0x293>
fldt   -0x50(%rbp)
mov    -0x24(%rbp),%edi
mov    %rsp,%rax
fstpt  (%rax)
call   10a0 <__format_int@plt>
mov    %rax,-0x30(%rbp)
fldt   -0x20(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    %rsp,%rax
fstpt  (%rax)
call   1090 <__format_double_frac@plt>
mov    %rax,-0x38(%rbp)
fldt   -0x50(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    151f <__format_double+0x34f>
jp     151f <__format_double+0x34f>
jmp    1496 <__format_double+0x2c6>
fldt   -0x20(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    151f <__format_double+0x34f>
jmp    14aa <__format_double+0x2da>
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    14d5 <__format_double+0x305>
jp     14d5 <__format_double+0x305>
jmp    14c6 <__format_double+0x2f6>
mov    -0x24(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1500 <__format_double+0x330>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rcx
lea    0xb44(%rip),%rdi
lea    0xb3f(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   10c0 <strvcat@plt>
mov    %rax,-0x40(%rbp)
jmp    151a <__format_double+0x34a>
mov    -0x30(%rbp),%rsi
lea    0xb1d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   10c0 <strvcat@plt>
mov    %rax,-0x40(%rbp)
jmp    157f <__format_double+0x3af>
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    154a <__format_double+0x37a>
jp     154a <__format_double+0x37a>
jmp    153b <__format_double+0x36b>
mov    -0x24(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     156d <__format_double+0x39d>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xad1(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   10c0 <strvcat@plt>
mov    %rax,-0x40(%rbp)
jmp    157a <__format_double+0x3aa>
mov    -0x30(%rbp),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x40(%rbp)
jmp    157f <__format_double+0x3af>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__format_double>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
fldt   0x60(%rsp)
fld    %st(0)
fstpt  0x18(%rsp)
fstpt  (%rsp)
call   1080 <isnan@plt>
test   %rax,%rax
je     1201 <__format_double+0x31>
test   $0x10,%bl
jne    1236 <__format_double+0x66>
lea    0xe0d(%rip),%rdi
jmp    123d <__format_double+0x6d>
fldt   0x18(%rsp)
fstpt  (%rsp)
call   10f0 <isinf@plt>
test   %rax,%rax
je     124a <__format_double+0x7a>
test   $0x10,%bl
jne    1306 <__format_double+0x136>
fldz
fldt   0x18(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1320 <__format_double+0x150>
lea    0xde6(%rip),%rdi
jmp    123d <__format_double+0x6d>
lea    0xdcb(%rip),%rdi
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    10e0 <strdup@plt>
test   $0x80,%bl
fldt   0x18(%rsp)
jne    1272 <__format_double+0xa2>
flds   0xda7(%rip)
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
jbe    1342 <__format_double+0x172>
mov    %ebx,%eax
and    $0x100,%eax
je     1342 <__format_double+0x172>
fstpt  (%rsp)
call   10b0 <log10l@plt>
fld    %st(0)
fstpt  0x24(%rsp)
fstpt  (%rsp)
call   10d0 <floorl@plt>
mov    $0xa,%edi
mov    %eax,%esi
call   1040 <powl@plt>
fldt   0x18(%rsp)
fdivp  %st,%st(1)
mov    %ebx,%edi
and    $0xffffff7f,%edi
fstpt  (%rsp)
mov    %ebp,%esi
call   1050 <__format_double@plt>
mov    %rax,%r14
mov    %ebx,%edi
or     $0x1,%edi
fldt   0x24(%rsp)
fstpt  (%rsp)
call   10a0 <__format_int@plt>
mov    %rax,%rbp
test   $0x10,%bl
lea    0xd59(%rip),%rax
lea    0xd50(%rip),%rsi
cmove  %rax,%rsi
mov    %r14,%rdi
mov    %rbp,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   10c0 <strvcat@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
fldz
fldt   0x18(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1331 <__format_double+0x161>
lea    0xcf5(%rip),%rdi
jmp    123d <__format_double+0x6d>
test   $0x1,%bl
jne    1379 <__format_double+0x1a9>
lea    0xcf4(%rip),%rdi
jmp    123d <__format_double+0x6d>
test   $0x1,%bl
jne    1385 <__format_double+0x1b5>
lea    0xcd9(%rip),%rdi
jmp    123d <__format_double+0x6d>
fstpt  (%rsp)
lea    0x30(%rsp),%rdi
call   1060 <modfl@plt>
flds   0xcaf(%rip)
fld    %st(1)
fstpt  0x18(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
fldt   0x30(%rsp)
fld    %st(0)
fstpt  0x24(%rsp)
jbe    1391 <__format_double+0x1c1>
fstpt  (%rsp)
mov    %ebx,%edi
call   1070 <__format_double_int@plt>
jmp    139b <__format_double+0x1cb>
lea    0xc9f(%rip),%rdi
jmp    123d <__format_double+0x6d>
lea    0xc89(%rip),%rdi
jmp    123d <__format_double+0x6d>
fstpt  (%rsp)
mov    %ebx,%edi
call   10a0 <__format_int@plt>
mov    %rax,%r14
fldt   0x18(%rsp)
fstpt  (%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
call   1090 <__format_double_frac@plt>
fldt   0x18(%rsp)
mov    %rax,%rbp
fldz
fxch   %st(1)
fucomi %st(1),%st
setnp  %al
sete   %cl
and    %al,%cl
test   $0x4,%bl
sete   %al
and    %cl,%al
fldt   0x24(%rsp)
fucomip %st(2),%st
jne    1401 <__format_double+0x231>
jp     1401 <__format_double+0x231>
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
fldz
fldz
jbe    1401 <__format_double+0x231>
fstp   %st(1)
fstp   %st(0)
lea    0xc3c(%rip),%rdi
test   %al,%al
je     1416 <__format_double+0x246>
mov    %r14,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   10c0 <strvcat@plt>
jmp    12e7 <__format_double+0x117>
fstp   %st(1)
fstp   %st(0)
test   %al,%al
je     1432 <__format_double+0x262>
mov    %r14,%rdi
call   10e0 <strdup@plt>
jmp    12e7 <__format_double+0x117>
lea    0xc0d(%rip),%rdx
mov    %r14,%rsi
mov    %rbp,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   10c0 <strvcat@plt>
jmp    12e7 <__format_double+0x117>
lea    0xbf1(%rip),%rsi
jmp    12d8 <__format_double+0x108>

LLVM IR (-O0):
@.str = [4 x i8] c"NAN\00"
@.str.1 = [4 x i8] c"nan\00"
@.str.2 = [5 x i8] c"-INF\00"
@.str.3 = [5 x i8] c"+INF\00"
@.str.4 = [4 x i8] c"INF\00"
@.str.5 = [5 x i8] c"-inf\00"
@.str.6 = [5 x i8] c"+inf\00"
@.str.7 = [4 x i8] c"inf\00"
@.str.8 = [2 x i8] c"E\00"
@.str.9 = [2 x i8] c"e\00"
@.str.10 = [2 x i8] c"-\00"
@.str.11 = [2 x i8] c".\00"
define i8* @__format_double(x86_fp80 %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%12 = load x86_fp80, x86_fp80* %5
%13 = call i64 @isnan(x86_fp80 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %3
%16 = load i32, i32* %6
%17 = and i32 %16, 16
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %4
br label %157
21: ; preds = %15
%22 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %22, i8** %4
br label %157
23: ; preds = %3
%24 = load x86_fp80, x86_fp80* %5
%25 = call i64 @isinf(x86_fp80 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %57
27: ; preds = %23
%28 = load i32, i32* %6
%29 = and i32 %28, 16
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %44
31: ; preds = %27
%32 = load x86_fp80, x86_fp80* %5
%33 = fcmp olt x86_fp80 %32, 0xK00000000000000000000
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %35, i8** %4
br label %157
36: ; preds = %31
%37 = load i32, i32* %6
%38 = and i32 %37, 1
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %41, i8** %4
br label %157
42: ; preds = %36
%43 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i8* %43, i8** %4
br label %157
44: ; preds = %27
%45 = load x86_fp80, x86_fp80* %5
%46 = fcmp olt x86_fp80 %45, 0xK00000000000000000000
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i8* %48, i8** %4
br label %157
49: ; preds = %44
%50 = load i32, i32* %6
%51 = and i32 %50, 1
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
store i8* %54, i8** %4
br label %157
55: ; preds = %49
%56 = call i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
store i8* %56, i8** %4
br label %157
57: ; preds = %23
%58 = load i32, i32* %6
%59 = and i32 %58, 128
%60 = icmp ne i32 %59, 0
br i1 %60, label %68, label %61
61: ; preds = %57
%62 = load i32, i32* %6
%63 = and i32 %62, 256
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %97
65: ; preds = %61
%66 = load x86_fp80, x86_fp80* %5
%67 = fcmp ogt x86_fp80 %66, 0xK401CEE6B280000000000
br i1 %67, label %68, label %97
68: ; preds = %65, %57
%69 = load x86_fp80, x86_fp80* %5
%70 = call x86_fp80 @log10l(x86_fp80 %69)
store x86_fp80 %70, x86_fp80* %11
%71 = load x86_fp80, x86_fp80* %11
%72 = call i32 @floorl(x86_fp80 %71)
%73 = call x86_fp80 @powl(i32 10, i32 %72)
%74 = load x86_fp80, x86_fp80* %5
%75 = fdiv x86_fp80 %74, %73
store x86_fp80 %75, x86_fp80* %5
%76 = load x86_fp80, x86_fp80* %5
%77 = load i32, i32* %6
%78 = and i32 %77, -129
%79 = load i32, i32* %7
%80 = call i8* @__format_double(x86_fp80 %76, i32 %78, i32 %79)
store i8* %80, i8** %8
%81 = load x86_fp80, x86_fp80* %11
%82 = load i32, i32* %6
%83 = or i32 %82, 1
%84 = call i8* @__format_int(x86_fp80 %81, i32 %83)
store i8* %84, i8** %9
%85 = load i8*, i8** %8
%86 = load i32, i32* %6
%87 = and i32 %86, 16
%88 = icmp ne i32 %87, 0
%89 = zext i1 %88 to i64
%90 = select i1 %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%91 = load i8*, i8** %9
%92 = call i8* (i8*, i8*, i8*, ...) @strvcat(i8* %85, i8* %90, i8* %91, i8* null)
store i8* %92, i8** %10
%93 = load i8*, i8** %8
%94 = call i32 @free(i8* %93)
%95 = load i8*, i8** %9
%96 = call i32 @free(i8* %95)
br label %155
97: ; preds = %65, %61
%98 = load x86_fp80, x86_fp80* %5
%99 = call x86_fp80 @modfl(x86_fp80 %98, x86_fp80* %11)
store x86_fp80 %99, x86_fp80* %5
%100 = load x86_fp80, x86_fp80* %5
%101 = fcmp ogt x86_fp80 %100, 0xK401DEE6B280000000000
br i1 %101, label %102, label %106
102: ; preds = %97
%103 = load x86_fp80, x86_fp80* %11
%104 = load i32, i32* %6
%105 = call i8* @__format_double_int(x86_fp80 %103, i32 %104)
store i8* %105, i8** %8
br label %110
106: ; preds = %97
%107 = load x86_fp80, x86_fp80* %11
%108 = load i32, i32* %6
%109 = call i8* @__format_int(x86_fp80 %107, i32 %108)
store i8* %109, i8** %8
br label %110
110: ; preds = %106, %102
%111 = load x86_fp80, x86_fp80* %5
%112 = load i32, i32* %6
%113 = load i32, i32* %7
%114 = call i8* @__format_double_frac(x86_fp80 %111, i32 %112, i32 %113)
store i8* %114, i8** %9
%115 = load x86_fp80, x86_fp80* %11
%116 = fcmp oeq x86_fp80 %115, 0xK00000000000000000000
br i1 %116, label %117, label %135
117: ; preds = %110
%118 = load x86_fp80, x86_fp80* %5
%119 = fcmp olt x86_fp80 %118, 0xK00000000000000000000
br i1 %119, label %120, label %135
120: ; preds = %117
%121 = load x86_fp80, x86_fp80* %5
%122 = fcmp une x86_fp80 %121, 0xK00000000000000000000
br i1 %122, label %127, label %123
123: ; preds = %120
%124 = load i32, i32* %6
%125 = and i32 %124, 4
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %131
127: ; preds = %123, %120
%128 = load i8*, i8** %8
%129 = load i8*, i8** %9
%130 = call i8* (i8*, i8*, i8*, ...) @strvcat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* %128, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* %129, i8* null)
store i8* %130, i8** %10
br label %134
131: ; preds = %123
%132 = load i8*, i8** %8
%133 = call i8* (i8*, i8*, i8*, ...) @strvcat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* %132, i8* null)
store i8* %133, i8** %10
br label %134
134: ; preds = %131, %127
br label %150
135: ; preds = %117, %110
%136 = load x86_fp80, x86_fp80* %5
%137 = fcmp une x86_fp80 %136, 0xK00000000000000000000
br i1 %137, label %142, label %138
138: ; preds = %135
%139 = load i32, i32* %6
%140 = and i32 %139, 4
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %146
142: ; preds = %138, %135
%143 = load i8*, i8** %8
%144 = load i8*, i8** %9
%145 = call i8* (i8*, i8*, i8*, ...) @strvcat(i8* %143, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* %144, i8* null)
store i8* %145, i8** %10
br label %149
146: ; preds = %138
%147 = load i8*, i8** %8
%148 = call i8* @strdup(i8* %147)
store i8* %148, i8** %10
br label %149
149: ; preds = %146, %142
br label %150
150: ; preds = %149, %134
%151 = load i8*, i8** %8
%152 = call i32 @free(i8* %151)
%153 = load i8*, i8** %9
%154 = call i32 @free(i8* %153)
br label %155
155: ; preds = %150, %68
%156 = load i8*, i8** %10
store i8* %156, i8** %4
br label %157
157: ; preds = %155, %55, %53, %47, %42, %40, %34, %21, %19
%158 = load i8*, i8** %4
ret i8* %158
}

LLVM IR (-O2):
@.str = [4 x i8] c"NAN\00"
@.str.1 = [4 x i8] c"nan\00"
@.str.2 = [5 x i8] c"-INF\00"
@.str.3 = [5 x i8] c"+INF\00"
@.str.4 = [4 x i8] c"INF\00"
@.str.5 = [5 x i8] c"-inf\00"
@.str.6 = [5 x i8] c"+inf\00"
@.str.7 = [4 x i8] c"inf\00"
@.str.8 = [2 x i8] c"E\00"
@.str.9 = [2 x i8] c"e\00"
@.str.10 = [2 x i8] c"-\00"
@.str.11 = [2 x i8] c".\00"
define i8* @__format_double(x86_fp80 %0, i32 %1, i32 %2) {
%4 = alloca x86_fp80
%5 = bitcast x86_fp80* %4 to i8*
%6 = tail call i64 @isnan(x86_fp80 %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %3
%9 = and i32 %1, 16
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %97
13: ; preds = %8
%14 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %97
15: ; preds = %3
%16 = tail call i64 @isinf(x86_fp80 %0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %42, label %18
18: ; preds = %15
%19 = and i32 %1, 16
%20 = icmp eq i32 %19, 0
%21 = fcmp olt x86_fp80 %0, 0xK00000000000000000000
br i1 %20, label %32, label %22
22: ; preds = %18
br i1 %21, label %23, label %25
23: ; preds = %22
%24 = tail call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %97
25: ; preds = %22
%26 = and i32 %1, 1
%27 = icmp eq i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = tail call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %97
30: ; preds = %25
%31 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %97
32: ; preds = %18
br i1 %21, label %33, label %35
33: ; preds = %32
%34 = tail call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %97
35: ; preds = %32
%36 = and i32 %1, 1
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = tail call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %97
40: ; preds = %35
%41 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %97
42: ; preds = %15
%43 = and i32 %1, 128
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = and i32 %1, 256
%47 = icmp ne i32 %46, 0
%48 = fcmp ogt x86_fp80 %0, 0xK401CEE6B280000000000
%49 = and i1 %48, %47
br i1 %49, label %50, label %65
50: ; preds = %45, %42
%51 = tail call x86_fp80 @log10l(x86_fp80 %0)
%52 = tail call i32 @floorl(x86_fp80 %51)
%53 = tail call x86_fp80 @powl(i32 10, i32 %52)
%54 = fdiv x86_fp80 %0, %53
%55 = and i32 %1, -129
%56 = tail call i8* @__format_double(x86_fp80 %54, i32 %55, i32 %2)
%57 = or i32 %1, 1
%58 = tail call i8* @__format_int(x86_fp80 %51, i32 %57)
%59 = and i32 %1, 16
%60 = icmp eq i32 %59, 0
%61 = select i1 %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0)
%62 = tail call i8* (i8*, i8*, i8*, ...) @strvcat(i8* %56, i8* %61, i8* %58, i8* null)
%63 = tail call i32 @free(i8* %56)
%64 = tail call i32 @free(i8* %58)
br label %97
65: ; preds = %45
%66 = call x86_fp80 @modfl(x86_fp80 %0, x86_fp80* %4)
%67 = fcmp ogt x86_fp80 %66, 0xK401DEE6B280000000000
%68 = load x86_fp80, x86_fp80* %4
br i1 %67, label %69, label %71
69: ; preds = %65
%70 = tail call i8* @__format_double_int(x86_fp80 %68, i32 %1)
br label %73
71: ; preds = %65
%72 = tail call i8* @__format_int(x86_fp80 %68, i32 %1)
br label %73
73: ; preds = %71, %69
%74 = phi i8* [ %70, %69 ], [ %72, %71 ]
%75 = tail call i8* @__format_double_frac(x86_fp80 %66, i32 %1, i32 %2)
%76 = fcmp oeq x86_fp80 %68, 0xK00000000000000000000
%77 = fcmp olt x86_fp80 %66, 0xK00000000000000000000
%78 = select i1 %76, i1 %77, i1 false
%79 = fcmp oeq x86_fp80 %66, 0xK00000000000000000000
%80 = and i32 %1, 4
%81 = icmp eq i32 %80, 0
%82 = and i1 %81, %79
br i1 %78, label %83, label %88
83: ; preds = %73
br i1 %82, label %86, label %84
84: ; preds = %83
%85 = tail call i8* (i8*, i8*, i8*, ...) @strvcat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* %75, i8* null)
br label %93
86: ; preds = %83
%87 = tail call i8* (i8*, i8*, i8*, ...) @strvcat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* %74, i8* null)
br label %93
88: ; preds = %73
br i1 %82, label %91, label %89
89: ; preds = %88
%90 = tail call i8* (i8*, i8*, i8*, ...) @strvcat(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* %75, i8* null)
br label %93
91: ; preds = %88
%92 = tail call i8* @strdup(i8* %74)
br label %93
93: ; preds = %89, %91, %84, %86
%94 = phi i8* [ %85, %84 ], [ %87, %86 ], [ %90, %89 ], [ %92, %91 ]
%95 = tail call i32 @free(i8* %74)
%96 = tail call i32 @free(i8* %75)
br label %97
97: ; preds = %50, %93, %40, %38, %33, %30, %28, %23, %13, %11
%98 = phi i8* [ %12, %11 ], [ %14, %13 ], [ %24, %23 ], [ %29, %28 ], [ %31, %30 ], [ %34, %33 ], [ %39, %38 ], [ %41, %40 ], [ %62, %50 ], [ %94, %93 ]
ret i8* %98
}