#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 */
char atoi(char const *);
int /*<<< orphan*/ bmount(char const *);
int /*<<< orphan*/ bumount();
int mi_chmod(char const *, char);
int /*<<< orphan*/ puts(char *);
int main(int argc, char const *argv[]) {
  if (argc != 4) {
    puts("Uso: mi_chmod <nombre_dispositivo> <permisos> <path>");
    return -1;
  }
  const char *camino = argv[3];
  char permisos = atoi(argv[2]);
  int resultado;
  bmount(argv[1]);
  resultado = mi_chmod(camino, permisos);
  bumount();
  return resultado;
}


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     1188 <main+0x38>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <main+0x7e>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <bmount@plt>
mov    -0x18(%rbp),%rdi
movsbl -0x19(%rbp),%esi
call   1070 <mi_chmod@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <bumount@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x4,%edi
jne    118d <main+0x3d>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
mov    0x18(%rsi),%r14
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
call   1050 <bmount@plt>
movsbl %bpl,%esi
mov    %r14,%rdi
call   1070 <mi_chmod@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <bumount@plt>
mov    %ebx,%eax
jmp    119e <main+0x4e>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Uso: mi_chmod <nombre_dispositivo> <permisos> <path>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca 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, 4
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @puts(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %30
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 3
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call signext i8 @atoi(i8* %19)
store i8 %20, i8* %7
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @bmount(i8* %23)
%25 = load i8*, i8** %6
%26 = load i8, i8* %7
%27 = call i32 @mi_chmod(i8* %25, i8 signext %26)
store i32 %27, i32* %8
%28 = call i32 (...) @bumount()
%29 = load i32, i32* %8
store i32 %29, i32* %3
br label %30
30: ; preds = %13, %11
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [53 x i8] c"Uso: mi_chmod <nombre_dispositivo> <permisos> <path>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %17
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call signext i8 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @bmount(i8* %13)
%15 = tail call i32 @mi_chmod(i8* %8, i8 signext %11)
%16 = tail call i32 (...) @bumount()
br label %17
17: ; preds = %6, %4
%18 = phi i32 [ -1, %4 ], [ %15, %6 ]
ret i32 %18
}