#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
scalar_t__ ENOENT;
char *create_file_name(char *);
scalar_t__ errno;
int /*<<< orphan*/ fatal(char *, char *, ...);
int mkdir(char *, int);
int stat(char *, struct stat *);
int /*<<< orphan*/ strerror(scalar_t__);
int strlen(char *);
void check_moc_dir() {
  char *dir_name = create_file_name("");
  struct stat file_stat;
  dir_name[strlen(dir_name) - 1] = 0;
  if (stat(dir_name, &file_stat) == -1) {
    if (errno == ENOENT) {
      if (mkdir(dir_name, 0700) == -1)
        fatal("Can't create directory %s, %s", dir_name, strerror(errno));
    } else
      fatal("Error trying to check for "
            ".moc"
            " directory: %s",
            strerror(errno));
  }
}


x86 assembly (clang, -O0):
<check_moc_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeae(%rip),%rdi
call   1050 <create_file_name@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0xffffffff,%eax
jne    1235 <check_moc_dir+0xd5>
mov    0x2e2a(%rip),%rax
mov    (%rax),%rax
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%rax
jne    1210 <check_moc_dir+0xb0>
mov    -0x8(%rbp),%rdi
mov    $0x1c0,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    120b <check_moc_dir+0xab>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2df1(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1080 <fatal@plt>
jmp    1230 <check_moc_dir+0xd0>
mov    0x2dc9(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
movslq %eax,%rsi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1080 <fatal@plt>
jmp    1235 <check_moc_dir+0xd5>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_moc_dir>:
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
call   1050 <create_file_name@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <stat@plt>
cmp    $0xffffffff,%eax
je     119a <check_moc_dir+0x3a>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e3f(%rip),%r14
mov    (%r14),%rdi
mov    0x2e25(%rip),%rax
cmp    (%rax),%rdi
jne    11e4 <check_moc_dir+0x84>
mov    %rbx,%rdi
mov    $0x1c0,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    1192 <check_moc_dir+0x32>
mov    (%r14),%rdi
call   1070 <strerror@plt>
lea    0xe2f(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <fatal@plt>
call   1070 <strerror@plt>
movslq %eax,%rsi
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <fatal@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [1 x i8] zeroinitializer
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [30 x i8] c"Can't create directory %s, %s\00"
@.str.2 = [45 x i8] c"Error trying to check for .moc directory: %s\00"
define void @check_moc_dir() {
%1 = alloca i8*
%2 = alloca %struct.stat
%3 = call i8* @create_file_name(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = load i8*, i8** %1
%6 = call i32 @strlen(i8* %5)
%7 = sub nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %4, i64 %8
store i8 0, i8* %9
%10 = load i8*, i8** %1
%11 = call i32 @stat(i8* %10, %struct.stat* %2)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %34
13: ; preds = %0
%14 = load i64, i64* @errno
%15 = load i64, i64* @ENOENT
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8*, i8** %1
%19 = call i32 @mkdir(i8* %18, i32 448)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i8*, i8** %1
%23 = load i64, i64* @errno
%24 = call i32 @strerror(i64 %23)
%25 = call i32 (i8*, i8*, ...) @fatal(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %22, i32 %24)
br label %26
26: ; preds = %21, %17
br label %33
27: ; preds = %13
%28 = load i64, i64* @errno
%29 = call i32 @strerror(i64 %28)
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i8*
%32 = call i32 (i8*, i8*, ...) @fatal(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %27, %26
br label %34
34: ; preds = %33, %0
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [1 x i8] zeroinitializer
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [30 x i8] c"Can't create directory %s, %s\00"
@.str.2 = [45 x i8] c"Error trying to check for .moc directory: %s\00"
define void @check_moc_dir() {
%1 = alloca %struct.stat
%2 = tail call i8* @create_file_name(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = bitcast %struct.stat* %1 to i8*
%4 = tail call i32 @strlen(i8* %2)
%5 = add nsw i32 %4, -1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %2, i64 %6
store i8 0, i8* %7
%8 = call i32 @stat(i8* %2, %struct.stat* %1)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %26
10: ; preds = %0
%11 = load i64, i64* @errno
%12 = load i64, i64* @ENOENT
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = tail call i32 @mkdir(i8* %2, i32 448)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i64, i64* @errno
%19 = tail call i32 @strerror(i64 %18)
%20 = tail call i32 (i8*, i8*, ...) @fatal(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %19)
br label %26
21: ; preds = %10
%22 = tail call i32 @strerror(i64 %11)
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i8*
%25 = tail call i32 (i8*, i8*, ...) @fatal(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %21, %17, %14, %0
ret void
}