#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 fabs(double);
double l2norm(double *, int);
int stopcheck2_mt(double fx, int N, double fo, double *jac, double *dx,
                  double eps, double stoptol, double functol, int retval) {
  int rcode;
  double nrm, nrmnx, relfit;
  rcode = 0;
  if (retval == 3) {
    rcode = 4;
    return rcode;
  }
  if (retval == 15) {
    rcode = 15;
    return rcode;
  }
  nrm = l2norm(jac, N);
  nrmnx = nrm / (double)N;
  if (fabs(fo) < eps) {
    relfit = fabs(fx - fo);
  } else {
    relfit = fabs((fx - fo) / fo);
  }
  if (nrmnx < stoptol) {
    return 1;
  } else if (relfit < functol) {
    return 6;
  }
  return rcode;
}


x86 assembly (clang, -O0):
<stopcheck2_mt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  %xmm2,-0x38(%rbp)
movsd  %xmm3,-0x40(%rbp)
movsd  %xmm4,-0x48(%rbp)
mov    %ecx,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
cmpl   $0x3,-0x4c(%rbp)
jne    1162 <stopcheck2_mt+0x52>
movl   $0x4,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    124a <stopcheck2_mt+0x13a>
cmpl   $0xf,-0x4c(%rbp)
jne    117e <stopcheck2_mt+0x6e>
movl   $0xf,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    124a <stopcheck2_mt+0x13a>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <l2norm@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm1
movaps 0xe52(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e0 <stopcheck2_mt+0xd0>
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movaps 0xe2e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    11ff <stopcheck2_mt+0xef>
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movaps 0xe0a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    121f <stopcheck2_mt+0x10f>
movl   $0x1,-0x4(%rbp)
jmp    124a <stopcheck2_mt+0x13a>
movsd  -0x68(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    123f <stopcheck2_mt+0x12f>
movl   $0x6,-0x4(%rbp)
jmp    124a <stopcheck2_mt+0x13a>
jmp    1244 <stopcheck2_mt+0x134>
mov    -0x50(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stopcheck2_mt>:
push   %rbx
sub    $0x40,%rsp
cmp    $0x3,%ecx
je     1129 <stopcheck2_mt+0x19>
cmp    $0xf,%ecx
jne    1133 <stopcheck2_mt+0x23>
mov    $0xf,%eax
jmp    11cf <stopcheck2_mt+0xbf>
mov    $0x4,%eax
jmp    11cf <stopcheck2_mt+0xbf>
mov    %edi,%ebx
movsd  %xmm2,0x8(%rsp)
movaps %xmm1,0x20(%rsp)
movapd %xmm0,0x30(%rsp)
movsd  %xmm4,0x10(%rsp)
mov    %rsi,%rdi
mov    %ebx,%esi
movsd  %xmm3,0x18(%rsp)
call   1030 <l2norm@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
mov    $0x1,%eax
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     11cf <stopcheck2_mt+0xbf>
movapd 0x30(%rsp),%xmm3
movapd 0x20(%rsp),%xmm4
subsd  %xmm4,%xmm3
movapd 0xe70(%rip),%xmm0
movapd %xmm4,%xmm1
andpd  %xmm0,%xmm1
cmpltsd 0x8(%rsp),%xmm1
movsd  0xe69(%rip),%xmm2
andpd  %xmm1,%xmm2
andnpd %xmm4,%xmm1
orpd   %xmm2,%xmm1
divsd  %xmm1,%xmm3
andpd  %xmm0,%xmm3
xor    %ecx,%ecx
movsd  0x10(%rsp),%xmm0
ucomisd %xmm3,%xmm0
mov    $0x6,%eax
cmovbe %ecx,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @stopcheck2_mt(double %0, i32 %1, double %2, double* %3, double* nocapture readnone %4, double %5, double %6, double %7, i32 %8) {
switch i32 %8, label %11 [
i32 3, label %25
i32 15, label %10
]
10: ; preds = %9
br label %25
11: ; preds = %9
%12 = tail call double @l2norm(double* %3, i32 %1)
%13 = sitofp i32 %1 to double
%14 = fdiv double %12, %13
%15 = fcmp olt double %14, %6
br i1 %15, label %25, label %16
16: ; preds = %11
%17 = fsub double %0, %2
%18 = tail call double @llvm.fabs.f64(double %2)
%19 = fcmp olt double %18, %5
%20 = select i1 %19, double 1.000000e+00, double %2
%21 = fdiv double %17, %20
%22 = tail call double @llvm.fabs.f64(double %21)
%23 = fcmp olt double %22, %7
%24 = select i1 %23, i32 6, i32 0
br label %25
25: ; preds = %16, %11, %9, %10
%26 = phi i32 [ 15, %10 ], [ 4, %9 ], [ 1, %11 ], [ %24, %16 ]
ret i32 %26
}