#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 backcol(int, double **, double *, int);
int backrow(int, double **, double *, int);
int cholcol(int, double **);
int cholrow(int, double **);
int /*<<< orphan*/ converte_milisegundo(unsigned long long);
int forwcol(int, double **, double *);
int forwrow(int, double **, double *);
int /*<<< orphan*/ imprime_vetor(int, double *);
int /*<<< orphan*/ printf(char *, ...);
unsigned long long tempo_em_microsegundos();
int testa_cholesky(int n, double A[][800], double b[], int modo,
                   int imprime_solucao, int imprime_tempo) {
  unsigned long long mark0, mark1, mark2, mark3;
  mark0 = tempo_em_microsegundos();
  if (modo == 0) {
    if (cholrow(n, A) == -1)
      return -1;
  } else {
    if (cholcol(n, A) == -1)
      return -1;
  }
  mark1 = tempo_em_microsegundos();
  if (modo == 0) {
    if (forwrow(n, A, b) == -1)
      return -1;
  } else {
    if (forwcol(n, A, b) == -1)
      return -1;
  }
  mark2 = tempo_em_microsegundos();
  if (modo == 0) {
    if (backrow(n, A, b, 1) == -1)
      return -1;
  } else {
    if (backcol(n, A, b, 1) == -1)
      return -1;
  }
  mark3 = tempo_em_microsegundos();
  if (imprime_tempo) {
    printf("| %6.2lf | %.2lf | %.2lf\n", converte_milisegundo(mark1 - mark0),
           converte_milisegundo(mark2 - mark1),
           converte_milisegundo(mark3 - mark2));
  }
  if (imprime_solucao == 1) {
    printf("x eh:\n");
    imprime_vetor(n, b);
  }
  return 0;
}


