#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 */
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void ptime(const char *fmt, time_t *t) {
  char stamp[256] = {0};
  time_t tt = time(NULL);
  strftime(stamp, 256, fmt, localtime(t ? t : &tt));
  printf("%s", stamp);
}


x86 assembly (clang, -O0):
<ptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x120(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b9 <ptime+0x69>
mov    -0x10(%rbp),%rax
mov    %rax,-0x130(%rbp)
jmp    11cc <ptime+0x7c>
lea    -0x114(%rbp),%rax
mov    %rax,-0x130(%rbp)
jmp    11cc <ptime+0x7c>
mov    -0x130(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x128(%rbp),%rdi
mov    -0x120(%rbp),%rdx
mov    %eax,%ecx
mov    $0x100,%esi
call   1070 <strftime@plt>
lea    -0x110(%rbp),%rsi
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptime>:
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
test   %rbx,%rbx
lea    0xc(%rsp),%rdi
cmovne %rbx,%rdi
call   1030 <localtime@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1060 <strftime@plt>
lea    0xe08(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @ptime(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [256 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = bitcast [256 x i8]* %5 to i8*
%8 = call i32 @time(i32* null)
store i32 %8, i32* %6
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = load i32*, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i32*, i32** %4
br label %16
15: ; preds = %2
br label %16
16: ; preds = %15, %13
%17 = phi i32* [ %14, %13 ], [ %6, %15 ]
%18 = call i32 @localtime(i32* %17)
%19 = call i32 @strftime(i8* %9, i32 256, i8* %10, i32 %18)
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %20)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @ptime(i8* %0, i32* %1) {
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %4
%8 = icmp eq i32* %1, null
%9 = select i1 %8, i32* %4, i32* %1
%10 = call i32 @localtime(i32* %9)
%11 = call i32 @strftime(i8* %5, i32 256, i8* %0, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
ret void
}