#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 bmount(char *);
int bumount();
int /*<<< orphan*/ exit(int);
int mi_creat(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("[crear_entrades.c] ERROR: Arguments incorrectes. Ex: "
           "./crear_entrades disco.imagen\n");
    exit(-1);
  }
  if (bmount(argv[1]) == -1) {
    return -1;
  }
  char nom[50];
  int i = 0;
  for (i = 1; i <= 16; i++) {
    sprintf(nom, "/dir%d/", i);
    if (mi_creat(nom, 7) == -1) {
      printf("[crear_entrades.c] ERROR: No s'han creat les entrades.\n");
      return -1;
    }
  }
  if (bumount() == -1) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1196 <main+0x36>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <bmount@plt>
cmp    $0xffffffff,%eax
jne    11b8 <main+0x58>
movl   $0xffffffff,-0x4(%rbp)
jmp    1248 <main+0xe8>
movl   $0x0,-0x54(%rbp)
movl   $0x1,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jg     1225 <main+0xc5>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
lea    0xe76(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x7,%esi
call   1030 <mi_creat@plt>
cmp    $0xffffffff,%eax
jne    1212 <main+0xb2>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1248 <main+0xe8>
jmp    1217 <main+0xb7>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11c6 <main+0x66>
mov    $0x0,%al
call   1050 <bumount@plt>
cmp    $0xffffffff,%eax
jne    1241 <main+0xe1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1248 <main+0xe8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
cmp    $0x2,%edi
jne    11e7 <main+0x87>
mov    0x8(%rsi),%rdi
call   1060 <bmount@plt>
cmp    $0xffffffff,%eax
je     11d8 <main+0x78>
mov    $0x1,%ebx
lea    0xe78(%rip),%r14
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1070 <sprintf@plt>
mov    %r15,%rdi
mov    $0x7,%esi
call   1040 <mi_creat@plt>
cmp    $0xffffffff,%eax
je     11cc <main+0x6c>
add    $0x1,%ebx
cmp    $0x11,%ebx
jne    1190 <main+0x30>
xor    %eax,%eax
call   1050 <bumount@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
sete   %al
neg    %eax
jmp    11dd <main+0x7d>
lea    0xe35(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [84 x i8] c"[crear_entrades.c] ERROR: Arguments incorrectes. Ex: ./crear_entrades disco.imagen\0A\00"
@.str.1 = [8 x i8] c"/dir%d/\00"
@.str.2 = [56 x i8] c"[crear_entrades.c] ERROR: No s'han creat les entrades.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [50 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @bmount(i8* %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 -1, i32* %3
br label %42
20: ; preds = %13
store i32 0, i32* %7
store i32 1, i32* %7
br label %21
21: ; preds = %34, %20
%22 = load i32, i32* %7
%23 = icmp sle i32 %22, 16
br i1 %23, label %24, label %37
24: ; preds = %21
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%26 = load i32, i32* %7
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%29 = call i32 @mi_creat(i8* %28, i32 7)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %42
33: ; preds = %24
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %21
37: ; preds = %21
%38 = call i32 (...) @bumount()
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 -1, i32* %3
br label %42
41: ; preds = %37
store i32 0, i32* %3
br label %42
42: ; preds = %41, %40, %31, %19
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"/dir%d/\00"
@str = [55 x i8] c"[crear_entrades.c] ERROR: No s'han creat les entrades.\00"
@str.3 = [83 x i8] c"[crear_entrades.c] ERROR: Arguments incorrectes. Ex: ./crear_entrades disco.imagen\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [50 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @str.3, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @bmount(i8* %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %31, label %13
13: ; preds = %8
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
br label %18
15: ; preds = %18
%16 = add nuw nsw i32 %19, 1
%17 = icmp eq i32 %16, 17
br i1 %17, label %25, label %18
18: ; preds = %13, %15
%19 = phi i32 [ 1, %13 ], [ %16, %15 ]
%20 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 @mi_creat(i8* %14, i32 7)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %15
23: ; preds = %18
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
br label %29
25: ; preds = %15
%26 = call i32 (...) @bumount()
%27 = icmp eq i32 %26, -1
%28 = sext i1 %27 to i32
br label %29
29: ; preds = %25, %23
%30 = phi i32 [ -1, %23 ], [ %28, %25 ]
br label %31
31: ; preds = %8, %29
%32 = phi i32 [ %30, %29 ], [ -1, %8 ]
ret i32 %32
}