#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*/ printf(char *);
void addaces(int *hpmax, int *aces, int a) {
  printf("Is this one of the four artifacts?!\n");
  if (a < 9)
    a = 0;
  else if (a < 22)
    a = 1;
  else if (a < 35)
    a = 2;
  else
    a = 3;
  if (*(aces + a)) {
    printf("It is only a pathetic imitation...\n");
    return;
  }
  *(aces + a) = 1;
  if (a == 0) {
    printf("You found the Ruby of Gaza!\n");
    *hpmax = *hpmax + 5;
  } else if (a == 1) {
    printf("You found the Bag of Meres!\n");
  } else if (a == 2) {
    printf("You found the Scepter of Leynos!\n");
  } else {
    printf("You found the Bracelet of Armok!\n");
  }
}


x86 assembly (clang, -O0):
<addaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x9,-0x14(%rbp)
jge    1145 <addaces+0x35>
movl   $0x0,-0x14(%rbp)
jmp    1182 <addaces+0x72>
cmpl   $0x16,-0x14(%rbp)
jge    115b <addaces+0x4b>
movl   $0x1,-0x14(%rbp)
jmp    117d <addaces+0x6d>
cmpl   $0x23,-0x14(%rbp)
jge    1171 <addaces+0x61>
movl   $0x2,-0x14(%rbp)
jmp    1178 <addaces+0x68>
movl   $0x3,-0x14(%rbp)
jmp    117d <addaces+0x6d>
jmp    1182 <addaces+0x72>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11a5 <addaces+0x95>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
jmp    122a <addaces+0x11a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
cmpl   $0x0,-0x14(%rbp)
jne    11de <addaces+0xce>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x5,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    122a <addaces+0x11a>
cmpl   $0x1,-0x14(%rbp)
jne    11f9 <addaces+0xe9>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
jmp    1225 <addaces+0x115>
cmpl   $0x2,-0x14(%rbp)
jne    1214 <addaces+0x104>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
jmp    1220 <addaces+0x110>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
jmp    1225 <addaces+0x115>
jmp    122a <addaces+0x11a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addaces>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x9,%ebp
jge    114d <addaces+0x3d>
cmpl   $0x0,(%rbx)
jne    116d <addaces+0x5d>
movl   $0x1,(%rbx)
lea    0xf43(%rip),%rdi
call   1030 <puts@plt>
addl   $0x5,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret
cmp    $0x23,%ebp
mov    $0x3,%edx
sbb    $0x0,%rdx
mov    %ebp,%eax
sub    $0x16,%eax
mov    $0x1,%ecx
cmovae %rdx,%rcx
cmpl   $0x0,(%rbx,%rcx,4)
je     117d <addaces+0x6d>
lea    0xf2a(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
movl   $0x1,(%rbx,%rcx,4)
cmp    $0x15,%ebp
ja     1192 <addaces+0x82>
lea    0xed6(%rip),%rdi
jmp    1174 <addaces+0x64>
cmp    $0xc,%eax
ja     11a0 <addaces+0x90>
lea    0xea7(%rip),%rdi
jmp    1174 <addaces+0x64>
lea    0xe7d(%rip),%rdi
jmp    1174 <addaces+0x64>

LLVM IR (-O0):
@.str = [37 x i8] c"Is this one of the four artifacts?!\0A\00"
@.str.1 = [36 x i8] c"It is only a pathetic imitation...\0A\00"
@.str.2 = [29 x i8] c"You found the Ruby of Gaza!\0A\00"
@.str.3 = [29 x i8] c"You found the Bag of Meres!\0A\00"
@.str.4 = [34 x i8] c"You found the Scepter of Leynos!\0A\00"
@.str.5 = [34 x i8] c"You found the Bracelet of Armok!\0A\00"
define void @addaces(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 9
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 0, i32* %6
br label %22
11: ; preds = %3
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 22
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %6
br label %21
15: ; preds = %11
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 35
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 2, i32* %6
br label %20
19: ; preds = %15
store i32 3, i32* %6
br label %20
20: ; preds = %19, %18
br label %21
21: ; preds = %20, %14
br label %22
22: ; preds = %21, %10
%23 = load i32*, i32** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %58
31: ; preds = %22
%32 = load i32*, i32** %5
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 1, i32* %35
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %31
%39 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%40 = load i32*, i32** %4
%41 = load i32, i32* %40
%42 = add nsw i32 %41, 5
%43 = load i32*, i32** %4
store i32 %42, i32* %43
br label %58
44: ; preds = %31
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %57
49: ; preds = %44
%50 = load i32, i32* %6
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %56
54: ; preds = %49
%55 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %54, %52
br label %57
57: ; preds = %56, %47
br label %58
58: ; preds = %29, %57, %38
ret void
}

LLVM IR (-O2):
@str = [36 x i8] c"Is this one of the four artifacts?!\00"
@str.6 = [33 x i8] c"You found the Bracelet of Armok!\00"
@str.7 = [33 x i8] c"You found the Scepter of Leynos!\00"
@str.8 = [28 x i8] c"You found the Bag of Meres!\00"
@str.9 = [28 x i8] c"You found the Ruby of Gaza!\00"
@str.10 = [35 x i8] c"It is only a pathetic imitation...\00"
define void @addaces(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%5 = icmp slt i32 %2, 9
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = icmp ult i32 %2, 22
%8 = icmp ult i32 %2, 35
%9 = select i1 %8, i64 2, i64 3
%10 = add nsw i32 %2, -22
%11 = icmp ult i32 %10, 13
%12 = select i1 %7, i64 1, i64 %9
%13 = getelementptr inbounds i32, i32* %1, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %25, label %19
16: ; preds = %3
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16, %6
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.10, i64 0, i64 0))
br label %33
21: ; preds = %16
store i32 1, i32* %1
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.9, i64 0, i64 0))
%23 = load i32, i32* %0
%24 = add nsw i32 %23, 5
store i32 %24, i32* %0
br label %33
25: ; preds = %6
store i32 1, i32* %13
br i1 %7, label %26, label %28
26: ; preds = %25
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
br label %33
28: ; preds = %25
br i1 %11, label %29, label %31
29: ; preds = %28
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
br label %33
31: ; preds = %28
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.6, i64 0, i64 0))
br label %33
33: ; preds = %26, %31, %29, %19, %21
ret void
}