#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 */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void add_time_stamp(char *b, int crlf) {
  struct tm *t;
  time_t now;
  now = time(NULL);
  t = gmtime(&now);
  strftime(b + strlen(b), 38,
           "Date: %a, %d %b %Y %H:%M:%S GMT"
           "\r\n",
           t);
  if (crlf)
    strcat(b, "\r\n");
}


x86 assembly (clang, -O0):
<add_time_stamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x18(%rbp),%rcx
mov    $0x26,%esi
lea    0xe5e(%rip),%rdx
call   1050 <strftime@plt>
cmpl   $0x0,-0xc(%rbp)
je     11c1 <add_time_stamp+0x71>
mov    -0x8(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1070 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_time_stamp>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1060 <gmtime@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
lea    0xe75(%rip),%rdx
mov    $0x26,%esi
mov    %rbp,%rcx
call   1050 <strftime@plt>
test   %r14d,%r14d
je     11ac <add_time_stamp+0x5c>
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [34 x i8] c"Date: %a, %d %b %Y %H:%M:%S GMT\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @add_time_stamp(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.tm*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = call i32 @time(i32* null)
store i32 %7, i32* %6
%8 = call %struct.tm* @gmtime(i32* %6)
store %struct.tm* %8, %struct.tm** %5
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
%14 = load %struct.tm*, %struct.tm** %5
%15 = call i32 @strftime(i8* %13, i32 38, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %struct.tm* %14)
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i8*, i8** %3
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %18, %2
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [34 x i8] c"Date: %a, %d %b %Y %H:%M:%S GMT\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @add_time_stamp(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = call %struct.tm* @gmtime(i32* %3)
%7 = call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = call i32 @strftime(i8* %9, i32 38, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%11 = icmp eq i32 %1, 0
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %2
ret void
}