#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 {
  scalar_t__ tm_sec;
  scalar_t__ tm_min;
  scalar_t__ tm_hour;
  scalar_t__ tm_mday;
  scalar_t__ tm_mon;
  scalar_t__ tm_year;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *timestamp(int tzdelta, int ifmt) {
  static char timebuff[256];
  time_t time_val = (time_t)(0);
  struct tm *tmstruct = (struct tm *)NULL, *localtime();
  int year = 0, hour = 0, ispm = 1, month = 0, day = 0, minute = 0, second = 0;
  int tzadjust();
  int daynumber();
  static char *daynames[] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                             "Friday", "Saturday", "Sunday"};
  static char *monthnames[] = {
      "?",    "January", "February",  "March",   "April",    "May",      "June",
      "July", "August",  "September", "October", "November", "December", "?"};
  *timebuff = '\000';
  time((time_t *)(&time_val));
  tmstruct = localtime((time_t *)(&time_val));
  year = (int)(tmstruct->tm_year);
  month = (int)(tmstruct->tm_mon) + 1;
  day = (int)(tmstruct->tm_mday);
  hour = (int)(tmstruct->tm_hour);
  minute = (int)(tmstruct->tm_min);
  second = (int)(tmstruct->tm_sec);
  year += 1900;
  tzadjust(tzdelta, &year, &month, &day, &hour);
  if (hour < 0 || hour > 23 || day < 1 || day > 31 || month < 1 || month > 12 ||
      year < 1973)
    goto end_of_job;
  switch (ifmt) {
  default:
  case 0:
    if (hour < 12) {
      ispm = 0;
      if (hour == 0)
        hour = 12;
    }
    if (hour > 12)
      hour -= 12;
    break;
  }
  switch (ifmt) {
  default:
  case 0:
    sprintf(timebuff, "%04d-%02d-%02d:%02d:%02d:%02d%s", year, month, day, hour,
            minute, second, ((ispm) ? "pm" : "am"));
    break;
  case 1:
    sprintf(timebuff, "%s, %s %d, %d",
            daynames[daynumber(year, month, day) % 7], monthnames[month], day,
            year);
    break;
  case 2:
    sprintf(timebuff, "%s, %s %d, %d, %d:%02d:%02d%s",
            daynames[daynumber(year, month, day) % 7], monthnames[month], day,
            year, hour, minute, second, ((ispm) ? "pm" : "am"));
    break;
  case 3:
    sprintf(timebuff, "%d:%02d:%02d%s", hour, minute, second,
            ((ispm) ? "pm" : "am"));
    break;
  case 4:
    sprintf(timebuff, "%d%02d%02d%02d%02d", month, day, hour, minute, second);
    break;
  }
end_of_job:
  return (timebuff);
}


