#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 scalar_t__ time_t;
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ gethostname(char *, int);
scalar_t__ getpid();
scalar_t__ getppid();
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, int, int, int);
int strlen(char *);
scalar_t__ time(int /*<<< orphan*/ *);
char *tmpFILEpath(char *base) {
  register pid_t pid = getpid(), ppid = getppid();
  register time_t sectime = time(NULL);
  register char *tmppath;
  char hostname[100];
  gethostname(hostname, 100);
  hostname[100 - 1] = '\0';
  if (!base)
    base = "/tmp";
  tmppath = malloc(sizeof(char) * (strlen(base) + strlen(hostname) + 100));
  sprintf(tmppath, "%s/%s_%d_%d_%d.tmpfile", base, hostname, (int)pid,
          (int)ppid, (int)sectime);
  return tmppath;
}


x86 assembly (clang, -O0):
<tmpFILEpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1090 <getppid@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x64,%esi
call   1070 <gethostname@plt>
movb   $0x0,-0x2d(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11cd <tmpFILEpath+0x5d>
lea    0xe37(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
add    %ecx,%eax
add    $0x64,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    -0x90(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %eax,%r8d
mov    -0x18(%rbp),%rax
mov    %eax,%r9d
mov    -0x20(%rbp),%rax
lea    0xdd7(%rip),%rsi
mov    %eax,(%rsp)
call   1080 <sprintf@plt>
mov    -0x28(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tmpFILEpath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1090 <getppid@plt>
mov    %rax,%r15
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%r13
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x64,%esi
call   1070 <gethostname@plt>
movb   $0x0,0x73(%rsp)
test   %rbx,%rbx
lea    0xe40(%rip),%rbp
cmovne %rbx,%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %r13d,(%rsp)
lea    0xe16(%rip),%rsi
mov    %rax,%rdi
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r14d,%r8d
mov    %r15d,%r9d
call   1080 <sprintf@plt>
mov    %rbx,%rax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"/tmp\00"
@.str.1 = [23 x i8] c"%s/%s_%d_%d_%d.tmpfile\00"
define i8* @tmpFILEpath(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca [100 x i8]
store i8* %0, i8** %2
%8 = call i64 (...) @getpid()
store i64 %8, i64* %3
%9 = call i64 (...) @getppid()
store i64 %9, i64* %4
%10 = call i64 @time(i32* null)
store i64 %10, i64* %5
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%12 = call i32 @gethostname(i8* %11, i32 100)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 99
store i8 0, i8* %13
%14 = load i8*, i8** %2
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %16, %1
%18 = load i8*, i8** %2
%19 = call i32 @strlen(i8* %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %19, %21
%23 = add nsw i32 %22, 100
%24 = sext i32 %23 to i64
%25 = mul i64 1, %24
%26 = trunc i64 %25 to i32
%27 = call i8* @malloc(i32 %26)
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = load i8*, i8** %2
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%31 = load i64, i64* %3
%32 = trunc i64 %31 to i32
%33 = load i64, i64* %4
%34 = trunc i64 %33 to i32
%35 = load i64, i64* %5
%36 = trunc i64 %35 to i32
%37 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30, i32 %32, i32 %34, i32 %36)
%38 = load i8*, i8** %6
ret i8* %38
}

LLVM IR (-O2):
@.str = [5 x i8] c"/tmp\00"
@.str.1 = [23 x i8] c"%s/%s_%d_%d_%d.tmpfile\00"
define noalias i8* @tmpFILEpath(i8* %0) {
%2 = alloca [100 x i8]
%3 = tail call i64 (...) @getpid()
%4 = tail call i64 (...) @getppid()
%5 = tail call i64 @time(i32* null)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @gethostname(i8* %6, i32 100)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 99
store i8 0, i8* %8
%9 = icmp eq i8* %0, null
%10 = select i1 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @strlen(i8* %6)
%13 = add i32 %11, 100
%14 = add i32 %13, %12
%15 = call i8* @malloc(i32 %14)
%16 = trunc i64 %3 to i32
%17 = trunc i64 %4 to i32
%18 = trunc i64 %5 to i32
%19 = call i32 @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %6, i32 %16, i32 %17, i32 %18)
ret i8* %15
}