#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 *minimize(double *, double *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char const *argv[]) {
  int n = 3;
  int k = 10;
  int i;
  double *result = (double *)malloc(n * sizeof(double));
  double x[10] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
  double y[10] = {2.98,  6.03,  11.05, 17.99, 27.1,
                  39.05, 50.89, 67.1,  82.77, 103.2};
  result = minimize(x, y, n, k);
  for (i = 0; i < n; i++) {
    printf("%.4f ", result[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1060 <minimize@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fd <main+0xbd>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xeb8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c8 <main+0x88>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
mov    $0x18,%edi
call   1050 <malloc@plt>
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe8b(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe6f(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xef3(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe83(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x50(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x3,%edx
mov    $0xa,%ecx
call   1060 <minimize@plt>
mov    %rax,%rbx
movsd  (%rax),%xmm0
lea    0xeaa(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rbx),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x10(%rbx),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.x = [10 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00, double 8.000000e+00, double 9.000000e+00, double 1.000000e+01]
@__const.main.y = [10 x double] [double 2.980000e+00, double 6.030000e+00, double 1.105000e+01, double 1.799000e+01, double 2.710000e+01, double 3.905000e+01, double 5.089000e+01, double 6.710000e+01, double 0x4054B147AE147AE1, double 1.032000e+02]
@.str = [6 x i8] c"%.4f \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca [10 x double]
%11 = alloca [10 x double]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
store i32 10, i32* %7
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to double*
store double* %17, double** %9
%18 = bitcast [10 x double]* %10 to i8*
%19 = bitcast [10 x double]* %11 to i8*
%20 = getelementptr inbounds [10 x double], [10 x double]* %10, i64 0, i64 0
%21 = getelementptr inbounds [10 x double], [10 x double]* %11, i64 0, i64 0
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call double* @minimize(double* %20, double* %21, i32 %22, i32 %23)
store double* %24, double** %9
store i32 0, i32* %8
br label %25
25: ; preds = %36, %2
%26 = load i32, i32* %8
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %39
29: ; preds = %25
%30 = load double*, double** %9
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %34)
br label %36
36: ; preds = %29
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %25
39: ; preds = %25
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.x = [10 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00, double 8.000000e+00, double 9.000000e+00, double 1.000000e+01]
@__const.main.y = [10 x double] [double 2.980000e+00, double 6.030000e+00, double 1.105000e+01, double 1.799000e+01, double 2.710000e+01, double 3.905000e+01, double 5.089000e+01, double 6.710000e+01, double 0x4054B147AE147AE1, double 1.032000e+02]
@.str = [6 x i8] c"%.4f \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x double]
%4 = alloca [10 x double]
%5 = tail call i64 @malloc(i32 24)
%6 = bitcast [10 x double]* %3 to i8*
%7 = bitcast [10 x double]* %4 to i8*
%8 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%9 = getelementptr inbounds [10 x double], [10 x double]* %4, i64 0, i64 0
%10 = call double* @minimize(double* %8, double* %9, i32 3, i32 10)
%11 = load double, double* %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %11)
%13 = getelementptr inbounds double, double* %10, i64 1
%14 = load double, double* %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %14)
%16 = getelementptr inbounds double, double* %10, i64 2
%17 = load double, double* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %17)
%19 = call i32 @putchar(i32 10)
ret i32 0
}