#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*/ get_datetime_of_day(int *, int *, int *, int *, int *, int *,
                                       int *, long *, long *);
long labs(long);
int /*<<< orphan*/ snprintf(char *, size_t const, char *, char const *, int,
                            char const *, int, int, int, int, char *, int, int);
void get_rfc822_header_format_current_date(char *date, const size_t date_len) {
  const char *wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  int wday;
  int year;
  int month;
  int day;
  int hour;
  int minute;
  int second;
  long int usec;
  long int gmtoff;
  get_datetime_of_day(&wday, &year, &month, &day, &hour, &minute, &second,
                      &usec, &gmtoff);
  int gmtoff_h = (int)(labs(gmtoff) / 3600L);
  int gmtoff_m = (int)(labs(gmtoff) % 3600L);
  snprintf(date, date_len, "%s, %d %s %d %02d:%02d:%02d %s%02d%02d",
           wdays[wday], day, months[month - 1], year, hour, minute, second,
           gmtoff < 0 ? "-" : "+", gmtoff_h, gmtoff_m);
}


x86 assembly (clang, -O0):
<get_rfc822_header_format_current_date>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x120,%rsp
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
lea    -0x70(%rbp),%rdi
lea    0x2c1b(%rip),%rsi
mov    $0x38,%edx
call   1060 <memcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0x2c43(%rip),%rsi
mov    $0x60,%edx
call   1060 <memcpy@plt>
lea    -0xd4(%rbp),%rdi
lea    -0xd8(%rbp),%rsi
lea    -0xdc(%rbp),%rdx
lea    -0xe0(%rbp),%rcx
lea    -0xe4(%rbp),%r8
lea    -0xe8(%rbp),%r9
lea    -0xec(%rbp),%r11
lea    -0xf8(%rbp),%r10
lea    -0x100(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <get_datetime_of_day@plt>
mov    -0x100(%rbp),%rdi
call   1030 <labs@plt>
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %eax,-0x104(%rbp)
mov    -0x100(%rbp),%rdi
call   1030 <labs@plt>
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x108(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
movslq -0xd4(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rcx
mov    -0xe0(%rbp),%r8d
mov    -0xdc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xd0(%rbp,%rax,8),%r9
ff
mov    -0xd8(%rbp),%r12d
mov    -0xe4(%rbp),%r15d
mov    -0xe8(%rbp),%r14d
mov    -0xec(%rbp),%ebx
mov    -0x100(%rbp),%rdx
lea    0xe0b(%rip),%r11
lea    0xe02(%rip),%rax
cmp    $0x0,%rdx
cmovl  %rax,%r11
mov    -0x104(%rbp),%r10d
mov    -0x108(%rbp),%eax
lea    0xdbf(%rip),%rdx
mov    %r12d,(%rsp)
mov    %r15d,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %eax,0x30(%rsp)
call   1050 <snprintf@plt>
add    $0x120,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rfc822_header_format_current_date>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
sub    $0x8,%rsp
lea    0x30(%rsp),%rax
lea    0x38(%rsp),%rbx
lea    0x14(%rsp),%r10
lea    0x2c(%rsp),%rdi
lea    0x28(%rsp),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
push   %rax
push   %rbx
push   %r10
call   1030 <get_datetime_of_day@plt>
add    $0x20,%rsp
mov    0x28(%rsp),%rsi
mov    %rsi,%rbx
neg    %rbx
cmovs  %rsi,%rbx
mov    %rbx,%rax
shr    $0x4,%rax
movabs $0x91a2b3c4d5e6f81,%rcx
2b 1a 09
mul    %rcx
mov    %rdx,%rax
shr    $0x3,%rax
imul   $0xe10,%eax,%ecx
sub    %ecx,%ebx
movslq 0x24(%rsp),%rcx
lea    0xec8(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
mov    0x18(%rsp),%r8d
movslq 0x1c(%rsp),%rdx
lea    0xecc(%rip),%rdi
movslq -0x4(%rdi,%rdx,4),%r9
add    %rdi,%r9
mov    0x20(%rsp),%r10d
mov    0x14(%rsp),%r11d
mov    0x10(%rsp),%r12d
mov    0xc(%rsp),%r13d
test   %rsi,%rsi
lea    0xe85(%rip),%rdx
lea    0xe80(%rip),%rbp
cmovs  %rdx,%rbp
sub    $0x8,%rsp
lea    0xe48(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
push   %rbx
push   %rax
push   %rbp
push   %r13
push   %r12
push   %r11
push   %r10
call   1040 <snprintf@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"Sun\00"
@.str.1 = [4 x i8] c"Mon\00"
@.str.2 = [4 x i8] c"Tue\00"
@.str.3 = [4 x i8] c"Wed\00"
@.str.4 = [4 x i8] c"Thu\00"
@.str.5 = [4 x i8] c"Fri\00"
@.str.6 = [4 x i8] c"Sat\00"
@__const.get_rfc822_header_format_current_date.wdays = [7 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)]
@.str.7 = [4 x i8] c"Jan\00"
@.str.8 = [4 x i8] c"Feb\00"
@.str.9 = [4 x i8] c"Mar\00"
@.str.10 = [4 x i8] c"Apr\00"
@.str.11 = [4 x i8] c"May\00"
@.str.12 = [4 x i8] c"Jun\00"
@.str.13 = [4 x i8] c"Jul\00"
@.str.14 = [4 x i8] c"Aug\00"
@.str.15 = [4 x i8] c"Sep\00"
@.str.16 = [4 x i8] c"Oct\00"
@.str.17 = [4 x i8] c"Nov\00"
@.str.18 = [4 x i8] c"Dec\00"
@__const.get_rfc822_header_format_current_date.months = [12 x i8*] [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), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i32 0, i32 0)]
@.str.19 = [39 x i8] c"%s, %d %s %d %02d:%02d:%02d %s%02d%02d\00"
@.str.20 = [2 x i8] c"-\00"
@.str.21 = [2 x i8] c"+\00"
define void @get_rfc822_header_format_current_date(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [7 x i8*]
%6 = alloca [12 x i8*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%18 = bitcast [7 x i8*]* %5 to i8*
%19 = bitcast [12 x i8*]* %6 to i8*
%20 = call i32 @get_datetime_of_day(i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i64* %14, i64* %15)
%21 = load i64, i64* %15
%22 = call i64 @labs(i64 %21)
%23 = sdiv i64 %22, 3600
%24 = trunc i64 %23 to i32
store i32 %24, i32* %16
%25 = load i64, i64* %15
%26 = call i64 @labs(i64 %25)
%27 = srem i64 %26, 3600
%28 = trunc i64 %27 to i32
store i32 %28, i32* %17
%29 = load i8*, i8** %3
%30 = load i64, i64* %4
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [7 x i8*], [7 x i8*]* %5, i64 0, i64 %32
%34 = load i8*, i8** %33
%35 = load i32, i32* %10
%36 = load i32, i32* %9
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [12 x i8*], [12 x i8*]* %6, i64 0, i64 %38
%40 = load i8*, i8** %39
%41 = load i32, i32* %8
%42 = load i32, i32* %11
%43 = load i32, i32* %12
%44 = load i32, i32* %13
%45 = load i64, i64* %15
%46 = icmp slt i64 %45, 0
%47 = zext i1 %46 to i64
%48 = select i1 %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0)
%49 = load i32, i32* %16
%50 = load i32, i32* %17
%51 = call i32 @snprintf(i8* %29, i64 %30, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.19, i64 0, i64 0), i8* %34, i32 %35, i8* %40, i32 %41, i32 %42, i32 %43, i32 %44, i8* %48, i32 %49, i32 %50)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"Sun\00"
@.str.1 = [4 x i8] c"Mon\00"
@.str.2 = [4 x i8] c"Tue\00"
@.str.3 = [4 x i8] c"Wed\00"
@.str.4 = [4 x i8] c"Thu\00"
@.str.5 = [4 x i8] c"Fri\00"
@.str.6 = [4 x i8] c"Sat\00"
@reltable.get_rfc822_header_format_current_date = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.get_rfc822_header_format_current_date to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.get_rfc822_header_format_current_date to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.get_rfc822_header_format_current_date to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.get_rfc822_header_format_current_date to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.get_rfc822_header_format_current_date to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.get_rfc822_header_format_current_date to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.get_rfc822_header_format_current_date to i64)) to i32)]
@.str.7 = [4 x i8] c"Jan\00"
@.str.8 = [4 x i8] c"Feb\00"
@.str.9 = [4 x i8] c"Mar\00"
@.str.10 = [4 x i8] c"Apr\00"
@.str.11 = [4 x i8] c"May\00"
@.str.12 = [4 x i8] c"Jun\00"
@.str.13 = [4 x i8] c"Jul\00"
@.str.14 = [4 x i8] c"Aug\00"
@.str.15 = [4 x i8] c"Sep\00"
@.str.16 = [4 x i8] c"Oct\00"
@.str.17 = [4 x i8] c"Nov\00"
@.str.18 = [4 x i8] c"Dec\00"
@reltable.get_rfc822_header_format_current_date.22 = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.12 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.13 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.14 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.15 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.16 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.17 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.18 to i64), i64 ptrtoint ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i64)) to i32)]
@.str.19 = [39 x i8] c"%s, %d %s %d %02d:%02d:%02d %s%02d%02d\00"
@.str.20 = [2 x i8] c"-\00"
@.str.21 = [2 x i8] c"+\00"
define void @get_rfc822_header_format_current_date(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = bitcast i32* %3 to i8*
%13 = bitcast i32* %4 to i8*
%14 = bitcast i32* %5 to i8*
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = bitcast i64* %10 to i8*
%20 = bitcast i64* %11 to i8*
%21 = call i32 @get_datetime_of_day(i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i64* %10, i64* %11)
%22 = load i64, i64* %11
%23 = call i64 @llvm.abs.i64(i64 %22, i1 true)
%24 = udiv i64 %23, 3600
%25 = trunc i64 %24 to i32
%26 = urem i64 %23, 3600
%27 = trunc i64 %26 to i32
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = shl i64 %29, 2
%31 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.get_rfc822_header_format_current_date to i8*), i64 %30)
%32 = load i32, i32* %6
%33 = load i32, i32* %5
%34 = add nsw i32 %33, -1
%35 = sext i32 %34 to i64
%36 = shl i64 %35, 2
%37 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.get_rfc822_header_format_current_date.22 to i8*), i64 %36)
%38 = load i32, i32* %4
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = icmp slt i64 %22, 0
%43 = select i1 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0)
%44 = call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.19, i64 0, i64 0), i8* %31, i32 %32, i8* %37, i32 %38, i32 %39, i32 %40, i32 %41, i8* %43, i32 %25, i32 %27)
ret void
}