x86 assembly (clang, -O0):
<timestamp>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x68,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movb   $0x0,0x2f6a(%rip)
lea    -0x14(%rbp),%rdi
call   1040 <time@plt>
lea    -0x14(%rbp),%rdi
mov    $0x0,%al
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x28(%rax),%rax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%rax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x76c,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x24(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rcx
lea    -0x28(%rbp),%r8
mov    $0x0,%al
call   1060 <tzadjust@plt>
cmpl   $0x0,-0x28(%rbp)
jl     1270 <timestamp+0x120>
cmpl   $0x17,-0x28(%rbp)
jg     1270 <timestamp+0x120>
cmpl   $0x1,-0x34(%rbp)
jl     1270 <timestamp+0x120>
cmpl   $0x1f,-0x34(%rbp)
jg     1270 <timestamp+0x120>
cmpl   $0x1,-0x30(%rbp)
jl     1270 <timestamp+0x120>
cmpl   $0xc,-0x30(%rbp)
jg     1270 <timestamp+0x120>
cmpl   $0x7b5,-0x24(%rbp)
jge    1275 <timestamp+0x125>
jmp    1496 <timestamp+0x346>
mov    -0x10(%rbp),%eax
test   %eax,%eax
je     128a <timestamp+0x13a>
jmp    1285 <timestamp+0x135>
jmp    128a <timestamp+0x13a>
cmpl   $0xc,-0x28(%rbp)
jge    12b1 <timestamp+0x161>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    12ac <timestamp+0x15c>
movl   $0xc,-0x28(%rbp)
jmp    12b1 <timestamp+0x161>
cmpl   $0xc,-0x28(%rbp)
jle    12c4 <timestamp+0x174>
mov    -0x28(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x28(%rbp)
jmp    12c9 <timestamp+0x179>
mov    -0x10(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x4,%rax
ja     12ee <timestamp+0x19e>
mov    -0x48(%rbp),%rax
lea    0xd1b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    12f3 <timestamp+0x1a3>
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x38(%rbp),%r11d
mov    -0x3c(%rbp),%r10d
mov    -0x2c(%rbp),%edi
lea    0xdb5(%rip),%rax
lea    0xdab(%rip),%rsi
cmp    $0x0,%edi
cmovne %rsi,%rax
lea    0x2de8(%rip),%rdi
lea    0xd76(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    1491 <timestamp+0x341>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    $0x0,%al
call   1050 <daynumber@plt>
mov    $0x7,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2ce5(%rip),%rax
mov    (%rax,%rcx,8),%rdx
movslq -0x30(%rbp),%rcx
lea    0x2d16(%rip),%rax
mov    (%rax,%rcx,8),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    0x2d83(%rip),%rdi
lea    0xd37(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    1491 <timestamp+0x341>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    $0x0,%al
call   1050 <daynumber@plt>
mov    $0x7,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2c8e(%rip),%rax
mov    (%rax,%rcx,8),%rdx
movslq -0x30(%rbp),%rcx
lea    0x2cbf(%rip),%rax
mov    (%rax,%rcx,8),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    -0x28(%rbp),%ebx
mov    -0x38(%rbp),%r11d
mov    -0x3c(%rbp),%r10d
mov    -0x2c(%rbp),%edi
lea    0xcd6(%rip),%rax
lea    0xccc(%rip),%rsi
cmp    $0x0,%edi
cmovne %rsi,%rax
lea    0x2d09(%rip),%rdi
lea    0xccb(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    1491 <timestamp+0x341>
mov    -0x28(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x2c(%rbp),%esi
lea    0xc88(%rip),%r9
lea    0xc7e(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r9
lea    0x2cbb(%rip),%rdi
lea    0xc8c(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    1491 <timestamp+0x341>
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%eax
lea    0x2c90(%rip),%rdi
lea    0xc70(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    1496 <timestamp+0x346>
lea    0x2c73(%rip),%rax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestamp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r13d
mov    %edi,%ebp
movl   $0x0,0x14(%rsp)
movb   $0x0,0x2eee(%rip)
lea    0x14(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <time@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <localtime@plt>
mov    0x20(%rax),%ecx
add    $0x1,%ecx
mov    $0x76c,%edx
add    0x28(%rax),%edx
mov    %ecx,0xc(%rsp)
mov    0x18(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    0x10(%rax),%ecx
mov    %ecx,0x4(%rsp)
mov    (%rax),%r12d
mov    0x8(%rax),%r14d
mov    %edx,0x10(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <tzadjust@plt>
mov    0x4(%rsp),%eax
cmp    $0x17,%eax
ja     13de <timestamp+0x28e>
mov    0x8(%rsp),%r8d
test   %r8d,%r8d
jle    13de <timestamp+0x28e>
cmp    $0x1f,%r8d
jg     13de <timestamp+0x28e>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    13de <timestamp+0x28e>
cmp    $0xc,%ecx
jg     13de <timestamp+0x28e>
mov    0x10(%rsp),%edx
cmp    $0x7b5,%edx
jl     13de <timestamp+0x28e>
cmp    $0xb,%eax
ja     123b <timestamp+0xeb>
lea    0xe9d(%rip),%r15
test   %eax,%eax
jne    1254 <timestamp+0x104>
movl   $0xc,0x4(%rsp)
mov    $0xc,%r9d
jmp    1257 <timestamp+0x107>
lea    0xe7f(%rip),%r15
mov    $0xc,%r9d
cmp    $0xc,%eax
je     1257 <timestamp+0x107>
add    $0xfffffff4,%eax
mov    %eax,0x4(%rsp)
mov    %eax,%r9d
add    $0xffffffff,%r13d
cmp    $0x3,%r13d
ja     12e9 <timestamp+0x199>
lea    0xd94(%rip),%rax
movslq (%rax,%r13,4),%rsi
add    %rax,%rsi
jmp    *%rsi
mov    %edx,%edi
mov    %ecx,%esi
mov    %r8d,%edx
xor    %eax,%eax
call   1050 <daynumber@plt>
cltq
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
lea    0x2abf(%rip),%rcx
mov    (%rcx,%rax,8),%rdx
movslq 0xc(%rsp),%rax
lea    0x2aef(%rip),%rcx
mov    (%rcx,%rax,8),%rcx
mov    0x8(%rsp),%r8d
mov    0x10(%rsp),%r9d
lea    0x2d8a(%rip),%rdi
lea    0xdea(%rip),%rsi
xor    %eax,%eax
call   1070 <sprintf@plt>
jmp    13de <timestamp+0x28e>
sub    $0x8,%rsp
lea    0x2d6c(%rip),%rdi
lea    0xda6(%rip),%rsi
xor    %eax,%eax
push   %r15
push   %r12
push   %r14
call   1070 <sprintf@plt>
add    $0x20,%rsp
jmp    13de <timestamp+0x28e>
mov    %edx,%edi
mov    %ecx,%esi
mov    %r8d,%edx
xor    %eax,%eax
call   1050 <daynumber@plt>
cltq
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
lea    0x2a23(%rip),%rcx
mov    (%rcx,%rax,8),%rdx
movslq 0xc(%rsp),%rax
lea    0x2a53(%rip),%rcx
mov    (%rcx,%rax,8),%rcx
mov    0x8(%rsp),%r8d
mov    0x10(%rsp),%r9d
mov    0x4(%rsp),%ebp
lea    0x2cea(%rip),%rdi
lea    0xd58(%rip),%rsi
xor    %eax,%eax
push   %r15
push   %r12
push   %r14
push   %rbp
call   1070 <sprintf@plt>
add    $0x20,%rsp
jmp    13de <timestamp+0x28e>
lea    0x2cc8(%rip),%rdi
lea    0xd45(%rip),%rsi
mov    %r9d,%edx
mov    %r14d,%ecx
mov    %r12d,%r8d
mov    %r15,%r9
xor    %eax,%eax
call   1070 <sprintf@plt>
jmp    13de <timestamp+0x28e>
sub    $0x8,%rsp
lea    0x2ca1(%rip),%rdi
lea    0xd2d(%rip),%rsi
mov    %ecx,%edx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
push   %r12
call   1070 <sprintf@plt>
add    $0x10,%rsp
lea    0x2c7b(%rip),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i64, i64, i64, i64, i64, i64 }
@timestamp.timebuff = internal global [256 x i8] zeroinitializer
@timestamp.daynames = internal global [7 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0)]
@.str = [7 x i8] c"Monday\00"
@.str.1 = [8 x i8] c"Tuesday\00"
@.str.2 = [10 x i8] c"Wednesday\00"
@.str.3 = [9 x i8] c"Thursday\00"
@.str.4 = [7 x i8] c"Friday\00"
@.str.5 = [9 x i8] c"Saturday\00"
@.str.6 = [7 x i8] c"Sunday\00"
@timestamp.monthnames = internal global [14 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0)]
@.str.7 = [2 x i8] c"?\00"
@.str.8 = [8 x i8] c"January\00"
@.str.9 = [9 x i8] c"February\00"
@.str.10 = [6 x i8] c"March\00"
@.str.11 = [6 x i8] c"April\00"
@.str.12 = [4 x i8] c"May\00"
@.str.13 = [5 x i8] c"June\00"
@.str.14 = [5 x i8] c"July\00"
@.str.15 = [7 x i8] c"August\00"
@.str.16 = [10 x i8] c"September\00"
@.str.17 = [8 x i8] c"October\00"
@.str.18 = [9 x i8] c"November\00"
@.str.19 = [9 x i8] c"December\00"
@.str.20 = [32 x i8] c"%04d-%02d-%02d:%02d:%02d:%02d%s\00"
@.str.21 = [3 x i8] c"pm\00"
@.str.22 = [3 x i8] c"am\00"
@.str.23 = [14 x i8] c"%s, %s %d, %d\00"
@.str.24 = [30 x i8] c"%s, %s %d, %d, %d:%02d:%02d%s\00"
@.str.25 = [15 x i8] c"%d:%02d:%02d%s\00"
@.str.26 = [19 x i8] c"%d%02d%02d%02d%02d\00"
define i8* @timestamp(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.tm*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store %struct.tm* null, %struct.tm** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 1, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0)
%14 = call i32 @time(i32* %5)
%15 = call %struct.tm* (i32*, ...) bitcast (%struct.tm* (...)* @localtime to %struct.tm* (i32*, ...)*)(i32* %5)
store %struct.tm* %15, %struct.tm** %6
%16 = load %struct.tm*, %struct.tm** %6
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 5
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
store i32 %19, i32* %7
%20 = load %struct.tm*, %struct.tm** %6
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 4
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = add nsw i32 %23, 1
store i32 %24, i32* %10
%25 = load %struct.tm*, %struct.tm** %6
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 3
%27 = load i64, i64* %26
%28 = trunc i64 %27 to i32
store i32 %28, i32* %11
%29 = load %struct.tm*, %struct.tm** %6
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 2
%31 = load i64, i64* %30
%32 = trunc i64 %31 to i32
store i32 %32, i32* %8
%33 = load %struct.tm*, %struct.tm** %6
%34 = getelementptr inbounds %struct.tm, %struct.tm* %33, i32 0, i32 1
%35 = load i64, i64* %34
%36 = trunc i64 %35 to i32
store i32 %36, i32* %12
%37 = load %struct.tm*, %struct.tm** %6
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 0
%39 = load i64, i64* %38
%40 = trunc i64 %39 to i32
store i32 %40, i32* %13
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1900
store i32 %42, i32* %7
%43 = load i32, i32* %3
%44 = call i32 (i32, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @tzadjust to i32 (i32, i32*, i32*, i32*, i32*, ...)*)(i32 %43, i32* %7, i32* %10, i32* %11, i32* %8)
%45 = load i32, i32* %8
%46 = icmp slt i32 %45, 0
br i1 %46, label %65, label %47
47: ; preds = %2
%48 = load i32, i32* %8
%49 = icmp sgt i32 %48, 23
br i1 %49, label %65, label %50
50: ; preds = %47
%51 = load i32, i32* %11
%52 = icmp slt i32 %51, 1
br i1 %52, label %65, label %53
53: ; preds = %50
%54 = load i32, i32* %11
%55 = icmp sgt i32 %54, 31
br i1 %55, label %65, label %56
56: ; preds = %53
%57 = load i32, i32* %10
%58 = icmp slt i32 %57, 1
br i1 %58, label %65, label %59
59: ; preds = %56
%60 = load i32, i32* %10
%61 = icmp sgt i32 %60, 12
br i1 %61, label %65, label %62
62: ; preds = %59
%63 = load i32, i32* %7
%64 = icmp slt i32 %63, 1973
br i1 %64, label %65, label %66
65: ; preds = %62, %59, %56, %53, %50, %47, %2
br label %155
66: ; preds = %62
%67 = load i32, i32* %4
switch i32 %67, label %68 [
i32 0, label %69
]
68: ; preds = %66
br label %69
69: ; preds = %66, %68
%70 = load i32, i32* %8
%71 = icmp slt i32 %70, 12
br i1 %71, label %72, label %77
72: ; preds = %69
store i32 0, i32* %9
%73 = load i32, i32* %8
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %72
store i32 12, i32* %8
br label %76
76: ; preds = %75, %72
br label %77
77: ; preds = %76, %69
%78 = load i32, i32* %8
%79 = icmp sgt i32 %78, 12
br i1 %79, label %80, label %83
80: ; preds = %77
%81 = load i32, i32* %8
%82 = sub nsw i32 %81, 12
store i32 %82, i32* %8
br label %83
83: ; preds = %80, %77
br label %84
84: ; preds = %83
%85 = load i32, i32* %4
switch i32 %85, label %86 [
i32 0, label %87
i32 1, label %99
i32 2, label %115
i32 3, label %138
i32 4, label %147
]
86: ; preds = %84
br label %87
87: ; preds = %84, %86
%88 = load i32, i32* %7
%89 = load i32, i32* %10
%90 = load i32, i32* %11
%91 = load i32, i32* %8
%92 = load i32, i32* %12
%93 = load i32, i32* %13
%94 = load i32, i32* %9
%95 = icmp ne i32 %94, 0
%96 = zext i1 %95 to i64
%97 = select i1 %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0)
%98 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.20, i64 0, i64 0), i32 %88, i32 %89, i32 %90, i32 %91, i32 %92, i32 %93, i8* %97)
br label %154
99: ; preds = %84
%100 = load i32, i32* %7
%101 = load i32, i32* %10
%102 = load i32, i32* %11
%103 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %100, i32 %101, i32 %102)
%104 = srem i32 %103, 7
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [7 x i8*], [7 x i8*]* @timestamp.daynames, i64 0, i64 %105
%107 = load i8*, i8** %106
%108 = load i32, i32* %10
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [14 x i8*], [14 x i8*]* @timestamp.monthnames, i64 0, i64 %109
%111 = load i8*, i8** %110
%112 = load i32, i32* %11
%113 = load i32, i32* %7
%114 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.23, i64 0, i64 0), i8* %107, i8* %111, i32 %112, i32 %113)
br label %154
115: ; preds = %84
%116 = load i32, i32* %7
%117 = load i32, i32* %10
%118 = load i32, i32* %11
%119 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %116, i32 %117, i32 %118)
%120 = srem i32 %119, 7
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [7 x i8*], [7 x i8*]* @timestamp.daynames, i64 0, i64 %121
%123 = load i8*, i8** %122
%124 = load i32, i32* %10
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [14 x i8*], [14 x i8*]* @timestamp.monthnames, i64 0, i64 %125
%127 = load i8*, i8** %126
%128 = load i32, i32* %11
%129 = load i32, i32* %7
%130 = load i32, i32* %8
%131 = load i32, i32* %12
%132 = load i32, i32* %13
%133 = load i32, i32* %9
%134 = icmp ne i32 %133, 0
%135 = zext i1 %134 to i64
%136 = select i1 %134, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0)
%137 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0), i8* %123, i8* %127, i32 %128, i32 %129, i32 %130, i32 %131, i32 %132, i8* %136)
br label %154
138: ; preds = %84
%139 = load i32, i32* %8
%140 = load i32, i32* %12
%141 = load i32, i32* %13
%142 = load i32, i32* %9
%143 = icmp ne i32 %142, 0
%144 = zext i1 %143 to i64
%145 = select i1 %143, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0)
%146 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.25, i64 0, i64 0), i32 %139, i32 %140, i32 %141, i8* %145)
br label %154
147: ; preds = %84
%148 = load i32, i32* %10
%149 = load i32, i32* %11
%150 = load i32, i32* %8
%151 = load i32, i32* %12
%152 = load i32, i32* %13
%153 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.26, i64 0, i64 0), i32 %148, i32 %149, i32 %150, i32 %151, i32 %152)
br label %154
154: ; preds = %147, %138, %115, %99, %87
br label %155
155: ; preds = %154, %65
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i64, i64, i64, i64, i64, i64 }
@timestamp.timebuff = internal global [256 x i8] zeroinitializer
@timestamp.daynames = internal unnamed_addr constant [7 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0)]
@.str = [7 x i8] c"Monday\00"
@.str.1 = [8 x i8] c"Tuesday\00"
@.str.2 = [10 x i8] c"Wednesday\00"
@.str.3 = [9 x i8] c"Thursday\00"
@.str.4 = [7 x i8] c"Friday\00"
@.str.5 = [9 x i8] c"Saturday\00"
@.str.6 = [7 x i8] c"Sunday\00"
@timestamp.monthnames = internal unnamed_addr constant [14 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0)]
@.str.7 = [2 x i8] c"?\00"
@.str.8 = [8 x i8] c"January\00"
@.str.9 = [9 x i8] c"February\00"
@.str.10 = [6 x i8] c"March\00"
@.str.11 = [6 x i8] c"April\00"
@.str.12 = [4 x i8] c"May\00"
@.str.13 = [5 x i8] c"June\00"
@.str.14 = [5 x i8] c"July\00"
@.str.15 = [7 x i8] c"August\00"
@.str.16 = [10 x i8] c"September\00"
@.str.17 = [8 x i8] c"October\00"
@.str.18 = [9 x i8] c"November\00"
@.str.19 = [9 x i8] c"December\00"
@.str.20 = [32 x i8] c"%04d-%02d-%02d:%02d:%02d:%02d%s\00"
@.str.21 = [3 x i8] c"pm\00"
@.str.22 = [3 x i8] c"am\00"
@.str.23 = [14 x i8] c"%s, %s %d, %d\00"
@.str.24 = [30 x i8] c"%s, %s %d, %d, %d:%02d:%02d%s\00"
@.str.25 = [15 x i8] c"%d:%02d:%02d%s\00"
@.str.26 = [19 x i8] c"%d%02d%02d%02d%02d\00"
define i8* @timestamp(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0)
%13 = call i32 @time(i32* %3)
%14 = call %struct.tm* (i32*, ...) bitcast (%struct.tm* (...)* @localtime to %struct.tm* (i32*, ...)*)(i32* %3)
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 5
%16 = load i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 4
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
%22 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 3
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %7
%25 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 2
%26 = load i64, i64* %25
%27 = trunc i64 %26 to i32
store i32 %27, i32* %5
%28 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 1
%29 = load i64, i64* %28
%30 = trunc i64 %29 to i32
%31 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 0
%32 = load i64, i64* %31
%33 = trunc i64 %32 to i32
%34 = add nsw i32 %17, 1900
store i32 %34, i32* %4
%35 = call i32 (i32, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @tzadjust to i32 (i32, i32*, i32*, i32*, i32*, ...)*)(i32 %0, i32* %4, i32* %6, i32* %7, i32* %5)
%36 = load i32, i32* %5
%37 = icmp ugt i32 %36, 23
%38 = load i32, i32* %7
%39 = icmp slt i32 %38, 1
%40 = select i1 %37, i1 true, i1 %39
%41 = icmp sgt i32 %38, 31
%42 = select i1 %40, i1 true, i1 %41
%43 = load i32, i32* %6
%44 = icmp slt i32 %43, 1
%45 = select i1 %42, i1 true, i1 %44
%46 = icmp sgt i32 %43, 12
%47 = select i1 %45, i1 true, i1 %46
%48 = load i32, i32* %4
%49 = icmp slt i32 %48, 1973
%50 = select i1 %47, i1 true, i1 %49
br i1 %50, label %96, label %51
51: ; preds = %2
%52 = icmp ult i32 %36, 12
br i1 %52, label %53, label %56
53: ; preds = %51
%54 = icmp eq i32 %36, 0
br i1 %54, label %55, label %60
55: ; preds = %53
store i32 12, i32* %5
br label %60
56: ; preds = %51
%57 = icmp eq i32 %36, 12
br i1 %57, label %60, label %58
58: ; preds = %56
%59 = add nsw i32 %36, -12
store i32 %59, i32* %5
br label %60
60: ; preds = %53, %55, %56, %58
%61 = phi i32 [ 12, %55 ], [ 12, %56 ], [ %59, %58 ], [ %36, %53 ]
%62 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), %55 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), %56 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), %58 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), %53 ]
switch i32 %1, label %63 [
i32 4, label %94
i32 1, label %65
i32 2, label %78
i32 3, label %92
]
63: ; preds = %60
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.20, i64 0, i64 0), i32 %48, i32 %43, i32 %38, i32 %61, i32 %30, i32 %33, i8* %62)
br label %96
65: ; preds = %60
%66 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %48, i32 %43, i32 %38)
%67 = srem i32 %66, 7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [7 x i8*], [7 x i8*]* @timestamp.daynames, i64 0, i64 %68
%70 = load i8*, i8** %69
%71 = load i32, i32* %6
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [14 x i8*], [14 x i8*]* @timestamp.monthnames, i64 0, i64 %72
%74 = load i8*, i8** %73
%75 = load i32, i32* %7
%76 = load i32, i32* %4
%77 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.23, i64 0, i64 0), i8* %70, i8* %74, i32 %75, i32 %76)
br label %96
78: ; preds = %60
%79 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %48, i32 %43, i32 %38)
%80 = srem i32 %79, 7
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [7 x i8*], [7 x i8*]* @timestamp.daynames, i64 0, i64 %81
%83 = load i8*, i8** %82
%84 = load i32, i32* %6
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [14 x i8*], [14 x i8*]* @timestamp.monthnames, i64 0, i64 %85
%87 = load i8*, i8** %86
%88 = load i32, i32* %7
%89 = load i32, i32* %4
%90 = load i32, i32* %5
%91 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0), i8* %83, i8* %87, i32 %88, i32 %89, i32 %90, i32 %30, i32 %33, i8* %62)
br label %96
92: ; preds = %60
%93 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.25, i64 0, i64 0), i32 %61, i32 %30, i32 %33, i8* %62)
br label %96
94: ; preds = %60
%95 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.26, i64 0, i64 0), i32 %43, i32 %38, i32 %61, i32 %30, i32 %33)
br label %96
96: ; preds = %63, %65, %78, %92, %94, %2
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0)
}