#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 EEXIST 129
#define ENOENT 128
int errno;
int /*<<< orphan*/ getpid();
scalar_t__ mkdir(char const *, int);
int /*<<< orphan*/ say(char *, int /*<<< orphan*/, char const *,
                       int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int);
void domkdir(const char *name) {
  if (mkdir(name, 0775) < 0) {
    switch (errno) {
    case ENOENT:
    case EEXIST:
      break;
    default:
      say("pid %d: mkdir %s: %s\n", getpid(), name, strerror(errno));
      break;
    }
  }
}


x86 assembly (clang, -O0):
<domkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1fd,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
jge    11bd <domkdir+0x7d>
mov    0x2e75(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
sub    $0x1,%eax
ja     1183 <domkdir+0x43>
jmp    117e <domkdir+0x3e>
jmp    11b8 <domkdir+0x78>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    %eax,%ecx
lea    0xe4d(%rip),%rdi
call   1060 <say@plt>
jmp    11bd <domkdir+0x7d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<domkdir>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x1fd,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
jns    116a <domkdir+0x2a>
mov    0x2e83(%rip),%rbp
mov    0x0(%rbp),%eax
and    $0xfffffffe,%eax
cmp    $0x80,%eax
jne    116f <domkdir+0x2f>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%edi
call   1050 <strerror@plt>
lea    0xe78(%rip),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <say@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [22 x i8] c"pid %d: mkdir %s: %s\0A\00"
define void @domkdir(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @mkdir(i8* %3, i32 509)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %1
%7 = load i32, i32* @errno
switch i32 %7, label %9 [
i32 128, label %8
i32 129, label %8
]
8: ; preds = %6, %6
br label %15
9: ; preds = %6
%10 = call i32 (...) @getpid()
%11 = load i8*, i8** %2
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @say(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %11, i32 %13)
br label %15
15: ; preds = %9, %8
br label %16
16: ; preds = %15, %1
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [22 x i8] c"pid %d: mkdir %s: %s\0A\00"
define void @domkdir(i8* %0) {
%2 = tail call i64 @mkdir(i8* %0, i32 509)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = load i32, i32* @errno
%6 = and i32 %5, -2
%7 = icmp eq i32 %6, 128
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = tail call i32 (...) @getpid()
%10 = load i32, i32* @errno
%11 = tail call i32 @strerror(i32 %10)
%12 = tail call i32 @say(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %0, i32 %11)
br label %13
13: ; preds = %4, %8, %1
ret void
}