#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;
  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(int /*<<< orphan*/ *);
char *safe_strdup(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, char *, int, int, int,
                           int);
char *get_cookie_time(time_t t) {
  struct tm *utc = gmtime(&t);
  char *wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  char utc_str[200];
  sprintf(utc_str, "%s, %d %s %d %02d:%02d:%02d UTC", wdays[utc->tm_wday],
          utc->tm_mday, months[utc->tm_mon], (utc->tm_year + 1900),
          utc->tm_hour, utc->tm_min, utc->tm_sec);
  return safe_strdup(utc_str);
}


x86 assembly (clang, -O0):
<get_cookie_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c1a(%rip),%rsi
mov    $0x38,%edx
call   1030 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
lea    0x2c42(%rip),%rsi
mov    $0x60,%edx
call   1030 <memcpy@plt>
lea    -0x180(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x50(%rbp,%rax,8),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0xb0(%rbp,%rax,8),%r8
ff
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%r9d
add    $0x76c,%r9d
mov    -0x10(%rbp),%rax
mov    0x1c(%rax),%r11d
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x24(%rax),%eax
lea    0xe6d(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1060 <sprintf@plt>
lea    -0x180(%rbp),%rdi
call   1040 <safe_strdup@plt>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cookie_time>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <gmtime@plt>
mov    (%rax),%rcx
lea    0xf1a(%rip),%rsi
movslq (%rsi,%rcx,4),%rdx
add    %rsi,%rdx
mov    0x8(%rax),%ecx
mov    0x10(%rax),%rsi
lea    0xf21(%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    0xebf(%rip),%rsi
lea    0x18(%rsp),%r14
mov    %r14,%rdi
push   %rax
push   %rbx
push   %r10
call   1050 <sprintf@plt>
add    $0x20,%rsp
mov    %r14,%rdi
call   1030 <safe_strdup@plt>
add    $0xd8,%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.get_cookie_time.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_cookie_time.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 = [32 x i8] c"%s, %d %s %d %02d:%02d:%02d UTC\00"
define i8* @get_cookie_time(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca [7 x i8*]
%5 = alloca [12 x i8*]
%6 = alloca [200 x i8]
store i32 %0, i32* %2
%7 = call %struct.tm* @gmtime(i32* %2)
store %struct.tm* %7, %struct.tm** %3
%8 = bitcast [7 x i8*]* %4 to i8*
%9 = bitcast [12 x i8*]* %5 to i8*
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%11 = load %struct.tm*, %struct.tm** %3
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = load %struct.tm*, %struct.tm** %3
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = load %struct.tm*, %struct.tm** %3
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 2
%21 = load i64, i64* %20
%22 = getelementptr inbounds [12 x i8*], [12 x i8*]* %5, i64 0, i64 %21
%23 = load i8*, i8** %22
%24 = load %struct.tm*, %struct.tm** %3
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 3
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1900
%28 = load %struct.tm*, %struct.tm** %3
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 4
%30 = load i32, i32* %29
%31 = load %struct.tm*, %struct.tm** %3
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 5
%33 = load i32, i32* %32
%34 = load %struct.tm*, %struct.tm** %3
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 6
%36 = load i32, i32* %35
%37 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0), i8* %15, i32 %18, i8* %23, i32 %27, i32 %30, i32 %33, i32 %36)
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%39 = call i8* @safe_strdup(i8* %38)
ret i8* %39
}

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