#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*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ do_indent(int);
int /*<<< orphan*/ localtime(int *);
int /*<<< orphan*/ printf(char *, char *, char *, ...);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int time(int /*<<< orphan*/ *);
void print_timestamp(int timestamp, char *leader, int indent, int monochrome) {
  char buffer[32];
  time_t now, timestamp2;
  long diff, days_ago, days_ahead;
  now = time(NULL);
  diff = now - timestamp;
  days_ago = (diff + ((diff > 0) ? 43200 : -43200)) / 86400;
  timestamp2 = (time_t)timestamp;
  strftime(buffer, sizeof(buffer), "%a %d %b %Y %H:%M", localtime(&timestamp2));
  do_indent(indent + 2);
  if (days_ago < 0) {
    days_ahead = -days_ago;
    if (monochrome) {
      printf("%s: %s (%ld day%s ahead)\n", leader, buffer, days_ago,
             (days_ahead == 1) ? "" : "s");
    } else {
      printf("%s%s:%s %s %s(%ld day%s ahead)%s\n", "[32m", leader, "[0m",
             buffer, "[35m", days_ahead, (days_ahead == 1) ? "" : "s", "[0m");
    }
  } else {
    if (monochrome) {
      printf("%s: %s (%ld day%s ago)\n", leader, buffer, days_ago,
             (days_ago == 1) ? "" : "s");
    } else {
      printf("%s%s:%s %s (%ld day%s ago)\n", "[32m", leader, "[0m", buffer,
             days_ago, (days_ago == 1) ? "" : "s");
    }
  }
}


