#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*/ BalBak(int, int, int, double *, int, double **);
int /*<<< orphan*/ Balanc(int, double **, int *, int *, double *);
int /*<<< orphan*/ ElTran(int, int, int, double **, int *, double **);
int /*<<< orphan*/ ElmHes(int, int, int, double **, int *);
int Hqr2(int, int, int, double **, double *, double *, double **);
int /*<<< orphan*/ PyErr_SetString(int, char *);
int eigens_for_real_matrix(int dim, double **a, double *wr, double *wi,
                           double **z, int *iv1, double *fv1) {
  static int is1, is2;
  int ierr;
  Balanc(dim, a, &is1, &is2, fv1);
  ElmHes(dim, is1, is2, a, iv1);
  ElTran(dim, is1, is2, a, iv1, z);
  ierr = Hqr2(dim, is1, is2, a, wr, wi, z);
  if (ierr == 0)
    BalBak(dim, is1, is2, fv1, dim, z);
  else {
    PyErr_SetString(2, "Error in Hqr2: max iterations exceeded.");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<eigens_for_real_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x10(%rbp),%r8
lea    0x2ebf(%rip),%rdx
lea    0x2ebc(%rip),%rcx
call   1080 <Balanc@plt>
mov    -0x8(%rbp),%edi
mov    0x2eaa(%rip),%esi
mov    0x2ea8(%rip),%edx
mov    -0x10(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1060 <ElmHes@plt>
mov    -0x8(%rbp),%edi
mov    0x2e8e(%rip),%esi
mov    0x2e8c(%rip),%edx
mov    -0x10(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x28(%rbp),%r9
call   1070 <ElTran@plt>
mov    -0x8(%rbp),%edi
mov    0x2e6e(%rip),%esi
mov    0x2e6c(%rip),%edx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    -0x28(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <Hqr2@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1237 <eigens_for_real_matrix+0xd7>
mov    -0x8(%rbp),%edi
mov    0x2e39(%rip),%esi
mov    0x2e37(%rip),%edx
mov    0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8d
mov    -0x28(%rbp),%r9
call   1040 <BalBak@plt>
jmp    1254 <eigens_for_real_matrix+0xf4>
mov    $0x2,%edi
lea    0xdbd(%rip),%rsi
call   1030 <PyErr_SetString@plt>
movl   $0x0,-0x4(%rbp)
jmp    125b <eigens_for_real_matrix+0xfb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eigens_for_real_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r13
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x40(%rsp),%r8
lea    0x2ecc(%rip),%rdx
lea    0x2ec9(%rip),%rcx
call   1080 <Balanc@plt>
mov    0x2eba(%rip),%esi
mov    0x2eb8(%rip),%edx
mov    %ebp,%edi
mov    %rbx,%rcx
mov    %r14,%r8
call   1060 <ElmHes@plt>
mov    0x2ea1(%rip),%esi
mov    0x2e9f(%rip),%edx
mov    %ebp,%edi
mov    %rbx,%rcx
mov    %r14,%r8
mov    %r13,%r9
call   1070 <ElTran@plt>
mov    0x2e85(%rip),%esi
mov    0x2e83(%rip),%edx
mov    %r13,(%rsp)
mov    %ebp,%edi
mov    %rbx,%rcx
mov    %r12,%r8
mov    %r15,%r9
call   1050 <Hqr2@plt>
test   %eax,%eax
je     1202 <eigens_for_real_matrix+0xa2>
lea    0xe0c(%rip),%rsi
mov    $0x2,%edi
call   1030 <PyErr_SetString@plt>
xor    %eax,%eax
jmp    1225 <eigens_for_real_matrix+0xc5>
mov    0x2e4c(%rip),%esi
mov    0x2e4a(%rip),%edx
mov    %ebp,%edi
mov    0x40(%rsp),%rcx
mov    %ebp,%r8d
mov    %r13,%r9
call   1040 <BalBak@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@eigens_for_real_matrix.is1 = internal global i32 0
@eigens_for_real_matrix.is2 = internal global i32 0
@.str = [40 x i8] c"Error in Hqr2: max iterations exceeded.\00"
define i32 @eigens_for_real_matrix(i32 %0, double** %1, double* %2, double* %3, double** %4, i32* %5, double* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca double**
%11 = alloca double*
%12 = alloca double*
%13 = alloca double**
%14 = alloca i32*
%15 = alloca double*
%16 = alloca i32
store i32 %0, i32* %9
store double** %1, double*** %10
store double* %2, double** %11
store double* %3, double** %12
store double** %4, double*** %13
store i32* %5, i32** %14
store double* %6, double** %15
%17 = load i32, i32* %9
%18 = load double**, double*** %10
%19 = load double*, double** %15
%20 = call i32 @Balanc(i32 %17, double** %18, i32* @eigens_for_real_matrix.is1, i32* @eigens_for_real_matrix.is2, double* %19)
%21 = load i32, i32* %9
%22 = load i32, i32* @eigens_for_real_matrix.is1
%23 = load i32, i32* @eigens_for_real_matrix.is2
%24 = load double**, double*** %10
%25 = load i32*, i32** %14
%26 = call i32 @ElmHes(i32 %21, i32 %22, i32 %23, double** %24, i32* %25)
%27 = load i32, i32* %9
%28 = load i32, i32* @eigens_for_real_matrix.is1
%29 = load i32, i32* @eigens_for_real_matrix.is2
%30 = load double**, double*** %10
%31 = load i32*, i32** %14
%32 = load double**, double*** %13
%33 = call i32 @ElTran(i32 %27, i32 %28, i32 %29, double** %30, i32* %31, double** %32)
%34 = load i32, i32* %9
%35 = load i32, i32* @eigens_for_real_matrix.is1
%36 = load i32, i32* @eigens_for_real_matrix.is2
%37 = load double**, double*** %10
%38 = load double*, double** %11
%39 = load double*, double** %12
%40 = load double**, double*** %13
%41 = call i32 @Hqr2(i32 %34, i32 %35, i32 %36, double** %37, double* %38, double* %39, double** %40)
store i32 %41, i32* %16
%42 = load i32, i32* %16
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %52
44: ; preds = %7
%45 = load i32, i32* %9
%46 = load i32, i32* @eigens_for_real_matrix.is1
%47 = load i32, i32* @eigens_for_real_matrix.is2
%48 = load double*, double** %15
%49 = load i32, i32* %9
%50 = load double**, double*** %13
%51 = call i32 @BalBak(i32 %45, i32 %46, i32 %47, double* %48, i32 %49, double** %50)
br label %54
52: ; preds = %7
%53 = call i32 @PyErr_SetString(i32 2, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %55
54: ; preds = %44
store i32 1, i32* %8
br label %55
55: ; preds = %54, %52
%56 = load i32, i32* %8
ret i32 %56
}

LLVM IR (-O2):
@eigens_for_real_matrix.is1 = internal global i32 0
@eigens_for_real_matrix.is2 = internal global i32 0
@.str = [40 x i8] c"Error in Hqr2: max iterations exceeded.\00"
define i32 @eigens_for_real_matrix(i32 %0, double** %1, double* %2, double* %3, double** %4, i32* %5, double* %6) {
%8 = tail call i32 @Balanc(i32 %0, double** %1, i32* @eigens_for_real_matrix.is1, i32* @eigens_for_real_matrix.is2, double* %6)
%9 = load i32, i32* @eigens_for_real_matrix.is1
%10 = load i32, i32* @eigens_for_real_matrix.is2
%11 = tail call i32 @ElmHes(i32 %0, i32 %9, i32 %10, double** %1, i32* %5)
%12 = load i32, i32* @eigens_for_real_matrix.is1
%13 = load i32, i32* @eigens_for_real_matrix.is2
%14 = tail call i32 @ElTran(i32 %0, i32 %12, i32 %13, double** %1, i32* %5, double** %4)
%15 = load i32, i32* @eigens_for_real_matrix.is1
%16 = load i32, i32* @eigens_for_real_matrix.is2
%17 = tail call i32 @Hqr2(i32 %0, i32 %15, i32 %16, double** %1, double* %2, double* %3, double** %4)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %7
%20 = load i32, i32* @eigens_for_real_matrix.is1
%21 = load i32, i32* @eigens_for_real_matrix.is2
%22 = tail call i32 @BalBak(i32 %0, i32 %20, i32 %21, double* %6, i32 %0, double** %4)
br label %25
23: ; preds = %7
%24 = tail call i32 @PyErr_SetString(i32 2, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %19, %23
%26 = phi i32 [ 1, %19 ], [ 0, %23 ]
ret i32 %26
}