#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 _mkdir(int, int, int, char **);
int /*<<< orphan*/ _mode(int /*<<< orphan*/, int *);
int _usage();
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
int main(int argc, char *argv[]) {
  mode_t mode = 0777;
  int flagp = 0;
  int o;
  while ((o = getopt(argc, argv, "pm:")) != -1)
    switch (o) {
    case 'm':
      if (_mode(optarg, &mode) != 0)
        return _usage();
      break;
    case 'p':
      flagp = 1;
      break;
    default:
      return _usage();
    }
  if (argc == optind)
    return _usage();
  return _mkdir(flagp, mode, argc - optind, &argv[optind]);
}


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)
movl   $0x1ff,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8e(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11f7 <main+0xb7>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x6d,%eax
je     11a8 <main+0x68>
jmp    1197 <main+0x57>
mov    -0x20(%rbp),%eax
sub    $0x70,%eax
je     11d7 <main+0x97>
jmp    11e3 <main+0xa3>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
call   1040 <_mode@plt>
cmp    $0x0,%eax
je     11d2 <main+0x92>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1247 <main+0x107>
jmp    11f2 <main+0xb2>
movl   $0x1,-0x18(%rbp)
jmp    11f2 <main+0xb2>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1247 <main+0x107>
jmp    1164 <main+0x24>
mov    -0x8(%rbp),%eax
mov    0x2ddf(%rip),%rcx
cmp    (%rcx),%eax
jne    1218 <main+0xd8>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1247 <main+0x107>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    0x2db8(%rip),%rax
sub    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    0x2dab(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
add    %rax,%rcx
call   1050 <_mkdir@plt>
mov    %eax,-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
mov    %rsi,%r14
mov    %edi,%ebx
movl   $0x1ff,0x4(%rsp)
xor    %r15d,%r15d
lea    0xe9e(%rip),%rbp
mov    0x2e8f(%rip),%r13
lea    0x4(%rsp),%r12
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1060 <getopt@plt>
cmp    $0x6d,%eax
jne    1194 <main+0x54>
mov    0x0(%r13),%edi
mov    %r12,%rsi
call   1040 <_mode@plt>
test   %eax,%eax
je     1170 <main+0x30>
jmp    11b4 <main+0x74>
cmp    $0xffffffff,%eax
je     11a6 <main+0x66>
cmp    $0x70,%eax
jne    11b4 <main+0x74>
mov    $0x1,%r15d
jmp    1170 <main+0x30>
mov    0x2e33(%rip),%rax
movslq (%rax),%rax
cmp    %ebx,%eax
jne    11ca <main+0x8a>
xor    %eax,%eax
call   1030 <_usage@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%rsp),%esi
sub    %eax,%ebx
lea    (%r14,%rax,8),%rcx
mov    %r15d,%edi
mov    %ebx,%edx
call   1050 <_mkdir@plt>
jmp    11bb <main+0x7b>

LLVM IR (-O0):
@.str = [4 x i8] c"pm:\00"
@optarg = global i32 0
@optind = 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
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 511, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %26, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %8
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = load i32, i32* %8
switch i32 %15, label %24 [
i32 109, label %16
i32 112, label %23
]
16: ; preds = %14
%17 = load i32, i32* @optarg
%18 = call i32 @_mode(i32 %17, i32* %6)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (...) @_usage()
store i32 %21, i32* %3
br label %44
22: ; preds = %16
br label %26
23: ; preds = %14
store i32 1, i32* %7
br label %26
24: ; preds = %14
%25 = call i32 (...) @_usage()
store i32 %25, i32* %3
br label %44
26: ; preds = %23, %22
br label %9
27: ; preds = %9
%28 = load i32, i32* %4
%29 = load i32, i32* @optind
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (...) @_usage()
store i32 %32, i32* %3
br label %44
33: ; preds = %27
%34 = load i32, i32* %7
%35 = load i32, i32* %6
%36 = load i32, i32* %4
%37 = load i32, i32* @optind
%38 = sub nsw i32 %36, %37
%39 = load i8**, i8*** %5
%40 = load i32, i32* @optind
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = call i32 @_mkdir(i32 %34, i32 %35, i32 %38, i8** %42)
store i32 %43, i32* %3
br label %44
44: ; preds = %33, %31, %24, %20
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [4 x i8] c"pm:\00"
@optarg = global i32 0
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 511, i32* %3
br label %5
5: ; preds = %7, %2
%6 = phi i32 [ 0, %2 ], [ 1, %7 ]
br label %7
7: ; preds = %5, %9
%8 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %15 [
i32 -1, label %17
i32 109, label %9
i32 112, label %5
]
9: ; preds = %7
%10 = load i32, i32* @optarg
%11 = call i32 @_mode(i32 %10, i32* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %7, label %13
13: ; preds = %9
%14 = call i32 (...) @_usage()
br label %28
15: ; preds = %7
%16 = call i32 (...) @_usage()
br label %28
17: ; preds = %7
%18 = load i32, i32* @optind
%19 = icmp eq i32 %18, %0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (...) @_usage()
br label %28
22: ; preds = %17
%23 = load i32, i32* %3
%24 = sub nsw i32 %0, %18
%25 = sext i32 %18 to i64
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = call i32 @_mkdir(i32 %6, i32 %23, i32 %24, i8** %26)
br label %28
28: ; preds = %22, %20, %15, %13
%29 = phi i32 [ %16, %15 ], [ %14, %13 ], [ %21, %20 ], [ %27, %22 ]
ret i32 %29
}