#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 */
unsigned short atoi(char *);
int bmount(char *);
int bumount();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ mi_creat(char *, unsigned short);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sem_del();
int /*<<< orphan*/ sem_init();
int main(int argc, char *argv[]) {
  unsigned short int mode;
  if (argc != 4) {
    printf("[mi_creat.c] ERROR: Arguments incorrectes. Ex: mi_creat <nomFS> "
           "<cami> <permissos>\n");
    exit(-1);
  }
  sem_init();
  mode = atoi(argv[3]);
  if (mode < 0 || mode > 7) {
    printf("[mi_creat.c] ERROR: Permissos incorrectes!\n");
    sem_del();
    return -1;
  }
  if (bmount(argv[1]) == -1) {
    sem_del();
    return -1;
  }
  mi_creat(argv[2], mode);
  if (bumount() == -1) {
    sem_del();
    return -1;
  }
  sem_del();
  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)
cmpl   $0x4,-0x8(%rbp)
je     11b6 <main+0x36>
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1080 <sem_init@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %ax,-0x12(%rbp)
movzwl -0x12(%rbp),%eax
cmp    $0x0,%eax
jl     11e8 <main+0x68>
movzwl -0x12(%rbp),%eax
cmp    $0x7,%eax
jle    1207 <main+0x87>
lea    0xe65(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <sem_del@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1272 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <bmount@plt>
cmp    $0xffffffff,%eax
jne    1230 <main+0xb0>
mov    $0x0,%al
call   1040 <sem_del@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1272 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
movzwl -0x12(%rbp),%esi
call   1030 <mi_creat@plt>
mov    $0x0,%al
call   1060 <bumount@plt>
cmp    $0xffffffff,%eax
jne    1264 <main+0xe4>
mov    $0x0,%al
call   1040 <sem_del@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1272 <main+0xf2>
mov    $0x0,%al
call   1040 <sem_del@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    11fa <main+0x7a>
mov    %rsi,%rbx
xor    %eax,%eax
call   1080 <sem_init@plt>
mov    0x18(%rbx),%rdi
call   1090 <atoi@plt>
cmp    $0x8,%ax
jb     11af <main+0x2f>
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
jmp    11e5 <main+0x65>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
call   1070 <bmount@plt>
cmp    $0xffffffff,%eax
je     11e5 <main+0x65>
mov    0x10(%rbx),%rdi
movzwl %bp,%esi
call   1040 <mi_creat@plt>
xor    %eax,%eax
call   1060 <bumount@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
xor    %eax,%eax
call   1050 <sem_del@plt>
neg    %ebx
jmp    11f1 <main+0x71>
xor    %eax,%eax
call   1050 <sem_del@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [84 x i8] c"[mi_creat.c] ERROR: Arguments incorrectes. Ex: mi_creat <nomFS> <cami> <permissos>\0A\00"
@.str.1 = [44 x i8] c"[mi_creat.c] ERROR: Permissos incorrectes!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 4
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = call i32 (...) @sem_init()
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 3
%16 = load i8*, i8** %15
%17 = call zeroext i16 @atoi(i8* %16)
store i16 %17, i16* %6
%18 = load i16, i16* %6
%19 = zext i16 %18 to i32
%20 = icmp slt i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %12
%22 = load i16, i16* %6
%23 = zext i16 %22 to i32
%24 = icmp sgt i32 %23, 7
br i1 %24, label %25, label %28
25: ; preds = %21, %12
%26 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 (...) @sem_del()
store i32 -1, i32* %3
br label %48
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @bmount(i8* %31)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (...) @sem_del()
store i32 -1, i32* %3
br label %48
36: ; preds = %28
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = load i16, i16* %6
%41 = call i32 @mi_creat(i8* %39, i16 zeroext %40)
%42 = call i32 (...) @bumount()
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %36
%45 = call i32 (...) @sem_del()
store i32 -1, i32* %3
br label %48
46: ; preds = %36
%47 = call i32 (...) @sem_del()
store i32 0, i32* %3
br label %48
48: ; preds = %46, %44, %34, %25
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@str = [43 x i8] c"[mi_creat.c] ERROR: Permissos incorrectes!\00"
@str.2 = [83 x i8] c"[mi_creat.c] ERROR: Arguments incorrectes. Ex: mi_creat <nomFS> <cami> <permissos>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @str.2, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = tail call i32 (...) @sem_init()
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call zeroext i16 @atoi(i8* %10)
%12 = icmp ugt i16 %11, 7
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 (...) @sem_del()
br label %31
16: ; preds = %7
%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 %21, label %23
21: ; preds = %16
%22 = tail call i32 (...) @sem_del()
br label %31
23: ; preds = %16
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @mi_creat(i8* %25, i16 zeroext %11)
%27 = tail call i32 (...) @bumount()
%28 = icmp eq i32 %27, -1
%29 = tail call i32 (...) @sem_del()
%30 = sext i1 %28 to i32
br label %31
31: ; preds = %23, %21, %13
%32 = phi i32 [ -1, %13 ], [ -1, %21 ], [ %30, %23 ]
ret i32 %32
}