#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 errno;
int getopt(int, char **, char *);
int mkdir(char *, int);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ print_usage();
int strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int opt;
  char *point;
  int mode_set = 0;
  int mode = 0777;
  while (-1 != (opt = getopt(argc - 1, argv, "hm:v"))) {
    switch (opt) {
    case 'h':
      print_usage();
      return 0;
    case 'm':
      mode = strtol(optarg, NULL, 8);
      mode_set = 1;
      break;
    case 'v':
      mode |= 0x01000000;
      break;
    default:
      return 0;
    }
  }
  if (argc > 1) {
    mode_t umode;
    point = argv[argc - 1];
    if (mode_set) {
      umode = umask(0);
    }
    if (-1 == mkdir(point, mode)) {
      return -errno;
    }
    if (mode_set) {
      umask(umode);
    }
  }
  return 0;
}


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)
movl   $0x0,-0x24(%rbp)
movl   $0x1ff,-0x28(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
lea    0xe7b(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     122c <main+0xdc>
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x68,%eax
je     11d2 <main+0x82>
jmp    11b0 <main+0x60>
mov    -0x30(%rbp),%eax
sub    $0x6d,%eax
je     11e5 <main+0x95>
jmp    11c1 <main+0x71>
mov    -0x30(%rbp),%eax
sub    $0x76,%eax
je     120b <main+0xbb>
jmp    121b <main+0xcb>
mov    $0x0,%al
call   1070 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ab <main+0x15b>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x8,%edx
call   1050 <strtol@plt>
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1227 <main+0xd7>
mov    -0x28(%rbp),%eax
or     $0x1000000,%eax
mov    %eax,-0x28(%rbp)
jmp    1227 <main+0xd7>
movl   $0x0,-0x4(%rbp)
jmp    12ab <main+0x15b>
jmp    1174 <main+0x24>
cmpl   $0x1,-0x8(%rbp)
jle    12a4 <main+0x154>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     125f <main+0x10f>
xor    %edi,%edi
call   1040 <umask@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1030 <mkdir@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    128d <main+0x13d>
xor    %eax,%eax
mov    0x2d55(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    12ab <main+0x15b>
cmpl   $0x0,-0x24(%rbp)
je     129f <main+0x14f>
mov    -0x2c(%rbp),%edi
call   1040 <umask@plt>
jmp    12a4 <main+0x154>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r15d
lea    -0x1(%r15),%ebp
mov    $0x1ff,%eax
mov    $0x1,%cl
mov    %rcx,(%rsp)
lea    0xe89(%rip),%r14
mov    %eax,%r13d
or     $0x1000000,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r14,%rdx
call   1060 <getopt@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cmp    $0x76,%ecx
je     1190 <main+0x40>
cmp    $0xffffffff,%ecx
je     11e1 <main+0x91>
cmp    $0x6d,%ecx
jne    11d0 <main+0x80>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %rax,(%rsp)
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <strtol@plt>
jmp    1177 <main+0x27>
xor    %r14d,%r14d
cmp    $0x68,%ecx
jne    123a <main+0xea>
xor    %eax,%eax
call   1070 <print_usage@plt>
jmp    123a <main+0xea>
xor    %r14d,%r14d
cmp    $0x2,%r15d
jl     123a <main+0xea>
mov    %ebp,%eax
mov    (%r12,%rax,8),%rbp
testb  $0x1,(%rsp)
je     1207 <main+0xb7>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    123a <main+0xea>
jmp    122d <main+0xdd>
xor    %r14d,%r14d
xor    %edi,%edi
call   1040 <umask@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
mov    %ebx,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
je     122d <main+0xdd>
mov    %r15d,%edi
call   1040 <umask@plt>
jmp    123a <main+0xea>
mov    0x2da4(%rip),%rax
xor    %r14d,%r14d
sub    (%rax),%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"hm:v\00"
@optarg = global i32 0
@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 i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 511, i32* %9
br label %11
11: ; preds = %28, %2
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %6
%16 = icmp ne i32 -1, %15
br i1 %16, label %17, label %29
17: ; preds = %11
%18 = load i32, i32* %6
switch i32 %18, label %27 [
i32 104, label %19
i32 109, label %21
i32 118, label %24
]
19: ; preds = %17
%20 = call i32 (...) @print_usage()
store i32 0, i32* %3
br label %59
21: ; preds = %17
%22 = load i32, i32* @optarg
%23 = call i32 @strtol(i32 %22, i32* null, i32 8)
store i32 %23, i32* %9
store i32 1, i32* %8
br label %28
24: ; preds = %17
%25 = load i32, i32* %9
%26 = or i32 %25, 16777216
store i32 %26, i32* %9
br label %28
27: ; preds = %17
store i32 0, i32* %3
br label %59
28: ; preds = %24, %21
br label %11
29: ; preds = %11
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 1
br i1 %31, label %32, label %58
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
store i8* %38, i8** %7
%39 = load i32, i32* %8
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %32
%42 = call i32 @umask(i32 0)
store i32 %42, i32* %10
br label %43
43: ; preds = %41, %32
%44 = load i8*, i8** %7
%45 = load i32, i32* %9
%46 = call i32 @mkdir(i8* %44, i32 %45)
%47 = icmp eq i32 -1, %46
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = load i32, i32* @errno
%50 = sub nsw i32 0, %49
store i32 %50, i32* %3
br label %59
51: ; preds = %43
%52 = load i32, i32* %8
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* %10
%56 = call i32 @umask(i32 %55)
br label %57
57: ; preds = %54, %51
br label %58
58: ; preds = %57, %29
store i32 0, i32* %3
br label %59
59: ; preds = %58, %48, %27, %19
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
@.str = [5 x i8] c"hm:v\00"
@optarg = global i32 0
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = add nsw i32 %0, -1
br label %4
4: ; preds = %13, %2
%5 = phi i1 [ false, %13 ], [ true, %2 ]
%6 = phi i32 [ %15, %13 ], [ 511, %2 ]
%7 = or i32 %6, 16777216
br label %8
8: ; preds = %8, %4
%9 = phi i32 [ %6, %4 ], [ %7, %8 ]
%10 = tail call i32 @getopt(i32 %3, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %34 [
i32 -1, label %16
i32 104, label %11
i32 109, label %13
i32 118, label %8
]
11: ; preds = %8
%12 = tail call i32 (...) @print_usage()
br label %34
13: ; preds = %8
%14 = load i32, i32* @optarg
%15 = tail call i32 @strtol(i32 %14, i32* null, i32 8)
br label %4
16: ; preds = %8
%17 = icmp sgt i32 %0, 1
br i1 %17, label %18, label %34
18: ; preds = %16
%19 = zext i32 %3 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
br i1 %5, label %22, label %25
22: ; preds = %18
%23 = tail call i32 @mkdir(i8* %21, i32 %9)
%24 = icmp eq i32 %23, -1
br i1 %24, label %31, label %34
25: ; preds = %18
%26 = tail call i32 @umask(i32 0)
%27 = tail call i32 @mkdir(i8* %21, i32 %9)
%28 = icmp eq i32 %27, -1
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = tail call i32 @umask(i32 %26)
br label %34
31: ; preds = %22, %25
%32 = load i32, i32* @errno
%33 = sub nsw i32 0, %32
br label %34
34: ; preds = %8, %22, %29, %16, %31, %11
%35 = phi i32 [ 0, %11 ], [ %33, %31 ], [ 0, %16 ], [ 0, %29 ], [ 0, %22 ], [ 0, %8 ]
ret i32 %35
}