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

/* Variables and functions */
int /*<<< orphan*/ config_set(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtrim(char *);
bool config_load(const char *fname) {
  char buf[(1 << 9)], group[(1 << 9)], fullname[((1 << 9) * 2) + 2], *name,
      *ptr;
  FILE *f;
  bool have_group;
  if (!(f = fopen(fname, "r")))
    return false;
  have_group = false;
  while (1) {
    if (!fgets(buf, sizeof(buf), f))
      break;
    ptr = strtrim(buf);
    switch (*ptr) {
    case '#':
      break;
    case '[':
      ptr = strtrim(ptr + 1);
      for (name = ptr; *ptr && *ptr != ']'; ptr++)
        continue;
      if (*ptr)
        *ptr++ = 0;
      strcpy(group, strtrim(name));
      if (!strcmp(group, "cloudfs"))
        have_group = false;
      else
        have_group = true;
      break;
    default:
      for (name = ptr; *ptr && *ptr != '='; ptr++)
        continue;
      if (*ptr)
        *ptr++ = 0;
      ptr = strtrim(ptr);
      name = strtrim(name);
      if (!*name)
        break;
      if (have_group) {
        snprintf(fullname, sizeof(fullname), "%s-%s", group, name);
        config_set(fullname, ptr);
      } else {
        config_set(name, ptr);
      }
      break;
    }
  }
  fclose(f);
  return true;
}


x86 assembly (clang, -O0):
<config_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x838(%rbp)
cmp    $0x0,%rax
jne    11bc <config_load+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1492 <config_load+0x312>
movl   $0x0,-0x83c(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x838(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%eax
jne    11ec <config_load+0x6c>
jmp    147f <config_load+0x2ff>
lea    -0x210(%rbp),%rdi
call   1080 <strtrim@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x840(%rbp)
sub    $0x23,%eax
je     1231 <config_load+0xb1>
jmp    121d <config_load+0x9d>
mov    -0x840(%rbp),%eax
sub    $0x5b,%eax
je     1236 <config_load+0xb6>
jmp    1346 <config_load+0x1c6>
jmp    147a <config_load+0x2fa>
mov    -0x830(%rbp),%rdi
add    $0x1,%rdi
call   1080 <strtrim@plt>
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    -0x830(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x841(%rbp)
je     128c <config_load+0x10c>
mov    -0x830(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
setne  %al
mov    %al,-0x841(%rbp)
mov    -0x841(%rbp),%al
test   $0x1,%al
jne    129f <config_load+0x11f>
jmp    12bb <config_load+0x13b>
jmp    12a4 <config_load+0x124>
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    125b <config_load+0xdb>
mov    -0x830(%rbp),%rax
cmpb   $0x0,(%rax)
je     12e3 <config_load+0x163>
mov    -0x830(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x830(%rbp)
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rax
mov    %rax,-0x850(%rbp)
mov    -0x828(%rbp),%rdi
call   1080 <strtrim@plt>
mov    -0x850(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xce8(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1337 <config_load+0x1b7>
movl   $0x0,-0x83c(%rbp)
jmp    1341 <config_load+0x1c1>
movl   $0x1,-0x83c(%rbp)
jmp    147a <config_load+0x2fa>
mov    -0x830(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    -0x830(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x851(%rbp)
je     1385 <config_load+0x205>
mov    -0x830(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
setne  %al
mov    %al,-0x851(%rbp)
mov    -0x851(%rbp),%al
test   $0x1,%al
jne    1398 <config_load+0x218>
jmp    13b4 <config_load+0x234>
jmp    139d <config_load+0x21d>
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    1354 <config_load+0x1d4>
mov    -0x830(%rbp),%rax
cmpb   $0x0,(%rax)
je     13dc <config_load+0x25c>
mov    -0x830(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x830(%rbp)
movb   $0x0,(%rax)
mov    -0x830(%rbp),%rdi
call   1080 <strtrim@plt>
mov    %rax,-0x830(%rbp)
mov    -0x828(%rbp),%rdi
call   1080 <strtrim@plt>
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1417 <config_load+0x297>
jmp    147a <config_load+0x2fa>
cmpl   $0x0,-0x83c(%rbp)
je     1462 <config_load+0x2e2>
lea    -0x820(%rbp),%rdi
lea    -0x410(%rbp),%rcx
mov    -0x828(%rbp),%r8
mov    $0x402,%esi
lea    0xbc5(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   10a0 <config_set@plt>
jmp    1475 <config_load+0x2f5>
mov    -0x828(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   10a0 <config_set@plt>
jmp    147a <config_load+0x2fa>
jmp    11c6 <config_load+0x46>
mov    -0x838(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_load>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
lea    0xe78(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1303 <config_load+0x193>
mov    %rax,%rbx
lea    0x200(%rsp),%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %eax,%eax
je     12f4 <config_load+0x184>
xor    %r13d,%r13d
lea    0x200(%rsp),%r14
mov    %rsp,%r15
jmp    1209 <config_load+0x99>
movb   $0x0,(%rcx)
mov    %rax,%rdi
call   1070 <strtrim@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %r13d,%r13d
movabs $0x736664756f6c63,%rax
cmp    %rax,(%rsp)
setne  %r13b
mov    %r14,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %eax,%eax
je     12f4 <config_load+0x184>
mov    %r14,%rdi
call   1070 <strtrim@plt>
mov    %rax,%rbp
mov    (%rax),%al
movsbl %al,%ecx
cmp    $0x23,%ecx
je     11f1 <config_load+0x81>
cmp    $0x5b,%ecx
jne    1260 <config_load+0xf0>
add    $0x1,%rbp
mov    %rbp,%rdi
call   1070 <strtrim@plt>
mov    %rax,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rcx),%edx
test   %dl,%dl
je     11c9 <config_load+0x59>
cmp    $0x5d,%dl
je     11c6 <config_load+0x56>
add    $0x1,%rcx
jmp    1240 <config_load+0xd0>
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rdi
test   %al,%al
je     1281 <config_load+0x111>
cmp    $0x3d,%al
je     1287 <config_load+0x117>
movzbl (%rdi),%eax
jmp    1270 <config_load+0x100>
add    $0xffffffffffffffff,%rdi
jmp    128b <config_load+0x11b>
movb   $0x0,-0x1(%rdi)
call   1070 <strtrim@plt>
mov    %rax,%r12
mov    %rbp,%rdi
call   1070 <strtrim@plt>
cmpb   $0x0,(%rax)
je     11f1 <config_load+0x81>
test   %r13d,%r13d
je     12e1 <config_load+0x171>
lea    0x400(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x402,%esi
lea    0xd42(%rip),%rdx
mov    %r15,%rcx
mov    %rax,%r8
call   1050 <snprintf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1090 <config_set@plt>
mov    $0x1,%r13d
jmp    11f1 <config_load+0x81>
mov    %rax,%rdi
mov    %r12,%rsi
call   1090 <config_set@plt>
xor    %r13d,%r13d
jmp    11f1 <config_load+0x81>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
jmp    1305 <config_load+0x195>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"cloudfs\00"
@.str.2 = [6 x i8] c"%s-%s\00"
define i32 @config_load(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [1026 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
store i8* %0, i8** %3
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %9
%13 = icmp ne i32* %12, null
br i1 %13, label %15, label %14
14: ; preds = %1
store i32 0, i32* %2
br label %122
15: ; preds = %1
store i32 0, i32* %10
br label %16
16: ; preds = %15, %118
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%18 = load i32*, i32** %9
%19 = call i32 @fgets(i8* %17, i32 512, i32* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %16
br label %119
22: ; preds = %16
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%24 = call i8* @strtrim(i8* %23)
store i8* %24, i8** %8
%25 = load i8*, i8** %8
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
switch i32 %27, label %68 [
i32 35, label %28
i32 91, label %29
]
28: ; preds = %22
br label %118
29: ; preds = %22
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = call i8* @strtrim(i8* %31)
store i8* %32, i8** %8
%33 = load i8*, i8** %8
store i8* %33, i8** %7
br label %34
34: ; preds = %47, %29
%35 = load i8*, i8** %8
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %34
%40 = load i8*, i8** %8
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 93
br label %44
44: ; preds = %39, %34
%45 = phi i1 [ false, %34 ], [ %43, %39 ]
br i1 %45, label %46, label %50
46: ; preds = %44
br label %47
47: ; preds = %46
%48 = load i8*, i8** %8
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %8
br label %34
50: ; preds = %44
%51 = load i8*, i8** %8
%52 = load i8, i8* %51
%53 = icmp ne i8 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load i8*, i8** %8
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %8
store i8 0, i8* %55
br label %57
57: ; preds = %54, %50
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%59 = load i8*, i8** %7
%60 = call i8* @strtrim(i8* %59)
%61 = call i32 @strcpy(i8* %58, i8* %60)
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%63 = call i32 @strcmp(i8* %62, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%64 = icmp ne i32 %63, 0
br i1 %64, label %66, label %65
65: ; preds = %57
store i32 0, i32* %10
br label %67
66: ; preds = %57
store i32 1, i32* %10
br label %67
67: ; preds = %66, %65
br label %118
68: ; preds = %22
%69 = load i8*, i8** %8
store i8* %69, i8** %7
br label %70
70: ; preds = %83, %68
%71 = load i8*, i8** %8
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %80
75: ; preds = %70
%76 = load i8*, i8** %8
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp ne i32 %78, 61
br label %80
80: ; preds = %75, %70
%81 = phi i1 [ false, %70 ], [ %79, %75 ]
br i1 %81, label %82, label %86
82: ; preds = %80
br label %83
83: ; preds = %82
%84 = load i8*, i8** %8
%85 = getelementptr inbounds i8, i8* %84, i32 1
store i8* %85, i8** %8
br label %70
86: ; preds = %80
%87 = load i8*, i8** %8
%88 = load i8, i8* %87
%89 = icmp ne i8 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %86
%91 = load i8*, i8** %8
%92 = getelementptr inbounds i8, i8* %91, i32 1
store i8* %92, i8** %8
store i8 0, i8* %91
br label %93
93: ; preds = %90, %86
%94 = load i8*, i8** %8
%95 = call i8* @strtrim(i8* %94)
store i8* %95, i8** %8
%96 = load i8*, i8** %7
%97 = call i8* @strtrim(i8* %96)
store i8* %97, i8** %7
%98 = load i8*, i8** %7
%99 = load i8, i8* %98
%100 = icmp ne i8 %99, 0
br i1 %100, label %102, label %101
101: ; preds = %93
br label %118
102: ; preds = %93
%103 = load i32, i32* %10
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %113
105: ; preds = %102
%106 = getelementptr inbounds [1026 x i8], [1026 x i8]* %6, i64 0, i64 0
%107 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%108 = load i8*, i8** %7
%109 = call i32 @snprintf(i8* %106, i32 1026, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %107, i8* %108)
%110 = getelementptr inbounds [1026 x i8], [1026 x i8]* %6, i64 0, i64 0
%111 = load i8*, i8** %8
%112 = call i32 @config_set(i8* %110, i8* %111)
br label %117
113: ; preds = %102
%114 = load i8*, i8** %7
%115 = load i8*, i8** %8
%116 = call i32 @config_set(i8* %114, i8* %115)
br label %117
117: ; preds = %113, %105
br label %118
118: ; preds = %117, %101, %67, %28
br label %16
119: ; preds = %21
%120 = load i32*, i32** %9
%121 = call i32 @fclose(i32* %120)
store i32 1, i32* %2
br label %122
122: ; preds = %119, %14
%123 = load i32, i32* %2
ret i32 %123
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%s-%s\00"
define i32 @config_load(i8* nocapture %0) {
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [1026 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1026 x i8], [1026 x i8]* %4, i64 0, i64 0
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %62, label %10
10: ; preds = %1
%11 = call i32 @fgets(i8* %5, i32 512, i32* %8)
%12 = icmp eq i32 %11, 0
br i1 %12, label %60, label %13
13: ; preds = %10
%14 = bitcast [512 x i8]* %3 to i64*
br label %15
15: ; preds = %13, %56
%16 = phi i32 [ 0, %13 ], [ %57, %56 ]
%17 = call i8* @strtrim(i8* %5)
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %35 [
i32 35, label %56
i32 91, label %20
]
20: ; preds = %15
%21 = getelementptr inbounds i8, i8* %17, i64 1
%22 = call i8* @strtrim(i8* %21)
br label %23
23: ; preds = %26, %20
%24 = phi i8* [ %22, %20 ], [ %27, %26 ]
%25 = load i8, i8* %24
switch i8 %25, label %26 [
i8 0, label %29
i8 93, label %28
]
26: ; preds = %23
%27 = getelementptr inbounds i8, i8* %24, i64 1
br label %23
28: ; preds = %23
store i8 0, i8* %24
br label %29
29: ; preds = %23, %28
%30 = call i8* @strtrim(i8* %22)
%31 = call i32 @strcpy(i8* %6, i8* %30)
%32 = load i64, i64* %14
%33 = icmp ne i64 %32, 32482203974724707
%34 = zext i1 %33 to i32
br label %56
35: ; preds = %15, %38
%36 = phi i8 [ %40, %38 ], [ %18, %15 ]
%37 = phi i8* [ %39, %38 ], [ %17, %15 ]
switch i8 %36, label %38 [
i8 0, label %43
i8 61, label %41
]
38: ; preds = %35
%39 = getelementptr inbounds i8, i8* %37, i64 1
%40 = load i8, i8* %39
br label %35
41: ; preds = %35
%42 = getelementptr inbounds i8, i8* %37, i64 1
store i8 0, i8* %37
br label %43
43: ; preds = %35, %41
%44 = phi i8* [ %42, %41 ], [ %37, %35 ]
%45 = call i8* @strtrim(i8* %44)
%46 = call i8* @strtrim(i8* %17)
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 0
br i1 %48, label %56, label %49
49: ; preds = %43
%50 = icmp eq i32 %16, 0
br i1 %50, label %54, label %51
51: ; preds = %49
%52 = call i32 @snprintf(i8* %7, i32 1026, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %46)
%53 = call i32 @config_set(i8* %7, i8* %45)
br label %56
54: ; preds = %49
%55 = call i32 @config_set(i8* %46, i8* %45)
br label %56
56: ; preds = %29, %51, %54, %43, %15
%57 = phi i32 [ 1, %51 ], [ 0, %54 ], [ %16, %43 ], [ %16, %15 ], [ %34, %29 ]
%58 = call i32 @fgets(i8* %5, i32 512, i32* %8)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %15
60: ; preds = %56, %10
%61 = call i32 @fclose(i32* %8)
br label %62
62: ; preds = %1, %60
%63 = phi i32 [ 1, %60 ], [ 0, %1 ]
ret i32 %63
}