#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*/ eliminacion(double **, double *, int, 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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sustitucion(double **, double *, int, double *);
void init_gauss() {
  double **A, *B, *X;
  int tam;
  printf("Metodo de Eliminacion de Gauss Simple");
  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);
  eliminacion(A, X, tam, B);
  sustitucion(A, X, tam, B);
  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_gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   10c0 <scanf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <crear_matriz@plt>
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <crear_vector@plt>
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <crear_vector@plt>
mov    %rax,-0x18(%rbp)
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1080 <lee_matriz@plt>
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10e0 <lee_vector@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <imprime_matriz_aumentada@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   10d0 <eliminacion@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   10b0 <sustitucion@plt>
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <imprime_vector@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1090 <destruye_matriz@plt>
mov    -0x10(%rbp),%rdi
call   1070 <destruye_vector@plt>
mov    -0x18(%rbp),%rdi
call   1070 <destruye_vector@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_gauss>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe20(%rip),%rdi
call   1050 <printf@plt>
lea    0xe3a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe52(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10d0 <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    0xe4c(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   1090 <lee_matriz@plt>
lea    0xe04(%rip),%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   10f0 <lee_vector@plt>
lea    0xe4a(%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    %r15,%rsi
mov    %r14,%rcx
call   10e0 <eliminacion@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rcx
call   10c0 <sustitucion@plt>
lea    0xe27(%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 = [38 x i8] c"Metodo de Eliminacion de Gauss Simple\00"
@.str.1 = [36 x i8] c"\0A\0AIndique el numero de variables: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [49 x i8] c"\0AIntroduzca los coeficientes de la matriz A[][]\0A\00"
@.str.4 = [46 x i8] c"\0AIntroduzca los terminos independientes B[]\0A \00"
@.str.5 = [29 x i8] c"\0AMatriz aumentada original:\0A\00"
@.str.6 = [32 x i8] c"\0A\0ALa solucion a el sistema es:\0A\00"
define void @init_gauss() {
%1 = alloca double**
%2 = alloca double*
%3 = alloca double*
%4 = alloca i32
%5 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%8 = load i32, i32* %4
%9 = load i32, i32* %4
%10 = call double** @crear_matriz(i32 %8, i32 %9)
store double** %10, double*** %1
%11 = load i32, i32* %4
%12 = call double* @crear_vector(i32 %11)
store double* %12, double** %2
%13 = load i32, i32* %4
%14 = call double* @crear_vector(i32 %13)
store double* %14, double** %3
%15 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%16 = load double**, double*** %1
%17 = load i32, i32* %4
%18 = load i32, i32* %4
%19 = call i32 @lee_matriz(double** %16, i32 %17, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%21 = load double*, double** %2
%22 = load i32, i32* %4
%23 = call i32 @lee_vector(double* %21, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%25 = load double**, double*** %1
%26 = load double*, double** %2
%27 = load i32, i32* %4
%28 = call i32 @imprime_matriz_aumentada(double** %25, double* %26, i32 %27)
%29 = load double**, double*** %1
%30 = load double*, double** %3
%31 = load i32, i32* %4
%32 = load double*, double** %2
%33 = call i32 @eliminacion(double** %29, double* %30, i32 %31, double* %32)
%34 = load double**, double*** %1
%35 = load double*, double** %3
%36 = load i32, i32* %4
%37 = load double*, double** %2
%38 = call i32 @sustitucion(double** %34, double* %35, i32 %36, double* %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%40 = load double*, double** %3
%41 = load i32, i32* %4
%42 = call i32 @imprime_vector(double* %40, i32 %41)
%43 = load double**, double*** %1
%44 = load i32, i32* %4
%45 = load i32, i32* %4
%46 = call i32 @destruye_matriz(double** %43, i32 %44, i32 %45)
%47 = load double*, double** %2
%48 = call i32 @destruye_vector(double* %47)
%49 = load double*, double** %3
%50 = call i32 @destruye_vector(double* %49)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Metodo de Eliminacion de Gauss Simple\00"
@.str.1 = [36 x i8] c"\0A\0AIndique el numero de variables: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [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.7 = [28 x i8] c"\0AMatriz aumentada original:\00"
@str.8 = [31 x i8] c"\0A\0ALa solucion a el sistema es:\00"
define void @init_gauss() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call double** @crear_matriz(i32 %6, i32 %6)
%8 = load i32, i32* %1
%9 = call double* @crear_vector(i32 %8)
%10 = load i32, i32* %1
%11 = call double* @crear_vector(i32 %10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = call i32 @lee_matriz(double** %7, i32 %13, i32 %13)
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* %1
%17 = call i32 @lee_vector(double* %9, i32 %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.7, i64 0, i64 0))
%19 = load i32, i32* %1
%20 = call i32 @imprime_matriz_aumentada(double** %7, double* %9, i32 %19)
%21 = load i32, i32* %1
%22 = call i32 @eliminacion(double** %7, double* %11, i32 %21, double* %9)
%23 = load i32, i32* %1
%24 = call i32 @sustitucion(double** %7, double* %11, i32 %23, double* %9)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%26 = load i32, i32* %1
%27 = call i32 @imprime_vector(double* %11, i32 %26)
%28 = load i32, i32* %1
%29 = call i32 @destruye_matriz(double** %7, i32 %28, i32 %28)
%30 = call i32 @destruye_vector(double* %9)
%31 = call i32 @destruye_vector(double* %11)
ret void
}