#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*/ assert(int);
int emperor_opens_the_door_with_lion(int door_gladiator, bool *is_girl) {
  int i;
  for (i = 0; i < 3; i++) {
    if (i != door_gladiator && !is_girl[i])
      return i;
  }
  assert(false);
  return -1;
}


x86 assembly (clang, -O0):
<emperor_opens_the_door_with_lion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    116c <emperor_opens_the_door_with_lion+0x5c>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1159 <emperor_opens_the_door_with_lion+0x49>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1159 <emperor_opens_the_door_with_lion+0x49>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117a <emperor_opens_the_door_with_lion+0x6a>
jmp    115e <emperor_opens_the_door_with_lion+0x4e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <emperor_opens_the_door_with_lion+0x16>
xor    %edi,%edi
call   1030 <assert@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emperor_opens_the_door_with_lion>:
push   %rax
test   %edi,%edi
je     112c <emperor_opens_the_door_with_lion+0x1c>
cmpl   $0x0,(%rsi)
je     1146 <emperor_opens_the_door_with_lion+0x36>
cmp    $0x1,%edi
je     1132 <emperor_opens_the_door_with_lion+0x22>
cmpl   $0x0,0x4(%rsi)
je     114a <emperor_opens_the_door_with_lion+0x3a>
cmp    $0x2,%edi
jne    1132 <emperor_opens_the_door_with_lion+0x22>
jmp    1138 <emperor_opens_the_door_with_lion+0x28>
cmpl   $0x0,0x4(%rsi)
je     114a <emperor_opens_the_door_with_lion+0x3a>
cmpl   $0x0,0x8(%rsi)
je     1151 <emperor_opens_the_door_with_lion+0x41>
xor    %edi,%edi
call   1030 <assert@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret
mov    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @emperor_opens_the_door_with_lion(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 0, i32* %6
br label %7
7: ; preds = %24, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i32*, i32** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %14
%22 = load i32, i32* %6
store i32 %22, i32* %3
br label %29
23: ; preds = %14, %10
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %7
27: ; preds = %7
%28 = call i32 @assert(i32 0)
store i32 -1, i32* %3
br label %29
29: ; preds = %27, %21
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @emperor_opens_the_door_with_lion(i32 %0, i32* nocapture %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %4
%8 = icmp eq i32 %0, 1
br i1 %8, label %19, label %9
9: ; preds = %7
%10 = getelementptr inbounds i32, i32* %1, i64 1
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %25, label %17
13: ; preds = %2
%14 = getelementptr inbounds i32, i32* %1, i64 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %25, label %19
17: ; preds = %9
%18 = icmp eq i32 %0, 2
br i1 %18, label %23, label %19
19: ; preds = %13, %7, %17
%20 = getelementptr inbounds i32, i32* %1, i64 2
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19, %17
%24 = tail call i32 @assert(i32 0)
br label %25
25: ; preds = %4, %9, %19, %13, %23
%26 = phi i32 [ -1, %23 ], [ 0, %4 ], [ 1, %9 ], [ 2, %19 ], [ 1, %13 ]
ret i32 %26
}