#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 ENOMEM;
int /*<<< orphan*/ assert(void *);
int /*<<< orphan*/ free(char *);
scalar_t__ isempty(char const *);
char *strdup(char const *);
int config_parse_string(const char *filename, unsigned line,
                        const char *section, const char *lvalue, int ltype,
                        const char *rvalue, void *data) {
  char **s = data, *n;
  assert(filename);
  assert(lvalue);
  assert(rvalue);
  assert(data);
  if (isempty(rvalue))
    n = NULL;
  else {
    n = strdup(rvalue);
    if (!n)
      return -ENOMEM;
  }
  free(*s);
  *s = n;
  return 0;
}


x86 assembly (clang, -O0):
<config_parse_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x38(%rbp),%rdi
call   1040 <assert@plt>
mov    0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x38(%rbp),%rdi
call   1060 <isempty@plt>
cmp    $0x0,%rax
je     11af <config_parse_string+0x6f>
movq   $0x0,-0x48(%rbp)
jmp    11df <config_parse_string+0x9f>
mov    -0x38(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11da <config_parse_string+0x9a>
xor    %eax,%eax
mov    0x2e10(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <config_parse_string+0xbd>
jmp    11df <config_parse_string+0x9f>
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_parse_string>:
push   %r15
push   %r14
push   %rbx
mov    %r9,%rbx
mov    %rcx,%r15
mov    0x20(%rsp),%r14
call   1040 <assert@plt>
mov    %r15,%rdi
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1040 <assert@plt>
mov    %r14,%rdi
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1060 <isempty@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     1181 <config_parse_string+0x41>
xor    %ebx,%ebx
jmp    1191 <config_parse_string+0x51>
mov    %rbx,%rdi
call   1050 <strdup@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a5 <config_parse_string+0x65>
mov    (%r14),%rdi
call   1030 <free@plt>
mov    %rbx,(%r14)
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e34(%rip),%rax
xor    %r15d,%r15d
sub    (%rax),%r15d
jmp    119c <config_parse_string+0x5c>

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

LLVM IR (-O2):
@ENOMEM = global i32 0
define i32 @config_parse_string(i8* %0, i32 %1, i8* nocapture readnone %2, i8* %3, i32 %4, i8* %5, i8* %6) {
%8 = bitcast i8* %6 to i8**
%9 = tail call i32 @assert(i8* %0)
%10 = tail call i32 @assert(i8* %3)
%11 = tail call i32 @assert(i8* %5)
%12 = tail call i32 @assert(i8* %6)
%13 = tail call i64 @isempty(i8* %5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %7
%16 = tail call i8* @strdup(i8* %5)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @ENOMEM
%20 = sub nsw i32 0, %19
br label %25
21: ; preds = %7, %15
%22 = phi i8* [ %16, %15 ], [ null, %7 ]
%23 = load i8*, i8** %8
%24 = tail call i32 @free(i8* %23)
store i8* %22, i8** %8
br label %25
25: ; preds = %21, %18
%26 = phi i32 [ 0, %21 ], [ %20, %18 ]
ret i32 %26
}