#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int polynomial(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  clock_t tic = clock();
  int n;
  double x, poly;
  printf("enter the x value: ");
  scanf("%lf", &x);
  poly = 3 * polynomial(x, 5) + 2 * polynomial(x, 4) - 5 * polynomial(x, 3) -
         polynomial(x, 2) + 7 * polynomial(x, 1) - 6 * polynomial(x, 0);
  printf("%.2lf\n", poly);
  clock_t toc = clock();
  printf("elapsed: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
mov    $0x5,%edi
call   1030 <polynomial@plt>
imul   $0x3,%eax,%eax
mov    %eax,-0x44(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x4,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x3,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
imul   $0x5,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
imul   $0x7,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
movsd  -0x20(%rbp),%xmm0
xor    %edi,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   $0x6,%ecx,%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xdf3(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d9d(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdc9(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm0
mov    $0x5,%edi
call   1030 <polynomial@plt>
lea    (%rax,%rax,2),%ebp
movsd  0x8(%rsp),%xmm0
mov    $0x4,%edi
call   1030 <polynomial@plt>
lea    0x0(%rbp,%rax,2),%ebp
movsd  0x8(%rsp),%xmm0
mov    $0x3,%edi
call   1030 <polynomial@plt>
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
movsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <polynomial@plt>
sub    %eax,%ebp
movsd  0x8(%rsp),%xmm0
mov    $0x1,%edi
call   1030 <polynomial@plt>
lea    0x0(,%rax,8),%ebx
sub    %eax,%ebx
add    %ebp,%ebx
movsd  0x8(%rsp),%xmm0
xor    %edi,%edi
call   1030 <polynomial@plt>
add    %eax,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
lea    0xe1c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2dcc(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdf8(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"enter the x value: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [7 x i8] c"%.2lf\0A\00"
@.str.3 = [21 x i8] c"elapsed: %f seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca i64
store i32 0, i32* %1
%7 = call i64 (...) @clock()
store i64 %7, i64* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%10 = load double, double* %4
%11 = call i32 @polynomial(double %10, i32 5)
%12 = mul nsw i32 3, %11
%13 = load double, double* %4
%14 = call i32 @polynomial(double %13, i32 4)
%15 = mul nsw i32 2, %14
%16 = add nsw i32 %12, %15
%17 = load double, double* %4
%18 = call i32 @polynomial(double %17, i32 3)
%19 = mul nsw i32 5, %18
%20 = sub nsw i32 %16, %19
%21 = load double, double* %4
%22 = call i32 @polynomial(double %21, i32 2)
%23 = sub nsw i32 %20, %22
%24 = load double, double* %4
%25 = call i32 @polynomial(double %24, i32 1)
%26 = mul nsw i32 7, %25
%27 = add nsw i32 %23, %26
%28 = load double, double* %4
%29 = call i32 @polynomial(double %28, i32 0)
%30 = mul nsw i32 6, %29
%31 = sub nsw i32 %27, %30
%32 = sitofp i32 %31 to double
store double %32, double* %5
%33 = load double, double* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %33)
%35 = call i64 (...) @clock()
store i64 %35, i64* %6
%36 = load i64, i64* %6
%37 = load i64, i64* %2
%38 = sub nsw i64 %36, %37
%39 = sitofp i64 %38 to double
%40 = load double, double* @CLOCKS_PER_SEC
%41 = fdiv double %39, %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"enter the x value: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [7 x i8] c"%.2lf\0A\00"
@.str.3 = [21 x i8] c"elapsed: %f seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca double
%2 = tail call i64 (...) @clock()
%3 = bitcast double* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%6 = load double, double* %1
%7 = call i32 @polynomial(double %6, i32 5)
%8 = mul nsw i32 %7, 3
%9 = load double, double* %1
%10 = call i32 @polynomial(double %9, i32 4)
%11 = shl nsw i32 %10, 1
%12 = add nsw i32 %11, %8
%13 = load double, double* %1
%14 = call i32 @polynomial(double %13, i32 3)
%15 = mul i32 %14, -5
%16 = add i32 %12, %15
%17 = load double, double* %1
%18 = call i32 @polynomial(double %17, i32 2)
%19 = sub i32 %16, %18
%20 = load double, double* %1
%21 = call i32 @polynomial(double %20, i32 1)
%22 = mul nsw i32 %21, 7
%23 = add nsw i32 %19, %22
%24 = load double, double* %1
%25 = call i32 @polynomial(double %24, i32 0)
%26 = mul i32 %25, -6
%27 = add i32 %23, %26
%28 = sitofp i32 %27 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %28)
%30 = call i64 (...) @clock()
%31 = sub nsw i64 %30, %2
%32 = sitofp i64 %31 to double
%33 = load double, double* @CLOCKS_PER_SEC
%34 = fdiv double %32, %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %34)
ret i32 0
}