#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 */
int pow(double, double);
int /*<<< orphan*/ usleep(int);
void fitfun(double *x, int nx, void *output, int *winfo, double *result,
            int ncon, double *constraints) {
  usleep(10 * 1000);
  double y = 0;
  int i;
  for (i = 0; i < nx; i++)
    y += x[i];
  result[0] = pow((y + 2.0), 2.0) - 10;
  result[1] = pow((y - 2.0), 2.0) + 20;
}


x86 assembly (clang, -O0):
<fitfun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    $0x2710,%edi
call   1040 <usleep@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118d <fitfun+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    115c <fitfun+0x3c>
movsd  0xe6b(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm1
call   1030 <pow@plt>
sub    $0xa,%eax
cvtsi2sd %eax,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
movsd  0xe3d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe31(%rip),%xmm1
call   1030 <pow@plt>
add    $0x14,%eax
cvtsi2sd %eax,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fitfun>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x2710,%edi
call   1040 <usleep@plt>
test   %ebp,%ebp
jle    1157 <fitfun+0x37>
mov    %ebp,%ecx
lea    -0x1(%rcx),%rdx
mov    %ecx,%eax
and    $0x7,%eax
cmp    $0x7,%rdx
jae    115d <fitfun+0x3d>
xorpd  %xmm0,%xmm0
xor    %edx,%edx
jmp    11a8 <fitfun+0x88>
xorpd  %xmm0,%xmm0
jmp    11ce <fitfun+0xae>
and    $0xfffffff8,%ecx
xorpd  %xmm0,%xmm0
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
addsd  (%rbx,%rdx,8),%xmm0
addsd  0x8(%rbx,%rdx,8),%xmm0
addsd  0x10(%rbx,%rdx,8),%xmm0
addsd  0x18(%rbx,%rdx,8),%xmm0
addsd  0x20(%rbx,%rdx,8),%xmm0
addsd  0x28(%rbx,%rdx,8),%xmm0
addsd  0x30(%rbx,%rdx,8),%xmm0
addsd  0x38(%rbx,%rdx,8),%xmm0
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    1170 <fitfun+0x50>
test   %rax,%rax
je     11ce <fitfun+0xae>
lea    (%rbx,%rdx,8),%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  (%rcx,%rdx,8),%xmm0
add    $0x1,%rdx
cmp    %rdx,%rax
jne    11c0 <fitfun+0xa0>
movsd  0xe2a(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
addsd  %xmm1,%xmm0
call   1030 <pow@plt>
add    $0xfffffff6,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rsp),%xmm0
addsd  0xe06(%rip),%xmm0
movsd  0xdf6(%rip),%xmm1
call   1030 <pow@plt>
add    $0x14,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @fitfun(double* %0, i32 %1, i8* %2, i32* %3, double* %4, i32 %5, double* %6) {
%8 = alloca double*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double*
%15 = alloca double
%16 = alloca i32
store double* %0, double** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32* %3, i32** %11
store double* %4, double** %12
store i32 %5, i32* %13
store double* %6, double** %14
%17 = call i32 @usleep(i32 10000)
store double 0.000000e+00, double* %15
store i32 0, i32* %16
br label %18
18: ; preds = %30, %7
%19 = load i32, i32* %16
%20 = load i32, i32* %9
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load double*, double** %8
%24 = load i32, i32* %16
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double, double* %15
%29 = fadd double %28, %27
store double %29, double* %15
br label %30
30: ; preds = %22
%31 = load i32, i32* %16
%32 = add nsw i32 %31, 1
store i32 %32, i32* %16
br label %18
33: ; preds = %18
%34 = load double, double* %15
%35 = fadd double %34, 2.000000e+00
%36 = call i32 @pow(double %35, double 2.000000e+00)
%37 = sub nsw i32 %36, 10
%38 = sitofp i32 %37 to double
%39 = load double*, double** %12
%40 = getelementptr inbounds double, double* %39, i64 0
store double %38, double* %40
%41 = load double, double* %15
%42 = fsub double %41, 2.000000e+00
%43 = call i32 @pow(double %42, double 2.000000e+00)
%44 = add nsw i32 %43, 20
%45 = sitofp i32 %44 to double
%46 = load double*, double** %12
%47 = getelementptr inbounds double, double* %46, i64 1
store double %45, double* %47
ret void
}

LLVM IR (-O2):
define void @fitfun(double* nocapture %0, i32 %1, i8* nocapture readnone %2, i32* nocapture readnone %3, double* nocapture writeonly %4, i32 %5, double* nocapture readnone %6) {
%8 = tail call i32 @usleep(i32 10000)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %70
10: ; preds = %7
%11 = zext i32 %1 to i64
%12 = add nsw i64 %11, -1
%13 = and i64 %11, 7
%14 = icmp ult i64 %12, 7
br i1 %14, label %55, label %15
15: ; preds = %10
%16 = and i64 %11, 4294967288
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 0, %15 ], [ %52, %17 ]
%19 = phi double [ 0.000000e+00, %15 ], [ %51, %17 ]
%20 = phi i64 [ 0, %15 ], [ %53, %17 ]
%21 = getelementptr inbounds double, double* %0, i64 %18
%22 = load double, double* %21
%23 = fadd double %19, %22
%24 = or i64 %18, 1
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = load double, double* %25
%27 = fadd double %23, %26
%28 = or i64 %18, 2
%29 = getelementptr inbounds double, double* %0, i64 %28
%30 = load double, double* %29
%31 = fadd double %27, %30
%32 = or i64 %18, 3
%33 = getelementptr inbounds double, double* %0, i64 %32
%34 = load double, double* %33
%35 = fadd double %31, %34
%36 = or i64 %18, 4
%37 = getelementptr inbounds double, double* %0, i64 %36
%38 = load double, double* %37
%39 = fadd double %35, %38
%40 = or i64 %18, 5
%41 = getelementptr inbounds double, double* %0, i64 %40
%42 = load double, double* %41
%43 = fadd double %39, %42
%44 = or i64 %18, 6
%45 = getelementptr inbounds double, double* %0, i64 %44
%46 = load double, double* %45
%47 = fadd double %43, %46
%48 = or i64 %18, 7
%49 = getelementptr inbounds double, double* %0, i64 %48
%50 = load double, double* %49
%51 = fadd double %47, %50
%52 = add nuw nsw i64 %18, 8
%53 = add i64 %20, 8
%54 = icmp eq i64 %53, %16
br i1 %54, label %55, label %17
55: ; preds = %17, %10
%56 = phi double [ undef, %10 ], [ %51, %17 ]
%57 = phi i64 [ 0, %10 ], [ %52, %17 ]
%58 = phi double [ 0.000000e+00, %10 ], [ %51, %17 ]
%59 = icmp eq i64 %13, 0
br i1 %59, label %70, label %60
60: ; preds = %55, %60
%61 = phi i64 [ %67, %60 ], [ %57, %55 ]
%62 = phi double [ %66, %60 ], [ %58, %55 ]
%63 = phi i64 [ %68, %60 ], [ 0, %55 ]
%64 = getelementptr inbounds double, double* %0, i64 %61
%65 = load double, double* %64
%66 = fadd double %62, %65
%67 = add nuw nsw i64 %61, 1
%68 = add i64 %63, 1
%69 = icmp eq i64 %68, %13
br i1 %69, label %70, label %60
70: ; preds = %55, %60, %7
%71 = phi double [ 0.000000e+00, %7 ], [ %56, %55 ], [ %66, %60 ]
%72 = fadd double %71, 2.000000e+00
%73 = tail call i32 @pow(double %72, double 2.000000e+00)
%74 = add nsw i32 %73, -10
%75 = sitofp i32 %74 to double
store double %75, double* %4
%76 = fadd double %71, -2.000000e+00
%77 = tail call i32 @pow(double %76, double 2.000000e+00)
%78 = add nsw i32 %77, 20
%79 = sitofp i32 %78 to double
%80 = getelementptr inbounds double, double* %4, i64 1
store double %79, double* %80
ret void
}