#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 */

/* Variables and functions */
int S_IREAD;
int S_IWRITE;
int /*<<< orphan*/ close(int);
int creat(char *, int);
int /*<<< orphan*/ unlink(char *);
int main() {
  int fd1;
  fd1 = creat("foobar1", S_IREAD | S_IWRITE);
  close(fd1);
  unlink("foobar1");
  unlink("foobar1");
  unlink("foobar2");
  unlink(0);
  unlink("..");
  unlink("");
  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    0x2e99(%rip),%rax
or     (%rax),%esi
lea    0xea8(%rip),%rdi
call   1050 <creat@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
lea    0xe91(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe85(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe81(%rip),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <unlink@plt>
lea    0xe74(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe6a(%rip),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    0x2ea9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xeb6(%rip),%rbx
mov    %rbx,%rdi
call   1050 <creat@plt>
mov    %eax,%edi
call   1040 <close@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
lea    0xe98(%rip),%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
call   1030 <unlink@plt>
lea    0xe8d(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe83(%rip),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"foobar1\00"
@S_IREAD = global i32 0
@S_IWRITE = global i32 0
@.str.1 = [8 x i8] c"foobar2\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @S_IREAD
%4 = load i32, i32* @S_IWRITE
%5 = or i32 %3, %4
%6 = call i32 @creat(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = call i32 @close(i32 %7)
%9 = call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @unlink(i8* null)
%13 = call i32 @unlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @unlink(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"foobar1\00"
@S_IREAD = global i32 0
@S_IWRITE = global i32 0
@.str.1 = [8 x i8] c"foobar2\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = load i32, i32* @S_IREAD
%2 = load i32, i32* @S_IWRITE
%3 = or i32 %2, %1
%4 = tail call i32 @creat(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @close(i32 %4)
%6 = tail call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @unlink(i8* null)
%10 = tail call i32 @unlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @unlink(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}