#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*/ EXIT_FAILURE;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
char *strerror(scalar_t__);
char *tmpnam(char *);
char *xtmpnam(char *space) {
  char *buf = NULL;
  errno = 0;
  if ((buf = tmpnam(space)) == NULL) {
    printf("Could not determine unique file name.(%s)\n", strerror(errno));
    fflush(NULL);
    exit(EXIT_FAILURE);
  }
  return buf;
}


x86 assembly (clang, -O0):
<xtmpnam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e75(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1060 <tmpnam@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11be <xtmpnam+0x6e>
mov    0x2e50(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xtmpnam>:
push   %rbx
mov    0x2e88(%rip),%rbx
movq   $0x0,(%rbx)
call   1060 <tmpnam@plt>
test   %rax,%rax
je     116b <xtmpnam+0x1b>
pop    %rbx
ret
mov    (%rbx),%rdi
call   1070 <strerror@plt>
lea    0xe86(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <fflush@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@.str = [43 x i8] c"Could not determine unique file name.(%s)\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @xtmpnam(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
store i64 0, i64* @errno
%4 = load i8*, i8** %2
%5 = call i8* @tmpnam(i8* %4)
store i8* %5, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %14
7: ; preds = %1
%8 = load i64, i64* @errno
%9 = call i8* @strerror(i64 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 @fflush(i32* null)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = load i8*, i8** %3
ret i8* %15
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [43 x i8] c"Could not determine unique file name.(%s)\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @xtmpnam(i8* %0) {
store i64 0, i64* @errno
%2 = tail call i8* @tmpnam(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = load i64, i64* @errno
%6 = tail call i8* @strerror(i64 %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @fflush(i32* null)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
ret i8* %2
}