#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*/ res_path;

/* 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_result(int **res, int matrix_size) {
  *res = xmalloc_aligned(matrix_size * matrix_size * sizeof(int), 4096);
  char res_path[32];
  snprintf(res_path, sizeof(res_path), "matrixmul_compare_%06d.dat",
           matrix_size);
  assert(read_matrix(*res, res_path, matrix_size));
}


x86 assembly (clang, -O0):
<read_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
imul   -0xc(%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)
lea    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%ecx
mov    $0x20,%esi
lea    0xe7b(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <read_matrix@plt>
mov    %eax,%edi
call   1040 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [27 x i8] c"matrixmul_compare_%06d.dat\00"
define void @read_result(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
%5 = alloca [32 x i8]
store i32** %0, i32*** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = load i32, i32* %4
%8 = mul nsw i32 %6, %7
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 4
%11 = trunc i64 %10 to i32
%12 = call i32* @xmalloc_aligned(i32 %11, i32 4096)
%13 = load i32**, i32*** %3
store i32* %12, i32** %13
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%15 = load i32, i32* %4
%16 = call i32 @snprintf(i8* %14, i32 32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32**, i32*** %3
%18 = load i32*, i32** %17
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%20 = load i32, i32* %4
%21 = call i32 @read_matrix(i32* %18, i8* %19, i32 %20)
%22 = call i32 @assert(i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"matrixmul_compare_%06d.dat\00"
define void @read_result(i32** nocapture %0, i32 %1) {
%3 = alloca [32 x i8]
%4 = shl i32 %1, 2
%5 = mul i32 %4, %1
%6 = tail call i32* @xmalloc_aligned(i32 %5, i32 4096)
store i32* %6, i32** %0
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %1)
%9 = load i32*, i32** %0
%10 = call i32 @read_matrix(i32* %9, i8* %7, i32 %1)
%11 = call i32 @assert(i32 %10)
ret void
}