#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_seidel(double **, double *, double *, int, 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 *, ...);
void init_gauss_seid() {
  double **A, *B, *X, es;
  int imax, tam;
  printf("\n\t\tMetodo de Gauss Seidel");
  printf("\n\tIngresa las iteraciones maximas:\t");
  scanf("%d", &imax);
  printf("\n\tIngresa el error:\t");
  scanf("%lf", &es);
  printf("\n\tIngresa el numero de variables:\t");
  scanf("%d", &tam);
  A = crear_matriz(tam, tam);
  B = crear_vector(tam);
  X = crear_vector(tam);
  printf("\n\t\tDame los valores de la matriz:");
  lee_matriz(A, tam, tam);
  printf("\n\t\tDame los valores del vector:");
  lee_vector(X, tam);
  printf("\nMatriz aumentada original:\n");
  imprime_matriz_aumentada(A, B, tam);
  gauss_seidel(A, B, X, tam, imax, es);
  printf("Solucion al sistema\n");
  imprime_vector(X, tam);
  destruye_matriz(A, tam, tam);
  destruye_vector(X);
  destruye_vector(B);
}


x86 assembly (clang, -O0):
<init_gauss_seid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
lea    0xe61(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
lea    0xe2b(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x28(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1060 <crear_matriz@plt>
mov    %rax,-0x8(%rbp)
mov    -0x28(%rbp),%edi
call   10b0 <crear_vector@plt>
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%edi
call   10b0 <crear_vector@plt>
mov    %rax,-0x18(%rbp)
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1090 <lee_matriz@plt>
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10d0 <lee_vector@plt>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1030 <imprime_matriz_aumentada@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%r8d
movsd  -0x20(%rbp),%xmm0
call   1080 <gauss_seidel@plt>
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1050 <imprime_vector@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x28(%rbp),%edx
call   10a0 <destruye_matriz@plt>
mov    -0x18(%rbp),%rdi
call   1070 <destruye_vector@plt>
mov    -0x10(%rbp),%rdi
call   1070 <destruye_vector@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_gauss_seid>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
lea    0xe3e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe56(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   10d0 <scanf@plt>
lea    0xe43(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    (%rsp),%edi
mov    %edi,%esi
call   1070 <crear_matriz@plt>
mov    %rax,%r15
mov    (%rsp),%edi
call   10c0 <crear_vector@plt>
mov    %rax,%r14
mov    (%rsp),%edi
call   10c0 <crear_vector@plt>
mov    %rax,%rbx
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
mov    (%rsp),%edx
mov    %r15,%rdi
mov    %edx,%esi
call   10a0 <lee_matriz@plt>
lea    0xe2d(%rip),%rdi
call   1050 <printf@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
call   10e0 <lee_vector@plt>
lea    0xe36(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <imprime_matriz_aumentada@plt>
mov    (%rsp),%ecx
mov    0x4(%rsp),%r8d
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1090 <gauss_seidel@plt>
lea    0xe1c(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
call   1060 <imprime_vector@plt>
mov    (%rsp),%edx
mov    %r15,%rdi
mov    %edx,%esi
call   10b0 <destruye_matriz@plt>
mov    %rbx,%rdi
call   1080 <destruye_vector@plt>
mov    %r14,%rdi
call   1080 <destruye_vector@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0A\09\09Metodo de Gauss Seidel\00"
@.str.1 = [36 x i8] c"\0A\09Ingresa las iteraciones maximas:\09\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"\0A\09Ingresa el error:\09\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [35 x i8] c"\0A\09Ingresa el numero de variables:\09\00"
@.str.6 = [34 x i8] c"\0A\09\09Dame los valores de la matriz:\00"
@.str.7 = [32 x i8] c"\0A\09\09Dame los valores del vector:\00"
@.str.8 = [29 x i8] c"\0AMatriz aumentada original:\0A\00"
@.str.9 = [21 x i8] c"Solucion al sistema\0A\00"
define void @init_gauss_seid() {
%1 = alloca double**
%2 = alloca double*
%3 = alloca double*
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %4)
%12 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%14 = load i32, i32* %6
%15 = load i32, i32* %6
%16 = call double** @crear_matriz(i32 %14, i32 %15)
store double** %16, double*** %1
%17 = load i32, i32* %6
%18 = call double* @crear_vector(i32 %17)
store double* %18, double** %2
%19 = load i32, i32* %6
%20 = call double* @crear_vector(i32 %19)
store double* %20, double** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%22 = load double**, double*** %1
%23 = load i32, i32* %6
%24 = load i32, i32* %6
%25 = call i32 @lee_matriz(double** %22, i32 %23, i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%27 = load double*, double** %3
%28 = load i32, i32* %6
%29 = call i32 @lee_vector(double* %27, i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%31 = load double**, double*** %1
%32 = load double*, double** %2
%33 = load i32, i32* %6
%34 = call i32 @imprime_matriz_aumentada(double** %31, double* %32, i32 %33)
%35 = load double**, double*** %1
%36 = load double*, double** %2
%37 = load double*, double** %3
%38 = load i32, i32* %6
%39 = load i32, i32* %5
%40 = load double, double* %4
%41 = call i32 @gauss_seidel(double** %35, double* %36, double* %37, i32 %38, i32 %39, double %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%43 = load double*, double** %3
%44 = load i32, i32* %6
%45 = call i32 @imprime_vector(double* %43, i32 %44)
%46 = load double**, double*** %1
%47 = load i32, i32* %6
%48 = load i32, i32* %6
%49 = call i32 @destruye_matriz(double** %46, i32 %47, i32 %48)
%50 = load double*, double** %3
%51 = call i32 @destruye_vector(double* %50)
%52 = load double*, double** %2
%53 = call i32 @destruye_vector(double* %52)
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0A\09\09Metodo de Gauss Seidel\00"
@.str.1 = [36 x i8] c"\0A\09Ingresa las iteraciones maximas:\09\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"\0A\09Ingresa el error:\09\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [35 x i8] c"\0A\09Ingresa el numero de variables:\09\00"
@.str.6 = [34 x i8] c"\0A\09\09Dame los valores de la matriz:\00"
@.str.7 = [32 x i8] c"\0A\09\09Dame los valores del vector:\00"
@str = [28 x i8] c"\0AMatriz aumentada original:\00"
@str.10 = [20 x i8] c"Solucion al sistema\00"
define void @init_gauss_seid() {
%1 = alloca double
%2 = alloca i32
%3 = alloca i32
%4 = bitcast double* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %1)
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = call double** @crear_matriz(i32 %14, i32 %14)
%16 = load i32, i32* %3
%17 = call double* @crear_vector(i32 %16)
%18 = load i32, i32* %3
%19 = call double* @crear_vector(i32 %18)
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%21 = load i32, i32* %3
%22 = call i32 @lee_matriz(double** %15, i32 %21, i32 %21)
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%24 = load i32, i32* %3
%25 = call i32 @lee_vector(double* %19, i32 %24)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = call i32 @imprime_matriz_aumentada(double** %15, double* %17, i32 %27)
%29 = load i32, i32* %3
%30 = load i32, i32* %2
%31 = load double, double* %1
%32 = call i32 @gauss_seidel(double** %15, double* %17, double* %19, i32 %29, i32 %30, double %31)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%34 = load i32, i32* %3
%35 = call i32 @imprime_vector(double* %19, i32 %34)
%36 = load i32, i32* %3
%37 = call i32 @destruye_matriz(double** %15, i32 %36, i32 %36)
%38 = call i32 @destruye_vector(double* %19)
%39 = call i32 @destruye_vector(double* %17)
ret void
}