#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*/ gauss_mod(double **, double *, int, double *, 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 *, ...);
void init_gauss_mod(void) {
  double **A, *B, *X, tol;
  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("\nIntroduzca la tolerancia\n ");
  scanf("%lf", &tol);
  printf("\nMatriz aumentada original:\n");
  imprime_matriz_aumentada(A, B, tam);
  gauss_mod(A, B, tam, X, tol);
  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_mod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1060 <crear_matriz@plt>
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%edi
call   10b0 <crear_vector@plt>
mov    %rax,-0x10(%rbp)
mov    -0x24(%rbp),%edi
call   10b0 <crear_vector@plt>
mov    %rax,-0x18(%rbp)
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1090 <lee_matriz@plt>
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10d0 <lee_vector@plt>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <imprime_matriz_aumentada@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rcx
movsd  -0x20(%rbp),%xmm0
call   1080 <gauss_mod@plt>
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <imprime_vector@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10a0 <destruye_matriz@plt>
mov    -0x10(%rbp),%rdi
call   1070 <destruye_vector@plt>
mov    -0x18(%rbp),%rdi
call   1070 <destruye_vector@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_gauss_mod>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe62(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x4(%rsp),%edi
mov    %edi,%esi
call   1070 <crear_matriz@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%edi
call   10c0 <crear_vector@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
call   10c0 <crear_vector@plt>
mov    %rax,%r15
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   10a0 <lee_matriz@plt>
lea    0xe12(%rip),%rdi
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   10e0 <lee_vector@plt>
lea    0xe28(%rip),%rdi
call   1050 <printf@plt>
lea    0xe38(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
lea    0xe59(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <imprime_matriz_aumentada@plt>
mov    0x4(%rsp),%edx
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rcx
call   1090 <gauss_mod@plt>
lea    0xe42(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
call   1060 <imprime_vector@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   10b0 <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 = [28 x i8] c"\0AIntroduzca la tolerancia\0A \00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [29 x i8] c"\0AMatriz aumentada original:\0A\00"
@.str.8 = [32 x i8] c"\0A\0ALa solucion a el sistema es:\0A\00"
define void @init_gauss_mod() {
%1 = alloca double**
%2 = alloca double*
%3 = alloca double*
%4 = alloca double
%5 = alloca i32
%6 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%9 = load i32, i32* %5
%10 = load i32, i32* %5
%11 = call double** @crear_matriz(i32 %9, i32 %10)
store double** %11, double*** %1
%12 = load i32, i32* %5
%13 = call double* @crear_vector(i32 %12)
store double* %13, double** %2
%14 = load i32, i32* %5
%15 = call double* @crear_vector(i32 %14)
store double* %15, double** %3
%16 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%17 = load double**, double*** %1
%18 = load i32, i32* %5
%19 = load i32, i32* %5
%20 = call i32 @lee_matriz(double** %17, i32 %18, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%22 = load double*, double** %2
%23 = load i32, i32* %5
%24 = call i32 @lee_vector(double* %22, i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %4)
%27 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%28 = load double**, double*** %1
%29 = load double*, double** %2
%30 = load i32, i32* %5
%31 = call i32 @imprime_matriz_aumentada(double** %28, double* %29, i32 %30)
%32 = load double**, double*** %1
%33 = load double*, double** %2
%34 = load i32, i32* %5
%35 = load double*, double** %3
%36 = load double, double* %4
%37 = call i32 @gauss_mod(double** %32, double* %33, i32 %34, double* %35, double %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%39 = load double*, double** %3
%40 = load i32, i32* %5
%41 = call i32 @imprime_vector(double* %39, i32 %40)
%42 = load double**, double*** %1
%43 = load i32, i32* %5
%44 = load i32, i32* %5
%45 = call i32 @destruye_matriz(double** %42, i32 %43, i32 %44)
%46 = load double*, double** %2
%47 = call i32 @destruye_vector(double* %46)
%48 = load double*, double** %3
%49 = call i32 @destruye_vector(double* %48)
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.5 = [28 x i8] c"\0AIntroduzca la tolerancia\0A \00"
@.str.6 = [4 x i8] c"%lf\00"
@str = [48 x i8] c"\0AIntroduzca los coeficientes de la matriz A[][]\00"
@str.9 = [28 x i8] c"\0AMatriz aumentada original:\00"
@str.10 = [31 x i8] c"\0A\0ALa solucion a el sistema es:\00"
define void @init_gauss_mod() {
%1 = alloca double
%2 = alloca i32
%3 = bitcast double* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = call double** @crear_matriz(i32 %8, i32 %8)
%10 = load i32, i32* %2
%11 = call double* @crear_vector(i32 %10)
%12 = load i32, i32* %2
%13 = call double* @crear_vector(i32 %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = call i32 @lee_matriz(double** %9, i32 %15, i32 %15)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32, i32* %2
%19 = call i32 @lee_vector(double* %11, i32 %18)
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %1)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.9, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = call i32 @imprime_matriz_aumentada(double** %9, double* %11, i32 %23)
%25 = load i32, i32* %2
%26 = load double, double* %1
%27 = call i32 @gauss_mod(double** %9, double* %11, i32 %25, double* %13, double %26)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.10, i64 0, i64 0))
%29 = load i32, i32* %2
%30 = call i32 @imprime_vector(double* %13, i32 %29)
%31 = load i32, i32* %2
%32 = call i32 @destruye_matriz(double** %9, i32 %31, i32 %31)
%33 = call i32 @destruye_vector(double* %11)
%34 = call i32 @destruye_vector(double* %13)
ret void
}