#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 configuration_entry {
  int dummy;
};
struct configuration {
  int dummy;
};

/* Variables and functions */
int add_configuration_entry(struct configuration *,
                            struct configuration_entry *);
int /*<<< orphan*/ assert(int);
struct configuration_entry *configuration_find_entry(struct configuration *,
                                                     char const *);
struct configuration_entry *create_def_configuration_entry(char const *);
struct configuration_entry *find_create_entry(struct configuration *config,
                                              const char *entry_name) {
  struct configuration_entry *entry = NULL;
  int res;
  (void)0;
  entry = configuration_find_entry(config, entry_name);
  if (entry == NULL) {
    entry = create_def_configuration_entry(entry_name);
    assert(entry != NULL);
    res = add_configuration_entry(config, entry);
    assert(res == 0);
  }
  (void)0;
  return (entry);
}


x86 assembly (clang, -O0):
<find_create_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <configuration_find_entry@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b4 <find_create_entry+0x74>
mov    -0x10(%rbp),%rdi
call   1050 <create_def_configuration_entry@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <add_configuration_entry@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_create_entry>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1060 <configuration_find_entry@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1189 <find_create_entry+0x49>
mov    %r15,%rdi
call   1050 <create_def_configuration_entry@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <add_configuration_entry@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.configuration_entry = type { i32 }
%struct.configuration = type { i32 }
define %struct.configuration_entry* @find_create_entry(%struct.configuration* %0, i8* %1) {
%3 = alloca %struct.configuration*
%4 = alloca i8*
%5 = alloca %struct.configuration_entry*
%6 = alloca i32
store %struct.configuration* %0, %struct.configuration** %3
store i8* %1, i8** %4
store %struct.configuration_entry* null, %struct.configuration_entry** %5
%7 = load %struct.configuration*, %struct.configuration** %3
%8 = load i8*, i8** %4
%9 = call %struct.configuration_entry* @configuration_find_entry(%struct.configuration* %7, i8* %8)
store %struct.configuration_entry* %9, %struct.configuration_entry** %5
%10 = load %struct.configuration_entry*, %struct.configuration_entry** %5
%11 = icmp eq %struct.configuration_entry* %10, null
br i1 %11, label %12, label %26
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call %struct.configuration_entry* @create_def_configuration_entry(i8* %13)
store %struct.configuration_entry* %14, %struct.configuration_entry** %5
%15 = load %struct.configuration_entry*, %struct.configuration_entry** %5
%16 = icmp ne %struct.configuration_entry* %15, null
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load %struct.configuration*, %struct.configuration** %3
%20 = load %struct.configuration_entry*, %struct.configuration_entry** %5
%21 = call i32 @add_configuration_entry(%struct.configuration* %19, %struct.configuration_entry* %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
br label %26
26: ; preds = %12, %2
%27 = load %struct.configuration_entry*, %struct.configuration_entry** %5
ret %struct.configuration_entry* %27
}

LLVM IR (-O2):
%struct.configuration_entry = type { i32 }
%struct.configuration = type { i32 }
define %struct.configuration_entry* @find_create_entry(%struct.configuration* %0, i8* %1) {
%3 = tail call %struct.configuration_entry* @configuration_find_entry(%struct.configuration* %0, i8* %1)
%4 = icmp eq %struct.configuration_entry* %3, null
br i1 %4, label %5, label %14
5: ; preds = %2
%6 = tail call %struct.configuration_entry* @create_def_configuration_entry(i8* %1)
%7 = icmp ne %struct.configuration_entry* %6, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @add_configuration_entry(%struct.configuration* %0, %struct.configuration_entry* %6)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
br label %14
14: ; preds = %5, %2
%15 = phi %struct.configuration_entry* [ %6, %5 ], [ %3, %2 ]
ret %struct.configuration_entry* %15
}