#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *getenv(char *);
int /*<<< orphan*/ info(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ parse_rcline(char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
void read_rcfile(void) {
  FILE *f;
  char filename[64], buf[64];
  char *homedir;
  int linenum = 1;
  homedir = getenv("HOME");
  if (!homedir) {
    info(0,
         "warning: HOME is not set so I can't read "
         "$HOME/%s\n",
         ".vrctlrc");
    return;
  }
  snprintf(filename, 64, "%s/%s", homedir, ".vrctlrc");
  f = fopen(filename, "r");
  if (f == NULL)
    return;
  while (fgets(buf, 64, f) != NULL)
    parse_rcline(filename, linenum++, buf);
  if (ferror(f))
    info(0, "warning: errors detected reading %s\n", filename);
  fclose(f);
}


x86 assembly (clang, -O0):
<read_rcfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x1,-0x9c(%rbp)
lea    0xe64(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    11d0 <read_rcfile+0x50>
xor    %edi,%edi
lea    0xe46(%rip),%rsi
lea    0xe72(%rip),%rdx
call   10a0 <info@plt>
jmp    128f <read_rcfile+0x10f>
lea    -0x50(%rbp),%rdi
mov    -0x98(%rbp),%rcx
mov    $0x40,%esi
lea    0xe5a(%rip),%rdx
lea    0xe4a(%rip),%r8
call   1070 <snprintf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1217 <read_rcfile+0x97>
jmp    128f <read_rcfile+0x10f>
jmp    121c <read_rcfile+0x9c>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x40,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1261 <read_rcfile+0xe1>
lea    -0x50(%rbp),%rdi
mov    -0x9c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
lea    -0x90(%rbp),%rdx
call   1060 <parse_rcline@plt>
jmp    121c <read_rcfile+0x9c>
mov    -0x8(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1286 <read_rcfile+0x106>
lea    -0x50(%rbp),%rdx
xor    %edi,%edi
lea    0xdc8(%rip),%rsi
call   10a0 <info@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fclose@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_rcfile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xe6c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1259 <read_rcfile+0xd9>
lea    0xe98(%rip),%rdx
lea    0xe88(%rip),%r8
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1070 <snprintf@plt>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     124b <read_rcfile+0xcb>
mov    %rax,%r15
lea    0x40(%rsp),%rdi
mov    $0x40,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1225 <read_rcfile+0xa5>
mov    $0x1,%esi
mov    %rsp,%r14
lea    0x40(%rsp),%rbx
xchg   %ax,%ax
lea    0x1(%rsi),%ebp
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <parse_rcline@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
mov    %ebp,%esi
test   %rax,%rax
jne    1200 <read_rcfile+0x80>
mov    %r15,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     1243 <read_rcfile+0xc3>
lea    0xe10(%rip),%rsi
mov    %rsp,%rdx
xor    %edi,%edi
call   10a0 <info@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda5(%rip),%rsi
lea    0xdd1(%rip),%rdx
xor    %edi,%edi
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <info@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [51 x i8] c"warning: HOME is not set so I can't read $HOME/%s\0A\00"
@.str.2 = [9 x i8] c".vrctlrc\00"
@.str.3 = [6 x i8] c"%s/%s\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [37 x i8] c"warning: errors detected reading %s\0A\00"
define void @read_rcfile() {
%1 = alloca i32*
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
%4 = alloca i8*
%5 = alloca i32
store i32 1, i32* %5
%6 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 @info(i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %42
11: ; preds = %0
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 @snprintf(i8* %12, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %16, i32** %1
%17 = load i32*, i32** %1
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %11
br label %42
20: ; preds = %11
br label %21
21: ; preds = %26, %20
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%23 = load i32*, i32** %1
%24 = call i32* @fgets(i8* %22, i32 64, i32* %23)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%31 = call i32 @parse_rcline(i8* %27, i32 %28, i8* %30)
br label %21
32: ; preds = %21
%33 = load i32*, i32** %1
%34 = call i64 @ferror(i32* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%38 = call i32 @info(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %32
%40 = load i32*, i32** %1
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %39, %19, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [51 x i8] c"warning: HOME is not set so I can't read $HOME/%s\0A\00"
@.str.2 = [9 x i8] c".vrctlrc\00"
@.str.3 = [6 x i8] c"%s/%s\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [37 x i8] c"warning: errors detected reading %s\0A\00"
define void @read_rcfile() {
%1 = alloca [64 x i8]
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @info(i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %29
9: ; preds = %0
%10 = call i32 @snprintf(i8* %3, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %29, label %13
13: ; preds = %9
%14 = call i32* @fgets(i8* %4, i32 64, i32* %11)
%15 = icmp eq i32* %14, null
br i1 %15, label %22, label %16
16: ; preds = %13, %16
%17 = phi i32 [ %18, %16 ], [ 1, %13 ]
%18 = add nuw nsw i32 %17, 1
%19 = call i32 @parse_rcline(i8* %3, i32 %17, i8* %4)
%20 = call i32* @fgets(i8* %4, i32 64, i32* %11)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %16
22: ; preds = %16, %13
%23 = call i64 @ferror(i32* %11)
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 @info(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %3)
br label %27
27: ; preds = %25, %22
%28 = call i32 @fclose(i32* %11)
br label %29
29: ; preds = %9, %27, %7
ret void
}