#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 scalar_t__ time_t;

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ gmtime(scalar_t__ *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
scalar_t__ time(int /*<<< orphan*/);
char *http_date(time_t offset_sec) {
  static char *str = NULL;
  if (!str)
    str = calloc(1024, sizeof(char));
  time_t now = time(0) + offset_sec;
  strftime(str, 1024 * sizeof(char), "%a, %d %b %Y %H:%M:%S %Z", gmtime(&now));
  return str;
}


x86 assembly (clang, -O0):
<http_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,0x2ef4(%rip)
jne    1170 <http_date+0x30>
mov    $0x400,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,0x2ed8(%rip)
xor    %edi,%edi
call   1040 <time@plt>
add    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2ec2(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
call   1060 <gmtime@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%ecx
mov    $0x400,%esi
lea    0xe5b(%rip),%rdx
call   1050 <strftime@plt>
mov    0x2e97(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_date>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
cmpq   $0x0,0x2ef8(%rip)
jne    1168 <http_date+0x28>
mov    $0x400,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,0x2ee0(%rip)
xor    %edi,%edi
call   1040 <time@plt>
add    %rbx,%rax
mov    %rax,0x8(%rsp)
mov    0x2eca(%rip),%rbx
lea    0x8(%rsp),%rdi
call   1060 <gmtime@plt>
lea    0xe71(%rip),%rdx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %eax,%ecx
call   1050 <strftime@plt>
mov    0x2ea3(%rip),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@http_date.str = internal global i8* null
@.str = [25 x i8] c"%a, %d %b %Y %H:%M:%S %Z\00"
define i8* @http_date(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = load i8*, i8** @http_date.str
%5 = icmp ne i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i8* @calloc(i32 1024, i32 1)
store i8* %7, i8** @http_date.str
br label %8
8: ; preds = %6, %1
%9 = call i64 @time(i32 0)
%10 = load i64, i64* %2
%11 = add nsw i64 %9, %10
store i64 %11, i64* %3
%12 = load i8*, i8** @http_date.str
%13 = call i32 @gmtime(i64* %3)
%14 = call i32 @strftime(i8* %12, i32 1024, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i8*, i8** @http_date.str
ret i8* %15
}

LLVM IR (-O2):
@http_date.str = internal unnamed_addr global i8* null
@.str = [25 x i8] c"%a, %d %b %Y %H:%M:%S %Z\00"
define i8* @http_date(i64 %0) {
%2 = alloca i64
%3 = load i8*, i8** @http_date.str
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call dereferenceable_or_null(1024) i8* @calloc(i32 1024, i32 1)
store i8* %6, i8** @http_date.str
br label %7
7: ; preds = %5, %1
%8 = bitcast i64* %2 to i8*
%9 = tail call i64 @time(i32 0)
%10 = add nsw i64 %9, %0
store i64 %10, i64* %2
%11 = load i8*, i8** @http_date.str
%12 = call i32 @gmtime(i64* %2)
%13 = call i32 @strftime(i8* %11, i32 1024, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** @http_date.str
ret i8* %14
}