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


x86 assembly (clang, -O0):
<randMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c7 <randMatrix+0x97>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b4 <randMatrix+0x84>
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1173 <randMatrix+0x43>
jmp    11b9 <randMatrix+0x89>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <randMatrix+0x30>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,0x4(%rsp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r14d,%r14d
jle    11a6 <randMatrix+0x76>
mov    0x4(%rsp),%ebp
mov    %r14d,%r14d
lea    0x0(,%rbp,4),%r12
xor    %r13d,%r13d
jmp    117c <randMatrix+0x4c>
nopl   0x0(%rax)
add    $0x1,%r13
add    %r12,%rbx
cmp    %r14,%r13
je     11a6 <randMatrix+0x76>
cmpl   $0x0,0x4(%rsp)
jle    1170 <randMatrix+0x40>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,(%rbx,%r15,4)
add    $0x1,%r15
cmp    %r15,%rbp
jne    1190 <randMatrix+0x60>
jmp    1170 <randMatrix+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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