#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);
int 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,-0x8(%rbp)
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%edi
lea    0xe42(%rip),%rsi
mov    $0xc,%edx
call   1040 <write@plt>
mov    -0x8(%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,-0x8(%rbp)
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%edi
lea    0xde7(%rip),%rsi
mov    $0xc,%edx
call   1040 <write@plt>
mov    -0x8(%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    -0x8(%rbp),%edi
lea    0xddf(%rip),%rsi
mov    $0xd,%edx
call   1040 <write@plt>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   10a0 <stop_timer@plt>
mov    -0x4(%rbp),%eax
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 i32 @mkdirs() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @start_timer(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = call i64 @mkdir(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 493)
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i64 @mkdir(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 493)
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i64 @mkdir(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 493)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i64 @mkdir(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 493)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* @O_CREAT
%21 = load i32, i32* @O_TRUNC
%22 = or i32 %20, %21
%23 = load i32, i32* @O_WRONLY
%24 = or i32 %22, %23
%25 = call i32 @open(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 420)
store i32 %25, i32* %2
%26 = icmp ne i32 %25, -1
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i32, i32* %2
%30 = call i32 @write(i32 %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 12)
%31 = load i32, i32* %2
%32 = call i32 @close(i32 %31)
%33 = load i32, i32* @O_CREAT
%34 = load i32, i32* @O_TRUNC
%35 = or i32 %33, %34
%36 = load i32, i32* @O_WRONLY
%37 = or i32 %35, %36
%38 = call i32 @open(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %37, i32 420)
store i32 %38, i32* %2
%39 = icmp ne i32 %38, -1
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load i32, i32* %2
%43 = call i32 @write(i32 %42, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 12)
%44 = load i32, i32* %2
%45 = load i32, i32* @SEEK_SET
%46 = call i32 @lseek(i32 %44, i32 31457280, i32 %45)
%47 = icmp ne i32 %46, -1
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i32, i32* %2
%51 = call i32 @write(i32 %50, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 13)
%52 = load i32, i32* %2
%53 = call i32 @close(i32 %52)
%54 = call i32 (...) @stop_timer()
%55 = load i32, i32* %1
ret i32 %55
}

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 i32 @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 i32 undef
}