#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 rand();
void genMatrix(int A[][20]) {
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 20; j++) {
      A[i][j] = rand() % 101;
    }
  }
}


x86 assembly (clang, -O0):
<genMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    1184 <genMatrix+0x74>
movl   $0x0,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    1171 <genMatrix+0x61>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x65,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <genMatrix+0x24>
jmp    1176 <genMatrix+0x66>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <genMatrix+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genMatrix>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x288df0cb,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x65,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    $0x14,%rbx
jne    1130 <genMatrix+0x20>
add    $0x1,%r14
add    $0x50,%r15
cmp    $0x14,%r14
jne    1120 <genMatrix+0x10>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @genMatrix([20 x i32]* %0) {
%2 = alloca [20 x i32]*
%3 = alloca i32
%4 = alloca i32
store [20 x i32]* %0, [20 x i32]** %2
store i32 0, i32* %3
br label %5
5: ; preds = %26, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %29
8: ; preds = %5
store i32 0, i32* %4
br label %9
9: ; preds = %22, %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 20
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 101
%15 = load [20 x i32]*, [20 x i32]** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 %17
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [20 x i32], [20 x i32]* %18, i64 0, i64 %20
store i32 %14, i32* %21
br label %22
22: ; preds = %12
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %9
25: ; preds = %9
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %5
29: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @genMatrix([20 x i32]* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %5
%3 = phi i64 [ 0, %1 ], [ %6, %5 ]
br label %8
4: ; preds = %5
ret void
5: ; preds = %8
%6 = add nuw nsw i64 %3, 1
%7 = icmp eq i64 %6, 20
br i1 %7, label %4, label %2
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %13, %8 ]
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 101
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %0, i64 %3, i64 %9
store i32 %11, i32* %12
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, 20
br i1 %14, label %5, label %8
}