#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 */
struct tm {
  size_t tm_wday;
  int tm_mday;
  size_t tm_mon;
  int tm_year;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *gmtime(long *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, char *, int, int, int,
                           int);
char *cgi_gmt_str(long date) {
  char *day[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  char *mon[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  static char str[48];
  struct tm *s;
  s = gmtime(&date);
  sprintf(str, "%s, %02d %s %d %02d:%02d:%02d GMT", day[s->tm_wday], s->tm_mday,
          mon[s->tm_mon], s->tm_year + 1900, s->tm_hour, s->tm_min, s->tm_sec);
  return (str);
}


x86 assembly (clang, -O0):
<cgi_gmt_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0x2c36(%rip),%rsi
mov    $0x38,%edx
call   1030 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0x2c5e(%rip),%rsi
mov    $0x60,%edx
call   1030 <memcpy@plt>
lea    -0x8(%rbp),%rdi
call   1040 <gmtime@plt>
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
mov    (%rax),%rax
mov    -0x40(%rbp,%rax,8),%rdx
mov    -0xa8(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0xa8(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0xa0(%rbp,%rax,8),%r8
ff
mov    -0xa8(%rbp),%rax
mov    0x18(%rax),%r9d
add    $0x76c,%r9d
mov    -0xa8(%rbp),%rax
mov    0x1c(%rax),%r11d
mov    -0xa8(%rbp),%rax
mov    0x20(%rax),%r10d
mov    -0xa8(%rbp),%rax
mov    0x24(%rax),%eax
lea    0x2e6f(%rip),%rdi
lea    0xe64(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <sprintf@plt>
lea    0x2e4f(%rip),%rax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgi_gmt_str>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,(%rsp)
mov    %rsp,%rdi
call   1030 <gmtime@plt>
mov    (%rax),%rcx
lea    0xf36(%rip),%rsi
movslq (%rsi,%rcx,4),%rdx
add    %rsi,%rdx
mov    0x8(%rax),%ecx
mov    0x10(%rax),%rsi
lea    0xf3d(%rip),%rdi
movslq (%rdi,%rsi,4),%r8
mov    $0x76c,%r9d
add    0x18(%rax),%r9d
add    %rdi,%r8
mov    0x1c(%rax),%r10d
mov    0x20(%rax),%ebx
mov    0x24(%rax),%eax
sub    $0x8,%rsp
lea    0x2ecb(%rip),%r14
lea    0xed0(%rip),%rsi
mov    %r14,%rdi
push   %rax
push   %rbx
push   %r10
call   1040 <sprintf@plt>
add    $0x20,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i64, i32, i64, i32, i32, i32, i32 }
@.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.cgi_gmt_str.day = [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.cgi_gmt_str.mon = [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)]
@cgi_gmt_str.str = internal global [48 x i8] zeroinitializer
@.str.19 = [34 x i8] c"%s, %02d %s %d %02d:%02d:%02d GMT\00"
define i8* @cgi_gmt_str(i64 %0) {
%2 = alloca i64
%3 = alloca [7 x i8*]
%4 = alloca [12 x i8*]
%5 = alloca %struct.tm*
store i64 %0, i64* %2
%6 = bitcast [7 x i8*]* %3 to i8*
%7 = bitcast [12 x i8*]* %4 to i8*
%8 = call %struct.tm* @gmtime(i64* %2)
store %struct.tm* %8, %struct.tm** %5
%9 = load %struct.tm*, %struct.tm** %5
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = getelementptr inbounds [7 x i8*], [7 x i8*]* %3, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = load %struct.tm*, %struct.tm** %5
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = load %struct.tm*, %struct.tm** %5
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 2
%19 = load i64, i64* %18
%20 = getelementptr inbounds [12 x i8*], [12 x i8*]* %4, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = load %struct.tm*, %struct.tm** %5
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 3
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1900
%26 = load %struct.tm*, %struct.tm** %5
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 4
%28 = load i32, i32* %27
%29 = load %struct.tm*, %struct.tm** %5
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 5
%31 = load i32, i32* %30
%32 = load %struct.tm*, %struct.tm** %5
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 6
%34 = load i32, i32* %33
%35 = call i32 @sprintf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @cgi_gmt_str.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0), i8* %13, i32 %16, i8* %21, i32 %25, i32 %28, i32 %31, i32 %34)
ret i8* getelementptr inbounds ([48 x i8], [48 x i8]* @cgi_gmt_str.str, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i64, i32, i64, i32, i32, i32, i32 }
@.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.cgi_gmt_str = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.cgi_gmt_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.cgi_gmt_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.cgi_gmt_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.cgi_gmt_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.cgi_gmt_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.cgi_gmt_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.cgi_gmt_str 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.cgi_gmt_str.20 = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.12 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.13 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.14 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.15 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.16 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.17 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.18 to i64), i64 ptrtoint ([12 x i32]* @reltable.cgi_gmt_str.20 to i64)) to i32)]
@cgi_gmt_str.str = internal global [48 x i8] zeroinitializer
@.str.19 = [34 x i8] c"%s, %02d %s %d %02d:%02d:%02d GMT\00"
define i8* @cgi_gmt_str(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = call %struct.tm* @gmtime(i64* %2)
%4 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%5 = load i64, i64* %4
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.cgi_gmt_str to i8*), i64 %6)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
%11 = load i64, i64* %10
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.cgi_gmt_str.20 to i8*), i64 %12)
%14 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1900
%17 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 6
%22 = load i32, i32* %21
%23 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @cgi_gmt_str.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0), i8* %7, i32 %9, i8* %13, i32 %16, i32 %18, i32 %20, i32 %22)
ret i8* getelementptr inbounds ([48 x i8], [48 x i8]* @cgi_gmt_str.str, i64 0, i64 0)
}