#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 */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int mkdir(char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int usage();
int mkdir_main(int argc, char *argv[]) {
  int symbolic = 0;
  int ret;
  if (argc < 2)
    return usage();
  while (argc > 1) {
    argc--;
    argv++;
    ret = mkdir(argv[0], 0777);
    if (ret < 0) {
      fprintf(stderr, "mkdir failed for %s, %s\n", argv[0], strerror(errno));
      return ret;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<mkdir_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116f <mkdir_main+0x2f>
mov    $0x0,%al
call   1050 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1203 <mkdir_main+0xc3>
jmp    1174 <mkdir_main+0x34>
cmpl   $0x1,-0x8(%rbp)
jle    11fc <mkdir_main+0xbc>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11f7 <mkdir_main+0xb7>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe19(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1203 <mkdir_main+0xc3>
jmp    1174 <mkdir_main+0x34>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkdir_main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jge    1154 <mkdir_main+0x14>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <usage@plt>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x8,%rbx
nopl   (%rax)
cmp    $0x2,%ebp
jl     11b1 <mkdir_main+0x71>
add    $0xffffffff,%ebp
mov    (%rbx),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
add    $0x8,%rbx
test   %eax,%eax
jns    1160 <mkdir_main+0x20>
mov    %eax,%r14d
mov    0x2e59(%rip),%rax
mov    (%rax),%ebp
mov    -0x8(%rbx),%rbx
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe5e(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
jmp    11b4 <mkdir_main+0x74>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"mkdir failed for %s, %s\0A\00"
@errno = global i32 0
define i32 @mkdir_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
store i32 %11, i32* %3
br label %38
12: ; preds = %2
br label %13
13: ; preds = %36, %12
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %37
16: ; preds = %13
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
store i32 %18, i32* %4
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %5
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @mkdir(i8* %23, i32 511)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %16
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %31, i8* %33)
%35 = load i32, i32* %7
store i32 %35, i32* %3
br label %38
36: ; preds = %16
br label %13
37: ; preds = %13
store i32 0, i32* %3
br label %38
38: ; preds = %37, %27, %10
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"mkdir failed for %s, %s\0A\00"
@errno = global i32 0
define i32 @mkdir_main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %22
6: ; preds = %2, %10
%7 = phi i8** [ %12, %10 ], [ %1, %2 ]
%8 = phi i32 [ %11, %10 ], [ %0, %2 ]
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = add nsw i32 %8, -1
%12 = getelementptr inbounds i8*, i8** %7, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @mkdir(i8* %13, i32 511)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %6
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %20)
br label %22
22: ; preds = %6, %16, %4
%23 = phi i32 [ %5, %4 ], [ %14, %16 ], [ 0, %6 ]
ret i32 %23
}