#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 */
double **crear_matriz(int, int);
double *crear_vector(int);
int /*<<< orphan*/ destruye_matriz(double **, int, int);
int /*<<< orphan*/ destruye_vector(double *);
int /*<<< orphan*/ imprime_matriz_aumentada(double **, double *, int);
int /*<<< orphan*/ imprime_vector(double *, int);
int /*<<< orphan*/ lee_matriz(double **, int, int);
int /*<<< orphan*/ lee_vector(double *, int);
int /*<<< orphan*/ lu_decomp(double **, double *, int, double *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void init_lu() {
  int tam;
  double **A, *B, *X;
  printf("\n\nIndique el numero de  variables: ");
  scanf("%d", &tam);
  A = crear_matriz(tam, tam);
  B = crear_vector(tam);
  X = crear_vector(tam);
  printf("\nIntroduzca los coeficientes de la matriz A[][]\n");
  lee_matriz(A, tam, tam);
  printf("\nIntroduzca los terminos independientes B[]\n ");
  lee_vector(B, tam);
  printf("\nMatriz aumentada original:\n");
  imprime_matriz_aumentada(A, B, tam);
  lu_decomp(A, B, tam, X);
  printf("\n\nLa solucion a el sistema es:\n");
  imprime_vector(X, tam);
  destruye_matriz(A, tam, tam);
  destruye_vector(B);
  destruye_vector(X);
}


x86 assembly (clang, -O0):
<init_lu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1060 <crear_matriz@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   10a0 <crear_vector@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   10a0 <crear_vector@plt>
mov    %rax,-0x20(%rbp)
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1080 <lee_matriz@plt>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   10d0 <lee_vector@plt>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1030 <imprime_matriz_aumentada@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   10c0 <lu_decomp@plt>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <imprime_vector@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1090 <destruye_matriz@plt>
mov    -0x18(%rbp),%rdi
call   1070 <destruye_vector@plt>
mov    -0x20(%rbp),%rdi
call   1070 <destruye_vector@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_lu>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
lea    0xe48(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10c0 <scanf@plt>
mov    0xc(%rsp),%edi
mov    %edi,%esi
call   1070 <crear_matriz@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
call   10b0 <crear_vector@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
call   10b0 <crear_vector@plt>
mov    %rax,%r15
lea    0xe42(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   1090 <lee_matriz@plt>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   10e0 <lee_vector@plt>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <imprime_matriz_aumentada@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rcx
call   10d0 <lu_decomp@plt>
lea    0xe2f(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%esi
mov    %r15,%rdi
call   1060 <imprime_vector@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   10a0 <destruye_matriz@plt>
mov    %r14,%rdi
call   1080 <destruye_vector@plt>
mov    %r15,%rdi
call   1080 <destruye_vector@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0A\0AIndique el numero de variables: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"\0AIntroduzca los coeficientes de la matriz A[][]\0A\00"
@.str.3 = [46 x i8] c"\0AIntroduzca los terminos independientes B[]\0A \00"
@.str.4 = [29 x i8] c"\0AMatriz aumentada original:\0A\00"
@.str.5 = [32 x i8] c"\0A\0ALa solucion a el sistema es:\0A\00"
define void @init_lu() {
%1 = alloca i32
%2 = alloca double**
%3 = alloca double*
%4 = alloca double*
%5 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = load i32, i32* %1
%9 = call double** @crear_matriz(i32 %7, i32 %8)
store double** %9, double*** %2
%10 = load i32, i32* %1
%11 = call double* @crear_vector(i32 %10)
store double* %11, double** %3
%12 = load i32, i32* %1
%13 = call double* @crear_vector(i32 %12)
store double* %13, double** %4
%14 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%15 = load double**, double*** %2
%16 = load i32, i32* %1
%17 = load i32, i32* %1
%18 = call i32 @lee_matriz(double** %15, i32 %16, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%20 = load double*, double** %3
%21 = load i32, i32* %1
%22 = call i32 @lee_vector(double* %20, i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%24 = load double**, double*** %2
%25 = load double*, double** %3
%26 = load i32, i32* %1
%27 = call i32 @imprime_matriz_aumentada(double** %24, double* %25, i32 %26)
%28 = load double**, double*** %2
%29 = load double*, double** %3
%30 = load i32, i32* %1
%31 = load double*, double** %4
%32 = call i32 @lu_decomp(double** %28, double* %29, i32 %30, double* %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%34 = load double*, double** %4
%35 = load i32, i32* %1
%36 = call i32 @imprime_vector(double* %34, i32 %35)
%37 = load double**, double*** %2
%38 = load i32, i32* %1
%39 = load i32, i32* %1
%40 = call i32 @destruye_matriz(double** %37, i32 %38, i32 %39)
%41 = load double*, double** %3
%42 = call i32 @destruye_vector(double* %41)
%43 = load double*, double** %4
%44 = call i32 @destruye_vector(double* %43)
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"\0A\0AIndique el numero de variables: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [46 x i8] c"\0AIntroduzca los terminos independientes B[]\0A \00"
@str = [48 x i8] c"\0AIntroduzca los coeficientes de la matriz A[][]\00"
@str.6 = [28 x i8] c"\0AMatriz aumentada original:\00"
@str.7 = [31 x i8] c"\0A\0ALa solucion a el sistema es:\00"
define void @init_lu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call double** @crear_matriz(i32 %5, i32 %5)
%7 = load i32, i32* %1
%8 = call double* @crear_vector(i32 %7)
%9 = load i32, i32* %1
%10 = call double* @crear_vector(i32 %9)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = call i32 @lee_matriz(double** %6, i32 %12, i32 %12)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = call i32 @lee_vector(double* %8, i32 %15)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
%18 = load i32, i32* %1
%19 = call i32 @imprime_matriz_aumentada(double** %6, double* %8, i32 %18)
%20 = load i32, i32* %1
%21 = call i32 @lu_decomp(double** %6, double* %8, i32 %20, double* %10)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.7, i64 0, i64 0))
%23 = load i32, i32* %1
%24 = call i32 @imprime_vector(double* %10, i32 %23)
%25 = load i32, i32* %1
%26 = call i32 @destruye_matriz(double** %6, i32 %25, i32 %25)
%27 = call i32 @destruye_vector(double* %8)
%28 = call i32 @destruye_vector(double* %10)
ret void
}