#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*/ exit(int);
char *get_key_value(void *, char const *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *, char const *);
int strlen(char *);
char *xstrdup(char const *);
char *getconfdir(void *cfgdata, const char *section, const char *key,
                 int isnull, char *notfound) {
  const char *cp;
  char *v;
  cp = get_key_value(cfgdata, section, key, NULL);
  if (!cp && !isnull) {
    printf("Config Item: [%s] %s: not set\n", section, key);
    exit(1);
  } else if (!cp && isnull) {
    if (notfound) {
      cp = notfound;
      goto process;
    } else
      return notfound;
  } else {
  process:
    v = xstrdup(cp);
    if (v[strlen(v) - 1] == '/')
      v[strlen(v) - 1] = 0;
    return v;
  }
}


x86 assembly (clang, -O0):
<getconfdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <get_key_value@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11b7 <getconfdir+0x67>
cmpl   $0x0,-0x24(%rbp)
jne    11b7 <getconfdir+0x67>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpq   $0x0,-0x38(%rbp)
jne    11f1 <getconfdir+0xa1>
cmpl   $0x0,-0x24(%rbp)
je     11f1 <getconfdir+0xa1>
cmpq   $0x0,-0x30(%rbp)
je     11e4 <getconfdir+0x94>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    11f6 <getconfdir+0xa6>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1256 <getconfdir+0x106>
jmp    11f6 <getconfdir+0xa6>
mov    -0x38(%rbp),%rdi
call   1060 <xstrdup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    124e <getconfdir+0xfe>
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getconfdir>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%rbx
xor    %ecx,%ecx
call   1030 <get_key_value@plt>
test   %ebp,%ebp
jne    1172 <getconfdir+0x22>
test   %rax,%rax
je     11c0 <getconfdir+0x70>
test   %ebp,%ebp
je     1183 <getconfdir+0x33>
test   %rax,%rax
jne    1183 <getconfdir+0x33>
mov    %r14,%rax
test   %r14,%r14
je     11b0 <getconfdir+0x60>
mov    %rax,%rdi
call   1060 <xstrdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    11b2 <getconfdir+0x62>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    11b2 <getconfdir+0x62>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe39(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Config Item: [%s] %s: not set\0A\00"
define i8* @getconfdir(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i8*, i8** %9
%17 = call i8* @get_key_value(i8* %14, i8* %15, i8* %16, i32* null)
store i8* %17, i8** %12
%18 = load i8*, i8** %12
%19 = icmp ne i8* %18, null
br i1 %19, label %28, label %20
20: ; preds = %5
%21 = load i32, i32* %10
%22 = icmp ne i32 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = load i8*, i8** %8
%25 = load i8*, i8** %9
%26 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %20, %5
%29 = load i8*, i8** %12
%30 = icmp ne i8* %29, null
br i1 %30, label %41, label %31
31: ; preds = %28
%32 = load i32, i32* %10
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = load i8*, i8** %11
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = load i8*, i8** %11
store i8* %38, i8** %12
br label %42
39: ; preds = %34
%40 = load i8*, i8** %11
store i8* %40, i8** %6
br label %63
41: ; preds = %31, %28
br label %42
42: ; preds = %41, %37
%43 = load i8*, i8** %12
%44 = call i8* @xstrdup(i8* %43)
store i8* %44, i8** %13
%45 = load i8*, i8** %13
%46 = load i8*, i8** %13
%47 = call i32 @strlen(i8* %46)
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %45, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 47
br i1 %53, label %54, label %61
54: ; preds = %42
%55 = load i8*, i8** %13
%56 = load i8*, i8** %13
%57 = call i32 @strlen(i8* %56)
%58 = sub nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %55, i64 %59
store i8 0, i8* %60
br label %61
61: ; preds = %54, %42
%62 = load i8*, i8** %13
store i8* %62, i8** %6
br label %63
63: ; preds = %61, %39
%64 = load i8*, i8** %6
ret i8* %64
}

LLVM IR (-O2):
@.str = [31 x i8] c"Config Item: [%s] %s: not set\0A\00"
define i8* @getconfdir(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = tail call i8* @get_key_value(i8* %0, i8* %1, i8* %2, i32* null)
%7 = icmp ne i8* %6, null
%8 = icmp ne i32 %3, 0
%9 = or i1 %8, %7
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %5
%14 = icmp eq i8* %6, null
%15 = and i1 %8, %14
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = icmp eq i8* %4, null
br i1 %17, label %32, label %18
18: ; preds = %16, %13
%19 = phi i8* [ %6, %13 ], [ %4, %16 ]
%20 = tail call i8* @xstrdup(i8* %19)
%21 = tail call i32 @strlen(i8* %20)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 47
br i1 %26, label %27, label %32
27: ; preds = %18
%28 = tail call i32 @strlen(i8* %20)
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %20, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %18, %27, %16
%33 = phi i8* [ null, %16 ], [ %20, %27 ], [ %20, %18 ]
ret i8* %33
}