#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*/ *fopen(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcat(char *, char *);
FILE *getFileExist(char *fileName, char *currDir) {
  char *finalDir;
  memset(finalDir, 0, 512);
  strcat(finalDir, currDir);
  strcat(finalDir, "/");
  strcat(finalDir, fileName);
  FILE *file = fopen(finalDir, "r+");
  if (file) {
    return file;
  } else {
    return NULL;
  }
}


x86 assembly (clang, -O0):
<getFileExist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1030 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a6 <getFileExist+0x76>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ae <getFileExist+0x7e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileExist>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %esi,%esi
mov    $0x200,%edx
call   1030 <memset@plt>
mov    %rbx,%rsi
call   1050 <strcat@plt>
lea    0xeab(%rip),%rsi
call   1050 <strcat@plt>
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xe99(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fopen@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [3 x i8] c"r+\00"
define i32* @getFileExist(i8* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %6
%9 = call i32 @memset(i8* %8, i32 0, i32 512)
%10 = load i8*, i8** %6
%11 = load i8*, i8** %5
%12 = call i32 @strcat(i8* %10, i8* %11)
%13 = load i8*, i8** %6
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %6
%16 = load i8*, i8** %4
%17 = call i32 @strcat(i8* %15, i8* %16)
%18 = load i8*, i8** %6
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32*, i32** %7
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = load i32*, i32** %7
store i32* %23, i32** %3
br label %25
24: ; preds = %2
store i32* null, i32** %3
br label %25
25: ; preds = %24, %22
%26 = load i32*, i32** %3
ret i32* %26
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [3 x i8] c"r+\00"
define noalias i32* @getFileExist(i8* %0, i8* %1) {
%3 = tail call i32 @memset(i8* undef, i32 0, i32 512)
%4 = tail call i32 @strcat(i8* undef, i8* %1)
%5 = tail call i32 @strcat(i8* undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @strcat(i8* undef, i8* %0)
%7 = tail call i32* @fopen(i8* undef, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret i32* %7
}