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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
void *kitsune_get_cur_val(char const *);
char *kitsune_get_symbol_key(char const *, char const *, char const *,
                             char const *);
void *kitsune_lookup_key_new(char *);
void *stackvars_get_local_new(char const *, char const *);
void *kitsune_get_symbol_addr_new(const char *name, const char *funcname,
                                  const char *filename, const char *namespace) {
  if (funcname && !filename) {
    return stackvars_get_local_new(funcname, name);
  } else {
    char *key = kitsune_get_symbol_key(name, funcname, filename, namespace);
    void *result = kitsune_lookup_key_new(key);
    free(key);
    if (!result && !funcname && !filename && !namespace) {
      result = kitsune_get_cur_val(name);
    }
    return result;
  }
}


x86 assembly (clang, -O0):
<kitsune_get_symbol_addr_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1194 <kitsune_get_symbol_addr_new+0x44>
cmpq   $0x0,-0x20(%rbp)
jne    1194 <kitsune_get_symbol_addr_new+0x44>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <stackvars_get_local_new@plt>
mov    %rax,-0x8(%rbp)
jmp    1204 <kitsune_get_symbol_addr_new+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1070 <kitsune_get_symbol_key@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <kitsune_lookup_key_new@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x38(%rbp)
jne    11fc <kitsune_get_symbol_addr_new+0xac>
cmpq   $0x0,-0x18(%rbp)
jne    11fc <kitsune_get_symbol_addr_new+0xac>
cmpq   $0x0,-0x20(%rbp)
jne    11fc <kitsune_get_symbol_addr_new+0xac>
cmpq   $0x0,-0x28(%rbp)
jne    11fc <kitsune_get_symbol_addr_new+0xac>
mov    -0x10(%rbp),%rdi
call   1040 <kitsune_get_cur_val@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kitsune_get_symbol_addr_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rsi,%rsi
je     118a <kitsune_get_symbol_addr_new+0x3a>
test   %r15,%r15
jne    118a <kitsune_get_symbol_addr_new+0x3a>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <stackvars_get_local_new@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1070 <kitsune_get_symbol_key@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1060 <kitsune_lookup_key_new@plt>
mov    %rax,%r13
mov    %rbp,%rdi
call   1030 <free@plt>
test   %r12,%r12
jne    11db <kitsune_get_symbol_addr_new+0x8b>
test   %r15,%r15
jne    11db <kitsune_get_symbol_addr_new+0x8b>
test   %rbx,%rbx
jne    11db <kitsune_get_symbol_addr_new+0x8b>
test   %r13,%r13
jne    11db <kitsune_get_symbol_addr_new+0x8b>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <kitsune_get_cur_val@plt>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @kitsune_get_symbol_addr_new(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %21
14: ; preds = %4
%15 = load i8*, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i8*, i8** %7
%19 = load i8*, i8** %6
%20 = call i8* @stackvars_get_local_new(i8* %18, i8* %19)
store i8* %20, i8** %5
br label %47
21: ; preds = %14, %4
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = load i8*, i8** %8
%25 = load i8*, i8** %9
%26 = call i8* @kitsune_get_symbol_key(i8* %22, i8* %23, i8* %24, i8* %25)
store i8* %26, i8** %10
%27 = load i8*, i8** %10
%28 = call i8* @kitsune_lookup_key_new(i8* %27)
store i8* %28, i8** %11
%29 = load i8*, i8** %10
%30 = call i32 @free(i8* %29)
%31 = load i8*, i8** %11
%32 = icmp ne i8* %31, null
br i1 %32, label %45, label %33
33: ; preds = %21
%34 = load i8*, i8** %7
%35 = icmp ne i8* %34, null
br i1 %35, label %45, label %36
36: ; preds = %33
%37 = load i8*, i8** %8
%38 = icmp ne i8* %37, null
br i1 %38, label %45, label %39
39: ; preds = %36
%40 = load i8*, i8** %9
%41 = icmp ne i8* %40, null
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i8*, i8** %6
%44 = call i8* @kitsune_get_cur_val(i8* %43)
store i8* %44, i8** %11
br label %45
45: ; preds = %42, %39, %36, %33, %21
%46 = load i8*, i8** %11
store i8* %46, i8** %5
br label %47
47: ; preds = %45, %17
%48 = load i8*, i8** %5
ret i8* %48
}

LLVM IR (-O2):
define i8* @kitsune_get_symbol_addr_new(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = icmp eq i8* %1, null
%6 = icmp ne i8* %2, null
%7 = or i1 %5, %6
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i8* @stackvars_get_local_new(i8* %1, i8* %0)
br label %22
10: ; preds = %4
%11 = tail call i8* @kitsune_get_symbol_key(i8* %0, i8* %1, i8* %2, i8* %3)
%12 = tail call i8* @kitsune_lookup_key_new(i8* %11)
%13 = tail call i32 @free(i8* %11)
%14 = icmp ne i8* %12, null
%15 = icmp ne i8* %1, null
%16 = or i1 %15, %14
%17 = or i1 %6, %16
%18 = icmp ne i8* %3, null
%19 = or i1 %18, %17
br i1 %19, label %22, label %20
20: ; preds = %10
%21 = tail call i8* @kitsune_get_cur_val(i8* %0)
br label %22
22: ; preds = %10, %20, %8
%23 = phi i8* [ %9, %8 ], [ %12, %10 ], [ %21, %20 ]
ret i8* %23
}