#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 cfg_section {
  int dummy;
};
struct cfg_domain {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cfg_del_entry(char *, char *, char *);
struct cfg_domain *cfg_get_domain(char *);
struct cfg_section *cfg_get_section(struct cfg_domain *, char *);
int /*<<< orphan*/ cfg_set_entry(struct cfg_section *, char *, char const *);
void cfg_set_str(char *dname, char *sname, char *ename, const char *value) {
  struct cfg_domain *domain = NULL;
  struct cfg_section *section = NULL;
  if (NULL == value) {
    cfg_del_entry(dname, sname, ename);
  } else {
    domain = cfg_get_domain(dname);
    section = cfg_get_section(domain, sname);
    cfg_set_entry(section, ename, value);
  }
}


x86 assembly (clang, -O0):
<cfg_set_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    118a <cfg_set_str+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <cfg_del_entry@plt>
jmp    11b9 <cfg_set_str+0x79>
mov    -0x8(%rbp),%rdi
call   1060 <cfg_get_domain@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <cfg_get_section@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <cfg_set_entry@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_set_str>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
test   %rcx,%rcx
je     1176 <cfg_set_str+0x36>
mov    %rcx,%rbx
call   1060 <cfg_get_domain@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <cfg_get_section@plt>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <cfg_set_entry@plt>
mov    %r15,%rsi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <cfg_del_entry@plt>

LLVM IR (-O0):
%struct.cfg_domain = type { i32 }
%struct.cfg_section = type { i32 }
define void @cfg_set_str(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.cfg_domain*
%10 = alloca %struct.cfg_section*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store %struct.cfg_domain* null, %struct.cfg_domain** %9
store %struct.cfg_section* null, %struct.cfg_section** %10
%11 = load i8*, i8** %8
%12 = icmp eq i8* null, %11
br i1 %12, label %13, label %18
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = call i32 @cfg_del_entry(i8* %14, i8* %15, i8* %16)
br label %28
18: ; preds = %4
%19 = load i8*, i8** %5
%20 = call %struct.cfg_domain* @cfg_get_domain(i8* %19)
store %struct.cfg_domain* %20, %struct.cfg_domain** %9
%21 = load %struct.cfg_domain*, %struct.cfg_domain** %9
%22 = load i8*, i8** %6
%23 = call %struct.cfg_section* @cfg_get_section(%struct.cfg_domain* %21, i8* %22)
store %struct.cfg_section* %23, %struct.cfg_section** %10
%24 = load %struct.cfg_section*, %struct.cfg_section** %10
%25 = load i8*, i8** %7
%26 = load i8*, i8** %8
%27 = call i32 @cfg_set_entry(%struct.cfg_section* %24, i8* %25, i8* %26)
br label %28
28: ; preds = %18, %13
ret void
}

LLVM IR (-O2):
%struct.cfg_domain = type { i32 }
%struct.cfg_section = type { i32 }
define void @cfg_set_str(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = icmp eq i8* %3, null
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @cfg_del_entry(i8* %0, i8* %1, i8* %2)
br label %12
8: ; preds = %4
%9 = tail call %struct.cfg_domain* @cfg_get_domain(i8* %0)
%10 = tail call %struct.cfg_section* @cfg_get_section(%struct.cfg_domain* %9, i8* %1)
%11 = tail call i32 @cfg_set_entry(%struct.cfg_section* %10, i8* %2, i8* %3)
br label %12
12: ; preds = %8, %6
ret void
}