#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *get_conf_file();
char *malloc(int);
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
char *get_conf_value(char *label) {
  FILE *conf;
  char *ret, *tempbuffer, *file;
  file = get_conf_file();
  if ((conf = fopen(file, "r")) == NULL) {
    free(file);
    return NULL;
  }
  tempbuffer = malloc(256);
  while (!feof(conf)) {
    fgets(tempbuffer, 256, conf);
    if (strchr(tempbuffer, '#') != NULL)
      *strchr(tempbuffer, '#') = '\0';
    if (strncmp(tempbuffer, label, strlen(label)) == 0 &&
        strstr(tempbuffer, ": ") != NULL) {
      ret = malloc(strlen(strstr(tempbuffer, ": ")) - 1);
      strncpy(ret, strstr(tempbuffer, ": ") + 2,
              strlen(strstr(tempbuffer, ": ")) - 1);
      if (ret[strlen(ret) - 1] = '\n')
        ret[strlen(ret) - 1] = '\0';
      return ret;
    }
  }
  free(tempbuffer);
  free(file);
  return NULL;
}


x86 assembly (clang, -O0):
<get_conf_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <get_conf_file@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11fb <get_conf_value+0x4b>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    139b <get_conf_value+0x1eb>
mov    $0x100,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1227 <get_conf_value+0x77>
jmp    1381 <get_conf_value+0x1d1>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1090 <fgets@plt>
mov    -0x28(%rbp),%rdi
mov    $0x23,%esi
call   1080 <strchr@plt>
cmp    $0x0,%rax
je     1262 <get_conf_value+0xb2>
mov    -0x28(%rbp),%rdi
mov    $0x23,%esi
call   1080 <strchr@plt>
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1060 <strncmp@plt>
cmp    $0x0,%rax
jne    137c <get_conf_value+0x1cc>
mov    -0x28(%rbp),%rdi
lea    0xd63(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     137c <get_conf_value+0x1cc>
mov    -0x28(%rbp),%rdi
lea    0xd49(%rip),%rsi
call   10d0 <strstr@plt>
mov    %rax,%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
sub    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xd1b(%rip),%rsi
call   10d0 <strstr@plt>
add    $0x2,%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xd03(%rip),%rsi
call   10d0 <strstr@plt>
mov    %rax,%rdi
call   1070 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
sub    $0x1,%edx
call   1050 <strncpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xa,(%rax,%rcx,1)
mov    $0x1,%al
test   $0x1,%al
jne    134e <get_conf_value+0x19e>
jmp    136f <get_conf_value+0x1bf>
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    139b <get_conf_value+0x1eb>
jmp    1209 <get_conf_value+0x59>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_conf_value>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <get_conf_file@plt>
mov    %rax,%r14
lea    0xe33(%rip),%rsi
mov    %rax,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     11fe <get_conf_value+0x4e>
mov    %rax,%r12
mov    $0x100,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
je     1216 <get_conf_value+0x66>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xde5(%rip),%r13
jmp    122c <get_conf_value+0x7c>
nop
mov    %r12,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    11f6 <get_conf_value+0x46>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
mov    %rbx,%rdi
mov    $0x23,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     1251 <get_conf_value+0xa1>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1060 <strncmp@plt>
test   %rax,%rax
jne    1220 <get_conf_value+0x70>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
je     1220 <get_conf_value+0x70>
mov    %rax,%rdi
call   1070 <strlen@plt>
lea    -0x1(%rax),%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
lea    0xd6d(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strstr@plt>
lea    0x2(%rax),%rbx
mov    %rax,%rdi
call   1070 <strlen@plt>
lea    -0x1(%rax),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strncpy@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
movb   $0xa,-0x1(%rax,%r14,1)
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
jmp    1209 <get_conf_value+0x59>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c": \00"
define i8* @get_conf_value(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
%8 = call i8* (...) @get_conf_file()
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i8*, i8** %7
%14 = call i32 @free(i8* %13)
store i8* null, i8** %2
br label %79
15: ; preds = %1
%16 = call i8* @malloc(i32 256)
store i8* %16, i8** %6
br label %17
17: ; preds = %73, %15
%18 = load i32*, i32** %4
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %74
22: ; preds = %17
%23 = load i8*, i8** %6
%24 = load i32*, i32** %4
%25 = call i32 @fgets(i8* %23, i32 256, i32* %24)
%26 = load i8*, i8** %6
%27 = call i8* @strchr(i8* %26, i8 signext 35)
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i8*, i8** %6
%31 = call i8* @strchr(i8* %30, i8 signext 35)
store i8 0, i8* %31
br label %32
32: ; preds = %29, %22
%33 = load i8*, i8** %6
%34 = load i8*, i8** %3
%35 = load i8*, i8** %3
%36 = call i32 @strlen(i8* %35)
%37 = call i64 @strncmp(i8* %33, i8* %34, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %73
39: ; preds = %32
%40 = load i8*, i8** %6
%41 = call i8* @strstr(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %73
43: ; preds = %39
%44 = load i8*, i8** %6
%45 = call i8* @strstr(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%46 = call i32 @strlen(i8* %45)
%47 = sub nsw i32 %46, 1
%48 = call i8* @malloc(i32 %47)
store i8* %48, i8** %5
%49 = load i8*, i8** %5
%50 = load i8*, i8** %6
%51 = call i8* @strstr(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%52 = getelementptr inbounds i8, i8* %51, i64 2
%53 = load i8*, i8** %6
%54 = call i8* @strstr(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%55 = call i32 @strlen(i8* %54)
%56 = sub nsw i32 %55, 1
%57 = call i32 @strncpy(i8* %49, i8* %52, i32 %56)
%58 = load i8*, i8** %5
%59 = load i8*, i8** %5
%60 = call i32 @strlen(i8* %59)
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %58, i64 %62
store i8 10, i8* %63
br i1 true, label %64, label %71
64: ; preds = %43
%65 = load i8*, i8** %5
%66 = load i8*, i8** %5
%67 = call i32 @strlen(i8* %66)
%68 = sub nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %65, i64 %69
store i8 0, i8* %70
br label %71
71: ; preds = %64, %43
%72 = load i8*, i8** %5
store i8* %72, i8** %2
br label %79
73: ; preds = %39, %32
br label %17
74: ; preds = %17
%75 = load i8*, i8** %6
%76 = call i32 @free(i8* %75)
%77 = load i8*, i8** %7
%78 = call i32 @free(i8* %77)
store i8* null, i8** %2
br label %79
79: ; preds = %74, %71, %12
%80 = load i8*, i8** %2
ret i8* %80
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c": \00"
define i8* @get_conf_value(i8* %0) {
%2 = tail call i8* (...) @get_conf_file()
%3 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @free(i8* %2)
br label %46
7: ; preds = %1
%8 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%9 = tail call i32 @feof(i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %43
11: ; preds = %7, %40
%12 = tail call i32 @fgets(i8* %8, i32 256, i32* %3)
%13 = tail call i8* @strchr(i8* dereferenceable(1) %8, i8 signext 35)
%14 = icmp eq i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %11
store i8 0, i8* %13
br label %16
16: ; preds = %15, %11
%17 = tail call i32 @strlen(i8* %0)
%18 = tail call i64 @strncmp(i8* %8, i8* %0, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %40
20: ; preds = %16
%21 = tail call i8* @strstr(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %40, label %23
23: ; preds = %20
%24 = tail call i32 @strlen(i8* %21)
%25 = add nsw i32 %24, -1
%26 = tail call i8* @malloc(i32 %25)
%27 = tail call i8* @strstr(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds i8, i8* %27, i64 2
%29 = tail call i32 @strlen(i8* %27)
%30 = add nsw i32 %29, -1
%31 = tail call i32 @strncpy(i8* %26, i8* %28, i32 %30)
%32 = tail call i32 @strlen(i8* %26)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %26, i64 %34
store i8 10, i8* %35
%36 = tail call i32 @strlen(i8* %26)
%37 = add nsw i32 %36, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %26, i64 %38
store i8 0, i8* %39
br label %46
40: ; preds = %20, %16
%41 = tail call i32 @feof(i32* %3)
%42 = icmp eq i32 %41, 0
br i1 %42, label %11, label %43
43: ; preds = %40, %7
%44 = tail call i32 @free(i8* %8)
%45 = tail call i32 @free(i8* %2)
br label %46
46: ; preds = %43, %23, %5
%47 = phi i8* [ null, %5 ], [ %26, %23 ], [ null, %43 ]
ret i8* %47
}