x86 assembly (clang, -O0):
<print_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
sub    -0x4(%rbp),%eax
cltq
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x50(%rbp),%rsi
mov    $0xffff5740,%ecx
mov    $0xa8c0,%edx
cmp    $0x0,%rsi
cmovg  %edx,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rax,-0x58(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x48(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x48(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%ecx
mov    $0x20,%esi
lea    0xe2a(%rip),%rdx
call   1060 <strftime@plt>
mov    -0x14(%rbp),%edi
add    $0x2,%edi
call   1070 <do_indent@plt>
cmpq   $0x0,-0x58(%rbp)
jge    129d <print_timestamp+0x14d>
xor    %eax,%eax
sub    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     123e <print_timestamp+0xee>
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    -0x60(%rbp),%rdi
lea    0xe10(%rip),%r8
lea    0xe08(%rip),%rax
cmp    $0x1,%rdi
cmove  %rax,%r8
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1298 <print_timestamp+0x148>
mov    -0x10(%rbp),%rdx
lea    -0x40(%rbp),%r8
mov    -0x60(%rbp),%r11
mov    -0x60(%rbp),%rcx
lea    0xdd7(%rip),%r10
lea    0xdcf(%rip),%rax
cmp    $0x1,%rcx
cmove  %rax,%r10
lea    0xdc3(%rip),%rdi
lea    0xdde(%rip),%rsi
lea    0xddd(%rip),%rax
lea    0xddb(%rip),%r9
mov    %rax,%rcx
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
jmp    132b <print_timestamp+0x1db>
cmpl   $0x0,-0x18(%rbp)
je     12e0 <print_timestamp+0x190>
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    -0x58(%rbp),%rdi
lea    0xd6e(%rip),%r8
lea    0xd66(%rip),%rax
cmp    $0x1,%rdi
cmove  %rax,%r8
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1326 <print_timestamp+0x1d6>
mov    -0x10(%rbp),%rdx
lea    -0x40(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    -0x58(%rbp),%rsi
lea    0xd35(%rip),%rax
lea    0xd2d(%rip),%rcx
cmp    $0x1,%rsi
cmove  %rcx,%rax
lea    0xd6c(%rip),%rdi
lea    0xd3c(%rip),%rsi
lea    0xd3b(%rip),%rcx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
jmp    132b <print_timestamp+0x1db>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_timestamp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%r15d
mov    %edx,%r13d
mov    %rsi,%r14
mov    %edi,%ebx
xor    %edi,%edi
call   1050 <time@plt>
sub    %ebx,%eax
cltq
lea    -0xa8c0(%rax),%rbp
lea    0xa8c0(%rax),%rcx
test   %eax,%eax
cmovg  %rcx,%rbp
movabs $0x1845c8a0ce512957,%rcx
c8 45 18
mov    %rbp,%rax
imul   %rcx
mov    %rdx,%r12
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xd,%r12
add    %rax,%r12
mov    %ebx,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe42(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
add    $0x2,%r13d
mov    %r13d,%edi
call   1070 <do_indent@plt>
cmp    $0xfffffffffffeae80,%rbp
jg     121d <print_timestamp+0xcd>
test   %r15d,%r15d
je     1263 <print_timestamp+0x113>
add    $0x2a2ff,%rbp
cmp    $0x15180,%rbp
lea    0xe2d(%rip),%rax
lea    0xe27(%rip),%r8
cmovb  %rax,%r8
lea    0xe02(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %r14,%rsi
mov    %r12,%rcx
jmp    1257 <print_timestamp+0x107>
add    $0xfffffffffffeae80,%rbp
cmp    $0x15180,%rbp
lea    0xdf9(%rip),%rax
lea    0xdf3(%rip),%rbp
cmovb  %rax,%rbp
test   %r15d,%r15d
je     12bf <print_timestamp+0x16f>
lea    0xe18(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %r14,%rsi
mov    %r12,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12ef <print_timestamp+0x19f>
neg    %r12
add    $0x2a2ff,%rbp
cmp    $0x15180,%rbp
lea    0xdb0(%rip),%rax
lea    0xdaa(%rip),%rbp
cmovb  %rax,%rbp
sub    $0x8,%rsp
lea    0xdc5(%rip),%rcx
lea    0xd96(%rip),%rdi
lea    0xdb1(%rip),%rsi
lea    0xdb5(%rip),%r9
lea    0x18(%rsp),%r8
mov    %r14,%rdx
xor    %eax,%eax
push   %rcx
push   %rbp
push   %r12
call   1040 <printf@plt>
add    $0x20,%rsp
jmp    12ef <print_timestamp+0x19f>
sub    $0x8,%rsp
lea    0xdaf(%rip),%rdi
lea    0xd7f(%rip),%rsi
lea    0xd7e(%rip),%rcx
lea    0x18(%rsp),%r8
mov    %r14,%rdx
mov    %r12,%r9
xor    %eax,%eax
push   %rbp
call   1040 <printf@plt>
add    $0x10,%rsp
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%a %d %b %Y %H:%M\00"
@.str.1 = [26 x i8] c"%s: %s (%ld day%s ahead)\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"s\00"
@.str.4 = [34 x i8] c"%s%s:%s %s %s(%ld day%s ahead)%s\0A\00"
@.str.5 = [6 x i8] c"\1B[32m\00"
@.str.6 = [5 x i8] c"\1B[0m\00"
@.str.7 = [6 x i8] c"\1B[35m\00"
@.str.8 = [24 x i8] c"%s: %s (%ld day%s ago)\0A\00"
@.str.9 = [28 x i8] c"%s%s:%s %s (%ld day%s ago)\0A\00"
define void @print_timestamp(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [32 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%15 = call i32 @time(i32* null)
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = load i32, i32* %5
%18 = sub nsw i32 %16, %17
%19 = sext i32 %18 to i64
store i64 %19, i64* %12
%20 = load i64, i64* %12
%21 = load i64, i64* %12
%22 = icmp sgt i64 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 43200, i32 -43200
%25 = sext i32 %24 to i64
%26 = add nsw i64 %20, %25
%27 = sdiv i64 %26, 86400
store i64 %27, i64* %13
%28 = load i32, i32* %5
store i32 %28, i32* %11
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%30 = call i32 @localtime(i32* %11)
%31 = call i32 @strftime(i8* %29, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 2
%34 = call i32 @do_indent(i32 %33)
%35 = load i64, i64* %13
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %61
37: ; preds = %4
%38 = load i64, i64* %13
%39 = sub nsw i64 0, %38
store i64 %39, i64* %14
%40 = load i32, i32* %8
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %51
42: ; preds = %37
%43 = load i8*, i8** %6
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%45 = load i64, i64* %13
%46 = load i64, i64* %14
%47 = icmp eq i64 %46, 1
%48 = zext i1 %47 to i64
%49 = select i1 %47, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%50 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %43, i8* %44, i64 %45, i8* %49)
br label %60
51: ; preds = %37
%52 = load i8*, i8** %6
%53 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%54 = load i64, i64* %14
%55 = load i64, i64* %14
%56 = icmp eq i64 %55, 1
%57 = zext i1 %56 to i64
%58 = select i1 %56, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%59 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i64 %54, i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %60
60: ; preds = %51, %42
br label %83
61: ; preds = %4
%62 = load i32, i32* %8
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %73
64: ; preds = %61
%65 = load i8*, i8** %6
%66 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%67 = load i64, i64* %13
%68 = load i64, i64* %13
%69 = icmp eq i64 %68, 1
%70 = zext i1 %69 to i64
%71 = select i1 %69, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%72 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %65, i8* %66, i64 %67, i8* %71)
br label %82
73: ; preds = %61
%74 = load i8*, i8** %6
%75 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%76 = load i64, i64* %13
%77 = load i64, i64* %13
%78 = icmp eq i64 %77, 1
%79 = zext i1 %78 to i64
%80 = select i1 %78, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%81 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %75, i64 %76, i8* %80)
br label %82
82: ; preds = %73, %64
br label %83
83: ; preds = %82, %60
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%a %d %b %Y %H:%M\00"
@.str.1 = [26 x i8] c"%s: %s (%ld day%s ahead)\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"s\00"
@.str.4 = [34 x i8] c"%s%s:%s %s %s(%ld day%s ahead)%s\0A\00"
@.str.5 = [6 x i8] c"\1B[32m\00"
@.str.6 = [5 x i8] c"\1B[0m\00"
@.str.7 = [6 x i8] c"\1B[35m\00"
@.str.8 = [24 x i8] c"%s: %s (%ld day%s ago)\0A\00"
@.str.9 = [28 x i8] c"%s%s:%s %s (%ld day%s ago)\0A\00"
define void @print_timestamp(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca [32 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%8 = bitcast i32* %6 to i8*
%9 = tail call i32 @time(i32* null)
%10 = sub nsw i32 %9, %0
%11 = sext i32 %10 to i64
%12 = icmp sgt i32 %10, 0
%13 = select i1 %12, i64 43200, i64 -43200
%14 = add nsw i64 %13, %11
%15 = sdiv i64 %14, 86400
store i32 %0, i32* %6
%16 = call i32 @localtime(i32* %6)
%17 = call i32 @strftime(i8* %7, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = add nsw i32 %2, 2
%19 = call i32 @do_indent(i32 %18)
%20 = icmp slt i64 %14, -86399
%21 = icmp eq i32 %3, 0
br i1 %20, label %22, label %34
22: ; preds = %4
br i1 %21, label %28, label %23
23: ; preds = %22
%24 = add nsw i64 %14, 172799
%25 = icmp ult i64 %24, 86400
%26 = select i1 %25, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%27 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %7, i64 %15, i8* %26)
br label %42
28: ; preds = %22
%29 = sub nsw i64 0, %15
%30 = add nsw i64 %14, 172799
%31 = icmp ult i64 %30, 86400
%32 = select i1 %31, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%33 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i64 %29, i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %42
34: ; preds = %4
%35 = add nsw i64 %14, -86400
%36 = icmp ult i64 %35, 86400
%37 = select i1 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
br i1 %21, label %40, label %38
38: ; preds = %34
%39 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %1, i8* %7, i64 %15, i8* %37)
br label %42
40: ; preds = %34
%41 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %7, i64 %15, i8* %37)
br label %42
42: ; preds = %38, %40, %23, %28
ret void
}