#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 /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
double sqrt(double);
int /*<<< orphan*/ trstep_ddl(double *, double *, int, double *, double,
                              double *, double *, double, double *, double *,
                              double *, double *);
int trupdate(double (*)(double *, int), double *, double *, double *, int,
             double *, double, int, double *, double *, double, int, double *,
             double *, double *, double *);
int trsrch_ddl(double (*funcpt)(double *, int), double *xi, double *jac,
               double *sN, int N, double *dx, double maxstep, int iter,
               double *L, double *hess, double stol, double *ioval, double *x) {
  int retval, i, method;
  double nlen, funcprev;
  double *temp, *step, *xprev, *ssd, *v;
  retval = 4;
  nlen = 0.0;
  ioval[7] = 1.0;
  method = 1;
  temp = (double *)malloc(sizeof(double) * N);
  step = (double *)malloc(sizeof(double) * N);
  xprev = (double *)malloc(sizeof(double) * N);
  ssd = (double *)malloc(sizeof(double) * N);
  v = (double *)malloc(sizeof(double) * N);
  for (i = 0; i < N; ++i) {
    nlen += dx[i] * sN[i] * dx[i] * sN[i];
  }
  nlen = sqrt(nlen);
  funcprev = 0.0;
  while (retval >= 2 && retval != 15) {
    trstep_ddl(jac, sN, N, dx, maxstep, L, hess, nlen, ioval, ssd, v, step);
    retval = trupdate(funcpt, xi, jac, step, N, dx, maxstep, retval, L, hess,
                      stol, method, ioval, xprev, &funcprev, x);
  }
  free(temp);
  free(step);
  free(xprev);
  free(ssd);
  free(v);
  return retval;
}


