#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 yearlength(int);
void rev_unixtime(unsigned int utime, short *year, char *month, char *day,
                  char *hour, char *minute, char *second) {
  char days_per_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int days = utime / (60 * 60 * 24);
  char sec = utime % 60;
  char min = (utime / 60) % 60;
  char hou = (utime / (60 * 60)) % 24;
  int yy = 1970;
  if (days > 15706) {
    days -= 15706;
    yy += 43;
  }
  for (;;) {
    int l = yearlength(yy);
    if (days >= l) {
      yy++;
      days -= (l + 1);
    } else
      break;
  }
  int mon = 1;
  for (;;) {
    int l = days_per_month[mon];
    if ((l == 2) && (yearlength(yy) == 365))
      l++;
    if (days >= l) {
      mon++;
      days -= l;
    } else
      break;
  }
  days++;
  *year = yy;
  *month = mon;
  *day = days;
  *hour = hou;
  *minute = min;
  *second = sec;
  return;
}


x86 assembly (clang, -O0):
<rev_unixtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x3d(%rbp)
mov    0xec4(%rip),%eax
mov    %eax,-0x35(%rbp)
mov    0xebf(%rip),%al
mov    %al,-0x31(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x44(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %dl,%al
mov    %al,-0x45(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %dl,%al
mov    %al,-0x46(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %ecx
mov    $0x18,%ecx
xor    %edx,%edx
div    %ecx
mov    %dl,%al
mov    %al,-0x47(%rbp)
movl   $0x7b2,-0x4c(%rbp)
cmpl   $0x3d5a,-0x44(%rbp)
jle    11cc <rev_unixtime+0xbc>
mov    -0x44(%rbp),%eax
sub    $0x3d5a,%eax
mov    %eax,-0x44(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x2b,%eax
mov    %eax,-0x4c(%rbp)
jmp    11d1 <rev_unixtime+0xc1>
mov    -0x4c(%rbp),%edi
call   1030 <yearlength@plt>
mov    %eax,-0x50(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x50(%rbp),%eax
jl     1204 <rev_unixtime+0xf4>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
mov    -0x44(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x44(%rbp)
jmp    1209 <rev_unixtime+0xf9>
jmp    120e <rev_unixtime+0xfe>
jmp    11d1 <rev_unixtime+0xc1>
movl   $0x1,-0x54(%rbp)
movslq -0x54(%rbp),%rax
movsbl -0x3d(%rbp,%rax,1),%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x2,-0x58(%rbp)
jne    1247 <rev_unixtime+0x137>
mov    -0x4c(%rbp),%edi
call   1030 <yearlength@plt>
cmp    $0x16d,%eax
jne    1247 <rev_unixtime+0x137>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x58(%rbp),%eax
jl     126c <rev_unixtime+0x15c>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x44(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x44(%rbp)
jmp    1271 <rev_unixtime+0x161>
jmp    1276 <rev_unixtime+0x166>
jmp    1215 <rev_unixtime+0x105>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x4c(%rbp),%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x54(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x44(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x47(%rbp),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x46(%rbp),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
mov    -0x45(%rbp),%cl
mov    0x10(%rbp),%rax
mov    %cl,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rev_unixtime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,(%rsp)
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %edi,%r15d
mov    $0xc22e4507,%eax
imul   %r15,%rax
shr    $0x30,%rax
lea    -0x3d5a(%rax),%ecx
cmp    $0x50e37880,%edi
mov    $0x7dd,%edx
mov    $0x7b2,%r14d
cmovae %edx,%r14d
cmovb  %eax,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%r12d
mov    %r14d,%edi
call   1030 <yearlength@plt>
add    $0x1,%r14d
mov    %eax,%ecx
not    %ecx
add    %r12d,%ecx
cmp    %eax,%r12d
jge    1170 <rev_unixtime+0x60>
xor    %eax,%eax
lea    0xe6c(%rip),%rdx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%ecx
movsbl 0x1(%rax,%rdx,1),%esi
add    $0x1,%rax
sub    %esi,%r12d
jge    11a0 <rev_unixtime+0x90>
mov    $0x91a2b3c5,%edx
imul   %r15,%rdx
shr    $0x2b,%rdx
mov    $0xaaaaaaab,%esi
imul   %rdx,%rsi
shr    $0x24,%rsi
shl    $0x3,%esi
lea    (%rsi,%rsi,2),%esi
sub    %esi,%edx
mov    $0x88888889,%esi
imul   %rsi,%r15
shr    $0x25,%r15
imul   %r15,%rsi
shr    $0x25,%rsi
imul   $0x3c,%esi,%esi
imul   $0x3c,%r15d,%edi
sub    %esi,%r15d
sub    %edi,%ebp
add    $0xffffffff,%r14d
mov    %r14w,(%rbx)
mov    %al,0x0(%r13)
add    $0x1,%cl
mov    (%rsp),%rax
mov    %cl,(%rax)
mov    0x8(%rsp),%rax
mov    %dl,(%rax)
mov    0x10(%rsp),%rax
mov    %r15b,(%rax)
mov    0x50(%rsp),%rax
mov    %bpl,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.rev_unixtime.days_per_month = [13 x i8] c"\00\1F\1C\1F\1E\1F\1E\1F\1F\1E\1F\1E\1F"
define void @rev_unixtime(i32 %0, i16* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6) {
%8 = alloca i32
%9 = alloca i16*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [13 x i8]
%16 = alloca i32
%17 = alloca i8
%18 = alloca i8
%19 = alloca i8
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i32 %0, i32* %8
store i16* %1, i16** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i8* %6, i8** %14
%24 = bitcast [13 x i8]* %15 to i8*
%25 = load i32, i32* %8
%26 = udiv i32 %25, 86400
store i32 %26, i32* %16
%27 = load i32, i32* %8
%28 = urem i32 %27, 60
%29 = trunc i32 %28 to i8
store i8 %29, i8* %17
%30 = load i32, i32* %8
%31 = udiv i32 %30, 60
%32 = urem i32 %31, 60
%33 = trunc i32 %32 to i8
store i8 %33, i8* %18
%34 = load i32, i32* %8
%35 = udiv i32 %34, 3600
%36 = urem i32 %35, 24
%37 = trunc i32 %36 to i8
store i8 %37, i8* %19
store i32 1970, i32* %20
%38 = load i32, i32* %16
%39 = icmp sgt i32 %38, 15706
br i1 %39, label %40, label %45
40: ; preds = %7
%41 = load i32, i32* %16
%42 = sub nsw i32 %41, 15706
store i32 %42, i32* %16
%43 = load i32, i32* %20
%44 = add nsw i32 %43, 43
store i32 %44, i32* %20
br label %45
45: ; preds = %40, %7
br label %46
46: ; preds = %60, %45
%47 = load i32, i32* %20
%48 = call i32 @yearlength(i32 %47)
store i32 %48, i32* %21
%49 = load i32, i32* %16
%50 = load i32, i32* %21
%51 = icmp sge i32 %49, %50
br i1 %51, label %52, label %59
52: ; preds = %46
%53 = load i32, i32* %20
%54 = add nsw i32 %53, 1
store i32 %54, i32* %20
%55 = load i32, i32* %21
%56 = add nsw i32 %55, 1
%57 = load i32, i32* %16
%58 = sub nsw i32 %57, %56
store i32 %58, i32* %16
br label %60
59: ; preds = %46
br label %61
60: ; preds = %52
br label %46
61: ; preds = %59
store i32 1, i32* %22
br label %62
62: ; preds = %88, %61
%63 = load i32, i32* %22
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [13 x i8], [13 x i8]* %15, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
store i32 %67, i32* %23
%68 = load i32, i32* %23
%69 = icmp eq i32 %68, 2
br i1 %69, label %70, label %77
70: ; preds = %62
%71 = load i32, i32* %20
%72 = call i32 @yearlength(i32 %71)
%73 = icmp eq i32 %72, 365
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = load i32, i32* %23
%76 = add nsw i32 %75, 1
store i32 %76, i32* %23
br label %77
77: ; preds = %74, %70, %62
%78 = load i32, i32* %16
%79 = load i32, i32* %23
%80 = icmp sge i32 %78, %79
br i1 %80, label %81, label %87
81: ; preds = %77
%82 = load i32, i32* %22
%83 = add nsw i32 %82, 1
store i32 %83, i32* %22
%84 = load i32, i32* %23
%85 = load i32, i32* %16
%86 = sub nsw i32 %85, %84
store i32 %86, i32* %16
br label %88
87: ; preds = %77
br label %89
88: ; preds = %81
br label %62
89: ; preds = %87
%90 = load i32, i32* %16
%91 = add nsw i32 %90, 1
store i32 %91, i32* %16
%92 = load i32, i32* %20
%93 = trunc i32 %92 to i16
%94 = load i16*, i16** %9
store i16 %93, i16* %94
%95 = load i32, i32* %22
%96 = trunc i32 %95 to i8
%97 = load i8*, i8** %10
store i8 %96, i8* %97
%98 = load i32, i32* %16
%99 = trunc i32 %98 to i8
%100 = load i8*, i8** %11
store i8 %99, i8* %100
%101 = load i8, i8* %19
%102 = load i8*, i8** %12
store i8 %101, i8* %102
%103 = load i8, i8* %18
%104 = load i8*, i8** %13
store i8 %103, i8* %104
%105 = load i8, i8* %17
%106 = load i8*, i8** %14
store i8 %105, i8* %106
ret void
}

LLVM IR (-O2):
@__const.rev_unixtime.days_per_month = [13 x i8] c"\00\1F\1C\1F\1E\1F\1E\1F\1F\1E\1F\1E\1F"
define void @rev_unixtime(i32 %0, i16* nocapture writeonly %1, i8* nocapture writeonly %2, i8* nocapture writeonly %3, i8* nocapture writeonly %4, i8* nocapture writeonly %5, i8* nocapture writeonly %6) {
%8 = udiv i32 %0, 86400
%9 = icmp ugt i32 %0, 1357084799
%10 = add nsw i32 %8, -15706
%11 = select i1 %9, i32 2013, i32 1970
%12 = select i1 %9, i32 %10, i32 %8
br label %13
13: ; preds = %13, %7
%14 = phi i32 [ %11, %7 ], [ %18, %13 ]
%15 = phi i32 [ %12, %7 ], [ %20, %13 ]
%16 = tail call i32 @yearlength(i32 %14)
%17 = icmp slt i32 %15, %16
%18 = add nuw nsw i32 %14, 1
%19 = xor i32 %16, -1
%20 = add i32 %15, %19
br i1 %17, label %21, label %13
21: ; preds = %13, %21
%22 = phi i64 [ %28, %21 ], [ 1, %13 ]
%23 = phi i32 [ %29, %21 ], [ %15, %13 ]
%24 = getelementptr inbounds [13 x i8], [13 x i8]* @__const.rev_unixtime.days_per_month, i64 0, i64 %22
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp slt i32 %23, %26
%28 = add nuw i64 %22, 1
%29 = sub nsw i32 %23, %26
br i1 %27, label %30, label %21
30: ; preds = %21
%31 = udiv i32 %0, 3600
%32 = urem i32 %31, 24
%33 = trunc i32 %32 to i8
%34 = udiv i32 %0, 60
%35 = urem i32 %34, 60
%36 = trunc i32 %35 to i8
%37 = urem i32 %0, 60
%38 = trunc i32 %37 to i8
%39 = trunc i32 %14 to i16
store i16 %39, i16* %1
%40 = trunc i64 %22 to i8
store i8 %40, i8* %2
%41 = trunc i32 %23 to i8
%42 = add i8 %41, 1
store i8 %42, i8* %3
store i8 %33, i8* %4
store i8 %36, i8* %5
store i8 %38, i8* %6
ret void
}