#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();
void levelBrickGeneration(int number, int x, int y, int map[y][x]) {
  int randomX, randomY;
  for (int i = 0; i < number; i++) {
    do {
      randomX = rand() % 100;
      randomY = rand() % 50;
    } while (randomX == 0 || randomX == 99 || randomY == 0 || randomY == 49);
    map[randomY][randomX] = 3;
  }
}


x86 assembly (clang, -O0):
<levelBrickGeneration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11da <levelBrickGeneration+0xca>
jmp    1144 <levelBrickGeneration+0x34>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x31(%rbp)
je     119f <levelBrickGeneration+0x8f>
mov    $0x1,%al
cmpl   $0x63,-0x1c(%rbp)
mov    %al,-0x31(%rbp)
je     119f <levelBrickGeneration+0x8f>
mov    $0x1,%al
cmpl   $0x0,-0x20(%rbp)
mov    %al,-0x31(%rbp)
je     119f <levelBrickGeneration+0x8f>
cmpl   $0x31,-0x20(%rbp)
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1144 <levelBrickGeneration+0x34>
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movl   $0x3,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1133 <levelBrickGeneration+0x23>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<levelBrickGeneration>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11a3 <levelBrickGeneration+0x93>
mov    %rcx,%r14
mov    %edi,%r12d
mov    %esi,%r15d
xor    %r13d,%r13d
nop
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rbp
imul   $0x51eb851f,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rcx
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ebx,%ebp
je     1130 <levelBrickGeneration+0x20>
sub    %ecx,%eax
cmp    $0x63,%ebp
je     1130 <levelBrickGeneration+0x20>
test   %eax,%eax
je     1130 <levelBrickGeneration+0x20>
cmp    $0x31,%eax
je     1130 <levelBrickGeneration+0x20>
cltq
imul   %r15,%rax
lea    (%r14,%rax,4),%rax
movslq %ebp,%rcx
movl   $0x3,(%rax,%rcx,4)
add    $0x1,%r13d
cmp    %r12d,%r13d
jne    1130 <levelBrickGeneration+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @levelBrickGeneration(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
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%12 = load i32, i32* %7
%13 = zext i32 %12 to i64
%14 = load i32, i32* %6
%15 = zext i32 %14 to i64
store i32 0, i32* %11
br label %16
16: ; preds = %49, %4
%17 = load i32, i32* %11
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %52
20: ; preds = %16
br label %21
21: ; preds = %38, %20
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 100
store i32 %23, i32* %9
%24 = call i32 (...) @rand()
%25 = srem i32 %24, 50
store i32 %25, i32* %10
br label %26
26: ; preds = %21
%27 = load i32, i32* %9
%28 = icmp eq i32 %27, 0
br i1 %28, label %38, label %29
29: ; preds = %26
%30 = load i32, i32* %9
%31 = icmp eq i32 %30, 99
br i1 %31, label %38, label %32
32: ; preds = %29
%33 = load i32, i32* %10
%34 = icmp eq i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* %10
%37 = icmp eq i32 %36, 49
br label %38
38: ; preds = %35, %32, %29, %26
%39 = phi i1 [ true, %32 ], [ true, %29 ], [ true, %26 ], [ %37, %35 ]
br i1 %39, label %21, label %40
40: ; preds = %38
%41 = load i32*, i32** %8
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = mul nsw i64 %43, %15
%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 3, i32* %48
br label %49
49: ; preds = %40
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 1
store i32 %51, i32* %11
br label %16
52: ; preds = %16
ret void
}

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