#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int arr[100];
  int n, i, sum, x;
  printf("Enter n\n");
  scanf("%d", &n);
  printf("Enter %d coefficients\n", (n + 1));
  for (i = 0; i <= n; i++)
    scanf("%d", &arr[i]);
  printf("Enter x\n");
  scanf("%d", &x);
  sum = arr[n] * x;
  for (i = n - 1; i >= 1; i--)
    sum = (sum + arr[i]) * x;
  sum += arr[0];
  printf("Sum of term = %d\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1a4(%rbp),%esi
add    $0x1,%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jg     11bb <main+0x9b>
movslq -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe67(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    1174 <main+0x54>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe39(%rip),%rdi
lea    -0x1b0(%rbp),%rsi
call   1040 <scanf@plt>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
imul   -0x1b0(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
cmpl   $0x1,-0x1a8(%rbp)
jl     1248 <main+0x128>
mov    -0x1ac(%rbp),%eax
movslq -0x1a8(%rbp),%rcx
add    -0x1a0(%rbp,%rcx,4),%eax
imul   -0x1b0(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1a8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1a8(%rbp)
jmp    1206 <main+0xe6>
mov    -0x1a0(%rbp),%eax
add    -0x1ac(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%esi
add    $0x1,%esi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
js     11ad <main+0x7d>
mov    $0xffffffffffffffff,%r15
lea    0x10(%rsp),%rbx
lea    0xe78(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movslq 0x8(%rsp),%rax
add    $0x1,%r15
add    $0x4,%rbx
cmp    %rax,%r15
jl     1190 <main+0x60>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
lea    0xe40(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
movslq 0x8(%rsp),%rcx
mov    0xc(%rsp),%eax
mov    0x10(%rsp,%rcx,4),%esi
imul   %eax,%esi
cmp    $0x2,%rcx
jl     1204 <main+0xd4>
mov    %ecx,%ecx
add    $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
lea    -0x2(%rcx),%edx
add    0x10(%rsp,%rdx,4),%esi
imul   %eax,%esi
add    $0xffffffffffffffff,%rcx
cmp    $0x2,%rcx
ja     11f0 <main+0xc0>
add    0x10(%rsp),%esi
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Enter n\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"Enter %d coefficients\0A\00"
@.str.3 = [9 x i8] c"Enter x\0A\00"
@.str.4 = [18 x i8] c"Sum of term = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 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* %3)
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %10)
store i32 0, i32* %4
br label %12
12: ; preds = %21, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %12
24: ; preds = %12
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = load i32, i32* %6
%32 = mul nsw i32 %30, %31
store i32 %32, i32* %5
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 1
store i32 %34, i32* %4
br label %35
35: ; preds = %47, %24
%36 = load i32, i32* %4
%37 = icmp sge i32 %36, 1
br i1 %37, label %38, label %50
38: ; preds = %35
%39 = load i32, i32* %5
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = add nsw i32 %39, %43
%45 = load i32, i32* %6
%46 = mul nsw i32 %44, %45
store i32 %46, i32* %5
br label %47
47: ; preds = %38
%48 = load i32, i32* %4
%49 = add nsw i32 %48, -1
store i32 %49, i32* %4
br label %35
50: ; preds = %35
%51 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%52 = load i32, i32* %51
%53 = load i32, i32* %5
%54 = add nsw i32 %53, %52
store i32 %54, i32* %5
%55 = load i32, i32* %5
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"Enter %d coefficients\0A\00"
@.str.4 = [18 x i8] c"Sum of term = %d\0A\00"
@str = [8 x i8] c"Enter n\00"
@str.5 = [8 x i8] c"Enter x\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [100 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 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* %2)
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %0, %14
%15 = phi i64 [ %18, %14 ], [ 0, %0 ]
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = add nuw nsw i64 %15, 1
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %15, %20
br i1 %21, label %14, label %22
22: ; preds = %14, %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.5, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* %3
%30 = mul nsw i32 %28, %29
%31 = icmp sgt i32 %25, 1
br i1 %31, label %32, label %44
32: ; preds = %22
%33 = zext i32 %25 to i64
br label %34
34: ; preds = %32, %34
%35 = phi i64 [ %33, %32 ], [ %37, %34 ]
%36 = phi i32 [ %30, %32 ], [ %42, %34 ]
%37 = add nsw i64 %35, -1
%38 = and i64 %37, 4294967295
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, %36
%42 = mul nsw i32 %41, %29
%43 = icmp ugt i64 %35, 2
br i1 %43, label %34, label %44
44: ; preds = %34, %22
%45 = phi i32 [ %30, %22 ], [ %42, %34 ]
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%47 = load i32, i32* %46
%48 = add nsw i32 %47, %45
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %48)
ret i32 0
}