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

/* Variables and functions */
int S_IRWXG;
int S_IRWXO;
int S_IRWXU;
int mkdir(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, scalar_t__);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int executeMkdirCommand(char *arg) {
  int ret = 0;
  char name[20];
  mode_t process_mask = umask(0);
  strncpy(name, arg, strlen(arg) - 1);
  ret = mkdir(name, S_IRWXU | S_IRWXG | S_IRWXO);
  if (!ret) {
    printf("Directory %s created\n", name);
  } else {
    perror("Error");
  }
  umask(process_mask);
  return ret;
}


x86 assembly (clang, -O0):
<executeMkdirCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %edi,%edi
call   1070 <umask@plt>
mov    %eax,-0x24(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rdi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
mov    0x2e1a(%rip),%rax
or     (%rax),%esi
mov    0x2e29(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11f0 <executeMkdirCommand+0x90>
lea    -0x20(%rbp),%rsi
lea    0xe1a(%rip),%rdi
call   1060 <printf@plt>
jmp    11fc <executeMkdirCommand+0x9c>
lea    0xe1f(%rip),%rdi
call   1080 <perror@plt>
mov    -0x24(%rbp),%edi
call   1070 <umask@plt>
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeMkdirCommand>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbp
xor    %edi,%edi
call   1070 <umask@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
mov    0x2e4a(%rip),%rax
mov    0x2e3b(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e48(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
call   1040 <mkdir@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11da <executeMkdirCommand+0x7a>
lea    0xe41(%rip),%rdi
mov    %rsp,%rsi
call   1060 <printf@plt>
mov    %r14d,%edi
call   1070 <umask@plt>
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe35(%rip),%rdi
call   1080 <perror@plt>
jmp    11c7 <executeMkdirCommand+0x67>

LLVM IR (-O0):
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@.str = [22 x i8] c"Directory %s created\0A\00"
@.str.1 = [6 x i8] c"Error\00"
define i32 @executeMkdirCommand(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = call i32 @umask(i32 0)
store i32 %6, i32* %5
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = load i8*, i8** %2
%10 = call i64 @strlen(i8* %9)
%11 = sub nsw i64 %10, 1
%12 = call i32 @strncpy(i8* %7, i8* %8, i64 %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%14 = load i32, i32* @S_IRWXU
%15 = load i32, i32* @S_IRWXG
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IRWXO
%18 = or i32 %16, %17
%19 = call i32 @mkdir(i8* %13, i32 %18)
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %1
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %27
25: ; preds = %1
%26 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = load i32, i32* %5
%29 = call i32 @umask(i32 %28)
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@.str = [22 x i8] c"Directory %s created\0A\00"
@.str.1 = [6 x i8] c"Error\00"
define i32 @executeMkdirCommand(i8* %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @umask(i32 0)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = add nsw i64 %5, -1
%7 = call i32 @strncpy(i8* %3, i8* %0, i64 %6)
%8 = load i32, i32* @S_IRWXU
%9 = load i32, i32* @S_IRWXG
%10 = or i32 %9, %8
%11 = load i32, i32* @S_IRWXO
%12 = or i32 %10, %11
%13 = call i32 @mkdir(i8* %3, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %19
17: ; preds = %1
%18 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %15
%20 = call i32 @umask(i32 %4)
ret i32 %13
}