#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 */
typedef int mode_t;

/* Variables and functions */
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ errno;
int mkdir(char *, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *filename = NULL;
  mode_t mode =
      S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
  int result = 0;
  if (argc == 1) {
    printf("Usage: %s [PATH/FolderName]\n", argv[0]);
    return -1;
  }
  filename = argv[1];
  if (!(result = mkdir(filename, mode))) {
    printf(
        "[I]: Success, now use \"ls [path/folder name]\" to see the result\n");
    return 0;
  } else {
    printf("[E]: Error, failed to create folder [%s], ErrorCode[%s]\n", argv[1],
           strerror(errno));
    return -1;
  }
}


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)
movq   $0x0,-0x18(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    0x2e7a(%rip),%rcx
or     (%rcx),%eax
mov    0x2e79(%rip),%rcx
or     (%rcx),%eax
mov    0x2e48(%rip),%rcx
or     (%rcx),%eax
mov    0x2e57(%rip),%rcx
or     (%rcx),%eax
mov    0x2e2e(%rip),%rcx
or     (%rcx),%eax
mov    0x2e5d(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11c2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1236 <main+0x106>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <mkdir@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jne    1200 <main+0xd0>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1236 <main+0x106>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jne    115c <main+0x1c>
mov    (%rbx),%rsi
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ce <main+0x8e>
mov    0x2e45(%rip),%rax
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e6b(%rip),%rax
or     (%rax),%esi
mov    0x2e3a(%rip),%rax
or     (%rax),%esi
mov    0x2e49(%rip),%rax
or     (%rax),%esi
mov    0x2e20(%rip),%rax
or     (%rax),%esi
mov    0x2e4f(%rip),%rax
or     (%rax),%esi
mov    0x8(%rbx),%rdi
call   1030 <mkdir@plt>
test   %eax,%eax
je     11d5 <main+0x95>
mov    0x8(%rbx),%rbx
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe5c(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@.str = [29 x i8] c"Usage: %s [PATH/FolderName]\0A\00"
@.str.1 = [65 x i8] c"[I]: Success, now use \22ls [path/folder name]\22 to see the result\0A\00"
@.str.2 = [57 x i8] c"[E]: Error, failed to create folder [%s], ErrorCode[%s]\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%9 = load i32, i32* @S_IRUSR
%10 = load i32, i32* @S_IWUSR
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IXUSR
%13 = or i32 %11, %12
%14 = load i32, i32* @S_IRGRP
%15 = or i32 %13, %14
%16 = load i32, i32* @S_IXGRP
%17 = or i32 %15, %16
%18 = load i32, i32* @S_IROTH
%19 = or i32 %17, %18
%20 = load i32, i32* @S_IXOTH
%21 = or i32 %19, %20
store i32 %21, i32* %7
store i32 0, i32* %8
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %29
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %27)
store i32 -1, i32* %3
br label %46
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
store i8* %32, i8** %6
%33 = load i8*, i8** %6
%34 = load i32, i32* %7
%35 = call i32 @mkdir(i8* %33, i32 %34)
store i32 %35, i32* %8
%36 = icmp ne i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %29
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %46
39: ; preds = %29
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %44)
store i32 -1, i32* %3
br label %46
46: ; preds = %39, %37, %24
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@.str = [29 x i8] c"Usage: %s [PATH/FolderName]\0A\00"
@.str.2 = [57 x i8] c"[E]: Error, failed to create folder [%s], ErrorCode[%s]\0A\00"
@errno = global i32 0
@str = [64 x i8] c"[I]: Success, now use \22ls [path/folder name]\22 to see the result\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %32
7: ; preds = %2
%8 = load i32, i32* @S_IRUSR
%9 = load i32, i32* @S_IWUSR
%10 = or i32 %9, %8
%11 = load i32, i32* @S_IXUSR
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IRGRP
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IXGRP
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IROTH
%18 = or i32 %16, %17
%19 = load i32, i32* @S_IXOTH
%20 = or i32 %18, %19
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = tail call i32 @mkdir(i8* %22, i32 %20)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %7
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
br label %32
27: ; preds = %7
%28 = load i8*, i8** %21
%29 = load i32, i32* @errno
%30 = tail call i8* @strerror(i32 %29)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %30)
br label %32
32: ; preds = %27, %25, %4
%33 = phi i32 [ -1, %4 ], [ -1, %27 ], [ 0, %25 ]
ret i32 %33
}