#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(char *);
int /*<<< orphan*/ create(char *, int);
int /*<<< orphan*/ create_fs(char *);
int /*<<< orphan*/ mount_fs(char *);
int /*<<< orphan*/ open(char *);
int /*<<< orphan*/ read(char *);
int /*<<< orphan*/ sync_fs();
int /*<<< orphan*/ write(char *, char *);
int main(int argc, char **argv) {
  char *name = "filesystem_disk";
  create_fs(name);
  mount_fs(name);
  create("dir1", (0x02 | 0x04 | 0x20 | 0x01));
  open("dir1");
  create("file1", (0x02 | 0x04 | 0x20 | 0x00));
  open("file1");
  write("file1", "THIS BETTER WORK!!!!\0");
  read("file1");
  close("file1");
  close("dir1");
  create("file3", (0x02 | 0x04 | 0x20 | 0x00));
  sync_fs();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe63(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <create_fs@plt>
mov    -0x18(%rbp),%rdi
call   1090 <mount_fs@plt>
lea    0xe56(%rip),%rdi
mov    $0x27,%esi
call   1070 <create@plt>
lea    0xe45(%rip),%rdi
call   1080 <open@plt>
lea    0xe3e(%rip),%rdi
mov    $0x26,%esi
call   1070 <create@plt>
lea    0xe2d(%rip),%rdi
call   1080 <open@plt>
lea    0xe21(%rip),%rdi
lea    0xe26(%rip),%rsi
call   1030 <write@plt>
lea    0xe0e(%rip),%rdi
call   1060 <read@plt>
lea    0xe02(%rip),%rdi
call   1050 <close@plt>
lea    0xdf1(%rip),%rdi
call   1050 <close@plt>
lea    0xdf0(%rip),%rdi
mov    $0x26,%esi
call   1070 <create@plt>
mov    $0x0,%al
call   10a0 <sync_fs@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe75(%rip),%rbx
mov    %rbx,%rdi
call   1040 <create_fs@plt>
mov    %rbx,%rdi
call   1090 <mount_fs@plt>
lea    0xe6e(%rip),%r14
mov    %r14,%rdi
mov    $0x27,%esi
call   1070 <create@plt>
mov    %r14,%rdi
call   1080 <open@plt>
lea    0xe57(%rip),%rbx
mov    %rbx,%rdi
mov    $0x26,%esi
call   1070 <create@plt>
mov    %rbx,%rdi
call   1080 <open@plt>
lea    0xe47(%rip),%rsi
mov    %rbx,%rdi
call   1030 <write@plt>
mov    %rbx,%rdi
call   1060 <read@plt>
mov    %rbx,%rdi
call   1050 <close@plt>
mov    %r14,%rdi
call   1050 <close@plt>
lea    0xe1a(%rip),%rdi
mov    $0x26,%esi
call   1070 <create@plt>
xor    %eax,%eax
call   10a0 <sync_fs@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"filesystem_disk\00"
@.str.1 = [5 x i8] c"dir1\00"
@.str.2 = [6 x i8] c"file1\00"
@.str.3 = [22 x i8] c"THIS BETTER WORK!!!!\00\00"
@.str.4 = [6 x i8] c"file3\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i8*, i8** %6
%8 = call i32 @create_fs(i8* %7)
%9 = load i8*, i8** %6
%10 = call i32 @mount_fs(i8* %9)
%11 = call i32 @create(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 39)
%12 = call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @create(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 38)
%14 = call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @write(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @read(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @close(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @close(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @create(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 38)
%20 = call i32 (...) @sync_fs()
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"filesystem_disk\00"
@.str.1 = [5 x i8] c"dir1\00"
@.str.2 = [6 x i8] c"file1\00"
@.str.3 = [22 x i8] c"THIS BETTER WORK!!!!\00\00"
@.str.4 = [6 x i8] c"file3\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @create_fs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @mount_fs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @create(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 39)
%6 = tail call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @create(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 38)
%8 = tail call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @write(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @read(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @close(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @close(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @create(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 38)
%14 = tail call i32 (...) @sync_fs()
ret i32 0
}