#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 */
char *chase_symlinks(char const *);
int /*<<< orphan*/ free(char *);
char *init_file_name();
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
const char *init_file_tmp_name(void) {
  static char *file = 0;
  if (!file) {
    const char *name = init_file_name();
    const char *suffix = ".tmp";
    char *n2 = chase_symlinks(name);
    if (n2)
      name = n2;
    if (!name || !*name)
      file = "";
    else {
      file = (char *)malloc(strlen(name) + strlen(suffix) + 2);
      strcpy(file, name);
      strcat(file, suffix);
    }
    if (n2)
      free(n2);
  }
  if (file && *file)
    return file;
  else
    return 0;
}


x86 assembly (clang, -O0):
<init_file_tmp_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
cmpq   $0x0,0x2ee0(%rip)
jne    124d <init_file_tmp_name+0xdd>
mov    $0x0,%al
call   1060 <init_file_name@plt>
mov    %rax,-0x10(%rbp)
lea    0xe68(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <chase_symlinks@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11bc <init_file_tmp_name+0x4c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d4 <init_file_tmp_name+0x64>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11e7 <init_file_tmp_name+0x77>
lea    0xe29(%rip),%rax
mov    %rax,0x2e7e(%rip)
jmp    1234 <init_file_tmp_name+0xc4>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1070 <malloc@plt>
mov    %rax,0x2e4c(%rip)
mov    0x2e45(%rip),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    0x2e35(%rip),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <strcat@plt>
cmpq   $0x0,-0x20(%rbp)
je     1248 <init_file_tmp_name+0xd8>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    124d <init_file_tmp_name+0xdd>
cmpq   $0x0,0x2e0b(%rip)
je     127e <init_file_tmp_name+0x10e>
mov    0x2dfe(%rip),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127e <init_file_tmp_name+0x10e>
mov    0x2deb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1286 <init_file_tmp_name+0x116>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_file_tmp_name>:
push   %r14
push   %rbx
push   %rax
mov    0x2ee5(%rip),%rax
test   %rax,%rax
jne    120e <init_file_tmp_name+0x9e>
xor    %eax,%eax
call   1060 <init_file_name@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <chase_symlinks@plt>
mov    %rax,%r14
test   %rax,%rax
cmovne %rax,%rbx
test   %rbx,%rbx
je     11e7 <init_file_tmp_name+0x77>
cmpb   $0x0,(%rbx)
je     11e7 <init_file_tmp_name+0x77>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x6(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,0x2e9e(%rip)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    0x2e8c(%rip),%rdi
lea    0xe25(%rip),%rsi
call   1090 <strcat@plt>
test   %r14,%r14
jne    11fa <init_file_tmp_name+0x8a>
jmp    1202 <init_file_tmp_name+0x92>
lea    0xe16(%rip),%rax
mov    %rax,0x2e6b(%rip)
test   %r14,%r14
je     1202 <init_file_tmp_name+0x92>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2e57(%rip),%rax
test   %rax,%rax
je     1213 <init_file_tmp_name+0xa3>
cmpb   $0x0,(%rax)
jne    1215 <init_file_tmp_name+0xa5>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@init_file_tmp_name.file = internal global i8* null
@.str = [5 x i8] c".tmp\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @init_file_tmp_name() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = load i8*, i8** @init_file_tmp_name.file
%6 = icmp ne i8* %5, null
br i1 %6, label %45, label %7
7: ; preds = %0
%8 = call i8* (...) @init_file_name()
store i8* %8, i8** %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%9 = load i8*, i8** %2
%10 = call i8* @chase_symlinks(i8* %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = load i8*, i8** %4
store i8* %14, i8** %2
br label %15
15: ; preds = %13, %7
%16 = load i8*, i8** %2
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18, %15
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** @init_file_tmp_name.file
br label %38
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = call i64 @strlen(i8* %24)
%26 = load i8*, i8** %3
%27 = call i64 @strlen(i8* %26)
%28 = add nsw i64 %25, %27
%29 = add nsw i64 %28, 2
%30 = call i64 @malloc(i64 %29)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** @init_file_tmp_name.file
%32 = load i8*, i8** @init_file_tmp_name.file
%33 = load i8*, i8** %2
%34 = call i32 @strcpy(i8* %32, i8* %33)
%35 = load i8*, i8** @init_file_tmp_name.file
%36 = load i8*, i8** %3
%37 = call i32 @strcat(i8* %35, i8* %36)
br label %38
38: ; preds = %23, %22
%39 = load i8*, i8** %4
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i8*, i8** %4
%43 = call i32 @free(i8* %42)
br label %44
44: ; preds = %41, %38
br label %45
45: ; preds = %44, %0
%46 = load i8*, i8** @init_file_tmp_name.file
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i8*, i8** @init_file_tmp_name.file
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %48
%54 = load i8*, i8** @init_file_tmp_name.file
store i8* %54, i8** %1
br label %56
55: ; preds = %48, %45
store i8* null, i8** %1
br label %56
56: ; preds = %55, %53
%57 = load i8*, i8** %1
ret i8* %57
}

LLVM IR (-O2):
@init_file_tmp_name.file = internal unnamed_addr global i8* null
@.str = [5 x i8] c".tmp\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @init_file_tmp_name() {
%1 = load i8*, i8** @init_file_tmp_name.file
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %27
3: ; preds = %0
%4 = tail call i8* (...) @init_file_name()
%5 = tail call i8* @chase_symlinks(i8* %4)
%6 = icmp eq i8* %5, null
%7 = select i1 %6, i8* %4, i8* %5
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load i8, i8* %7
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %3
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** @init_file_tmp_name.file
br label %21
13: ; preds = %9
%14 = tail call i64 @strlen(i8* %7)
%15 = add nsw i64 %14, 6
%16 = tail call i64 @malloc(i64 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** @init_file_tmp_name.file
%18 = tail call i32 @strcpy(i8* %17, i8* %7)
%19 = load i8*, i8** @init_file_tmp_name.file
%20 = tail call i32 @strcat(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %13, %12
br i1 %6, label %24, label %22
22: ; preds = %21
%23 = tail call i32 @free(i8* %5)
br label %24
24: ; preds = %21, %22
%25 = load i8*, i8** @init_file_tmp_name.file
%26 = icmp eq i8* %25, null
br i1 %26, label %31, label %27
27: ; preds = %0, %24
%28 = phi i8* [ %25, %24 ], [ %1, %0 ]
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27, %24
br label %32
32: ; preds = %27, %31
%33 = phi i8* [ null, %31 ], [ %28, %27 ]
ret i8* %33
}