#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*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ fs_create(char *);
scalar_t__ fs_delete(char *);
scalar_t__ mount_fs(char *);
int /*<<< orphan*/ stderr;
scalar_t__ umount_fs(char *);
int test_file_creation() {
  char *fname = "test_file";
  if (mount_fs("test.fs")) {
    fprintf(stderr, "test_file_creation: Mount failed.\n");
    return -1;
  }
  if (fs_create(fname)) {
    fprintf(stderr, "test_file_creation: File creation failed.\n");
    return -1;
  }
  if (umount_fs("test.fs")) {
    fprintf(stderr, "test_file_creation: Unmount failed.\n");
    return -1;
  }
  if (mount_fs("test.fs")) {
    fprintf(stderr, "test_file_creation: Mount failed.\n");
    return -1;
  }
  if (fs_delete(fname)) {
    fprintf(stderr, "test_file_creation: File deletion failed.\n");
    return -1;
  }
  if (umount_fs("test.fs")) {
    fprintf(stderr, "test_file_creation: Unmount failed.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_file_creation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xea0(%rip),%rdi
call   1070 <mount_fs@plt>
cmp    $0x0,%rax
je     119a <test_file_creation+0x4a>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ae <test_file_creation+0x15e>
mov    -0x10(%rbp),%rdi
call   1030 <fs_create@plt>
cmp    $0x0,%rax
je     11ce <test_file_creation+0x7e>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ae <test_file_creation+0x15e>
lea    0xe35(%rip),%rdi
call   1040 <umount_fs@plt>
cmp    $0x0,%rax
je     1205 <test_file_creation+0xb5>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ae <test_file_creation+0x15e>
lea    0xdfe(%rip),%rdi
call   1070 <mount_fs@plt>
cmp    $0x0,%rax
je     123c <test_file_creation+0xec>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
lea    0xde7(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ae <test_file_creation+0x15e>
mov    -0x10(%rbp),%rdi
call   1060 <fs_delete@plt>
cmp    $0x0,%rax
je     1270 <test_file_creation+0x120>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ae <test_file_creation+0x15e>
lea    0xd93(%rip),%rdi
call   1040 <umount_fs@plt>
cmp    $0x0,%rax
je     12a7 <test_file_creation+0x157>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ae <test_file_creation+0x15e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_file_creation>:
push   %r14
push   %rbx
push   %rax
lea    0xeaf(%rip),%rdi
call   1070 <mount_fs@plt>
lea    0xeab(%rip),%rbx
test   %rax,%rax
jne    11e2 <test_file_creation+0x92>
lea    0xe8d(%rip),%rdi
call   1030 <fs_create@plt>
test   %rax,%rax
je     1186 <test_file_creation+0x36>
lea    0xeb1(%rip),%rbx
jmp    11e2 <test_file_creation+0x92>
lea    0xe7d(%rip),%rdi
call   1040 <umount_fs@plt>
lea    0xec7(%rip),%r14
test   %rax,%rax
je     11a3 <test_file_creation+0x53>
mov    %r14,%rbx
jmp    11e2 <test_file_creation+0x92>
lea    0xe60(%rip),%rdi
call   1070 <mount_fs@plt>
test   %rax,%rax
jne    11e2 <test_file_creation+0x92>
lea    0xe45(%rip),%rdi
call   1060 <fs_delete@plt>
test   %rax,%rax
je     11ce <test_file_creation+0x7e>
lea    0xeb9(%rip),%rbx
jmp    11e2 <test_file_creation+0x92>
lea    0xe35(%rip),%rdi
call   1040 <umount_fs@plt>
mov    %r14,%rbx
test   %rax,%rax
je     1200 <test_file_creation+0xb0>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    11f8 <test_file_creation+0xa8>

LLVM IR (-O0):
@.str = [10 x i8] c"test_file\00"
@.str.1 = [8 x i8] c"test.fs\00"
@stderr = global i32 0
@.str.2 = [35 x i8] c"test_file_creation: Mount failed.\0A\00"
@.str.3 = [43 x i8] c"test_file_creation: File creation failed.\0A\00"
@.str.4 = [37 x i8] c"test_file_creation: Unmount failed.\0A\00"
@.str.5 = [43 x i8] c"test_file_creation: File deletion failed.\0A\00"
define i32 @test_file_creation() {
%1 = alloca i32
%2 = alloca i8*
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = call i64 @mount_fs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %41
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i64 @fs_create(i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %41
15: ; preds = %8
%16 = call i64 @umount_fs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %41
21: ; preds = %15
%22 = call i64 @mount_fs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %41
27: ; preds = %21
%28 = load i8*, i8** %2
%29 = call i64 @fs_delete(i8* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %41
34: ; preds = %27
%35 = call i64 @umount_fs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %41
40: ; preds = %34
store i32 0, i32* %1
br label %41
41: ; preds = %40, %37, %31, %24, %18, %12, %5
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str = [10 x i8] c"test_file\00"
@.str.1 = [8 x i8] c"test.fs\00"
@stderr = global i32 0
@.str.2 = [35 x i8] c"test_file_creation: Mount failed.\0A\00"
@.str.3 = [43 x i8] c"test_file_creation: File creation failed.\0A\00"
@.str.4 = [37 x i8] c"test_file_creation: Unmount failed.\0A\00"
@.str.5 = [43 x i8] c"test_file_creation: File deletion failed.\0A\00"
define i32 @test_file_creation() {
%1 = tail call i64 @mount_fs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %18
3: ; preds = %0
%4 = tail call i64 @fs_create(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = tail call i64 @umount_fs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = tail call i64 @mount_fs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = tail call i64 @fs_delete(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = tail call i64 @umount_fs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15, %12, %9, %6, %3, %0
%19 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), %3 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), %12 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), %15 ]
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* %19)
br label %22
22: ; preds = %18, %15
%23 = phi i32 [ 0, %15 ], [ -1, %18 ]
ret i32 %23
}