#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 scalar_t__ __mode_t;

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ mkdir(char *, scalar_t__);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
scalar_t__ umask(int /*<<< orphan*/);
int main(int argc, char **argv) {
  __mode_t mask = umask(0);
  if (argc < 2) {
    fputs("Usage: md <dirname>\n", stderr);
    return 1;
  }
  ++argv;
  if (mkdir(*argv, 0777 - mask) != 0) {
    perror("md");
    return 1;
  }
  return 0;
}


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)
xor    %edi,%edi
call   1050 <umask@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118c <main+0x4c>
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
lea    0xe85(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <main+0x96>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x1ff,%esi
sub    -0x18(%rbp),%rsi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     11cf <main+0x8f>
lea    0xe57(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <main+0x96>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <umask@plt>
cmp    $0x1,%ebp
jg     1173 <main+0x33>
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    0xe99(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x1,%ebx
jmp    1189 <main+0x49>
mov    0x8(%r14),%rdi
mov    $0x1ff,%esi
sub    %rax,%rsi
call   1030 <mkdir@plt>
test   %rax,%rax
jne    1190 <main+0x50>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe7e(%rip),%rdi
call   1060 <perror@plt>
jmp    116c <main+0x2c>

LLVM IR (-O0):
@.str = [21 x i8] c"Usage: md <dirname>\0A\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"md\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 @umask(i32 0)
store i64 %7, i64* %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 1, i32* %3
br label %25
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %5
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %16
%18 = load i64, i64* %6
%19 = sub nsw i64 511, %18
%20 = call i64 @mkdir(i8* %17, i64 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %13
%23 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %25
24: ; preds = %13
store i32 0, i32* %3
br label %25
25: ; preds = %24, %22, %10
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [21 x i8] c"Usage: md <dirname>\0A\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"md\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i64 @umask(i32 0)
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %16
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = sub nsw i64 511, %3
%12 = tail call i64 @mkdir(i8* %10, i64 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %8
%15 = tail call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %8, %14, %5
%17 = phi i32 [ 1, %5 ], [ 1, %14 ], [ 0, %8 ]
ret i32 %17
}