#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 cvsrch(double (*)(double *, int), void (*)(double *, int, double *),
           double *, double *, double *, double *, double *, int, double *,
           double, int, double, double, double, double);
int lnsrchmt(double (*funcpt)(double *, int),
             void (*funcgrad)(double *, int, double *), double *xi, double *f,
             double *jac, double *alpha, double *p, int N, double *dx,
             double maxstep, int MAXITER, double eps2, double ftol, double gtol,
             double xtol, double *x) {
  int i, retval, info;
  for (i = 0; i < N; ++i) {
    x[i] = xi[i];
  }
  info = cvsrch(funcpt, funcgrad, x, f, jac, alpha, p, N, dx, maxstep, MAXITER,
                eps2, ftol, gtol, xtol);
  retval = info;
  return retval;
}


x86 assembly (clang, -O0):
<lnsrchmt>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x88,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movsd  %xmm0,-0x40(%rbp)
movsd  %xmm1,-0x48(%rbp)
movsd  %xmm2,-0x50(%rbp)
movsd  %xmm3,-0x58(%rbp)
movsd  %xmm4,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    119a <lnsrchmt+0x8a>
mov    -0x20(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x30(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1166 <lnsrchmt+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%rbx
mov    0x18(%rbp),%r11d
mov    0x20(%rbp),%r10
movsd  -0x40(%rbp),%xmm0
mov    0x28(%rbp),%eax
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm4
mov    %rbx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <cvsrch@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<lnsrchmt>:
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r11
mov    0x48(%rsp),%rdx
mov    0x30(%rsp),%eax
test   %eax,%eax
jle    1298 <lnsrchmt+0x188>
mov    %eax,%r10d
cmp    $0x4,%eax
jb     1149 <lnsrchmt+0x39>
lea    (%r11,%r10,8),%rax
cmp    %rdx,%rax
jbe    11c0 <lnsrchmt+0xb0>
lea    (%rdx,%r10,8),%rax
cmp    %r11,%rax
jbe    11c0 <lnsrchmt+0xb0>
xor    %eax,%eax
mov    %rax,%r14
not    %r14
add    %r10,%r14
mov    %r10,%rbx
and    $0x3,%rbx
je     1175 <lnsrchmt+0x65>
nopl   (%rax)
movsd  (%r11,%rax,8),%xmm5
movsd  %xmm5,(%rdx,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rbx
jne    1160 <lnsrchmt+0x50>
cmp    $0x3,%r14
jb     1298 <lnsrchmt+0x188>
nop
movsd  (%r11,%rax,8),%xmm5
movsd  %xmm5,(%rdx,%rax,8)
movsd  0x8(%r11,%rax,8),%xmm5
movsd  %xmm5,0x8(%rdx,%rax,8)
movsd  0x10(%r11,%rax,8),%xmm5
movsd  %xmm5,0x10(%rdx,%rax,8)
movsd  0x18(%r11,%rax,8),%xmm5
movsd  %xmm5,0x18(%rdx,%rax,8)
add    $0x4,%rax
cmp    %rax,%r10
jne    1180 <lnsrchmt+0x70>
jmp    1298 <lnsrchmt+0x188>
mov    %r10d,%eax
and    $0xfffffffc,%eax
lea    -0x4(%rax),%rbx
mov    %rbx,%r15
shr    $0x2,%r15
add    $0x1,%r15
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0xc,%rbx
jae    11e6 <lnsrchmt+0xd6>
xor    %ebx,%ebx
jmp    1250 <lnsrchmt+0x140>
and    $0xfffffffffffffffc,%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movups (%r11,%rbx,8),%xmm5
movups 0x10(%r11,%rbx,8),%xmm6
movups %xmm5,(%rdx,%rbx,8)
movups %xmm6,0x10(%rdx,%rbx,8)
movups 0x20(%r11,%rbx,8),%xmm5
movups 0x30(%r11,%rbx,8),%xmm6
movups %xmm5,0x20(%rdx,%rbx,8)
movups %xmm6,0x30(%rdx,%rbx,8)
movups 0x40(%r11,%rbx,8),%xmm5
movups 0x50(%r11,%rbx,8),%xmm6
movups %xmm5,0x40(%rdx,%rbx,8)
movups %xmm6,0x50(%rdx,%rbx,8)
movups 0x60(%r11,%rbx,8),%xmm5
movups 0x70(%r11,%rbx,8),%xmm6
movups %xmm5,0x60(%rdx,%rbx,8)
movups %xmm6,0x70(%rdx,%rbx,8)
add    $0x10,%rbx
add    $0xfffffffffffffffc,%r15
jne    11f0 <lnsrchmt+0xe0>
test   %r14,%r14
je     128f <lnsrchmt+0x17f>
lea    (%rdx,%rbx,8),%r15
add    $0x10,%r15
lea    (%r11,%rbx,8),%r12
add    $0x10,%r12
shl    $0x5,%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movups -0x10(%r12,%rbx,1),%xmm5
movups (%r12,%rbx,1),%xmm6
movups %xmm5,-0x10(%r15,%rbx,1)
movups %xmm6,(%r15,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%r14
jne    1270 <lnsrchmt+0x160>
cmp    %r10,%rax
jne    114b <lnsrchmt+0x3b>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <cvsrch@plt>

LLVM IR (-O0):
define i32 @lnsrchmt(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* %2, double* %3, double* %4, double* %5, double* %6, i32 %7, double* %8, double %9, i32 %10, double %11, double %12, double %13, double %14, double* %15) {
%17 = alloca double (double*, i32)*
%18 = alloca void (double*, i32, double*)*
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double*
%23 = alloca double*
%24 = alloca i32
%25 = alloca double*
%26 = alloca double
%27 = alloca i32
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double*
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
store double (double*, i32)* %0, double (double*, i32)** %17
store void (double*, i32, double*)* %1, void (double*, i32, double*)** %18
store double* %2, double** %19
store double* %3, double** %20
store double* %4, double** %21
store double* %5, double** %22
store double* %6, double** %23
store i32 %7, i32* %24
store double* %8, double** %25
store double %9, double* %26
store i32 %10, i32* %27
store double %11, double* %28
store double %12, double* %29
store double %13, double* %30
store double %14, double* %31
store double* %15, double** %32
store i32 0, i32* %33
br label %36
36: ; preds = %50, %16
%37 = load i32, i32* %33
%38 = load i32, i32* %24
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %53
40: ; preds = %36
%41 = load double*, double** %19
%42 = load i32, i32* %33
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = load double*, double** %32
%47 = load i32, i32* %33
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
store double %45, double* %49
br label %50
50: ; preds = %40
%51 = load i32, i32* %33
%52 = add nsw i32 %51, 1
store i32 %52, i32* %33
br label %36
53: ; preds = %36
%54 = load double (double*, i32)*, double (double*, i32)** %17
%55 = load void (double*, i32, double*)*, void (double*, i32, double*)** %18
%56 = load double*, double** %32
%57 = load double*, double** %20
%58 = load double*, double** %21
%59 = load double*, double** %22
%60 = load double*, double** %23
%61 = load i32, i32* %24
%62 = load double*, double** %25
%63 = load double, double* %26
%64 = load i32, i32* %27
%65 = load double, double* %28
%66 = load double, double* %29
%67 = load double, double* %30
%68 = load double, double* %31
%69 = call i32 @cvsrch(double (double*, i32)* %54, void (double*, i32, double*)* %55, double* %56, double* %57, double* %58, double* %59, double* %60, i32 %61, double* %62, double %63, i32 %64, double %65, double %66, double %67, double %68)
store i32 %69, i32* %35
%70 = load i32, i32* %35
store i32 %70, i32* %34
%71 = load i32, i32* %34
ret i32 %71
}

LLVM IR (-O2):
define i32 @lnsrchmt(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* nocapture %2, double* %3, double* %4, double* %5, double* %6, i32 %7, double* %8, double %9, i32 %10, double %11, double %12, double %13, double %14, double* %15) {
%17 = icmp sgt i32 %7, 0
br i1 %17, label %18, label %143
18: ; preds = %16
%19 = zext i32 %7 to i64
%20 = icmp ult i32 %7, 4
br i1 %20, label %106, label %21
21: ; preds = %18
%22 = getelementptr double, double* %15, i64 %19
%23 = getelementptr double, double* %2, i64 %19
%24 = icmp ugt double* %23, %15
%25 = icmp ugt double* %22, %2
%26 = and i1 %24, %25
br i1 %26, label %106, label %27
27: ; preds = %21
%28 = and i64 %19, 4294967292
%29 = add nsw i64 %28, -4
%30 = lshr exact i64 %29, 2
%31 = add nuw nsw i64 %30, 1
%32 = and i64 %31, 3
%33 = icmp ult i64 %29, 12
br i1 %33, label %85, label %34
34: ; preds = %27
%35 = and i64 %31, 9223372036854775804
br label %36
36: ; preds = %36, %34
%37 = phi i64 [ 0, %34 ], [ %82, %36 ]
%38 = phi i64 [ 0, %34 ], [ %83, %36 ]
%39 = getelementptr inbounds double, double* %2, i64 %37
%40 = bitcast double* %39 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = getelementptr inbounds double, double* %39, i64 2
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = getelementptr inbounds double, double* %15, i64 %37
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> %41, <2 x double>* %46
%47 = getelementptr inbounds double, double* %45, i64 2
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> %44, <2 x double>* %48
%49 = or i64 %37, 4
%50 = getelementptr inbounds double, double* %2, i64 %49
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = getelementptr inbounds double, double* %50, i64 2
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %15, i64 %49
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> %52, <2 x double>* %57
%58 = getelementptr inbounds double, double* %56, i64 2
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %55, <2 x double>* %59
%60 = or i64 %37, 8
%61 = getelementptr inbounds double, double* %2, i64 %60
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = getelementptr inbounds double, double* %15, i64 %60
%68 = bitcast double* %67 to <2 x double>*
store <2 x double> %63, <2 x double>* %68
%69 = getelementptr inbounds double, double* %67, i64 2
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %66, <2 x double>* %70
%71 = or i64 %37, 12
%72 = getelementptr inbounds double, double* %2, i64 %71
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = getelementptr inbounds double, double* %72, i64 2
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = getelementptr inbounds double, double* %15, i64 %71
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> %74, <2 x double>* %79
%80 = getelementptr inbounds double, double* %78, i64 2
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> %77, <2 x double>* %81
%82 = add nuw i64 %37, 16
%83 = add nuw i64 %38, 4
%84 = icmp eq i64 %83, %35
br i1 %84, label %85, label %36
85: ; preds = %36, %27
%86 = phi i64 [ 0, %27 ], [ %82, %36 ]
%87 = icmp eq i64 %32, 0
br i1 %87, label %104, label %88
88: ; preds = %85, %88
%89 = phi i64 [ %101, %88 ], [ %86, %85 ]
%90 = phi i64 [ %102, %88 ], [ 0, %85 ]
%91 = getelementptr inbounds double, double* %2, i64 %89
%92 = bitcast double* %91 to <2 x double>*
%93 = load <2 x double>, <2 x double>* %92
%94 = getelementptr inbounds double, double* %91, i64 2
%95 = bitcast double* %94 to <2 x double>*
%96 = load <2 x double>, <2 x double>* %95
%97 = getelementptr inbounds double, double* %15, i64 %89
%98 = bitcast double* %97 to <2 x double>*
store <2 x double> %93, <2 x double>* %98
%99 = getelementptr inbounds double, double* %97, i64 2
%100 = bitcast double* %99 to <2 x double>*
store <2 x double> %96, <2 x double>* %100
%101 = add nuw i64 %89, 4
%102 = add i64 %90, 1
%103 = icmp eq i64 %102, %32
br i1 %103, label %104, label %88
104: ; preds = %88, %85
%105 = icmp eq i64 %28, %19
br i1 %105, label %143, label %106
106: ; preds = %21, %18, %104
%107 = phi i64 [ 0, %21 ], [ 0, %18 ], [ %28, %104 ]
%108 = xor i64 %107, -1
%109 = add nsw i64 %108, %19
%110 = and i64 %19, 3
%111 = icmp eq i64 %110, 0
br i1 %111, label %121, label %112
112: ; preds = %106, %112
%113 = phi i64 [ %118, %112 ], [ %107, %106 ]
%114 = phi i64 [ %119, %112 ], [ 0, %106 ]
%115 = getelementptr inbounds double, double* %2, i64 %113
%116 = load double, double* %115
%117 = getelementptr inbounds double, double* %15, i64 %113
store double %116, double* %117
%118 = add nuw nsw i64 %113, 1
%119 = add i64 %114, 1
%120 = icmp eq i64 %119, %110
br i1 %120, label %121, label %112
121: ; preds = %112, %106
%122 = phi i64 [ %107, %106 ], [ %118, %112 ]
%123 = icmp ult i64 %109, 3
br i1 %123, label %143, label %124
124: ; preds = %121, %124
%125 = phi i64 [ %141, %124 ], [ %122, %121 ]
%126 = getelementptr inbounds double, double* %2, i64 %125
%127 = load double, double* %126
%128 = getelementptr inbounds double, double* %15, i64 %125
store double %127, double* %128
%129 = add nuw nsw i64 %125, 1
%130 = getelementptr inbounds double, double* %2, i64 %129
%131 = load double, double* %130
%132 = getelementptr inbounds double, double* %15, i64 %129
store double %131, double* %132
%133 = add nuw nsw i64 %125, 2
%134 = getelementptr inbounds double, double* %2, i64 %133
%135 = load double, double* %134
%136 = getelementptr inbounds double, double* %15, i64 %133
store double %135, double* %136
%137 = add nuw nsw i64 %125, 3
%138 = getelementptr inbounds double, double* %2, i64 %137
%139 = load double, double* %138
%140 = getelementptr inbounds double, double* %15, i64 %137
store double %139, double* %140
%141 = add nuw nsw i64 %125, 4
%142 = icmp eq i64 %141, %19
br i1 %142, label %143, label %124
143: ; preds = %121, %124, %104, %16
%144 = tail call i32 @cvsrch(double (double*, i32)* %0, void (double*, i32, double*)* %1, double* %15, double* %3, double* %4, double* %5, double* %6, i32 %7, double* %8, double %9, i32 %10, double %11, double %12, double %13, double %14)
ret i32 %144
}