#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 random_map(int map[23 + 2][80 + 2], int input) {
  int how_many, rand_row, rand_col;
  int flag_map[23 + 2][80 + 2] = {0};
  how_many = 23 * 80 * input / 100;
  srand(time(NULL));
  while (how_many != 0) {
    rand_row = rand() % 23 + 1;
    rand_col = rand() % 80 + 1;
    if (flag_map[rand_row][rand_col] == 0) {
      flag_map[rand_row][rand_col] = 1;
      map[rand_row][rand_col] = 1;
      how_many--;
    }
  }
}


x86 assembly (clang, -O0):
<random_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x2020(%rbp),%rdi
xor    %esi,%esi
mov    $0x2008,%edx
call   1030 <memset@plt>
imul   $0x730,-0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmpl   $0x0,-0x10(%rbp)
je     1229 <random_map+0xe9>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x17,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x50,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq -0x14(%rbp),%rcx
lea    -0x2020(%rbp),%rax
imul   $0x148,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1224 <random_map+0xe4>
movslq -0x14(%rbp),%rcx
lea    -0x2020(%rbp),%rax
imul   $0x148,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x148,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1187 <random_map+0x47>
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_map>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2010,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x2008,%edx
xor    %esi,%esi
call   1030 <memset@plt>
imul   $0x730,%ebp,%ebp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0x63(%rbp),%eax
cmp    $0xc7,%eax
jae    1189 <random_map+0x49>
add    $0x2010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
movslq %ebp,%rax
imul   $0x51eb851f,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
sar    $0x25,%rbp
add    %eax,%ebp
jmp    11b4 <random_map+0x74>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %ebp,%ebp
je     117d <random_map+0x3d>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0xffffffffb21642c9,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
shl    $0x3,%edx
sub    %edx,%ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
shl    $0x4,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cltq
movslq %ebx,%rcx
imul   $0x148,%rcx,%rcx
lea    (%rsp,%rcx,1),%rdx
cmpl   $0x0,0x4(%rdx,%rax,4)
jne    11b0 <random_map+0x70>
lea    (%rdx,%rax,4),%rdx
add    $0x4,%rdx
add    $0x1,%rax
movl   $0x1,(%rdx)
add    %r14,%rcx
movl   $0x1,(%rcx,%rax,4)
add    $0xffffffff,%ebp
jmp    11b0 <random_map+0x70>

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

LLVM IR (-O2):
define void @random_map([82 x i32]* nocapture writeonly %0, i32 %1) {
%3 = alloca [25 x [82 x i32]]
%4 = bitcast [25 x [82 x i32]]* %3 to i8*
%5 = mul nsw i32 %1, 1840
%6 = tail call i32 @time(i32* null)
%7 = tail call i32 @srand(i32 %6)
%8 = add i32 %5, 99
%9 = icmp ult i32 %8, 199
br i1 %9, label %31, label %10
10: ; preds = %2
%11 = sdiv i32 %5, 100
br label %12
12: ; preds = %10, %28
%13 = phi i32 [ %29, %28 ], [ %11, %10 ]
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 23
%16 = add nsw i32 %15, 1
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 80
%19 = add nsw i32 %18, 1
%20 = sext i32 %16 to i64
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds [25 x [82 x i32]], [25 x [82 x i32]]* %3, i64 0, i64 %20, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %12
store i32 1, i32* %22
%26 = getelementptr inbounds [82 x i32], [82 x i32]* %0, i64 %20, i64 %21
store i32 1, i32* %26
%27 = add nsw i32 %13, -1
br label %28
28: ; preds = %25, %12
%29 = phi i32 [ %27, %25 ], [ %13, %12 ]
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %12
31: ; preds = %28, %2
ret void
}