#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void init_map(int w, int h, bool map[w][h]) {
  int c, r;
  srand(time(NULL));
  for (r = 0; r < h; r++) {
    for (c = 0; c < w; c++) {
      if (rand() % 10 > 2) {
        map[c][r] = true;
        printf(". ");
      } else {
        map[c][r] = false;
        printf("X ");
      }
    }
    printf("\n");
  }
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<init_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1235 <init_map+0xf5>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121b <init_map+0xdb>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jle    11da <init_map+0x9a>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    1208 <init_map+0xc8>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
lea    0xe00(%rip),%rdi
call   1030 <printf@plt>
jmp    120d <init_map+0xcd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1183 <init_map+0x43>
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <init_map+0x30>
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %esi,%ebx
mov    %edi,0x4(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
test   %ebx,%ebx
jle    122f <init_map+0xdf>
mov    %ebx,%eax
mov    0x4(%rsp),%ecx
mov    %rcx,0x8(%rsp)
mov    %rax,0x10(%rsp)
lea    0x0(,%rax,4),%rbp
lea    0xe64(%rip),%rbx
xor    %r15d,%r15d
jmp    11c9 <init_map+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
add    $0x4,%r14
cmp    0x10(%rsp),%r15
je     122f <init_map+0xdf>
cmpl   $0x0,0x4(%rsp)
jle    11b0 <init_map+0x60>
mov    0x8(%rsp),%r12
mov    %r14,%r13
jmp    11f4 <init_map+0xa4>
nopw   0x0(%rax,%rax,1)
mov    %cl,%al
mov    %eax,0x0(%r13)
call   1040 <printf@plt>
add    %rbp,%r13
add    $0xffffffffffffffff,%r12
je     11b0 <init_map+0x60>
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
xor    %eax,%eax
mov    %rbx,%rdi
cmp    $0x3,%ecx
setge  %cl
jge    11e0 <init_map+0x90>
lea    0xdd6(%rip),%rdi
jmp    11e0 <init_map+0x90>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c". \00"
@.str.1 = [3 x i8] c"X \00"
define void @init_map(i32 %0, i32 %1, i32* nocapture writeonly %2) {
%4 = zext i32 %1 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 %31
8: ; preds = %3
%9 = icmp sgt i32 %0, 0
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %8, %27
%12 = phi i64 [ 0, %8 ], [ %29, %27 ]
br i1 %9, label %13, label %27
13: ; preds = %11
%14 = getelementptr inbounds i32, i32* %2, i64 %12
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ %25, %15 ], [ 0, %13 ]
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 10
%19 = icmp sgt i32 %18, 2
%20 = mul nuw nsw i64 %16, %4
%21 = zext i1 %19 to i32
%22 = select i1 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%23 = getelementptr inbounds i32, i32* %14, i64 %20
store i32 %21, i32* %23
%24 = tail call i32 @printf(i8* dereferenceable(1) %22)
%25 = add nuw nsw i64 %16, 1
%26 = icmp eq i64 %25, %10
br i1 %26, label %27, label %15
27: ; preds = %15, %11
%28 = tail call i32 @putchar(i32 10)
%29 = add nuw nsw i64 %12, 1
%30 = icmp eq i64 %29, %4
br i1 %30, label %31, label %11
31: ; preds = %27, %3
%32 = tail call i32 @putchar(i32 10)
ret void
}