x86 assembly (clang, -O0):
<trsrch_ddl>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8d,-0x4c(%rbp)
mov    %r9,-0x58(%rbp)
movsd  %xmm0,-0x60(%rbp)
movsd  %xmm1,-0x68(%rbp)
movl   $0x4,-0x6c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    0x28(%rbp),%rax
movsd  0xe4c(%rip),%xmm0
movsd  %xmm0,0x38(%rax)
movl   $0x1,-0x74(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x90(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x98(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0xa0(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0xa8(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0xb0(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1295 <trsrch_ddl+0x145>
mov    -0x58(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x70(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
movslq -0x70(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x80(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1235 <trsrch_ddl+0xe5>
movsd  -0x80(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x80(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
xor    %eax,%eax
cmpl   $0x2,-0x6c(%rbp)
mov    %al,-0xb1(%rbp)
jl     12ce <trsrch_ddl+0x17e>
cmpl   $0xf,-0x6c(%rbp)
setne  %al
mov    %al,-0xb1(%rbp)
mov    -0xb1(%rbp),%al
test   $0x1,%al
jne    12e1 <trsrch_ddl+0x191>
jmp    13b2 <trsrch_ddl+0x262>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x4c(%rbp),%edx
mov    -0x58(%rbp),%rcx
movsd  -0x60(%rbp),%xmm0
mov    0x18(%rbp),%r8
mov    0x20(%rbp),%r9
movsd  -0x80(%rbp),%xmm1
mov    0x28(%rbp),%rbx
mov    -0xa8(%rbp),%r11
mov    -0xb0(%rbp),%r10
mov    -0x98(%rbp),%rax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1040 <trstep_ddl@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    -0x4c(%rbp),%r8d
mov    -0x58(%rbp),%r9
movsd  -0x60(%rbp),%xmm0
mov    -0x6c(%rbp),%r13d
mov    0x18(%rbp),%r12
mov    0x20(%rbp),%r15
movsd  -0x68(%rbp),%xmm1
mov    -0x74(%rbp),%r14d
mov    0x28(%rbp),%rbx
mov    -0xa0(%rbp),%r11
mov    0x30(%rbp),%rax
lea    -0x88(%rbp),%r10
mov    %r13d,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14d,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
call   1070 <trupdate@plt>
mov    %eax,-0x6c(%rbp)
jmp    12af <trsrch_ddl+0x15f>
mov    -0x90(%rbp),%rdi
call   1030 <free@plt>
mov    -0x98(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa0(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0xb0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x6c(%rbp),%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<trsrch_ddl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movsd  %xmm1,0x68(%rsp)
movsd  %xmm0,0x38(%rsp)
mov    %r9,%rbx
mov    %r8d,%r15d
mov    %rcx,%rbp
mov    %rdx,0x60(%rsp)
mov    %rsi,0x50(%rsp)
mov    %rdi,0x48(%rsp)
mov    0xc8(%rsp),%rcx
movabs $0x3ff0000000000000,%rax
mov    %rax,0x38(%rcx)
lea    0x0(,%r15,8),%r14d
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,0x30(%rsp)
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,0x18(%rsp)
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
mov    %r15,0x10(%rsp)
test   %r15d,%r15d
jle    128b <trsrch_ddl+0x13b>
mov    0x10(%rsp),%rcx
mov    %ecx,%eax
cmp    $0x1,%ecx
jne    1209 <trsrch_ddl+0xb9>
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
jmp    1268 <trsrch_ddl+0x118>
mov    %eax,%edx
and    $0xfffffffe,%edx
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%rcx,8),%xmm2
movsd  0x8(%rbx,%rcx,8),%xmm3
movsd  0x0(%rbp,%rcx,8),%xmm4
movsd  0x8(%rbp,%rcx,8),%xmm5
movapd %xmm2,%xmm6
mulsd  %xmm4,%xmm6
mulsd  %xmm2,%xmm6
mulsd  %xmm4,%xmm6
addsd  %xmm0,%xmm6
movapd %xmm3,%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm5,%xmm0
addsd  %xmm6,%xmm0
add    $0x2,%rcx
cmp    %rcx,%rdx
jne    1220 <trsrch_ddl+0xd0>
test   $0x1,%al
je     128b <trsrch_ddl+0x13b>
movsd  (%rbx,%rcx,8),%xmm2
movsd  0x0(%rbp,%rcx,8),%xmm3
movapd %xmm2,%xmm4
mulsd  %xmm3,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm3,%xmm4
addsd  %xmm4,%xmm0
ucomisd %xmm1,%xmm0
mov    %rbp,0x58(%rsp)
mov    %r12,0x40(%rsp)
jb     12a1 <trsrch_ddl+0x151>
sqrtsd %xmm0,%xmm0
jmp    12a6 <trsrch_ddl+0x156>
call   1060 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movq   $0x0,0x70(%rsp)
mov    $0x4,%ebp
mov    0x60(%rsp),%r14
mov    0x10(%rsp),%r13
mov    0x30(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    0x58(%rsp),%rsi
mov    %r13d,%edx
mov    %rbx,%r15
mov    %rbx,%rcx
movsd  0x38(%rsp),%xmm0
mov    0xb8(%rsp),%r8
mov    0xc0(%rsp),%r9
movsd  0x8(%rsp),%xmm1
push   %r12
push   0x20(%rsp)
push   0x30(%rsp)
mov    0xe0(%rsp),%rax
push   %rax
call   1040 <trstep_ddl@plt>
add    $0x20,%rsp
mov    0x48(%rsp),%rdi
mov    0x50(%rsp),%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13d,%r8d
mov    %rbx,%r9
movsd  0x38(%rsp),%xmm0
movsd  0x68(%rsp),%xmm1
push   0xd0(%rsp)
lea    0x78(%rsp),%rax
push   %rax
push   0x38(%rsp)
push   0xe0(%rsp)
push   $0x1
push   0xe8(%rsp)
push   0xe8(%rsp)
push   %rbp
call   1070 <trupdate@plt>
add    $0x40,%rsp
mov    %eax,%ebp
cmp    $0x2,%eax
jl     137d <trsrch_ddl+0x22d>
cmp    $0xf,%ebp
jne    12d0 <trsrch_ddl+0x180>
mov    0x40(%rsp),%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
call   1030 <free@plt>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @trsrch_ddl(double (double*, i32)* %0, double* %1, double* %2, double* %3, i32 %4, double* %5, double %6, i32 %7, double* %8, double* %9, double %10, double* %11, double* %12) {
%14 = alloca double (double*, i32)*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca i32
%19 = alloca double*
%20 = alloca double
%21 = alloca i32
%22 = alloca double*
%23 = alloca double*
%24 = alloca double
%25 = alloca double*
%26 = alloca double*
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca double
%31 = alloca double
%32 = alloca double*
%33 = alloca double*
%34 = alloca double*
%35 = alloca double*
%36 = alloca double*
store double (double*, i32)* %0, double (double*, i32)** %14
store double* %1, double** %15
store double* %2, double** %16
store double* %3, double** %17
store i32 %4, i32* %18
store double* %5, double** %19
store double %6, double* %20
store i32 %7, i32* %21
store double* %8, double** %22
store double* %9, double** %23
store double %10, double* %24
store double* %11, double** %25
store double* %12, double** %26
store i32 4, i32* %27
store double 0.000000e+00, double* %30
%37 = load double*, double** %25
%38 = getelementptr inbounds double, double* %37, i64 7
store double 1.000000e+00, double* %38
store i32 1, i32* %29
%39 = load i32, i32* %18
%40 = sext i32 %39 to i64
%41 = mul i64 8, %40
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to double*
store double* %44, double** %32
%45 = load i32, i32* %18
%46 = sext i32 %45 to i64
%47 = mul i64 8, %46
%48 = trunc i64 %47 to i32
%49 = call i64 @malloc(i32 %48)
%50 = inttoptr i64 %49 to double*
store double* %50, double** %33
%51 = load i32, i32* %18
%52 = sext i32 %51 to i64
%53 = mul i64 8, %52
%54 = trunc i64 %53 to i32
%55 = call i64 @malloc(i32 %54)
%56 = inttoptr i64 %55 to double*
store double* %56, double** %34
%57 = load i32, i32* %18
%58 = sext i32 %57 to i64
%59 = mul i64 8, %58
%60 = trunc i64 %59 to i32
%61 = call i64 @malloc(i32 %60)
%62 = inttoptr i64 %61 to double*
store double* %62, double** %35
%63 = load i32, i32* %18
%64 = sext i32 %63 to i64
%65 = mul i64 8, %64
%66 = trunc i64 %65 to i32
%67 = call i64 @malloc(i32 %66)
%68 = inttoptr i64 %67 to double*
store double* %68, double** %36
store i32 0, i32* %28
br label %69
69: ; preds = %98, %13
%70 = load i32, i32* %28
%71 = load i32, i32* %18
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %101
73: ; preds = %69
%74 = load double*, double** %19
%75 = load i32, i32* %28
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
%78 = load double, double* %77
%79 = load double*, double** %17
%80 = load i32, i32* %28
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
%83 = load double, double* %82
%84 = fmul double %78, %83
%85 = load double*, double** %19
%86 = load i32, i32* %28
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double, double* %85, i64 %87
%89 = load double, double* %88
%90 = fmul double %84, %89
%91 = load double*, double** %17
%92 = load i32, i32* %28
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
%95 = load double, double* %94
%96 = load double, double* %30
%97 = call double @llvm.fmuladd.f64(double %90, double %95, double %96)
store double %97, double* %30
br label %98
98: ; preds = %73
%99 = load i32, i32* %28
%100 = add nsw i32 %99, 1
store i32 %100, i32* %28
br label %69
101: ; preds = %69
%102 = load double, double* %30
%103 = call double @sqrt(double %102)
store double %103, double* %30
store double 0.000000e+00, double* %31
br label %104
104: ; preds = %112, %101
%105 = load i32, i32* %27
%106 = icmp sge i32 %105, 2
br i1 %106, label %107, label %110
107: ; preds = %104
%108 = load i32, i32* %27
%109 = icmp ne i32 %108, 15
br label %110
110: ; preds = %107, %104
%111 = phi i1 [ false, %104 ], [ %109, %107 ]
br i1 %111, label %112, label %142
112: ; preds = %110
%113 = load double*, double** %16
%114 = load double*, double** %17
%115 = load i32, i32* %18
%116 = load double*, double** %19
%117 = load double, double* %20
%118 = load double*, double** %22
%119 = load double*, double** %23
%120 = load double, double* %30
%121 = load double*, double** %25
%122 = load double*, double** %35
%123 = load double*, double** %36
%124 = load double*, double** %33
%125 = call i32 @trstep_ddl(double* %113, double* %114, i32 %115, double* %116, double %117, double* %118, double* %119, double %120, double* %121, double* %122, double* %123, double* %124)
%126 = load double (double*, i32)*, double (double*, i32)** %14
%127 = load double*, double** %15
%128 = load double*, double** %16
%129 = load double*, double** %33
%130 = load i32, i32* %18
%131 = load double*, double** %19
%132 = load double, double* %20
%133 = load i32, i32* %27
%134 = load double*, double** %22
%135 = load double*, double** %23
%136 = load double, double* %24
%137 = load i32, i32* %29
%138 = load double*, double** %25
%139 = load double*, double** %34
%140 = load double*, double** %26
%141 = call i32 @trupdate(double (double*, i32)* %126, double* %127, double* %128, double* %129, i32 %130, double* %131, double %132, i32 %133, double* %134, double* %135, double %136, i32 %137, double* %138, double* %139, double* %31, double* %140)
store i32 %141, i32* %27
br label %104
142: ; preds = %110
%143 = load double*, double** %32
%144 = call i32 @free(double* %143)
%145 = load double*, double** %33
%146 = call i32 @free(double* %145)
%147 = load double*, double** %34
%148 = call i32 @free(double* %147)
%149 = load double*, double** %35
%150 = call i32 @free(double* %149)
%151 = load double*, double** %36
%152 = call i32 @free(double* %151)
%153 = load i32, i32* %27
ret i32 %153
}

LLVM IR (-O2):
define i32 @trsrch_ddl(double (double*, i32)* %0, double* %1, double* %2, double* %3, i32 %4, double* %5, double %6, i32 %7, double* %8, double* %9, double %10, double* %11, double* %12) {
%14 = alloca double
%15 = bitcast double* %14 to i8*
%16 = getelementptr inbounds double, double* %11, i64 7
store double 1.000000e+00, double* %16
%17 = shl i32 %4, 3
%18 = tail call i64 @malloc(i32 %17)
%19 = tail call i64 @malloc(i32 %17)
%20 = inttoptr i64 %19 to double*
%21 = tail call i64 @malloc(i32 %17)
%22 = inttoptr i64 %21 to double*
%23 = tail call i64 @malloc(i32 %17)
%24 = inttoptr i64 %23 to double*
%25 = tail call i64 @malloc(i32 %17)
%26 = inttoptr i64 %25 to double*
%27 = icmp sgt i32 %4, 0
br i1 %27, label %28, label %69
28: ; preds = %13
%29 = zext i32 %4 to i64
%30 = and i64 %29, 1
%31 = icmp eq i32 %4, 1
br i1 %31, label %56, label %32
32: ; preds = %28
%33 = and i64 %29, 4294967294
br label %34
34: ; preds = %34, %32
%35 = phi i64 [ 0, %32 ], [ %53, %34 ]
%36 = phi double [ 0.000000e+00, %32 ], [ %52, %34 ]
%37 = phi i64 [ 0, %32 ], [ %54, %34 ]
%38 = getelementptr inbounds double, double* %5, i64 %35
%39 = load double, double* %38
%40 = getelementptr inbounds double, double* %3, i64 %35
%41 = load double, double* %40
%42 = fmul double %39, %41
%43 = fmul double %39, %42
%44 = tail call double @llvm.fmuladd.f64(double %43, double %41, double %36)
%45 = or i64 %35, 1
%46 = getelementptr inbounds double, double* %5, i64 %45
%47 = load double, double* %46
%48 = getelementptr inbounds double, double* %3, i64 %45
%49 = load double, double* %48
%50 = fmul double %47, %49
%51 = fmul double %47, %50
%52 = tail call double @llvm.fmuladd.f64(double %51, double %49, double %44)
%53 = add nuw nsw i64 %35, 2
%54 = add i64 %37, 2
%55 = icmp eq i64 %54, %33
br i1 %55, label %56, label %34
56: ; preds = %34, %28
%57 = phi double [ undef, %28 ], [ %52, %34 ]
%58 = phi i64 [ 0, %28 ], [ %53, %34 ]
%59 = phi double [ 0.000000e+00, %28 ], [ %52, %34 ]
%60 = icmp eq i64 %30, 0
br i1 %60, label %69, label %61
61: ; preds = %56
%62 = getelementptr inbounds double, double* %5, i64 %58
%63 = load double, double* %62
%64 = getelementptr inbounds double, double* %3, i64 %58
%65 = load double, double* %64
%66 = fmul double %63, %65
%67 = fmul double %63, %66
%68 = tail call double @llvm.fmuladd.f64(double %67, double %65, double %59)
br label %69
69: ; preds = %61, %56, %13
%70 = phi double [ 0.000000e+00, %13 ], [ %57, %56 ], [ %68, %61 ]
%71 = tail call double @sqrt(double %70)
store double 0.000000e+00, double* %14
br label %72
72: ; preds = %69, %72
%73 = phi i32 [ 4, %69 ], [ %75, %72 ]
%74 = call i32 @trstep_ddl(double* %2, double* %3, i32 %4, double* %5, double %6, double* %8, double* %9, double %71, double* %11, double* %24, double* %26, double* %20)
%75 = call i32 @trupdate(double (double*, i32)* %0, double* %1, double* %2, double* %20, i32 %4, double* %5, double %6, i32 %73, double* %8, double* %9, double %10, i32 1, double* %11, double* %22, double* %14, double* %12)
%76 = icmp sgt i32 %75, 1
%77 = icmp ne i32 %75, 15
%78 = and i1 %76, %77
br i1 %78, label %72, label %79
79: ; preds = %72
%80 = inttoptr i64 %18 to double*
%81 = call i32 @free(double* %80)
%82 = call i32 @free(double* %20)
%83 = call i32 @free(double* %22)
%84 = call i32 @free(double* %24)
%85 = call i32 @free(double* %26)
ret i32 %75
}