#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ alloc_matrix(int, int, float ***);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free_matrix(int, float **);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ mult_matrix(int, int, int, float **, float **, float **);
int /*<<< orphan*/ read_matrix(int /*<<< orphan*/ *, int, int, float **);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int M, K, N;
  float **A = NULL, **B = NULL, **C = NULL;
  FILE *fp;
  if (argc != 2) {
    fprintf(stderr, "Usage: mm <input>\n");
    return EXIT_FAILURE;
  }
  fp = fopen(argv[1], "r");
  fscanf(fp, "%d", &M);
  fscanf(fp, "%d", &K);
  fscanf(fp, "%d", &N);
  alloc_matrix(M, K, &A);
  alloc_matrix(K, N, &B);
  alloc_matrix(M, N, &C);
  read_matrix(fp, M, K, A);
  read_matrix(fp, K, N, B);
  fclose(fp);
  mult_matrix(M, K, N, A, B, C);
  free_matrix(M, A);
  free_matrix(K, B);
  free_matrix(M, C);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11de <main+0x5e>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d8 <main+0x158>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe26(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe14(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1070 <fscanf@plt>
mov    -0x40(%rbp),%rdi
lea    0xe00(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <fscanf@plt>
mov    -0x40(%rbp),%rdi
lea    0xdec(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <fscanf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x28(%rbp),%rdx
call   1050 <alloc_matrix@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1050 <alloc_matrix@plt>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
lea    -0x38(%rbp),%rdx
call   1050 <alloc_matrix@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1090 <read_matrix@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x30(%rbp),%rcx
call   1090 <read_matrix@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
call   1060 <mult_matrix@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1030 <free_matrix@plt>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1030 <free_matrix@plt>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   1030 <free_matrix@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
cmp    $0x2,%edi
jne    12b0 <main+0x130>
mov    0x8(%rsi),%rdi
lea    0xe5d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0xe50(%rip),%r14
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <fscanf@plt>
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <fscanf@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <fscanf@plt>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
lea    0x18(%rsp),%rdx
call   1050 <alloc_matrix@plt>
mov    0x4(%rsp),%edi
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdx
call   1050 <alloc_matrix@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
lea    0x20(%rsp),%rdx
call   1050 <alloc_matrix@plt>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x18(%rsp),%rcx
mov    %rbx,%rdi
call   1090 <read_matrix@plt>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%rcx
mov    %rbx,%rdi
call   1090 <read_matrix@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    0x20(%rsp),%r9
call   1060 <mult_matrix@plt>
mov    0x8(%rsp),%edi
mov    0x18(%rsp),%rsi
call   1030 <free_matrix@plt>
mov    0x4(%rsp),%edi
mov    0x10(%rsp),%rsi
call   1030 <free_matrix@plt>
mov    0x8(%rsp),%edi
mov    0x20(%rsp),%rsi
call   1030 <free_matrix@plt>
mov    0x2d22(%rip),%rax
jmp    12cc <main+0x14c>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
lea    0xd40(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d0c(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: mm <input>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float**
%10 = alloca float**
%11 = alloca float**
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float** null, float*** %9
store float** null, float*** %10
store float** null, float*** %11
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %68
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %12
%24 = load i32*, i32** %12
%25 = call i32 @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%26 = load i32*, i32** %12
%27 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%28 = load i32*, i32** %12
%29 = call i32 @fscanf(i32* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = call i32 @alloc_matrix(i32 %30, i32 %31, float*** %9)
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = call i32 @alloc_matrix(i32 %33, i32 %34, float*** %10)
%36 = load i32, i32* %6
%37 = load i32, i32* %8
%38 = call i32 @alloc_matrix(i32 %36, i32 %37, float*** %11)
%39 = load i32*, i32** %12
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = load float**, float*** %9
%43 = call i32 @read_matrix(i32* %39, i32 %40, i32 %41, float** %42)
%44 = load i32*, i32** %12
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = load float**, float*** %10
%48 = call i32 @read_matrix(i32* %44, i32 %45, i32 %46, float** %47)
%49 = load i32*, i32** %12
%50 = call i32 @fclose(i32* %49)
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = load i32, i32* %8
%54 = load float**, float*** %9
%55 = load float**, float*** %10
%56 = load float**, float*** %11
%57 = call i32 @mult_matrix(i32 %51, i32 %52, i32 %53, float** %54, float** %55, float** %56)
%58 = load i32, i32* %6
%59 = load float**, float*** %9
%60 = call i32 @free_matrix(i32 %58, float** %59)
%61 = load i32, i32* %7
%62 = load float**, float*** %10
%63 = call i32 @free_matrix(i32 %61, float** %62)
%64 = load i32, i32* %6
%65 = load float**, float*** %11
%66 = call i32 @free_matrix(i32 %64, float** %65)
%67 = load i32, i32* @EXIT_SUCCESS
store i32 %67, i32* %3
br label %68
68: ; preds = %19, %15
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: mm <input>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float**
%7 = alloca float**
%8 = alloca float**
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast float*** %6 to i8*
store float** null, float*** %6
%13 = bitcast float*** %7 to i8*
store float** null, float*** %7
%14 = bitcast float*** %8 to i8*
store float** null, float*** %8
%15 = icmp eq i32 %0, 2
br i1 %15, label %19, label %16
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %60
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%24 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%25 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = call i32 @alloc_matrix(i32 %26, i32 %27, float*** %6)
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = call i32 @alloc_matrix(i32 %29, i32 %30, float*** %7)
%32 = load i32, i32* %3
%33 = load i32, i32* %5
%34 = call i32 @alloc_matrix(i32 %32, i32 %33, float*** %8)
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = load float**, float*** %6
%38 = call i32 @read_matrix(i32* %22, i32 %35, i32 %36, float** %37)
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = load float**, float*** %7
%42 = call i32 @read_matrix(i32* %22, i32 %39, i32 %40, float** %41)
%43 = call i32 @fclose(i32* %22)
%44 = load i32, i32* %3
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = load float**, float*** %6
%48 = load float**, float*** %7
%49 = load float**, float*** %8
%50 = call i32 @mult_matrix(i32 %44, i32 %45, i32 %46, float** %47, float** %48, float** %49)
%51 = load i32, i32* %3
%52 = load float**, float*** %6
%53 = call i32 @free_matrix(i32 %51, float** %52)
%54 = load i32, i32* %4
%55 = load float**, float*** %7
%56 = call i32 @free_matrix(i32 %54, float** %55)
%57 = load i32, i32* %3
%58 = load float**, float*** %8
%59 = call i32 @free_matrix(i32 %57, float** %58)
br label %60
60: ; preds = %19, %16
%61 = phi i32* [ @EXIT_FAILURE, %16 ], [ @EXIT_SUCCESS, %19 ]
%62 = load i32, i32* %61
ret i32 %62
}