#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*/ assert(int);
int poly(double *, double, long);
int poly_6_3a(double *, double, long);
int polyh(double *, double, long);
int main(int argc, char *argv[]) {
  double a[10 + 1] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
  double x = 2;
  long degree = 10;
  assert(poly(a, x, degree) ==
         2 + 4 + 8 + 16 + 32 + (2 + 4 + 8 + 16 + 32) * 32);
  assert(poly_6_3a(a, x, degree) ==
         2 + 4 + 8 + 16 + 32 + (2 + 4 + 8 + 16 + 32) * 32);
  assert(poly(a, x, degree) == polyh(a, x, degree));
  x = 1;
  degree = 1000;
  double b[1000 + 1];
  for (int c = 0; c < 1000; c++) {
    poly(b, x, degree);
  }
  for (int c = 0; c < 1000; c++) {
    poly_6_3a(b, x, degree);
  }
  for (int c = 0; c < 1000; c++) {
    polyh(b, x, degree);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1fe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x58,%edx
call   1050 <memcpy@plt>
movsd  0xe82(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movq   $0xa,-0x80(%rbp)
lea    -0x70(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
mov    -0x80(%rbp),%rsi
call   1040 <poly@plt>
cmp    $0x7fe,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x70(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
mov    -0x80(%rbp),%rsi
call   1070 <poly_6_3a@plt>
cmp    $0x7fe,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x70(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
mov    -0x80(%rbp),%rsi
call   1040 <poly@plt>
mov    %eax,-0x1fe0(%rbp)
lea    -0x70(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
mov    -0x80(%rbp),%rsi
call   1060 <polyh@plt>
mov    %eax,%ecx
mov    -0x1fe0(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  0xddc(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movq   $0x3e8,-0x80(%rbp)
movl   $0x0,-0x1fd4(%rbp)
cmpl   $0x3e8,-0x1fd4(%rbp)
jge    1274 <main+0x124>
lea    -0x1fd0(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
mov    -0x80(%rbp),%rsi
call   1040 <poly@plt>
mov    -0x1fd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1fd4(%rbp)
jmp    123b <main+0xeb>
movl   $0x0,-0x1fd8(%rbp)
cmpl   $0x3e8,-0x1fd8(%rbp)
jge    12b7 <main+0x167>
lea    -0x1fd0(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
mov    -0x80(%rbp),%rsi
call   1070 <poly_6_3a@plt>
mov    -0x1fd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1fd8(%rbp)
jmp    127e <main+0x12e>
movl   $0x0,-0x1fdc(%rbp)
cmpl   $0x3e8,-0x1fdc(%rbp)
jge    12fa <main+0x1aa>
lea    -0x1fd0(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
mov    -0x80(%rbp),%rsi
call   1060 <polyh@plt>
mov    -0x1fdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1fdc(%rbp)
jmp    12c1 <main+0x171>
xor    %eax,%eax
add    $0x1fe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x1fa8,%rsp
mov    0xf10(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xef4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe84(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
movsd  0xe65(%rip),%xmm0
mov    $0xa,%esi
mov    %rbx,%rdi
call   1040 <poly@plt>
xor    %edi,%edi
cmp    $0x7fe,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0xa,%esi
mov    %rbx,%rdi
movsd  0xe38(%rip),%xmm0
call   1060 <poly_6_3a@plt>
xor    %edi,%edi
cmp    $0x7fe,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0xa,%esi
mov    %rbx,%rdi
movsd  0xe13(%rip),%xmm0
call   1040 <poly@plt>
mov    %eax,%ebp
mov    $0xa,%esi
mov    %rbx,%rdi
movsd  0xdfc(%rip),%xmm0
call   1050 <polyh@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1030 <assert@plt>
mov    $0x3e8,%ebp
lea    0x60(%rsp),%rbx
mov    $0x3e8,%esi
mov    %rbx,%rdi
movsd  0xdd8(%rip),%xmm0
call   1040 <poly@plt>
add    $0xffffffff,%ebp
jne    1220 <main+0xe0>
mov    $0x3e8,%ebp
lea    0x60(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x3e8,%esi
mov    %rbx,%rdi
movsd  0xda8(%rip),%xmm0
call   1060 <poly_6_3a@plt>
add    $0xffffffff,%ebp
jne    1250 <main+0x110>
mov    $0x3e8,%ebp
lea    0x60(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x3e8,%esi
mov    %rbx,%rdi
movsd  0xd78(%rip),%xmm0
call   1050 <polyh@plt>
add    $0xffffffff,%ebp
jne    1280 <main+0x140>
xor    %eax,%eax
add    $0x1fa8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.a = [11 x double] [double 0.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [11 x double]
%7 = alloca double
%8 = alloca i64
%9 = alloca [1001 x double]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [11 x double]* %6 to i8*
store double 2.000000e+00, double* %7
store i64 10, i64* %8
%14 = getelementptr inbounds [11 x double], [11 x double]* %6, i64 0, i64 0
%15 = load double, double* %7
%16 = load i64, i64* %8
%17 = call i32 @poly(double* %14, double %15, i64 %16)
%18 = icmp eq i32 %17, 2046
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds [11 x double], [11 x double]* %6, i64 0, i64 0
%22 = load double, double* %7
%23 = load i64, i64* %8
%24 = call i32 @poly_6_3a(double* %21, double %22, i64 %23)
%25 = icmp eq i32 %24, 2046
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = getelementptr inbounds [11 x double], [11 x double]* %6, i64 0, i64 0
%29 = load double, double* %7
%30 = load i64, i64* %8
%31 = call i32 @poly(double* %28, double %29, i64 %30)
%32 = getelementptr inbounds [11 x double], [11 x double]* %6, i64 0, i64 0
%33 = load double, double* %7
%34 = load i64, i64* %8
%35 = call i32 @polyh(double* %32, double %33, i64 %34)
%36 = icmp eq i32 %31, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
store double 1.000000e+00, double* %7
store i64 1000, i64* %8
store i32 0, i32* %10
br label %39
39: ; preds = %47, %2
%40 = load i32, i32* %10
%41 = icmp slt i32 %40, 1000
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = getelementptr inbounds [1001 x double], [1001 x double]* %9, i64 0, i64 0
%44 = load double, double* %7
%45 = load i64, i64* %8
%46 = call i32 @poly(double* %43, double %44, i64 %45)
br label %47
47: ; preds = %42
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
br label %39
50: ; preds = %39
store i32 0, i32* %11
br label %51
51: ; preds = %59, %50
%52 = load i32, i32* %11
%53 = icmp slt i32 %52, 1000
br i1 %53, label %54, label %62
54: ; preds = %51
%55 = getelementptr inbounds [1001 x double], [1001 x double]* %9, i64 0, i64 0
%56 = load double, double* %7
%57 = load i64, i64* %8
%58 = call i32 @poly_6_3a(double* %55, double %56, i64 %57)
br label %59
59: ; preds = %54
%60 = load i32, i32* %11
%61 = add nsw i32 %60, 1
store i32 %61, i32* %11
br label %51
62: ; preds = %51
store i32 0, i32* %12
br label %63
63: ; preds = %71, %62
%64 = load i32, i32* %12
%65 = icmp slt i32 %64, 1000
br i1 %65, label %66, label %74
66: ; preds = %63
%67 = getelementptr inbounds [1001 x double], [1001 x double]* %9, i64 0, i64 0
%68 = load double, double* %7
%69 = load i64, i64* %8
%70 = call i32 @polyh(double* %67, double %68, i64 %69)
br label %71
71: ; preds = %66
%72 = load i32, i32* %12
%73 = add nsw i32 %72, 1
store i32 %73, i32* %12
br label %63
74: ; preds = %63
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [11 x double] [double 0.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [11 x double]
%4 = alloca [1001 x double]
%5 = bitcast [11 x double]* %3 to i8*
%6 = getelementptr inbounds [11 x double], [11 x double]* %3, i64 0, i64 0
%7 = call i32 @poly(double* %6, double 2.000000e+00, i64 10)
%8 = icmp eq i32 %7, 2046
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @poly_6_3a(double* %6, double 2.000000e+00, i64 10)
%12 = icmp eq i32 %11, 2046
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @poly(double* %6, double 2.000000e+00, i64 10)
%16 = call i32 @polyh(double* %6, double 2.000000e+00, i64 10)
%17 = icmp eq i32 %15, %16
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = bitcast [1001 x double]* %4 to i8*
%21 = getelementptr inbounds [1001 x double], [1001 x double]* %4, i64 0, i64 0
br label %22
22: ; preds = %2, %22
%23 = phi i32 [ 0, %2 ], [ %25, %22 ]
%24 = call i32 @poly(double* %21, double 1.000000e+00, i64 1000)
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, 1000
br i1 %26, label %27, label %22
27: ; preds = %22, %27
%28 = phi i32 [ %30, %27 ], [ 0, %22 ]
%29 = call i32 @poly_6_3a(double* %21, double 1.000000e+00, i64 1000)
%30 = add nuw nsw i32 %28, 1
%31 = icmp eq i32 %30, 1000
br i1 %31, label %33, label %27
32: ; preds = %33
ret i32 0
33: ; preds = %27, %33
%34 = phi i32 [ %36, %33 ], [ 0, %27 ]
%35 = call i32 @polyh(double* %21, double 1.000000e+00, i64 1000)
%36 = add nuw nsw i32 %34, 1
%37 = icmp eq i32 %36, 1000
br i1 %37, label %32, label %33
}