int emkdir(name, mode) const char *name;
const int mode;
{
  register int result;
  register const char *format;
  register char *command;
  register char *qname;
  if ((qname = quoted(name)) == ((void *)0))
    return -1;
  format = "mkdir 2>&- %s && chmod 2>&- %o %s";
  command = imalloc(strlen(format) + 2 * strlen(qname) + 20 + 1);
  if (command == ((void *)0)) {
    ifree(qname);
    return -1;
  }
  (void)sprintf(command, format, qname, mode, qname);
  ifree(qname);
  result = system(command);
  ifree(command);
  return (result == 0) ? 0 : -1;
}


x86 assembly (clang, -O0):
<emkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <quoted@plt>
cltq
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1196 <emkdir+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    124a <emkdir+0xea>
lea    0xe63(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
shl    $0x1,%rax
add    %rax,%rdi
add    $0x14,%rdi
add    $0x1,%rdi
mov    $0x0,%al
call   1050 <imalloc@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11f9 <emkdir+0x99>
mov    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1060 <ifree@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    124a <emkdir+0xea>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x30(%rbp),%r8
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1060 <ifree@plt>
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1040 <system@plt>
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1060 <ifree@plt>
mov    -0x18(%rbp),%edx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emkdir>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
xor    %eax,%eax
call   1070 <quoted@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
je     11e2 <emkdir+0x82>
movslq %eax,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%rax,%rax,1),%rdi
add    $0x36,%rdi
xor    %eax,%eax
call   1050 <imalloc@plt>
test   %eax,%eax
je     11d8 <emkdir+0x78>
movslq %eax,%rbp
lea    0xe61(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r14d,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <ifree@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <system@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <ifree@plt>
neg    %ebx
sbb    %ebp,%ebp
jmp    11e2 <emkdir+0x82>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <ifree@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"mkdir 2>&- %s && chmod 2>&- %o %s\00"
define i32 @emkdir(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%10 = load i8*, i8** %4
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @quoted to i32 (i8*, ...)*)(i8* %10)
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %9
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 -1, i32* %3
br label %50
16: ; preds = %2
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8** %7
%17 = load i8*, i8** %7
%18 = call i64 @strlen(i8* %17)
%19 = load i8*, i8** %9
%20 = call i64 @strlen(i8* %19)
%21 = mul i64 2, %20
%22 = add i64 %18, %21
%23 = add i64 %22, 20
%24 = add i64 %23, 1
%25 = call i32 (i64, ...) bitcast (i32 (...)* @imalloc to i32 (i64, ...)*)(i64 %24)
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %33
30: ; preds = %16
%31 = load i8*, i8** %9
%32 = call i32 (i8*, ...) bitcast (i32 (...)* @ifree to i32 (i8*, ...)*)(i8* %31)
store i32 -1, i32* %3
br label %50
33: ; preds = %16
%34 = load i8*, i8** %8
%35 = load i8*, i8** %7
%36 = load i8*, i8** %9
%37 = load i32, i32* %5
%38 = load i8*, i8** %9
%39 = call i32 (i8*, i8*, ...) @sprintf(i8* %34, i8* %35, i8* %36, i32 %37, i8* %38)
%40 = load i8*, i8** %9
%41 = call i32 (i8*, ...) bitcast (i32 (...)* @ifree to i32 (i8*, ...)*)(i8* %40)
%42 = load i8*, i8** %8
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %42)
store i32 %43, i32* %6
%44 = load i8*, i8** %8
%45 = call i32 (i8*, ...) bitcast (i32 (...)* @ifree to i32 (i8*, ...)*)(i8* %44)
%46 = load i32, i32* %6
%47 = icmp eq i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 0, i32 -1
store i32 %49, i32* %3
br label %50
50: ; preds = %33, %30, %15
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [34 x i8] c"mkdir 2>&- %s && chmod 2>&- %o %s\00"
define i32 @emkdir(i8* %0, i32 %1) {
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @quoted to i32 (i8*, ...)*)(i8* %0)
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
%6 = icmp eq i32 %3, 0
br i1 %6, label %24, label %7
7: ; preds = %2
%8 = tail call i64 @strlen(i8* %5)
%9 = shl i64 %8, 1
%10 = add i64 %9, 54
%11 = tail call i32 (i64, ...) bitcast (i32 (...)* @imalloc to i32 (i64, ...)*)(i64 %10)
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
%14 = icmp eq i32 %11, 0
br i1 %14, label %15, label %17
15: ; preds = %7
%16 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ifree to i32 (i8*, ...)*)(i8* %5)
br label %24
17: ; preds = %7
%18 = tail call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %1, i8* %5)
%19 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ifree to i32 (i8*, ...)*)(i8* %5)
%20 = tail call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %13)
%21 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ifree to i32 (i8*, ...)*)(i8* %13)
%22 = icmp ne i32 %20, 0
%23 = sext i1 %22 to i32
br label %24
24: ; preds = %2, %17, %15
%25 = phi i32 [ -1, %15 ], [ %23, %17 ], [ -1, %2 ]
ret i32 %25
}