#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 */
double RAND_MAX;
int /*<<< orphan*/ mazestep(char **, int *, int *, int, int);
double rand();
void mazewalk(char **maze, int rows, int cols) {
  int i, r, c;
  c = cols | 1;
  maze[0][c] = ' ';
  maze[2 * rows][c] = ' ';
  i = (int)(2 * (rand() / (RAND_MAX + 1.0)));
  c = (i) ? 1 : 2 * cols - 1;
  r = rows | 1;
  maze[r][c] = ' ';
  mazestep(maze, &rows, &cols, r, c);
}


x86 assembly (clang, -O0):
<mazewalk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    $0x0,%al
call   1040 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe93(%rip),%xmm0
mov    0x2e6c(%rip),%rax
addsd  (%rax),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe74(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11ae <mazewalk+0x8e>
mov    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ba <mazewalk+0x9a>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <mazestep@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mazewalk>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %esi,0x8(%rsp)
mov    %edx,0xc(%rsp)
movslq %edx,%rax
or     $0x1,%rax
mov    (%rdi),%rcx
movb   $0x20,(%rcx,%rax,1)
movslq 0x8(%rsp),%rcx
shl    $0x4,%rcx
mov    (%rdi,%rcx,1),%rcx
movb   $0x20,(%rcx,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x2e8b(%rip),%rax
movsd  (%rax),%xmm1
addsd  0xe97(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%eax
test   %eax,%eax
mov    0xc(%rsp),%eax
lea    -0x1(%rax,%rax,1),%eax
mov    $0x1,%edx
cmove  %eax,%edx
movslq 0x8(%rsp),%rcx
or     $0x1,%rcx
mov    (%rbx,%rcx,8),%rax
movslq %edx,%r8
movb   $0x20,(%rax,%r8,1)
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <mazestep@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @mazewalk(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = or i32 %10, 1
store i32 %11, i32* %9
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = load i32, i32* %9
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8 32, i8* %17
%18 = load i8**, i8*** %4
%19 = load i32, i32* %5
%20 = mul nsw i32 2, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %18, i64 %21
%23 = load i8*, i8** %22
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 32, i8* %26
%27 = call double (...) @rand()
%28 = load double, double* @RAND_MAX
%29 = fadd double %28, 1.000000e+00
%30 = fdiv double %27, %29
%31 = fmul double 2.000000e+00, %30
%32 = fptosi double %31 to i32
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %3
br label %40
36: ; preds = %3
%37 = load i32, i32* %6
%38 = mul nsw i32 2, %37
%39 = sub nsw i32 %38, 1
br label %40
40: ; preds = %36, %35
%41 = phi i32 [ 1, %35 ], [ %39, %36 ]
store i32 %41, i32* %9
%42 = load i32, i32* %5
%43 = or i32 %42, 1
store i32 %43, i32* %8
%44 = load i8**, i8*** %4
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 32, i8* %51
%52 = load i8**, i8*** %4
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = call i32 @mazestep(i8** %52, i32* %5, i32* %6, i32 %53, i32 %54)
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @mazewalk(i8** %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
store i32 %1, i32* %4
store i32 %2, i32* %5
%6 = or i32 %2, 1
%7 = load i8*, i8** %0
%8 = sext i32 %6 to i64
%9 = getelementptr inbounds i8, i8* %7, i64 %8
store i8 32, i8* %9
%10 = load i32, i32* %4
%11 = shl nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %0, i64 %12
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i64 %8
store i8 32, i8* %15
%16 = tail call double (...) @rand()
%17 = load double, double* @RAND_MAX
%18 = fadd double %17, 1.000000e+00
%19 = fdiv double %16, %18
%20 = fmul double %19, 2.000000e+00
%21 = fptosi double %20 to i32
%22 = icmp eq i32 %21, 0
%23 = load i32, i32* %5
%24 = shl nsw i32 %23, 1
%25 = add nsw i32 %24, -1
%26 = select i1 %22, i32 %25, i32 1
%27 = load i32, i32* %4
%28 = or i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %0, i64 %29
%31 = load i8*, i8** %30
%32 = sext i32 %26 to i64
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8 32, i8* %33
%34 = call i32 @mazestep(i8** %0, i32* %4, i32* %5, i32 %28, i32 %26)
ret void
}