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

/* Variables and functions */
int /*<<< orphan*/ rev_unixtime(unsigned int, unsigned short *, unsigned char *,
                                unsigned char *, unsigned char *,
                                unsigned char *, unsigned char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char, char *,
                           unsigned short, ...);
void format_datetime(unsigned int utime, char *str) {
  unsigned char second, minute, hour, day, month;
  unsigned short year, cur_year;
  char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                      "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  rev_unixtime(1400000000, &cur_year, &month, &day, &hour, &minute, &second);
  rev_unixtime(utime, &year, &month, &day, &hour, &minute, &second);
  if (year == cur_year)
    sprintf(str, "%2d %s %2d:%02d", day, months[month - 1], hour, minute);
  else
    sprintf(str, "%2d %s %5d", day, months[month - 1], year);
}


x86 assembly (clang, -O0):
<format_datetime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0x2c73(%rip),%rsi
mov    $0x60,%edx
call   1040 <memcpy@plt>
mov    $0x53724e00,%edi
lea    -0x1a(%rbp),%rsi
lea    -0x15(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x13(%rbp),%r8
lea    -0x12(%rbp),%r9
lea    -0x11(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <rev_unixtime@plt>
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x15(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x13(%rbp),%r8
lea    -0x12(%rbp),%r9
lea    -0x11(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <rev_unixtime@plt>
movzwl -0x18(%rbp),%eax
movzwl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
jne    11e9 <format_datetime+0xb9>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%dl
movzbl -0x15(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x80(%rbp,%rax,8),%rcx
movzbl -0x13(%rbp),%eax
movzbl -0x12(%rbp),%r9d
lea    0xe5a(%rip),%rsi
movzbl %dl,%edx
movzwl %ax,%r8d
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    1215 <format_datetime+0xe5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%al
movzbl -0x15(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    -0x80(%rbp,%rcx,8),%rcx
lea    0xe3a(%rip),%rsi
movzbl %al,%edx
movzwl -0x18(%rbp),%r8d
mov    $0x0,%al
call   1050 <sprintf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_datetime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,0x20(%rsp)
mov    %edi,%ebp
lea    0x1f(%rsp),%r14
mov    %r14,(%rsp)
lea    0x1a(%rsp),%rsi
lea    0x16(%rsp),%rbx
lea    0x17(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0x19(%rsp),%r13
mov    $0x53724e00,%edi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    %r13,%r9
call   1030 <rev_unixtime@plt>
mov    %r14,(%rsp)
lea    0x1c(%rsp),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    %r13,%r9
call   1030 <rev_unixtime@plt>
movzwl 0x1c(%rsp),%esi
mov    0x17(%rsp),%al
movzbl 0x16(%rsp),%ecx
lea    0x2c22(%rip),%rdx
mov    -0x8(%rdx,%rcx,8),%rcx
cmp    0x1a(%rsp),%si
jne    11ce <format_datetime+0xae>
movzbl 0x18(%rsp),%r8d
movzbl 0x19(%rsp),%r9d
movzbl %al,%edx
lea    0xe70(%rip),%rsi
mov    0x20(%rsp),%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    11e8 <format_datetime+0xc8>
movzbl %al,%edx
movzwl %si,%r8d
lea    0xe64(%rip),%rsi
mov    0x20(%rsp),%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"Jan\00"
@.str.1 = [4 x i8] c"Feb\00"
@.str.2 = [4 x i8] c"Mar\00"
@.str.3 = [4 x i8] c"Apr\00"
@.str.4 = [4 x i8] c"May\00"
@.str.5 = [4 x i8] c"Jun\00"
@.str.6 = [4 x i8] c"Jul\00"
@.str.7 = [4 x i8] c"Aug\00"
@.str.8 = [4 x i8] c"Sep\00"
@.str.9 = [4 x i8] c"Oct\00"
@.str.10 = [4 x i8] c"Nov\00"
@.str.11 = [4 x i8] c"Dec\00"
@__const.format_datetime.months = [12 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0)]
@.str.12 = [16 x i8] c"%2d %s %2d:%02d\00"
@.str.13 = [11 x i8] c"%2d %s %5d\00"
define void @format_datetime(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i16
%11 = alloca i16
%12 = alloca [12 x i8*]
store i32 %0, i32* %3
store i8* %1, i8** %4
%13 = bitcast [12 x i8*]* %12 to i8*
%14 = call i32 @rev_unixtime(i32 1400000000, i16* %11, i8* %9, i8* %8, i8* %7, i8* %6, i8* %5)
%15 = load i32, i32* %3
%16 = call i32 @rev_unixtime(i32 %15, i16* %10, i8* %9, i8* %8, i8* %7, i8* %6, i8* %5)
%17 = load i16, i16* %10
%18 = zext i16 %17 to i32
%19 = load i16, i16* %11
%20 = zext i16 %19 to i32
%21 = icmp eq i32 %18, %20
br i1 %21, label %22, label %36
22: ; preds = %2
%23 = load i8*, i8** %4
%24 = load i8, i8* %8
%25 = load i8, i8* %9
%26 = zext i8 %25 to i32
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [12 x i8*], [12 x i8*]* %12, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = load i8, i8* %7
%32 = zext i8 %31 to i16
%33 = load i8, i8* %6
%34 = zext i8 %33 to i32
%35 = call i32 (i8*, i8*, i8, i8*, i16, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8 zeroext %24, i8* %30, i16 zeroext %32, i32 %34)
br label %47
36: ; preds = %2
%37 = load i8*, i8** %4
%38 = load i8, i8* %8
%39 = load i8, i8* %9
%40 = zext i8 %39 to i32
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [12 x i8*], [12 x i8*]* %12, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = load i16, i16* %10
%46 = call i32 (i8*, i8*, i8, i8*, i16, ...) @sprintf(i8* %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8 zeroext %38, i8* %44, i16 zeroext %45)
br label %47
47: ; preds = %36, %22
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"Jan\00"
@.str.1 = [4 x i8] c"Feb\00"
@.str.2 = [4 x i8] c"Mar\00"
@.str.3 = [4 x i8] c"Apr\00"
@.str.4 = [4 x i8] c"May\00"
@.str.5 = [4 x i8] c"Jun\00"
@.str.6 = [4 x i8] c"Jul\00"
@.str.7 = [4 x i8] c"Aug\00"
@.str.8 = [4 x i8] c"Sep\00"
@.str.9 = [4 x i8] c"Oct\00"
@.str.10 = [4 x i8] c"Nov\00"
@.str.11 = [4 x i8] c"Dec\00"
@__const.format_datetime.months = [12 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0)]
@.str.12 = [16 x i8] c"%2d %s %2d:%02d\00"
@.str.13 = [11 x i8] c"%2d %s %5d\00"
define void @format_datetime(i32 %0, i8* nocapture writeonly %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i16
%9 = alloca i16
%10 = bitcast i16* %8 to i8*
%11 = bitcast i16* %9 to i8*
%12 = call i32 @rev_unixtime(i32 1400000000, i16* %9, i8* %7, i8* %6, i8* %5, i8* %4, i8* %3)
%13 = call i32 @rev_unixtime(i32 %0, i16* %8, i8* %7, i8* %6, i8* %5, i8* %4, i8* %3)
%14 = load i16, i16* %8
%15 = load i16, i16* %9
%16 = icmp eq i16 %14, %15
%17 = load i8, i8* %6
%18 = load i8, i8* %7
%19 = zext i8 %18 to i64
%20 = add nsw i64 %19, -1
%21 = getelementptr inbounds [12 x i8*], [12 x i8*]* @__const.format_datetime.months, i64 0, i64 %20
%22 = load i8*, i8** %21
br i1 %16, label %23, label %29
23: ; preds = %2
%24 = load i8, i8* %5
%25 = zext i8 %24 to i16
%26 = load i8, i8* %4
%27 = zext i8 %26 to i32
%28 = call i32 (i8*, i8*, i8, i8*, i16, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8 zeroext %17, i8* %22, i16 zeroext %25, i32 %27)
br label %31
29: ; preds = %2
%30 = call i32 (i8*, i8*, i8, i8*, i16, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8 zeroext %17, i8* %22, i16 zeroext %14)
br label %31
31: ; preds = %29, %23
ret void
}