#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 power(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, x, i, output = 0;
  int a[11] = {0};
  int pos = 0;
  scanf("%d", &n);
  scanf("%d", &x);
  for (i = 0; i <= n; i++)
    scanf("%d", &a[i]);
  for (i = n; i >= 0; i--) {
    output = output + (a[n - i] * power(x, i));
  }
  printf("%d", output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x2c,%edx
call   1050 <memset@plt>
movl   $0x0,-0x44(%rbp)
lea    0xe8c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe7c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c9 <main+0x89>
movslq -0x10(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4a(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1194 <main+0x54>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1217 <main+0xd7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
cltq
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <power@plt>
mov    -0x4c(%rbp),%ecx
mov    %eax,%edx
mov    -0x48(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11cf <main+0x8f>
mov    -0x14(%rbp),%esi
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x2c(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xeab(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
xor    %r14d,%r14d
cmpl   $0x0,0x8(%rsp)
js     120a <main+0xda>
mov    $0xffffffffffffffff,%rbx
lea    0x10(%rsp),%rbp
lea    0xe70(%rip),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
movslq 0x8(%rsp),%r12
add    $0x1,%rbx
add    $0x4,%rbp
cmp    %r12,%rbx
jl     1190 <main+0x60>
test   %r12d,%r12d
js     120a <main+0xda>
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%edi
mov    %r12d,%esi
call   1030 <power@plt>
mov    %eax,%r14d
imul   %ebx,%r14d
test   %r12d,%r12d
je     120a <main+0xda>
lea    0x1(%r12),%ebp
mov    $0x1,%r15d
sub    %r12,%r15
nopl   0x0(%rax)
lea    -0x2(%rbp),%esi
movslq 0x8(%rsp),%rax
add    %r15,%rax
mov    0x10(%rsp,%rax,4),%ebx
mov    0xc(%rsp),%edi
call   1030 <power@plt>
imul   %ebx,%eax
add    %eax,%r14d
add    $0xffffffff,%ebp
add    $0x1,%r15
cmp    $0x1,%ebp
jg     11e0 <main+0xb0>
lea    0xdef(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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