#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, int);
double fitfun(double *x, int N, void *output, int *info) {
  double f;
  int i;
  f = 0.0;
  for (i = 0; i < N - 1; i++) {
    f = f + pow((x[i] * x[i] + x[i + 1] - 11.0), 2) +
        pow((x[i] + x[i + 1] * x[i + 1] - 7.0), 2);
  }
  f = (-0.1) * f;
  return f;
}


x86 assembly (clang, -O0):
<fitfun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    121a <fitfun+0x10a>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe83(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe1b(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1136 <fitfun+0x26>
movsd  0xdde(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fitfun>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     11b0 <fitfun+0xa0>
mov    %esi,%r14d
mov    %rdi,%r15
add    $0xffffffff,%r14d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  (%r15,%rbx,8),%xmm0
lea    0x1(%rbx),%r12
mulsd  %xmm0,%xmm0
addsd  0x8(%r15,%rbx,8),%xmm0
addsd  0xea6(%rip),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r15,%rbx,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%r15,%rbx,8),%xmm0
addsd  0xe81(%rip),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  (%rsp),%xmm0
mov    %r12,%rbx
cmp    %r12,%r14
jne    1140 <fitfun+0x30>
mulsd  0xe6a(%rip),%xmm0
jmp    11b8 <fitfun+0xa8>
movsd  0xe48(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @fitfun(double* %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca double
%10 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32* %3, i32** %8
store double 0.000000e+00, double* %9
store i32 0, i32* %10
br label %11
11: ; preds = %59, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 1
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %62
16: ; preds = %11
%17 = load double, double* %9
%18 = load double*, double** %5
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %5
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double*, double** %5
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %28, i64 %31
%33 = load double, double* %32
%34 = call double @llvm.fmuladd.f64(double %22, double %27, double %33)
%35 = fsub double %34, 1.100000e+01
%36 = call double @pow(double %35, i32 2)
%37 = fadd double %17, %36
%38 = load double*, double** %5
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %5
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %43, i64 %46
%48 = load double, double* %47
%49 = load double*, double** %5
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %49, i64 %52
%54 = load double, double* %53
%55 = call double @llvm.fmuladd.f64(double %48, double %54, double %42)
%56 = fsub double %55, 7.000000e+00
%57 = call double @pow(double %56, i32 2)
%58 = fadd double %37, %57
store double %58, double* %9
br label %59
59: ; preds = %16
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
br label %11
62: ; preds = %11
%63 = load double, double* %9
%64 = fmul double -1.000000e-01, %63
store double %64, double* %9
%65 = load double, double* %9
ret double %65
}

LLVM IR (-O2):
define double @fitfun(double* nocapture %0, i32 %1, i8* nocapture readnone %2, i32* nocapture readnone %3) {
%5 = icmp sgt i32 %1, 1
br i1 %5, label %6, label %30
6: ; preds = %4
%7 = add nsw i32 %1, -1
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %14, %9 ]
%11 = phi double [ 0.000000e+00, %6 ], [ %26, %9 ]
%12 = getelementptr inbounds double, double* %0, i64 %10
%13 = load double, double* %12
%14 = add nuw nsw i64 %10, 1
%15 = getelementptr inbounds double, double* %0, i64 %14
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %16)
%18 = fadd double %17, -1.100000e+01
%19 = tail call double @pow(double %18, i32 2)
%20 = fadd double %11, %19
%21 = load double, double* %12
%22 = load double, double* %15
%23 = tail call double @llvm.fmuladd.f64(double %22, double %22, double %21)
%24 = fadd double %23, -7.000000e+00
%25 = tail call double @pow(double %24, i32 2)
%26 = fadd double %20, %25
%27 = icmp eq i64 %14, %8
br i1 %27, label %28, label %9
28: ; preds = %9
%29 = fmul double %26, -1.000000e-01
br label %30
30: ; preds = %28, %4
%31 = phi double [ -0.000000e+00, %4 ], [ %29, %28 ]
ret double %31
}