#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 /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ open_rdonly(char *);
int /*<<< orphan*/ symlink(char *, char *);
int /*<<< orphan*/ unlink(char *);
int execute_unlink() {
  close(open_rdonly("syscalls.txt"));
  unlink("syscalls.txt");
  close(open_rdonly("syscalls2.txt"));
  symlink("syscalls2.txt", "syscalls.symlink");
  unlink("syscalls.symlink");
  unlink("hopefully_no_such_filename_exists.txt");
  return 0;
}


x86 assembly (clang, -O0):
<execute_unlink>:
push   %rbp
mov    %rsp,%rbp
lea    0xeb5(%rip),%rdi
call   1040 <open_rdonly@plt>
mov    %eax,%edi
call   1060 <close@plt>
lea    0xea2(%rip),%rdi
call   1030 <unlink@plt>
lea    0xea3(%rip),%rdi
call   1040 <open_rdonly@plt>
mov    %eax,%edi
call   1060 <close@plt>
lea    0xe90(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1050 <symlink@plt>
lea    0xe8b(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe90(%rip),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_unlink>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rbx
mov    %rbx,%rdi
call   1040 <open_rdonly@plt>
mov    %eax,%edi
call   1060 <close@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
lea    0xea4(%rip),%r14
mov    %r14,%rdi
call   1040 <open_rdonly@plt>
mov    %eax,%edi
call   1060 <close@plt>
lea    0xe9c(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <symlink@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
lea    0xe93(%rip),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"syscalls.txt\00"
@.str.1 = [14 x i8] c"syscalls2.txt\00"
@.str.2 = [17 x i8] c"syscalls.symlink\00"
@.str.3 = [38 x i8] c"hopefully_no_such_filename_exists.txt\00"
define i32 @execute_unlink() {
%1 = call i32 @open_rdonly(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @close(i32 %1)
%3 = call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @open_rdonly(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @close(i32 %4)
%6 = call i32 @symlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @unlink(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"syscalls.txt\00"
@.str.1 = [14 x i8] c"syscalls2.txt\00"
@.str.2 = [17 x i8] c"syscalls.symlink\00"
@.str.3 = [38 x i8] c"hopefully_no_such_filename_exists.txt\00"
define i32 @execute_unlink() {
%1 = tail call i32 @open_rdonly(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @close(i32 %1)
%3 = tail call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @open_rdonly(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @close(i32 %4)
%6 = tail call i32 @symlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @unlink(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}