#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 llist_head {
  int dummy;
};

/* Variables and functions */
char *nubase_config_table_get(struct llist_head *, char *);
char *strdup(char *);
char *nubase_config_table_get_or_default(struct llist_head *config_table_list,
                                         char *key, char *replace) {
  char *str;
  str = nubase_config_table_get(config_table_list, key);
  if (str) {
    return strdup(str);
  } else if (replace) {
    return strdup(replace);
  } else {
    return strdup("");
  }
}


x86 assembly (clang, -O0):
<nubase_config_table_get_or_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <nubase_config_table_get@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1162 <nubase_config_table_get_or_default+0x42>
mov    -0x28(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    118f <nubase_config_table_get_or_default+0x6f>
cmpq   $0x0,-0x20(%rbp)
je     117f <nubase_config_table_get_or_default+0x5f>
mov    -0x20(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    118f <nubase_config_table_get_or_default+0x6f>
lea    0xe7a(%rip),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nubase_config_table_get_or_default>:
push   %rbx
mov    %rdx,%rbx
call   1030 <nubase_config_table_get@plt>
test   %rax,%rax
je     1137 <nubase_config_table_get_or_default+0x17>
mov    %rax,%rdi
pop    %rbx
jmp    1040 <strdup@plt>
test   %rbx,%rbx
je     1145 <nubase_config_table_get_or_default+0x25>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <strdup@plt>
lea    0xeb4(%rip),%rdi
pop    %rbx
jmp    1040 <strdup@plt>

LLVM IR (-O0):
%struct.llist_head = type { i32 }
@.str = [1 x i8] zeroinitializer
define i8* @nubase_config_table_get_or_default(%struct.llist_head* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca %struct.llist_head*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store %struct.llist_head* %0, %struct.llist_head** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load %struct.llist_head*, %struct.llist_head** %5
%10 = load i8*, i8** %6
%11 = call i8* @nubase_config_table_get(%struct.llist_head* %9, i8* %10)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i8*, i8** %8
%16 = call i8* @strdup(i8* %15)
store i8* %16, i8** %4
br label %25
17: ; preds = %3
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8*, i8** %7
%22 = call i8* @strdup(i8* %21)
store i8* %22, i8** %4
br label %25
23: ; preds = %17
%24 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %24, i8** %4
br label %25
25: ; preds = %23, %20, %14
%26 = load i8*, i8** %4
ret i8* %26
}

LLVM IR (-O2):
%struct.llist_head = type { i32 }
@.str = [1 x i8] zeroinitializer
define noalias i8* @nubase_config_table_get_or_default(%struct.llist_head* %0, i8* %1, i8* %2) {
%4 = tail call i8* @nubase_config_table_get(%struct.llist_head* %0, i8* %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i8* @strdup(i8* %4)
br label %14
8: ; preds = %3
%9 = icmp eq i8* %2, null
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i8* @strdup(i8* %2)
br label %14
12: ; preds = %8
%13 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %10, %6
%15 = phi i8* [ %7, %6 ], [ %11, %10 ], [ %13, %12 ]
ret i8* %15
}