#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *);
void nameenemy(char *s, int enemy) {
  memset(s, 0, sizeof(s));
  if (enemy % 13 == 10)
    sprintf(s, "adventurer");
  else if (enemy < 13)
    sprintf(s, "amazon");
  else if (enemy < 26)
    sprintf(s, "demon");
  else if (enemy < 39)
    sprintf(s, "magician");
  else
    sprintf(s, "warrior");
}


x86 assembly (clang, -O0):
<nameenemy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    -0xc(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xa,%edx
jne    1168 <nameenemy+0x48>
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11e4 <nameenemy+0xc4>
cmpl   $0xd,-0xc(%rbp)
jge    1187 <nameenemy+0x67>
mov    -0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11df <nameenemy+0xbf>
cmpl   $0x1a,-0xc(%rbp)
jge    11a6 <nameenemy+0x86>
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11da <nameenemy+0xba>
cmpl   $0x27,-0xc(%rbp)
jge    11c5 <nameenemy+0xa5>
mov    -0x8(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11d5 <nameenemy+0xb5>
mov    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11da <nameenemy+0xba>
jmp    11df <nameenemy+0xbf>
jmp    11e4 <nameenemy+0xc4>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nameenemy>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
movslq %ebp,%rax
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
sub    %ecx,%eax
cmp    $0xa,%eax
jne    115e <nameenemy+0x4e>
movabs $0x7275746e65766461,%rax
74 75 72
mov    %rax,(%rbx)
movl   $0x726572,0x7(%rbx)
jmp    11aa <nameenemy+0x9a>
cmp    $0xc,%ebp
jg     1172 <nameenemy+0x62>
movl   $0x6e6f7a,0x3(%rbx)
movl   $0x7a616d61,(%rbx)
jmp    11aa <nameenemy+0x9a>
cmp    $0x19,%ebp
ja     1185 <nameenemy+0x75>
movw   $0x6e,0x4(%rbx)
movl   $0x6f6d6564,(%rbx)
jmp    11aa <nameenemy+0x9a>
cmp    $0x26,%ebp
ja     119d <nameenemy+0x8d>
movabs $0x6e6169636967616d,%rax
69 61 6e
mov    %rax,(%rbx)
movb   $0x0,0x8(%rbx)
jmp    11aa <nameenemy+0x9a>
movabs $0x726f6972726177,%rax
mov    %rax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"adventurer\00"
@.str.1 = [7 x i8] c"amazon\00"
@.str.2 = [6 x i8] c"demon\00"
@.str.3 = [9 x i8] c"magician\00"
@.str.4 = [8 x i8] c"warrior\00"
define void @nameenemy(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = call i32 @memset(i8* %5, i32 0, i32 8)
%7 = load i32, i32* %4
%8 = srem i32 %7, 13
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %37
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 13
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %36
19: ; preds = %13
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 26
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %35
25: ; preds = %19
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 39
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i8*, i8** %3
%30 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %34
31: ; preds = %25
%32 = load i8*, i8** %3
%33 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %31, %28
br label %35
35: ; preds = %34, %22
br label %36
36: ; preds = %35, %16
br label %37
37: ; preds = %36, %10
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"adventurer\00"
@.str.1 = [7 x i8] c"amazon\00"
@.str.2 = [6 x i8] c"demon\00"
@.str.3 = [9 x i8] c"magician\00"
define void @nameenemy(i8* %0, i32 %1) {
%3 = tail call i32 @memset(i8* %0, i32 0, i32 8)
%4 = srem i32 %1, 13
%5 = icmp eq i32 %4, 10
br i1 %5, label %6, label %7
6: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %0, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 11, i1 false)
br label %18
7: ; preds = %2
%8 = icmp slt i32 %1, 13
br i1 %8, label %9, label %10
9: ; preds = %7
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %0, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 7, i1 false)
br label %18
10: ; preds = %7
%11 = icmp ult i32 %1, 26
br i1 %11, label %12, label %13
12: ; preds = %10
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(6) %0, i8* align 1 dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 6, i1 false)
br label %18
13: ; preds = %10
%14 = icmp ult i32 %1, 39
br i1 %14, label %15, label %16
15: ; preds = %13
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %0, i8* align 1 dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i64 9, i1 false)
br label %18
16: ; preds = %13
%17 = bitcast i8* %0 to i64*
store i64 32210646027362679, i64* %17
br label %18
18: ; preds = %9, %15, %16, %12, %6
ret void
}