#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 addRandomEntrances(int (*maze)[13]) {
  int rndStartRow = 0, rndStartCol = 0;
  int rndEndRow = 13 - 1, rndEndCol = 13 - 1;
  if ((rand() % 3) == 1) {
    rndStartRow = (rand() % (13 - 2) + 1);
    if (rndStartRow % 2 == 0)
      rndStartRow++;
    rndEndRow = (rand() % (13 - 2) + 1);
    if (rndEndRow % 2 == 0)
      rndEndRow++;
  } else {
    rndStartCol = (rand() % (13 - 2) + 1);
    if (rndStartCol % 2 == 0)
      rndStartCol++;
    rndEndCol = (rand() % (13 - 2) + 1);
    if (rndEndCol % 2 == 0)
      rndEndCol++;
  }
  maze[rndStartRow][rndStartCol] = 0;
  maze[rndEndRow][rndEndCol] = 0;
}


x86 assembly (clang, -O0):
<addRandomEntrances>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0xc,-0x14(%rbp)
movl   $0xc,-0x18(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11b9 <addRandomEntrances+0xa9>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1182 <addRandomEntrances+0x72>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b4 <addRandomEntrances+0xa4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1222 <addRandomEntrances+0x112>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11eb <addRandomEntrances+0xdb>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    121d <addRandomEntrances+0x10d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1222 <addRandomEntrances+0x112>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x34,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x34,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addRandomEntrances>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rbx
imul   $0x55555556,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
mov    %eax,%edx
sub    %ecx,%edx
add    $0x1,%edx
neg    %ecx
test   $0x1,%dl
lea    0x2(%rax,%rcx,1),%ebp
cmovne %edx,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
mov    %eax,%edx
sub    %ecx,%edx
add    $0x1,%edx
neg    %ecx
test   $0x1,%dl
lea    0x2(%rax,%rcx,1),%eax
cmovne %edx,%eax
cmp    $0x1,%ebx
movslq %ebp,%rcx
cltq
mov    $0x0,%edx
cmove  %rcx,%rdx
cmove  %r14,%rcx
mov    $0xc,%esi
mov    $0xc,%edi
cmove  %rax,%rdi
cmove  %rsi,%rax
imul   $0x34,%rdx,%rdx
add    %r15,%rdx
movl   $0x0,(%rdx,%rcx,4)
imul   $0x34,%rdi,%rcx
add    %r15,%rcx
movl   $0x0,(%rcx,%rax,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @addRandomEntrances([13 x i32]* %0) {
%2 = alloca [13 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store [13 x i32]* %0, [13 x i32]** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 12, i32* %5
store i32 12, i32* %6
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 3
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %31
10: ; preds = %1
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = srem i32 %14, 2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %20
20: ; preds = %17, %10
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 11
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = srem i32 %24, 2
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %30
30: ; preds = %27, %20
br label %52
31: ; preds = %1
%32 = call i32 (...) @rand()
%33 = srem i32 %32, 11
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = srem i32 %35, 2
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %31
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %41
41: ; preds = %38, %31
%42 = call i32 (...) @rand()
%43 = srem i32 %42, 11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = srem i32 %45, 2
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %41
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %51
51: ; preds = %48, %41
br label %52
52: ; preds = %51, %30
%53 = load [13 x i32]*, [13 x i32]** %2
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [13 x i32], [13 x i32]* %53, i64 %55
%57 = load i32, i32* %4
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [13 x i32], [13 x i32]* %56, i64 0, i64 %58
store i32 0, i32* %59
%60 = load [13 x i32]*, [13 x i32]** %2
%61 = load i32, i32* %5
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [13 x i32], [13 x i32]* %60, i64 %62
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [13 x i32], [13 x i32]* %63, i64 0, i64 %65
store i32 0, i32* %66
ret void
}

LLVM IR (-O2):
define void @addRandomEntrances([13 x i32]* nocapture writeonly %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 3
%4 = icmp eq i32 %3, 1
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 11
%7 = add nsw i32 %6, 1
%8 = and i32 %7, 1
%9 = icmp eq i32 %8, 0
%10 = add nsw i32 %6, 2
%11 = select i1 %9, i32 %10, i32 %7
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 11
%14 = add nsw i32 %13, 1
%15 = and i32 %14, 1
%16 = icmp eq i32 %15, 0
%17 = add nsw i32 %13, 2
%18 = select i1 %16, i32 %17, i32 %14
%19 = sext i32 %11 to i64
%20 = sext i32 %18 to i64
%21 = select i1 %4, i64 %19, i64 0
%22 = select i1 %4, i64 0, i64 %19
%23 = select i1 %4, i64 %20, i64 12
%24 = select i1 %4, i64 12, i64 %20
%25 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 %21, i64 %22
store i32 0, i32* %25
%26 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 %23, i64 %24
store i32 0, i32* %26
ret void
}