#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*/ BUFSIZ;
char *calloc(int /*<<< orphan*/, int);
int /*<<< orphan*/ *fopen(char *, char *);
char *getenv(char *);
int /*<<< orphan*/ strcat(char *, char *);
int main() {
  char *path = calloc(BUFSIZ, 1);
  strcat(path, getenv("HOME"));
  strcat(path, "/.bashrc");
  FILE *foo = fopen(path, "r");
  return foo == NULL;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe8b(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
lea    0xea2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <strcat@plt>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [5 x i8] c"HOME\00"
@.str.1 = [9 x i8] c"/.bashrc\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
store i32 0, i32* %1
%4 = load i32, i32* @BUFSIZ
%5 = call i8* @calloc(i32 %4, i32 1)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strcat(i8* %6, i8* %7)
%9 = load i8*, i8** %2
%10 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = load i8*, i8** %2
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = icmp eq i32* %13, null
%15 = zext i1 %14 to i32
ret i32 %15
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [5 x i8] c"HOME\00"
@.str.1 = [9 x i8] c"/.bashrc\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @main() {
%1 = load i32, i32* @BUFSIZ
%2 = tail call i8* @calloc(i32 %1, i32 1)
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strcat(i8* %2, i8* %3)
%5 = tail call i32 @strcat(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32* %6, null
%8 = zext i1 %7 to i32
ret i32 %8
}