#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 O_CREAT;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int lseek(int, int, int /*<<< orphan*/);
scalar_t__ mkdir(char *, int);
int open(char *, int, int);
int /*<<< orphan*/ start_timer(char *);
int /*<<< orphan*/ stop_timer();
int /*<<< orphan*/ write(int, char *, int);
void mkdirs() {
  start_timer("Creating directory structure");
  assert(mkdir("/tmp/removefile-test", 0755) == 0);
  assert(mkdir("/tmp/removefile-test/foo", 0755) == 0);
  assert(mkdir("/tmp/removefile-test/foo/bar", 0755) == 0);
  assert(mkdir("/tmp/removefile-test/foo/baz", 0755) == 0);
  int fd;
  assert((fd = open("/tmp/removefile-test/foo/baz/woot",
                    O_CREAT | O_TRUNC | O_WRONLY, 0644)) != -1);
  write(fd, "Hello World\n", 12);
  close(fd);
  assert((fd = open("/tmp/removefile-test/foo/baz/wootage",
                    O_CREAT | O_TRUNC | O_WRONLY, 0644)) != -1);
  write(fd, "Hello World\n", 12);
  assert(lseek(fd, 1024 * 1024 * 30, SEEK_SET) != -1);
  write(fd, "Goodbye Moon\n", 13);
  close(fd);
  stop_timer();
}


