#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*/ chdir(char *);
int /*<<< orphan*/ chmod(char *, int);
int /*<<< orphan*/ create_file(char *, char *, int);
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ symlink(char *, char *);
void setup() {
  mkdir("working", 0777);
  chdir("working");
  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    0xea5(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe94(%rip),%rdi
call   1040 <chdir@plt>
lea    0xf16(%rip),%rdi
lea    0xe89(%rip),%rsi
mov    $0x1ff,%edx
call   1070 <create_file@plt>
lea    0xe7d(%rip),%rdi
lea    0xe71(%rip),%rsi
mov    $0x1ff,%edx
call   1070 <create_file@plt>
lea    0xe65(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1050 <symlink@plt>
lea    0xe63(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe52(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1050 <symlink@plt>
lea    0xe58(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe54(%rip),%rdi
lea    0xe11(%rip),%rsi
mov    $0x1ff,%edx
call   1070 <create_file@plt>
lea    0xe55(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe1e(%rip),%rdi
mov    $0x16d,%esi
call   1060 <chmod@plt>
lea    0xe4b(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe43(%rip),%rdi
lea    0xdc6(%rip),%rsi
mov    $0x1ff,%edx
call   1070 <create_file@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %rbx,%rdi
call   1040 <chdir@plt>
lea    0xf17(%rip),%rdi
lea    0xe8a(%rip),%r14
mov    %r14,%rsi
mov    $0x1ff,%edx
call   1070 <create_file@plt>
lea    0xe7b(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1ff,%edx
call   1070 <create_file@plt>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <symlink@plt>
lea    0xe66(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <symlink@plt>
lea    0xe5c(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe55(%rip),%rdi
mov    %r14,%rsi
mov    $0x1ff,%edx
call   1070 <create_file@plt>
lea    0xe5a(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %rbx,%rdi
mov    $0x16d,%esi
call   1060 <chmod@plt>
lea    0xe54(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe4c(%rip),%rdi
mov    %r14,%rsi
mov    $0x1ff,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <create_file@plt>

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

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