#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int bmount(char *);
int bumount();
char *malloc(int);
int /*<<< orphan*/ mi_dir(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("ERROR: mi_ls => main: Faltan argumentos!!! El número permitido de "
           "argumentos son 3. \n");
    return (EXIT_FAILURE);
  } else {
    if (bmount(argv[1]) == -1) {
      printf("ERROR: mi_ls => main: Error al abrir (bmount) el sistema de "
             "ficheros.\n");
      return (EXIT_FAILURE);
    }
    char *buffer = malloc(7000);
    mi_dir(argv[2], buffer);
    printf("%s\n", buffer);
    if (bumount() == -1) {
      printf("ERROR: mi_ls => main =>Error al desmontar(bumount) el sistema de "
             "ficheros.\n");
      return (EXIT_FAILURE);
    }
  }
  return (EXIT_SUCCESS);
}


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   $0x3,-0x8(%rbp)
je     118f <main+0x3f>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1235 <main+0xe5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <bmount@plt>
cmp    $0xffffffff,%eax
jne    11c4 <main+0x74>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1235 <main+0xe5>
mov    $0x1b58,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <mi_dir@plt>
mov    -0x18(%rbp),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <bumount@plt>
cmp    $0xffffffff,%eax
jne    1224 <main+0xd4>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1235 <main+0xe5>
jmp    1229 <main+0xd9>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    11a1 <main+0x51>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <bmount@plt>
cmp    $0xffffffff,%eax
je     11aa <main+0x5a>
mov    $0x1b58,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    0x10(%rbx),%rdi
mov    %rax,%rsi
call   1070 <mi_dir@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <bumount@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     11c8 <main+0x78>
cmp    $0xffffffff,%ebp
je     11bf <main+0x6f>
jmp    11e2 <main+0x92>
lea    0xee9(%rip),%rdi
jmp    11b1 <main+0x61>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe31(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%ebx
cmp    $0xffffffff,%ebp
je     11bf <main+0x6f>
mov    0x2def(%rip),%rax
jmp    11bd <main+0x6d>

LLVM IR (-O0):
@.str = [87 x i8] c"ERROR: mi_ls => main: Faltan argumentos!!! El n\C3\BAmero permitido de argumentos son 3. \0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [71 x i8] c"ERROR: mi_ls => main: Error al abrir (bmount) el sistema de ficheros.\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [76 x i8] c"ERROR: mi_ls => main =>Error al desmontar(bumount) el sistema de ficheros.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
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, 3
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
store i32 %11, i32* %3
br label %38
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @bmount(i8* %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %3
br label %38
21: ; preds = %12
%22 = call i8* @malloc(i32 7000)
store i8* %22, i8** %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = load i8*, i8** %6
%27 = call i32 @mi_dir(i8* %25, i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = call i32 (...) @bumount()
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %35
32: ; preds = %21
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %3
br label %38
35: ; preds = %21
br label %36
36: ; preds = %35
%37 = load i32, i32* @EXIT_SUCCESS
store i32 %37, i32* %3
br label %38
38: ; preds = %36, %32, %18, %9
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [75 x i8] c"ERROR: mi_ls => main =>Error al desmontar(bumount) el sistema de ficheros.\00"
@str.4 = [70 x i8] c"ERROR: mi_ls => main: Error al abrir (bmount) el sistema de ficheros.\00"
@str.5 = [86 x i8] c"ERROR: mi_ls => main: Faltan argumentos!!! El n\C3\BAmero permitido de argumentos son 3. \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @str.5, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
br label %30
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @bmount(i8* %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.4, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
br label %30
15: ; preds = %7
%16 = tail call dereferenceable_or_null(7000) i8* @malloc(i32 7000)
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @mi_dir(i8* %18, i8* %16)
%20 = tail call i32 @puts(i8* dereferenceable(1) %16)
%21 = tail call i32 (...) @bumount()
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
br label %26
26: ; preds = %15, %23
%27 = phi i32 [ %25, %23 ], [ 0, %15 ]
%28 = load i32, i32* @EXIT_SUCCESS
%29 = select i1 %22, i32 %27, i32 %28
br label %30
30: ; preds = %26, %12, %4
%31 = phi i32 [ %6, %4 ], [ %14, %12 ], [ %29, %26 ]
ret i32 %31
}