#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 */
struct vtx_data {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, ...);
int /*<<< orphan*/ printf(char *, double, ...);
double checkeig_ext(double *err, double *work, struct vtx_data **A, double *y,
                    int n, double extval, double *vwsqrt, double *gvec,
                    double eigtol, int warnings) {
  extern FILE *Output_File;
  extern int DEBUG_EVECS;
  extern int WARNING_EVECS;
  double resid;
  double ch_norm();
  void splarax();
  void scadd();
  void scale_diag();
  void cpvec();
  splarax(err, A, n, y, vwsqrt, work);
  scadd(err, 1, n, -extval, y);
  cpvec(work, 1, n, gvec);
  scale_diag(work, 1, n, vwsqrt);
  scadd(err, 1, n, -1.0, work);
  resid = ch_norm(err, 1, n);
  if (DEBUG_EVECS > 0) {
    printf("  extended residual: %g\n", resid);
    if (Output_File != NULL) {
      fprintf(Output_File, "  extended residual: %g\n", resid);
    }
  }
  if (warnings && WARNING_EVECS > 0 && resid > eigtol) {
    printf("WARNING: Extended residual (%g) greater than tolerance (%g).\n",
           resid, eigtol);
    if (Output_File != NULL) {
      fprintf(Output_File,
              "WARNING: Extended residual (%g) greater than tolerance (%g).\n",
              resid, eigtol);
    }
  }
  return (resid);
}


