#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 */
int /*<<< orphan*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int mkdir(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int create_workdir(void) {
  int ret;
  if (access("/tmp/mkinnofideifw", F_OK)) {
    printf("directory %s not exist!\n", "/tmp/mkinnofideifw");
    ret = mkdir("/tmp/mkinnofideifw", 0777);
    if (ret < 0) {
      printf("cannot create %s directory\n", "/tmp/mkinnofideifw");
    }
    return ret;
  }
  return 0;
}


x86 assembly (clang, -O0):
<create_workdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    0xeb8(%rip),%rdi
call   1050 <access@plt>
cmp    $0x0,%rax
je     11a6 <create_workdir+0x76>
lea    0xeb5(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    119b <create_workdir+0x6b>
lea    0xe9d(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <create_workdir+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_workdir>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    0xebf(%rip),%rdi
call   1050 <access@plt>
test   %rax,%rax
je     1189 <create_workdir+0x59>
lea    0xec1(%rip),%rdi
lea    0xea7(%rip),%rbx
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    118b <create_workdir+0x5b>
lea    0xeb1(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <printf@plt>
jmp    118b <create_workdir+0x5b>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"/tmp/mkinnofideifw\00"
@F_OK = global i32 0
@.str.1 = [25 x i8] c"directory %s not exist!\0A\00"
@.str.2 = [28 x i8] c"cannot create %s directory\0A\00"
define i32 @create_workdir() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @F_OK
%4 = call i64 @access(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @mkdir(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 511)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = load i32, i32* %2
store i32 %14, i32* %1
br label %16
15: ; preds = %0
store i32 0, i32* %1
br label %16
16: ; preds = %15, %13
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [19 x i8] c"/tmp/mkinnofideifw\00"
@F_OK = global i32 0
@.str.1 = [25 x i8] c"directory %s not exist!\0A\00"
@.str.2 = [28 x i8] c"cannot create %s directory\0A\00"
define i32 @create_workdir() {
%1 = load i32, i32* @F_OK
%2 = tail call i64 @access(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @mkdir(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 511)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %0, %4, %8
%11 = phi i32 [ %6, %8 ], [ %6, %4 ], [ 0, %0 ]
ret i32 %11
}