x86 assembly (clang, -O0):
<mkdirs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe71(%rip),%rdi
call   1080 <start_timer@plt>
lea    0xe82(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe75(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe6c(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe67(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
mov    0x2dc4(%rip),%rax
or     (%rax),%esi
mov    0x2d8b(%rip),%rax
or     (%rax),%esi
lea    0xe47(%rip),%rdi
mov    $0x1a4,%edx
call   1090 <open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x4(%rbp),%edi
lea    0xe42(%rip),%rsi
mov    $0xc,%edx
call   1040 <write@plt>
mov    -0x4(%rbp),%edi
call   1060 <close@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%esi
mov    0x2d69(%rip),%rax
or     (%rax),%esi
mov    0x2d30(%rip),%rax
or     (%rax),%esi
lea    0xe1b(%rip),%rdi
mov    $0x1a4,%edx
call   1090 <open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x4(%rbp),%edi
lea    0xde7(%rip),%rsi
mov    $0xc,%edx
call   1040 <write@plt>
mov    -0x4(%rbp),%edi
mov    0x2cfc(%rip),%rax
mov    (%rax),%edx
mov    $0x1e00000,%esi
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x4(%rbp),%edi
lea    0xddf(%rip),%rsi
mov    $0xd,%edx
call   1040 <write@plt>
mov    -0x4(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   10a0 <stop_timer@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkdirs>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xe70(%rip),%rdi
call   1080 <start_timer@plt>
lea    0xe81(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe77(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe71(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe6f(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    0x2de0(%rip),%r15
mov    0x2dd1(%rip),%r12
mov    (%r12),%esi
or     (%r15),%esi
mov    0x2d93(%rip),%r13
or     0x0(%r13),%esi
lea    0xe4d(%rip),%rdi
mov    $0x1a4,%edx
call   1090 <open@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
lea    0xe4e(%rip),%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1040 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    (%r12),%esi
or     (%r15),%esi
or     0x0(%r13),%esi
lea    0xe33(%rip),%rdi
mov    $0x1a4,%edx
call   1090 <open@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1040 <write@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    $0x1e00000,%esi
call   1050 <lseek@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1070 <assert@plt>
lea    0xe05(%rip),%rsi
mov    %ebx,%edi
mov    $0xd,%edx
call   1040 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    10a0 <stop_timer@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Creating directory structure\00"
@.str.1 = [21 x i8] c"/tmp/removefile-test\00"
@.str.2 = [25 x i8] c"/tmp/removefile-test/foo\00"
@.str.3 = [29 x i8] c"/tmp/removefile-test/foo/bar\00"
@.str.4 = [29 x i8] c"/tmp/removefile-test/foo/baz\00"
@.str.5 = [34 x i8] c"/tmp/removefile-test/foo/baz/woot\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_WRONLY = global i32 0
@.str.6 = [13 x i8] c"Hello World\0A\00"
@.str.7 = [37 x i8] c"/tmp/removefile-test/foo/baz/wootage\00"
@SEEK_SET = global i32 0
@.str.8 = [14 x i8] c"Goodbye Moon\0A\00"
define void @mkdirs() {
%1 = alloca i32
%2 = call i32 @start_timer(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%3 = call i64 @mkdir(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 493)
%4 = icmp eq i64 %3, 0
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = call i64 @mkdir(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 493)
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i64 @mkdir(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 493)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i64 @mkdir(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 493)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* @O_CREAT
%20 = load i32, i32* @O_TRUNC
%21 = or i32 %19, %20
%22 = load i32, i32* @O_WRONLY
%23 = or i32 %21, %22
%24 = call i32 @open(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 420)
store i32 %24, i32* %1
%25 = icmp ne i32 %24, -1
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %1
%29 = call i32 @write(i32 %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 12)
%30 = load i32, i32* %1
%31 = call i32 @close(i32 %30)
%32 = load i32, i32* @O_CREAT
%33 = load i32, i32* @O_TRUNC
%34 = or i32 %32, %33
%35 = load i32, i32* @O_WRONLY
%36 = or i32 %34, %35
%37 = call i32 @open(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %36, i32 420)
store i32 %37, i32* %1
%38 = icmp ne i32 %37, -1
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load i32, i32* %1
%42 = call i32 @write(i32 %41, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 12)
%43 = load i32, i32* %1
%44 = load i32, i32* @SEEK_SET
%45 = call i32 @lseek(i32 %43, i32 31457280, i32 %44)
%46 = icmp ne i32 %45, -1
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load i32, i32* %1
%50 = call i32 @write(i32 %49, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 13)
%51 = load i32, i32* %1
%52 = call i32 @close(i32 %51)
%53 = call i32 (...) @stop_timer()
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Creating directory structure\00"
@.str.1 = [21 x i8] c"/tmp/removefile-test\00"
@.str.2 = [25 x i8] c"/tmp/removefile-test/foo\00"
@.str.3 = [29 x i8] c"/tmp/removefile-test/foo/bar\00"
@.str.4 = [29 x i8] c"/tmp/removefile-test/foo/baz\00"
@.str.5 = [34 x i8] c"/tmp/removefile-test/foo/baz/woot\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_WRONLY = global i32 0
@.str.6 = [13 x i8] c"Hello World\0A\00"
@.str.7 = [37 x i8] c"/tmp/removefile-test/foo/baz/wootage\00"
@SEEK_SET = global i32 0
@.str.8 = [14 x i8] c"Goodbye Moon\0A\00"
define void @mkdirs() {
%1 = tail call i32 @start_timer(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @mkdir(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 493)
%3 = icmp eq i64 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i64 @mkdir(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 493)
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i64 @mkdir(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 493)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i64 @mkdir(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 493)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = load i32, i32* @O_CREAT
%19 = load i32, i32* @O_TRUNC
%20 = or i32 %19, %18
%21 = load i32, i32* @O_WRONLY
%22 = or i32 %20, %21
%23 = tail call i32 @open(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %22, i32 420)
%24 = icmp ne i32 %23, -1
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = tail call i32 @write(i32 %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 12)
%28 = tail call i32 @close(i32 %23)
%29 = load i32, i32* @O_CREAT
%30 = load i32, i32* @O_TRUNC
%31 = or i32 %30, %29
%32 = load i32, i32* @O_WRONLY
%33 = or i32 %31, %32
%34 = tail call i32 @open(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %33, i32 420)
%35 = icmp ne i32 %34, -1
%36 = zext i1 %35 to i32
%37 = tail call i32 @assert(i32 %36)
%38 = tail call i32 @write(i32 %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 12)
%39 = load i32, i32* @SEEK_SET
%40 = tail call i32 @lseek(i32 %34, i32 31457280, i32 %39)
%41 = icmp ne i32 %40, -1
%42 = zext i1 %41 to i32
%43 = tail call i32 @assert(i32 %42)
%44 = tail call i32 @write(i32 %34, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 13)
%45 = tail call i32 @close(i32 %34)
%46 = tail call i32 (...) @stop_timer()
ret void
}