#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*/ matrixadd(int *, int *, int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int firstmatrix[2][2] = {{1, 1}, {2, 2}};
  int secondmatrix[2][2] = {{3, 4}, {8, 9}};
  int destination[2][2];
  printf("\n");
  matrixadd(&firstmatrix[0][0], &secondmatrix[0][0], &destination[0][0], 2, 2);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      printf("%d   ", destination[i][j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x2,%r8d
mov    %r8d,%ecx
call   1040 <matrixadd@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jge    11f3 <main+0xd3>
movl   $0x0,-0x48(%rbp)
cmpl   $0x2,-0x48(%rbp)
jge    11d7 <main+0xb7>
movslq -0x44(%rbp),%rcx
lea    -0x40(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    119b <main+0x7b>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    118a <main+0x6a>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x20(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
mov    $0x2,%ecx
mov    $0x2,%r8d
call   1050 <matrixadd@plt>
mov    (%rsp),%esi
lea    0xea2(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

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

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