#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 *ft_lltoa(long long);
char *ft_strfjoin(char *, char *, int, int);
char *ft_strfjoinnchar(char *, int, char);
int ft_strlen(char *);
char *ft_ftoa(long double f) {
  long long a;
  long long b;
  char *s;
  char *tmp;
  a = (long long)f;
  f = f - (long double)a;
  b = (int)(f * 1000000);
  if (b < 0)
    b = -b;
  s = ft_lltoa(a);
  s = ft_strfjoinnchar(s, -1, '.');
  tmp = ft_lltoa(b);
  if (6 - ft_strlen(tmp) > 0)
    tmp = ft_strfjoinnchar(tmp, 6 - ft_strlen(tmp), '0');
  s = ft_strfjoin(s, tmp, 1, 1);
  if (f < 0 && s[0] != '-')
    s = ft_strfjoinnchar(s, 1, '-');
  return (s);
}


x86 assembly (clang, -O0):
<ft_ftoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
fnstcw -0x4a(%rbp)
movzwl -0x4a(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x4c(%rbp)
fldcw  -0x4c(%rbp)
fistpll -0x48(%rbp)
fldcw  -0x4a(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x18(%rbp)
fldt   -0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
fildll -0x40(%rbp)
fsubrp %st,%st(1)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
flds   0xe72(%rip)
fmulp  %st,%st(1)
fnstcw -0x4e(%rbp)
movzwl -0x4e(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x50(%rbp)
fldcw  -0x50(%rbp)
fistpl -0x34(%rbp)
fldcw  -0x4e(%rbp)
mov    -0x34(%rbp),%eax
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    11c7 <ft_ftoa+0x87>
xor    %eax,%eax
sub    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <ft_lltoa@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x2e,%edx
call   1030 <ft_strfjoinnchar@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <ft_lltoa@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <ft_strlen@plt>
mov    %eax,%ecx
mov    $0x6,%eax
sub    %ecx,%eax
cmp    $0x0,%eax
jle    123d <ft_ftoa+0xfd>
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <ft_strlen@plt>
mov    -0x58(%rbp),%rdi
mov    $0x6,%esi
sub    %eax,%esi
mov    $0x30,%edx
call   1030 <ft_strfjoinnchar@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1050 <ft_strfjoin@plt>
mov    %rax,-0x28(%rbp)
fldt   -0x10(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    1290 <ft_ftoa+0x150>
jmp    1269 <ft_ftoa+0x129>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1290 <ft_ftoa+0x150>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x2d,%edx
call   1030 <ft_strfjoinnchar@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_ftoa>:
push   %r14
push   %rbx
sub    $0x38,%rsp
fldt   0x50(%rsp)
fnstcw 0xe(%rsp)
movzwl 0xe(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x12(%rsp)
fldcw  0x12(%rsp)
fld    %st(0)
fistpll 0x18(%rsp)
fldcw  0xe(%rsp)
mov    0x18(%rsp),%rdi
mov    %rdi,0x20(%rsp)
fildll 0x20(%rsp)
fsubrp %st,%st(1)
fld    %st(0)
fstpt  0x2c(%rsp)
fmuls  0xe78(%rip)
fnstcw 0xc(%rsp)
movzwl 0xc(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x10(%rsp)
fldcw  0x10(%rsp)
fistpl 0x14(%rsp)
fldcw  0xc(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,%ebx
neg    %ebx
cmovs  %eax,%ebx
call   1060 <ft_lltoa@plt>
mov    %rax,%rdi
mov    $0xffffffff,%esi
mov    $0x2e,%edx
call   1030 <ft_strfjoinnchar@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <ft_lltoa@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <ft_strlen@plt>
cmp    $0x5,%eax
jg     1203 <ft_ftoa+0xc3>
mov    %rbx,%rdi
call   1040 <ft_strlen@plt>
mov    $0x6,%esi
sub    %eax,%esi
mov    %rbx,%rdi
mov    $0x30,%edx
call   1030 <ft_strfjoinnchar@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1050 <ft_strfjoin@plt>
fldz
fldt   0x2c(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    122b <ft_ftoa+0xeb>
cmpb   $0x2d,(%rax)
jne    1233 <ft_ftoa+0xf3>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0x2d,%edx
add    $0x38,%rsp
pop    %rbx
pop    %r14
jmp    1030 <ft_strfjoinnchar@plt>

LLVM IR (-O0):
define i8* @ft_ftoa(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
store x86_fp80 %0, x86_fp80* %2
%7 = load x86_fp80, x86_fp80* %2
%8 = fptosi x86_fp80 %7 to i64
store i64 %8, i64* %3
%9 = load x86_fp80, x86_fp80* %2
%10 = load i64, i64* %3
%11 = sitofp i64 %10 to x86_fp80
%12 = fsub x86_fp80 %9, %11
store x86_fp80 %12, x86_fp80* %2
%13 = load x86_fp80, x86_fp80* %2
%14 = fmul x86_fp80 %13, 0xK4012F424000000000000
%15 = fptosi x86_fp80 %14 to i32
%16 = sext i32 %15 to i64
store i64 %16, i64* %4
%17 = load i64, i64* %4
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %1
%20 = load i64, i64* %4
%21 = sub nsw i64 0, %20
store i64 %21, i64* %4
br label %22
22: ; preds = %19, %1
%23 = load i64, i64* %3
%24 = call i8* @ft_lltoa(i64 %23)
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = call i8* @ft_strfjoinnchar(i8* %25, i32 -1, i8 signext 46)
store i8* %26, i8** %5
%27 = load i64, i64* %4
%28 = call i8* @ft_lltoa(i64 %27)
store i8* %28, i8** %6
%29 = load i8*, i8** %6
%30 = call i32 @ft_strlen(i8* %29)
%31 = sub nsw i32 6, %30
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %22
%34 = load i8*, i8** %6
%35 = load i8*, i8** %6
%36 = call i32 @ft_strlen(i8* %35)
%37 = sub nsw i32 6, %36
%38 = call i8* @ft_strfjoinnchar(i8* %34, i32 %37, i8 signext 48)
store i8* %38, i8** %6
br label %39
39: ; preds = %33, %22
%40 = load i8*, i8** %5
%41 = load i8*, i8** %6
%42 = call i8* @ft_strfjoin(i8* %40, i8* %41, i32 1, i32 1)
store i8* %42, i8** %5
%43 = load x86_fp80, x86_fp80* %2
%44 = fcmp olt x86_fp80 %43, 0xK00000000000000000000
br i1 %44, label %45, label %54
45: ; preds = %39
%46 = load i8*, i8** %5
%47 = getelementptr inbounds i8, i8* %46, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 45
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = load i8*, i8** %5
%53 = call i8* @ft_strfjoinnchar(i8* %52, i32 1, i8 signext 45)
store i8* %53, i8** %5
br label %54
54: ; preds = %51, %45, %39
%55 = load i8*, i8** %5
ret i8* %55
}

LLVM IR (-O2):
define i8* @ft_ftoa(x86_fp80 %0) {
%2 = fptosi x86_fp80 %0 to i64
%3 = sitofp i64 %2 to x86_fp80
%4 = fsub x86_fp80 %0, %3
%5 = fmul x86_fp80 %4, 0xK4012F424000000000000
%6 = fptosi x86_fp80 %5 to i32
%7 = tail call i32 @llvm.abs.i32(i32 %6, i1 false)
%8 = zext i32 %7 to i64
%9 = tail call i8* @ft_lltoa(i64 %2)
%10 = tail call i8* @ft_strfjoinnchar(i8* %9, i32 -1, i8 signext 46)
%11 = tail call i8* @ft_lltoa(i64 %8)
%12 = tail call i32 @ft_strlen(i8* %11)
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = tail call i32 @ft_strlen(i8* %11)
%16 = sub nsw i32 6, %15
%17 = tail call i8* @ft_strfjoinnchar(i8* %11, i32 %16, i8 signext 48)
br label %18
18: ; preds = %14, %1
%19 = phi i8* [ %17, %14 ], [ %11, %1 ]
%20 = tail call i8* @ft_strfjoin(i8* %10, i8* %19, i32 1, i32 1)
%21 = fcmp olt x86_fp80 %4, 0xK00000000000000000000
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load i8, i8* %20
%24 = icmp eq i8 %23, 45
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i8* @ft_strfjoinnchar(i8* %20, i32 1, i8 signext 45)
br label %27
27: ; preds = %25, %22, %18
%28 = phi i8* [ %26, %25 ], [ %20, %22 ], [ %20, %18 ]
ret i8* %28
}