#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*/ printf(char *, int);
int main() {
  int i, j;
  int a[2][2] = {{1, 2}, {3, 4}};
  int b[2][2] = {{1, 1}, {1, 1}};
  int r[2][2] = {};
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      r[i][j] = a[i][j] + b[i][j];
      printf("add=[%d]\n", r[i][j]);
    }
  }
}


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    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jge    1212 <main+0xf2>
movl   $0x0,-0x48(%rbp)
cmpl   $0x2,-0x48(%rbp)
jge    11ff <main+0xdf>
movslq -0x44(%rbp),%rcx
lea    -0x20(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
movslq -0x44(%rbp),%rcx
lea    -0x30(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x48(%rbp),%rcx
add    (%rax,%rcx,4),%edx
movslq -0x44(%rbp),%rcx
lea    -0x40(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x48(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x44(%rbp),%rcx
lea    -0x40(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1183 <main+0x63>
jmp    1204 <main+0xe4>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1172 <main+0x52>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"add=[%d]\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 2)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 3)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 4)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 5)
ret i32 0
}