makedir(dirname, mode) char *dirname;
int mode;
{
  register int pid;
  int retcode, status;
  switch ((pid = fork())) {
  case -1:
    return (-1);
  case 0:
    umask(0);
    execl("/bin/mkdir", "mkdir", dirname, (char *)0);
    exit(1);
  default:
    while ((retcode = wait(&status)) != pid && retcode != -1)
      ;
    if (retcode == -1)
      return -1;
    else {
      chmod(dirname, mode);
      return status;
    }
  }
}


x86 assembly (clang, -O0):
<makedir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,-0x18(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
sub    $0xffffffff,%eax
je     119c <makedir+0x3c>
jmp    118c <makedir+0x2c>
mov    -0x24(%rbp),%eax
test   %eax,%eax
je     11a8 <makedir+0x48>
jmp    11d8 <makedir+0x78>
movl   $0xffffffff,-0x4(%rbp)
jmp    1244 <makedir+0xe4>
xor    %edi,%edi
mov    $0x0,%al
call   1030 <umask@plt>
mov    -0x10(%rbp),%rdx
lea    0xe44(%rip),%rdi
lea    0xe42(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   1060 <execl@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11dd <makedir+0x7d>
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1070 <wait@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%ecx
mov    %al,-0x25(%rbp)
je     1205 <makedir+0xa5>
cmpl   $0xffffffff,-0x1c(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1215 <makedir+0xb5>
jmp    121a <makedir+0xba>
jmp    11dd <makedir+0x7d>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1230 <makedir+0xd0>
movl   $0xffffffff,-0x4(%rbp)
jmp    1244 <makedir+0xe4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1040 <chmod@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makedir>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r14
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     11c0 <makedir+0x60>
test   %ebx,%ebx
je     11cd <makedir+0x6d>
lea    0x4(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <wait@plt>
cmp    %ebx,%eax
je     11a3 <makedir+0x43>
cmp    $0xffffffff,%eax
jne    1190 <makedir+0x30>
cmp    $0xffffffff,%eax
je     11bb <makedir+0x5b>
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <chmod@plt>
mov    0x4(%rsp),%ebx
jmp    11c0 <makedir+0x60>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
xor    %eax,%eax
call   1030 <umask@plt>
lea    0xe23(%rip),%rdi
lea    0xe21(%rip),%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1060 <execl@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"/bin/mkdir\00"
@.str.1 = [6 x i8] c"mkdir\00"
define i32 @makedir(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = call i32 (...) @fork()
store i32 %9, i32* %6
switch i32 %9, label %15 [
i32 -1, label %10
i32 0, label %11
]
10: ; preds = %2
store i32 -1, i32* %3
br label %35
11: ; preds = %2
%12 = call i32 (i32, ...) bitcast (i32 (...)* @umask to i32 (i32, ...)*)(i32 0)
%13 = load i8*, i8** %4
%14 = call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @execl to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* null)
unreachable
15: ; preds = %2
br label %16
16: ; preds = %25, %15
%17 = call i32 (i32*, ...) bitcast (i32 (...)* @wait to i32 (i32*, ...)*)(i32* %8)
store i32 %17, i32* %7
%18 = load i32, i32* %6
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, -1
br label %23
23: ; preds = %20, %16
%24 = phi i1 [ false, %16 ], [ %22, %20 ]
br i1 %24, label %25, label %26
25: ; preds = %23
br label %16
26: ; preds = %23
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 -1, i32* %3
br label %35
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = load i32, i32* %5
%33 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @chmod to i32 (i8*, i32, ...)*)(i8* %31, i32 %32)
%34 = load i32, i32* %8
store i32 %34, i32* %3
br label %35
35: ; preds = %30, %29, %10
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [11 x i8] c"/bin/mkdir\00"
@.str.1 = [6 x i8] c"mkdir\00"
define i32 @makedir(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (...) @fork()
switch i32 %5, label %9 [
i32 -1, label %19
i32 0, label %6
]
6: ; preds = %2
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @umask to i32 (i32, ...)*)(i32 0)
%8 = tail call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @execl to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* null)
tail call void @exit(i32 1)
unreachable
9: ; preds = %2, %9
%10 = call i32 (i32*, ...) bitcast (i32 (...)* @wait to i32 (i32*, ...)*)(i32* %3)
%11 = icmp ne i32 %10, %5
%12 = icmp ne i32 %10, -1
%13 = and i1 %11, %12
br i1 %13, label %9, label %14
14: ; preds = %9
%15 = icmp eq i32 %10, -1
br i1 %15, label %19, label %16
16: ; preds = %14
%17 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @chmod to i32 (i8*, i32, ...)*)(i8* %0, i32 %1)
%18 = load i32, i32* %3
br label %19
19: ; preds = %14, %2, %16
%20 = phi i32 [ %18, %16 ], [ %5, %2 ], [ -1, %14 ]
ret i32 %20
}