#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 FILENAME_MAX;
int /*<<< orphan*/ R_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, size_t const, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
scalar_t__ strlen(char *);
char *strrchr(char *, char);
void check_load_rc() {
  char *home_dir = NULL;
  const size_t buffer_size = 2048;
  char rc_path[FILENAME_MAX], buf[buffer_size];
  FILE *rc_file = NULL;
  char *keyword, *arg, *saveptr;
  extern void load_rc(char *keyword, char *arg);
  home_dir = getenv("HOME");
  if (home_dir == NULL) {
    fprintf(stderr, "No home directory.\n");
    return;
  }
  sprintf(rc_path, "%s/.picfsrc", home_dir);
  if (access(rc_path, R_OK) != 0) {
    return;
  }
  rc_file = fopen(rc_path, "r");
  while (!feof(rc_file)) {
    if (fgets(buf, buffer_size, rc_file) == NULL)
      break;
    arg = strrchr(buf, '\n');
    if (arg == NULL)
      continue;
    if (arg)
      *arg = '\0';
    arg = strrchr(buf, '\r');
    if (arg)
      *arg = '\0';
    arg = strchr(buf, '#');
    if (arg)
      *arg = '\0';
    keyword = buf;
    if (*keyword == 0)
      continue;
    while (*keyword == ' ')
      keyword++;
    if (strlen(keyword) == 0)
      continue;
    arg = strchr(keyword, ' ');
    if (arg == NULL)
      continue;
    *arg = 0;
    arg++;
    while (*arg == ' ')
      arg++;
    if (*arg == 0)
      continue;
    load_rc(keyword, arg);
  }
  fclose(rc_file);
}


