#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*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
int /*<<< orphan*/ parse_opt_file(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void read_opt_file() {
  char *home = NULL;
  char opt_file[257];
  FILE *fp;
  if (NULL == (home = getenv("HOME"))) {
    fprintf(stderr, "warning:  cannot determine home directory\n");
    return;
  } else {
    strcpy(opt_file, home);
    strcat(opt_file, "/");
    strcat(opt_file, ".cuerenamerc");
  }
  if (NULL != (fp = fopen(opt_file, "rb"))) {
    parse_opt_file(fp);
    fclose(fp);
  }
}


x86 assembly (clang, -O0):
<read_opt_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movq   $0x0,-0x8(%rbp)
lea    0xe76(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
mov    %rcx,-0x8(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11bb <read_opt_file+0x4b>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1231 <read_opt_file+0xc1>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x110(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x110(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x118(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1231 <read_opt_file+0xc1>
mov    -0x118(%rbp),%rdi
call   1070 <parse_opt_file@plt>
mov    -0x118(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_opt_file>:
push   %rbx
sub    $0x110,%rsp
lea    0xe81(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11e5 <read_opt_file+0x75>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11dc <read_opt_file+0x6c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <parse_opt_file@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x110,%rsp
pop    %rbx
ret
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
add    $0x110,%rsp
pop    %rbx
jmp    1060 <fprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"warning: cannot determine home directory\0A\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [13 x i8] c".cuerenamerc\00"
@.str.4 = [3 x i8] c"rb\00"
define void @read_opt_file() {
%1 = alloca i8*
%2 = alloca [257 x i8]
%3 = alloca i32*
store i8* null, i8** %1
%4 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %1
%5 = icmp eq i8* null, %4
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %26
9: ; preds = %0
%10 = getelementptr inbounds [257 x i8], [257 x i8]* %2, i64 0, i64 0
%11 = load i8*, i8** %1
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = getelementptr inbounds [257 x i8], [257 x i8]* %2, i64 0, i64 0
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [257 x i8], [257 x i8]* %2, i64 0, i64 0
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %9
%18 = getelementptr inbounds [257 x i8], [257 x i8]* %2, i64 0, i64 0
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %19, i32** %3
%20 = icmp ne i32* null, %19
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i32*, i32** %3
%23 = call i32 @parse_opt_file(i32* %22)
%24 = load i32*, i32** %3
%25 = call i32 @fclose(i32* %24)
br label %26
26: ; preds = %6, %21, %17
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"warning: cannot determine home directory\0A\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [13 x i8] c".cuerenamerc\00"
@.str.4 = [3 x i8] c"rb\00"
define void @read_opt_file() {
%1 = alloca [257 x i8]
%2 = getelementptr inbounds [257 x i8], [257 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 %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %17
8: ; preds = %0
%9 = call i32 @strcpy(i8* %2, i8* %3)
%10 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %8
%15 = call i32 @parse_opt_file(i32* %12)
%16 = call i32 @fclose(i32* %12)
br label %17
17: ; preds = %8, %14, %5
ret void
}