#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_add(int **, int **, int **);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int main(void) {
  int i, j;
  int ma[2][3] = {{1, 2, 3}, {4, 5, 6}};
  int mb[2][3] = {{6, 3, 4}, {5, 1, 2}};
  int mc[2][3] = {0};
  mat_add(ma, mb, mc);
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 3; j++)
      printf("%3d", mc[i][j]);
    putchar('\n');
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea9(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea6(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1060 <mat_add@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    121c <main+0xdc>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1204 <main+0xc4>
movslq -0x8(%rbp),%rcx
lea    -0x70(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ca <main+0x8a>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b9 <main+0x79>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
mov    0xed4(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    0xedc(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x40(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <mat_add@plt>
mov    (%rsp),%esi
lea    0xea7(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.ma = [2 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6]]
@__const.main.mb = [2 x [3 x i32]] [[3 x i32] [i32 6, i32 3, i32 4], [3 x i32] [i32 5, i32 1, i32 2]]
@.str = [4 x i8] c"%3d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x [3 x i32]]
%5 = alloca [2 x [3 x i32]]
%6 = alloca [2 x [3 x i32]]
store i32 0, i32* %1
%7 = bitcast [2 x [3 x i32]]* %4 to i8*
%8 = bitcast [2 x [3 x i32]]* %5 to i8*
%9 = bitcast [2 x [3 x i32]]* %6 to i8*
%10 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %4, i64 0, i64 0
%11 = bitcast [3 x i32]* %10 to i32**
%12 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %5, i64 0, i64 0
%13 = bitcast [3 x i32]* %12 to i32**
%14 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %6, i64 0, i64 0
%15 = bitcast [3 x i32]* %14 to i32**
%16 = call i32 @mat_add(i32** %11, i32** %13, i32** %15)
store i32 0, i32* %2
br label %17
17: ; preds = %38, %0
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %41
20: ; preds = %17
store i32 0, i32* %3
br label %21
21: ; preds = %33, %20
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %6, i64 0, i64 %26
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [3 x i32], [3 x i32]* %27, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %24
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %21
36: ; preds = %21
%37 = call i32 @putchar(i8 signext 10)
br label %38
38: ; preds = %36
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %17
41: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@__const.main.ma = [2 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6]]
@__const.main.mb = [2 x [3 x i32]] [[3 x i32] [i32 6, i32 3, i32 4], [3 x i32] [i32 5, i32 1, i32 2]]
@.str = [4 x i8] c"%3d\00"
define i32 @main() {
%1 = alloca [2 x [3 x i32]]
%2 = alloca [2 x [3 x i32]]
%3 = alloca [2 x [3 x i32]]
%4 = bitcast [2 x [3 x i32]]* %1 to i8*
%5 = bitcast [2 x [3 x i32]]* %2 to i8*
%6 = bitcast [2 x [3 x i32]]* %3 to i8*
%7 = bitcast [2 x [3 x i32]]* %1 to i32**
%8 = bitcast [2 x [3 x i32]]* %2 to i32**
%9 = bitcast [2 x [3 x i32]]* %3 to i32**
%10 = call i32 @mat_add(i32** %7, i32** %8, i32** %9)
%11 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %3, i64 0, i64 0, i64 0
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %3, i64 0, i64 0, i64 1
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %3, i64 0, i64 0, i64 2
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 @putchar(i8 signext 10)
%21 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %3, i64 0, i64 1, i64 0
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %3, i64 0, i64 1, i64 1
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [2 x [3 x i32]], [2 x [3 x i32]]* %3, i64 0, i64 1, i64 2
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = call i32 @putchar(i8 signext 10)
ret i32 0
}