#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 index_value {
  int dummy;
};
struct index_node_f {
  int dummy;
};
struct index_file {
  int dummy;
};
struct buffer {
  int dummy;
};

/* Variables and functions */
struct buffer *buf_create();
int /*<<< orphan*/ buf_destroy(struct buffer *);
struct index_node_f *index_readroot(struct index_file *);
int /*<<< orphan*/ index_searchwild__node(struct index_node_f *,
                                          struct buffer *, char const *,
                                          int /*<<< orphan*/,
                                          struct index_value **);
struct index_value *index_searchwild(struct index_file *in, const char *key) {
  struct index_node_f *root = index_readroot(in);
  struct buffer *buf = buf_create();
  struct index_value *out = NULL;
  index_searchwild__node(root, buf, key, 0, &out);
  buf_destroy(buf);
  return out;
}


x86 assembly (clang, -O0):
<index_searchwild>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <index_readroot@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <buf_create@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %ecx,%ecx
lea    -0x28(%rbp),%r8
call   1040 <index_searchwild__node@plt>
mov    -0x20(%rbp),%rdi
call   1060 <buf_destroy@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<index_searchwild>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
call   1050 <index_readroot@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1030 <buf_create@plt>
mov    %rax,%rbx
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%r8
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1040 <index_searchwild__node@plt>
mov    %rbx,%rdi
call   1060 <buf_destroy@plt>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.index_value = type { i32 }
%struct.index_file = type { i32 }
%struct.index_node_f = type { i32 }
%struct.buffer = type { i32 }
define %struct.index_value* @index_searchwild(%struct.index_file* %0, i8* %1) {
%3 = alloca %struct.index_file*
%4 = alloca i8*
%5 = alloca %struct.index_node_f*
%6 = alloca %struct.buffer*
%7 = alloca %struct.index_value*
store %struct.index_file* %0, %struct.index_file** %3
store i8* %1, i8** %4
%8 = load %struct.index_file*, %struct.index_file** %3
%9 = call %struct.index_node_f* @index_readroot(%struct.index_file* %8)
store %struct.index_node_f* %9, %struct.index_node_f** %5
%10 = call %struct.buffer* (...) @buf_create()
store %struct.buffer* %10, %struct.buffer** %6
store %struct.index_value* null, %struct.index_value** %7
%11 = load %struct.index_node_f*, %struct.index_node_f** %5
%12 = load %struct.buffer*, %struct.buffer** %6
%13 = load i8*, i8** %4
%14 = call i32 @index_searchwild__node(%struct.index_node_f* %11, %struct.buffer* %12, i8* %13, i32 0, %struct.index_value** %7)
%15 = load %struct.buffer*, %struct.buffer** %6
%16 = call i32 @buf_destroy(%struct.buffer* %15)
%17 = load %struct.index_value*, %struct.index_value** %7
ret %struct.index_value* %17
}

LLVM IR (-O2):
%struct.index_value = type { i32 }
%struct.index_file = type { i32 }
%struct.index_node_f = type { i32 }
%struct.buffer = type { i32 }
define %struct.index_value* @index_searchwild(%struct.index_file* %0, i8* %1) {
%3 = alloca %struct.index_value*
%4 = tail call %struct.index_node_f* @index_readroot(%struct.index_file* %0)
%5 = tail call %struct.buffer* (...) @buf_create()
%6 = bitcast %struct.index_value** %3 to i8*
store %struct.index_value* null, %struct.index_value** %3
%7 = call i32 @index_searchwild__node(%struct.index_node_f* %4, %struct.buffer* %5, i8* %1, i32 0, %struct.index_value** %3)
%8 = call i32 @buf_destroy(%struct.buffer* %5)
%9 = load %struct.index_value*, %struct.index_value** %3
ret %struct.index_value* %9
}