#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__ errno;
scalar_t__ mkdir(char *, int);
int smm_errno_update(int);
int smm_mkdir(char *path) {
  if (path == NULL) {
    return smm_errno_update(0);
  }
  if (mkdir(path, 0755) == 0) {
    return smm_errno_update(0);
  }
  if (errno == EEXIST) {
    return smm_errno_update(0);
  }
  return smm_errno_update((0xC0000000 | (11)));
}


x86 assembly (clang, -O0):
<smm_mkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1146 <smm_mkdir+0x26>
xor    %edi,%edi
call   1040 <smm_errno_update@plt>
mov    %eax,-0x4(%rbp)
jmp    11a3 <smm_mkdir+0x83>
mov    -0x10(%rbp),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
jne    116d <smm_mkdir+0x4d>
xor    %edi,%edi
call   1040 <smm_errno_update@plt>
mov    %eax,-0x4(%rbp)
jmp    11a3 <smm_mkdir+0x83>
mov    0x2e64(%rip),%rax
mov    (%rax),%rax
mov    0x2e62(%rip),%rcx
cmp    (%rcx),%rax
jne    1196 <smm_mkdir+0x76>
xor    %edi,%edi
call   1040 <smm_errno_update@plt>
mov    %eax,-0x4(%rbp)
jmp    11a3 <smm_mkdir+0x83>
mov    $0xc000000b,%edi
call   1040 <smm_errno_update@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smm_mkdir>:
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     1155 <smm_mkdir+0x35>
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
je     1155 <smm_mkdir+0x35>
mov    0x2e9a(%rip),%rax
mov    (%rax),%rax
mov    0x2e98(%rip),%rcx
xor    %edx,%edx
cmp    (%rcx),%rax
mov    $0xc000000b,%ebx
cmove  %edx,%ebx
mov    %ebx,%edi
pop    %rbx
jmp    1040 <smm_errno_update@plt>

LLVM IR (-O0):
@errno = global i64 0
@EEXIST = global i64 0
define i32 @smm_mkdir(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @smm_errno_update(i32 0)
store i32 %7, i32* %2
br label %22
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @mkdir(i8* %9, i32 493)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @smm_errno_update(i32 0)
store i32 %13, i32* %2
br label %22
14: ; preds = %8
%15 = load i64, i64* @errno
%16 = load i64, i64* @EEXIST
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @smm_errno_update(i32 0)
store i32 %19, i32* %2
br label %22
20: ; preds = %14
%21 = call i32 @smm_errno_update(i32 -1073741813)
store i32 %21, i32* %2
br label %22
22: ; preds = %20, %18, %12, %6
%23 = load i32, i32* %2
ret i32 %23
}

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