#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 {
  size_t tm_wday;
  size_t tm_mon;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
char *malloc(int const);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ strftime(char *, int const, char *, struct tm *);
char *time_rfc1123(time_t t) {
  char *days_names[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  char *month_names[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  const int date_len = 29;
  struct tm *tmp;
  char *outstr = malloc(date_len + 1);
  tmp = gmtime(&t);
  strftime(outstr, date_len + 1, "---, %d --- %Y %H:%M:%S GMT", tmp);
  memcpy(outstr, days_names[tmp->tm_wday], 3);
  memcpy(outstr + 8, month_names[tmp->tm_mon], 3);
  outstr[date_len] = '\0';
  return outstr;
}


x86 assembly (clang, -O0):
<time_rfc1123>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0x2c27(%rip),%rsi
mov    $0x38,%edx
call   1030 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0x2c4f(%rip),%rsi
mov    $0x60,%edx
call   1030 <memcpy@plt>
movl   $0x1d,-0xa4(%rbp)
mov    $0x1e,%edi
call   1040 <malloc@plt>
mov    %rax,-0xb8(%rbp)
lea    -0x4(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rcx
mov    $0x1e,%esi
lea    0xe8c(%rip),%rdx
call   1050 <strftime@plt>
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rax
mov    (%rax),%rax
mov    -0x40(%rbp,%rax,8),%rsi
mov    $0x3,%edx
call   1030 <memcpy@plt>
mov    -0xb8(%rbp),%rdi
add    $0x8,%rdi
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0xa0(%rbp,%rax,8),%rsi
ff
mov    $0x3,%edx
call   1030 <memcpy@plt>
mov    -0xb8(%rbp),%rax
movb   $0x0,0x1d(%rax)
mov    -0xb8(%rbp),%rax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_rfc1123>:
push   %r14
push   %rbx
push   %rax
mov    %edi,0x4(%rsp)
mov    $0x1e,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%rdi
call   1060 <gmtime@plt>
mov    %rax,%r14
lea    0xee3(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
mov    (%r14),%rax
lea    0xee5(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <memcpy@plt>
lea    0x8(%rbx),%rdi
mov    0x8(%r14),%rax
lea    0xede(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    $0x3,%edx
call   1030 <memcpy@plt>
movb   $0x0,0x1d(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i64, i64 }
@.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.time_rfc1123.days_names = [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.time_rfc1123.month_names = [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 = [28 x i8] c"---, %d --- %Y %H:%M:%S GMT\00"
define i8* @time_rfc1123(i32 %0) {
%2 = alloca i32
%3 = alloca [7 x i8*]
%4 = alloca [12 x i8*]
%5 = alloca i32
%6 = alloca %struct.tm*
%7 = alloca i8*
store i32 %0, i32* %2
%8 = bitcast [7 x i8*]* %3 to i8*
%9 = bitcast [12 x i8*]* %4 to i8*
store i32 29, i32* %5
%10 = call i8* @malloc(i32 30)
store i8* %10, i8** %7
%11 = call %struct.tm* @gmtime(i32* %2)
store %struct.tm* %11, %struct.tm** %6
%12 = load i8*, i8** %7
%13 = load %struct.tm*, %struct.tm** %6
%14 = call i32 @strftime(i8* %12, i32 30, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.19, i64 0, i64 0), %struct.tm* %13)
%15 = load i8*, i8** %7
%16 = load %struct.tm*, %struct.tm** %6
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
%18 = load i64, i64* %17
%19 = getelementptr inbounds [7 x i8*], [7 x i8*]* %3, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @memcpy(i8* %15, i8* %20, i32 3)
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i64 8
%24 = load %struct.tm*, %struct.tm** %6
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 1
%26 = load i64, i64* %25
%27 = getelementptr inbounds [12 x i8*], [12 x i8*]* %4, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @memcpy(i8* %23, i8* %28, i32 3)
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i64 29
store i8 0, i8* %31
%32 = load i8*, i8** %7
ret i8* %32
}

LLVM IR (-O2):
%struct.tm = type { i64, i64 }
@.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.time_rfc1123 = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.time_rfc1123 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_rfc1123 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_rfc1123 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_rfc1123 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_rfc1123 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_rfc1123 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.time_rfc1123 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.time_rfc1123.20 = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.12 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.13 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.14 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.15 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.16 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.17 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.18 to i64), i64 ptrtoint ([12 x i32]* @reltable.time_rfc1123.20 to i64)) to i32)]
@.str.19 = [28 x i8] c"---, %d --- %Y %H:%M:%S GMT\00"
define i8* @time_rfc1123(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = tail call dereferenceable_or_null(30) i8* @malloc(i32 30)
%4 = call %struct.tm* @gmtime(i32* %2)
%5 = call i32 @strftime(i8* %3, i32 30, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.19, i64 0, i64 0), %struct.tm* %4)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%7 = load i64, i64* %6
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.time_rfc1123 to i8*), i64 %8)
%10 = call i32 @memcpy(i8* %3, i8* %9, i32 3)
%11 = getelementptr inbounds i8, i8* %3, i64 8
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%13 = load i64, i64* %12
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.time_rfc1123.20 to i8*), i64 %14)
%16 = call i32 @memcpy(i8* %11, i8* %15, i32 3)
%17 = getelementptr inbounds i8, i8* %3, i64 29
store i8 0, i8* %17
ret i8* %3
}