#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 */
unsigned int getpid();
scalar_t__ malloc(int);
int /*<<< orphan*/ pptcapi_ltoa(unsigned int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int time(int /*<<< orphan*/ *);
char *pptcapi_temp_name() {
  char *retbuf = (char *)malloc(256);
  if (retbuf) {
    char tempbuf1[50];
    pptcapi_ltoa(getpid(), tempbuf1, 10);
    char tempbuf2[50];
    unsigned int t = time(NULL) - 1000000000;
    pptcapi_ltoa(t, tempbuf2, 10);
    snprintf(retbuf, 256, "%s_%s", tempbuf1, tempbuf2);
  }
  return retbuf;
}


x86 assembly (clang, -O0):
<pptcapi_temp_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11d0 <pptcapi_temp_name+0x80>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1050 <pptcapi_ltoa@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
sub    $0x3b9aca00,%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0xa,%edx
call   1050 <pptcapi_ltoa@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    -0x80(%rbp),%r8
mov    $0x100,%esi
lea    0xe35(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pptcapi_temp_name>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c0 <pptcapi_temp_name+0x70>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0x40(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1050 <pptcapi_ltoa@plt>
xor    %edi,%edi
call   1060 <time@plt>
lea    -0x3b9aca00(%rax),%edi
mov    %rsp,%r15
mov    %r15,%rsi
mov    $0xa,%edx
call   1050 <pptcapi_ltoa@plt>
lea    0xe53(%rip),%rdx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <snprintf@plt>
mov    %rbx,%rax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s_%s\00"
define i8* @pptcapi_temp_name() {
%1 = alloca i8*
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = call i64 @malloc(i32 256)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %1
%7 = load i8*, i8** %1
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %22
9: ; preds = %0
%10 = call i32 (...) @getpid()
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i32 @pptcapi_ltoa(i32 %10, i8* %11, i32 10)
%13 = call i32 @time(i32* null)
%14 = sub nsw i32 %13, 1000000000
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%17 = call i32 @pptcapi_ltoa(i32 %15, i8* %16, i32 10)
%18 = load i8*, i8** %1
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%21 = call i32 @snprintf(i8* %18, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
br label %22
22: ; preds = %9, %0
%23 = load i8*, i8** %1
ret i8* %23
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s_%s\00"
define i8* @pptcapi_temp_name() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = tail call i64 @malloc(i32 256)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %15, label %6
6: ; preds = %0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%8 = tail call i32 (...) @getpid()
%9 = call i32 @pptcapi_ltoa(i32 %8, i8* %7, i32 10)
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%11 = call i32 @time(i32* null)
%12 = add nsw i32 %11, -1000000000
%13 = call i32 @pptcapi_ltoa(i32 %12, i8* %10, i32 10)
%14 = call i32 @snprintf(i8* %4, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %10)
br label %15
15: ; preds = %6, %0
ret i8* %4
}