#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
void *malloc(int);
int /*<<< orphan*/ stderr;
char **mazeinit(int rows, int cols, char wall) {
  char **a = malloc((2 * rows + 1) * sizeof(char *));
  int i, j;
  for (i = 0; i < 2 * rows + 1; i++) {
    if (!(a[i] = malloc(2 * cols + 1))) {
      fprintf(stderr, "Out of memory.\n");
      exit(1);
    }
    for (j = 0; j < 2 * cols + 1; j++)
      a[i][j] = (wall) ? wall : '*';
  }
  return a;
}


x86 assembly (clang, -O0):
<mazeinit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1235 <mazeinit+0x105>
mov    -0x8(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    11bb <mazeinit+0x8b>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1222 <mazeinit+0xf2>
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
je     11ef <mazeinit+0xbf>
movsbl -0x9(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11fc <mazeinit+0xcc>
mov    $0x2a,%eax
mov    %eax,-0x24(%rbp)
jmp    11fc <mazeinit+0xcc>
mov    -0x24(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c2 <mazeinit+0x92>
jmp    1227 <mazeinit+0xf7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1164 <mazeinit+0x34>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mazeinit>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebx
mov    %esi,%r15d
lea    (%rdi,%rdi,1),%ebp
add    $0x1,%ebp
add    %edi,%edi
lea    0x8(,%rdi,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
test   %ebp,%ebp
jle    11bd <mazeinit+0x7d>
test   %bl,%bl
movzbl %bl,%eax
mov    $0x2a,%ecx
cmovne %eax,%ecx
lea    (%r15,%r15,1),%ebx
add    $0x1,%ebx
mov    %ebp,%r12d
xor    %ebp,%ebp
movzbl %cl,%r15d
jmp    1199 <mazeinit+0x59>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r12
je     11bd <mazeinit+0x7d>
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,(%r14,%rbp,8)
test   %rax,%rax
je     11c9 <mazeinit+0x89>
test   %ebx,%ebx
jle    1190 <mazeinit+0x50>
mov    %rax,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
jmp    1190 <mazeinit+0x50>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"Out of memory.\0A\00"
define i8** @mazeinit(i32 %0, i32 %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%10 = load i32, i32* %4
%11 = mul nsw i32 2, %10
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call i8* @malloc(i32 %15)
%17 = bitcast i8* %16 to i8**
store i8** %17, i8*** %7
store i32 0, i32* %8
br label %18
18: ; preds = %68, %3
%19 = load i32, i32* %8
%20 = load i32, i32* %4
%21 = mul nsw i32 2, %20
%22 = add nsw i32 %21, 1
%23 = icmp slt i32 %19, %22
br i1 %23, label %24, label %71
24: ; preds = %18
%25 = load i32, i32* %5
%26 = mul nsw i32 2, %25
%27 = add nsw i32 %26, 1
%28 = call i8* @malloc(i32 %27)
%29 = load i8**, i8*** %7
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
store i8* %28, i8** %32
%33 = icmp ne i8* %28, null
br i1 %33, label %38, label %34
34: ; preds = %24
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %24
store i32 0, i32* %9
br label %39
39: ; preds = %64, %38
%40 = load i32, i32* %9
%41 = load i32, i32* %5
%42 = mul nsw i32 2, %41
%43 = add nsw i32 %42, 1
%44 = icmp slt i32 %40, %43
br i1 %44, label %45, label %67
45: ; preds = %39
%46 = load i8, i8* %6
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = load i8, i8* %6
%51 = sext i8 %50 to i32
br label %53
52: ; preds = %45
br label %53
53: ; preds = %52, %49
%54 = phi i32 [ %51, %49 ], [ 42, %52 ]
%55 = trunc i32 %54 to i8
%56 = load i8**, i8*** %7
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
store i8 %55, i8* %63
br label %64
64: ; preds = %53
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %39
67: ; preds = %39
br label %68
68: ; preds = %67
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
store i32 %70, i32* %8
br label %18
71: ; preds = %18
%72 = load i8**, i8*** %7
ret i8** %72
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"Out of memory.\0A\00"
define noalias i8** @mazeinit(i32 %0, i32 %1, i8 signext %2) {
%4 = shl nsw i32 %0, 1
%5 = or i32 %4, 1
%6 = shl i32 %5, 3
%7 = tail call i8* @malloc(i32 %6)
%8 = bitcast i8* %7 to i8**
%9 = icmp sgt i32 %5, 0
br i1 %9, label %10, label %33
10: ; preds = %3
%11 = shl nsw i32 %1, 1
%12 = or i32 %11, 1
%13 = icmp sgt i32 %12, 0
%14 = icmp eq i8 %2, 0
%15 = select i1 %14, i8 42, i8 %2
%16 = or i32 %11, 1
%17 = zext i32 %16 to i64
%18 = zext i32 %5 to i64
br label %19
19: ; preds = %10, %30
%20 = phi i64 [ 0, %10 ], [ %31, %30 ]
%21 = tail call i8* @malloc(i32 %12)
%22 = getelementptr inbounds i8*, i8** %8, i64 %20
store i8* %21, i8** %22
%23 = icmp eq i8* %21, null
br i1 %23, label %26, label %24
24: ; preds = %19
br i1 %13, label %25, label %30
25: ; preds = %24
br label %30
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %25, %24
%31 = add nuw nsw i64 %20, 1
%32 = icmp eq i64 %31, %18
br i1 %32, label %33, label %19
33: ; preds = %30, %3
ret i8** %8
}