#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 polynomial(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  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);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
mov    $0x5,%edi
call   1030 <polynomial@plt>
imul   $0x3,%eax,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x4,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x3,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   $0x5,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   $0x7,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
xor    %edi,%edi
call   1030 <polynomial@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   $0x6,%ecx,%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe0e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
mov    $0x5,%edi
call   1030 <polynomial@plt>
lea    (%rax,%rax,2),%ebx
movsd  (%rsp),%xmm0
mov    $0x4,%edi
call   1030 <polynomial@plt>
lea    (%rbx,%rax,2),%ebx
movsd  (%rsp),%xmm0
mov    $0x3,%edi
call   1030 <polynomial@plt>
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
movsd  (%rsp),%xmm0
mov    $0x2,%edi
call   1030 <polynomial@plt>
sub    %eax,%ebx
movsd  (%rsp),%xmm0
mov    $0x1,%edi
call   1030 <polynomial@plt>
lea    0x0(,%rax,8),%ebp
sub    %eax,%ebp
add    %ebx,%ebp
movsd  (%rsp),%xmm0
xor    %edi,%edi
call   1030 <polynomial@plt>
add    %eax,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%7 = load double, double* %3
%8 = call i32 @polynomial(double %7, i32 5)
%9 = mul nsw i32 3, %8
%10 = load double, double* %3
%11 = call i32 @polynomial(double %10, i32 4)
%12 = mul nsw i32 2, %11
%13 = add nsw i32 %9, %12
%14 = load double, double* %3
%15 = call i32 @polynomial(double %14, i32 3)
%16 = mul nsw i32 5, %15
%17 = sub nsw i32 %13, %16
%18 = load double, double* %3
%19 = call i32 @polynomial(double %18, i32 2)
%20 = sub nsw i32 %17, %19
%21 = load double, double* %3
%22 = call i32 @polynomial(double %21, i32 1)
%23 = mul nsw i32 7, %22
%24 = add nsw i32 %20, %23
%25 = load double, double* %3
%26 = call i32 @polynomial(double %25, i32 0)
%27 = mul nsw i32 6, %26
%28 = sub nsw i32 %24, %27
%29 = sitofp i32 %28 to double
store double %29, double* %4
%30 = load double, double* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %30)
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"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = call i32 @polynomial(double %5, i32 5)
%7 = mul nsw i32 %6, 3
%8 = load double, double* %1
%9 = call i32 @polynomial(double %8, i32 4)
%10 = shl nsw i32 %9, 1
%11 = add nsw i32 %10, %7
%12 = load double, double* %1
%13 = call i32 @polynomial(double %12, i32 3)
%14 = mul i32 %13, -5
%15 = add i32 %11, %14
%16 = load double, double* %1
%17 = call i32 @polynomial(double %16, i32 2)
%18 = sub i32 %15, %17
%19 = load double, double* %1
%20 = call i32 @polynomial(double %19, i32 1)
%21 = mul nsw i32 %20, 7
%22 = add nsw i32 %18, %21
%23 = load double, double* %1
%24 = call i32 @polynomial(double %23, i32 0)
%25 = mul i32 %24, -6
%26 = add i32 %22, %25
%27 = sitofp i32 %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %27)
ret i32 0
}