#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 *dec2bin3(int);
double floor(double);
char *int2bin(int);
scalar_t__ malloc(int);
char *dou2pre(double a) {
  int ifpositive = 1;
  if (a < 0) {
    a = -a;
    ifpositive = 0;
  }
  char *result;
  result = (char *)malloc(sizeof(char) * 33);
  int mul10 = 0;
  while (!(a == floor(a))) {
    a *= 10;
    mul10++;
  }
  int aint = (int)(a);
  result = int2bin(aint);
  char *mul10bin;
  mul10bin = (char *)malloc(sizeof(char) * 6);
  mul10bin = dec2bin3(mul10);
  for (int i = 0; i < 6; i++) {
    result[24 + i] = mul10bin[i];
  }
  if (ifpositive == 0) {
    result[30] = '0';
    result[31] = '0';
  } else {
    result[30] = '1';
    result[31] = '1';
  }
  result[32] = '\0';
  return result;
}


x86 assembly (clang, -O0):
<dou2pre>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    118a <dou2pre+0x4a>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x21,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1060 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
xor    $0xff,%al
test   $0x1,%al
jne    11d6 <dou2pre+0x96>
jmp    11f6 <dou2pre+0xb6>
movsd  0xe22(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119f <dou2pre+0x5f>
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <int2bin@plt>
mov    %rax,-0x18(%rbp)
mov    $0x6,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <dec2bin3@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jge    125e <dou2pre+0x11e>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x18,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    122b <dou2pre+0xeb>
cmpl   $0x0,-0xc(%rbp)
jne    127d <dou2pre+0x13d>
mov    -0x18(%rbp),%rax
movb   $0x30,0x1e(%rax)
mov    -0x18(%rbp),%rax
movb   $0x30,0x1f(%rax)
jmp    128d <dou2pre+0x14d>
mov    -0x18(%rbp),%rax
movb   $0x31,0x1e(%rax)
mov    -0x18(%rbp),%rax
movb   $0x31,0x1f(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x20(%rax)
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dou2pre>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movapd 0xeb0(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm3
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm1
movapd %xmm0,0x10(%rsp)
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
movapd %xmm3,(%rsp)
mov    $0x21,%edi
call   1040 <malloc@plt>
movapd (%rsp),%xmm0
call   1060 <floor@plt>
movapd (%rsp),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jne    119d <dou2pre+0x5d>
jnp    11ce <dou2pre+0x8e>
xor    %ebx,%ebx
nop
mulsd  0xe68(%rip),%xmm0
movapd %xmm0,(%rsp)
add    $0x1,%ebx
movapd (%rsp),%xmm0
call   1060 <floor@plt>
movapd (%rsp),%xmm1
ucomisd %xmm0,%xmm1
movapd (%rsp),%xmm0
jne    11a0 <dou2pre+0x60>
jp     11a0 <dou2pre+0x60>
jmp    11d0 <dou2pre+0x90>
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
ucomisd 0x10(%rsp),%xmm1
seta   %bpl
cvttsd2si %xmm0,%edi
call   1030 <int2bin@plt>
mov    %rax,%r14
mov    $0x6,%edi
call   1040 <malloc@plt>
mov    %ebx,%edi
call   1050 <dec2bin3@plt>
mov    (%rax),%cl
mov    %cl,0x18(%r14)
mov    0x1(%rax),%cl
mov    %cl,0x19(%r14)
mov    0x2(%rax),%cl
mov    %cl,0x1a(%r14)
mov    0x3(%rax),%cl
mov    %cl,0x1b(%r14)
mov    0x4(%rax),%cl
mov    %cl,0x1c(%r14)
mov    0x5(%rax),%al
mov    %al,0x1d(%r14)
xor    $0x31,%bpl
mov    %bpl,0x1e(%r14)
mov    %bpl,0x1f(%r14)
movb   $0x0,0x20(%r14)
mov    %r14,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @dou2pre(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store double %0, double* %2
store i32 1, i32* %3
%9 = load double, double* %2
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load double, double* %2
%13 = fneg double %12
store double %13, double* %2
store i32 0, i32* %3
br label %14
14: ; preds = %11, %1
%15 = call i64 @malloc(i32 33)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %4
store i32 0, i32* %5
br label %17
17: ; preds = %23, %14
%18 = load double, double* %2
%19 = load double, double* %2
%20 = call double @llvm.floor.f64(double %19)
%21 = fcmp oeq double %18, %20
%22 = xor i1 %21, true
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load double, double* %2
%25 = fmul double %24, 1.000000e+01
store double %25, double* %2
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %17
28: ; preds = %17
%29 = load double, double* %2
%30 = fptosi double %29 to i32
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = call i8* @int2bin(i32 %31)
store i8* %32, i8** %4
%33 = call i64 @malloc(i32 6)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %7
%35 = load i32, i32* %5
%36 = call i8* @dec2bin3(i32 %35)
store i8* %36, i8** %7
store i32 0, i32* %8
br label %37
37: ; preds = %51, %28
%38 = load i32, i32* %8
%39 = icmp slt i32 %38, 6
br i1 %39, label %40, label %54
40: ; preds = %37
%41 = load i8*, i8** %7
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = load i8*, i8** %4
%47 = load i32, i32* %8
%48 = add nsw i32 24, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %46, i64 %49
store i8 %45, i8* %50
br label %51
51: ; preds = %40
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %37
54: ; preds = %37
%55 = load i32, i32* %3
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i64 30
store i8 48, i8* %59
%60 = load i8*, i8** %4
%61 = getelementptr inbounds i8, i8* %60, i64 31
store i8 48, i8* %61
br label %67
62: ; preds = %54
%63 = load i8*, i8** %4
%64 = getelementptr inbounds i8, i8* %63, i64 30
store i8 49, i8* %64
%65 = load i8*, i8** %4
%66 = getelementptr inbounds i8, i8* %65, i64 31
store i8 49, i8* %66
br label %67
67: ; preds = %62, %57
%68 = load i8*, i8** %4
%69 = getelementptr inbounds i8, i8* %68, i64 32
store i8 0, i8* %69
%70 = load i8*, i8** %4
ret i8* %70
}

LLVM IR (-O2):
define i8* @dou2pre(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
%5 = tail call i64 @malloc(i32 33)
%6 = tail call double @llvm.floor.f64(double %4)
%7 = fcmp une double %4, %6
br i1 %7, label %8, label %15
8: ; preds = %1, %8
%9 = phi double [ %11, %8 ], [ %4, %1 ]
%10 = phi i32 [ %12, %8 ], [ 0, %1 ]
%11 = fmul double %9, 1.000000e+01
%12 = add nuw nsw i32 %10, 1
%13 = tail call double @llvm.floor.f64(double %11)
%14 = fcmp une double %11, %13
br i1 %14, label %8, label %15
15: ; preds = %8, %1
%16 = phi i32 [ 0, %1 ], [ %12, %8 ]
%17 = phi double [ %4, %1 ], [ %11, %8 ]
%18 = fptosi double %17 to i32
%19 = tail call i8* @int2bin(i32 %18)
%20 = tail call i64 @malloc(i32 6)
%21 = tail call i8* @dec2bin3(i32 %16)
%22 = load i8, i8* %21
%23 = getelementptr inbounds i8, i8* %19, i64 24
store i8 %22, i8* %23
%24 = getelementptr inbounds i8, i8* %21, i64 1
%25 = load i8, i8* %24
%26 = getelementptr inbounds i8, i8* %19, i64 25
store i8 %25, i8* %26
%27 = getelementptr inbounds i8, i8* %21, i64 2
%28 = load i8, i8* %27
%29 = getelementptr inbounds i8, i8* %19, i64 26
store i8 %28, i8* %29
%30 = getelementptr inbounds i8, i8* %21, i64 3
%31 = load i8, i8* %30
%32 = getelementptr inbounds i8, i8* %19, i64 27
store i8 %31, i8* %32
%33 = getelementptr inbounds i8, i8* %21, i64 4
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %19, i64 28
store i8 %34, i8* %35
%36 = getelementptr inbounds i8, i8* %21, i64 5
%37 = load i8, i8* %36
%38 = getelementptr inbounds i8, i8* %19, i64 29
store i8 %37, i8* %38
%39 = select i1 %2, i8 48, i8 49
%40 = getelementptr inbounds i8, i8* %19, i64 30
store i8 %39, i8* %40
%41 = getelementptr inbounds i8, i8* %19, i64 31
store i8 %39, i8* %41
%42 = getelementptr inbounds i8, i8* %19, i64 32
store i8 0, i8* %42
ret i8* %19
}