#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 */
scalar_t__ malloc(int);
double objective_function(double *, double *, double *, int, int);
double *call_functions(double x[], double y[], double **simplex, int n, int k) {
  int i;
  double *function_values = (double *)malloc((n + 1) * sizeof(double));
  for (i = 0; i < (n + 1); i++) {
    function_values[i] = objective_function(x, y, simplex[i], n, k);
  }
  return function_values;
}


x86 assembly (clang, -O0):
<call_functions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11a5 <call_functions+0x85>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1040 <objective_function@plt>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1159 <call_functions+0x39>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_functions>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0xc(%rsp)
mov    %ecx,%ebx
mov    %rdx,0x10(%rsp)
mov    %rsi,%r12
mov    %rdi,%r13
lea    0x8(,%rbx,8),%edi
call   1030 <malloc@plt>
mov    %rax,%rbp
test   %ebx,%ebx
js     118b <call_functions+0x6b>
lea    0x1(%rbx),%r14d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
mov    (%rax,%r15,8),%rdx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%ecx
mov    0xc(%rsp),%r8d
call   1040 <objective_function@plt>
movsd  %xmm0,0x0(%rbp,%r15,8)
add    $0x1,%r15
cmp    %r15,%r14
jne    1160 <call_functions+0x40>
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double* @call_functions(double* %0, double* %1, double** %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
store double* %0, double** %6
store double* %1, double** %7
store double** %2, double*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %9
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %12
store i32 0, i32* %11
br label %20
20: ; preds = %40, %5
%21 = load i32, i32* %11
%22 = load i32, i32* %9
%23 = add nsw i32 %22, 1
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %43
25: ; preds = %20
%26 = load double*, double** %6
%27 = load double*, double** %7
%28 = load double**, double*** %8
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double*, double** %28, i64 %30
%32 = load double*, double** %31
%33 = load i32, i32* %9
%34 = load i32, i32* %10
%35 = call double @objective_function(double* %26, double* %27, double* %32, i32 %33, i32 %34)
%36 = load double*, double** %12
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double %35, double* %39
br label %40
40: ; preds = %25
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
br label %20
43: ; preds = %20
%44 = load double*, double** %12
ret double* %44
}

LLVM IR (-O2):
define double* @call_functions(double* %0, double* %1, double** nocapture %2, i32 %3, i32 %4) {
%6 = shl i32 %3, 3
%7 = add i32 %6, 8
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to double*
%10 = icmp slt i32 %3, 0
br i1 %10, label %22, label %11
11: ; preds = %5
%12 = add nuw i32 %3, 1
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 0, %11 ], [ %20, %14 ]
%16 = getelementptr inbounds double*, double** %2, i64 %15
%17 = load double*, double** %16
%18 = tail call double @objective_function(double* %0, double* %1, double* %17, i32 %3, i32 %4)
%19 = getelementptr inbounds double, double* %9, i64 %15
store double %18, double* %19
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %14
22: ; preds = %14, %5
ret double* %9
}