#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*/ printf(char *);
char *tempnam(char *, char *);
int tempName(char **name) {
  if (*name != NULL) {
    printf("Nullpointer must be given to 'tempName'\n");
    return -1;
  }
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
  *name = tempnam(".", "clash");
#pragma clang diagnostic pop
  if (*name == NULL) {
    printf("Unable to create tempory file-name\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<tempName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1152 <tempName+0x32>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <tempName+0x7c>
lea    0xed0(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1040 <tempnam@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1195 <tempName+0x75>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <tempName+0x7c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tempName>:
push   %rbx
cmpq   $0x0,(%rdi)
je     113a <tempName+0x1a>
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
jmp    115d <tempName+0x3d>
mov    %rdi,%rbx
lea    0xebc(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <tempnam@plt>
mov    %rax,%rcx
mov    %rax,(%rbx)
xor    %eax,%eax
test   %rcx,%rcx
je     115f <tempName+0x3f>
pop    %rbx
ret
lea    0xea2(%rip),%rdi
jmp    112e <tempName+0xe>

LLVM IR (-O0):
@.str = [41 x i8] c"Nullpointer must be given to 'tempName'\0A\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [6 x i8] c"clash\00"
@.str.3 = [36 x i8] c"Unable to create tempory file-name\0A\00"
define i32 @tempName(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
store i8** %0, i8*** %3
%4 = load i8**, i8*** %3
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %18
9: ; preds = %1
%10 = call i8* @tempnam(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = load i8**, i8*** %3
store i8* %10, i8** %11
%12 = load i8**, i8*** %3
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %2
br label %18
17: ; preds = %9
store i32 0, i32* %2
br label %18
18: ; preds = %17, %15, %7
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c".\00"
@.str.2 = [6 x i8] c"clash\00"
@str = [35 x i8] c"Unable to create tempory file-name\00"
@str.4 = [40 x i8] c"Nullpointer must be given to 'tempName'\00"
define i32 @tempName(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i8* @tempnam(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i8* %5, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4, %1
%8 = phi i8* [ getelementptr inbounds ([40 x i8], [40 x i8]* @str.4, i64 0, i64 0), %1 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0), %4 ]
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
br label %10
10: ; preds = %7, %4
%11 = phi i32 [ 0, %4 ], [ -1, %7 ]
ret i32 %11
}