#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ check_disk();
scalar_t__ check_vol(unsigned int);
char *getenv(char *);
int /*<<< orphan*/ init_master();
int /*<<< orphan*/ init_super(unsigned int);
int /*<<< orphan*/ load_mbr();
int /*<<< orphan*/ load_super(unsigned int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char *cv, ch;
  unsigned int current_vol;
  init_master();
  check_disk();
  load_mbr();
  if ((cv = getenv("CURRENT_VOLUME")) != NULL) {
    current_vol = (unsigned int)atoi(cv);
  } else {
    current_vol = 0U;
  }
  if (check_vol(current_vol)) {
    if (!load_super(current_vol)) {
      printf("Un systeme de fichier est deja present sur cette partition,"
             "voulez-vous continuer ? [o/N] : ");
      (void)scanf(" %c", &ch);
      if (ch == 'o' || ch == 'O')
        init_super(current_vol);
    } else {
      init_super(current_vol);
    }
  } else
    printf("Impossible de creer un systeme de fichier pour"
           "cette partition.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <init_master@plt>
mov    $0x0,%al
call   1050 <check_disk@plt>
mov    $0x0,%al
call   10a0 <load_mbr@plt>
lea    0xe35(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11ef <main+0x4f>
mov    -0x10(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11f6 <main+0x56>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <check_vol@plt>
cmp    $0x0,%rax
je     1269 <main+0xc9>
mov    -0x18(%rbp),%edi
call   10b0 <load_super@plt>
cmp    $0x0,%eax
jne    125c <main+0xbc>
lea    0xdef(%rip),%rdi
call   1060 <printf@plt>
lea    0xe3f(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1090 <scanf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x6f,%eax
je     124f <main+0xaf>
movsbl -0x11(%rbp),%eax
cmp    $0x4f,%eax
jne    1257 <main+0xb7>
mov    -0x18(%rbp),%edi
call   1080 <init_super@plt>
jmp    1264 <main+0xc4>
mov    -0x18(%rbp),%edi
call   1080 <init_super@plt>
jmp    1275 <main+0xd5>
lea    0xdff(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <init_master@plt>
xor    %eax,%eax
call   1060 <check_disk@plt>
xor    %eax,%eax
call   10b0 <load_mbr@plt>
lea    0xe2d(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11e8 <main+0x38>
mov    %rax,%rdi
call   10d0 <atoi@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1080 <check_vol@plt>
test   %rax,%rax
je     122f <main+0x7f>
mov    %ebx,%edi
call   10c0 <load_super@plt>
test   %eax,%eax
jne    1226 <main+0x76>
lea    0xe09(%rip),%rdi
call   1070 <printf@plt>
lea    0xe59(%rip),%rdi
lea    0xf(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0xf(%rsp),%al
and    $0xdf,%al
cmp    $0x4f,%al
jne    123b <main+0x8b>
mov    %ebx,%edi
call   1090 <init_super@plt>
jmp    123b <main+0x8b>
lea    0xe39(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"CURRENT_VOLUME\00"
@.str.1 = [92 x i8] c"Un systeme de fichier est deja present sur cette partition,voulez-vous continuer ? [o/N] : \00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [64 x i8] c"Impossible de creer un systeme de fichier pourcette partition.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @init_master()
%6 = call i32 (...) @check_disk()
%7 = call i32 (...) @load_mbr()
%8 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %2
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i8*, i8** %2
%12 = call i64 @atoi(i8* %11)
%13 = trunc i64 %12 to i32
store i32 %13, i32* %4
br label %15
14: ; preds = %0
store i32 0, i32* %4
br label %15
15: ; preds = %14, %10
%16 = load i32, i32* %4
%17 = call i64 @check_vol(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = load i32, i32* %4
%21 = call i32 @load_super(i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %19
%24 = call i32 @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 111
br i1 %28, label %33, label %29
29: ; preds = %23
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 79
br i1 %32, label %33, label %36
33: ; preds = %29, %23
%34 = load i32, i32* %4
%35 = call i32 @init_super(i32 %34)
br label %36
36: ; preds = %33, %29
br label %40
37: ; preds = %19
%38 = load i32, i32* %4
%39 = call i32 @init_super(i32 %38)
br label %40
40: ; preds = %37, %36
br label %43
41: ; preds = %15
%42 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"CURRENT_VOLUME\00"
@.str.1 = [92 x i8] c"Un systeme de fichier est deja present sur cette partition,voulez-vous continuer ? [o/N] : \00"
@.str.2 = [4 x i8] c" %c\00"
@str = [63 x i8] c"Impossible de creer un systeme de fichier pourcette partition.\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (...) @init_master()
%3 = tail call i32 (...) @check_disk()
%4 = tail call i32 (...) @load_mbr()
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = tail call i64 @atoi(i8* %5)
%9 = trunc i64 %8 to i32
br label %10
10: ; preds = %0, %7
%11 = phi i32 [ %9, %7 ], [ 0, %0 ]
%12 = tail call i64 @check_vol(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %27, label %14
14: ; preds = %10
%15 = tail call i32 @load_super(i32 %11)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%20 = load i8, i8* %1
%21 = and i8 %20, -33
%22 = icmp eq i8 %21, 79
br i1 %22, label %23, label %29
23: ; preds = %17
%24 = call i32 @init_super(i32 %11)
br label %29
25: ; preds = %14
%26 = tail call i32 @init_super(i32 %11)
br label %29
27: ; preds = %10
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %25, %17, %23, %27
ret i32 0
}