#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 confere_fatoracao_lu(double **, double **, double **, double **, double **,
                         double **, int);
int /*<<< orphan*/ fatoracao_lu(double **, int, double **, double **,
                                double **);
int /*<<< orphan*/ free(double **);
int /*<<< orphan*/ imprime_matriz(double **, int, int, char *);
double **matriz_quadrada_nula(int);
int /*<<< orphan*/ printf(char *);
void imprime_teste_fatoracao_lu(double **A, double **L_ok, double **U_ok,
                                double **P_ok, int dim) {
  bool correto;
  double **L, **U, **P;
  L = matriz_quadrada_nula(dim);
  U = matriz_quadrada_nula(dim);
  P = matriz_quadrada_nula(dim);
  printf("\n-------------------\n");
  printf("\nFatoracao LU: \n");
  imprime_matriz(A, dim, dim, "A = matriz");
  fatoracao_lu(A, dim, L, U, P);
  imprime_matriz(L, dim, dim, "L encontrado");
  imprime_matriz(L_ok, dim, dim, "L correto");
  imprime_matriz(U, dim, dim, "U encontrado");
  imprime_matriz(U_ok, dim, dim, "U correto");
  imprime_matriz(P, dim, dim, "P encontrado");
  imprime_matriz(P_ok, dim, dim, "P correto");
  correto = confere_fatoracao_lu(L, U, P, L_ok, U_ok, P_ok, dim);
  if (correto) {
    printf("\nFatoracao LU executada com sucesso.\n");
  } else {
    printf("\nFatoracao LU nao passou nos testes.\n");
  }
  printf("\n-------------------\n");
  free(L);
  L = NULL;
  free(U);
  U = NULL;
  free(P);
  P = NULL;
}


