#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 */
scalar_t__ EEXIST;
scalar_t__ ENOENT;
scalar_t__ errno;
int mkdir(char *, int);
int wdc_UtilsCreateDir(char *path) {
  int retStatus;
  int status = 0;
  if (!path) {
    return -3;
  }
  retStatus = mkdir(path, 0x999);
  if (retStatus < 0) {
    if (errno == EEXIST) {
      status = -36;
    } else if (errno == ENOENT) {
      status = -37;
    } else {
      status = -38;
    }
  }
  return status;
}


x86 assembly (clang, -O0):
<wdc_UtilsCreateDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113a <wdc_UtilsCreateDir+0x2a>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11b8 <wdc_UtilsCreateDir+0xa8>
mov    -0x10(%rbp),%rdi
mov    $0x999,%esi
call   1030 <mkdir@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11b2 <wdc_UtilsCreateDir+0xa2>
mov    0x2e7c(%rip),%rax
mov    (%rax),%rax
mov    0x2e7a(%rip),%rcx
cmp    (%rcx),%rax
jne    117b <wdc_UtilsCreateDir+0x6b>
movl   $0xffffffdc,-0x18(%rbp)
jmp    11ad <wdc_UtilsCreateDir+0x9d>
mov    0x2e56(%rip),%rax
mov    (%rax),%rax
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%rax
jne    11a1 <wdc_UtilsCreateDir+0x91>
movl   $0xffffffdb,-0x18(%rbp)
jmp    11a8 <wdc_UtilsCreateDir+0x98>
movl   $0xffffffda,-0x18(%rbp)
jmp    11ad <wdc_UtilsCreateDir+0x9d>
jmp    11b2 <wdc_UtilsCreateDir+0xa2>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wdc_UtilsCreateDir>:
push   %rax
test   %rdi,%rdi
je     112a <wdc_UtilsCreateDir+0x1a>
mov    $0x999,%esi
call   1030 <mkdir@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
js     1131 <wdc_UtilsCreateDir+0x21>
pop    %rcx
ret
mov    $0xfffffffd,%eax
pop    %rcx
ret
mov    0x2ea0(%rip),%rax
mov    (%rax),%rcx
mov    0x2e9e(%rip),%rdx
mov    $0xffffffdc,%eax
cmp    (%rdx),%rcx
je     1128 <wdc_UtilsCreateDir+0x18>
mov    0x2e75(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
sete   %al
or     $0xffffffda,%eax
pop    %rcx
ret

LLVM IR (-O0):
@errno = global i64 0
@EEXIST = global i64 0
@ENOENT = global i64 0
define i32 @wdc_UtilsCreateDir(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 -3, i32* %2
br label %29
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @mkdir(i8* %10, i32 2457)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = load i64, i64* @errno
%16 = load i64, i64* @EEXIST
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 -36, i32* %5
br label %26
19: ; preds = %14
%20 = load i64, i64* @errno
%21 = load i64, i64* @ENOENT
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 -37, i32* %5
br label %25
24: ; preds = %19
store i32 -38, i32* %5
br label %25
25: ; preds = %24, %23
br label %26
26: ; preds = %25, %18
br label %27
27: ; preds = %26, %9
%28 = load i32, i32* %5
store i32 %28, i32* %2
br label %29
29: ; preds = %27, %8
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@errno = global i64 0
@EEXIST = global i64 0
@ENOENT = global i64 0
define i32 @wdc_UtilsCreateDir(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = tail call i32 @mkdir(i8* %0, i32 2457)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = load i64, i64* @errno
%8 = load i64, i64* @EEXIST
%9 = icmp eq i64 %7, %8
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i64, i64* @ENOENT
%12 = icmp eq i64 %7, %11
%13 = select i1 %12, i32 -37, i32 -38
br label %14
14: ; preds = %3, %6, %10, %1
%15 = phi i32 [ -3, %1 ], [ 0, %3 ], [ -36, %6 ], [ %13, %10 ]
ret i32 %15
}