#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 cos(double);
double exp(double);
double log(double);
double pow(double, int);
int /*<<< orphan*/ printf(char *, double, double);
double sin(double);
int main() {
  double x = 3;
  printf("cos(%d) = %.3f \n", x, cos(x));
  printf("sin(%d) = %.3f \n", x, sin(x));
  printf("exp(%d) = %.3f \n", x, exp(x));
  printf("log(%d) = %.3f \n", x, log(x));
  printf("pow(%d,2) = %.3f \n", x, pow(x, 2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1080 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf00(%rip),%rdi
movsd  0xed0(%rip),%xmm0
movsd  0xed0(%rip),%xmm1
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
movsd  0xec4(%rip),%xmm1
movsd  0xeac(%rip),%xmm0
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
movsd  0xeb0(%rip),%xmm1
movsd  0xe90(%rip),%xmm0
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
movsd  0xe9c(%rip),%xmm1
movsd  0xe74(%rip),%xmm0
call   1030 <printf@plt>
movsd  0xe67(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
lea    0xebf(%rip),%rdi
movsd  0xe4b(%rip),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"cos(%d) = %.3f \0A\00"
@.str.1 = [17 x i8] c"sin(%d) = %.3f \0A\00"
@.str.2 = [17 x i8] c"exp(%d) = %.3f \0A\00"
@.str.3 = [17 x i8] c"log(%d) = %.3f \0A\00"
@.str.4 = [19 x i8] c"pow(%d,2) = %.3f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
store i32 0, i32* %1
store double 3.000000e+00, double* %2
%3 = load double, double* %2
%4 = load double, double* %2
%5 = call double @cos(double %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %3, double %5)
%7 = load double, double* %2
%8 = load double, double* %2
%9 = call double @sin(double %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), double %7, double %9)
%11 = load double, double* %2
%12 = load double, double* %2
%13 = call double @exp(double %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %11, double %13)
%15 = load double, double* %2
%16 = load double, double* %2
%17 = call double @log(double %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %15, double %17)
%19 = load double, double* %2
%20 = load double, double* %2
%21 = call double @pow(double %20, i32 2)
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), double %19, double %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"cos(%d) = %.3f \0A\00"
@.str.1 = [17 x i8] c"sin(%d) = %.3f \0A\00"
@.str.2 = [17 x i8] c"exp(%d) = %.3f \0A\00"
@.str.3 = [17 x i8] c"log(%d) = %.3f \0A\00"
@.str.4 = [19 x i8] c"pow(%d,2) = %.3f \0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double 3.000000e+00, double 0xBFEFAE04BE85E5D2)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), double 3.000000e+00, double 0x3FC210386DB6D55B)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double 3.000000e+00, double 0x403415E5BF6FB106)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double 3.000000e+00, double 0x3FF193EA7AAD030B)
%5 = tail call double @pow(double 3.000000e+00, i32 2)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), double 3.000000e+00, double %5)
ret i32 0
}