#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*/ mat_mul(int **, int **, int **);
int /*<<< orphan*/ print_arr(int *, int);
int /*<<< orphan*/ putchar(char);
int main(void) {
  int x[4][3] = {
      {1, 2, 3},
      {1, 2, 3},
      {1, 2, 3},
      {1, 2, 3},
  };
  int y[3][4] = {
      {1, 2, 3, 4},
      {1, 2, 3, 4},
      {1, 2, 3, 4},
  };
  int z[3][3];
  mat_mul(x, y, z);
  for (int i = 0; i < 3; i++) {
    print_arr(z[i], 3);
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    -0x70(%rbp),%rdi
lea    0xebe(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
call   1060 <mat_mul@plt>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x3,-0xa4(%rbp)
jge    11e4 <main+0xa4>
movslq -0xa4(%rbp),%rax
lea    -0xa0(%rbp),%rdi
imul   $0xc,%rax,%rax
add    %rax,%rdi
mov    $0x3,%esi
call   1040 <print_arr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    119a <main+0x5a>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x90,%rsp
movaps 0xee1(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeea(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x60(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdx
call   1050 <mat_mul@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <print_arr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc(%rsp),%rdi
mov    $0x3,%esi
call   1040 <print_arr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x18(%rsp),%rdi
mov    $0x3,%esi
call   1040 <print_arr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.x = [4 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 1, i32 2, i32 3]]
@__const.main.y = [3 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 1, i32 2, i32 3, i32 4]]
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [3 x i32]]
%3 = alloca [3 x [4 x i32]]
%4 = alloca [3 x [3 x i32]]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [4 x [3 x i32]]* %2 to i8*
%7 = bitcast [3 x [4 x i32]]* %3 to i8*
%8 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %2, i64 0, i64 0
%9 = bitcast [3 x i32]* %8 to i32**
%10 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %3, i64 0, i64 0
%11 = bitcast [4 x i32]* %10 to i32**
%12 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 0
%13 = bitcast [3 x i32]* %12 to i32**
%14 = call i32 @mat_mul(i32** %9, i32** %11, i32** %13)
store i32 0, i32* %5
br label %15
15: ; preds = %25, %0
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %20
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %21, i64 0, i64 0
%23 = call i32 @print_arr(i32* %22, i32 3)
%24 = call i32 @putchar(i8 signext 10)
br label %25
25: ; preds = %18
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %15
28: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@__const.main.x = [4 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 1, i32 2, i32 3]]
@__const.main.y = [3 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 1, i32 2, i32 3, i32 4]]
define i32 @main() {
%1 = alloca [4 x [3 x i32]]
%2 = alloca [3 x [4 x i32]]
%3 = alloca [3 x [3 x i32]]
%4 = bitcast [4 x [3 x i32]]* %1 to i8*
%5 = bitcast [3 x [4 x i32]]* %2 to i8*
%6 = bitcast [3 x [3 x i32]]* %3 to i8*
%7 = bitcast [4 x [3 x i32]]* %1 to i32**
%8 = bitcast [3 x [4 x i32]]* %2 to i32**
%9 = bitcast [3 x [3 x i32]]* %3 to i32**
%10 = call i32 @mat_mul(i32** %7, i32** %8, i32** %9)
%11 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %3, i64 0, i64 0, i64 0
%12 = call i32 @print_arr(i32* %11, i32 3)
%13 = call i32 @putchar(i8 signext 10)
%14 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %3, i64 0, i64 1, i64 0
%15 = call i32 @print_arr(i32* %14, i32 3)
%16 = call i32 @putchar(i8 signext 10)
%17 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %3, i64 0, i64 2, i64 0
%18 = call i32 @print_arr(i32* %17, i32 3)
%19 = call i32 @putchar(i8 signext 10)
ret i32 0
}