#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 randomize(int **map, int width, int height) {
  srand(time(NULL));
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      map[y][x] = rand() % 2;
    }
  }
}


x86 assembly (clang, -O0):
<randomize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%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    -0x10(%rbp),%eax
jge    11bb <randomize+0x8b>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <randomize+0x78>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <randomize+0x3c>
jmp    11ad <randomize+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <randomize+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r14d,%r14d
jle    11a5 <randomize+0x75>
mov    %r14d,%r14d
mov    %r15d,%r13d
xor    %ebx,%ebx
jmp    1179 <randomize+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r14,%rbx
je     11a5 <randomize+0x75>
test   %r15d,%r15d
jle    1170 <randomize+0x40>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    (%r12,%rbx,8),%rcx
mov    %eax,(%rcx,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1180 <randomize+0x50>
jmp    1170 <randomize+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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