#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*/ mi_read_f(unsigned int, unsigned char *, int,
                             int /*<<< orphan*/);
int /*<<< orphan*/ mi_write_f(unsigned int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
unsigned int reservar_inodo(float, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, unsigned char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  printf("\n\n\n\n\n\nInicio ejecución 'escribir.c' \n\n");
  if (argc != 2) {
    printf("ERROR: escribir.c => main: Faltan argumentos!!! El número "
           "permitido de argumentos son 2. \n");
    return -1;
  } else {
    if (bmount(argv[1]) == -1) {
      printf("ERROR: escribir.c => main: Error al abrir (bmount) el sistema de "
             "ficheros.\n");
      return -1;
    }
    printf("El nombre del Sistema de Ficheros es: %s \n", argv[1]);
    char *string = "Esto es una prueba";
    unsigned int ninodo = reservar_inodo('f', 6);
    mi_write_f(ninodo, string, 71680000, strlen(string));
    unsigned char leido[1024];
    mi_read_f(ninodo, leido, 71680000, strlen(string));
    printf("Contenido leido:\n");
    write(1, leido, strlen(string));
    printf("\n");
    if (bumount() == -1) {
      printf("ERROR: escribir.c => main =>Error al cerrar(bumount) el sistema "
             "de ficheros.\n");
      return -1;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
je     11cb <main+0x4b>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    131c <main+0x19c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <bmount@plt>
cmp    $0xffffffff,%eax
jne    11fb <main+0x7b>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    131c <main+0x19c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xee7(%rip),%rax
mov    %rax,-0x18(%rbp)
movss  0xddc(%rip),%xmm0
mov    $0x6,%edi
call   10a0 <reservar_inodo@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x444(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x440(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x444(%rbp),%edi
mov    -0x440(%rbp),%rsi
mov    %eax,%ecx
mov    $0x445c000,%edx
call   1050 <mi_write_f@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x434(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rsi
mov    %eax,%ecx
mov    $0x445c000,%edx
call   1030 <mi_read_f@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x428(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1040 <write@plt>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1080 <bumount@plt>
cmp    $0xffffffff,%eax
jne    1310 <main+0x190>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    131c <main+0x19c>
jmp    1315 <main+0x195>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe8b(%rip),%rdi
call   1050 <puts@plt>
cmp    $0x2,%ebp
jne    1280 <main+0xe0>
mov    0x8(%rbx),%rdi
call   10b0 <bmount@plt>
cmp    $0xffffffff,%eax
je     1289 <main+0xe9>
mov    0x8(%rbx),%rsi
lea    0xe22(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
movss  0xe0f(%rip),%xmm0
mov    $0x6,%edi
call   10c0 <reservar_inodo@plt>
mov    %eax,%ebp
lea    0xe2b(%rip),%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x445c000,%edx
mov    %eax,%ecx
call   1070 <mi_write_f@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %rsp,%r14
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x445c000,%edx
mov    %eax,%ecx
call   1040 <mi_read_f@plt>
lea    0xe29(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    $0x1,%ebx
mov    $0x1,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10a0 <bumount@plt>
cmp    $0xffffffff,%eax
jne    129a <main+0xfa>
lea    0xdfc(%rip),%rdi
jmp    1290 <main+0xf0>
lea    0xe8b(%rip),%rdi
jmp    1290 <main+0xf0>
lea    0xe37(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"\0A\0A\0A\0A\0A\0AInicio ejecuci\C3\B3n 'escribir.c' \0A\0A\00"
@.str.1 = [92 x i8] c"ERROR: escribir.c => main: Faltan argumentos!!! El n\C3\BAmero permitido de argumentos son 2. \0A\00"
@.str.2 = [76 x i8] c"ERROR: escribir.c => main: Error al abrir (bmount) el sistema de ficheros.\0A\00"
@.str.3 = [43 x i8] c"El nombre del Sistema de Ficheros es: %s \0A\00"
@.str.4 = [19 x i8] c"Esto es una prueba\00"
@.str.5 = [18 x i8] c"Contenido leido:\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [78 x i8] c"ERROR: escribir.c => main =>Error al cerrar(bumount) el sistema de ficheros.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %50
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @bmount(i8* %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %50
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %25)
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8** %6
%27 = call i32 @reservar_inodo(float 1.020000e+02, i32 6)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = load i8*, i8** %6
%30 = load i8*, i8** %6
%31 = call i32 @strlen(i8* %30)
%32 = call i32 @mi_write_f(i32 %28, i8* %29, i32 71680000, i32 %31)
%33 = load i32, i32* %7
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%35 = load i8*, i8** %6
%36 = call i32 @strlen(i8* %35)
%37 = call i32 @mi_read_f(i32 %33, i8* %34, i32 71680000, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%40 = load i8*, i8** %6
%41 = call i32 @strlen(i8* %40)
%42 = call i32 @write(i32 1, i8* %39, i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 (...) @bumount()
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %22
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %50
48: ; preds = %22
br label %49
49: ; preds = %48
store i32 1, i32* %3
br label %50
50: ; preds = %49, %46, %20, %12
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str.3 = [43 x i8] c"El nombre del Sistema de Ficheros es: %s \0A\00"
@.str.4 = [19 x i8] c"Esto es una prueba\00"
@str = [39 x i8] c"\0A\0A\0A\0A\0A\0AInicio ejecuci\C3\B3n 'escribir.c' \0A\00"
@str.8 = [17 x i8] c"Contenido leido:\00"
@str.9 = [77 x i8] c"ERROR: escribir.c => main =>Error al cerrar(bumount) el sistema de ficheros.\00"
@str.10 = [75 x i8] c"ERROR: escribir.c => main: Error al abrir (bmount) el sistema de ficheros.\00"
@str.11 = [91 x i8] c"ERROR: escribir.c => main: Faltan argumentos!!! El n\C3\BAmero permitido de argumentos son 2. \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.11, i64 0, i64 0))
br label %34
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 %13, label %15
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str.10, i64 0, i64 0))
br label %34
15: ; preds = %8
%16 = load i8*, i8** %9
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = tail call i32 @reservar_inodo(float 1.020000e+02, i32 6)
%19 = tail call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%20 = tail call i32 @mi_write_f(i32 %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 71680000, i32 %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%22 = tail call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @mi_read_f(i32 %18, i8* %21, i32 71680000, i32 %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%25 = call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @write(i32 1, i8* %21, i32 %25)
%27 = call i32 @putchar(i32 10)
%28 = call i32 (...) @bumount()
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %15
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str.9, i64 0, i64 0))
br label %32
32: ; preds = %15, %30
%33 = phi i32 [ 1, %15 ], [ -1, %30 ]
br label %34
34: ; preds = %32, %13, %6
%35 = phi i32 [ -1, %6 ], [ -1, %13 ], [ %33, %32 ]
ret i32 %35
}