#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 checkFSValid(int);
int /*<<< orphan*/ formatFS(int);
int isDiskExtant(char *);
int openDisk(char *, int);
int mountFS() {
  int diskNum = -1;
  int isFSValid = -1;
  if (isDiskExtant("tinyFSDisk") == 1) {
    if ((diskNum = openDisk("tinyFSDisk", 0)) == -1) {
      return -1;
    }
  } else {
    if ((diskNum = openDisk("tinyFSDisk", 10240)) == -1) {
      return -1;
    }
  }
  if ((isFSValid = checkFSValid(diskNum)) == -1) {
    return -1;
  } else if (isFSValid == 0) {
    formatFS(diskNum);
  }
  return diskNum;
}


x86 assembly (clang, -O0):
<mountFS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
lea    0xea3(%rip),%rdi
call   1060 <isDiskExtant@plt>
cmp    $0x1,%eax
jne    1196 <mountFS+0x56>
lea    0xe8e(%rip),%rdi
xor    %esi,%esi
call   1040 <openDisk@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    1191 <mountFS+0x51>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <mountFS+0xc1>
jmp    11c4 <mountFS+0x84>
lea    0xe63(%rip),%rdi
mov    $0x2800,%esi
call   1040 <openDisk@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11bf <mountFS+0x7f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <mountFS+0xc1>
jmp    11c4 <mountFS+0x84>
mov    -0x8(%rbp),%edi
call   1050 <checkFSValid@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    11e4 <mountFS+0xa4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <mountFS+0xc1>
cmpl   $0x0,-0xc(%rbp)
jne    11f6 <mountFS+0xb6>
mov    -0x8(%rbp),%edi
call   1030 <formatFS@plt>
jmp    11fb <mountFS+0xbb>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mountFS>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1060 <isDiskExtant@plt>
lea    0xeac(%rip),%rdi
cmp    $0x1,%eax
jne    115d <mountFS+0x1d>
xor    %esi,%esi
jmp    1162 <mountFS+0x22>
mov    $0x2800,%esi
call   1040 <openDisk@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1187 <mountFS+0x47>
mov    %ebx,%edi
call   1050 <checkFSValid@plt>
cmp    $0xffffffff,%eax
je     118e <mountFS+0x4e>
test   %eax,%eax
jne    1190 <mountFS+0x50>
mov    %ebx,%edi
call   1030 <formatFS@plt>
jmp    1190 <mountFS+0x50>
mov    $0xffffffff,%ebx
jmp    1190 <mountFS+0x50>
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"tinyFSDisk\00"
define i32 @mountFS() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 -1, i32* %2
store i32 -1, i32* %3
%4 = call i32 @isDiskExtant(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = call i32 @openDisk(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %7, i32* %2
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 -1, i32* %1
br label %30
10: ; preds = %6
br label %16
11: ; preds = %0
%12 = call i32 @openDisk(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10240)
store i32 %12, i32* %2
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 -1, i32* %1
br label %30
15: ; preds = %11
br label %16
16: ; preds = %15, %10
%17 = load i32, i32* %2
%18 = call i32 @checkFSValid(i32 %17)
store i32 %18, i32* %3
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %1
br label %30
21: ; preds = %16
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %2
%26 = call i32 @formatFS(i32 %25)
br label %27
27: ; preds = %24, %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %2
store i32 %29, i32* %1
br label %30
30: ; preds = %28, %20, %14, %9
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [11 x i8] c"tinyFSDisk\00"
define i32 @mountFS() {
%1 = tail call i32 @isDiskExtant(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @openDisk(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %15, label %9
6: ; preds = %0
%7 = tail call i32 @openDisk(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10240)
%8 = icmp eq i32 %7, -1
br i1 %8, label %15, label %9
9: ; preds = %6, %3
%10 = phi i32 [ %4, %3 ], [ %7, %6 ]
%11 = tail call i32 @checkFSValid(i32 %10)
switch i32 %11, label %14 [
i32 -1, label %15
i32 0, label %12
]
12: ; preds = %9
%13 = tail call i32 @formatFS(i32 %10)
br label %14
14: ; preds = %9, %12
br label %15
15: ; preds = %9, %6, %3, %14
%16 = phi i32 [ %10, %14 ], [ -1, %3 ], [ -1, %6 ], [ %11, %9 ]
ret i32 %16
}