#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 nameitem(char *s, int i) {
  memset(s, 0, sizeof(s));
  if (i == 0) {
    sprintf(s, "Ruby of Gaza");
    return;
  }
  if (i == 26) {
    sprintf(s, "Scepter of Leynos");
    return;
  }
  if (i == 39) {
    sprintf(s, "Bracelet of Armok");
    return;
  }
  if (i % 13 == 10) {
    sprintf(s, "prisoner");
    return;
  }
  if (i % 13 == 11) {
    sprintf(s, "white priestess");
    return;
  }
  if (i == 12) {
    sprintf(s, "djinn of Life");
    return;
  }
  if (i == 25) {
    sprintf(s, "djinn of Luck");
    return;
  }
  if (i == 38) {
    sprintf(s, "djinn of Destiny");
    return;
  }
  if (i == 51) {
    sprintf(s, "djinn of Death");
    return;
  }
  if (i < 12) {
    sprintf(s, "%d life potions", i % 13 + 1);
    return;
  }
  if (i < 25) {
    sprintf(s, "%d gems", i % 13 + 1);
    return;
  }
  if (i < 38) {
    sprintf(s, "%d magic potions", i % 13 + 1);
    return;
  }
  if (i < 51)
    sprintf(s, "%d strength potions", i % 13 + 1);
}


