#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 add(int, int);
double add_precise(double, double);
int div(int, int /*<<< orphan*/);
double div_precise(int, int);
int mult(int, int);
double mult_precise(double, double);
int /*<<< orphan*/ printf(char *, double);
int sub(int, int);
double sub_precise(double, double);
int main() {
  double ap = add_precise(1.5, 1.5);
  double sp = sub_precise(20.5, 0.234);
  double mp = mult_precise(10.5, 50.2);
  double dp = div_precise(19, 2);
  printf("Adding 1 + 1 = %d\n", add(1, 1));
  printf("Adding 1.5 + 1.5 = %f\n", ap);
  printf("Subtracting 10 - 5 = %d\n", sub(10, 5));
  printf("Subtracting 20.5 - 0.234 = %f\n", sp);
  printf("Multiplying 20 * 10 = %d\n", mult(20, 10));
  printf("Multiplying 10.5 and 50.2 = %f\n", mp);
  printf("Dividing 5 by 0 (did you check for this?) = %d\n", div(5, 0));
  printf("Dividing 19 by 2 = %f\n", dp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xe79(%rip),%xmm1
movaps %xmm1,%xmm0
call   1050 <add_precise@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xe54(%rip),%xmm0
movsd  0xe54(%rip),%xmm1
call   1070 <sub_precise@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe2a(%rip),%xmm0
movsd  0xe2a(%rip),%xmm1
call   10a0 <mult_precise@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x13,%edi
mov    $0x2,%esi
call   1030 <div_precise@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <add@plt>
cvtsi2sd %eax,%xmm0
lea    0xe15(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xe17(%rip),%rdi
call   1060 <printf@plt>
mov    $0xa,%edi
mov    $0x5,%esi
call   10b0 <sub@plt>
cvtsi2sd %eax,%xmm0
lea    0xe0f(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe17(%rip),%rdi
call   1060 <printf@plt>
mov    $0x14,%edi
mov    $0xa,%esi
call   1080 <mult@plt>
cvtsi2sd %eax,%xmm0
lea    0xe17(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe20(%rip),%rdi
call   1060 <printf@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1090 <div@plt>
cvtsi2sd %eax,%xmm0
lea    0xe24(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xe43(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movsd  0xe64(%rip),%xmm0
movaps %xmm0,%xmm1
call   1050 <add_precise@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe56(%rip),%xmm0
movsd  0xe56(%rip),%xmm1
call   1070 <sub_precise@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe4b(%rip),%xmm0
movsd  0xe4b(%rip),%xmm1
call   10a0 <mult_precise@plt>
movsd  %xmm0,0x18(%rsp)
mov    $0x13,%edi
mov    $0x2,%esi
call   1030 <div_precise@plt>
movsd  %xmm0,0x20(%rsp)
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <add@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe16(%rip),%rdi
call   1060 <printf@plt>
lea    0xe1d(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1060 <printf@plt>
mov    $0xa,%edi
mov    $0x5,%esi
call   10b0 <sub@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe0c(%rip),%rdi
call   1060 <printf@plt>
lea    0xe19(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1060 <printf@plt>
mov    $0x14,%edi
mov    $0xa,%esi
call   1080 <mult@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe10(%rip),%rdi
call   1060 <printf@plt>
lea    0xe1e(%rip),%rdi
movsd  0x18(%rsp),%xmm0
call   1060 <printf@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1090 <div@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe19(%rip),%rdi
call   1060 <printf@plt>
lea    0xe3d(%rip),%rdi
movsd  0x20(%rsp),%xmm0
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Adding 1 + 1 = %d\0A\00"
@.str.1 = [23 x i8] c"Adding 1.5 + 1.5 = %f\0A\00"
@.str.2 = [25 x i8] c"Subtracting 10 - 5 = %d\0A\00"
@.str.3 = [31 x i8] c"Subtracting 20.5 - 0.234 = %f\0A\00"
@.str.4 = [26 x i8] c"Multiplying 20 * 10 = %d\0A\00"
@.str.5 = [32 x i8] c"Multiplying 10.5 and 50.2 = %f\0A\00"
@.str.6 = [48 x i8] c"Dividing 5 by 0 (did you check for this?) = %d\0A\00"
@.str.7 = [23 x i8] c"Dividing 19 by 2 = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call double @add_precise(double 1.500000e+00, double 1.500000e+00)
store double %6, double* %2
%7 = call double @sub_precise(double 2.050000e+01, double 2.340000e-01)
store double %7, double* %3
%8 = call double @mult_precise(double 1.050000e+01, double 5.020000e+01)
store double %8, double* %4
%9 = call double @div_precise(i32 19, i32 2)
store double %9, double* %5
%10 = call i32 @add(i32 1, i32 1)
%11 = sitofp i32 %10 to double
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %11)
%13 = load double, double* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %13)
%15 = call i32 @sub(i32 10, i32 5)
%16 = sitofp i32 %15 to double
%17 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %16)
%18 = load double, double* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = call i32 @mult(i32 20, i32 10)
%21 = sitofp i32 %20 to double
%22 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), double %21)
%23 = load double, double* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), double %23)
%25 = call i32 @div(i32 5, i32 0)
%26 = sitofp i32 %25 to double
%27 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), double %26)
%28 = load double, double* %5
%29 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), double %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Adding 1 + 1 = %d\0A\00"
@.str.1 = [23 x i8] c"Adding 1.5 + 1.5 = %f\0A\00"
@.str.2 = [25 x i8] c"Subtracting 10 - 5 = %d\0A\00"
@.str.3 = [31 x i8] c"Subtracting 20.5 - 0.234 = %f\0A\00"
@.str.4 = [26 x i8] c"Multiplying 20 * 10 = %d\0A\00"
@.str.5 = [32 x i8] c"Multiplying 10.5 and 50.2 = %f\0A\00"
@.str.6 = [48 x i8] c"Dividing 5 by 0 (did you check for this?) = %d\0A\00"
@.str.7 = [23 x i8] c"Dividing 19 by 2 = %f\0A\00"
define i32 @main() {
%1 = tail call double @add_precise(double 1.500000e+00, double 1.500000e+00)
%2 = tail call double @sub_precise(double 2.050000e+01, double 2.340000e-01)
%3 = tail call double @mult_precise(double 1.050000e+01, double 5.020000e+01)
%4 = tail call double @div_precise(i32 19, i32 2)
%5 = tail call i32 @add(i32 1, i32 1)
%6 = sitofp i32 %5 to double
%7 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %1)
%9 = tail call i32 @sub(i32 10, i32 5)
%10 = sitofp i32 %9 to double
%11 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %2)
%13 = tail call i32 @mult(i32 20, i32 10)
%14 = sitofp i32 %13 to double
%15 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), double %14)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), double %3)
%17 = tail call i32 @div(i32 5, i32 0)
%18 = sitofp i32 %17 to double
%19 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), double %18)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), double %4)
ret i32 0
}