#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 TrieNode {
  int dummy;
};
struct Trie {
  int dummy;
};
struct List {
  int dummy;
};

/* Variables and functions */
struct List *list_alloc(int /*<<< orphan*/ *);
unsigned short strlen(char *);
struct TrieNode *trie_root(struct Trie *);
int /*<<< orphan*/ trie_search1(struct TrieNode *, char *, unsigned short,
                                unsigned short, struct List *);
struct List *trie_search(struct Trie *trie, char *keys) {
  unsigned short key_idx = 0;
  unsigned short key_len = strlen(keys);
  struct TrieNode *node = trie_root(trie);
  struct List *result = list_alloc(NULL);
  trie_search1(node, keys, key_idx, key_len, result);
  return result;
}


x86 assembly (clang, -O0):
<trie_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %ax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <trie_root@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <list_alloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x12(%rbp),%cx
mov    -0x14(%rbp),%ax
mov    -0x28(%rbp),%r8
movzwl %cx,%edx
movzwl %ax,%ecx
call   1050 <trie_search1@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trie_search>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <trie_root@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1060 <list_alloc@plt>
mov    %rax,%rbp
movzwl %r15w,%ecx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    %rax,%r8
call   1050 <trie_search1@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.List = type { i32 }
%struct.Trie = type { i32 }
%struct.TrieNode = type { i32 }
define %struct.List* @trie_search(%struct.Trie* %0, i8* %1) {
%3 = alloca %struct.Trie*
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i16
%7 = alloca %struct.TrieNode*
%8 = alloca %struct.List*
store %struct.Trie* %0, %struct.Trie** %3
store i8* %1, i8** %4
store i16 0, i16* %5
%9 = load i8*, i8** %4
%10 = call zeroext i16 @strlen(i8* %9)
store i16 %10, i16* %6
%11 = load %struct.Trie*, %struct.Trie** %3
%12 = call %struct.TrieNode* @trie_root(%struct.Trie* %11)
store %struct.TrieNode* %12, %struct.TrieNode** %7
%13 = call %struct.List* @list_alloc(i32* null)
store %struct.List* %13, %struct.List** %8
%14 = load %struct.TrieNode*, %struct.TrieNode** %7
%15 = load i8*, i8** %4
%16 = load i16, i16* %5
%17 = load i16, i16* %6
%18 = load %struct.List*, %struct.List** %8
%19 = call i32 @trie_search1(%struct.TrieNode* %14, i8* %15, i16 zeroext %16, i16 zeroext %17, %struct.List* %18)
%20 = load %struct.List*, %struct.List** %8
ret %struct.List* %20
}

LLVM IR (-O2):
%struct.List = type { i32 }
%struct.Trie = type { i32 }
%struct.TrieNode = type { i32 }
define %struct.List* @trie_search(%struct.Trie* %0, i8* %1) {
%3 = tail call zeroext i16 @strlen(i8* %1)
%4 = tail call %struct.TrieNode* @trie_root(%struct.Trie* %0)
%5 = tail call %struct.List* @list_alloc(i32* null)
%6 = tail call i32 @trie_search1(%struct.TrieNode* %4, i8* %1, i16 zeroext 0, i16 zeroext %3, %struct.List* %5)
ret %struct.List* %5
}