#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 pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  int i, sum = 0, j;
  int a[10];
  int x;
  printf("Enter the Number of Terms...\n");
  scanf("%d", &n);
  printf("N=%d\n", n);
  printf("Enter %d Co-Efficients...\n", n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  printf("Enter the Value of x...\n");
  scanf("%d", &x);
  printf("%d\n", x);
  for (i = 0; i <= n; i++)
    sum = sum + a[i] * pow(x, i);
  printf("Result= %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c2 <main+0x92>
movslq -0xc(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6f(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118d <main+0x5d>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x44(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     123e <main+0x10e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x48(%rbp)
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x44(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <pow@plt>
mov    -0x4c(%rbp),%ecx
mov    %eax,%edx
mov    -0x48(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f8 <main+0xc8>
mov    -0x10(%rbp),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
lea    0xea3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%esi
lea    0xe91(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11cd <main+0x8d>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe5d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11b0 <main+0x70>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
lea    0xe20(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
js     1236 <main+0xf6>
xor    %ebx,%ebx
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%ebp
mov    0xc(%rsp),%edi
mov    %ebx,%esi
call   1060 <pow@plt>
imul   %ebp,%eax
add    %eax,%r15d
lea    0x1(%rbx),%rax
movslq 0x8(%rsp),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     1210 <main+0xd0>
lea    0xde7(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Enter the Number of Terms...\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"N=%d\0A\00"
@.str.3 = [27 x i8] c"Enter %d Co-Efficients...\0A\00"
@.str.4 = [25 x i8] c"Enter the Value of x...\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [12 x i8] c"Result= %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [10 x i32]
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %12)
store i32 0, i32* %3
br label %14
14: ; preds = %23, %0
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %14
26: ; preds = %14
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%29 = load i32, i32* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %29)
store i32 0, i32* %3
br label %31
31: ; preds = %46, %26
%32 = load i32, i32* %3
%33 = load i32, i32* %2
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %49
35: ; preds = %31
%36 = load i32, i32* %4
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = load i32, i32* %7
%42 = load i32, i32* %3
%43 = call i32 @pow(i32 %41, i32 %42)
%44 = mul nsw i32 %40, %43
%45 = add nsw i32 %36, %44
store i32 %45, i32* %4
br label %46
46: ; preds = %35
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %31
49: ; preds = %31
%50 = load i32, i32* %4
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %50)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"N=%d\0A\00"
@.str.3 = [27 x i8] c"Enter %d Co-Efficients...\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [12 x i8] c"Result= %d\0A\00"
@str = [29 x i8] c"Enter the Number of Terms...\00"
@str.7 = [24 x i8] c"Enter the Value of x...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast [10 x i32]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %16, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %15, label %23
23: ; preds = %15, %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.7, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %1
%29 = icmp slt i32 %28, 0
br i1 %29, label %44, label %30
30: ; preds = %23, %30
%31 = phi i64 [ %40, %30 ], [ 0, %23 ]
%32 = phi i32 [ %39, %30 ], [ 0, %23 ]
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %31
%34 = load i32, i32* %33
%35 = load i32, i32* %3
%36 = trunc i64 %31 to i32
%37 = call i32 @pow(i32 %35, i32 %36)
%38 = mul nsw i32 %37, %34
%39 = add nsw i32 %38, %32
%40 = add nuw nsw i64 %31, 1
%41 = load i32, i32* %1
%42 = sext i32 %41 to i64
%43 = icmp slt i64 %31, %42
br i1 %43, label %30, label %44
44: ; preds = %30, %23
%45 = phi i32 [ 0, %23 ], [ %39, %30 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %45)
ret i32 0
}