#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 mkdir2(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strtok(int /*<<< orphan*/ *, char *);
void cmdMkdir(void) {
  char *token = strtok(NULL, " \t");
  if (token == NULL) {
    printf("Missing parameter\n");
    return;
  }
  int err = mkdir2(token);
  if (err < 0) {
    printf("Error: %d\n", err);
    return;
  }
  printf("Created new directory\n");
}


x86 assembly (clang, -O0):
<cmdMkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
lea    0xebd(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116a <cmdMkdir+0x3a>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a4 <cmdMkdir+0x74>
mov    -0x8(%rbp),%rdi
call   1030 <mkdir2@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1196 <cmdMkdir+0x66>
mov    -0xc(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a4 <cmdMkdir+0x74>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmdMkdir>:
push   %rax
lea    0xeb8(%rip),%rsi
xor    %edi,%edi
call   1060 <strtok@plt>
test   %rax,%rax
je     116d <cmdMkdir+0x2d>
mov    %rax,%rdi
call   1040 <mkdir2@plt>
test   %eax,%eax
js     117a <cmdMkdir+0x3a>
lea    0xea7(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xeb0(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xe82(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rcx
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
@.str.1 = [19 x i8] c"Missing parameter\0A\00"
@.str.2 = [11 x i8] c"Error: %d\0A\00"
@.str.3 = [23 x i8] c"Created new directory\0A\00"
define void @cmdMkdir() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %18
8: ; preds = %0
%9 = load i8*, i8** %1
%10 = call i32 @mkdir2(i8* %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %18
16: ; preds = %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %13, %6
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
@.str.2 = [11 x i8] c"Error: %d\0A\00"
@str = [22 x i8] c"Created new directory\00"
@str.4 = [18 x i8] c"Missing parameter\00"
define void @cmdMkdir() {
%1 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
br label %12
5: ; preds = %0
%6 = tail call i32 @mkdir2(i8* %1)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %6)
br label %12
10: ; preds = %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %8, %10, %3
ret void
}