#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);
int /*<<< orphan*/ destruye_matriz(double **, int, int);
int /*<<< orphan*/ imprime_matriz(double **, int, int);
int /*<<< orphan*/ lee_matriz(double **, int, int);
int /*<<< orphan*/ mat_mult(double **, double **, double **, int, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
void matriz_mult() {
  double **A, **B, **C;
  int n, m1, m2, l;
  printf("Dame las filas de la primera matriz: ");
  scanf("%d", &n);
  printf("Dame las columnas de la primera matriz: ");
  scanf("%d", &m1);
  printf("Dame las filas de la segunda matriz: ");
  scanf("%d", &m2);
  printf("Dame las columnas de la primera matriz: ");
  scanf("%d", &l);
  if (m1 != m2) {
    system("cls");
    printf("Error la columna de la primera matriz no es igual a la columna de "
           "la segunda matriz\n");
    matriz_mult();
  } else {
    system("cls");
    A = crear_matriz(n, m1);
    B = crear_matriz(m2, l);
    C = crear_matriz(n, l);
    printf("Primera matriz\n");
    lee_matriz(A, n, m1);
    printf("Segunda matriz\n");
    lee_matriz(B, m2, l);
    mat_mult(A, B, C, n, l, m1);
    printf("El resultado de la multiplicacion es\n");
    imprime_matriz(C, n, l);
    destruye_matriz(A, n, m1);
    destruye_matriz(B, m2, l);
    destruye_matriz(C, n, l);
    system("pause");
  }
}


x86 assembly (clang, -O0):
<matriz_mult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe61(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   10a0 <scanf@plt>
lea    0xe6e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe5f(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   10a0 <scanf@plt>
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
lea    0xe43(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   10a0 <scanf@plt>
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
lea    0xe27(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     1236 <matriz_mult+0xa6>
lea    0xe5d(%rip),%rdi
call   1040 <system@plt>
lea    0xe55(%rip),%rdi
call   1050 <printf@plt>
call   1030 <matriz_mult@plt>
jmp    1315 <matriz_mult+0x185>
lea    0xe3b(%rip),%rdi
call   1040 <system@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1060 <crear_matriz@plt>
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1060 <crear_matriz@plt>
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1060 <crear_matriz@plt>
mov    %rax,-0x18(%rbp)
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1080 <lee_matriz@plt>
lea    0xe50(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1080 <lee_matriz@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x20(%rbp),%r9d
call   10b0 <mat_mult@plt>
lea    0xe29(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1070 <imprime_matriz@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1090 <destruye_matriz@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1090 <destruye_matriz@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1090 <destruye_matriz@plt>
lea    0xe07(%rip),%rdi
call   1040 <system@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matriz_mult>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
lea    0xe69(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   10b0 <scanf@plt>
lea    0xe58(%rip),%r14
mov    %r14,%rdi
call   1060 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   10b0 <scanf@plt>
lea    0xe65(%rip),%rdi
call   1060 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   10b0 <scanf@plt>
mov    %r14,%rdi
call   1060 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   10b0 <scanf@plt>
mov    0x10(%rsp),%ebx
mov    0x14(%rsp),%ebp
lea    0xe55(%rip),%rdi
call   1050 <system@plt>
cmp    %ebp,%ebx
jne    130e <matriz_mult+0x16e>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
call   1070 <crear_matriz@plt>
mov    %rax,%rbx
mov    0x14(%rsp),%edi
mov    0x8(%rsp),%esi
call   1070 <crear_matriz@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1070 <crear_matriz@plt>
mov    %rax,%r15
lea    0xe1b(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
call   1090 <lee_matriz@plt>
lea    0xe0e(%rip),%rdi
call   1030 <puts@plt>
mov    0x14(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
call   1090 <lee_matriz@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    0x10(%rsp),%r9d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   10c0 <mat_mult@plt>
lea    0xde5(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r15,%rdi
call   1080 <imprime_matriz@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
call   10a0 <destruye_matriz@plt>
mov    0x14(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
call   10a0 <destruye_matriz@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r15,%rdi
call   10a0 <destruye_matriz@plt>
lea    0xd75(%rip),%rdi
call   1050 <system@plt>
jmp    131f <matriz_mult+0x17f>
lea    0xdb0(%rip),%rdi
call   1030 <puts@plt>
call   1040 <matriz_mult@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Dame las filas de la primera matriz: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c"Dame las columnas de la primera matriz: \00"
@.str.3 = [38 x i8] c"Dame las filas de la segunda matriz: \00"
@.str.4 = [4 x i8] c"cls\00"
@.str.5 = [85 x i8] c"Error la columna de la primera matriz no es igual a la columna de la segunda matriz\0A\00"
@.str.6 = [16 x i8] c"Primera matriz\0A\00"
@.str.7 = [16 x i8] c"Segunda matriz\0A\00"
@.str.8 = [38 x i8] c"El resultado de la multiplicacion es\0A\00"
@.str.9 = [6 x i8] c"pause\00"
define void @matriz_mult() {
%1 = alloca double**
%2 = alloca double**
%3 = alloca double**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%10 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%14 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.5, i64 0, i64 0))
br label %68
22: ; preds = %0
%23 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call double** @crear_matriz(i32 %24, i32 %25)
store double** %26, double*** %1
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = call double** @crear_matriz(i32 %27, i32 %28)
store double** %29, double*** %2
%30 = load i32, i32* %4
%31 = load i32, i32* %7
%32 = call double** @crear_matriz(i32 %30, i32 %31)
store double** %32, double*** %3
%33 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%34 = load double**, double*** %1
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = call i32 @lee_matriz(double** %34, i32 %35, i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%39 = load double**, double*** %2
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 @lee_matriz(double** %39, i32 %40, i32 %41)
%43 = load double**, double*** %1
%44 = load double**, double*** %2
%45 = load double**, double*** %3
%46 = load i32, i32* %4
%47 = load i32, i32* %7
%48 = load i32, i32* %5
%49 = call i32 @mat_mult(double** %43, double** %44, double** %45, i32 %46, i32 %47, i32 %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
%51 = load double**, double*** %3
%52 = load i32, i32* %4
%53 = load i32, i32* %7
%54 = call i32 @imprime_matriz(double** %51, i32 %52, i32 %53)
%55 = load double**, double*** %1
%56 = load i32, i32* %4
%57 = load i32, i32* %5
%58 = call i32 @destruye_matriz(double** %55, i32 %56, i32 %57)
%59 = load double**, double*** %2
%60 = load i32, i32* %6
%61 = load i32, i32* %7
%62 = call i32 @destruye_matriz(double** %59, i32 %60, i32 %61)
%63 = load double**, double*** %3
%64 = load i32, i32* %4
%65 = load i32, i32* %7
%66 = call i32 @destruye_matriz(double** %63, i32 %64, i32 %65)
%67 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %68
68: ; preds = %22, %19
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Dame las filas de la primera matriz: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c"Dame las columnas de la primera matriz: \00"
@.str.3 = [38 x i8] c"Dame las filas de la segunda matriz: \00"
@.str.4 = [4 x i8] c"cls\00"
@.str.9 = [6 x i8] c"pause\00"
@str = [15 x i8] c"Primera matriz\00"
@str.10 = [15 x i8] c"Segunda matriz\00"
@str.11 = [37 x i8] c"El resultado de la multiplicacion es\00"
@str.12 = [84 x i8] c"Error la columna de la primera matriz no es igual a la columna de la segunda matriz\00"
define void @matriz_mult() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp eq i32 %17, %18
%20 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br i1 %19, label %23, label %21
21: ; preds = %0
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @str.12, i64 0, i64 0))
br label %59
23: ; preds = %0
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = call double** @crear_matriz(i32 %24, i32 %25)
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call double** @crear_matriz(i32 %27, i32 %28)
%30 = load i32, i32* %1
%31 = load i32, i32* %4
%32 = call double** @crear_matriz(i32 %30, i32 %31)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%34 = load i32, i32* %1
%35 = load i32, i32* %2
%36 = call i32 @lee_matriz(double** %26, i32 %34, i32 %35)
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.10, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = call i32 @lee_matriz(double** %29, i32 %38, i32 %39)
%41 = load i32, i32* %1
%42 = load i32, i32* %4
%43 = load i32, i32* %2
%44 = call i32 @mat_mult(double** %26, double** %29, double** %32, i32 %41, i32 %42, i32 %43)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.11, i64 0, i64 0))
%46 = load i32, i32* %1
%47 = load i32, i32* %4
%48 = call i32 @imprime_matriz(double** %32, i32 %46, i32 %47)
%49 = load i32, i32* %1
%50 = load i32, i32* %2
%51 = call i32 @destruye_matriz(double** %26, i32 %49, i32 %50)
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = call i32 @destruye_matriz(double** %29, i32 %52, i32 %53)
%55 = load i32, i32* %1
%56 = load i32, i32* %4
%57 = call i32 @destruye_matriz(double** %32, i32 %55, i32 %56)
%58 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %59
59: ; preds = %23, %21
ret void
}