#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*/ rarities;

/* Variables and functions */
scalar_t__ strstr(char *, char *);
void rarity(char *rarity_string, int *rarity_counts) {
  char *rarities[6] = {"Common",      "Uncommon", "Rare",
                       "Mythic Rare", "Special",  "Basic Land"};
  int i;
  for (i = 0; i < (sizeof(rarities) / sizeof(rarities[0])); i++) {
    if (strstr(rarity_string, rarities[i]) &&
        rarity_string[0] == rarities[i][0]) {
      rarity_counts[i]++;
      break;
    }
  }
}


x86 assembly (clang, -O0):
<rarity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xeb9(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb5(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xea8(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xea9(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
cmp    $0x6,%rax
jae    11f7 <rarity+0xd7>
mov    -0x8(%rbp),%rdi
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11e4 <rarity+0xc4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movslq -0x44(%rbp),%rcx
mov    -0x40(%rbp,%rcx,8),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11e4 <rarity+0xc4>
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    11f7 <rarity+0xd7>
jmp    11e9 <rarity+0xc9>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1189 <rarity+0x69>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rarity>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
je     1137 <rarity+0x27>
cmpb   $0x43,(%rbx)
jne    1137 <rarity+0x27>
xor    %eax,%eax
jmp    11cd <rarity+0xbd>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     1155 <rarity+0x45>
mov    $0x1,%eax
cmpb   $0x55,(%rbx)
je     11cd <rarity+0xbd>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     1173 <rarity+0x63>
mov    $0x2,%eax
cmpb   $0x52,(%rbx)
je     11cd <rarity+0xbd>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     1191 <rarity+0x81>
mov    $0x3,%eax
cmpb   $0x4d,(%rbx)
je     11cd <rarity+0xbd>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     11af <rarity+0x9f>
mov    $0x4,%eax
cmpb   $0x53,(%rbx)
je     11cd <rarity+0xbd>
lea    0xe6e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     11d2 <rarity+0xc2>
mov    $0x5,%eax
cmpb   $0x42,(%rbx)
jne    11d2 <rarity+0xc2>
addl   $0x1,(%r14,%rax,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Common\00"
@.str.1 = [9 x i8] c"Uncommon\00"
@.str.2 = [5 x i8] c"Rare\00"
@.str.3 = [12 x i8] c"Mythic Rare\00"
@.str.4 = [8 x i8] c"Special\00"
@.str.5 = [11 x i8] c"Basic Land\00"
define void @rarity(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [6 x i8*]
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = bitcast [6 x i8*]* %5 to i8*
%8 = bitcast i8* %7 to [6 x i8*]*
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 3
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 5
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i32 0, i32 0), i8** %14
store i32 0, i32* %6
br label %15
15: ; preds = %48, %2
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = icmp ult i64 %17, 6
br i1 %18, label %19, label %51
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @strstr(i8* %20, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %47
27: ; preds = %19
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %33
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %31, %38
br i1 %39, label %40, label %47
40: ; preds = %27
%41 = load i32*, i32** %4
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %44
br label %51
47: ; preds = %27, %19
br label %48
48: ; preds = %47
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %15
51: ; preds = %40, %15
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Common\00"
@.str.1 = [9 x i8] c"Uncommon\00"
@.str.2 = [5 x i8] c"Rare\00"
@.str.3 = [12 x i8] c"Mythic Rare\00"
@.str.4 = [8 x i8] c"Special\00"
@.str.5 = [11 x i8] c"Basic Land\00"
define void @rarity(i8* %0, i32* nocapture %1) {
%3 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 67
br i1 %7, label %8, label %13
8: ; preds = %40, %34, %28, %22, %16, %5
%9 = phi i64 [ 0, %5 ], [ 1, %16 ], [ 2, %22 ], [ 3, %28 ], [ 4, %34 ], [ 5, %40 ]
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
store i32 %12, i32* %10
br label %43
13: ; preds = %2, %5
%14 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i8, i8* %0
%18 = icmp eq i8 %17, 85
br i1 %18, label %8, label %19
19: ; preds = %16, %13
%20 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i8, i8* %0
%24 = icmp eq i8 %23, 82
br i1 %24, label %8, label %25
25: ; preds = %22, %19
%26 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i8, i8* %0
%30 = icmp eq i8 %29, 77
br i1 %30, label %8, label %31
31: ; preds = %28, %25
%32 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i8, i8* %0
%36 = icmp eq i8 %35, 83
br i1 %36, label %8, label %37
37: ; preds = %34, %31
%38 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i8, i8* %0
%42 = icmp eq i8 %41, 66
br i1 %42, label %8, label %43
43: ; preds = %37, %40, %8
ret void
}