#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};
typedef int mode_t;

/* Variables and functions */
char EOF;
scalar_t__ errno;
char getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ help();
scalar_t__ mkdir(char *, int);
int optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int strtol(char *, char **, int);
int /*<<< orphan*/ version();
int main(int argc, char *argv[]) {
  int cmd_x;
  char optstring[] = "hva";
  mode_t mode;
  int opt_a = 0;
  char *ep;
  char optch;
  struct option long_opts[] = {{"help", 0, 0, 'h'},
                               {"version", 0, 0, 'v'},
                               {"all", 0, 0, 'a'},
                               {NULL, 0, 0, 0}};
  while ((optch = getopt_long(argc, argv, optstring, long_opts, &cmd_x)) !=
         EOF) {
    switch (optch) {
    case 'h':
      help();
      return 0;
    case 'v':
      version();
      return 0;
    case 'a':
      opt_a = 1;
      break;
    default:
      printf("-%c: unkown option\n", optch);
      break;
    }
  }
  if (argc - optind < 1) {
    printf("Incomplete inputs\n");
    return 0;
  } else if (argc - optind > 2) {
    printf("too many inputs\n");
    return 0;
  }
  errno = 0;
  mode = strtol(argv[optind], &ep, 8);
  if (errno) {
    perror(argv[optind]);
    return 0;
  }
  if (opt_a == 1) {
    mode = 0777;
  }
  if (mkdir(argv[optind + 1], mode) != 0) {
    perror(argv[optind + 1]);
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe61(%rip),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x60,%edx
call   1060 <memset@plt>
lea    0xe41(%rip),%rax
mov    %rax,-0x90(%rbp)
movl   $0x68,-0x80(%rbp)
lea    0xe31(%rip),%rax
mov    %rax,-0x78(%rbp)
movl   $0x76,-0x68(%rbp)
lea    0xe27(%rip),%rax
mov    %rax,-0x60(%rbp)
movl   $0x61,-0x50(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x90(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %al,-0x29(%rbp)
movsbl %al,%eax
mov    0x2dcb(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12b1 <main+0x131>
movsbl -0x29(%rbp),%eax
mov    %eax,-0x94(%rbp)
sub    $0x61,%eax
je     128e <main+0x10e>
jmp    1240 <main+0xc0>
mov    -0x94(%rbp),%eax
sub    $0x68,%eax
je     1268 <main+0xe8>
jmp    1254 <main+0xd4>
mov    -0x94(%rbp),%eax
sub    $0x76,%eax
je     127b <main+0xfb>
jmp    129a <main+0x11a>
mov    $0x0,%al
call   10a0 <help@plt>
movl   $0x0,-0x4(%rbp)
jmp    13e2 <main+0x262>
mov    $0x0,%al
call   1080 <version@plt>
movl   $0x0,-0x4(%rbp)
jmp    13e2 <main+0x262>
movl   $0x1,-0x20(%rbp)
jmp    12ac <main+0x12c>
movsbl -0x29(%rbp),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f5 <main+0x75>
mov    -0x8(%rbp),%eax
mov    0x2d25(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x1,%eax
jge    12e0 <main+0x160>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13e2 <main+0x262>
mov    -0x8(%rbp),%eax
mov    0x2cf6(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
jle    130f <main+0x18f>
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13e2 <main+0x262>
jmp    1314 <main+0x194>
mov    0x2cb5(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x2cb3(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   1070 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2c84(%rip),%rax
cmpq   $0x0,(%rax)
je     1379 <main+0x1f9>
mov    -0x10(%rbp),%rax
mov    0x2c7f(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    13e2 <main+0x262>
cmpl   $0x1,-0x20(%rbp)
jne    138a <main+0x20a>
movl   $0x1ff,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2c4b(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     13db <main+0x25b>
mov    -0x10(%rbp),%rax
mov    0x2c22(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    13e2 <main+0x262>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x617668,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
lea    0xe3d(%rip),%rax
mov    %rax,0x10(%rsp)
movl   $0x68,0x20(%rsp)
lea    0xe2e(%rip),%rax
mov    %rax,0x28(%rsp)
movl   $0x76,0x38(%rsp)
lea    0xe22(%rip),%rax
mov    %rax,0x40(%rsp)
movl   $0x61,0x50(%rsp)
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1050 <getopt_long@plt>
mov    0x2dd5(%rip),%r13
xor    %r15d,%r15d
cmp    0x0(%r13),%al
jne    1240 <main+0xc0>
mov    0x2dbd(%rip),%r14
movslq (%r14),%rax
sub    %eax,%ebp
jle    129b <main+0x11b>
cmp    $0x3,%ebp
jb     12a9 <main+0x129>
lea    0xdef(%rip),%rdi
call   1040 <puts@plt>
jmp    130c <main+0x18c>
lea    0xc(%rsp),%r12
xor    %r14d,%r14d
jmp    1270 <main+0xf0>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %r12,%r8
call   1050 <getopt_long@plt>
mov    %r15d,%r14d
cmp    0x0(%r13),%al
je     121c <main+0x9c>
movsbl %al,%esi
mov    $0x1,%r15d
cmp    $0x61,%esi
je     1250 <main+0xd0>
cmp    $0x76,%esi
je     12fc <main+0x17c>
cmp    $0x68,%esi
je     1305 <main+0x185>
lea    0xd82(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%r15d
jmp    1250 <main+0xd0>
lea    0xd93(%rip),%rdi
call   1040 <puts@plt>
jmp    130c <main+0x18c>
mov    0x2d20(%rip),%rbp
movq   $0x0,0x0(%rbp)
mov    (%rbx,%rax,8),%rdi
lea    0x70(%rsp),%rsi
mov    $0x8,%edx
call   1070 <strtol@plt>
cmpq   $0x0,0x0(%rbp)
jne    131d <main+0x19d>
cmp    $0x1,%r15d
mov    $0x1ff,%ecx
cmove  %ecx,%eax
movslq (%r14),%rcx
mov    0x8(%rbx,%rcx,8),%rdi
mov    %eax,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
je     130c <main+0x18c>
movslq (%r14),%rax
mov    0x8(%rbx,%rax,8),%rdi
jmp    1324 <main+0x1a4>
xor    %eax,%eax
call   1080 <version@plt>
jmp    130c <main+0x18c>
xor    %eax,%eax
call   10a0 <help@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movslq (%r14),%rax
mov    (%rbx,%rax,8),%rdi
call   1090 <perror@plt>
jmp    130c <main+0x18c>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@__const.main.optstring = [4 x i8] c"hva\00"
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [4 x i8] c"all\00"
@EOF = global i8 0
@.str.3 = [20 x i8] c"-%c: unkown option\0A\00"
@optind = global i32 0
@.str.4 = [19 x i8] c"Incomplete inputs\0A\00"
@.str.5 = [17 x i8] c"too many inputs\0A\00"
@errno = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8
%12 = alloca [4 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [4 x i8]* %7 to i8*
store i32 0, i32* %9
%14 = bitcast [4 x %struct.option]* %12 to i8*
%15 = bitcast i8* %14 to [4 x %struct.option]*
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %15, i32 0, i32 0
%17 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8** %17
%18 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 3
store i32 104, i32* %18
%19 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %15, i32 0, i32 1
%20 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 3
store i32 118, i32* %21
%22 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %15, i32 0, i32 2
%23 = getelementptr inbounds %struct.option, %struct.option* %22, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8** %23
%24 = getelementptr inbounds %struct.option, %struct.option* %22, i32 0, i32 3
store i32 97, i32* %24
br label %25
25: ; preds = %47, %2
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%29 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %12, i64 0, i64 0
%30 = call signext i8 @getopt_long(i32 %26, i8** %27, i8* %28, %struct.option* %29, i32* %6)
store i8 %30, i8* %11
%31 = sext i8 %30 to i32
%32 = load i8, i8* @EOF
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %31, %33
br i1 %34, label %35, label %48
35: ; preds = %25
%36 = load i8, i8* %11
%37 = sext i8 %36 to i32
switch i32 %37, label %43 [
i32 104, label %38
i32 118, label %40
i32 97, label %42
]
38: ; preds = %35
%39 = call i32 (...) @help()
store i32 0, i32* %3
br label %102
40: ; preds = %35
%41 = call i32 (...) @version()
store i32 0, i32* %3
br label %102
42: ; preds = %35
store i32 1, i32* %9
br label %47
43: ; preds = %35
%44 = load i8, i8* %11
%45 = sext i8 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %43, %42
br label %25
48: ; preds = %25
%49 = load i32, i32* %4
%50 = load i32, i32* @optind
%51 = sub nsw i32 %49, %50
%52 = icmp slt i32 %51, 1
br i1 %52, label %53, label %55
53: ; preds = %48
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %102
55: ; preds = %48
%56 = load i32, i32* %4
%57 = load i32, i32* @optind
%58 = sub nsw i32 %56, %57
%59 = icmp sgt i32 %58, 2
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %102
62: ; preds = %55
br label %63
63: ; preds = %62
store i64 0, i64* @errno
%64 = load i8**, i8*** %5
%65 = load i32, i32* @optind
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = call i32 @strtol(i8* %68, i8** %10, i32 8)
store i32 %69, i32* %8
%70 = load i64, i64* @errno
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %79
72: ; preds = %63
%73 = load i8**, i8*** %5
%74 = load i32, i32* @optind
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8*, i8** %73, i64 %75
%77 = load i8*, i8** %76
%78 = call i32 @perror(i8* %77)
store i32 0, i32* %3
br label %102
79: ; preds = %63
%80 = load i32, i32* %9
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %83
82: ; preds = %79
store i32 511, i32* %8
br label %83
83: ; preds = %82, %79
%84 = load i8**, i8*** %5
%85 = load i32, i32* @optind
%86 = add nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8*, i8** %84, i64 %87
%89 = load i8*, i8** %88
%90 = load i32, i32* %8
%91 = call i64 @mkdir(i8* %89, i32 %90)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %101
93: ; preds = %83
%94 = load i8**, i8*** %5
%95 = load i32, i32* @optind
%96 = add nsw i32 %95, 1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %94, i64 %97
%99 = load i8*, i8** %98
%100 = call i32 @perror(i8* %99)
store i32 0, i32* %3
br label %102
101: ; preds = %83
store i32 0, i32* %3
br label %102
102: ; preds = %101, %93, %72, %60, %53, %40, %38
%103 = load i32, i32* %3
ret i32 %103
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [4 x i8] c"all\00"
@EOF = global i8 0
@.str.3 = [20 x i8] c"-%c: unkown option\0A\00"
@optind = global i32 0
@errno = global i64 0
@str = [16 x i8] c"too many inputs\00"
@str.6 = [18 x i8] c"Incomplete inputs\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [4 x %struct.option]
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
store i32 6387304, i32* %4
%9 = bitcast i8** %5 to i8*
%10 = bitcast [4 x %struct.option]* %6 to i8*
%11 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 0, i32 3
store i32 104, i32* %12
%13 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 1, i32 3
store i32 118, i32* %14
%15 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 2, i32 3
store i32 97, i32* %16
%17 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %6, i64 0, i64 0
%18 = call signext i8 @getopt_long(i32 %0, i8** %1, i8* %8, %struct.option* %17, i32* %3)
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %18, %19
br i1 %20, label %36, label %21
21: ; preds = %2, %31
%22 = phi i8 [ %33, %31 ], [ %18, %2 ]
%23 = phi i32 [ %32, %31 ], [ 0, %2 ]
%24 = sext i8 %22 to i32
switch i32 %24, label %29 [
i32 104, label %25
i32 118, label %27
i32 97, label %31
]
25: ; preds = %21
%26 = call i32 (...) @help()
br label %77
27: ; preds = %21
%28 = call i32 (...) @version()
br label %77
29: ; preds = %21
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %31
31: ; preds = %21, %29
%32 = phi i32 [ %23, %29 ], [ 1, %21 ]
%33 = call signext i8 @getopt_long(i32 %0, i8** %1, i8* %8, %struct.option* %17, i32* %3)
%34 = load i8, i8* @EOF
%35 = icmp eq i8 %33, %34
br i1 %35, label %36, label %21
36: ; preds = %31, %2
%37 = phi i32 [ 0, %2 ], [ %32, %31 ]
%38 = load i32, i32* @optind
%39 = sub nsw i32 %0, %38
%40 = icmp slt i32 %39, 1
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
br label %77
43: ; preds = %36
%44 = icmp ugt i32 %39, 2
br i1 %44, label %45, label %47
45: ; preds = %43
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %77
47: ; preds = %43
store i64 0, i64* @errno
%48 = sext i32 %38 to i64
%49 = getelementptr inbounds i8*, i8** %1, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @strtol(i8* %50, i8** %5, i32 8)
%52 = load i64, i64* @errno
%53 = icmp eq i64 %52, 0
br i1 %53, label %60, label %54
54: ; preds = %47
%55 = load i32, i32* @optind
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %1, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @perror(i8* %58)
br label %77
60: ; preds = %47
%61 = icmp eq i32 %37, 1
%62 = select i1 %61, i32 511, i32 %51
%63 = load i32, i32* @optind
%64 = add nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %1, i64 %65
%67 = load i8*, i8** %66
%68 = call i64 @mkdir(i8* %67, i32 %62)
%69 = icmp eq i64 %68, 0
br i1 %69, label %77, label %70
70: ; preds = %60
%71 = load i32, i32* @optind
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %1, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 @perror(i8* %75)
br label %77
77: ; preds = %60, %70, %54, %45, %41, %27, %25
ret i32 0
}