#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 lmdif(int (*)(void *, int, int, double *, double *, int), void *, int, int,
          double *, double *, double, double, double, int, double, double *,
          int, double const, int, int *, double *, int, int *, double *,
          double *, double *, double *, double *);
int cminpack_lmdif(int (*func)(void *d, int n, int m, double *p, double *hx,
                               int iflag),
                   void *d, int m, int n, double *x, double *fvec, double tol,
                   int *iwa, double *wa, int lwa) {
  const double factor = 100.;
  int mp5n, mode, nfev;
  double ftol, gtol, xtol;
  double epsfcn;
  int maxfev, nprint;
  int info;
  if (n <= 0 || m < n || tol < 0. || lwa < m * n + n * 5 + m) {
    return 0;
  }
  maxfev = (n + 1) * 200;
  ftol = tol;
  xtol = tol;
  gtol = 0.;
  epsfcn = 0.;
  mode = 1;
  nprint = 0;
  mp5n = m + n * 5;
  info = lmdif(func, d, m, n, x, fvec, ftol, xtol, gtol, maxfev, epsfcn, wa,
               mode, factor, nprint, &nfev, &wa[mp5n], m, iwa, &wa[n],
               &wa[(n << 1)], &wa[n * 3], &wa[(n << 2)], &wa[n * 5]);
  if (info == 8) {
    info = 4;
  }
  return info;
}


