#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 */
#define EACCES 133
#define EEXIST 132
#define ENOENT 131
#define ENOSPC 130
#define ENOTDIR 129
#define EROFS 128
int S_IRGRP;
int S_IROTH;
int S_IRWXU;
int S_IXGRP;
int S_IXOTH;
char *basename(char *);
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int mkdir(char *, int);
int /*<<< orphan*/ printerr(char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int i, status, retval;
  if (argc < 2) {
    fprintf(stderr, "usage: %s DIRECTORY...\n", basename(argv[0]));
    return 1;
  }
  retval = 0;
  for (i = 1; i < argc; ++i) {
    errno = 0;
    status = mkdir(argv[i], S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
    if (status) {
      retval = 2;
      switch (errno) {
      case EACCES:
        printerr(basename(argv[0]), "permission denied", argv[i]);
        break;
      case EEXIST:
        printerr(basename(argv[0]), "file exists", argv[i]);
        break;
      case ENOENT:
        printerr(basename(argv[0]), "no such file or directory", argv[i]);
        break;
      case ENOSPC:
        printerr(basename(argv[0]), "no space left on device", argv[i]);
        break;
      case ENOTDIR:
        printerr(basename(argv[0]), "not a directory", argv[i]);
        break;
      case EROFS:
        printerr(basename(argv[0]), "read-only file system", argv[i]);
        break;
      default:
        printerr(basename(argv[0]), "unknown error.", argv[i]);
      }
    }
  }
  return retval;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1196 <main+0x56>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe93(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    138b <main+0x24b>
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1385 <main+0x245>
mov    0x2e09(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
mov    0x2ddf(%rip),%rax
or     (%rax),%esi
mov    0x2df6(%rip),%rax
or     (%rax),%esi
mov    0x2dc5(%rip),%rax
or     (%rax),%esi
mov    0x2dec(%rip),%rax
or     (%rax),%esi
call   1030 <mkdir@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1372 <main+0x232>
movl   $0x2,-0x1c(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     1346 <main+0x206>
mov    -0x28(%rbp),%rax
lea    0xdcb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdd0(%rip),%rsi
call   1040 <printerr@plt>
jmp    136d <main+0x22d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdb6(%rip),%rsi
call   1040 <printerr@plt>
jmp    136d <main+0x22d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd96(%rip),%rsi
call   1040 <printerr@plt>
jmp    136d <main+0x22d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd84(%rip),%rsi
call   1040 <printerr@plt>
jmp    136d <main+0x22d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd70(%rip),%rsi
call   1040 <printerr@plt>
jmp    136d <main+0x22d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd54(%rip),%rsi
call   1040 <printerr@plt>
jmp    136d <main+0x22d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd3e(%rip),%rsi
call   1040 <printerr@plt>
jmp    1372 <main+0x232>
jmp    1377 <main+0x237>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x64>
mov    -0x1c(%rbp),%eax
mov    %eax,-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,%r15
cmp    $0x2,%edi
jge    118b <main+0x4b>
mov    0x2e6e(%rip),%rax
mov    (%rax),%ebp
mov    (%r15),%rdi
call   1060 <basename@plt>
lea    0xe95(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r14d
xor    %ebp,%ebp
mov    $0x1,%ebx
mov    0x2e24(%rip),%r12
mov    0x2e3d(%rip),%r13
jmp    11d5 <main+0x95>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%rdi
call   1060 <basename@plt>
mov    (%r15,%rbx,8),%rdx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <printerr@plt>
mov    $0x2,%ebp
add    $0x1,%rbx
cmp    %rbx,%r14
je     117a <main+0x3a>
movl   $0x0,(%r12)
mov    (%r15,%rbx,8),%rdi
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
mov    0x2df7(%rip),%rax
or     (%rax),%esi
mov    0x2dde(%rip),%rax
or     (%rax),%esi
mov    0x2dad(%rip),%rax
or     (%rax),%esi
or     0x0(%r13),%esi
call   1030 <mkdir@plt>
test   %eax,%eax
je     11cc <main+0x8c>
mov    (%r12),%eax
add    $0xffffff80,%eax
lea    0xe6e(%rip),%rbp
cmp    $0x5,%eax
ja     11b0 <main+0x70>
cltq
lea    0xe72(%rip),%rcx
movslq (%rcx,%rax,4),%rbp
add    %rcx,%rbp
jmp    11b0 <main+0x70>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"usage: %s DIRECTORY...\0A\00"
@errno = global i32 0
@S_IRWXU = global i32 0
@S_IRGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@.str.1 = [18 x i8] c"permission denied\00"
@.str.2 = [12 x i8] c"file exists\00"
@.str.3 = [26 x i8] c"no such file or directory\00"
@.str.4 = [24 x i8] c"no space left on device\00"
@.str.5 = [16 x i8] c"not a directory\00"
@.str.6 = [22 x i8] c"read-only file system\00"
@.str.7 = [15 x i8] c"unknown error.\00"
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
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i8* @basename(i8* %15)
%17 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %127
18: ; preds = %2
store i32 0, i32* %8
store i32 1, i32* %6
br label %19
19: ; preds = %122, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %125
23: ; preds = %19
store i32 0, i32* @errno
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = load i32, i32* @S_IRWXU
%30 = load i32, i32* @S_IRGRP
%31 = or i32 %29, %30
%32 = load i32, i32* @S_IXGRP
%33 = or i32 %31, %32
%34 = load i32, i32* @S_IROTH
%35 = or i32 %33, %34
%36 = load i32, i32* @S_IXOTH
%37 = or i32 %35, %36
%38 = call i32 @mkdir(i8* %28, i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %121
41: ; preds = %23
store i32 2, i32* %8
%42 = load i32, i32* @errno
switch i32 %42, label %109 [
i32 133, label %43
i32 132, label %54
i32 131, label %65
i32 130, label %76
i32 129, label %87
i32 128, label %98
]
43: ; preds = %41
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i8* @basename(i8* %46)
%48 = load i8**, i8*** %5
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @printerr(i8* %47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %52)
br label %120
54: ; preds = %41
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = load i8*, i8** %56
%58 = call i8* @basename(i8* %57)
%59 = load i8**, i8*** %5
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 @printerr(i8* %58, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %63)
br label %120
65: ; preds = %41
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 0
%68 = load i8*, i8** %67
%69 = call i8* @basename(i8* %68)
%70 = load i8**, i8*** %5
%71 = load i32, i32* %6
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 @printerr(i8* %69, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %74)
br label %120
76: ; preds = %41
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 0
%79 = load i8*, i8** %78
%80 = call i8* @basename(i8* %79)
%81 = load i8**, i8*** %5
%82 = load i32, i32* %6
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 @printerr(i8* %80, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %85)
br label %120
87: ; preds = %41
%88 = load i8**, i8*** %5
%89 = getelementptr inbounds i8*, i8** %88, i64 0
%90 = load i8*, i8** %89
%91 = call i8* @basename(i8* %90)
%92 = load i8**, i8*** %5
%93 = load i32, i32* %6
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8*, i8** %92, i64 %94
%96 = load i8*, i8** %95
%97 = call i32 @printerr(i8* %91, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %96)
br label %120
98: ; preds = %41
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 0
%101 = load i8*, i8** %100
%102 = call i8* @basename(i8* %101)
%103 = load i8**, i8*** %5
%104 = load i32, i32* %6
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8*, i8** %103, i64 %105
%107 = load i8*, i8** %106
%108 = call i32 @printerr(i8* %102, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %107)
br label %120
109: ; preds = %41
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 0
%112 = load i8*, i8** %111
%113 = call i8* @basename(i8* %112)
%114 = load i8**, i8*** %5
%115 = load i32, i32* %6
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8*, i8** %114, i64 %116
%118 = load i8*, i8** %117
%119 = call i32 @printerr(i8* %113, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %118)
br label %120
120: ; preds = %109, %98, %87, %76, %65, %54, %43
br label %121
121: ; preds = %120, %23
br label %122
122: ; preds = %121
%123 = load i32, i32* %6
%124 = add nsw i32 %123, 1
store i32 %124, i32* %6
br label %19
125: ; preds = %19
%126 = load i32, i32* %8
store i32 %126, i32* %3
br label %127
127: ; preds = %125, %11
%128 = load i32, i32* %3
ret i32 %128
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"usage: %s DIRECTORY...\0A\00"
@errno = global i32 0
@S_IRWXU = global i32 0
@S_IRGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@.str.1 = [18 x i8] c"permission denied\00"
@.str.2 = [12 x i8] c"file exists\00"
@.str.3 = [26 x i8] c"no such file or directory\00"
@.str.4 = [24 x i8] c"no space left on device\00"
@.str.5 = [16 x i8] c"not a directory\00"
@.str.6 = [22 x i8] c"read-only file system\00"
@.str.7 = [15 x i8] c"unknown error.\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.6 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %11
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i8* @basename(i8* %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %45
11: ; preds = %4, %41
%12 = phi i64 [ 1, %4 ], [ %43, %41 ]
%13 = phi i32 [ 0, %4 ], [ %42, %41 ]
store i32 0, i32* @errno
%14 = getelementptr inbounds i8*, i8** %1, i64 %12
%15 = load i8*, i8** %14
%16 = load i32, i32* @S_IRWXU
%17 = load i32, i32* @S_IRGRP
%18 = or i32 %17, %16
%19 = load i32, i32* @S_IXGRP
%20 = or i32 %18, %19
%21 = load i32, i32* @S_IROTH
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IXOTH
%24 = or i32 %22, %23
%25 = tail call i32 @mkdir(i8* %15, i32 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %41, label %27
27: ; preds = %11
%28 = load i32, i32* @errno
%29 = add i32 %28, -128
%30 = icmp ult i32 %29, 6
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = sext i32 %29 to i64
%33 = shl i64 %32, 2
%34 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %33)
br label %35
35: ; preds = %27, %31
%36 = phi i8* [ %34, %31 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), %27 ]
%37 = load i8*, i8** %1
%38 = tail call i8* @basename(i8* %37)
%39 = load i8*, i8** %14
%40 = tail call i32 @printerr(i8* %38, i8* %36, i8* %39)
br label %41
41: ; preds = %35, %11
%42 = phi i32 [ %13, %11 ], [ 2, %35 ]
%43 = add nuw nsw i64 %12, 1
%44 = icmp eq i64 %43, %5
br i1 %44, label %45, label %11
45: ; preds = %41, %6
%46 = phi i32 [ 1, %6 ], [ %42, %41 ]
ret i32 %46
}