#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 W_OK;
int X_OK;
int access(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int main() {
  if (access("/home/shmiluyu/.abcdefg", W_OK | X_OK) == -1) {
    printf("folder doesn't exist");
  }
  FILE *db = fopen("/home/shmiluyu/git/demo.txt", "w");
  fclose(db);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
mov    0x2e81(%rip),%rax
or     (%rax),%esi
lea    0xe98(%rip),%rdi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
jne    1182 <main+0x42>
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    0x2e91(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xea6(%rip),%rdi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
jne    1170 <main+0x30>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"/home/shmiluyu/.abcdefg\00"
@W_OK = global i32 0
@X_OK = global i32 0
@.str.1 = [21 x i8] c"folder doesn't exist\00"
@.str.2 = [28 x i8] c"/home/shmiluyu/git/demo.txt\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = load i32, i32* @W_OK
%4 = load i32, i32* @X_OK
%5 = or i32 %3, %4
%6 = call i32 @access(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = call i32 @fclose(i32* %12)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"/home/shmiluyu/.abcdefg\00"
@W_OK = global i32 0
@X_OK = global i32 0
@.str.1 = [21 x i8] c"folder doesn't exist\00"
@.str.2 = [28 x i8] c"/home/shmiluyu/git/demo.txt\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main() {
%1 = load i32, i32* @W_OK
%2 = load i32, i32* @X_OK
%3 = or i32 %2, %1
%4 = tail call i32 @access(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @fclose(i32* %9)
ret i32 0
}