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

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ localtime(int *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int time(int /*<<< orphan*/);
time_t tstamp(time_t last, FILE *f) {
  time_t now;
  char tbuf[80];
  now = time(0);
  strftime(tbuf, 80, (now - last > 600) ? "%c" : "%M:%S", localtime(&now));
  fputs(tbuf, f);
  return now;
}


x86 assembly (clang, -O0):
<tstamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x14(%rbp),%edx
sub    -0x4(%rbp),%edx
lea    0xe92(%rip),%rax
lea    0xe88(%rip),%rcx
cmp    $0x258,%edx
cmovg  %rcx,%rax
mov    %rax,-0x78(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    %eax,%ecx
mov    $0x50,%esi
call   1060 <strftime@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x14(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tstamp>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
sub    %ebp,%eax
cmp    $0x259,%eax
lea    0xe9a(%rip),%rax
lea    0xe96(%rip),%rbp
cmovge %rax,%rbp
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1060 <strftime@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
mov    0xc(%rsp),%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [6 x i8] c"%M:%S\00"
define i32 @tstamp(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [80 x i8]
store i32 %0, i32* %3
store i32* %1, i32** %4
%7 = call i32 @time(i32 0)
store i32 %7, i32* %5
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = sub nsw i32 %9, %10
%12 = icmp sgt i32 %11, 600
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%15 = call i32 @localtime(i32* %5)
%16 = call i32 @strftime(i8* %8, i32 80, i8* %14, i32 %15)
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%18 = load i32*, i32** %4
%19 = call i32 @fputs(i8* %17, i32* %18)
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [6 x i8] c"%M:%S\00"
define i32 @tstamp(i32 %0, i32* nocapture %1) {
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @time(i32 0)
store i32 %7, i32* %3
%8 = sub nsw i32 %7, %0
%9 = icmp sgt i32 %8, 600
%10 = select i1 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%11 = call i32 @localtime(i32* %3)
%12 = call i32 @strftime(i8* %6, i32 80, i8* %10, i32 %11)
%13 = call i32 @fputs(i8* %6, i32* %1)
%14 = load i32, i32* %3
ret i32 %14
}