x86 assembly (clang, -O0):
<checkeig_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x10(%rbp),%r9
mov    $0x0,%al
call   1080 <splarax@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1,%al
call   1090 <scadd@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x0,%al
call   1070 <cpvec@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <scale_diag@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
movsd  0xdc8(%rip),%xmm0
mov    $0x1,%al
call   1090 <scadd@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    $0x1,%esi
mov    $0x0,%al
call   1060 <ch_norm@plt>
movsd  %xmm0,-0x48(%rbp)
mov    0x2d82(%rip),%rax
cmpl   $0x0,(%rax)
jle    12ad <checkeig_ext+0x13d>
movsd  -0x48(%rbp),%xmm0
lea    0xd95(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d67(%rip),%rax
cmpq   $0x0,(%rax)
je     12a8 <checkeig_ext+0x138>
mov    0x2d56(%rip),%rax
mov    (%rax),%rdi
movsd  -0x48(%rbp),%xmm0
lea    0xd67(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
jmp    12ad <checkeig_ext+0x13d>
cmpl   $0x0,0x18(%rbp)
je     1327 <checkeig_ext+0x1b7>
mov    0x2d12(%rip),%rax
cmpl   $0x0,(%rax)
jle    1327 <checkeig_ext+0x1b7>
movsd  -0x48(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1327 <checkeig_ext+0x1b7>
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xd39(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0x2cf2(%rip),%rax
cmpq   $0x0,(%rax)
je     1322 <checkeig_ext+0x1b2>
mov    0x2ce1(%rip),%rax
mov    (%rax),%rdi
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xd06(%rip),%rsi
mov    $0x2,%al
call   1050 <fprintf@plt>
jmp    1327 <checkeig_ext+0x1b7>
movsd  -0x48(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkeig_ext>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
mov    %r9,%r12
movaps %xmm0,(%rsp)
mov    %r8d,%ebx
mov    %rcx,%rbp
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x50(%rsp),%r13
mov    %rdx,%rsi
mov    %r8d,%edx
mov    %r9,%r8
mov    %r15,%r9
xor    %eax,%eax
call   1080 <splarax@plt>
movaps (%rsp),%xmm0
xorps  0xe46(%rip),%xmm0
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %rbp,%rcx
mov    $0x1,%al
call   1090 <scadd@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r13,%rcx
xor    %eax,%eax
call   1070 <cpvec@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   1030 <scale_diag@plt>
movsd  0xe12(%rip),%xmm0
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r15,%rcx
mov    $0x1,%al
call   1090 <scadd@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <ch_norm@plt>
mov    0x2db6(%rip),%rax
cmpl   $0x0,(%rax)
movsd  %xmm0,(%rsp)
jle    1273 <checkeig_ext+0x103>
lea    0xddd(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
mov    0x2d95(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1273 <checkeig_ext+0x103>
lea    0xdb6(%rip),%rsi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1050 <fprintf@plt>
movsd  (%rsp),%xmm0
cmpl   $0x0,0x58(%rsp)
je     12d9 <checkeig_ext+0x169>
mov    0x2d4f(%rip),%rax
cmpl   $0x0,(%rax)
jle    12d9 <checkeig_ext+0x169>
ucomisd 0x10(%rsp),%xmm0
jbe    12d9 <checkeig_ext+0x169>
lea    0xd9c(%rip),%rdi
movsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
mov    0x2d35(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     12d9 <checkeig_ext+0x169>
lea    0xd6f(%rip),%rsi
movsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x2,%al
call   1050 <fprintf@plt>
movsd  (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.vtx_data = type { i32 }
@DEBUG_EVECS = external global i32
@.str = [25 x i8] c" extended residual: %g\0A\00"
@Output_File = external global i32*
@WARNING_EVECS = external global i32
@.str.1 = [62 x i8] c"WARNING: Extended residual (%g) greater than tolerance (%g).\0A\00"
define double @checkeig_ext(double* %0, double* %1, %struct.vtx_data** %2, double* %3, i32 %4, double %5, double* %6, double* %7, double %8, i32 %9) {
%11 = alloca double*
%12 = alloca double*
%13 = alloca %struct.vtx_data**
%14 = alloca double*
%15 = alloca i32
%16 = alloca double
%17 = alloca double*
%18 = alloca double*
%19 = alloca double
%20 = alloca i32
%21 = alloca double
store double* %0, double** %11
store double* %1, double** %12
store %struct.vtx_data** %2, %struct.vtx_data*** %13
store double* %3, double** %14
store i32 %4, i32* %15
store double %5, double* %16
store double* %6, double** %17
store double* %7, double** %18
store double %8, double* %19
store i32 %9, i32* %20
%22 = load double*, double** %11
%23 = load %struct.vtx_data**, %struct.vtx_data*** %13
%24 = load i32, i32* %15
%25 = load double*, double** %14
%26 = load double*, double** %17
%27 = load double*, double** %12
%28 = load double*, double** %11
%29 = load i32, i32* %15
%30 = load double, double* %16
%31 = fneg double %30
%32 = load double*, double** %14
%33 = load double*, double** %12
%34 = load i32, i32* %15
%35 = load double*, double** %18
%36 = load double*, double** %12
%37 = load i32, i32* %15
%38 = load double*, double** %17
%39 = load double*, double** %11
%40 = load i32, i32* %15
%41 = load double*, double** %12
%42 = load double*, double** %11
%43 = load i32, i32* %15
%44 = call double (double*, i32, i32, ...) bitcast (double (...)* @ch_norm to double (double*, i32, i32, ...)*)(double* %42, i32 1, i32 %43)
store double %44, double* %21
%45 = load i32, i32* @DEBUG_EVECS
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %57
47: ; preds = %10
%48 = load double, double* %21
%49 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %48)
%50 = load i32*, i32** @Output_File
%51 = icmp ne i32* %50, null
br i1 %51, label %52, label %56
52: ; preds = %47
%53 = load i32*, i32** @Output_File
%54 = load double, double* %21
%55 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %54)
br label %56
56: ; preds = %52, %47
br label %57
57: ; preds = %56, %10
%58 = load i32, i32* %20
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %79
60: ; preds = %57
%61 = load i32, i32* @WARNING_EVECS
%62 = icmp sgt i32 %61, 0
br i1 %62, label %63, label %79
63: ; preds = %60
%64 = load double, double* %21
%65 = load double, double* %19
%66 = fcmp ogt double %64, %65
br i1 %66, label %67, label %79
67: ; preds = %63
%68 = load double, double* %21
%69 = load double, double* %19
%70 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), double %68, double %69)
%71 = load i32*, i32** @Output_File
%72 = icmp ne i32* %71, null
br i1 %72, label %73, label %78
73: ; preds = %67
%74 = load i32*, i32** @Output_File
%75 = load double, double* %21
%76 = load double, double* %19
%77 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), double %75, double %76)
br label %78
78: ; preds = %73, %67
br label %79
79: ; preds = %78, %63, %60, %57
%80 = load double, double* %21
ret double %80
}

LLVM IR (-O2):
%struct.vtx_data = type { i32 }
@DEBUG_EVECS = external global i32
@.str = [25 x i8] c" extended residual: %g\0A\00"
@Output_File = external global i32*
@WARNING_EVECS = external global i32
@.str.1 = [62 x i8] c"WARNING: Extended residual (%g) greater than tolerance (%g).\0A\00"
define double @checkeig_ext(double* %0, double* %1, %struct.vtx_data** %2, double* %3, i32 %4, double %5, double* %6, double* %7, double %8, i32 %9) {
tail call void (double*, %struct.vtx_data**, i32, double*, double*, double*, ...) bitcast (void (...)* @splarax to void (double*, %struct.vtx_data**, i32, double*, double*, double*, ...)*)(double* %0, %struct.vtx_data** %2, i32 %4, double* %3, double* %6, double* %1)
%11 = fneg double %5
tail call void (double*, i32, i32, double, double*, ...) bitcast (void (...)* @scadd to void (double*, i32, i32, double, double*, ...)*)(double* %0, i32 1, i32 %4, double %11, double* %3)
tail call void (double*, i32, i32, double*, ...) bitcast (void (...)* @cpvec to void (double*, i32, i32, double*, ...)*)(double* %1, i32 1, i32 %4, double* %7)
tail call void (double*, i32, i32, double*, ...) bitcast (void (...)* @scale_diag to void (double*, i32, i32, double*, ...)*)(double* %1, i32 1, i32 %4, double* %6)
tail call void (double*, i32, i32, double, double*, ...) bitcast (void (...)* @scadd to void (double*, i32, i32, double, double*, ...)*)(double* %0, i32 1, i32 %4, double -1.000000e+00, double* %1)
%12 = tail call double (double*, i32, i32, ...) bitcast (double (...)* @ch_norm to double (double*, i32, i32, ...)*)(double* %0, i32 1, i32 %4)
%13 = load i32, i32* @DEBUG_EVECS
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %12)
%17 = load i32*, i32** @Output_File
%18 = icmp eq i32* %17, null
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = tail call i32 (i32*, i8*, double, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %12)
br label %21
21: ; preds = %15, %19, %10
%22 = icmp ne i32 %9, 0
%23 = load i32, i32* @WARNING_EVECS
%24 = icmp sgt i32 %23, 0
%25 = select i1 %22, i1 %24, i1 false
%26 = fcmp ogt double %12, %8
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %28, label %34
28: ; preds = %21
%29 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), double %12, double %8)
%30 = load i32*, i32** @Output_File
%31 = icmp eq i32* %30, null
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = tail call i32 (i32*, i8*, double, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), double %12, double %8)
br label %34
34: ; preds = %28, %32, %21
ret double %12
}