x86 assembly (clang, -O0):
<cminpack_lmdif>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %edx,-0x44(%rbp)
mov    %ecx,-0x48(%rbp)
mov    %r8,-0x50(%rbp)
mov    %r9,-0x58(%rbp)
movsd  %xmm0,-0x60(%rbp)
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x0,-0x48(%rbp)
jle    1196 <cminpack_lmdif+0x86>
mov    -0x44(%rbp),%eax
cmp    -0x48(%rbp),%eax
jl     1196 <cminpack_lmdif+0x86>
xorps  %xmm0,%xmm0
ucomisd -0x60(%rbp),%xmm0
ja     1196 <cminpack_lmdif+0x86>
mov    0x20(%rbp),%eax
mov    -0x44(%rbp),%ecx
imul   -0x48(%rbp),%ecx
imul   $0x5,-0x48(%rbp),%edx
add    %edx,%ecx
add    -0x44(%rbp),%ecx
cmp    %ecx,%eax
jge    11a2 <cminpack_lmdif+0x92>
movl   $0x0,-0x2c(%rbp)
jmp    1381 <cminpack_lmdif+0x271>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
imul   $0xc8,%eax,%eax
mov    %eax,-0x9c(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movl   $0x1,-0x70(%rbp)
movl   $0x0,-0xa0(%rbp)
mov    -0x44(%rbp),%eax
imul   $0x5,-0x48(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    -0x48(%rbp),%eax
mov    %eax,-0xd0(%rbp)
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
movsd  -0x80(%rbp),%xmm0
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0x88(%rbp),%xmm2
ff
mov    -0x9c(%rbp),%eax
mov    %eax,-0xcc(%rbp)
movsd  -0x98(%rbp),%xmm3
ff
mov    0x18(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0xa0(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    0x18(%rbp),%r13
movslq -0x6c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%r13
mov    -0x44(%rbp),%r12d
mov    0x10(%rbp),%r15
mov    0x18(%rbp),%r14
movslq -0x48(%rbp),%rax
shl    $0x3,%rax
add    %rax,%r14
mov    0x18(%rbp),%rbx
mov    -0x48(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
add    %rax,%rbx
mov    0x18(%rbp),%r11
imul   $0x3,-0x48(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r11
mov    0x18(%rbp),%r10
mov    -0x48(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x3,%rax
add    %rax,%r10
mov    0x18(%rbp),%rax
imul   $0x5,-0x48(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    -0xd0(%rbp),%ecx
mov    %rax,-0xb0(%rbp)
movsd  0xd19(%rip),%xmm4
lea    -0x74(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0xcc(%rbp),%eax
mov    %eax,(%rsp)
mov    -0xc8(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    -0xc0(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    -0xbc(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    -0xb8(%rbp),%rax
mov    %rax,0x20(%rsp)
mov    -0xb0(%rbp),%rax
mov    %r13,0x28(%rsp)
mov    %r12d,0x30(%rsp)
mov    %r15,0x38(%rsp)
mov    %r14,0x40(%rsp)
mov    %rbx,0x48(%rsp)
mov    %r11,0x50(%rsp)
mov    %r10,0x58(%rsp)
mov    %rax,0x60(%rsp)
call   1030 <lmdif@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x8,-0xa4(%rbp)
jne    1378 <cminpack_lmdif+0x268>
movl   $0x4,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<cminpack_lmdif>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
test   %ecx,%ecx
jle    11e7 <cminpack_lmdif+0xd7>
cmp    %ecx,%edx
jl     11e7 <cminpack_lmdif+0xd7>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11e7 <cminpack_lmdif+0xd7>
mov    %ecx,%ebx
imul   %edx,%ebx
lea    (%rcx,%rcx,4),%r12d
lea    (%r12,%rdx,1),%r11d
add    %r11d,%ebx
cmp    0x50(%rsp),%ebx
jg     11e7 <cminpack_lmdif+0xd7>
mov    0x48(%rsp),%rax
imul   $0xc8,%ecx,%r10d
add    $0xc8,%r10d
movslq %r11d,%rbx
lea    (%rax,%rbx,8),%r11
mov    %ecx,%ebx
lea    (%rax,%rbx,8),%r14
lea    (%rcx,%rcx,1),%ebx
movslq %ebx,%rbx
lea    (%rax,%rbx,8),%r15
lea    (%rcx,%rcx,2),%ebx
movslq %ebx,%rbx
lea    (%rax,%rbx,8),%r13
lea    0x0(,%rcx,4),%ebp
movslq %ebp,%rbp
lea    (%rax,%rbp,8),%rbp
movslq %r12d,%rbx
lea    (%rax,%rbx,8),%rbx
sub    $0x8,%rsp
lea    0xc(%rsp),%r12
movsd  0xe51(%rip),%xmm4
xorps  %xmm2,%xmm2
xorps  %xmm3,%xmm3
movapd %xmm0,%xmm1
push   %rbx
push   %rbp
push   %r13
push   %r15
push   %r14
push   0x70(%rsp)
push   %rdx
push   %r11
push   %r12
push   $0x0
push   $0x1
push   %rax
push   %r10
call   1030 <lmdif@plt>
add    $0x70,%rsp
mov    %eax,%ecx
cmp    $0x8,%eax
mov    $0x4,%eax
cmovne %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cminpack_lmdif(i32 (i8*, i32, i32, double*, double*, i32)* %0, i8* %1, i32 %2, i32 %3, double* %4, double* %5, double %6, i32* %7, double* %8, i32 %9) {
%11 = alloca i32
%12 = alloca i32 (i8*, i32, i32, double*, double*, i32)*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca double*
%17 = alloca double*
%18 = alloca double
%19 = alloca i32*
%20 = alloca double*
%21 = alloca i32
%22 = alloca double
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
store i32 (i8*, i32, i32, double*, double*, i32)* %0, i32 (i8*, i32, i32, double*, double*, i32)** %12
store i8* %1, i8** %13
store i32 %2, i32* %14
store i32 %3, i32* %15
store double* %4, double** %16
store double* %5, double** %17
store double %6, double* %18
store i32* %7, i32** %19
store double* %8, double** %20
store i32 %9, i32* %21
store double 1.000000e+02, double* %22
%33 = load i32, i32* %15
%34 = icmp sle i32 %33, 0
br i1 %34, label %53, label %35
35: ; preds = %10
%36 = load i32, i32* %14
%37 = load i32, i32* %15
%38 = icmp slt i32 %36, %37
br i1 %38, label %53, label %39
39: ; preds = %35
%40 = load double, double* %18
%41 = fcmp olt double %40, 0.000000e+00
br i1 %41, label %53, label %42
42: ; preds = %39
%43 = load i32, i32* %21
%44 = load i32, i32* %14
%45 = load i32, i32* %15
%46 = mul nsw i32 %44, %45
%47 = load i32, i32* %15
%48 = mul nsw i32 %47, 5
%49 = add nsw i32 %46, %48
%50 = load i32, i32* %14
%51 = add nsw i32 %49, %50
%52 = icmp slt i32 %43, %51
br i1 %52, label %53, label %54
53: ; preds = %42, %39, %35, %10
store i32 0, i32* %11
br label %114
54: ; preds = %42
%55 = load i32, i32* %15
%56 = add nsw i32 %55, 1
%57 = mul nsw i32 %56, 200
store i32 %57, i32* %30
%58 = load double, double* %18
store double %58, double* %26
%59 = load double, double* %18
store double %59, double* %28
store double 0.000000e+00, double* %27
store double 0.000000e+00, double* %29
store i32 1, i32* %24
store i32 0, i32* %31
%60 = load i32, i32* %14
%61 = load i32, i32* %15
%62 = mul nsw i32 %61, 5
%63 = add nsw i32 %60, %62
store i32 %63, i32* %23
%64 = load i32 (i8*, i32, i32, double*, double*, i32)*, i32 (i8*, i32, i32, double*, double*, i32)** %12
%65 = load i8*, i8** %13
%66 = load i32, i32* %14
%67 = load i32, i32* %15
%68 = load double*, double** %16
%69 = load double*, double** %17
%70 = load double, double* %26
%71 = load double, double* %28
%72 = load double, double* %27
%73 = load i32, i32* %30
%74 = load double, double* %29
%75 = load double*, double** %20
%76 = load i32, i32* %24
%77 = load i32, i32* %31
%78 = load double*, double** %20
%79 = load i32, i32* %23
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
%82 = load i32, i32* %14
%83 = load i32*, i32** %19
%84 = load double*, double** %20
%85 = load i32, i32* %15
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double*, double** %20
%89 = load i32, i32* %15
%90 = shl i32 %89, 1
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %88, i64 %91
%93 = load double*, double** %20
%94 = load i32, i32* %15
%95 = mul nsw i32 %94, 3
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %93, i64 %96
%98 = load double*, double** %20
%99 = load i32, i32* %15
%100 = shl i32 %99, 2
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %98, i64 %101
%103 = load double*, double** %20
%104 = load i32, i32* %15
%105 = mul nsw i32 %104, 5
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %103, i64 %106
%108 = call i32 @lmdif(i32 (i8*, i32, i32, double*, double*, i32)* %64, i8* %65, i32 %66, i32 %67, double* %68, double* %69, double %70, double %71, double %72, i32 %73, double %74, double* %75, i32 %76, double 1.000000e+02, i32 %77, i32* %25, double* %81, i32 %82, i32* %83, double* %87, double* %92, double* %97, double* %102, double* %107)
store i32 %108, i32* %32
%109 = load i32, i32* %32
%110 = icmp eq i32 %109, 8
br i1 %110, label %111, label %112
111: ; preds = %54
store i32 4, i32* %32
br label %112
112: ; preds = %111, %54
%113 = load i32, i32* %32
store i32 %113, i32* %11
br label %114
114: ; preds = %112, %53
%115 = load i32, i32* %11
ret i32 %115
}

LLVM IR (-O2):
define i32 @cminpack_lmdif(i32 (i8*, i32, i32, double*, double*, i32)* %0, i8* %1, i32 %2, i32 %3, double* %4, double* %5, double %6, i32* %7, double* %8, i32 %9) {
%11 = alloca i32
%12 = bitcast i32* %11 to i8*
%13 = icmp slt i32 %3, 1
br i1 %13, label %45, label %14
14: ; preds = %10
%15 = icmp slt i32 %2, %3
%16 = fcmp olt double %6, 0.000000e+00
%17 = or i1 %15, %16
br i1 %17, label %45, label %18
18: ; preds = %14
%19 = mul nsw i32 %3, %2
%20 = mul nsw i32 %3, 5
%21 = add i32 %20, %2
%22 = add i32 %21, %19
%23 = icmp sgt i32 %22, %9
br i1 %23, label %45, label %24
24: ; preds = %18
%25 = mul i32 %3, 200
%26 = add i32 %25, 200
%27 = sext i32 %21 to i64
%28 = getelementptr inbounds double, double* %8, i64 %27
%29 = zext i32 %3 to i64
%30 = getelementptr inbounds double, double* %8, i64 %29
%31 = shl nuw i32 %3, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %8, i64 %32
%34 = mul nsw i32 %3, 3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %8, i64 %35
%37 = shl i32 %3, 2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %8, i64 %38
%40 = sext i32 %20 to i64
%41 = getelementptr inbounds double, double* %8, i64 %40
%42 = call i32 @lmdif(i32 (i8*, i32, i32, double*, double*, i32)* %0, i8* %1, i32 %2, i32 %3, double* %4, double* %5, double %6, double %6, double 0.000000e+00, i32 %26, double 0.000000e+00, double* %8, i32 1, double 1.000000e+02, i32 0, i32* %11, double* %28, i32 %2, i32* %7, double* %30, double* %33, double* %36, double* %39, double* %41)
%43 = icmp eq i32 %42, 8
%44 = select i1 %43, i32 4, i32 %42
br label %45
45: ; preds = %10, %14, %18, %24
%46 = phi i32 [ %44, %24 ], [ 0, %18 ], [ 0, %14 ], [ 0, %10 ]
ret i32 %46
}