#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 */
int /*<<< orphan*/ display_matrix(int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ multiply_matrix_2(int *, int *, int *, int);
int /*<<< orphan*/ read_matrix(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int N;
  scanf("%d", &N);
  int *matrix_a = (int *)malloc(N * N * sizeof(int));
  int *matrix_b = (int *)malloc(N * N * sizeof(int));
  int *matrix_c = (int *)malloc(N * N * sizeof(int));
  read_matrix(matrix_a, N);
  read_matrix(matrix_b, N);
  multiply_matrix_2(matrix_a, matrix_b, matrix_c, N);
  display_matrix(matrix_c, N);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
imul   -0x4(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x4(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x4(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <read_matrix@plt>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <read_matrix@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x4(%rbp),%ecx
call   1070 <multiply_matrix_2@plt>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <display_matrix@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
imul   %edi,%edi
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
imul   %edi,%edi
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    0xc(%rsp),%edi
imul   %edi,%edi
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   1050 <read_matrix@plt>
mov    0xc(%rsp),%esi
mov    %r15,%rdi
call   1050 <read_matrix@plt>
mov    0xc(%rsp),%ecx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <multiply_matrix_2@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <display_matrix@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = load i32, i32* %1
%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 i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %2
%14 = load i32, i32* %1
%15 = load i32, i32* %1
%16 = mul nsw i32 %14, %15
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i32*
store i32* %21, i32** %3
%22 = load i32, i32* %1
%23 = load i32, i32* %1
%24 = mul nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 4
%27 = trunc i64 %26 to i32
%28 = call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i32*
store i32* %29, i32** %4
%30 = load i32*, i32** %2
%31 = load i32, i32* %1
%32 = call i32 @read_matrix(i32* %30, i32 %31)
%33 = load i32*, i32** %3
%34 = load i32, i32* %1
%35 = call i32 @read_matrix(i32* %33, i32 %34)
%36 = load i32*, i32** %2
%37 = load i32*, i32** %3
%38 = load i32*, i32** %4
%39 = load i32, i32* %1
%40 = call i32 @multiply_matrix_2(i32* %36, i32* %37, i32* %38, i32 %39)
%41 = load i32*, i32** %4
%42 = load i32, i32* %1
%43 = call i32 @display_matrix(i32* %41, i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = shl i32 %4, 2
%6 = mul i32 %5, %4
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = load i32, i32* %1
%10 = shl i32 %9, 2
%11 = mul i32 %10, %9
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
%14 = load i32, i32* %1
%15 = shl i32 %14, 2
%16 = mul i32 %15, %14
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i32*
%19 = load i32, i32* %1
%20 = call i32 @read_matrix(i32* %8, i32 %19)
%21 = load i32, i32* %1
%22 = call i32 @read_matrix(i32* %13, i32 %21)
%23 = load i32, i32* %1
%24 = call i32 @multiply_matrix_2(i32* %8, i32* %13, i32* %18, i32 %23)
%25 = load i32, i32* %1
%26 = call i32 @display_matrix(i32* %18, i32 %25)
ret i32 0
}