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

/* Variables and functions */
char *asctime(int /*<<< orphan*/);
int /*<<< orphan*/ gmtime(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ realloc(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *getDate() {
  time_t serverTime;
  time(&serverTime);
  char *date = asctime(gmtime(&serverTime));
  *(date + strlen(date) - 1) = '\0';
  char *out = (char *)malloc(strlen(date) + 10);
  sprintf(out, "%s GMT", date);
  realloc(out, strlen(out) + 1);
  return out;
}


x86 assembly (clang, -O0):
<getDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x4(%rbp),%rdi
call   1050 <time@plt>
lea    -0x4(%rbp),%rdi
call   1080 <gmtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
add    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe26(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
add    $0x1,%esi
call   1070 <realloc@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDate>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1080 <gmtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%r14,%rax,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0xa(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe43(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
call   1070 <realloc@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s GMT\00"
define i8* @getDate() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = call i32 @time(i32* %1)
%5 = call i32 @gmtime(i32* %1)
%6 = call i8* @asctime(i32 %5)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 -1
store i8 0, i8* %12
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = add nsw i32 %14, 10
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = load i8*, i8** %2
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %3
%22 = load i8*, i8** %3
%23 = call i32 @strlen(i8* %22)
%24 = add nsw i32 %23, 1
%25 = call i32 @realloc(i8* %21, i32 %24)
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s GMT\00"
define i8* @getDate() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @time(i32* %1)
%4 = call i32 @gmtime(i32* %1)
%5 = call i8* @asctime(i32 %4)
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 -1
store i8 0, i8* %9
%10 = call i32 @strlen(i8* %5)
%11 = add nsw i32 %10, 10
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = call i32 @sprintf(i8* dereferenceable(1) %13, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
%15 = call i32 @strlen(i8* %13)
%16 = add nsw i32 %15, 1
%17 = call i32 @realloc(i8* %13, i32 %16)
ret i8* %13
}