#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*/ chmod(char *, int);
int /*<<< orphan*/ create_file(char *, char *, int);
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ symlink(char *, char *);
void setup() {
  create_file("file", "test", 0777);
  create_file("file1", "test", 0777);
  symlink("file1", "file1-link");
  mkdir("dir-empty", 0777);
  symlink("dir-empty", "dir-empty-link");
  mkdir("dir-readonly", 0777);
  create_file("dir-readonly/anotherfile", "test", 0777);
  mkdir("dir-readonly/anotherdir", 0777);
  chmod("dir-readonly", 0555);
  mkdir("dir-full", 0777);
  create_file("dir-full/anotherfile", "test", 0777);
}


x86 assembly (clang, -O0):
<setup>:
push   %rbp
mov    %rsp,%rbp
lea    0xf3b(%rip),%rdi
lea    0xeae(%rip),%rsi
mov    $0x1ff,%edx
call   1060 <create_file@plt>
lea    0xea2(%rip),%rdi
lea    0xe96(%rip),%rsi
mov    $0x1ff,%edx
call   1060 <create_file@plt>
lea    0xe8a(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1040 <symlink@plt>
lea    0xe88(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe77(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <symlink@plt>
lea    0xe7d(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe79(%rip),%rdi
lea    0xe36(%rip),%rsi
mov    $0x1ff,%edx
call   1060 <create_file@plt>
lea    0xe7a(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe43(%rip),%rdi
mov    $0x16d,%esi
call   1050 <chmod@plt>
lea    0xe70(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe68(%rip),%rdi
lea    0xdeb(%rip),%rsi
mov    $0x1ff,%edx
call   1060 <create_file@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup>:
push   %r14
push   %rbx
push   %rax
lea    0xf3b(%rip),%rdi
lea    0xeae(%rip),%r14
mov    %r14,%rsi
mov    $0x1ff,%edx
call   1060 <create_file@plt>
lea    0xe9f(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1ff,%edx
call   1060 <create_file@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <symlink@plt>
lea    0xe8a(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
call   1040 <symlink@plt>
lea    0xe80(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe79(%rip),%rdi
mov    %r14,%rsi
mov    $0x1ff,%edx
call   1060 <create_file@plt>
lea    0xe7e(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %rbx,%rdi
mov    $0x16d,%esi
call   1050 <chmod@plt>
lea    0xe78(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe70(%rip),%rdi
mov    %r14,%rsi
mov    $0x1ff,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <create_file@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"file\00"
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [6 x i8] c"file1\00"
@.str.3 = [11 x i8] c"file1-link\00"
@.str.4 = [10 x i8] c"dir-empty\00"
@.str.5 = [15 x i8] c"dir-empty-link\00"
@.str.6 = [13 x i8] c"dir-readonly\00"
@.str.7 = [25 x i8] c"dir-readonly/anotherfile\00"
@.str.8 = [24 x i8] c"dir-readonly/anotherdir\00"
@.str.9 = [9 x i8] c"dir-full\00"
@.str.10 = [21 x i8] c"dir-full/anotherfile\00"
define void @setup() {
%1 = call i32 @create_file(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 511)
%2 = call i32 @create_file(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 511)
%3 = call i32 @symlink(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%4 = call i32 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 511)
%5 = call i32 @symlink(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%6 = call i32 @mkdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 511)
%7 = call i32 @create_file(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 511)
%8 = call i32 @mkdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 511)
%9 = call i32 @chmod(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 365)
%10 = call i32 @mkdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 511)
%11 = call i32 @create_file(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 511)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"file\00"
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [6 x i8] c"file1\00"
@.str.3 = [11 x i8] c"file1-link\00"
@.str.4 = [10 x i8] c"dir-empty\00"
@.str.5 = [15 x i8] c"dir-empty-link\00"
@.str.6 = [13 x i8] c"dir-readonly\00"
@.str.7 = [25 x i8] c"dir-readonly/anotherfile\00"
@.str.8 = [24 x i8] c"dir-readonly/anotherdir\00"
@.str.9 = [9 x i8] c"dir-full\00"
@.str.10 = [21 x i8] c"dir-full/anotherfile\00"
define void @setup() {
%1 = tail call i32 @create_file(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 511)
%2 = tail call i32 @create_file(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 511)
%3 = tail call i32 @symlink(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 511)
%5 = tail call i32 @symlink(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%6 = tail call i32 @mkdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 511)
%7 = tail call i32 @create_file(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 511)
%8 = tail call i32 @mkdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 511)
%9 = tail call i32 @chmod(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 365)
%10 = tail call i32 @mkdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 511)
%11 = tail call i32 @create_file(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 511)
ret void
}