#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;
  case 4:
    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;
  case 5:
    sprintf(timebuff, "%d", year);
    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    14cc <timestamp+0x37c>
mov    -0x10(%rbp),%eax
mov    %eax,-0x40(%rbp)
test   %eax,%eax
je     129e <timestamp+0x14e>
jmp    1288 <timestamp+0x138>
mov    -0x40(%rbp),%eax
sub    $0x4,%eax
je     12dd <timestamp+0x18d>
jmp    1299 <timestamp+0x149>
jmp    129e <timestamp+0x14e>
cmpl   $0xc,-0x28(%rbp)
jge    12c5 <timestamp+0x175>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    12c0 <timestamp+0x170>
movl   $0xc,-0x28(%rbp)
jmp    12c5 <timestamp+0x175>
cmpl   $0xc,-0x28(%rbp)
jle    12d8 <timestamp+0x188>
mov    -0x28(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x28(%rbp)
jmp    12e2 <timestamp+0x192>
jmp    12e2 <timestamp+0x192>
mov    -0x10(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x5,%rax
ja     1307 <timestamp+0x1b7>
mov    -0x48(%rbp),%rax
lea    0xd02(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    130c <timestamp+0x1bc>
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    0xda0(%rip),%rax
lea    0xd96(%rip),%rsi
cmp    $0x0,%edi
cmovne %rsi,%rax
lea    0x2dcf(%rip),%rdi
lea    0xd61(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    14c7 <timestamp+0x377>
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    0x2ccc(%rip),%rax
mov    (%rax,%rcx,8),%rdx
movslq -0x30(%rbp),%rcx
lea    0x2cfd(%rip),%rax
mov    (%rax,%rcx,8),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    0x2d6a(%rip),%rdi
lea    0xd22(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    14c7 <timestamp+0x377>
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    0x2c75(%rip),%rax
mov    (%rax,%rcx,8),%rdx
movslq -0x30(%rbp),%rcx
lea    0x2ca6(%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    0xcc1(%rip),%rax
lea    0xcb7(%rip),%rsi
cmp    $0x0,%edi
cmovne %rsi,%rax
lea    0x2cf0(%rip),%rdi
lea    0xcb6(%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    14c7 <timestamp+0x377>
mov    -0x28(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x2c(%rbp),%esi
lea    0xc73(%rip),%r9
lea    0xc69(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r9
lea    0x2ca2(%rip),%rdi
lea    0xc77(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    14c7 <timestamp+0x377>
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%eax
lea    0x2c77(%rip),%rdi
lea    0xc5b(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    14c7 <timestamp+0x377>
mov    -0x24(%rbp),%edx
lea    0x2c57(%rip),%rdi
lea    0xc1a(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    14cc <timestamp+0x37c>
lea    0x2c3d(%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),%r15d
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),%r8d
cmp    $0x17,%r8d
ja     122e <timestamp+0xde>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    122e <timestamp+0xde>
cmp    $0x1f,%eax
jg     122e <timestamp+0xde>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    122e <timestamp+0xde>
cmp    $0xc,%ecx
jg     122e <timestamp+0xde>
mov    0x10(%rsp),%edx
cmp    $0x7b5,%edx
jl     122e <timestamp+0xde>
cmp    $0x4,%r13d
jne    1244 <timestamp+0xf4>
sub    $0x8,%rsp
lea    0x2e4d(%rip),%rdi
lea    0xedd(%rip),%rsi
mov    %ecx,%edx
mov    %eax,%ecx
mov    %r14d,%r9d
xor    %eax,%eax
push   %r15
call   1070 <sprintf@plt>
add    $0x10,%rsp
lea    0x2e2b(%rip),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0xb,%r8d
ja     1266 <timestamp+0x116>
lea    0xe77(%rip),%r12
test   %r8d,%r8d
jne    1282 <timestamp+0x132>
movl   $0xc,0x4(%rsp)
mov    $0xc,%r9d
jmp    1285 <timestamp+0x135>
lea    0xe58(%rip),%r12
mov    $0xc,%r9d
cmp    $0xc,%r8d
je     1285 <timestamp+0x135>
add    $0xfffffff4,%r8d
mov    %r8d,0x4(%rsp)
mov    %r8d,%r9d
add    $0xffffffff,%r13d
cmp    $0x4,%r13d
ja     13be <timestamp+0x26e>
lea    0xd66(%rip),%rsi
movslq (%rsi,%r13,4),%rdi
add    %rsi,%rdi
jmp    *%rdi
mov    %edx,%edi
mov    %ecx,%esi
mov    %eax,%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    0x2a92(%rip),%rcx
mov    (%rcx,%rax,8),%rdx
movslq 0xc(%rsp),%rax
lea    0x2ac2(%rip),%rcx
mov    (%rcx,%rax,8),%rcx
mov    0x8(%rsp),%r8d
mov    0x10(%rsp),%r9d
lea    0x2d5d(%rip),%rdi
lea    0xdc1(%rip),%rsi
xor    %eax,%eax
call   1070 <sprintf@plt>
jmp    122e <timestamp+0xde>
mov    %edx,%edi
mov    %ecx,%esi
mov    %eax,%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    0x2a1f(%rip),%rcx
mov    (%rcx,%rax,8),%rdx
movslq 0xc(%rsp),%rax
lea    0x2a4f(%rip),%rcx
mov    (%rcx,%rax,8),%rcx
mov    0x8(%rsp),%r8d
mov    0x10(%rsp),%r9d
mov    0x4(%rsp),%ebp
lea    0x2ce6(%rip),%rdi
lea    0xd58(%rip),%rsi
xor    %eax,%eax
push   %r12
push   %r15
push   %r14
push   %rbp
call   1070 <sprintf@plt>
add    $0x20,%rsp
jmp    122e <timestamp+0xde>
lea    0x2cc1(%rip),%rdi
lea    0xd42(%rip),%rsi
mov    %r9d,%edx
mov    %r14d,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
xor    %eax,%eax
call   1070 <sprintf@plt>
jmp    122e <timestamp+0xde>
sub    $0x8,%rsp
lea    0x2c97(%rip),%rdi
lea    0xcd5(%rip),%rsi
mov    %eax,%r8d
xor    %eax,%eax
push   %r12
push   %r15
push   %r14
call   1070 <sprintf@plt>
add    $0x20,%rsp
jmp    122e <timestamp+0xde>
lea    0x2c70(%rip),%rdi
lea    0xcdf(%rip),%rsi
xor    %eax,%eax
call   1070 <sprintf@plt>
jmp    122e <timestamp+0xde>

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"
@.str.27 = [3 x i8] c"%d\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 %159
66: ; preds = %62
%67 = load i32, i32* %4
switch i32 %67, label %68 [
i32 0, label %69
i32 4, label %84
]
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 %85
84: ; preds = %66
br label %85
85: ; preds = %84, %83
%86 = load i32, i32* %4
switch i32 %86, label %87 [
i32 0, label %88
i32 1, label %100
i32 2, label %116
i32 3, label %139
i32 4, label %148
i32 5, label %155
]
87: ; preds = %85
br label %88
88: ; preds = %85, %87
%89 = load i32, i32* %7
%90 = load i32, i32* %10
%91 = load i32, i32* %11
%92 = load i32, i32* %8
%93 = load i32, i32* %12
%94 = load i32, i32* %13
%95 = load i32, i32* %9
%96 = icmp ne i32 %95, 0
%97 = zext i1 %96 to i64
%98 = select i1 %96, 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)
%99 = 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 %89, i32 %90, i32 %91, i32 %92, i32 %93, i32 %94, i8* %98)
br label %158
100: ; preds = %85
%101 = load i32, i32* %7
%102 = load i32, i32* %10
%103 = load i32, i32* %11
%104 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %101, i32 %102, i32 %103)
%105 = srem i32 %104, 7
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [7 x i8*], [7 x i8*]* @timestamp.daynames, i64 0, i64 %106
%108 = load i8*, i8** %107
%109 = load i32, i32* %10
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [14 x i8*], [14 x i8*]* @timestamp.monthnames, i64 0, i64 %110
%112 = load i8*, i8** %111
%113 = load i32, i32* %11
%114 = load i32, i32* %7
%115 = 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* %108, i8* %112, i32 %113, i32 %114)
br label %158
116: ; preds = %85
%117 = load i32, i32* %7
%118 = load i32, i32* %10
%119 = load i32, i32* %11
%120 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %117, i32 %118, i32 %119)
%121 = srem i32 %120, 7
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [7 x i8*], [7 x i8*]* @timestamp.daynames, i64 0, i64 %122
%124 = load i8*, i8** %123
%125 = load i32, i32* %10
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [14 x i8*], [14 x i8*]* @timestamp.monthnames, i64 0, i64 %126
%128 = load i8*, i8** %127
%129 = load i32, i32* %11
%130 = load i32, i32* %7
%131 = load i32, i32* %8
%132 = load i32, i32* %12
%133 = load i32, i32* %13
%134 = load i32, i32* %9
%135 = icmp ne i32 %134, 0
%136 = zext i1 %135 to i64
%137 = select i1 %135, 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)
%138 = 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* %124, i8* %128, i32 %129, i32 %130, i32 %131, i32 %132, i32 %133, i8* %137)
br label %158
139: ; preds = %85
%140 = load i32, i32* %8
%141 = load i32, i32* %12
%142 = load i32, i32* %13
%143 = load i32, i32* %9
%144 = icmp ne i32 %143, 0
%145 = zext i1 %144 to i64
%146 = select i1 %144, 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)
%147 = 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 %140, i32 %141, i32 %142, i8* %146)
br label %158
148: ; preds = %85
%149 = load i32, i32* %10
%150 = load i32, i32* %11
%151 = load i32, i32* %8
%152 = load i32, i32* %12
%153 = load i32, i32* %13
%154 = 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 %149, i32 %150, i32 %151, i32 %152, i32 %153)
br label %158
155: ; preds = %85
%156 = load i32, i32* %7
%157 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0), i32 %156)
br label %158
158: ; preds = %155, %148, %139, %116, %100, %88
br label %159
159: ; preds = %158, %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"
@.str.27 = [3 x i8] c"%d\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 %100, label %51
51: ; preds = %2
%52 = icmp eq i32 %1, 4
br i1 %52, label %96, label %53
53: ; preds = %51
%54 = icmp ult i32 %36, 12
br i1 %54, label %55, label %58
55: ; preds = %53
%56 = icmp eq i32 %36, 0
br i1 %56, label %57, label %62
57: ; preds = %55
store i32 12, i32* %5
br label %62
58: ; preds = %53
%59 = icmp eq i32 %36, 12
br i1 %59, label %62, label %60
60: ; preds = %58
%61 = add nsw i32 %36, -12
store i32 %61, i32* %5
br label %62
62: ; preds = %55, %57, %58, %60
%63 = phi i32 [ %61, %60 ], [ 12, %58 ], [ 12, %57 ], [ %36, %55 ]
%64 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), %60 ], [ 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), %57 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), %55 ]
switch i32 %1, label %65 [
i32 5, label %98
i32 1, label %67
i32 2, label %80
i32 3, label %94
]
65: ; preds = %62
%66 = 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 %63, i32 %30, i32 %33, i8* %64)
br label %100
67: ; preds = %62
%68 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %48, i32 %43, i32 %38)
%69 = srem i32 %68, 7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [7 x i8*], [7 x i8*]* @timestamp.daynames, i64 0, i64 %70
%72 = load i8*, i8** %71
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [14 x i8*], [14 x i8*]* @timestamp.monthnames, i64 0, i64 %74
%76 = load i8*, i8** %75
%77 = load i32, i32* %7
%78 = load i32, i32* %4
%79 = 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* %72, i8* %76, i32 %77, i32 %78)
br label %100
80: ; preds = %62
%81 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %48, i32 %43, i32 %38)
%82 = srem i32 %81, 7
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [7 x i8*], [7 x i8*]* @timestamp.daynames, i64 0, i64 %83
%85 = load i8*, i8** %84
%86 = load i32, i32* %6
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [14 x i8*], [14 x i8*]* @timestamp.monthnames, i64 0, i64 %87
%89 = load i8*, i8** %88
%90 = load i32, i32* %7
%91 = load i32, i32* %4
%92 = load i32, i32* %5
%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 ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0), i8* %85, i8* %89, i32 %90, i32 %91, i32 %92, i32 %30, i32 %33, i8* %64)
br label %100
94: ; preds = %62
%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 ([15 x i8], [15 x i8]* @.str.25, i64 0, i64 0), i32 %63, i32 %30, i32 %33, i8* %64)
br label %100
96: ; preds = %51
%97 = 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 %36, i32 %30, i32 %33)
br label %100
98: ; preds = %62
%99 = 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 ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0), i32 %48)
br label %100
100: ; preds = %65, %67, %80, %94, %96, %98, %2
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @timestamp.timebuff, i64 0, i64 0)
}