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

/* Variables and functions */
char *ctime(scalar_t__ const *);
int /*<<< orphan*/ snprintf(char *, int, char *, long long);
char *cdf_ctime(const time_t *sec) {
  static char ctbuf[26];
  char *ptr = ctime(sec);
  if (ptr != NULL)
    return ptr;
  (void)snprintf(ctbuf, sizeof(ctbuf), "*Bad* 0x%16.16llx\n", (long long)*sec);
  return ctbuf;
}


x86 assembly (clang, -O0):
<cdf_ctime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1151 <cdf_ctime+0x31>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117b <cdf_ctime+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0x2ee1(%rip),%rdi
mov    $0x1a,%esi
lea    0xe95(%rip),%rdx
call   1040 <snprintf@plt>
lea    0x2ec9(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdf_ctime>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <ctime@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1152 <cdf_ctime+0x32>
mov    (%r14),%rcx
lea    0x2f02(%rip),%rbx
lea    0xebb(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1a,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@cdf_ctime.ctbuf = internal global [26 x i8] zeroinitializer
@.str = [19 x i8] c"*Bad* 0x%16.16llx\0A\00"
define i8* @cdf_ctime(i64* %0) {
%2 = alloca i8*
%3 = alloca i64*
%4 = alloca i8*
store i64* %0, i64** %3
%5 = load i64*, i64** %3
%6 = call i8* @ctime(i64* %5)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i8*, i8** %4
store i8* %10, i8** %2
br label %15
11: ; preds = %1
%12 = load i64*, i64** %3
%13 = load i64, i64* %12
%14 = call i32 @snprintf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @cdf_ctime.ctbuf, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %13)
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @cdf_ctime.ctbuf, i64 0, i64 0), i8** %2
br label %15
15: ; preds = %11, %9
%16 = load i8*, i8** %2
ret i8* %16
}

LLVM IR (-O2):
@cdf_ctime.ctbuf = internal global [26 x i8] zeroinitializer
@.str = [19 x i8] c"*Bad* 0x%16.16llx\0A\00"
define i8* @cdf_ctime(i64* %0) {
%2 = tail call i8* @ctime(i64* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i64, i64* %0
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @cdf_ctime.ctbuf, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %5)
br label %7
7: ; preds = %1, %4
%8 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @cdf_ctime.ctbuf, i64 0, i64 0), %4 ], [ %2, %1 ]
ret i8* %8
}