#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 */
long double FLT_MAX;
long double FLT_MIN;
char *ft_itoa(long double);
char *ft_strjoin_frs1(char *, char *);
char *ft_ldbltoa(long double n) {
  char *res;
  int neg;
  int tmp;
  int i;
  neg = 0;
  if (n == FLT_MAX)
    return ("3.402823e+38");
  if (n == FLT_MIN)
    return ("1.175494e-38");
  res = ft_strjoin_frs1(ft_itoa(n), ".");
  n -= (int)n;
  (n < 0.0 ? n = -n : 0);
  n *= 10;
  i = 0;
  while (n * 10 != 0) {
    tmp = (int)n;
    res = ft_strjoin_frs1(res, ft_itoa(n));
    n -= tmp;
    n *= 10;
    i++;
  }
  (i == 0 &&n * 10 == 0 ? res = ft_strjoin_frs1(res, "0") : 0);
  return (res);
}


x86 assembly (clang, -O0):
<ft_ldbltoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
fldt   -0x20(%rbp)
mov    0x2ea1(%rip),%rax
fldt   (%rax)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1168 <ft_ldbltoa+0x48>
jp     1168 <ft_ldbltoa+0x48>
jmp    1158 <ft_ldbltoa+0x38>
lea    0xea5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130c <ft_ldbltoa+0x1ec>
fldt   -0x20(%rbp)
mov    0x2e76(%rip),%rax
fldt   (%rax)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    119b <ft_ldbltoa+0x7b>
jp     119b <ft_ldbltoa+0x7b>
jmp    118b <ft_ldbltoa+0x6b>
lea    0xe7f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130c <ft_ldbltoa+0x1ec>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <ft_itoa@plt>
mov    %rax,%rdi
lea    0xe6c(%rip),%rsi
call   1030 <ft_strjoin_frs1@plt>
mov    %rax,-0x28(%rbp)
fldt   -0x20(%rbp)
fnstcw -0x46(%rbp)
movzwl -0x46(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x48(%rbp)
fldcw  -0x48(%rbp)
fistl  -0x3c(%rbp)
fldcw  -0x46(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
fildl  -0x38(%rbp)
fsubrp %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    1206 <ft_ldbltoa+0xe6>
jmp    11f9 <ft_ldbltoa+0xd9>
fldt   -0x20(%rbp)
fchs
fstpt  -0x20(%rbp)
jmp    120b <ft_ldbltoa+0xeb>
jmp    120b <ft_ldbltoa+0xeb>
fldt   -0x20(%rbp)
flds   0xdec(%rip)
fmulp  %st,%st(1)
fstpt  -0x20(%rbp)
movl   $0x0,-0x34(%rbp)
fldt   -0x20(%rbp)
flds   0xdd7(%rip)
fmulp  %st,%st(1)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1244 <ft_ldbltoa+0x124>
jp     1244 <ft_ldbltoa+0x124>
jmp    12b8 <ft_ldbltoa+0x198>
fldt   -0x20(%rbp)
fnstcw -0x4a(%rbp)
movzwl -0x4a(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x4c(%rbp)
fldcw  -0x4c(%rbp)
fistpl -0x44(%rbp)
fldcw  -0x4a(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <ft_itoa@plt>
mov    -0x58(%rbp),%rdi
mov    %rax,%rsi
call   1030 <ft_strjoin_frs1@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x40(%rbp)
fildl  -0x40(%rbp)
fldt   -0x20(%rbp)
fsubp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
flds   0xd5b(%rip)
fmulp  %st,%st(1)
fstpt  -0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1220 <ft_ldbltoa+0x100>
cmpl   $0x0,-0x34(%rbp)
jne    12ff <ft_ldbltoa+0x1df>
fldt   -0x20(%rbp)
flds   0xd35(%rip)
fmulp  %st,%st(1)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    12ff <ft_ldbltoa+0x1df>
jp     12ff <ft_ldbltoa+0x1df>
jmp    12e6 <ft_ldbltoa+0x1c6>
mov    -0x28(%rbp),%rdi
lea    0xd2f(%rip),%rsi
call   1030 <ft_strjoin_frs1@plt>
mov    %rax,-0x28(%rbp)
jmp    1304 <ft_ldbltoa+0x1e4>
jmp    1304 <ft_ldbltoa+0x1e4>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_ldbltoa>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
fldt   0x60(%rsp)
mov    0x2eaf(%rip),%rax
fldt   (%rax)
fucomip %st(1),%st
jne    1144 <ft_ldbltoa+0x24>
jp     1144 <ft_ldbltoa+0x24>
fstp   %st(0)
lea    0xec2(%rip),%rbx
jmp    115c <ft_ldbltoa+0x3c>
mov    0x2e9d(%rip),%rax
fldt   (%rax)
fucomip %st(1),%st
jne    1166 <ft_ldbltoa+0x46>
jp     1166 <ft_ldbltoa+0x46>
fstp   %st(0)
lea    0xeb5(%rip),%rbx
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret
fld    %st(0)
fstpt  (%rsp)
fstpt  0x30(%rsp)
call   1040 <ft_itoa@plt>
lea    0xea3(%rip),%rsi
mov    %rax,%rdi
call   1030 <ft_strjoin_frs1@plt>
fnstcw 0x1a(%rsp)
movzwl 0x1a(%rsp),%ecx
or     $0xc00,%ecx
mov    %cx,0x1e(%rsp)
fldcw  0x1e(%rsp)
fldt   0x30(%rsp)
fistl  0x28(%rsp)
fldcw  0x1a(%rsp)
mov    %rax,%rbx
mov    0x28(%rsp),%eax
mov    %eax,0x2c(%rsp)
fisubl 0x2c(%rsp)
fldz
fucomi %st(1),%st
fld    %st(1)
fchs
fxch   %st(2)
fcmovnbe %st(2),%st
fstp   %st(2)
flds   0xe36(%rip)
fmul   %st,%st(2)
fmul   %st(2),%st
fucomi %st(1),%st
fstp   %st(1)
fld    %st(0)
fstpt  0x3c(%rsp)
jne    11dc <ft_ldbltoa+0xbc>
jnp    1245 <ft_ldbltoa+0x125>
fstp   %st(0)
fldz
fstp   %st(0)
fld    %st(0)
fstpt  0x30(%rsp)
fnstcw 0x18(%rsp)
movzwl 0x18(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x1c(%rsp)
fldcw  0x1c(%rsp)
fistl  0x20(%rsp)
fldcw  0x18(%rsp)
mov    0x20(%rsp),%ebp
fstpt  (%rsp)
call   1040 <ft_itoa@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <ft_strjoin_frs1@plt>
mov    %rax,%rbx
mov    %ebp,0x24(%rsp)
fldt   0x30(%rsp)
fisubl 0x24(%rsp)
flds   0xdcd(%rip)
fmul   %st,%st(1)
fmul   %st(1),%st
fldz
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
jne    11e0 <ft_ldbltoa+0xc0>
jp     11e0 <ft_ldbltoa+0xc0>
jmp    124b <ft_ldbltoa+0x12b>
fstp   %st(1)
fldz
fxch   %st(1)
fstp   %st(1)
fldz
fldt   0x3c(%rsp)
fucomip %st(1),%st
jne    1280 <ft_ldbltoa+0x160>
jp     1280 <ft_ldbltoa+0x160>
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    115c <ft_ldbltoa+0x3c>
jp     115c <ft_ldbltoa+0x3c>
lea    0xdae(%rip),%rsi
mov    %rbx,%rdi
add    $0x48,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ft_strjoin_frs1@plt>
fstp   %st(1)
fstp   %st(0)
jmp    115c <ft_ldbltoa+0x3c>

LLVM IR (-O0):
@FLT_MAX = global x86_fp80 0xK00000000000000000000
@.str = [13 x i8] c"3.402823e+38\00"
@FLT_MIN = global x86_fp80 0xK00000000000000000000
@.str.1 = [13 x i8] c"1.175494e-38\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [2 x i8] c"0\00"
define i8* @ft_ldbltoa(x86_fp80 %0) {
%2 = alloca i8*
%3 = alloca x86_fp80
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store x86_fp80 %0, x86_fp80* %3
store i32 0, i32* %5
%8 = load x86_fp80, x86_fp80* %3
%9 = load x86_fp80, x86_fp80* @FLT_MAX
%10 = fcmp oeq x86_fp80 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
br label %69
12: ; preds = %1
%13 = load x86_fp80, x86_fp80* %3
%14 = load x86_fp80, x86_fp80* @FLT_MIN
%15 = fcmp oeq x86_fp80 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %12
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %69
17: ; preds = %12
%18 = load x86_fp80, x86_fp80* %3
%19 = call i8* @ft_itoa(x86_fp80 %18)
%20 = call i8* @ft_strjoin_frs1(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %20, i8** %4
%21 = load x86_fp80, x86_fp80* %3
%22 = fptosi x86_fp80 %21 to i32
%23 = sitofp i32 %22 to x86_fp80
%24 = load x86_fp80, x86_fp80* %3
%25 = fsub x86_fp80 %24, %23
store x86_fp80 %25, x86_fp80* %3
%26 = load x86_fp80, x86_fp80* %3
%27 = fcmp olt x86_fp80 %26, 0xK00000000000000000000
br i1 %27, label %28, label %31
28: ; preds = %17
%29 = load x86_fp80, x86_fp80* %3
%30 = fneg x86_fp80 %29
store x86_fp80 %30, x86_fp80* %3
br label %32
31: ; preds = %17
br label %32
32: ; preds = %31, %28
%33 = phi x86_fp80 [ %30, %28 ], [ 0xK00000000000000000000, %31 ]
%34 = load x86_fp80, x86_fp80* %3
%35 = fmul x86_fp80 %34, 0xK4002A000000000000000
store x86_fp80 %35, x86_fp80* %3
store i32 0, i32* %7
br label %36
36: ; preds = %40, %32
%37 = load x86_fp80, x86_fp80* %3
%38 = fmul x86_fp80 %37, 0xK4002A000000000000000
%39 = fcmp une x86_fp80 %38, 0xK00000000000000000000
br i1 %39, label %40, label %55
40: ; preds = %36
%41 = load x86_fp80, x86_fp80* %3
%42 = fptosi x86_fp80 %41 to i32
store i32 %42, i32* %6
%43 = load i8*, i8** %4
%44 = load x86_fp80, x86_fp80* %3
%45 = call i8* @ft_itoa(x86_fp80 %44)
%46 = call i8* @ft_strjoin_frs1(i8* %43, i8* %45)
store i8* %46, i8** %4
%47 = load i32, i32* %6
%48 = sitofp i32 %47 to x86_fp80
%49 = load x86_fp80, x86_fp80* %3
%50 = fsub x86_fp80 %49, %48
store x86_fp80 %50, x86_fp80* %3
%51 = load x86_fp80, x86_fp80* %3
%52 = fmul x86_fp80 %51, 0xK4002A000000000000000
store x86_fp80 %52, x86_fp80* %3
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %36
55: ; preds = %36
%56 = load i32, i32* %7
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %55
%59 = load x86_fp80, x86_fp80* %3
%60 = fmul x86_fp80 %59, 0xK4002A000000000000000
%61 = fcmp oeq x86_fp80 %60, 0xK00000000000000000000
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i8*, i8** %4
%64 = call i8* @ft_strjoin_frs1(i8* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %64, i8** %4
br label %66
65: ; preds = %58, %55
br label %66
66: ; preds = %65, %62
%67 = phi i8* [ %64, %62 ], [ null, %65 ]
%68 = load i8*, i8** %4
store i8* %68, i8** %2
br label %69
69: ; preds = %66, %16, %11
%70 = load i8*, i8** %2
ret i8* %70
}

LLVM IR (-O2):
@FLT_MAX = global x86_fp80 0xK00000000000000000000
@.str = [13 x i8] c"3.402823e+38\00"
@FLT_MIN = global x86_fp80 0xK00000000000000000000
@.str.1 = [13 x i8] c"1.175494e-38\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [2 x i8] c"0\00"
define i8* @ft_ldbltoa(x86_fp80 %0) {
%2 = load x86_fp80, x86_fp80* @FLT_MAX
%3 = fcmp oeq x86_fp80 %2, %0
br i1 %3, label %38, label %4
4: ; preds = %1
%5 = load x86_fp80, x86_fp80* @FLT_MIN
%6 = fcmp oeq x86_fp80 %5, %0
br i1 %6, label %38, label %7
7: ; preds = %4
%8 = tail call i8* @ft_itoa(x86_fp80 %0)
%9 = tail call i8* @ft_strjoin_frs1(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = fptosi x86_fp80 %0 to i32
%11 = sitofp i32 %10 to x86_fp80
%12 = fsub x86_fp80 %0, %11
%13 = fcmp olt x86_fp80 %12, 0xK00000000000000000000
%14 = fneg x86_fp80 %12
%15 = select i1 %13, x86_fp80 %14, x86_fp80 %12
%16 = fmul x86_fp80 %15, 0xK4002A000000000000000
%17 = fmul x86_fp80 %16, 0xK4002A000000000000000
%18 = fcmp une x86_fp80 %17, 0xK00000000000000000000
br i1 %18, label %19, label %30
19: ; preds = %7, %19
%20 = phi x86_fp80 [ %27, %19 ], [ %16, %7 ]
%21 = phi i8* [ %24, %19 ], [ %9, %7 ]
%22 = fptosi x86_fp80 %20 to i32
%23 = tail call i8* @ft_itoa(x86_fp80 %20)
%24 = tail call i8* @ft_strjoin_frs1(i8* %21, i8* %23)
%25 = sitofp i32 %22 to x86_fp80
%26 = fsub x86_fp80 %20, %25
%27 = fmul x86_fp80 %26, 0xK4002A000000000000000
%28 = fmul x86_fp80 %27, 0xK4002A000000000000000
%29 = fcmp une x86_fp80 %28, 0xK00000000000000000000
br i1 %29, label %19, label %30
30: ; preds = %19, %7
%31 = phi i8* [ %9, %7 ], [ %24, %19 ]
%32 = phi x86_fp80 [ %17, %7 ], [ %28, %19 ]
%33 = xor i1 %18, true
%34 = fcmp oeq x86_fp80 %32, 0xK00000000000000000000
%35 = select i1 %33, i1 %34, i1 false
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = tail call i8* @ft_strjoin_frs1(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %38
38: ; preds = %36, %30, %4, %1
%39 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %4 ], [ %37, %36 ], [ %31, %30 ]
ret i8* %39
}