#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*/ out;
typedef int /*<<< orphan*/ in1;
typedef int /*<<< orphan*/ in0;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ read_matrix(int *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int *xmalloc_aligned(int, int);
void read_data(int *input_matrixes[2], int **output_matrix, int matrix_size) {
  input_matrixes[0] =
      xmalloc_aligned(matrix_size * matrix_size * sizeof(int), 4096);
  input_matrixes[1] =
      xmalloc_aligned(matrix_size * matrix_size * sizeof(int), 4096);
  *output_matrix =
      xmalloc_aligned(matrix_size * matrix_size * sizeof(int), 4096);
  char in0[32];
  char in1[32];
  char out[32];
  snprintf(in0, sizeof(in0), "matrixmul_in0_%06d.dat", matrix_size);
  snprintf(in1, sizeof(in1), "matrixmul_in1_%06d.dat", matrix_size);
  snprintf(out, sizeof(out), "matrixmul_out_%06d.dat", matrix_size);
  assert(read_matrix(input_matrixes[0], in0, matrix_size));
  assert(read_matrix(input_matrixes[1], in1, matrix_size));
  assert(read_matrix(*output_matrix, out, matrix_size));
}


x86 assembly (clang, -O0):
<read_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
mov    $0x1000,%esi
call   1050 <xmalloc_aligned@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
mov    $0x1000,%esi
call   1050 <xmalloc_aligned@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
mov    $0x1000,%esi
call   1050 <xmalloc_aligned@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x20,%esi
lea    0xe2d(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x20,%esi
lea    0xe2c(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x20,%esi
lea    0xe2b(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <read_matrix@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <read_matrix@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <read_matrix@plt>
mov    %eax,%edi
call   1040 <assert@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%ebp
imul   %edx,%ebp
shl    $0x2,%ebp
mov    %ebp,%edi
mov    $0x1000,%esi
call   1050 <xmalloc_aligned@plt>
mov    %rax,(%r15)
mov    %ebp,%edi
mov    $0x1000,%esi
call   1050 <xmalloc_aligned@plt>
mov    %rax,0x8(%r15)
mov    %ebp,%edi
mov    $0x1000,%esi
call   1050 <xmalloc_aligned@plt>
mov    %rax,(%r14)
lea    0xe6d(%rip),%rdx
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
mov    %ebx,%ecx
call   1030 <snprintf@plt>
lea    0xe69(%rip),%rdx
lea    0x20(%rsp),%r13
mov    %r13,%rdi
mov    $0x20,%esi
mov    %ebx,%ecx
call   1030 <snprintf@plt>
lea    0xe65(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x20,%esi
mov    %ebx,%ecx
call   1030 <snprintf@plt>
mov    (%r15),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1060 <read_matrix@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    0x8(%r15),%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1060 <read_matrix@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    (%r14),%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1060 <read_matrix@plt>
mov    %eax,%edi
call   1040 <assert@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"matrixmul_in0_%06d.dat\00"
@.str.1 = [23 x i8] c"matrixmul_in1_%06d.dat\00"
@.str.2 = [23 x i8] c"matrixmul_out_%06d.dat\00"
define void @read_data(i32** %0, i32** %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32**
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
store i32** %0, i32*** %4
store i32** %1, i32*** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = load i32, i32* %6
%12 = mul nsw i32 %10, %11
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i32* @xmalloc_aligned(i32 %15, i32 4096)
%17 = load i32**, i32*** %4
%18 = getelementptr inbounds i32*, i32** %17, i64 0
store i32* %16, i32** %18
%19 = load i32, i32* %6
%20 = load i32, i32* %6
%21 = mul nsw i32 %19, %20
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call i32* @xmalloc_aligned(i32 %24, i32 4096)
%26 = load i32**, i32*** %4
%27 = getelementptr inbounds i32*, i32** %26, i64 1
store i32* %25, i32** %27
%28 = load i32, i32* %6
%29 = load i32, i32* %6
%30 = mul nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 4
%33 = trunc i64 %32 to i32
%34 = call i32* @xmalloc_aligned(i32 %33, i32 4096)
%35 = load i32**, i32*** %5
store i32* %34, i32** %35
%36 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%37 = load i32, i32* %6
%38 = call i32 @snprintf(i8* %36, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%40 = load i32, i32* %6
%41 = call i32 @snprintf(i8* %39, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%43 = load i32, i32* %6
%44 = call i32 @snprintf(i8* %42, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = load i32**, i32*** %4
%46 = getelementptr inbounds i32*, i32** %45, i64 0
%47 = load i32*, i32** %46
%48 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%49 = load i32, i32* %6
%50 = call i32 @read_matrix(i32* %47, i8* %48, i32 %49)
%51 = call i32 @assert(i32 %50)
%52 = load i32**, i32*** %4
%53 = getelementptr inbounds i32*, i32** %52, i64 1
%54 = load i32*, i32** %53
%55 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%56 = load i32, i32* %6
%57 = call i32 @read_matrix(i32* %54, i8* %55, i32 %56)
%58 = call i32 @assert(i32 %57)
%59 = load i32**, i32*** %5
%60 = load i32*, i32** %59
%61 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%62 = load i32, i32* %6
%63 = call i32 @read_matrix(i32* %60, i8* %61, i32 %62)
%64 = call i32 @assert(i32 %63)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"matrixmul_in0_%06d.dat\00"
@.str.1 = [23 x i8] c"matrixmul_in1_%06d.dat\00"
@.str.2 = [23 x i8] c"matrixmul_out_%06d.dat\00"
define void @read_data(i32** nocapture %0, i32** nocapture %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = shl i32 %2, 2
%8 = mul i32 %7, %2
%9 = tail call i32* @xmalloc_aligned(i32 %8, i32 4096)
store i32* %9, i32** %0
%10 = tail call i32* @xmalloc_aligned(i32 %8, i32 4096)
%11 = getelementptr inbounds i32*, i32** %0, i64 1
store i32* %10, i32** %11
%12 = tail call i32* @xmalloc_aligned(i32 %8, i32 4096)
store i32* %12, i32** %1
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%16 = call i32 @snprintf(i8* %13, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %2)
%17 = call i32 @snprintf(i8* %14, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%18 = call i32 @snprintf(i8* %15, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%19 = load i32*, i32** %0
%20 = call i32 @read_matrix(i32* %19, i8* %13, i32 %2)
%21 = call i32 @assert(i32 %20)
%22 = load i32*, i32** %11
%23 = call i32 @read_matrix(i32* %22, i8* %14, i32 %2)
%24 = call i32 @assert(i32 %23)
%25 = load i32*, i32** %1
%26 = call i32 @read_matrix(i32* %25, i8* %15, i32 %2)
%27 = call i32 @assert(i32 %26)
ret void
}