#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, int);
int rand();
int main(void) {
  int matrix[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      matrix[i][j] = rand() % 10;
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      printf("matrix[%d][%d] = %d\n", i, j, matrix[i][j]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    1197 <main+0x77>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    1184 <main+0x64>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq -0x34(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1147 <main+0x27>
jmp    1189 <main+0x69>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1136 <main+0x16>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    1202 <main+0xe2>
movl   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x40(%rbp)
jge    11ef <main+0xcf>
mov    -0x3c(%rbp),%esi
mov    -0x40(%rbp),%edx
movslq -0x3c(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11af <main+0x8f>
jmp    11f4 <main+0xd4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119e <main+0x7e>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rcx,%rdx
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edx
mov    %rdx,0x20(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rcx,%rdx
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edx
mov    %rdx,0x18(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rcx,%rdx
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edx
mov    %rdx,0x10(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rcx,%rdx
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edx
mov    %rdx,0x8(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbp
imul   $0x66666667,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%r14
imul   $0x66666667,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r14d
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%r15
imul   $0x66666667,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r15d
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%r12
imul   $0x66666667,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r12d
lea    0xd5b(%rip),%r13
mov    %r13,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    0x20(%rsp),%rcx
call   1030 <printf@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rcx
call   1030 <printf@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x2,%edx
mov    0x10(%rsp),%rcx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    0x8(%rsp),%rcx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    $0x2,%esi
xor    %edx,%edx
mov    %r14d,%ecx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15d,%ecx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
mov    %r12d,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"matrix[%d][%d] = %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @rand()
%2 = srem i32 %1, 10
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 10
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 10
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 10
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 10
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 10
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 10
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 10
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 10
%19 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 %2)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0, i32 1, i32 %4)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0, i32 2, i32 %6)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1, i32 0, i32 %8)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1, i32 1, i32 %10)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1, i32 2, i32 %12)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 2, i32 0, i32 %14)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 2, i32 1, i32 %16)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 2, i32 2, i32 %18)
ret i32 0
}