#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 */
long poly_evaluate(int const *, int, int);
void calculate_values(long *values, const int *coeffs, int terms, int count) {
  for (int i = 0; i < count; i++)
    values[i] = poly_evaluate(coeffs, terms, i + 1);
}


x86 assembly (clang, -O0):
<calculate_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1168 <calculate_values+0x58>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
call   1030 <poly_evaluate@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <calculate_values+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_values>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    114d <calculate_values+0x3d>
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
mov    %ecx,%r13d
xor    %ebx,%ebx
nopl   (%rax)
lea    0x1(%rbx),%rbp
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <poly_evaluate@plt>
mov    %rax,(%r12,%rbx,8)
mov    %rbp,%rbx
cmp    %rbp,%r13
jne    1130 <calculate_values+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @calculate_values(i64* nocapture writeonly %0, i32* %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %9
8: ; preds = %9, %4
ret void
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %11, %9 ]
%11 = add nuw nsw i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = tail call i64 @poly_evaluate(i32* %1, i32 %2, i32 %12)
%14 = getelementptr inbounds i64, i64* %0, i64 %10
store i64 %13, i64* %14
%15 = icmp eq i64 %11, %7
br i1 %15, label %8, label %9
}