#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 evaluatePoly(int *, int, int);
int /*<<< orphan*/ *gets(char *);
int parseLineToGetNumArr(char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int coeff[1000 + 1], input[10000], value[10000], polyDegree, numInput, i;
  char line[10000];
  while (gets(line) != NULL) {
    polyDegree = parseLineToGetNumArr(line, coeff);
    polyDegree--;
    gets(line);
    numInput = parseLineToGetNumArr(line, input);
    for (i = 0; i < numInput; i++)
      value[i] = evaluatePoly(coeff, polyDegree, input[i]);
    for (i = 0; i < numInput; i++) {
      if (i > 0)
        printf(" ");
      printf("%d", value[i]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x16f50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x16f50(%rbp),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
je     128f <main+0x14f>
lea    -0x16f50(%rbp),%rdi
lea    -0xfb0(%rbp),%rsi
call   1060 <parseLineToGetNumArr@plt>
mov    %eax,-0x14834(%rbp)
mov    -0x14834(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14834(%rbp)
lea    -0x16f50(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x16f50(%rbp),%rdi
lea    -0xabf0(%rbp),%rsi
call   1060 <parseLineToGetNumArr@plt>
mov    %eax,-0x14838(%rbp)
movl   $0x0,-0x1483c(%rbp)
mov    -0x1483c(%rbp),%eax
cmp    -0x14838(%rbp),%eax
jge    1215 <main+0xd5>
lea    -0xfb0(%rbp),%rdi
mov    -0x14834(%rbp),%esi
movslq -0x1483c(%rbp),%rax
mov    -0xabf0(%rbp,%rax,4),%edx
call   1040 <evaluatePoly@plt>
mov    %eax,%ecx
movslq -0x1483c(%rbp),%rax
mov    %ecx,-0x14830(%rbp,%rax,4)
mov    -0x1483c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1483c(%rbp)
jmp    11bf <main+0x7f>
movl   $0x0,-0x1483c(%rbp)
mov    -0x1483c(%rbp),%eax
cmp    -0x14838(%rbp),%eax
jge    127c <main+0x13c>
cmpl   $0x0,-0x1483c(%rbp)
jle    124c <main+0x10c>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1483c(%rbp),%rax
mov    -0x14830(%rbp,%rax,4),%esi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1483c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1483c(%rbp)
jmp    121f <main+0xdf>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0x16f50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x16f48,%rsp
mov    %rsp,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     1259 <main+0x109>
mov    %rsp,%r14
lea    0x2710(%rsp),%rbx
lea    0xe7c(%rip),%r12
jmp    11ab <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     1259 <main+0x109>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <parseLineToGetNumArr@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <gets@plt>
mov    %r14,%rdi
lea    0xd300(%rsp),%rsi
call   1070 <parseLineToGetNumArr@plt>
test   %eax,%eax
jle    1190 <main+0x40>
mov    %eax,%r13d
add    $0xffffffff,%ebp
mov    %eax,%r15d
xor    %r14d,%r14d
mov    0xd300(%rsp,%r14,4),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <evaluatePoly@plt>
mov    %eax,0x36c0(%rsp,%r14,4)
add    $0x1,%r14
cmp    %r14,%r15
jne    11e0 <main+0x90>
test   %r13d,%r13d
mov    %rsp,%r14
jle    1190 <main+0x40>
mov    0x36c0(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r13d
je     1190 <main+0x40>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0x36c0(%rsp,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1230 <main+0xe0>
jmp    1190 <main+0x40>
xor    %eax,%eax
add    $0x16f48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1001 x i32]
%3 = alloca [10000 x i32]
%4 = alloca [10000 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10000 x i8]
store i32 0, i32* %1
br label %9
9: ; preds = %61, %0
%10 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%11 = call i32* @gets(i8* %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %63
13: ; preds = %9
%14 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%15 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 0
%16 = call i32 @parseLineToGetNumArr(i8* %14, i32* %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = add nsw i32 %17, -1
store i32 %18, i32* %5
%19 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%20 = call i32* @gets(i8* %19)
%21 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%22 = getelementptr inbounds [10000 x i32], [10000 x i32]* %3, i64 0, i64 0
%23 = call i32 @parseLineToGetNumArr(i8* %21, i32* %22)
store i32 %23, i32* %6
store i32 0, i32* %7
br label %24
24: ; preds = %39, %13
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %42
28: ; preds = %24
%29 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 0
%30 = load i32, i32* %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10000 x i32], [10000 x i32]* %3, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 @evaluatePoly(i32* %29, i32 %30, i32 %34)
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10000 x i32], [10000 x i32]* %4, i64 0, i64 %37
store i32 %35, i32* %38
br label %39
39: ; preds = %28
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %24
42: ; preds = %24
store i32 0, i32* %7
br label %43
43: ; preds = %58, %42
%44 = load i32, i32* %7
%45 = load i32, i32* %6
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %61
47: ; preds = %43
%48 = load i32, i32* %7
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %52
52: ; preds = %50, %47
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10000 x i32], [10000 x i32]* %4, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %52
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %43
61: ; preds = %43
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %9
63: ; preds = %9
ret i32 0
}

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