#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 */
typedef int mode_t;

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ Message(char *, int, char *);
scalar_t__ access(char *, int /*<<< orphan*/);
scalar_t__ mkdir(char *, int);
int umask(int);
void MakeDirectory(char *dirname) {
  mode_t mode = 01777;
  if (access(dirname, F_OK) != 0) {
    mode_t oldMask;
    oldMask = umask((mode_t)0000);
    if (mkdir(dirname, mode) != 0) {
      Message("simq", 3, "Could not create queue directory");
    }
    umask(oldMask);
  }
}


x86 assembly (clang, -O0):
<MakeDirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x3ff,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0x0,%rax
je     11af <MakeDirectory+0x6f>
xor    %edi,%edi
call   1050 <umask@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     11a7 <MakeDirectory+0x67>
lea    0xe6a(%rip),%rdi
mov    $0x3,%esi
lea    0xe63(%rip),%rdx
call   1040 <Message@plt>
mov    -0x10(%rbp),%edi
call   1050 <umask@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeDirectory>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
test   %rax,%rax
je     1199 <MakeDirectory+0x59>
xor    %edi,%edi
call   1050 <umask@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x3ff,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
je     118c <MakeDirectory+0x4c>
lea    0xe85(%rip),%rdi
lea    0xe83(%rip),%rdx
mov    $0x3,%esi
call   1040 <Message@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <umask@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@F_OK = global i32 0
@.str = [5 x i8] c"simq\00"
@.str.1 = [33 x i8] c"Could not create queue directory\00"
define void @MakeDirectory(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 1023, i32* %3
%5 = load i8*, i8** %2
%6 = load i32, i32* @F_OK
%7 = call i64 @access(i8* %5, i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %1
%10 = call i32 @umask(i32 0)
store i32 %10, i32* %4
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = call i64 @mkdir(i8* %11, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @Message(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %9
%18 = load i32, i32* %4
%19 = call i32 @umask(i32 %18)
br label %20
20: ; preds = %17, %1
ret void
}

LLVM IR (-O2):
@F_OK = global i32 0
@.str = [5 x i8] c"simq\00"
@.str.1 = [33 x i8] c"Could not create queue directory\00"
define void @MakeDirectory(i8* nocapture %0) {
%2 = load i32, i32* @F_OK
%3 = tail call i64 @access(i8* %0, i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = tail call i32 @umask(i32 0)
%7 = tail call i64 @mkdir(i8* %0, i32 1023)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 @Message(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %5
%12 = tail call i32 @umask(i32 %6)
br label %13
13: ; preds = %11, %1
ret void
}