x86 assembly (clang, -O0):
<testa_cholesky>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    $0x0,%al
call   1040 <tempo_em_microsegundos@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11f9 <testa_cholesky+0x59>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <cholrow@plt>
cmp    $0xffffffff,%eax
jne    11f4 <testa_cholesky+0x54>
movl   $0xffffffff,-0x4(%rbp)
jmp    137e <testa_cholesky+0x1de>
jmp    121f <testa_cholesky+0x7f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10a0 <cholcol@plt>
cmp    $0xffffffff,%eax
jne    121a <testa_cholesky+0x7a>
movl   $0xffffffff,-0x4(%rbp)
jmp    137e <testa_cholesky+0x1de>
jmp    121f <testa_cholesky+0x7f>
mov    $0x0,%al
call   1040 <tempo_em_microsegundos@plt>
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    125e <testa_cholesky+0xbe>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10c0 <forwrow@plt>
cmp    $0xffffffff,%eax
jne    1259 <testa_cholesky+0xb9>
movl   $0xffffffff,-0x4(%rbp)
jmp    137e <testa_cholesky+0x1de>
jmp    1288 <testa_cholesky+0xe8>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10b0 <forwcol@plt>
cmp    $0xffffffff,%eax
jne    1283 <testa_cholesky+0xe3>
movl   $0xffffffff,-0x4(%rbp)
jmp    137e <testa_cholesky+0x1de>
jmp    1288 <testa_cholesky+0xe8>
mov    $0x0,%al
call   1040 <tempo_em_microsegundos@plt>
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12cc <testa_cholesky+0x12c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%ecx
call   1080 <backrow@plt>
cmp    $0xffffffff,%eax
jne    12c7 <testa_cholesky+0x127>
movl   $0xffffffff,-0x4(%rbp)
jmp    137e <testa_cholesky+0x1de>
jmp    12fb <testa_cholesky+0x15b>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%ecx
call   1090 <backcol@plt>
cmp    $0xffffffff,%eax
jne    12f6 <testa_cholesky+0x156>
movl   $0xffffffff,-0x4(%rbp)
jmp    137e <testa_cholesky+0x1de>
jmp    12fb <testa_cholesky+0x15b>
mov    $0x0,%al
call   1040 <tempo_em_microsegundos@plt>
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1353 <testa_cholesky+0x1b3>
mov    -0x38(%rbp),%rdi
sub    -0x30(%rbp),%rdi
call   1060 <converte_milisegundo@plt>
mov    %eax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
sub    -0x38(%rbp),%rdi
call   1060 <converte_milisegundo@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
sub    -0x40(%rbp),%rdi
call   1060 <converte_milisegundo@plt>
mov    -0x50(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    %eax,%ecx
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x1,-0x20(%rbp)
jne    1377 <testa_cholesky+0x1d7>
lea    0xcb6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <imprime_vetor@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testa_cholesky>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,(%rsp)
mov    %r8d,%ebp
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %edi,%r12d
xor    %eax,%eax
call   1050 <tempo_em_microsegundos@plt>
test   %ebx,%ebx
mov    %ebp,0x4(%rsp)
mov    %rax,0x10(%rsp)
mov    %r12d,%edi
mov    %r14,%rsi
je     1246 <testa_cholesky+0x96>
call   10b0 <cholcol@plt>
mov    $0xffffffff,%r13d
cmp    $0xffffffff,%eax
je     131c <testa_cholesky+0x16c>
xor    %eax,%eax
call   1050 <tempo_em_microsegundos@plt>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10c0 <forwcol@plt>
cmp    $0xffffffff,%eax
je     131c <testa_cholesky+0x16c>
xor    %eax,%eax
call   1050 <tempo_em_microsegundos@plt>
mov    %rax,%rbp
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x1,%ecx
call   10a0 <backcol@plt>
cmp    $0xffffffff,%eax
jne    129d <testa_cholesky+0xed>
jmp    131c <testa_cholesky+0x16c>
call   1030 <cholrow@plt>
mov    $0xffffffff,%r13d
cmp    $0xffffffff,%eax
je     131c <testa_cholesky+0x16c>
xor    %eax,%eax
call   1050 <tempo_em_microsegundos@plt>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10d0 <forwrow@plt>
cmp    $0xffffffff,%eax
je     131c <testa_cholesky+0x16c>
xor    %eax,%eax
call   1050 <tempo_em_microsegundos@plt>
mov    %rax,%rbp
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x1,%ecx
call   1090 <backrow@plt>
cmp    $0xffffffff,%eax
je     131c <testa_cholesky+0x16c>
mov    %rbp,0x8(%rsp)
mov    %rbx,%r14
mov    (%rsp),%ebp
xor    %r13d,%r13d
xor    %eax,%eax
call   1050 <tempo_em_microsegundos@plt>
test   %ebp,%ebp
je     12fe <testa_cholesky+0x14e>
mov    %rax,%rbx
mov    %r14,%rbp
mov    %r14,%rdi
sub    0x10(%rsp),%rdi
call   1070 <converte_milisegundo@plt>
mov    %eax,(%rsp)
mov    0x8(%rsp),%r14
mov    %r14,%rdi
sub    %rbp,%rdi
call   1070 <converte_milisegundo@plt>
mov    %eax,%ebp
sub    %r14,%rbx
mov    %rbx,%rdi
call   1070 <converte_milisegundo@plt>
lea    0xd10(%rip),%rdi
mov    (%rsp),%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <printf@plt>
cmpl   $0x1,0x4(%rsp)
jne    131c <testa_cholesky+0x16c>
lea    0xd0e(%rip),%rdi
call   1040 <puts@plt>
mov    %r12d,%edi
mov    %r15,%rsi
call   1060 <imprime_vetor@plt>
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"| %6.2lf | %.2lf | %.2lf\0A\00"
@.str.1 = [7 x i8] c"x eh:\0A\00"
define i32 @testa_cholesky(i32 %0, [800 x double]* %1, double* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca [800 x double]*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
store i32 %0, i32* %8
store [800 x double]* %1, [800 x double]** %9
store double* %2, double** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%18 = call i64 (...) @tempo_em_microsegundos()
store i64 %18, i64* %14
%19 = load i32, i32* %11
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %6
%22 = load i32, i32* %8
%23 = load [800 x double]*, [800 x double]** %9
%24 = bitcast [800 x double]* %23 to double**
%25 = call i32 @cholrow(i32 %22, double** %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 -1, i32* %7
br label %108
28: ; preds = %21
br label %37
29: ; preds = %6
%30 = load i32, i32* %8
%31 = load [800 x double]*, [800 x double]** %9
%32 = bitcast [800 x double]* %31 to double**
%33 = call i32 @cholcol(i32 %30, double** %32)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %36
35: ; preds = %29
store i32 -1, i32* %7
br label %108
36: ; preds = %29
br label %37
37: ; preds = %36, %28
%38 = call i64 (...) @tempo_em_microsegundos()
store i64 %38, i64* %15
%39 = load i32, i32* %11
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %50
41: ; preds = %37
%42 = load i32, i32* %8
%43 = load [800 x double]*, [800 x double]** %9
%44 = bitcast [800 x double]* %43 to double**
%45 = load double*, double** %10
%46 = call i32 @forwrow(i32 %42, double** %44, double* %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %49
48: ; preds = %41
store i32 -1, i32* %7
br label %108
49: ; preds = %41
br label %59
50: ; preds = %37
%51 = load i32, i32* %8
%52 = load [800 x double]*, [800 x double]** %9
%53 = bitcast [800 x double]* %52 to double**
%54 = load double*, double** %10
%55 = call i32 @forwcol(i32 %51, double** %53, double* %54)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %58
57: ; preds = %50
store i32 -1, i32* %7
br label %108
58: ; preds = %50
br label %59
59: ; preds = %58, %49
%60 = call i64 (...) @tempo_em_microsegundos()
store i64 %60, i64* %16
%61 = load i32, i32* %11
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %72
63: ; preds = %59
%64 = load i32, i32* %8
%65 = load [800 x double]*, [800 x double]** %9
%66 = bitcast [800 x double]* %65 to double**
%67 = load double*, double** %10
%68 = call i32 @backrow(i32 %64, double** %66, double* %67, i32 1)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %71
70: ; preds = %63
store i32 -1, i32* %7
br label %108
71: ; preds = %63
br label %81
72: ; preds = %59
%73 = load i32, i32* %8
%74 = load [800 x double]*, [800 x double]** %9
%75 = bitcast [800 x double]* %74 to double**
%76 = load double*, double** %10
%77 = call i32 @backcol(i32 %73, double** %75, double* %76, i32 1)
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %80
79: ; preds = %72
store i32 -1, i32* %7
br label %108
80: ; preds = %72
br label %81
81: ; preds = %80, %71
%82 = call i64 (...) @tempo_em_microsegundos()
store i64 %82, i64* %17
%83 = load i32, i32* %13
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %99
85: ; preds = %81
%86 = load i64, i64* %15
%87 = load i64, i64* %14
%88 = sub i64 %86, %87
%89 = call i32 @converte_milisegundo(i64 %88)
%90 = load i64, i64* %16
%91 = load i64, i64* %15
%92 = sub i64 %90, %91
%93 = call i32 @converte_milisegundo(i64 %92)
%94 = load i64, i64* %17
%95 = load i64, i64* %16
%96 = sub i64 %94, %95
%97 = call i32 @converte_milisegundo(i64 %96)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %89, i32 %93, i32 %97)
br label %99
99: ; preds = %85, %81
%100 = load i32, i32* %12
%101 = icmp eq i32 %100, 1
br i1 %101, label %102, label %107
102: ; preds = %99
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%104 = load i32, i32* %8
%105 = load double*, double** %10
%106 = call i32 @imprime_vetor(i32 %104, double* %105)
br label %107
107: ; preds = %102, %99
store i32 0, i32* %7
br label %108
108: ; preds = %107, %79, %70, %57, %48, %35, %27
%109 = load i32, i32* %7
ret i32 %109
}

LLVM IR (-O2):
@.str = [26 x i8] c"| %6.2lf | %.2lf | %.2lf\0A\00"
@str = [6 x i8] c"x eh:\00"
define i32 @testa_cholesky(i32 %0, [800 x double]* %1, double* %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i64 (...) @tempo_em_microsegundos()
%8 = icmp eq i32 %3, 0
%9 = bitcast [800 x double]* %1 to double**
br i1 %8, label %10, label %13
10: ; preds = %6
%11 = tail call i32 @cholrow(i32 %0, double** %9)
%12 = icmp eq i32 %11, -1
br i1 %12, label %50, label %16
13: ; preds = %6
%14 = tail call i32 @cholcol(i32 %0, double** %9)
%15 = icmp eq i32 %14, -1
br i1 %15, label %50, label %20
16: ; preds = %10
%17 = tail call i64 (...) @tempo_em_microsegundos()
%18 = tail call i32 @forwrow(i32 %0, double** %9, double* %2)
%19 = icmp eq i32 %18, -1
br i1 %19, label %50, label %24
20: ; preds = %13
%21 = tail call i64 (...) @tempo_em_microsegundos()
%22 = tail call i32 @forwcol(i32 %0, double** %9, double* %2)
%23 = icmp eq i32 %22, -1
br i1 %23, label %50, label %28
24: ; preds = %16
%25 = tail call i64 (...) @tempo_em_microsegundos()
%26 = tail call i32 @backrow(i32 %0, double** %9, double* %2, i32 1)
%27 = icmp eq i32 %26, -1
br i1 %27, label %50, label %32
28: ; preds = %20
%29 = tail call i64 (...) @tempo_em_microsegundos()
%30 = tail call i32 @backcol(i32 %0, double** %9, double* %2, i32 1)
%31 = icmp eq i32 %30, -1
br i1 %31, label %50, label %32
32: ; preds = %28, %24
%33 = phi i64 [ %29, %28 ], [ %25, %24 ]
%34 = phi i64 [ %21, %28 ], [ %17, %24 ]
%35 = tail call i64 (...) @tempo_em_microsegundos()
%36 = icmp eq i32 %5, 0
br i1 %36, label %45, label %37
37: ; preds = %32
%38 = sub i64 %34, %7
%39 = tail call i32 @converte_milisegundo(i64 %38)
%40 = sub i64 %33, %34
%41 = tail call i32 @converte_milisegundo(i64 %40)
%42 = sub i64 %35, %33
%43 = tail call i32 @converte_milisegundo(i64 %42)
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %39, i32 %41, i32 %43)
br label %45
45: ; preds = %37, %32
%46 = icmp eq i32 %4, 1
br i1 %46, label %47, label %50
47: ; preds = %45
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%49 = tail call i32 @imprime_vetor(i32 %0, double* %2)
br label %50
50: ; preds = %45, %47, %28, %24, %20, %16, %13, %10
%51 = phi i32 [ -1, %10 ], [ -1, %13 ], [ -1, %16 ], [ -1, %20 ], [ -1, %24 ], [ -1, %28 ], [ 0, %47 ], [ 0, %45 ]
ret i32 %51
}