#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*/ opt_add_item(char const *, char const *, char const *,
                                int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *opt_get_string(char const *, char const *,
                                   int /*<<< orphan*/ *);
int /*<<< orphan*/ opt_set_item(char const *, char const *, char const *,
                                int /*<<< orphan*/ *, int);
void opt_set_string(const char *section, const char *key, const char *value) {
  if (opt_get_string(section, key, NULL) == NULL)
    opt_add_item(section, key, value, NULL, 1);
  opt_set_item(section, key, value, NULL, 1);
}


x86 assembly (clang, -O0):
<opt_set_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <opt_get_string@plt>
cmp    $0x0,%rax
jne    117a <opt_set_string+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x1,%r8d
call   1040 <opt_add_item@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x1,%r8d
call   1030 <opt_set_item@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt_set_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edx,%edx
call   1050 <opt_get_string@plt>
test   %rax,%rax
jne    1160 <opt_set_string+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1040 <opt_add_item@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    $0x1,%r8d
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <opt_set_item@plt>

LLVM IR (-O0):
define void @opt_set_string(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i32* @opt_get_string(i8* %7, i8* %8, i32* null)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i32 @opt_add_item(i8* %12, i8* %13, i8* %14, i32* null, i32 1)
br label %16
16: ; preds = %11, %3
%17 = load i8*, i8** %4
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = call i32 @opt_set_item(i8* %17, i8* %18, i8* %19, i32* null, i32 1)
ret void
}

LLVM IR (-O2):
define void @opt_set_string(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32* @opt_get_string(i8* %0, i8* %1, i32* null)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @opt_add_item(i8* %0, i8* %1, i8* %2, i32* null, i32 1)
br label %8
8: ; preds = %6, %3
%9 = tail call i32 @opt_set_item(i8* %0, i8* %1, i8* %2, i32* null, i32 1)
ret void
}