#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 + 100.0 * pow((x[i + 1] - x[i] * x[i]), 2) + pow((x[i] - 1.0), 2);
  f = -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    1202 <fitfun+0xf2>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
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
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  -0x40(%rbp),%xmm1
movsd  0xe55(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe2b(%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  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%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   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm0,%xmm0
cmp    $0x2,%esi
jl     127d <fitfun+0x16d>
mov    %esi,%r14d
mov    %rdi,%r12
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
jne    1146 <fitfun+0x36>
xorpd  %xmm0,%xmm0
xor    %r13d,%r13d
jmp    1224 <fitfun+0x114>
mov    %r14d,%r15d
and    $0xfffffffe,%r15d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm0,(%rsp)
movsd  (%r12,%rbx,8),%xmm1
movsd  0x8(%r12,%rbx,8),%xmm0
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movapd %xmm0,%xmm1
movsd  0xe70(%rip),%xmm0
mulsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,(%rsp)
movsd  (%r12,%rbx,8),%xmm0
movsd  0xe5c(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0x2(%rbx),%r13
movsd  0x8(%r12,%rbx,8),%xmm1
movsd  0x10(%r12,%rbx,8),%xmm0
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mulsd  0xe10(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r12,%rbx,8),%xmm0
addsd  0xdff(%rip),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  (%rsp),%xmm0
mov    %r13,%rbx
cmp    %r13,%r15
jne    1160 <fitfun+0x50>
test   $0x1,%r14b
je     127d <fitfun+0x16d>
movsd  (%r12,%r13,8),%xmm1
movapd %xmm0,(%rsp)
movsd  0x8(%r12,%r13,8),%xmm0
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mulsd  0xdaa(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r12,%r13,8),%xmm0
addsd  0xd9a(%rip),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  (%rsp),%xmm0
xorpd  0xd8b(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = %46, %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 %49
16: ; preds = %11
%17 = load double, double* %9
%18 = load double*, double** %5
%19 = load i32, i32* %10
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %18, i64 %21
%23 = load double, double* %22
%24 = load double*, double** %5
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double*, double** %5
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = fneg double %28
%35 = call double @llvm.fmuladd.f64(double %34, double %33, double %23)
%36 = call double @pow(double %35, i32 2)
%37 = call double @llvm.fmuladd.f64(double 1.000000e+02, double %36, double %17)
%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 = fsub double %42, 1.000000e+00
%44 = call double @pow(double %43, i32 2)
%45 = fadd double %37, %44
store double %45, double* %9
br label %46
46: ; preds = %16
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %11
49: ; preds = %11
%50 = load double, double* %9
%51 = fneg double %50
store double %51, double* %9
%52 = load double, double* %9
ret double %52
}

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 %64
6: ; preds = %4
%7 = add nsw i32 %1, -1
%8 = zext i32 %7 to i64
%9 = and i64 %8, 1
%10 = icmp eq i32 %7, 1
br i1 %10, label %45, label %11
11: ; preds = %6
%12 = and i64 %8, 4294967294
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %30, %13 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %42, %13 ]
%16 = phi i64 [ 0, %11 ], [ %43, %13 ]
%17 = or i64 %14, 1
%18 = getelementptr inbounds double, double* %0, i64 %17
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %0, i64 %14
%21 = load double, double* %20
%22 = fneg double %21
%23 = tail call double @llvm.fmuladd.f64(double %22, double %21, double %19)
%24 = tail call double @pow(double %23, i32 2)
%25 = tail call double @llvm.fmuladd.f64(double %24, double 1.000000e+02, double %15)
%26 = load double, double* %20
%27 = fadd double %26, -1.000000e+00
%28 = tail call double @pow(double %27, i32 2)
%29 = fadd double %25, %28
%30 = add nuw nsw i64 %14, 2
%31 = getelementptr inbounds double, double* %0, i64 %30
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %0, i64 %17
%34 = load double, double* %33
%35 = fneg double %34
%36 = tail call double @llvm.fmuladd.f64(double %35, double %34, double %32)
%37 = tail call double @pow(double %36, i32 2)
%38 = tail call double @llvm.fmuladd.f64(double %37, double 1.000000e+02, double %29)
%39 = load double, double* %33
%40 = fadd double %39, -1.000000e+00
%41 = tail call double @pow(double %40, i32 2)
%42 = fadd double %38, %41
%43 = add i64 %16, 2
%44 = icmp eq i64 %43, %12
br i1 %44, label %45, label %13
45: ; preds = %13, %6
%46 = phi double [ undef, %6 ], [ %42, %13 ]
%47 = phi i64 [ 0, %6 ], [ %30, %13 ]
%48 = phi double [ 0.000000e+00, %6 ], [ %42, %13 ]
%49 = icmp eq i64 %9, 0
br i1 %49, label %64, label %50
50: ; preds = %45
%51 = add nuw nsw i64 %47, 1
%52 = getelementptr inbounds double, double* %0, i64 %51
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %0, i64 %47
%55 = load double, double* %54
%56 = fneg double %55
%57 = tail call double @llvm.fmuladd.f64(double %56, double %55, double %53)
%58 = tail call double @pow(double %57, i32 2)
%59 = tail call double @llvm.fmuladd.f64(double %58, double 1.000000e+02, double %48)
%60 = load double, double* %54
%61 = fadd double %60, -1.000000e+00
%62 = tail call double @pow(double %61, i32 2)
%63 = fadd double %59, %62
br label %64
64: ; preds = %50, %45, %4
%65 = phi double [ 0.000000e+00, %4 ], [ %46, %45 ], [ %63, %50 ]
%66 = fneg double %65
ret double %66
}