#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 errno;
int /*<<< orphan*/ help();
int mkdir(char *, int);
int parse_mod(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    help();
    return 0;
  }
  mode_t mode = 0775;
  umask(0);
  int i = 1;
  for (; i < argc; ++i) {
    if (*argv[i] == '-') {
      ++(argv[i]);
      switch (*argv[i]) {
      case 'h':
        help();
        return 0;
        break;
      case 'm':
        if (i + 1 < argc) {
          ++i;
          if ((mode = parse_mod(argv[i])) == -1) {
            write(2, "mkdir: please check your settings for -m\n", 41);
            return 1;
          }
        }
        break;
      default:
        write(2, "mkdir: invalid option\n", 22);
        return 1;
        break;
      }
    } else {
      if ((mkdir(argv[i], mode)) == -1) {
        perror("mkdir");
        return errno;
      }
    }
  }
  return 0;
}


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   $0x1,-0x8(%rbp)
jne    1193 <main+0x33>
mov    $0x0,%al
call   1070 <help@plt>
movl   $0x0,-0x4(%rbp)
jmp    1305 <main+0x1a5>
movl   $0x1fd,-0x14(%rbp)
xor    %edi,%edi
call   1050 <umask@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12fe <main+0x19e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12ac <main+0x14c>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x1,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x68,%eax
je     1211 <main+0xb1>
jmp    1200 <main+0xa0>
mov    -0x1c(%rbp),%eax
sub    $0x6d,%eax
je     1224 <main+0xc4>
jmp    1285 <main+0x125>
mov    $0x0,%al
call   1070 <help@plt>
movl   $0x0,-0x4(%rbp)
jmp    1305 <main+0x1a5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    1280 <main+0x120>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <parse_mod@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    127b <main+0x11b>
mov    $0x2,%edi
lea    0xd9b(%rip),%rsi
mov    $0x29,%edx
call   1040 <write@plt>
movl   $0x1,-0x4(%rbp)
jmp    1305 <main+0x1a5>
jmp    1280 <main+0x120>
jmp    12a7 <main+0x147>
mov    $0x2,%edi
lea    0xd99(%rip),%rsi
mov    $0x16,%edx
call   1040 <write@plt>
movl   $0x1,-0x4(%rbp)
jmp    1305 <main+0x1a5>
jmp    12eb <main+0x18b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x14(%rbp),%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    12e6 <main+0x186>
lea    0xd71(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1305 <main+0x1a5>
jmp    12eb <main+0x18b>
jmp    12f0 <main+0x190>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a8 <main+0x48>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    117f <main+0x1f>
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <help@plt>
jmp    123c <main+0xdc>
mov    %rsi,%r12
mov    %edi,%r13d
xor    %r14d,%r14d
xor    %edi,%edi
call   1050 <umask@plt>
cmp    $0x2,%r13d
jl     123c <main+0xdc>
mov    $0x1fd,%r15d
mov    $0x1,%ebx
jmp    11c9 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
je     124e <main+0xee>
add    $0x1,%ebx
cmp    %r13d,%ebx
jge    123c <main+0xdc>
movslq %ebx,%rax
mov    (%r12,%rax,8),%rdi
cmpb   $0x2d,(%rdi)
jne    11b0 <main+0x50>
lea    0x1(%rdi),%rcx
mov    %rcx,(%r12,%rax,8)
movsbl 0x1(%rdi),%eax
cmp    $0x6d,%eax
jne    1217 <main+0xb7>
lea    0x1(%rbx),%ebp
cmp    %r13d,%ebp
jge    11c1 <main+0x61>
movslq %ebp,%rax
mov    (%r12,%rax,8),%rdi
call   1080 <parse_mod@plt>
mov    %eax,%r15d
mov    %ebp,%ebx
cmp    $0xffffffff,%eax
jne    11c1 <main+0x61>
lea    0xdf5(%rip),%rsi
mov    $0x2,%edi
mov    $0x29,%edx
jmp    1231 <main+0xd1>
cmp    $0x68,%eax
je     1170 <main+0x10>
lea    0xe03(%rip),%rsi
mov    $0x2,%edi
mov    $0x16,%edx
call   1040 <write@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdec(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%r14d
jmp    123c <main+0xdc>

LLVM IR (-O0):
@.str = [42 x i8] c"mkdir: please check your settings for -m\0A\00"
@.str.1 = [23 x i8] c"mkdir: invalid option\0A\00"
@.str.2 = [6 x i8] c"mkdir\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @help()
store i32 0, i32* %3
br label %83
12: ; preds = %2
store i32 509, i32* %6
%13 = call i32 @umask(i32 0)
store i32 1, i32* %7
br label %14
14: ; preds = %79, %12
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %82
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 45
br i1 %26, label %27, label %65
27: ; preds = %18
%28 = load i8**, i8*** %5
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %31
%34 = load i8**, i8*** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
switch i32 %40, label %62 [
i32 104, label %41
i32 109, label %43
]
41: ; preds = %27
%42 = call i32 (...) @help()
store i32 0, i32* %3
br label %83
43: ; preds = %27
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
%46 = load i32, i32* %4
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %61
48: ; preds = %43
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
%51 = load i8**, i8*** %5
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @parse_mod(i8* %55)
store i32 %56, i32* %6
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %48
%59 = call i32 @write(i32 2, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 41)
store i32 1, i32* %3
br label %83
60: ; preds = %48
br label %61
61: ; preds = %60, %43
br label %64
62: ; preds = %27
%63 = call i32 @write(i32 2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 22)
store i32 1, i32* %3
br label %83
64: ; preds = %61
br label %78
65: ; preds = %18
%66 = load i8**, i8*** %5
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = load i32, i32* %6
%72 = call i32 @mkdir(i8* %70, i32 %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %77
74: ; preds = %65
%75 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%76 = load i32, i32* @errno
store i32 %76, i32* %3
br label %83
77: ; preds = %65
br label %78
78: ; preds = %77, %64
br label %79
79: ; preds = %78
%80 = load i32, i32* %7
%81 = add nsw i32 %80, 1
store i32 %81, i32* %7
br label %14
82: ; preds = %14
store i32 0, i32* %3
br label %83
83: ; preds = %82, %74, %62, %58, %41, %10
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@.str = [42 x i8] c"mkdir: please check your settings for -m\0A\00"
@.str.1 = [23 x i8] c"mkdir: invalid option\0A\00"
@.str.2 = [6 x i8] c"mkdir\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @help()
br label %47
6: ; preds = %2
%7 = tail call i32 @umask(i32 0)
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %47
9: ; preds = %6, %42
%10 = phi i32 [ %45, %42 ], [ 1, %6 ]
%11 = phi i32 [ %43, %42 ], [ 509, %6 ]
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 45
br i1 %16, label %17, label %36
17: ; preds = %9
%18 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %18, i8** %13
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %34 [
i32 104, label %21
i32 109, label %23
]
21: ; preds = %17
%22 = tail call i32 (...) @help()
br label %47
23: ; preds = %17
%24 = add nsw i32 %10, 1
%25 = icmp slt i32 %24, %0
br i1 %25, label %26, label %42
26: ; preds = %23
%27 = sext i32 %24 to i64
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = tail call i32 @parse_mod(i8* %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %42
32: ; preds = %26
%33 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 41)
br label %47
34: ; preds = %17
%35 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 22)
br label %47
36: ; preds = %9
%37 = tail call i32 @mkdir(i8* %14, i32 %11)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* @errno
br label %47
42: ; preds = %23, %26, %36
%43 = phi i32 [ %30, %26 ], [ %11, %23 ], [ %11, %36 ]
%44 = phi i32 [ %24, %26 ], [ %10, %23 ], [ %10, %36 ]
%45 = add nsw i32 %44, 1
%46 = icmp slt i32 %45, %0
br i1 %46, label %9, label %47
47: ; preds = %42, %6, %21, %32, %34, %39, %4
%48 = phi i32 [ 0, %4 ], [ 1, %34 ], [ 1, %32 ], [ 0, %21 ], [ %41, %39 ], [ 0, %6 ], [ 0, %42 ]
ret i32 %48
}