x86 assembly (clang, -O0):
<nameitem>:
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>
cmpl   $0x0,-0xc(%rbp)
jne    1160 <nameitem+0x40>
mov    -0x8(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0x1a,-0xc(%rbp)
jne    1181 <nameitem+0x61>
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0x27,-0xc(%rbp)
jne    11a2 <nameitem+0x82>
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
mov    -0xc(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xa,%edx
jne    11cd <nameitem+0xad>
mov    -0x8(%rbp),%rdi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
mov    -0xc(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xb,%edx
jne    11f8 <nameitem+0xd8>
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0xc,-0xc(%rbp)
jne    1219 <nameitem+0xf9>
mov    -0x8(%rbp),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0x19,-0xc(%rbp)
jne    123a <nameitem+0x11a>
mov    -0x8(%rbp),%rdi
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0x26,-0xc(%rbp)
jne    125b <nameitem+0x13b>
mov    -0x8(%rbp),%rdi
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0x33,-0xc(%rbp)
jne    127c <nameitem+0x15c>
mov    -0x8(%rbp),%rdi
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0xc,-0xc(%rbp)
jge    12ab <nameitem+0x18b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0x19,-0xc(%rbp)
jge    12da <nameitem+0x1ba>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0x26,-0xc(%rbp)
jge    1309 <nameitem+0x1e9>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
lea    0xda1(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1333 <nameitem+0x213>
cmpl   $0x33,-0xc(%rbp)
jge    1333 <nameitem+0x213>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nameitem>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
cmp    $0x27,%ebx
je     1160 <nameitem+0x40>
cmp    $0x1a,%ebx
je     1174 <nameitem+0x54>
test   %ebx,%ebx
jne    1188 <nameitem+0x68>
movabs $0x617a614720666f,%rax
mov    %rax,0x5(%r14)
movabs $0x20666f2079627552,%rax
6f 66 20
mov    %rax,(%r14)
jmp    11d2 <nameitem+0xb2>
movups 0xf58(%rip),%xmm0
movups %xmm0,(%r14)
movw   $0x6b,0x10(%r14)
jmp    11d2 <nameitem+0xb2>
movups 0xf32(%rip),%xmm0
movups %xmm0,(%r14)
movw   $0x73,0x10(%r14)
jmp    11d2 <nameitem+0xb2>
movslq %ebx,%rax
imul   $0x4ec4ec4f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%ecx
lea    (%rax,%rcx,4),%eax
mov    %ebx,%edx
sub    %eax,%edx
cmp    $0xb,%edx
je     11c7 <nameitem+0xa7>
cmp    $0xa,%edx
jne    11da <nameitem+0xba>
movabs $0x72656e6f73697270,%rax
6e 65 72
mov    %rax,(%r14)
movb   $0x0,0x8(%r14)
jmp    11d2 <nameitem+0xb2>
movups 0xf0c(%rip),%xmm0
movups %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    -0xc(%rbx),%eax
cmp    $0x27,%eax
ja     123d <nameitem+0x11d>
lea    0xe17(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movabs $0x6566694c20666f,%rax
jmp    1208 <nameitem+0xe8>
movabs $0x6b63754c20666f,%rax
mov    %rax,0x6(%r14)
jmp    122e <nameitem+0x10e>
movups 0xef1(%rip),%xmm0
movups %xmm0,(%r14)
movb   $0x0,0x10(%r14)
jmp    11d2 <nameitem+0xb2>
movabs $0x68746165442066,%rax
mov    %rax,0x7(%r14)
movabs $0x666f206e6e696a64,%rax
20 6f 66
jmp    115b <nameitem+0x3b>
cmp    $0xb,%ebx
jg     124e <nameitem+0x12e>
add    $0x1,%edx
lea    0xeda(%rip),%rsi
jmp    1283 <nameitem+0x163>
cmp    $0x18,%ebx
ja     125f <nameitem+0x13f>
add    $0x1,%edx
lea    0xed9(%rip),%rsi
jmp    1283 <nameitem+0x163>
cmp    $0x25,%ebx
ja     1270 <nameitem+0x150>
add    $0x1,%edx
lea    0xed0(%rip),%rsi
jmp    1283 <nameitem+0x163>
cmp    $0x32,%ebx
ja     11d2 <nameitem+0xb2>
add    $0x1,%edx
lea    0xecc(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Ruby of Gaza\00"
@.str.1 = [18 x i8] c"Scepter of Leynos\00"
@.str.2 = [18 x i8] c"Bracelet of Armok\00"
@.str.3 = [9 x i8] c"prisoner\00"
@.str.4 = [16 x i8] c"white priestess\00"
@.str.5 = [14 x i8] c"djinn of Life\00"
@.str.6 = [14 x i8] c"djinn of Luck\00"
@.str.7 = [17 x i8] c"djinn of Destiny\00"
@.str.8 = [15 x i8] c"djinn of Death\00"
@.str.9 = [16 x i8] c"%d life potions\00"
@.str.10 = [8 x i8] c"%d gems\00"
@.str.11 = [17 x i8] c"%d magic potions\00"
@.str.12 = [20 x i8] c"%d strength potions\00"
define void @nameitem(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 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %98
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 26
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %98
18: ; preds = %12
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 39
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %3
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %98
24: ; preds = %18
%25 = load i32, i32* %4
%26 = srem i32 %25, 13
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i8*, i8** %3
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %98
31: ; preds = %24
%32 = load i32, i32* %4
%33 = srem i32 %32, 13
%34 = icmp eq i32 %33, 11
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load i8*, i8** %3
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %98
38: ; preds = %31
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 12
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i8*, i8** %3
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %98
44: ; preds = %38
%45 = load i32, i32* %4
%46 = icmp eq i32 %45, 25
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i8*, i8** %3
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %98
50: ; preds = %44
%51 = load i32, i32* %4
%52 = icmp eq i32 %51, 38
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i8*, i8** %3
%55 = call i32 (i8*, i8*, ...) @sprintf(i8* %54, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %98
56: ; preds = %50
%57 = load i32, i32* %4
%58 = icmp eq i32 %57, 51
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i8*, i8** %3
%61 = call i32 (i8*, i8*, ...) @sprintf(i8* %60, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %98
62: ; preds = %56
%63 = load i32, i32* %4
%64 = icmp slt i32 %63, 12
br i1 %64, label %65, label %71
65: ; preds = %62
%66 = load i8*, i8** %3
%67 = load i32, i32* %4
%68 = srem i32 %67, 13
%69 = add nsw i32 %68, 1
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %66, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %69)
br label %98
71: ; preds = %62
%72 = load i32, i32* %4
%73 = icmp slt i32 %72, 25
br i1 %73, label %74, label %80
74: ; preds = %71
%75 = load i8*, i8** %3
%76 = load i32, i32* %4
%77 = srem i32 %76, 13
%78 = add nsw i32 %77, 1
%79 = call i32 (i8*, i8*, ...) @sprintf(i8* %75, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %78)
br label %98
80: ; preds = %71
%81 = load i32, i32* %4
%82 = icmp slt i32 %81, 38
br i1 %82, label %83, label %89
83: ; preds = %80
%84 = load i8*, i8** %3
%85 = load i32, i32* %4
%86 = srem i32 %85, 13
%87 = add nsw i32 %86, 1
%88 = call i32 (i8*, i8*, ...) @sprintf(i8* %84, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %87)
br label %98
89: ; preds = %80
%90 = load i32, i32* %4
%91 = icmp slt i32 %90, 51
br i1 %91, label %92, label %98
92: ; preds = %89
%93 = load i8*, i8** %3
%94 = load i32, i32* %4
%95 = srem i32 %94, 13
%96 = add nsw i32 %95, 1
%97 = call i32 (i8*, i8*, ...) @sprintf(i8* %93, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 %96)
br label %98
98: ; preds = %9, %15, %21, %28, %35, %41, %47, %53, %59, %65, %74, %83, %92, %89
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"Ruby of Gaza\00"
@.str.1 = [18 x i8] c"Scepter of Leynos\00"
@.str.2 = [18 x i8] c"Bracelet of Armok\00"
@.str.3 = [9 x i8] c"prisoner\00"
@.str.4 = [16 x i8] c"white priestess\00"
@.str.5 = [14 x i8] c"djinn of Life\00"
@.str.6 = [14 x i8] c"djinn of Luck\00"
@.str.7 = [17 x i8] c"djinn of Destiny\00"
@.str.8 = [15 x i8] c"djinn of Death\00"
@.str.9 = [16 x i8] c"%d life potions\00"
@.str.10 = [8 x i8] c"%d gems\00"
@.str.11 = [17 x i8] c"%d magic potions\00"
@.str.12 = [20 x i8] c"%d strength potions\00"
define void @nameitem(i8* %0, i32 %1) {
%3 = tail call i32 @memset(i8* %0, i32 0, i32 8)
switch i32 %1, label %7 [
i32 0, label %4
i32 26, label %5
i32 39, label %6
]
4: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(13) %0, i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 13, i1 false)
br label %36
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(18) %0, i8* align 1 dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 18, i1 false)
br label %36
6: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(18) %0, i8* align 1 dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i64 18, i1 false)
br label %36
7: ; preds = %2
%8 = srem i32 %1, 13
switch i32 %8, label %11 [
i32 10, label %9
i32 11, label %10
]
9: ; preds = %7
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 %36
10: ; preds = %7
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(16) %0, i8* align 1 dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i64 16, i1 false)
br label %36
11: ; preds = %7
switch i32 %1, label %16 [
i32 12, label %12
i32 25, label %13
i32 38, label %14
i32 51, label %15
]
12: ; preds = %11
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(14) %0, i8* align 1 dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i64 14, i1 false)
br label %36
13: ; preds = %11
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(14) %0, i8* align 1 dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i64 14, i1 false)
br label %36
14: ; preds = %11
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(17) %0, i8* align 1 dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i64 17, i1 false)
br label %36
15: ; preds = %11
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(15) %0, i8* align 1 dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i64 15, i1 false)
br label %36
16: ; preds = %11
%17 = icmp slt i32 %1, 12
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = add nsw i32 %8, 1
%20 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %19)
br label %36
21: ; preds = %16
%22 = icmp ult i32 %1, 25
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = add nsw i32 %8, 1
%25 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %24)
br label %36
26: ; preds = %21
%27 = icmp ult i32 %1, 38
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = add nsw i32 %8, 1
%30 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %29)
br label %36
31: ; preds = %26
%32 = icmp ult i32 %1, 51
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = add nsw i32 %8, 1
%35 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %4, %5, %6, %9, %10, %12, %13, %14, %15, %18, %23, %28, %33, %31
ret void
}