#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 */
double pow(double, double);
void poly(double x, double values[], int n) {
  for (int i = 1; i <= n; i++)
    values[i] = pow((double)x, (double)(i - 1));
}


x86 assembly (clang, -O0):
<poly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1166 <poly+0x56>
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
call   1030 <pow@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112b <poly+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poly>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    1215 <poly+0x105>
mov    %rdi,%r15
mov    %esi,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r14d
and    $0x3,%r14d
mov    $0x1,%r13d
cmp    $0x3,%rax
movsd  %xmm0,0x8(%rsp)
jb     11de <poly+0xce>
and    $0xfffffffc,%r12d
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xorps  %xmm1,%xmm1
cvtsi2sd %r13d,%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,0x8(%r15,%r13,8)
lea    0x1(%r13),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,0x10(%r15,%r13,8)
lea    0x2(%r13),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,0x18(%r15,%r13,8)
lea    0x3(%r13),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,0x20(%r15,%r13,8)
add    $0x4,%r13
cmp    %r13,%r12
jne    1160 <poly+0x50>
add    $0x1,%r13
test   %r14,%r14
je     1215 <poly+0x105>
lea    (%r15,%r13,8),%r15
add    $0xffffffff,%r13d
xor    %ebx,%ebx
nopl   (%rax)
lea    (%rbx,%r13,1),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11f0 <poly+0xe0>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @poly(double %0, double* %1, i32 %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double %0, double* %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 1, i32* %7
br label %8
8: ; preds = %22, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load double, double* %4
%14 = load i32, i32* %7
%15 = sub nsw i32 %14, 1
%16 = sitofp i32 %15 to double
%17 = call double @pow(double %13, double %16)
%18 = load double*, double** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
store double %17, double* %21
br label %22
22: ; preds = %12
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %8
25: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @poly(double %0, double* nocapture writeonly %1, i32 %2) {
%4 = icmp slt i32 %2, 1
br i1 %4, label %28, label %5
5: ; preds = %3
%6 = add nuw i32 %2, 1
%7 = zext i32 %6 to i64
%8 = add nsw i64 %7, -1
%9 = add nsw i64 %7, -2
%10 = and i64 %8, 3
%11 = icmp ult i64 %9, 3
br i1 %11, label %14, label %12
12: ; preds = %5
%13 = and i64 %8, -4
br label %29
14: ; preds = %29, %5
%15 = phi i64 [ 1, %5 ], [ %55, %29 ]
%16 = icmp eq i64 %10, 0
br i1 %16, label %28, label %17
17: ; preds = %14, %17
%18 = phi i64 [ %25, %17 ], [ %15, %14 ]
%19 = phi i64 [ %26, %17 ], [ 0, %14 ]
%20 = trunc i64 %18 to i32
%21 = add i32 %20, -1
%22 = sitofp i32 %21 to double
%23 = tail call double @pow(double %0, double %22)
%24 = getelementptr inbounds double, double* %1, i64 %18
store double %23, double* %24
%25 = add nuw nsw i64 %18, 1
%26 = add i64 %19, 1
%27 = icmp eq i64 %26, %10
br i1 %27, label %28, label %17
28: ; preds = %14, %17, %3
ret void
29: ; preds = %29, %12
%30 = phi i64 [ 1, %12 ], [ %55, %29 ]
%31 = phi i64 [ 0, %12 ], [ %56, %29 ]
%32 = trunc i64 %30 to i32
%33 = add nsw i32 %32, -1
%34 = sitofp i32 %33 to double
%35 = tail call double @pow(double %0, double %34)
%36 = getelementptr inbounds double, double* %1, i64 %30
store double %35, double* %36
%37 = add nuw nsw i64 %30, 1
%38 = trunc i64 %37 to i32
%39 = add nsw i32 %38, -1
%40 = sitofp i32 %39 to double
%41 = tail call double @pow(double %0, double %40)
%42 = getelementptr inbounds double, double* %1, i64 %37
store double %41, double* %42
%43 = add nuw nsw i64 %30, 2
%44 = trunc i64 %43 to i32
%45 = add nsw i32 %44, -1
%46 = sitofp i32 %45 to double
%47 = tail call double @pow(double %0, double %46)
%48 = getelementptr inbounds double, double* %1, i64 %43
store double %47, double* %48
%49 = add nuw nsw i64 %30, 3
%50 = trunc i64 %49 to i32
%51 = add i32 %50, -1
%52 = sitofp i32 %51 to double
%53 = tail call double @pow(double %0, double %52)
%54 = getelementptr inbounds double, double* %1, i64 %49
store double %53, double* %54
%55 = add nuw nsw i64 %30, 4
%56 = add i64 %31, 4
%57 = icmp eq i64 %56, %13
br i1 %57, label %14, label %29
}