#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 */
double float_to_fixed(float);
double power(int, int);
int /*<<< orphan*/ printf(char *, float, float, ...);
int main() {
  float f = -5.4321;
  float g = -3.0;
  printf("The fixed-point equivalent of %f is %d\n", f, float_to_fixed(f));
  printf("The fixed-point equivalent of %f is %d\n", g, float_to_fixed(g));
  printf("%f + %f = %f", f, g,
         (float_to_fixed(f) + float_to_fixed(g)) / power(2, 14));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  0xec4(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xeb3(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <float_to_fixed@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
cvtsd2ss %xmm1,%xmm1
lea    0xe8f(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <float_to_fixed@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
cvtsd2ss %xmm1,%xmm1
lea    0xe61(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <float_to_fixed@plt>
movsd  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <float_to_fixed@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x2,%edi
mov    $0xe,%esi
call   1040 <power@plt>
movsd  -0x18(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
movaps %xmm0,%xmm3
movss  -0xc(%rbp),%xmm0
divsd  %xmm3,%xmm2
lea    0xe18(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movss  0xec3(%rip),%xmm0
call   1030 <float_to_fixed@plt>
cvtsd2ss %xmm0,%xmm1
lea    0xebb(%rip),%rbx
mov    %rbx,%rdi
movss  0xea8(%rip),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
movss  0xe9d(%rip),%xmm0
call   1030 <float_to_fixed@plt>
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
mov    %rbx,%rdi
movss  0xe86(%rip),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
movss  0xe73(%rip),%xmm0
call   1030 <float_to_fixed@plt>
movsd  %xmm0,0x8(%rsp)
movss  0xe64(%rip),%xmm0
call   1030 <float_to_fixed@plt>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x2,%edi
mov    $0xe,%esi
call   1040 <power@plt>
movsd  0x8(%rsp),%xmm2
divsd  %xmm0,%xmm2
lea    0xe5b(%rip),%rdi
movss  0xe23(%rip),%xmm0
movss  0xe1f(%rip),%xmm1
mov    $0x3,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"The fixed-point equivalent of %f is %d\0A\00"
@.str.1 = [13 x i8] c"%f + %f = %f\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
store float 0xC015BA7860000000, float* %1
store float -3.000000e+00, float* %2
%3 = load float, float* %1
%4 = load float, float* %1
%5 = call double @float_to_fixed(float %4)
%6 = fptrunc double %5 to float
%7 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), float %3, float %6)
%8 = load float, float* %2
%9 = load float, float* %2
%10 = call double @float_to_fixed(float %9)
%11 = fptrunc double %10 to float
%12 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), float %8, float %11)
%13 = load float, float* %1
%14 = load float, float* %2
%15 = load float, float* %1
%16 = call double @float_to_fixed(float %15)
%17 = load float, float* %2
%18 = call double @float_to_fixed(float %17)
%19 = fadd double %16, %18
%20 = call double @power(i32 2, i32 14)
%21 = fdiv double %19, %20
%22 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %13, float %14, double %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"The fixed-point equivalent of %f is %d\0A\00"
@.str.1 = [13 x i8] c"%f + %f = %f\00"
define i32 @main() {
%1 = tail call double @float_to_fixed(float 0xC015BA7860000000)
%2 = fptrunc double %1 to float
%3 = tail call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), float 0xC015BA7860000000, float %2)
%4 = tail call double @float_to_fixed(float -3.000000e+00)
%5 = fptrunc double %4 to float
%6 = tail call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), float -3.000000e+00, float %5)
%7 = tail call double @float_to_fixed(float 0xC015BA7860000000)
%8 = tail call double @float_to_fixed(float -3.000000e+00)
%9 = fadd double %7, %8
%10 = tail call double @power(i32 2, i32 14)
%11 = fdiv double %9, %10
%12 = tail call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float 0xC015BA7860000000, float -3.000000e+00, double %11)
ret i32 0
}