#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();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void initMatrix(int M, int N, int A[N][M], int B[M][N]) {
  int i, j;
  srand(time(NULL));
  for (i = 0; i < N; i++) {
    for (j = 0; j < M; j++) {
      A[i][j] = rand();
      B[j][i] = rand();
    }
  }
}


x86 assembly (clang, -O0):
<initMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f9 <initMatrix+0xc9>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e6 <initMatrix+0xb6>
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117e <initMatrix+0x4e>
jmp    11eb <initMatrix+0xbb>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116b <initMatrix+0x3b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x10(%rsp)
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,0xc(%rsp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r15d,%r15d
jle    11e3 <initMatrix+0xb3>
mov    0xc(%rsp),%r13d
mov    %r15d,%eax
mov    %rax,0x20(%rsp)
lea    0x0(,%rax,4),%rbp
lea    0x0(,%r13,4),%rax
mov    %rax,0x18(%rsp)
xor    %r15d,%r15d
jmp    11a6 <initMatrix+0x76>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
addq   $0x4,0x10(%rsp)
add    0x18(%rsp),%rbx
cmp    0x20(%rsp),%r15
je     11e3 <initMatrix+0xb3>
cmpl   $0x0,0xc(%rsp)
jle    1190 <initMatrix+0x60>
mov    0x10(%rsp),%r14
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,(%rbx,%r12,4)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,(%r14)
add    $0x1,%r12
add    %rbp,%r14
cmp    %r12,%r13
jne    11c0 <initMatrix+0x90>
jmp    1190 <initMatrix+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @initMatrix(i32 %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = zext i32 %0 to i64
%6 = zext i32 %1 to i64
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %30
10: ; preds = %4
%11 = icmp sgt i32 %0, 0
br label %12
12: ; preds = %10, %27
%13 = phi i64 [ 0, %10 ], [ %28, %27 ]
br i1 %11, label %14, label %27
14: ; preds = %12
%15 = mul nuw nsw i64 %13, %5
%16 = getelementptr inbounds i32, i32* %2, i64 %15
%17 = getelementptr inbounds i32, i32* %3, i64 %13
br label %18
18: ; preds = %14, %18
%19 = phi i64 [ 0, %14 ], [ %25, %18 ]
%20 = tail call i32 (...) @rand()
%21 = getelementptr inbounds i32, i32* %16, i64 %19
store i32 %20, i32* %21
%22 = tail call i32 (...) @rand()
%23 = mul nuw nsw i64 %19, %6
%24 = getelementptr inbounds i32, i32* %17, i64 %23
store i32 %22, i32* %24
%25 = add nuw nsw i64 %19, 1
%26 = icmp eq i64 %25, %5
br i1 %26, label %27, label %18
27: ; preds = %18, %12
%28 = add nuw nsw i64 %13, 1
%29 = icmp eq i64 %28, %6
br i1 %29, label %30, label %12
30: ; preds = %27, %4
ret void
}