#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 /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void check_dumpdir_existance() {
  DIR *dir;
  if (!(dir = opendir("dumps/"))) {
    perror("Fatal error opening code dump directory");
    fprintf(stderr, "create/check permissions on %s\n", "dumps/");
    exit(-1);
  }
  closedir(dir);
  return;
}


x86 assembly (clang, -O0):
<check_dumpdir_existance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    11a4 <check_dumpdir_existance+0x54>
lea    0xe8e(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
lea    0xe6b(%rip),%rdx
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1040 <closedir@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_dumpdir_existance>:
push   %rax
lea    0xea8(%rip),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     116b <check_dumpdir_existance+0x1b>
mov    %rax,%rdi
pop    %rax
jmp    1040 <closedir@plt>
lea    0xe95(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
lea    0xe72(%rip),%rdx
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"dumps/\00"
@.str.1 = [40 x i8] c"Fatal error opening code dump directory\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"create/check permissions on %s\0A\00"
define void @check_dumpdir_existance() {
%1 = alloca i32*
%2 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32* %2, i32** %1
%3 = icmp ne i32* %2, null
br i1 %3, label %9, label %4
4: ; preds = %0
%5 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 -1)
unreachable
9: ; preds = %0
%10 = load i32*, i32** %1
%11 = call i32 @closedir(i32* %10)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"dumps/\00"
@.str.1 = [40 x i8] c"Fatal error opening code dump directory\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"create/check permissions on %s\0A\00"
define void @check_dumpdir_existance() {
%1 = tail call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %0
%9 = tail call i32 @closedir(i32* %1)
ret void
}