x86 assembly (clang, -O0):
<check_load_rc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x800,-0x10(%rbp)
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x858(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xde7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    124e <check_load_rc+0x8e>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0xdc8(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x44(%rbp)
jmp    1459 <check_load_rc+0x299>
mov    -0x858(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdb9(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x858(%rbp),%rdi
mov    0x2d5d(%rip),%rax
mov    (%rax),%esi
call   10c0 <access@plt>
cmp    $0x0,%rax
je     1290 <check_load_rc+0xd0>
movl   $0x1,-0x44(%rbp)
jmp    1459 <check_load_rc+0x299>
mov    -0x858(%rbp),%rdi
lea    0xd87(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12c5 <check_load_rc+0x105>
jmp    1449 <check_load_rc+0x289>
mov    -0x28(%rbp),%rdx
lea    -0x850(%rbp),%rdi
mov    $0x800,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    12e9 <check_load_rc+0x129>
jmp    1449 <check_load_rc+0x289>
lea    -0x850(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    130e <check_load_rc+0x14e>
jmp    12a7 <check_load_rc+0xe7>
cmpq   $0x0,-0x38(%rbp)
je     1320 <check_load_rc+0x160>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x850(%rbp),%rdi
mov    $0xd,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1347 <check_load_rc+0x187>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x850(%rbp),%rdi
mov    $0x23,%esi
call   1060 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     136e <check_load_rc+0x1ae>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x850(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    138e <check_load_rc+0x1ce>
jmp    12a7 <check_load_rc+0xe7>
jmp    1393 <check_load_rc+0x1d3>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    13b4 <check_load_rc+0x1f4>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1393 <check_load_rc+0x1d3>
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jne    13cc <check_load_rc+0x20c>
jmp    12a7 <check_load_rc+0xe7>
mov    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    13ee <check_load_rc+0x22e>
jmp    12a7 <check_load_rc+0xe7>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1422 <check_load_rc+0x262>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1401 <check_load_rc+0x241>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1437 <check_load_rc+0x277>
jmp    12a7 <check_load_rc+0xe7>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10b0 <load_rc@plt>
jmp    12a7 <check_load_rc+0xe7>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_load_rc>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe1f(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1244 <check_load_rc+0x94>
lea    0xe27(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   10d0 <sprintf@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10b0 <access@plt>
test   %rax,%rax
jne    1239 <check_load_rc+0x89>
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     1263 <check_load_rc+0xb3>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <fprintf@plt>
lea    -0x820(%rbp),%r14
jmp    127c <check_load_rc+0xcc>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    1231 <check_load_rc+0x81>
mov    $0x800,%esi
mov    %r14,%rdi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1231 <check_load_rc+0x81>
mov    %r14,%rdi
mov    $0xa,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     1270 <check_load_rc+0xc0>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    $0xd,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     12bb <check_load_rc+0x10b>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    $0x23,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12d0 <check_load_rc+0x120>
movb   $0x0,(%rax)
mov    -0x820(%rbp),%al
test   %al,%al
je     1270 <check_load_rc+0xc0>
mov    %r14,%rbx
cmp    $0x20,%al
jne    12fc <check_load_rc+0x14c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
cmp    $0x20,%al
je     12f0 <check_load_rc+0x140>
test   %al,%al
je     1270 <check_load_rc+0xc0>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1270 <check_load_rc+0xc0>
movb   $0x0,(%rax)
nopl   (%rax)
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
cmp    $0x20,%cl
je     1320 <check_load_rc+0x170>
test   %cl,%cl
je     1270 <check_load_rc+0xc0>
mov    %rbx,%rdi
mov    %rax,%rsi
call   10a0 <load_rc@plt>
jmp    1270 <check_load_rc+0xc0>

LLVM IR (-O0):
@FILENAME_MAX = global i32 0
@.str = [5 x i8] c"HOME\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"No home directory.\0A\00"
@.str.2 = [12 x i8] c"%s/.picfsrc\00"
@R_OK = global i32 0
@.str.3 = [2 x i8] c"r\00"
define void @check_load_rc() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* null, i8** %1
store i64 2048, i64* %2
%10 = load i32, i32* @FILENAME_MAX
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %3
%13 = alloca i8, i64 %11
store i64 %11, i64* %4
%14 = alloca i8, i64 2048
store i32* null, i32** %5
%15 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %1
%16 = load i8*, i8** %1
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %9
br label %112
21: ; preds = %0
%22 = load i8*, i8** %1
%23 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @R_OK
%25 = call i64 @access(i8* %13, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 1, i32* %9
br label %112
28: ; preds = %21
%29 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %29, i32** %5
br label %30
30: ; preds = %106, %105, %87, %81, %67, %44, %28
%31 = load i32*, i32** %5
%32 = call i32 @feof(i32* %31)
%33 = icmp ne i32 %32, 0
%34 = xor i1 %33, true
br i1 %34, label %35, label %109
35: ; preds = %30
%36 = load i32*, i32** %5
%37 = call i32* @fgets(i8* %14, i64 2048, i32* %36)
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %40
39: ; preds = %35
br label %109
40: ; preds = %35
%41 = call i8* @strrchr(i8* %14, i8 signext 10)
store i8* %41, i8** %7
%42 = load i8*, i8** %7
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %45
44: ; preds = %40
br label %30
45: ; preds = %40
%46 = load i8*, i8** %7
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = load i8*, i8** %7
store i8 0, i8* %49
br label %50
50: ; preds = %48, %45
%51 = call i8* @strrchr(i8* %14, i8 signext 13)
store i8* %51, i8** %7
%52 = load i8*, i8** %7
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = load i8*, i8** %7
store i8 0, i8* %55
br label %56
56: ; preds = %54, %50
%57 = call i8* @strchr(i8* %14, i8 signext 35)
store i8* %57, i8** %7
%58 = load i8*, i8** %7
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = load i8*, i8** %7
store i8 0, i8* %61
br label %62
62: ; preds = %60, %56
store i8* %14, i8** %6
%63 = load i8*, i8** %6
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %62
br label %30
68: ; preds = %62
br label %69
69: ; preds = %74, %68
%70 = load i8*, i8** %6
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 32
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = load i8*, i8** %6
%76 = getelementptr inbounds i8, i8* %75, i32 1
store i8* %76, i8** %6
br label %69
77: ; preds = %69
%78 = load i8*, i8** %6
%79 = call i64 @strlen(i8* %78)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %77
br label %30
82: ; preds = %77
%83 = load i8*, i8** %6
%84 = call i8* @strchr(i8* %83, i8 signext 32)
store i8* %84, i8** %7
%85 = load i8*, i8** %7
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %88
87: ; preds = %82
br label %30
88: ; preds = %82
%89 = load i8*, i8** %7
store i8 0, i8* %89
%90 = load i8*, i8** %7
%91 = getelementptr inbounds i8, i8* %90, i32 1
store i8* %91, i8** %7
br label %92
92: ; preds = %97, %88
%93 = load i8*, i8** %7
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 32
br i1 %96, label %97, label %100
97: ; preds = %92
%98 = load i8*, i8** %7
%99 = getelementptr inbounds i8, i8* %98, i32 1
store i8* %99, i8** %7
br label %92
100: ; preds = %92
%101 = load i8*, i8** %7
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 0
br i1 %104, label %105, label %106
105: ; preds = %100
br label %30
106: ; preds = %100
%107 = load i8*, i8** %6
%108 = load i8*, i8** %7
br label %30
109: ; preds = %39, %30
%110 = load i32*, i32** %5
%111 = call i32 @fclose(i32* %110)
store i32 0, i32* %9
br label %112
112: ; preds = %109, %27, %18
%113 = load i8*, i8** %3
%114 = load i32, i32* %9
switch i32 %114, label %116 [
i32 0, label %115
i32 1, label %115
]
115: ; preds = %112, %112
ret void
116: ; preds = %112
unreachable
}

LLVM IR (-O2):
@FILENAME_MAX = global i32 0
@.str = [5 x i8] c"HOME\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"No home directory.\0A\00"
@.str.2 = [12 x i8] c"%s/.picfsrc\00"
@R_OK = global i32 0
@.str.3 = [2 x i8] c"r\00"
define void @check_load_rc() {
%1 = load i32, i32* @FILENAME_MAX
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %57
11: ; preds = %0
%12 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%13 = load i32, i32* @R_OK
%14 = call i64 @access(i8* %3, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %57
16: ; preds = %11
%17 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @feof(i32* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %55
20: ; preds = %16, %52
%21 = call i32* @fgets(i8* %5, i64 2048, i32* %17)
%22 = icmp eq i32* %21, null
br i1 %22, label %55, label %23
23: ; preds = %20
%24 = call i8* @strrchr(i8* %5, i8 signext 10)
%25 = icmp eq i8* %24, null
br i1 %25, label %52, label %26
26: ; preds = %23
store i8 0, i8* %24
%27 = call i8* @strrchr(i8* %5, i8 signext 13)
%28 = icmp eq i8* %27, null
br i1 %28, label %30, label %29
29: ; preds = %26
store i8 0, i8* %27
br label %30
30: ; preds = %29, %26
%31 = call i8* @strchr(i8* %5, i8 signext 35)
%32 = icmp eq i8* %31, null
br i1 %32, label %34, label %33
33: ; preds = %30
store i8 0, i8* %31
br label %34
34: ; preds = %33, %30
%35 = load i8, i8* %5
%36 = icmp eq i8 %35, 0
br i1 %36, label %52, label %37
37: ; preds = %34, %40
%38 = phi i8 [ %42, %40 ], [ %35, %34 ]
%39 = phi i8* [ %41, %40 ], [ %5, %34 ]
switch i8 %38, label %43 [
i8 32, label %40
i8 0, label %52
]
40: ; preds = %37
%41 = getelementptr inbounds i8, i8* %39, i64 1
%42 = load i8, i8* %41
br label %37
43: ; preds = %37
%44 = call i8* @strchr(i8* %39, i8 signext 32)
%45 = icmp eq i8* %44, null
br i1 %45, label %52, label %46
46: ; preds = %43
store i8 0, i8* %44
br label %47
47: ; preds = %47, %46
%48 = phi i8* [ %44, %46 ], [ %49, %47 ]
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = load i8, i8* %49
switch i8 %50, label %51 [
i8 32, label %47
i8 0, label %52
]
51: ; preds = %47
br label %52
52: ; preds = %37, %47, %51, %23, %34, %43
%53 = call i32 @feof(i32* %17)
%54 = icmp eq i32 %53, 0
br i1 %54, label %20, label %55
55: ; preds = %52, %20, %16
%56 = call i32 @fclose(i32* %17)
br label %57
57: ; preds = %11, %55, %8
ret void
}