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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11b8 <main+0x38>
lea    0xe59(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    126b <main+0xeb>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <strlen@plt>
add    $0x2,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %al,-0x21(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <bmount@plt>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     1247 <main+0xc7>
mov    -0x30(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x30(%rbp),%rdi
movsbl -0x21(%rbp),%esi
call   1050 <mi_creat@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1070 <bumount@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x4,%edi
jne    120e <main+0x8e>
mov    %rsi,%r14
mov    0x18(%rsi),%rdi
call   1060 <strlen@plt>
mov    %rsp,%r12
add    $0x2,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x18(%r14),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    0x10(%r14),%rdi
call   1090 <atoi@plt>
mov    %eax,%r15d
mov    0x8(%r14),%rdi
call   1080 <bmount@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
je     11f4 <main+0x74>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcat@plt>
movsbl %r15b,%esi
mov    %rbx,%rdi
call   1050 <mi_creat@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <bumount@plt>
mov    %r12,%rsp
jmp    121f <main+0x9f>
lea    0xdeb(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Uso: mi_mkdir <nombre_dispositivo> <permisos> <path>\00"
@.str.1 = [2 x i8] c"/\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @puts(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, 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 3
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = add nsw i32 %18, 2
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %6
%22 = alloca i8, i64 %20
store i64 %20, i64* %7
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32 @strcpy(i8* %22, i8* %25)
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call signext i8 @atoi(i8* %29)
store i8 %30, i8* %8
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @bmount(i8* %33)
%35 = call i32 @strlen(i8* %22)
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %22, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 47
br i1 %41, label %42, label %44
42: ; preds = %14
%43 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %42, %14
%45 = load i8, i8* %8
%46 = call i32 @mi_creat(i8* %22, i8 signext %45)
store i32 %46, i32* %9
%47 = call i32 (...) @bumount()
%48 = load i32, i32* %9
store i32 %48, i32* %3
%49 = load i8*, i8** %6
br label %50
50: ; preds = %44, %12
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [53 x i8] c"Uso: mi_mkdir <nombre_dispositivo> <permisos> <path>\00"
@.str.1 = [2 x i8] c"/\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 %33
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 2
%11 = zext i32 %10 to i64
%12 = tail call i8* @llvm.stacksave()
%13 = alloca i8, i64 %11
%14 = load i8*, i8** %7
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call signext i8 @atoi(i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @bmount(i8* %20)
%22 = call i32 @strlen(i8* %13)
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %13, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 47
br i1 %27, label %30, label %28
28: ; preds = %6
%29 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %6
%31 = call i32 @mi_creat(i8* %13, i8 signext %18)
%32 = call i32 (...) @bumount()
br label %33
33: ; preds = %30, %4
%34 = phi i32 [ -1, %4 ], [ %31, %30 ]
ret i32 %34
}