#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*/ BackSubstitute_Complex_Vector(double *, double *, double *,
                                                 int, double, int);
int /*<<< orphan*/ BackSubstitute_Real_Vector(double *, double *, double *, int,
                                              double, int);
double DBL_EPSILON;
double fabs(double);
void BackSubstitution(double *H, double eigen_real[], double eigen_imag[],
                      int n) {
  double zero_tolerance;
  double *pH;
  int i, j, row;
  pH = H;
  zero_tolerance = fabs(pH[0]);
  for (pH += n, i = 1; i < n; pH += n, i++)
    for (j = i - 1; j < n; j++)
      zero_tolerance += fabs(pH[j]);
  zero_tolerance *= DBL_EPSILON;
  for (row = n - 1; row >= 0; row--) {
    if (eigen_imag[row] == 0.0)
      BackSubstitute_Real_Vector(H, eigen_real, eigen_imag, row, zero_tolerance,
                                 n);
    else if (eigen_imag[row] < 0.0)
      BackSubstitute_Complex_Vector(H, eigen_real, eigen_imag, row,
                                    zero_tolerance, n);
  }
}


x86 assembly (clang, -O0):
<BackSubstitution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xeb2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ec <BackSubstitution+0xcc>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c4 <BackSubstitution+0xa4>
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe58(%rip),%xmm1
pand   %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1188 <BackSubstitution+0x68>
jmp    11c9 <BackSubstitution+0xa9>
mov    -0x1c(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1173 <BackSubstitution+0x53>
mov    0x2df5(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jl     12a1 <BackSubstitution+0x181>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1256 <BackSubstitution+0x136>
jp     1256 <BackSubstitution+0x136>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%r8d
call   1040 <BackSubstitute_Real_Vector@plt>
jmp    128e <BackSubstitution+0x16e>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    1289 <BackSubstitution+0x169>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%r8d
call   1030 <BackSubstitute_Complex_Vector@plt>
jmp    128e <BackSubstitution+0x16e>
jmp    1293 <BackSubstitution+0x173>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    120a <BackSubstitution+0xea>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BackSubstitution>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r12
movsd  (%rdi),%xmm0
andpd  0xeba(%rip),%xmm0
mov    %ecx,%ebp
cmp    $0x2,%ecx
jl     1226 <BackSubstitution+0x106>
movslq %r14d,%r10
lea    -0x1(%r14),%r8d
cmp    $0x1,%r8d
jne    1168 <BackSubstitution+0x48>
xor    %eax,%eax
mov    %r12,%rdx
jmp    11f9 <BackSubstitution+0xd9>
mov    %r8d,%r9d
and    $0xfffffffe,%r9d
lea    (%r12,%r10,8),%rdi
mov    %r10,%r11
shl    $0x4,%r11
lea    (%r12,%r11,1),%rsi
add    $0x10,%r11
xor    %eax,%eax
movapd 0xe74(%rip),%xmm2
mov    %rbp,%rbx
mov    %r12,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rdx,%r10,8),%rdx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
movsd  (%rdi,%rcx,8),%xmm1
andpd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rcx
cmp    %rcx,%rbx
jne    11b0 <BackSubstitution+0x90>
lea    (%rdx,%r10,8),%rdx
mov    $0x1,%ecx
nop
movsd  (%rsi,%rcx,8),%xmm1
andpd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rcx
cmp    %rcx,%rbx
jne    11d0 <BackSubstitution+0xb0>
add    $0x2,%rax
add    %r11,%rdi
add    $0xfffffffffffffffe,%rbx
add    %r11,%rsi
cmp    %r9,%rax
jne    11a0 <BackSubstitution+0x80>
test   $0x1,%r8b
je     1226 <BackSubstitution+0x106>
lea    (%rdx,%r10,8),%rcx
movapd 0xdf5(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movsd  (%rcx,%rax,8),%xmm1
andpd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rax
cmp    %rax,%rbp
jne    1210 <BackSubstitution+0xf0>
test   %r14d,%r14d
jle    12a9 <BackSubstitution+0x189>
mov    0x2db6(%rip),%rax
mulsd  (%rax),%xmm0
xorpd  %xmm2,%xmm2
movapd %xmm0,(%rsp)
jmp    1279 <BackSubstitution+0x159>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1040 <BackSubstitute_Real_Vector@plt>
xorpd  %xmm2,%xmm2
movapd (%rsp),%xmm0
mov    %rbp,%rax
add    $0x1,%rax
cmp    $0x1,%rax
jbe    12a9 <BackSubstitution+0x189>
add    $0xffffffffffffffff,%rbp
mov    %ebp,%eax
movsd  0x0(%r13,%rax,8),%xmm1
ucomisd %xmm2,%xmm1
jne    128e <BackSubstitution+0x16e>
jnp    1250 <BackSubstitution+0x130>
ucomisd %xmm1,%xmm2
jbe    126c <BackSubstitution+0x14c>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1030 <BackSubstitute_Complex_Vector@plt>
jmp    1263 <BackSubstitution+0x143>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DBL_EPSILON = global double 0.000000e+00
define void @BackSubstitution(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
%14 = load double*, double** %5
store double* %14, double** %10
%15 = load double*, double** %10
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = call double @llvm.fabs.f64(double %17)
store double %18, double* %9
%19 = load i32, i32* %8
%20 = load double*, double** %10
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds double, double* %20, i64 %21
store double* %22, double** %10
store i32 1, i32* %11
br label %23
23: ; preds = %47, %4
%24 = load i32, i32* %11
%25 = load i32, i32* %8
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %54
27: ; preds = %23
%28 = load i32, i32* %11
%29 = sub nsw i32 %28, 1
store i32 %29, i32* %12
br label %30
30: ; preds = %43, %27
%31 = load i32, i32* %12
%32 = load i32, i32* %8
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %46
34: ; preds = %30
%35 = load double*, double** %10
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = call double @llvm.fabs.f64(double %39)
%41 = load double, double* %9
%42 = fadd double %41, %40
store double %42, double* %9
br label %43
43: ; preds = %34
%44 = load i32, i32* %12
%45 = add nsw i32 %44, 1
store i32 %45, i32* %12
br label %30
46: ; preds = %30
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = load double*, double** %10
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds double, double* %49, i64 %50
store double* %51, double** %10
%52 = load i32, i32* %11
%53 = add nsw i32 %52, 1
store i32 %53, i32* %11
br label %23
54: ; preds = %23
%55 = load double, double* @DBL_EPSILON
%56 = load double, double* %9
%57 = fmul double %56, %55
store double %57, double* %9
%58 = load i32, i32* %8
%59 = sub nsw i32 %58, 1
store i32 %59, i32* %13
br label %60
60: ; preds = %95, %54
%61 = load i32, i32* %13
%62 = icmp sge i32 %61, 0
br i1 %62, label %63, label %98
63: ; preds = %60
%64 = load double*, double** %7
%65 = load i32, i32* %13
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = fcmp oeq double %68, 0.000000e+00
br i1 %69, label %70, label %78
70: ; preds = %63
%71 = load double*, double** %5
%72 = load double*, double** %6
%73 = load double*, double** %7
%74 = load i32, i32* %13
%75 = load double, double* %9
%76 = load i32, i32* %8
%77 = call i32 @BackSubstitute_Real_Vector(double* %71, double* %72, double* %73, i32 %74, double %75, i32 %76)
br label %94
78: ; preds = %63
%79 = load double*, double** %7
%80 = load i32, i32* %13
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
%83 = load double, double* %82
%84 = fcmp olt double %83, 0.000000e+00
br i1 %84, label %85, label %93
85: ; preds = %78
%86 = load double*, double** %5
%87 = load double*, double** %6
%88 = load double*, double** %7
%89 = load i32, i32* %13
%90 = load double, double* %9
%91 = load i32, i32* %8
%92 = call i32 @BackSubstitute_Complex_Vector(double* %86, double* %87, double* %88, i32 %89, double %90, i32 %91)
br label %93
93: ; preds = %85, %78
br label %94
94: ; preds = %93, %70
br label %95
95: ; preds = %94
%96 = load i32, i32* %13
%97 = add nsw i32 %96, -1
store i32 %97, i32* %13
br label %60
98: ; preds = %60
ret void
}

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