#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 atoi(char *);
int bmount(char *);
int bumount();
int bwrite(int, unsigned char *);
int /*<<< orphan*/ exit(int);
int infoSB();
int initAI(int);
int initMB();
int initSB(int);
int /*<<< orphan*/ printf(char *);
int reservarInode(int, int);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("[mi_mkfs.c] ERROR: Arguments incorrectes. Ex: mi_chmod <nomFS> "
           "<num_blocs>\n");
    exit(-1);
  }
  if (atoi(argv[2]) < 0) {
    printf("[mi_mkfs.c] ERROR: Nombre de bloc incorrectes\n");
    exit(-1);
  }
  if (bmount(argv[1]) == -1) {
    return -1;
  }
  int i;
  unsigned char buff[1024];
  for (i = 0; i < atoi(argv[2]); i++) {
    if (bwrite(i, buff) == -1) {
      return -1;
    }
  }
  if (initSB(atoi(argv[2])) == -1) {
    printf("[mi_mkfs.c] ERROR: Error cridant a initSB");
    return -1;
  }
  if (initMB() == -1) {
    printf("[mi_mkfs.c] ERROR: Error cridant a initMB");
    return -1;
  }
  if (initAI(atoi(argv[2])) == -1) {
    printf("[mi_mkfs.c] ERROR: Error cridant a initAI");
    return -1;
  }
  int r;
  if ((r = reservarInode(1, 7)) == -1) {
    printf("[mi_mkfs.c] ERROR: Error cridant a reservarInode");
    return -1;
  }
  if (infoSB() == -1) {
    printf("[mi_mkfs.c] ERROR: Error cridant a infoSB");
    return -1;
  }
  if (bumount() == -1) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11e9 <main+0x39>
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
cmp    $0x0,%eax
jge    1215 <main+0x65>
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <bmount@plt>
cmp    $0xffffffff,%eax
jne    1237 <main+0x87>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ae <main+0x1fe>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x428(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ecx
mov    -0x428(%rbp),%eax
cmp    %ecx,%eax
jge    129b <main+0xeb>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
call   1030 <bwrite@plt>
cmp    $0xffffffff,%eax
jne    1288 <main+0xd8>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ae <main+0x1fe>
jmp    128d <main+0xdd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123e <main+0x8e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edi
call   10a0 <initSB@plt>
cmp    $0xffffffff,%eax
jne    12d0 <main+0x120>
lea    0xdbc(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ae <main+0x1fe>
mov    $0x0,%al
call   1090 <initMB@plt>
cmp    $0xffffffff,%eax
jne    12f8 <main+0x148>
lea    0xdbe(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ae <main+0x1fe>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edi
call   1080 <initAI@plt>
cmp    $0xffffffff,%eax
jne    132d <main+0x17d>
lea    0xdb3(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ae <main+0x1fe>
mov    $0x1,%edi
mov    $0x7,%esi
call   10d0 <reservarInode@plt>
mov    %eax,-0x424(%rbp)
cmp    $0xffffffff,%eax
jne    1363 <main+0x1b3>
lea    0xda7(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ae <main+0x1fe>
mov    $0x0,%al
call   1070 <infoSB@plt>
cmp    $0xffffffff,%eax
jne    138b <main+0x1db>
lea    0xdb0(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ae <main+0x1fe>
mov    $0x0,%al
call   1050 <bumount@plt>
cmp    $0xffffffff,%eax
jne    13a7 <main+0x1f7>
movl   $0xffffffff,-0x4(%rbp)
jmp    13ae <main+0x1fe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
cmp    $0x3,%edi
jne    12d6 <main+0x116>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   10c0 <atoi@plt>
test   %eax,%eax
js     12df <main+0x11f>
mov    0x8(%rbx),%rdi
call   1070 <bmount@plt>
cmp    $0xffffffff,%eax
je     12c5 <main+0x105>
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
test   %eax,%eax
jle    1233 <main+0x73>
xor    %ebp,%ebp
mov    %rsp,%r14
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <bwrite@plt>
cmp    $0xffffffff,%eax
je     12c5 <main+0x105>
add    $0x1,%ebp
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
cmp    %eax,%ebp
jl     1210 <main+0x50>
mov    %eax,%edi
call   10b0 <initSB@plt>
cmp    $0xffffffff,%eax
je     1295 <main+0xd5>
xor    %eax,%eax
call   10a0 <initMB@plt>
cmp    $0xffffffff,%eax
je     129e <main+0xde>
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%edi
call   1090 <initAI@plt>
cmp    $0xffffffff,%eax
je     12a7 <main+0xe7>
mov    $0x1,%edi
mov    $0x7,%esi
call   10e0 <reservarInode@plt>
cmp    $0xffffffff,%eax
je     12b0 <main+0xf0>
xor    %eax,%eax
call   1080 <infoSB@plt>
cmp    $0xffffffff,%eax
je     12b9 <main+0xf9>
xor    %eax,%eax
call   1060 <bumount@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
sete   %al
neg    %eax
jmp    12ca <main+0x10a>
lea    0xd64(%rip),%rdi
jmp    12c0 <main+0x100>
lea    0xd85(%rip),%rdi
jmp    12c0 <main+0x100>
lea    0xda6(%rip),%rdi
jmp    12c0 <main+0x100>
lea    0xdc7(%rip),%rdi
jmp    12c0 <main+0x100>
lea    0xdef(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe2a(%rip),%rdi
jmp    12e6 <main+0x126>
lea    0xdf3(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [76 x i8] c"[mi_mkfs.c] ERROR: Arguments incorrectes. Ex: mi_chmod <nomFS> <num_blocs>\0A\00"
@.str.1 = [47 x i8] c"[mi_mkfs.c] ERROR: Nombre de bloc incorrectes\0A\00"
@.str.2 = [42 x i8] c"[mi_mkfs.c] ERROR: Error cridant a initSB\00"
@.str.3 = [42 x i8] c"[mi_mkfs.c] ERROR: Error cridant a initMB\00"
@.str.4 = [42 x i8] c"[mi_mkfs.c] ERROR: Error cridant a initAI\00"
@.str.5 = [49 x i8] c"[mi_mkfs.c] ERROR: Error cridant a reservarInode\00"
@.str.6 = [42 x i8] c"[mi_mkfs.c] ERROR: Error cridant a infoSB\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @bmount(i8* %26)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 -1, i32* %3
br label %86
30: ; preds = %23
store i32 0, i32* %6
br label %31
31: ; preds = %45, %30
%32 = load i32, i32* %6
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
%37 = icmp slt i32 %32, %36
br i1 %37, label %38, label %48
38: ; preds = %31
%39 = load i32, i32* %6
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%41 = call i32 @bwrite(i32 %39, i8* %40)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %44
43: ; preds = %38
store i32 -1, i32* %3
br label %86
44: ; preds = %38
br label %45
45: ; preds = %44
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %31
48: ; preds = %31
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 @atoi(i8* %51)
%53 = call i32 @initSB(i32 %52)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %48
%56 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
57: ; preds = %48
%58 = call i32 (...) @initMB()
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
62: ; preds = %57
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = call i32 @atoi(i8* %65)
%67 = call i32 @initAI(i32 %66)
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %71
69: ; preds = %62
%70 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
71: ; preds = %62
%72 = call i32 @reservarInode(i32 1, i32 7)
store i32 %72, i32* %8
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
76: ; preds = %71
%77 = call i32 (...) @infoSB()
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
81: ; preds = %76
%82 = call i32 (...) @bumount()
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %85
84: ; preds = %81
store i32 -1, i32* %3
br label %86
85: ; preds = %81
store i32 0, i32* %3
br label %86
86: ; preds = %85, %84, %79, %74, %69, %60, %55, %43, %29
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@.str.2 = [42 x i8] c"[mi_mkfs.c] ERROR: Error cridant a initSB\00"
@.str.3 = [42 x i8] c"[mi_mkfs.c] ERROR: Error cridant a initMB\00"
@.str.4 = [42 x i8] c"[mi_mkfs.c] ERROR: Error cridant a initAI\00"
@.str.5 = [49 x i8] c"[mi_mkfs.c] ERROR: Error cridant a reservarInode\00"
@.str.6 = [42 x i8] c"[mi_mkfs.c] ERROR: Error cridant a infoSB\00"
@str = [46 x i8] c"[mi_mkfs.c] ERROR: Nombre de bloc incorrectes\00"
@str.7 = [75 x i8] c"[mi_mkfs.c] ERROR: Arguments incorrectes. Ex: mi_chmod <nomFS> <num_blocs>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = icmp eq i32 %0, 3
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str.7, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %8
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @bmount(i8* %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %69, label %21
21: ; preds = %16
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%23 = load i8*, i8** %9
%24 = call i32 @atoi(i8* %23)
%25 = icmp sgt i32 %24, 0
br i1 %25, label %30, label %35
26: ; preds = %30
%27 = load i8*, i8** %9
%28 = call i32 @atoi(i8* %27)
%29 = icmp slt i32 %34, %28
br i1 %29, label %30, label %35
30: ; preds = %21, %26
%31 = phi i32 [ %34, %26 ], [ 0, %21 ]
%32 = call i32 @bwrite(i32 %31, i8* %22)
%33 = icmp eq i32 %32, -1
%34 = add nuw nsw i32 %31, 1
br i1 %33, label %67, label %26
35: ; preds = %26, %21
%36 = phi i32 [ %24, %21 ], [ %28, %26 ]
%37 = call i32 @initSB(i32 %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %67
41: ; preds = %35
%42 = call i32 (...) @initMB()
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
br label %67
46: ; preds = %41
%47 = load i8*, i8** %9
%48 = call i32 @atoi(i8* %47)
%49 = call i32 @initAI(i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
br label %67
53: ; preds = %46
%54 = call i32 @reservarInode(i32 1, i32 7)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %67
58: ; preds = %53
%59 = call i32 (...) @infoSB()
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
br label %67
63: ; preds = %58
%64 = call i32 (...) @bumount()
%65 = icmp eq i32 %64, -1
%66 = sext i1 %65 to i32
br label %67
67: ; preds = %30, %56, %61, %63, %51, %44, %39
%68 = phi i32 [ -1, %39 ], [ -1, %44 ], [ -1, %51 ], [ -1, %56 ], [ -1, %61 ], [ %66, %63 ], [ -1, %30 ]
br label %69
69: ; preds = %16, %67
%70 = phi i32 [ %68, %67 ], [ -1, %16 ]
ret i32 %70
}