#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 *, ...);
void sum_of_matrices(int ROW, int COL, int a[][COL], int b[][COL]) {
  int result[ROW][COL];
  int i;
  for (i = 0; i < ROW; i++) {
    printf("|");
    int k;
    for (k = 0; k < COL; k++) {
      result[i][k] = a[i][k] + b[i][k];
      printf("%3d", result[i][k]);
    }
    printf("|\n");
  }
}


x86 assembly (clang, -O0):
<sum_of_matrices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%esi
mov    %rsi,-0x58(%rbp)
mov    %rsi,%rax
mov    %rax,-0x50(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    %rsi,%rax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rdx
imul   %rsi,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1250 <sum_of_matrices+0x140>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1234 <sum_of_matrices+0x124>
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%rdi
mov    -0x10(%rbp),%rcx
movslq -0x34(%rbp),%rsi
imul   %rdi,%rsi
shl    $0x2,%rsi
add    %rsi,%rcx
movslq -0x38(%rbp),%rsi
mov    (%rcx,%rsi,4),%edi
mov    -0x18(%rbp),%rcx
movslq -0x34(%rbp),%rsi
imul   %r8,%rsi
shl    $0x2,%rsi
add    %rsi,%rcx
movslq -0x38(%rbp),%rsi
add    (%rcx,%rsi,4),%edi
movslq -0x34(%rbp),%rsi
imul   %rdx,%rsi
shl    $0x2,%rsi
mov    %rax,%rcx
add    %rsi,%rcx
movslq -0x38(%rbp),%rsi
mov    %edi,(%rcx,%rsi,4)
movslq -0x34(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1199 <sum_of_matrices+0x89>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1178 <sum_of_matrices+0x68>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum_of_matrices>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0x4(%rsp)
test   %edi,%edi
jle    11dd <sum_of_matrices+0xad>
mov    %rcx,%r14
mov    %rdx,%rbx
mov    0x4(%rsp),%ebp
mov    %edi,%eax
mov    %rax,0x10(%rsp)
lea    0x0(,%rbp,4),%rax
mov    %rax,0x8(%rsp)
lea    0xe91(%rip),%r13
xor    %r12d,%r12d
jmp    11a2 <sum_of_matrices+0x72>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r12
mov    0x8(%rsp),%rax
add    %rax,%r14
add    %rax,%rbx
cmp    0x10(%rsp),%r12
je     11dd <sum_of_matrices+0xad>
mov    $0x7c,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x4(%rsp)
jle    1180 <sum_of_matrices+0x50>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%r15,4),%esi
add    (%rbx,%r15,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    11c0 <sum_of_matrices+0x90>
jmp    1180 <sum_of_matrices+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"|\00"
@.str.1 = [4 x i8] c"%3d\00"
@.str.2 = [3 x i8] c"|\0A\00"
define void @sum_of_matrices(i32 %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%14 = load i32, i32* %6
%15 = zext i32 %14 to i64
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = load i32, i32* %5
%19 = zext i32 %18 to i64
%20 = load i32, i32* %6
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %9
%23 = mul nuw i64 %19, %21
%24 = alloca i32, i64 %23
store i64 %19, i64* %10
store i64 %21, i64* %11
store i32 0, i32* %12
br label %25
25: ; preds = %76, %4
%26 = load i32, i32* %12
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %79
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %13
br label %31
31: ; preds = %71, %29
%32 = load i32, i32* %13
%33 = load i32, i32* %6
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %74
35: ; preds = %31
%36 = load i32*, i32** %7
%37 = load i32, i32* %12
%38 = sext i32 %37 to i64
%39 = mul nsw i64 %38, %15
%40 = getelementptr inbounds i32, i32* %36, i64 %39
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = load i32*, i32** %8
%46 = load i32, i32* %12
%47 = sext i32 %46 to i64
%48 = mul nsw i64 %47, %17
%49 = getelementptr inbounds i32, i32* %45, i64 %48
%50 = load i32, i32* %13
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = add nsw i32 %44, %53
%55 = load i32, i32* %12
%56 = sext i32 %55 to i64
%57 = mul nsw i64 %56, %21
%58 = getelementptr inbounds i32, i32* %24, i64 %57
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
store i32 %54, i32* %61
%62 = load i32, i32* %12
%63 = sext i32 %62 to i64
%64 = mul nsw i64 %63, %21
%65 = getelementptr inbounds i32, i32* %24, i64 %64
%66 = load i32, i32* %13
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %35
%72 = load i32, i32* %13
%73 = add nsw i32 %72, 1
store i32 %73, i32* %13
br label %31
74: ; preds = %31
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %76
76: ; preds = %74
%77 = load i32, i32* %12
%78 = add nsw i32 %77, 1
store i32 %78, i32* %12
br label %25
79: ; preds = %25
%80 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%3d\00"
@str = [2 x i8] c"|\00"
define void @sum_of_matrices(i32 %0, i32 %1, i32* nocapture %2, i32* nocapture %3) {
%5 = zext i32 %1 to i64
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %31
7: ; preds = %4
%8 = icmp sgt i32 %1, 0
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %7, %27
%11 = phi i64 [ 0, %7 ], [ %29, %27 ]
%12 = tail call i32 @putchar(i32 124)
br i1 %8, label %13, label %27
13: ; preds = %10
%14 = mul nuw nsw i64 %11, %5
%15 = getelementptr inbounds i32, i32* %2, i64 %14
%16 = getelementptr inbounds i32, i32* %3, i64 %14
br label %17
17: ; preds = %13, %17
%18 = phi i64 [ 0, %13 ], [ %25, %17 ]
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
%21 = getelementptr inbounds i32, i32* %16, i64 %18
%22 = load i32, i32* %21
%23 = add nsw i32 %22, %20
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %5
br i1 %26, label %27, label %17
27: ; preds = %17, %10
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%29 = add nuw nsw i64 %11, 1
%30 = icmp eq i64 %29, %9
br i1 %30, label %31, label %10
31: ; preds = %27, %4
ret void
}