#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 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, char *);
int /*<<< orphan*/ gmtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *make_date_header() {
  time_t now = time(NULL);
  struct tm gmtnow;
  char buf[1000];
  char *out;
  gmtime_r(&now, &gmtnow);
  strftime(buf, 1000, "%a, %d %h %Y %H:%M:%S GMT", &gmtnow);
  asprintf(&out, "date: %s", buf);
  return (out);
}


x86 assembly (clang, -O0):
<make_date_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <gmtime_r@plt>
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
lea    0xe89(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1060 <strftime@plt>
lea    -0x3f0(%rbp),%rdx
lea    -0x3f8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1050 <asprintf@plt>
mov    -0x3f8(%rbp),%rax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_date_header>:
push   %r14
push   %rbx
sub    $0x408,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
lea    0x18(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <gmtime_r@plt>
lea    0xe92(%rip),%rdx
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rcx
call   1060 <strftime@plt>
lea    0xe90(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %r14,%rdx
call   1050 <asprintf@plt>
mov    0x10(%rsp),%rax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [26 x i8] c"%a, %d %h %Y %H:%M:%S GMT\00"
@.str.1 = [9 x i8] c"date: %s\00"
define i8* @make_date_header() {
%1 = alloca i32
%2 = alloca %struct.tm
%3 = alloca [1000 x i8]
%4 = alloca i8*
%5 = call i32 @time(i32* null)
store i32 %5, i32* %1
%6 = call i32 @gmtime_r(i32* %1, %struct.tm* %2)
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%8 = call i32 @strftime(i8* %7, i32 1000, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), %struct.tm* %2)
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%10 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %4
ret i8* %11
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [26 x i8] c"%a, %d %h %Y %H:%M:%S GMT\00"
@.str.1 = [9 x i8] c"date: %s\00"
define i8* @make_date_header() {
%1 = alloca i32
%2 = alloca %struct.tm
%3 = alloca [1000 x i8]
%4 = alloca i8*
%5 = bitcast i32* %1 to i8*
%6 = tail call i32 @time(i32* null)
store i32 %6, i32* %1
%7 = bitcast %struct.tm* %2 to i8*
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%9 = bitcast i8** %4 to i8*
%10 = call i32 @gmtime_r(i32* %1, %struct.tm* %2)
%11 = call i32 @strftime(i8* %8, i32 1000, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), %struct.tm* %2)
%12 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%13 = load i8*, i8** %4
ret i8* %13
}