#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 */
struct WaveletTree {
  int dummy;
};

/* Variables and functions */
char accessOp(struct WaveletTree *, char *, int);
int /*<<< orphan*/ assert(int);
struct WaveletTree *buildTree(char *, int, char *, int);
int /*<<< orphan*/ deleteTree(struct WaveletTree *);
char *extractAlphabetLetters(char *);
int /*<<< orphan*/ free(void *);
scalar_t__ malloc(int);
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void testAccessing() {
  char tmp[] = "Peter_Piper_picked_a_peck_of_pickled_peppers$";
  char *test = (char *)malloc((strlen(tmp) + 1) * sizeof(char));
  strcpy(test, tmp);
  char *used_alphabet = extractAlphabetLetters(test);
  struct WaveletTree *tree = buildTree(test, (int)strlen(test), used_alphabet,
                                       (int)strlen(used_alphabet));
  assert(accessOp(tree, used_alphabet, 0) == 'P');
  assert(accessOp(tree, used_alphabet, 9) == 'e');
  assert(accessOp(tree, used_alphabet, 18) == '_');
  assert(accessOp(tree, used_alphabet, 19) == 'a');
  assert(accessOp(tree, used_alphabet, 42) == 'r');
  assert(accessOp(tree, used_alphabet, 44) == '$');
  print("Accessing tests [PASSED]");
  free((void *)test);
  deleteTree(tree);
}


