#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *getenv(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ processCmd(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
readRC() {
  char *s;
  char line[1024];
  FILE *fp;
  if ((s = getenv("HOME")) == NULL)
    return (0);
  sprintf(line, "%s/.srerc", s);
  if (!(fp = fopen(line, "r")))
    return (0);
  while (fgets(line, 1000, fp) != NULL)
    if (processCmd(line) == 0) {
      printf("Bad .srerc init file; correct and restart\n");
      exit(0);
    }
  fclose(fp);
  return (1);
}


x86 assembly (clang, -O0):
<readRC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    0xe6e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11b1 <readRC+0x31>
movl   $0x0,-0x4(%rbp)
jmp    1260 <readRC+0xe0>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
jne    11f8 <readRC+0x78>
movl   $0x0,-0x4(%rbp)
jmp    1260 <readRC+0xe0>
jmp    11fd <readRC+0x7d>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rdx
mov    $0x3e8,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     124d <readRC+0xcd>
lea    -0x410(%rbp),%rdi
call   1040 <processCmd@plt>
cmp    $0x0,%rax
jne    1248 <readRC+0xc8>
lea    0xdd5(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
jmp    11fd <readRC+0x7d>
mov    -0x418(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readRC>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
lea    0xe70(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1212 <readRC+0x92>
lea    0xe62(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
call   1090 <sprintf@plt>
lea    0xe57(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1212 <readRC+0x92>
mov    %rax,%rbx
mov    %rsp,%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1205 <readRC+0x85>
mov    %rbp,%rdi
call   1040 <processCmd@plt>
test   %rax,%rax
jne    11d0 <readRC+0x50>
lea    0xe18(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [10 x i8] c"%s/.srerc\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [43 x i8] c"Bad .srerc init file; correct and restart\0A\00"
define i32 @readRC() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32*
%5 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 0, i32* %1
br label %33
8: ; preds = %0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %13, i32** %4
%14 = icmp ne i32* %13, null
br i1 %14, label %16, label %15
15: ; preds = %8
store i32 0, i32* %1
br label %33
16: ; preds = %8
br label %17
17: ; preds = %29, %16
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = load i32*, i32** %4
%20 = call i32* @fgets(i8* %18, i32 1000, i32* %19)
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %30
22: ; preds = %17
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%24 = call i64 @processCmd(i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %22
br label %17
30: ; preds = %17
%31 = load i32*, i32** %4
%32 = call i32 @fclose(i32* %31)
store i32 1, i32* %1
br label %33
33: ; preds = %30, %15, %7
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [10 x i8] c"%s/.srerc\00"
@.str.2 = [2 x i8] c"r\00"
@str = [42 x i8] c"Bad .srerc init file; correct and restart\00"
define i32 @readRC() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %20, label %5
5: ; preds = %0
%6 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %20, label %9
9: ; preds = %5, %12
%10 = call i32* @fgets(i8* %2, i32 1000, i32* %7)
%11 = icmp eq i32* %10, null
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = call i64 @processCmd(i8* %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %9
15: ; preds = %12
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %9
%19 = call i32 @fclose(i32* %7)
br label %20
20: ; preds = %5, %0, %18
%21 = phi i32 [ 1, %18 ], [ 0, %0 ], [ 0, %5 ]
ret i32 %21
}