x86 assembly (clang, -O0):
<imprime_teste_fatoracao_lu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <matriz_quadrada_nula@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <matriz_quadrada_nula@plt>
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <matriz_quadrada_nula@plt>
mov    %rax,-0x40(%rbp)
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
lea    0xe63(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe5e(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
call   1070 <fatoracao_lu@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe3b(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe32(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe26(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe1d(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x40(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe11(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe08(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    -0x24(%rbp),%eax
mov    %eax,(%rsp)
call   1080 <confere_fatoracao_lu@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     12ab <imprime_teste_fatoracao_lu+0x14b>
lea    0xdd6(%rip),%rdi
call   1050 <printf@plt>
jmp    12b7 <imprime_teste_fatoracao_lu+0x157>
lea    0xdeb(%rip),%rdi
call   1050 <printf@plt>
lea    0xd42(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x40(%rbp)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprime_teste_fatoracao_lu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r12d
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,%rbp
mov    %rsi,0x10(%rsp)
mov    %rdi,%r13
mov    %r8d,%edi
call   1050 <matriz_quadrada_nula@plt>
mov    %rax,%rbx
mov    %r12d,%edi
call   1050 <matriz_quadrada_nula@plt>
mov    %rax,%r15
mov    %r12d,%edi
call   1050 <matriz_quadrada_nula@plt>
mov    %rax,%r14
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe96(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3a(%rip),%rcx
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r12d,%edx
call   1060 <imprime_matriz@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1070 <fatoracao_lu@plt>
lea    0xe1c(%rip),%rcx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r12d,%edx
call   1060 <imprime_matriz@plt>
lea    0xe14(%rip),%rcx
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r12d,%edx
call   1060 <imprime_matriz@plt>
lea    0xe09(%rip),%rcx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r12d,%edx
call   1060 <imprime_matriz@plt>
lea    0xe01(%rip),%rcx
mov    0x18(%rsp),%r13
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r12d,%edx
call   1060 <imprime_matriz@plt>
lea    0xdf1(%rip),%rcx
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r12d,%edx
call   1060 <imprime_matriz@plt>
lea    0xde9(%rip),%rcx
mov    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r12d,%edx
call   1060 <imprime_matriz@plt>
mov    %r12d,(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    0x10(%rsp),%rcx
mov    %r13,%r8
mov    %rbp,%r9
call   1080 <confere_fatoracao_lu@plt>
test   %eax,%eax
lea    0xdca(%rip),%rax
lea    0xdfd(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
lea    0xdd8(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"\0A-------------------\0A\00"
@.str.1 = [17 x i8] c"\0AFatoracao LU: \0A\00"
@.str.2 = [11 x i8] c"A = matriz\00"
@.str.3 = [13 x i8] c"L encontrado\00"
@.str.4 = [10 x i8] c"L correto\00"
@.str.5 = [13 x i8] c"U encontrado\00"
@.str.6 = [10 x i8] c"U correto\00"
@.str.7 = [13 x i8] c"P encontrado\00"
@.str.8 = [10 x i8] c"P correto\00"
@.str.9 = [38 x i8] c"\0AFatoracao LU executada com sucesso.\0A\00"
@.str.10 = [38 x i8] c"\0AFatoracao LU nao passou nos testes.\0A\00"
define void @imprime_teste_fatoracao_lu(double** %0, double** %1, double** %2, double** %3, i32 %4) {
%6 = alloca double**
%7 = alloca double**
%8 = alloca double**
%9 = alloca double**
%10 = alloca i32
%11 = alloca i32
%12 = alloca double**
%13 = alloca double**
%14 = alloca double**
store double** %0, double*** %6
store double** %1, double*** %7
store double** %2, double*** %8
store double** %3, double*** %9
store i32 %4, i32* %10
%15 = load i32, i32* %10
%16 = call double** @matriz_quadrada_nula(i32 %15)
store double** %16, double*** %12
%17 = load i32, i32* %10
%18 = call double** @matriz_quadrada_nula(i32 %17)
store double** %18, double*** %13
%19 = load i32, i32* %10
%20 = call double** @matriz_quadrada_nula(i32 %19)
store double** %20, double*** %14
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%23 = load double**, double*** %6
%24 = load i32, i32* %10
%25 = load i32, i32* %10
%26 = call i32 @imprime_matriz(double** %23, i32 %24, i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%27 = load double**, double*** %6
%28 = load i32, i32* %10
%29 = load double**, double*** %12
%30 = load double**, double*** %13
%31 = load double**, double*** %14
%32 = call i32 @fatoracao_lu(double** %27, i32 %28, double** %29, double** %30, double** %31)
%33 = load double**, double*** %12
%34 = load i32, i32* %10
%35 = load i32, i32* %10
%36 = call i32 @imprime_matriz(double** %33, i32 %34, i32 %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%37 = load double**, double*** %7
%38 = load i32, i32* %10
%39 = load i32, i32* %10
%40 = call i32 @imprime_matriz(double** %37, i32 %38, i32 %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%41 = load double**, double*** %13
%42 = load i32, i32* %10
%43 = load i32, i32* %10
%44 = call i32 @imprime_matriz(double** %41, i32 %42, i32 %43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%45 = load double**, double*** %8
%46 = load i32, i32* %10
%47 = load i32, i32* %10
%48 = call i32 @imprime_matriz(double** %45, i32 %46, i32 %47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%49 = load double**, double*** %14
%50 = load i32, i32* %10
%51 = load i32, i32* %10
%52 = call i32 @imprime_matriz(double** %49, i32 %50, i32 %51, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%53 = load double**, double*** %9
%54 = load i32, i32* %10
%55 = load i32, i32* %10
%56 = call i32 @imprime_matriz(double** %53, i32 %54, i32 %55, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%57 = load double**, double*** %12
%58 = load double**, double*** %13
%59 = load double**, double*** %14
%60 = load double**, double*** %7
%61 = load double**, double*** %8
%62 = load double**, double*** %9
%63 = load i32, i32* %10
%64 = call i32 @confere_fatoracao_lu(double** %57, double** %58, double** %59, double** %60, double** %61, double** %62, i32 %63)
store i32 %64, i32* %11
%65 = load i32, i32* %11
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %5
%68 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
br label %71
69: ; preds = %5
%70 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
br label %71
71: ; preds = %69, %67
%72 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%73 = load double**, double*** %12
%74 = call i32 @free(double** %73)
store double** null, double*** %12
%75 = load double**, double*** %13
%76 = call i32 @free(double** %75)
store double** null, double*** %13
%77 = load double**, double*** %14
%78 = call i32 @free(double** %77)
store double** null, double*** %14
ret void
}

LLVM IR (-O2):
@.str.2 = [11 x i8] c"A = matriz\00"
@.str.3 = [13 x i8] c"L encontrado\00"
@.str.4 = [10 x i8] c"L correto\00"
@.str.5 = [13 x i8] c"U encontrado\00"
@.str.6 = [10 x i8] c"U correto\00"
@.str.7 = [13 x i8] c"P encontrado\00"
@.str.8 = [10 x i8] c"P correto\00"
@str.11 = [16 x i8] c"\0AFatoracao LU: \00"
@str.12 = [37 x i8] c"\0AFatoracao LU nao passou nos testes.\00"
@str.13 = [21 x i8] c"\0A-------------------\00"
@str.14 = [37 x i8] c"\0AFatoracao LU executada com sucesso.\00"
define void @imprime_teste_fatoracao_lu(double** %0, double** %1, double** %2, double** %3, i32 %4) {
%6 = tail call double** @matriz_quadrada_nula(i32 %4)
%7 = tail call double** @matriz_quadrada_nula(i32 %4)
%8 = tail call double** @matriz_quadrada_nula(i32 %4)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.13, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%11 = tail call i32 @imprime_matriz(double** %0, i32 %4, i32 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @fatoracao_lu(double** %0, i32 %4, double** %6, double** %7, double** %8)
%13 = tail call i32 @imprime_matriz(double** %6, i32 %4, i32 %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @imprime_matriz(double** %1, i32 %4, i32 %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 @imprime_matriz(double** %7, i32 %4, i32 %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%16 = tail call i32 @imprime_matriz(double** %2, i32 %4, i32 %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%17 = tail call i32 @imprime_matriz(double** %8, i32 %4, i32 %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%18 = tail call i32 @imprime_matriz(double** %3, i32 %4, i32 %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%19 = tail call i32 @confere_fatoracao_lu(double** %6, double** %7, double** %8, double** %1, double** %2, double** %3, i32 %4)
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.12, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.14, i64 0, i64 0)
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.13, i64 0, i64 0))
%24 = tail call i32 @free(double** %6)
%25 = tail call i32 @free(double** %7)
%26 = tail call i32 @free(double** %8)
ret void
}