#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 /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
char *xstrdup(char const *);
char *getconfpath(void *cfgdata, const char *section, const char *key,
                  int isnull, char *notfound, char *home, char *dir) {
  const char *cp;
  char *v, path[1024];
  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:
    if (cp[0] != '/') {
      path[0] = 0;
      if (home) {
        strcpy(path, home);
        strcat(path, "/");
      }
      if (dir) {
        strcat(path, dir);
        strcat(path, "/");
      }
      strcat(path, cp);
      v = xstrdup(path);
    } else {
      v = xstrdup(cp);
    }
    return v;
  }
}


x86 assembly (clang, -O0):
<getconfpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <get_key_value@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11d2 <getconfpath+0x72>
cmpl   $0x0,-0x24(%rbp)
jne    11d2 <getconfpath+0x72>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpq   $0x0,-0x40(%rbp)
jne    120c <getconfpath+0xac>
cmpl   $0x0,-0x24(%rbp)
je     120c <getconfpath+0xac>
cmpq   $0x0,-0x30(%rbp)
je     11ff <getconfpath+0x9f>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    1211 <getconfpath+0xb1>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12be <getconfpath+0x15e>
jmp    1211 <getconfpath+0xb1>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     12a9 <getconfpath+0x149>
movb   $0x0,-0x450(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1256 <getconfpath+0xf6>
lea    -0x450(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x450(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1070 <strcat@plt>
cmpq   $0x0,0x10(%rbp)
je     1284 <getconfpath+0x124>
lea    -0x450(%rbp),%rdi
mov    0x10(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x450(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x450(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x450(%rbp),%rdi
call   1060 <xstrdup@plt>
mov    %rax,-0x48(%rbp)
jmp    12b6 <getconfpath+0x156>
mov    -0x40(%rbp),%rdi
call   1060 <xstrdup@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getconfpath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %r9,%r15
mov    %r8,%r12
mov    %ecx,%r14d
mov    %rdx,%r13
mov    %rsi,%rbp
mov    0x450(%rsp),%rax
mov    %rax,0x8(%rsp)
xor    %ecx,%ecx
call   1040 <get_key_value@plt>
mov    %rax,%rbx
test   %r14d,%r14d
jne    11a5 <getconfpath+0x45>
test   %rbx,%rbx
je     1256 <getconfpath+0xf6>
test   %r14d,%r14d
je     11bb <getconfpath+0x5b>
test   %rbx,%rbx
jne    11bb <getconfpath+0x5b>
mov    %r12,%rbx
test   %r12,%r12
je     1242 <getconfpath+0xe2>
cmpb   $0x2f,(%rbx)
jne    11d9 <getconfpath+0x79>
mov    %rbx,%rdi
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <xstrdup@plt>
movb   $0x0,0x10(%rsp)
test   %r15,%r15
je     1202 <getconfpath+0xa2>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe25(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcat@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     1228 <getconfpath+0xc8>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <strcat@plt>
lea    0xdff(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcat@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
call   1060 <xstrdup@plt>
jmp    1244 <getconfpath+0xe4>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda3(%rip),%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

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

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