#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 int /*<<< orphan*/ time_t;

/* Variables and functions */
char *malloc(size_t);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *,
                            int /*<<< orphan*/);
int strlen(char const *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *__setup_tempfile(const char *dir) {
  char *fname;
  size_t n = strlen(dir) + 18;
  time_t t;
  time(&t);
  fname = malloc(n);
  if (!fname) {
    return NULL;
  }
  snprintf(fname, n, "%s/%016lx", dir, t);
  return fname;
}


x86 assembly (clang, -O0):
<__setup_tempfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x12,%eax
cltq
mov    %rax,-0x20(%rbp)
lea    -0x24(%rbp),%rdi
call   1050 <time@plt>
mov    -0x20(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118c <__setup_tempfile+0x4c>
movq   $0x0,-0x8(%rbp)
jmp    11b0 <__setup_tempfile+0x70>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x24(%rbp),%r8d
lea    0xe5d(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__setup_tempfile>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
call   1030 <strlen@plt>
add    $0x12,%eax
movslq %eax,%r15
lea    0xc(%rsp),%rdi
call   1050 <time@plt>
mov    %r15,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     118b <__setup_tempfile+0x4b>
mov    0xc(%rsp),%r8d
lea    0xe83(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rcx
call   1040 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"%s/%016lx\00"
define i8* @__setup_tempfile(i8* %0) {
%2 = alloca i32
%3 = tail call i32 @strlen(i8* %0)
%4 = add nsw i32 %3, 18
%5 = sext i32 %4 to i64
%6 = bitcast i32* %2 to i8*
%7 = call i32 @time(i32* %2)
%8 = call i8* @malloc(i64 %5)
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i32 @snprintf(i8* %8, i64 %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %11)
br label %13
13: ; preds = %1, %10
ret i8* %8
}