#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__ asprintf(char **, char *, char const *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ mkdtemp(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
char *strerror(int /*<<< orphan*/);
char *re_test_directory(const char *prefix) {
  char *directory;
  if (asprintf(&directory, "%s.XXXXXX", prefix) < 0)
    assert(0 && "allocation failed");
  if (!mkdtemp(directory)) {
    printf("# couldn't create temp directory: %s: %s\n", directory,
           strerror(errno));
    free(directory);
    assert(0 && "mkdtemp failed");
  }
  return directory;
}


x86 assembly (clang, -O0):
<re_test_directory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1060 <asprintf@plt>
cmp    $0x0,%rax
jge    1191 <re_test_directory+0x31>
xor    %edi,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <mkdtemp@plt>
cmp    $0x0,%eax
jne    11dc <re_test_directory+0x7c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<re_test_directory>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rdx
lea    0xe91(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1060 <asprintf@plt>
test   %rax,%rax
jns    1185 <re_test_directory+0x25>
xor    %edi,%edi
call   1050 <assert@plt>
mov    0x8(%rsp),%rdi
call   1070 <mkdtemp@plt>
test   %eax,%eax
jne    11c9 <re_test_directory+0x69>
mov    0x8(%rsp),%rbx
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe5d(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1050 <assert@plt>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s.XXXXXX\00"
@.str.1 = [42 x i8] c"# couldn't create temp directory: %s: %s\0A\00"
@errno = global i32 0
define i8* @re_test_directory(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @asprintf(i8** %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @assert(i32 0)
br label %9
9: ; preds = %7, %1
%10 = load i8*, i8** %3
%11 = call i32 @mkdtemp(i8* %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %16)
%18 = load i8*, i8** %3
%19 = call i32 @free(i8* %18)
%20 = call i32 @assert(i32 0)
br label %21
21: ; preds = %13, %9
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s.XXXXXX\00"
@.str.1 = [42 x i8] c"# couldn't create temp directory: %s: %s\0A\00"
@errno = global i32 0
define i8* @re_test_directory(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @asprintf(i8** %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @assert(i32 0)
br label %8
8: ; preds = %6, %1
%9 = load i8*, i8** %2
%10 = call i32 @mkdtemp(i8* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = load i32, i32* @errno
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %15)
%17 = load i8*, i8** %2
%18 = call i32 @free(i8* %17)
%19 = call i32 @assert(i32 0)
br label %20
20: ; preds = %12, %8
%21 = load i8*, i8** %2
ret i8* %21
}