#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 */
scalar_t__ EEXIST;
int /*<<< orphan*/ _PC_PATH_MAX;
int /*<<< orphan*/ chdir(char *);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ getcwd(char *, size_t);
int getopt(int, char **, char *);
int mkdir(char *, int);
long pathconf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
int main(int argc, char **argv) {
  int c;
  int create_missing = 1;
  while ((c = getopt(argc, argv, "p:")) != -1) {
    switch (c) {
    case 'p':
      create_missing = 0;
      break;
    case '?':
      fprintf(stderr, "usage: %s [-p] path ...\n", argv[0]);
      return (1);
    }
  }
  if (argc < 2) {
    fprintf(stderr, "usage: %s [-p] path ...\n", argv[0]);
    return (1);
  }
  long size = pathconf(".", _PC_PATH_MAX);
  char root[size];
  getcwd(root, (size_t)size);
  for (char **arg = ++argv; *arg; ++arg) {
    chdir(root);
    if (strcmp(*arg, "-p") == 0) {
      continue;
    }
    if (create_missing == 0) {
      char *dir;
      dir = strtok(*arg, "/");
      while (dir != NULL) {
        if (mkdir(dir, 0777) == -1) {
          if (errno == EEXIST) {
            break;
          } else {
            perror(dir);
            return (1);
          }
        }
        chdir(dir);
        dir = strtok(NULL, "/");
      }
    } else {
      if (mkdir(*arg, 0777) == -1) {
        if (errno == EEXIST) {
          break;
        } else {
          perror(*arg);
          return (1);
        }
      }
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe45(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     122a <main+0x9a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x48(%rbp)
sub    $0x3f,%eax
je     11fd <main+0x6d>
jmp    11e0 <main+0x50>
mov    -0x48(%rbp),%eax
sub    $0x70,%eax
jne    1225 <main+0x95>
jmp    11f1 <main+0x61>
movl   $0x0,-0x18(%rbp)
jmp    1225 <main+0x95>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdef(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    141b <main+0x28b>
jmp    11ad <main+0x1d>
cmpl   $0x2,-0x8(%rbp)
jge    125c <main+0xcc>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb8(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    141b <main+0x28b>
mov    0x2d75(%rip),%rax
mov    (%rax),%esi
lea    0xdb0(%rip),%rdi
call   1040 <pathconf@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x50(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rsi
call   1060 <getcwd@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmpq   $0x0,(%rax)
je     1406 <main+0x276>
mov    -0x50(%rbp),%rdi
call   1050 <chdir@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0xd44(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12ee <main+0x15e>
jmp    13f5 <main+0x265>
cmpl   $0x0,-0x18(%rbp)
jne    1393 <main+0x203>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0xd1b(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     138e <main+0x1fe>
mov    -0x40(%rbp),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    136c <main+0x1dc>
mov    0x2c90(%rip),%rax
mov    (%rax),%rax
mov    0x2c9e(%rip),%rcx
cmp    (%rcx),%rax
jne    1350 <main+0x1c0>
jmp    138e <main+0x1fe>
mov    -0x40(%rbp),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    1414 <main+0x284>
mov    -0x40(%rbp),%rdi
call   1050 <chdir@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xca1(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x40(%rbp)
jmp    130f <main+0x17f>
jmp    13f0 <main+0x260>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    13eb <main+0x25b>
mov    0x2c14(%rip),%rax
mov    (%rax),%rax
mov    0x2c22(%rip),%rcx
cmp    (%rcx),%rax
jne    13cc <main+0x23c>
jmp    1406 <main+0x276>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    1414 <main+0x284>
jmp    13f0 <main+0x260>
jmp    13f5 <main+0x265>
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    12b5 <main+0x125>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebx
xor    %r15d,%r15d
lea    0xe53(%rip),%r14
nopl   (%rax)
mov    %ebx,%edi
mov    %r13,%rsi
mov    %r14,%rdx
call   10b0 <getopt@plt>
cmp    $0xffffffff,%eax
je     11d3 <main+0x43>
cmp    $0x70,%eax
je     11ce <main+0x3e>
cmp    $0x3f,%eax
jne    11b0 <main+0x20>
jmp    11d8 <main+0x48>
mov    $0x1,%r15b
jmp    11b0 <main+0x20>
cmp    $0x1,%ebx
jg     11fb <main+0x6b>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
lea    0xe17(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    1332 <main+0x1a2>
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
lea    0xe11(%rip),%rdi
call   1040 <pathconf@plt>
mov    %rsp,%rbx
lea    0xf(%rax),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r14
sub    %rcx,%r14
mov    %r14,%rsp
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <getcwd@plt>
cmpq   $0x0,0x8(%r13)
je     130f <main+0x17f>
mov    %rbx,-0x30(%rbp)
add    $0x8,%r13
lea    0xdd8(%rip),%r12
jmp    1272 <main+0xe2>
nopl   0x0(%rax,%rax,1)
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
je     1313 <main+0x183>
cmpq   $0x0,0x8(%r13)
lea    0x8(%r13),%r13
je     1307 <main+0x177>
mov    %r14,%rdi
call   1050 <chdir@plt>
mov    0x0(%r13),%rdi
lea    0xd99(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1263 <main+0xd3>
mov    0x0(%r13),%rdi
test   $0x1,%r15b
je     1250 <main+0xc0>
mov    %r12,%rsi
call   10a0 <strtok@plt>
test   %rax,%rax
je     1263 <main+0xd3>
mov    %rax,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
je     12de <main+0x14e>
mov    %rbx,%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    12b0 <main+0x120>
jmp    1263 <main+0xd3>
mov    0x2ce3(%rip),%rax
mov    (%rax),%rax
mov    0x2cf1(%rip),%rcx
cmp    (%rcx),%rax
je     1263 <main+0xd3>
mov    %rbx,%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
jmp    1309 <main+0x179>
xor    %eax,%eax
mov    -0x30(%rbp),%rbx
jmp    132f <main+0x19f>
xor    %eax,%eax
jmp    132f <main+0x19f>
mov    0x2cae(%rip),%rax
mov    (%rax),%rcx
xor    %eax,%eax
mov    0x2cba(%rip),%rdx
cmp    (%rdx),%rcx
mov    -0x30(%rbp),%rbx
jne    1341 <main+0x1b1>
mov    %rbx,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
jmp    132f <main+0x19f>

LLVM IR (-O0):
@.str = [3 x i8] c"p:\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"usage: %s [-p] path ...\0A\00"
@.str.2 = [2 x i8] c".\00"
@_PC_PATH_MAX = global i32 0
@.str.3 = [3 x i8] c"-p\00"
@.str.4 = [2 x i8] c"/\00"
@errno = global i64 0
@EEXIST = global i64 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 i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8**
%12 = alloca i8*
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %6
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %6
switch i32 %20, label %28 [
i32 112, label %21
i32 63, label %22
]
21: ; preds = %19
store i32 0, i32* %7
br label %28
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %26)
store i32 1, i32* %3
br label %108
28: ; preds = %19, %21
br label %14
29: ; preds = %14
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 2
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %36)
store i32 1, i32* %3
br label %108
38: ; preds = %29
%39 = load i32, i32* @_PC_PATH_MAX
%40 = call i64 @pathconf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %39)
store i64 %40, i64* %8
%41 = load i64, i64* %8
%42 = call i8* @llvm.stacksave()
store i8* %42, i8** %9
%43 = alloca i8, i64 %41
store i64 %41, i64* %10
%44 = load i64, i64* %8
%45 = call i32 @getcwd(i8* %43, i64 %44)
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i32 1
store i8** %47, i8*** %5
store i8** %47, i8*** %11
br label %48
48: ; preds = %102, %38
%49 = load i8**, i8*** %11
%50 = load i8*, i8** %49
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %105
52: ; preds = %48
%53 = call i32 @chdir(i8* %43)
%54 = load i8**, i8*** %11
%55 = load i8*, i8** %54
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %52
br label %102
59: ; preds = %52
%60 = load i32, i32* %7
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %86
62: ; preds = %59
%63 = load i8**, i8*** %11
%64 = load i8*, i8** %63
%65 = call i8* @strtok(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %65, i8** %12
br label %66
66: ; preds = %81, %62
%67 = load i8*, i8** %12
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %85
69: ; preds = %66
%70 = load i8*, i8** %12
%71 = call i32 @mkdir(i8* %70, i32 511)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %81
73: ; preds = %69
%74 = load i64, i64* @errno
%75 = load i64, i64* @EEXIST
%76 = icmp eq i64 %74, %75
br i1 %76, label %77, label %78
77: ; preds = %73
br label %85
78: ; preds = %73
%79 = load i8*, i8** %12
%80 = call i32 @perror(i8* %79)
store i32 1, i32* %3
store i32 1, i32* %13
br label %106
81: ; preds = %69
%82 = load i8*, i8** %12
%83 = call i32 @chdir(i8* %82)
%84 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %84, i8** %12
br label %66
85: ; preds = %77, %66
br label %101
86: ; preds = %59
%87 = load i8**, i8*** %11
%88 = load i8*, i8** %87
%89 = call i32 @mkdir(i8* %88, i32 511)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %100
91: ; preds = %86
%92 = load i64, i64* @errno
%93 = load i64, i64* @EEXIST
%94 = icmp eq i64 %92, %93
br i1 %94, label %95, label %96
95: ; preds = %91
br label %105
96: ; preds = %91
%97 = load i8**, i8*** %11
%98 = load i8*, i8** %97
%99 = call i32 @perror(i8* %98)
store i32 1, i32* %3
store i32 1, i32* %13
br label %106
100: ; preds = %86
br label %101
101: ; preds = %100, %85
br label %102
102: ; preds = %101, %58
%103 = load i8**, i8*** %11
%104 = getelementptr inbounds i8*, i8** %103, i32 1
store i8** %104, i8*** %11
br label %48
105: ; preds = %95, %48
store i32 0, i32* %3
store i32 1, i32* %13
br label %106
106: ; preds = %105, %96, %78
%107 = load i8*, i8** %9
br label %108
108: ; preds = %106, %32, %22
%109 = load i32, i32* %3
ret i32 %109
}

LLVM IR (-O2):
@.str = [3 x i8] c"p:\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"usage: %s [-p] path ...\0A\00"
@.str.2 = [2 x i8] c".\00"
@_PC_PATH_MAX = global i32 0
@.str.3 = [3 x i8] c"-p\00"
@.str.4 = [2 x i8] c"/\00"
@errno = global i64 0
@EEXIST = global i64 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = phi i1 [ false, %2 ], [ true, %5 ]
br label %5
5: ; preds = %3, %5
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %5 [
i32 -1, label %11
i32 112, label %3
i32 63, label %7
]
7: ; preds = %5
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %67
11: ; preds = %5
%12 = icmp slt i32 %0, 2
br i1 %12, label %13, label %17
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %1
%16 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %67
17: ; preds = %11
%18 = load i32, i32* @_PC_PATH_MAX
%19 = tail call i64 @pathconf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = tail call i8* @llvm.stacksave()
%21 = alloca i8, i64 %19
%22 = call i32 @getcwd(i8* %21, i64 %19)
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = icmp eq i8* %24, null
br i1 %25, label %65, label %26
26: ; preds = %17, %61
%27 = phi i8** [ %62, %61 ], [ %23, %17 ]
%28 = call i32 @chdir(i8* %21)
%29 = load i8*, i8** %27
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %61, label %32
32: ; preds = %26
%33 = load i8*, i8** %27
br i1 %4, label %34, label %51
34: ; preds = %32
%35 = call i8* @strtok(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i8* %35, null
br i1 %36, label %61, label %37
37: ; preds = %34, %45
%38 = phi i8* [ %47, %45 ], [ %35, %34 ]
%39 = call i32 @mkdir(i8* %38, i32 511)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i64, i64* @errno
%43 = load i64, i64* @EEXIST
%44 = icmp eq i64 %42, %43
br i1 %44, label %61, label %49
45: ; preds = %37
%46 = call i32 @chdir(i8* %38)
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = icmp eq i8* %47, null
br i1 %48, label %61, label %37
49: ; preds = %41
%50 = call i32 @perror(i8* %38)
br label %65
51: ; preds = %32
%52 = call i32 @mkdir(i8* %33, i32 511)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %61
54: ; preds = %51
%55 = load i64, i64* @errno
%56 = load i64, i64* @EEXIST
%57 = icmp eq i64 %55, %56
br i1 %57, label %65, label %58
58: ; preds = %54
%59 = load i8*, i8** %27
%60 = call i32 @perror(i8* %59)
br label %65
61: ; preds = %45, %34, %41, %51, %26
%62 = getelementptr inbounds i8*, i8** %27, i64 1
%63 = load i8*, i8** %62
%64 = icmp eq i8* %63, null
br i1 %64, label %65, label %26
65: ; preds = %61, %17, %54, %58, %49
%66 = phi i32 [ 1, %49 ], [ 1, %58 ], [ 0, %54 ], [ 0, %17 ], [ 0, %61 ]
br label %67
67: ; preds = %65, %13, %7
%68 = phi i32 [ 1, %7 ], [ 1, %13 ], [ %66, %65 ]
ret i32 %68
}