x86 assembly (clang, -O0):
<testAccessing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x30(%rbp),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x2e,%edx
call   10b0 <memcpy@plt>
lea    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x38(%rbp),%rdi
call   1050 <extractAlphabetLetters@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x50(%rbp),%rdx
mov    %eax,%ecx
call   10a0 <buildTree@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
xor    %edx,%edx
call   10d0 <accessOp@plt>
movsbl %al,%eax
cmp    $0x50,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    $0x9,%edx
call   10d0 <accessOp@plt>
movsbl %al,%eax
cmp    $0x65,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    $0x12,%edx
call   10d0 <accessOp@plt>
movsbl %al,%eax
cmp    $0x5f,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    $0x13,%edx
call   10d0 <accessOp@plt>
movsbl %al,%eax
cmp    $0x61,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    $0x2a,%edx
call   10d0 <accessOp@plt>
movsbl %al,%eax
cmp    $0x72,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    $0x2c,%edx
call   10d0 <accessOp@plt>
movsbl %al,%eax
cmp    $0x24,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
lea    0xd0d(%rip),%rdi
call   1080 <print@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1070 <deleteTree@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testAccessing>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movups 0xe6d(%rip),%xmm0
movups %xmm0,0x1e(%rsp)
movaps 0xe53(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe37(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1050 <extractAlphabetLetters@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   10a0 <buildTree@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   10c0 <accessOp@plt>
xor    %edi,%edi
cmp    $0x50,%al
sete   %dil
call   1090 <assert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x9,%edx
call   10c0 <accessOp@plt>
xor    %edi,%edi
cmp    $0x65,%al
sete   %dil
call   1090 <assert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x12,%edx
call   10c0 <accessOp@plt>
xor    %edi,%edi
cmp    $0x5f,%al
sete   %dil
call   1090 <assert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x13,%edx
call   10c0 <accessOp@plt>
xor    %edi,%edi
cmp    $0x61,%al
sete   %dil
call   1090 <assert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x2a,%edx
call   10c0 <accessOp@plt>
xor    %edi,%edi
cmp    $0x72,%al
sete   %dil
call   1090 <assert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x2c,%edx
call   10c0 <accessOp@plt>
xor    %edi,%edi
cmp    $0x24,%al
sete   %dil
call   1090 <assert@plt>
lea    0xd5f(%rip),%rdi
call   1080 <print@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1070 <deleteTree@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.WaveletTree = type { i32 }
@__const.testAccessing.tmp = [46 x i8] c"Peter_Piper_picked_a_peck_of_pickled_peppers$\00"
@.str = [25 x i8] c"Accessing tests [PASSED]\00"
define void @testAccessing() {
%1 = alloca [46 x i8]
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.WaveletTree*
%5 = bitcast [46 x i8]* %1 to i8*
%6 = getelementptr inbounds [46 x i8], [46 x i8]* %1, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = add nsw i32 %7, 1
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 1
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %2
%14 = load i8*, i8** %2
%15 = getelementptr inbounds [46 x i8], [46 x i8]* %1, i64 0, i64 0
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = load i8*, i8** %2
%18 = call i8* @extractAlphabetLetters(i8* %17)
store i8* %18, i8** %3
%19 = load i8*, i8** %2
%20 = load i8*, i8** %2
%21 = call i32 @strlen(i8* %20)
%22 = load i8*, i8** %3
%23 = load i8*, i8** %3
%24 = call i32 @strlen(i8* %23)
%25 = call %struct.WaveletTree* @buildTree(i8* %19, i32 %21, i8* %22, i32 %24)
store %struct.WaveletTree* %25, %struct.WaveletTree** %4
%26 = load %struct.WaveletTree*, %struct.WaveletTree** %4
%27 = load i8*, i8** %3
%28 = call signext i8 @accessOp(%struct.WaveletTree* %26, i8* %27, i32 0)
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 80
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load %struct.WaveletTree*, %struct.WaveletTree** %4
%34 = load i8*, i8** %3
%35 = call signext i8 @accessOp(%struct.WaveletTree* %33, i8* %34, i32 9)
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 101
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load %struct.WaveletTree*, %struct.WaveletTree** %4
%41 = load i8*, i8** %3
%42 = call signext i8 @accessOp(%struct.WaveletTree* %40, i8* %41, i32 18)
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 95
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = load %struct.WaveletTree*, %struct.WaveletTree** %4
%48 = load i8*, i8** %3
%49 = call signext i8 @accessOp(%struct.WaveletTree* %47, i8* %48, i32 19)
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 97
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load %struct.WaveletTree*, %struct.WaveletTree** %4
%55 = load i8*, i8** %3
%56 = call signext i8 @accessOp(%struct.WaveletTree* %54, i8* %55, i32 42)
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 114
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = load %struct.WaveletTree*, %struct.WaveletTree** %4
%62 = load i8*, i8** %3
%63 = call signext i8 @accessOp(%struct.WaveletTree* %61, i8* %62, i32 44)
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 36
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
%68 = call i32 @print(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%69 = load i8*, i8** %2
%70 = call i32 @free(i8* %69)
%71 = load %struct.WaveletTree*, %struct.WaveletTree** %4
%72 = call i32 @deleteTree(%struct.WaveletTree* %71)
ret void
}

LLVM IR (-O2):
%struct.WaveletTree = type { i32 }
@__const.testAccessing.tmp = [46 x i8] c"Peter_Piper_picked_a_peck_of_pickled_peppers$\00"
@.str = [25 x i8] c"Accessing tests [PASSED]\00"
define void @testAccessing() {
%1 = alloca [46 x i8]
%2 = getelementptr inbounds [46 x i8], [46 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = add nsw i32 %3, 1
%5 = call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = call i32 @strcpy(i8* %6, i8* %2)
%8 = call i8* @extractAlphabetLetters(i8* %6)
%9 = call i32 @strlen(i8* %6)
%10 = call i32 @strlen(i8* %8)
%11 = call %struct.WaveletTree* @buildTree(i8* %6, i32 %9, i8* %8, i32 %10)
%12 = call signext i8 @accessOp(%struct.WaveletTree* %11, i8* %8, i32 0)
%13 = icmp eq i8 %12, 80
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call signext i8 @accessOp(%struct.WaveletTree* %11, i8* %8, i32 9)
%17 = icmp eq i8 %16, 101
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call signext i8 @accessOp(%struct.WaveletTree* %11, i8* %8, i32 18)
%21 = icmp eq i8 %20, 95
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call signext i8 @accessOp(%struct.WaveletTree* %11, i8* %8, i32 19)
%25 = icmp eq i8 %24, 97
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = call signext i8 @accessOp(%struct.WaveletTree* %11, i8* %8, i32 42)
%29 = icmp eq i8 %28, 114
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = call signext i8 @accessOp(%struct.WaveletTree* %11, i8* %8, i32 44)
%33 = icmp eq i8 %32, 36
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = call i32 @print(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @free(i8* %6)
%38 = call i32 @deleteTree(%struct.WaveletTree* %11)
ret void
}