#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*/ inttobin(long long, char *);
int /*<<< orphan*/ inttobinfloatpart(long double, char *, int);
char *malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
long double modfl(long double, long double *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void floattobinfloat(long double int_to_bin, char *bin_str) {
  long double int_part = 0.0;
  long double float_part = 0.0;
  float_part = modfl(int_to_bin, &int_part);
  char *int_part_str_bin = malloc(128);
  char *float_part_str_bin = malloc(128);
  memset(int_part_str_bin, '\0', 128);
  memset(float_part_str_bin, '\0', 128);
  inttobin((long long)int_part, int_part_str_bin);
  inttobinfloatpart(float_part, float_part_str_bin, 128);
  memset(bin_str, '\0', 128);
  if ((int_to_bin < 0) && (int_part_str_bin[0] != '-')) {
    strcpy(bin_str, "-");
  }
  strcat(bin_str, int_part_str_bin);
  strcat(bin_str, ".");
  strcat(bin_str, float_part_str_bin);
  bin_str[128] = '\0';
}


x86 assembly (clang, -O0):
<floattobinfloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
mov    %rdi,-0x18(%rbp)
fldz
fld    %st(0)
fstpt  -0x68(%rbp)
fld    %st(0)
fstpt  -0x30(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    -0x30(%rbp),%rdi
call   1050 <modfl@plt>
fstpt  -0x40(%rbp)
mov    $0x80,%edi
mov    %edi,-0x6c(%rbp)
call   1060 <malloc@plt>
mov    -0x6c(%rbp),%edi
mov    %rax,-0x48(%rbp)
call   1060 <malloc@plt>
mov    -0x6c(%rbp),%edx
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    %esi,-0x70(%rbp)
call   1040 <memset@plt>
mov    -0x70(%rbp),%esi
mov    -0x6c(%rbp),%edx
mov    -0x50(%rbp),%rdi
call   1040 <memset@plt>
fldt   -0x30(%rbp)
fnstcw -0x5a(%rbp)
movzwl -0x5a(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x5c(%rbp)
fldcw  -0x5c(%rbp)
fistpll -0x58(%rbp)
fldcw  -0x5a(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1080 <inttobin@plt>
mov    -0x6c(%rbp),%esi
fldt   -0x40(%rbp)
mov    -0x50(%rbp),%rdi
mov    %rsp,%rax
fstpt  (%rax)
call   1070 <inttobinfloatpart@plt>
mov    -0x70(%rbp),%esi
mov    -0x6c(%rbp),%edx
mov    -0x18(%rbp),%rdi
call   1040 <memset@plt>
fldt   -0x68(%rbp)
fldt   -0x10(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1268 <floattobinfloat+0xf8>
jmp    1248 <floattobinfloat+0xd8>
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1268 <floattobinfloat+0xf8>
mov    -0x18(%rbp),%rdi
lea    0xd9d(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xd82(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,0x80(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floattobinfloat>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
fldt   0x80(%rsp)
fld    %st(0)
fstpt  0x38(%rsp)
fldz
fld    %st(0)
fstpt  0x44(%rsp)
fstpt  0x50(%rsp)
fstpt  (%rsp)
lea    0x50(%rsp),%rdi
call   1050 <modfl@plt>
fstpt  0x2c(%rsp)
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
fldt   0x50(%rsp)
fnstcw 0x1c(%rsp)
movzwl 0x1c(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x1e(%rsp)
fldcw  0x1e(%rsp)
fistpll 0x20(%rsp)
fldcw  0x1c(%rsp)
mov    0x20(%rsp),%rdi
mov    %r15,%rsi
call   1080 <inttobin@plt>
fldt   0x2c(%rsp)
fstpt  (%rsp)
mov    %r14,%rdi
mov    $0x80,%esi
call   1070 <inttobinfloatpart@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
fldt   0x44(%rsp)
fldt   0x38(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1256 <floattobinfloat+0xe6>
cmpb   $0x2d,(%r15)
je     1256 <floattobinfloat+0xe6>
lea    0xdb2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcat@plt>
lea    0xd9a(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
movb   $0x0,0x80(%rbx)
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c".\00"
define void @floattobinfloat(x86_fp80 %0, i8* %1) {
%3 = alloca x86_fp80
%4 = alloca i8*
%5 = alloca x86_fp80
%6 = alloca x86_fp80
%7 = alloca i8*
%8 = alloca i8*
store x86_fp80 %0, x86_fp80* %3
store i8* %1, i8** %4
store x86_fp80 0xK00000000000000000000, x86_fp80* %5
store x86_fp80 0xK00000000000000000000, x86_fp80* %6
%9 = load x86_fp80, x86_fp80* %3
%10 = call x86_fp80 @modfl(x86_fp80 %9, x86_fp80* %5)
store x86_fp80 %10, x86_fp80* %6
%11 = call i8* @malloc(i32 128)
store i8* %11, i8** %7
%12 = call i8* @malloc(i32 128)
store i8* %12, i8** %8
%13 = load i8*, i8** %7
%14 = call i32 @memset(i8* %13, i8 signext 0, i32 128)
%15 = load i8*, i8** %8
%16 = call i32 @memset(i8* %15, i8 signext 0, i32 128)
%17 = load x86_fp80, x86_fp80* %5
%18 = fptosi x86_fp80 %17 to i64
%19 = load i8*, i8** %7
%20 = call i32 @inttobin(i64 %18, i8* %19)
%21 = load x86_fp80, x86_fp80* %6
%22 = load i8*, i8** %8
%23 = call i32 @inttobinfloatpart(x86_fp80 %21, i8* %22, i32 128)
%24 = load i8*, i8** %4
%25 = call i32 @memset(i8* %24, i8 signext 0, i32 128)
%26 = load x86_fp80, x86_fp80* %3
%27 = fcmp olt x86_fp80 %26, 0xK00000000000000000000
br i1 %27, label %28, label %37
28: ; preds = %2
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 45
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i8*, i8** %4
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %34, %28, %2
%38 = load i8*, i8** %4
%39 = load i8*, i8** %7
%40 = call i32 @strcat(i8* %38, i8* %39)
%41 = load i8*, i8** %4
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%43 = load i8*, i8** %4
%44 = load i8*, i8** %8
%45 = call i32 @strcat(i8* %43, i8* %44)
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 128
store i8 0, i8* %47
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c".\00"
define void @floattobinfloat(x86_fp80 %0, i8* %1) {
%3 = alloca x86_fp80
%4 = bitcast x86_fp80* %3 to i8*
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
%5 = call x86_fp80 @modfl(x86_fp80 %0, x86_fp80* %3)
%6 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%7 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%8 = tail call i32 @memset(i8* %6, i8 signext 0, i32 128)
%9 = tail call i32 @memset(i8* %7, i8 signext 0, i32 128)
%10 = load x86_fp80, x86_fp80* %3
%11 = fptosi x86_fp80 %10 to i64
%12 = tail call i32 @inttobin(i64 %11, i8* %6)
%13 = tail call i32 @inttobinfloatpart(x86_fp80 %5, i8* %7, i32 128)
%14 = tail call i32 @memset(i8* %1, i8 signext 0, i32 128)
%15 = fcmp olt x86_fp80 %0, 0xK00000000000000000000
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8, i8* %6
%18 = icmp eq i8 %17, 45
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %16, %2
%22 = tail call i32 @strcat(i8* %1, i8* %6)
%23 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 @strcat(i8* %1, i8* %7)
%25 = getelementptr inbounds i8, i8* %1, i64 128
store i8 0, i8* %25
ret void
}