#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 suggest_input {
  int dummy;
};
struct suffixtree {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ FreeSplitList(char **);
struct suggest_input **_suffixtree_find_prefix(struct suffixtree *, char *,
                                               int /*<<< orphan*/, char *,
                                               char ***, int *, char **);
int split(char *, char *, char ***);
struct suggest_input **suffixtree_find_prefix(struct suffixtree *root,
                                              char *word, char *user,
                                              char ***groups, int *num,
                                              char *collectionFilter) {
  char **collections;
  int n_collections, n_collections_dup;
  struct suggest_input **ret;
  int i;
  if (collectionFilter == NULL)
    collectionFilter = "";
  n_collections = split(collectionFilter, ",", &collections);
  n_collections_dup = n_collections;
  for (i = 0; i < n_collections_dup; i++) {
    if (*collections[i] == '\0')
      n_collections--;
  }
  ret = _suffixtree_find_prefix(root, word, 0, user, groups, num,
                                n_collections == 0 ? NULL : collections);
  FreeSplitList(collections);
  return ret;
}


x86 assembly (clang, -O0):
<suffixtree_find_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1169 <suffixtree_find_prefix+0x39>
lea    0xe9c(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe8c(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1040 <split@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    11cd <suffixtree_find_prefix+0x9d>
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ba <suffixtree_find_prefix+0x8a>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    11bf <suffixtree_find_prefix+0x8f>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    118d <suffixtree_find_prefix+0x5d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    120a <suffixtree_find_prefix+0xda>
xor    %eax,%eax
mov    %rax,-0x80(%rbp)
jmp    1212 <suffixtree_find_prefix+0xe2>
mov    -0x38(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%r8
mov    -0x68(%rbp),%rcx
mov    -0x70(%rbp),%rsi
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rax
xor    %edx,%edx
mov    %rax,(%rsp)
call   1050 <_suffixtree_find_prefix@plt>
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <FreeSplitList@plt>
mov    -0x48(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<suffixtree_find_prefix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r14
test   %r9,%r9
lea    0xeaa(%rip),%rdi
cmovne %r9,%rdi
lea    0xe9e(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1040 <split@plt>
mov    0x10(%rsp),%rcx
test   %eax,%eax
jle    1203 <suffixtree_find_prefix+0xd3>
mov    %rbx,%r9
mov    %eax,%edi
lea    -0x1(%rdi),%rsi
mov    %edi,%r8d
and    $0x3,%r8d
cmp    $0x3,%rsi
jae    1193 <suffixtree_find_prefix+0x63>
xor    %esi,%esi
jmp    11d8 <suffixtree_find_prefix+0xa8>
and    $0xfffffffc,%edi
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
mov    (%rcx,%rsi,8),%rbx
mov    0x8(%rcx,%rsi,8),%rbp
xor    %edx,%edx
cmpb   $0x0,(%rbx)
sete   %dl
cmpb   $0x1,0x0(%rbp)
sbb    %edx,%eax
mov    0x10(%rcx,%rsi,8),%rdx
xor    %ebp,%ebp
cmpb   $0x0,(%rdx)
sete   %bpl
mov    0x18(%rcx,%rsi,8),%rdx
cmpb   $0x1,(%rdx)
sbb    %ebp,%eax
add    $0x4,%rsi
cmp    %rsi,%rdi
jne    11a0 <suffixtree_find_prefix+0x70>
test   %r8,%r8
mov    %r9,%rbx
je     1203 <suffixtree_find_prefix+0xd3>
lea    (%rcx,%rsi,8),%rsi
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
mov    (%rsi,%rdi,8),%rdx
cmpb   $0x1,(%rdx)
sbb    $0x0,%eax
add    $0x1,%rdi
cmp    %rdi,%r8
jne    11f0 <suffixtree_find_prefix+0xc0>
xor    %edx,%edx
test   %eax,%eax
cmove  %rdx,%rcx
mov    %rcx,(%rsp)
mov    %r14,%rdi
mov    %r13,%rsi
xor    %edx,%edx
mov    %r12,%rcx
mov    %r15,%r8
mov    %rbx,%r9
call   1050 <_suffixtree_find_prefix@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rdi
call   1030 <FreeSplitList@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.suggest_input = type { i32 }
%struct.suffixtree = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c",\00"
define %struct.suggest_input** @suffixtree_find_prefix(%struct.suffixtree* %0, i8* %1, i8* %2, i8*** %3, i32* %4, i8* %5) {
%7 = alloca %struct.suffixtree*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8***
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i8**
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.suggest_input**
%17 = alloca i32
store %struct.suffixtree* %0, %struct.suffixtree** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8*** %3, i8**** %10
store i32* %4, i32** %11
store i8* %5, i8** %12
%18 = load i8*, i8** %12
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %12
br label %21
21: ; preds = %20, %6
%22 = load i8*, i8** %12
%23 = call i32 @split(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8*** %13)
store i32 %23, i32* %14
%24 = load i32, i32* %14
store i32 %24, i32* %15
store i32 0, i32* %17
br label %25
25: ; preds = %42, %21
%26 = load i32, i32* %17
%27 = load i32, i32* %15
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %45
29: ; preds = %25
%30 = load i8**, i8*** %13
%31 = load i32, i32* %17
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %29
%39 = load i32, i32* %14
%40 = add nsw i32 %39, -1
store i32 %40, i32* %14
br label %41
41: ; preds = %38, %29
br label %42
42: ; preds = %41
%43 = load i32, i32* %17
%44 = add nsw i32 %43, 1
store i32 %44, i32* %17
br label %25
45: ; preds = %25
%46 = load %struct.suffixtree*, %struct.suffixtree** %7
%47 = load i8*, i8** %8
%48 = load i8*, i8** %9
%49 = load i8***, i8**** %10
%50 = load i32*, i32** %11
%51 = load i32, i32* %14
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %45
br label %56
54: ; preds = %45
%55 = load i8**, i8*** %13
br label %56
56: ; preds = %54, %53
%57 = phi i8** [ null, %53 ], [ %55, %54 ]
%58 = call %struct.suggest_input** @_suffixtree_find_prefix(%struct.suffixtree* %46, i8* %47, i32 0, i8* %48, i8*** %49, i32* %50, i8** %57)
store %struct.suggest_input** %58, %struct.suggest_input*** %16
%59 = load i8**, i8*** %13
%60 = call i32 @FreeSplitList(i8** %59)
%61 = load %struct.suggest_input**, %struct.suggest_input*** %16
ret %struct.suggest_input** %61
}

LLVM IR (-O2):
%struct.suggest_input = type { i32 }
%struct.suffixtree = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c",\00"
define %struct.suggest_input** @suffixtree_find_prefix(%struct.suffixtree* %0, i8* %1, i8* %2, i8*** %3, i32* %4, i8* %5) {
%7 = alloca i8**
%8 = bitcast i8*** %7 to i8*
%9 = icmp eq i8* %5, null
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %5
%11 = call i32 @split(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8*** %7)
%12 = icmp sgt i32 %11, 0
%13 = load i8**, i8*** %7
br i1 %12, label %14, label %73
14: ; preds = %6
%15 = zext i32 %11 to i64
%16 = add nsw i64 %15, -1
%17 = and i64 %15, 3
%18 = icmp ult i64 %16, 3
br i1 %18, label %55, label %19
19: ; preds = %14
%20 = and i64 %15, 4294967292
br label %21
21: ; preds = %21, %19
%22 = phi i64 [ 0, %19 ], [ %52, %21 ]
%23 = phi i32 [ %11, %19 ], [ %51, %21 ]
%24 = phi i64 [ 0, %19 ], [ %53, %21 ]
%25 = getelementptr inbounds i8*, i8** %13, i64 %22
%26 = load i8*, i8** %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
%29 = sext i1 %28 to i32
%30 = add nsw i32 %23, %29
%31 = or i64 %22, 1
%32 = getelementptr inbounds i8*, i8** %13, i64 %31
%33 = load i8*, i8** %32
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
%36 = sext i1 %35 to i32
%37 = add nsw i32 %30, %36
%38 = or i64 %22, 2
%39 = getelementptr inbounds i8*, i8** %13, i64 %38
%40 = load i8*, i8** %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 0
%43 = sext i1 %42 to i32
%44 = add nsw i32 %37, %43
%45 = or i64 %22, 3
%46 = getelementptr inbounds i8*, i8** %13, i64 %45
%47 = load i8*, i8** %46
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 0
%50 = sext i1 %49 to i32
%51 = add nsw i32 %44, %50
%52 = add nuw nsw i64 %22, 4
%53 = add i64 %24, 4
%54 = icmp eq i64 %53, %20
br i1 %54, label %55, label %21
55: ; preds = %21, %14
%56 = phi i32 [ undef, %14 ], [ %51, %21 ]
%57 = phi i64 [ 0, %14 ], [ %52, %21 ]
%58 = phi i32 [ %11, %14 ], [ %51, %21 ]
%59 = icmp eq i64 %17, 0
br i1 %59, label %73, label %60
60: ; preds = %55, %60
%61 = phi i64 [ %70, %60 ], [ %57, %55 ]
%62 = phi i32 [ %69, %60 ], [ %58, %55 ]
%63 = phi i64 [ %71, %60 ], [ 0, %55 ]
%64 = getelementptr inbounds i8*, i8** %13, i64 %61
%65 = load i8*, i8** %64
%66 = load i8, i8* %65
%67 = icmp eq i8 %66, 0
%68 = sext i1 %67 to i32
%69 = add nsw i32 %62, %68
%70 = add nuw nsw i64 %61, 1
%71 = add i64 %63, 1
%72 = icmp eq i64 %71, %17
br i1 %72, label %73, label %60
73: ; preds = %55, %60, %6
%74 = phi i32 [ %11, %6 ], [ %56, %55 ], [ %69, %60 ]
%75 = icmp eq i32 %74, 0
%76 = select i1 %75, i8** null, i8** %13
%77 = call %struct.suggest_input** @_suffixtree_find_prefix(%struct.suffixtree* %0, i8* %1, i32 0, i8* %2, i8*** %3, i32* %4, i8** %76)
%78 = load i8**, i8*** %7
%79 = call i32 @FreeSplitList(i8** %78)
ret %struct.suggest_input** %77
}