#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;
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ strftime(char *, size_t, char const *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *__setup_tempfile(char *fname, size_t size, const char *dir,
                       const char *pat) {
  time_t t;
  struct tm tm;
  time(&t);
  if (!fname || size == 0) {
    return NULL;
  }
  localtime_r(&t, &tm);
  strftime(fname, size, pat, &tm);
  return fname;
}


x86 assembly (clang, -O0):
<__setup_tempfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x2c(%rbp),%rdi
call   1040 <time@plt>
cmpq   $0x0,-0x10(%rbp)
je     1167 <__setup_tempfile+0x37>
cmpq   $0x0,-0x18(%rbp)
jne    1174 <__setup_tempfile+0x44>
movq   $0x0,-0x8(%rbp)
jmp    119e <__setup_tempfile+0x6e>
lea    -0x2c(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1050 <strftime@plt>
mov    -0x10(%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   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xc(%rsp),%rdi
call   1040 <time@plt>
xor    %eax,%eax
test   %rbx,%rbx
je     1180 <__setup_tempfile+0x50>
test   %r15,%r15
je     1180 <__setup_tempfile+0x50>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%r12
mov    %r12,%rsi
call   1030 <localtime_r@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
call   1050 <strftime@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i8* @__setup_tempfile(i8* %0, i64 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca %struct.tm
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%12 = call i32 @time(i32* %10)
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %4
%16 = load i64, i64* %7
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15, %4
store i8* null, i8** %5
br label %26
19: ; preds = %15
%20 = call i32 @localtime_r(i32* %10, %struct.tm* %11)
%21 = load i8*, i8** %6
%22 = load i64, i64* %7
%23 = load i8*, i8** %9
%24 = call i32 @strftime(i8* %21, i64 %22, i8* %23, %struct.tm* %11)
%25 = load i8*, i8** %6
store i8* %25, i8** %5
br label %26
26: ; preds = %19, %18
%27 = load i8*, i8** %5
ret i8* %27
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i8* @__setup_tempfile(i8* %0, i64 %1, i8* nocapture readnone %2, i8* %3) {
%5 = alloca i32
%6 = alloca %struct.tm
%7 = bitcast i32* %5 to i8*
%8 = bitcast %struct.tm* %6 to i8*
%9 = call i32 @time(i32* %5)
%10 = icmp eq i8* %0, null
%11 = icmp eq i64 %1, 0
%12 = or i1 %10, %11
br i1 %12, label %16, label %13
13: ; preds = %4
%14 = call i32 @localtime_r(i32* %5, %struct.tm* %6)
%15 = call i32 @strftime(i8* %0, i64 %1, i8* %3, %struct.tm* %6)
br label %16
16: ; preds = %4, %13
%17 = phi i8* [ %0, %13 ], [ null, %4 ]
ret i8* %17
}