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

/* Variables and functions */
int /*<<< orphan*/ gmtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void send_date(int client) {
  time_t time_utc;
  struct tm tm_local;
  time(&time_utc);
  localtime_r(&time_utc, &tm_local);
  time_t time_local;
  struct tm tm_gmt;
  time_local = mktime(&tm_local);
  gmtime_r(&time_utc, &tm_gmt);
  int time_zone = tm_local.tm_hour - tm_gmt.tm_hour;
  if (time_zone < -12) {
    time_zone += 24;
  } else if (time_zone > 12) {
    time_zone -= 24;
  }
  char cur_time[256];
  strftime(cur_time, 256, "Date: %a, %d %b %Y %H:%M:%S GMT\r\n", &tm_gmt);
  send(client, cur_time, strlen(cur_time), 0);
  printf("%s", cur_time);
}


x86 assembly (clang, -O0):
<send_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1080 <time@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    -0x10(%rbp),%rdi
call   1090 <mktime@plt>
mov    %eax,-0x14(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <gmtime_r@plt>
mov    -0x10(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xfffffff4,-0x1c(%rbp)
jge    11de <send_date+0x5e>
mov    -0x1c(%rbp),%eax
add    $0x18,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f6 <send_date+0x76>
cmpl   $0xc,-0x1c(%rbp)
jle    11f1 <send_date+0x71>
mov    -0x1c(%rbp),%eax
sub    $0x18,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f6 <send_date+0x76>
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
lea    0xdf7(%rip),%rdx
lea    -0x18(%rbp),%rcx
call   10a0 <strftime@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x12c(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x12c(%rbp),%edi
mov    -0x128(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    -0x120(%rbp),%rsi
lea    0xdc9(%rip),%rdi
call   1060 <printf@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_date>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %edi,%r14d
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <time@plt>
lea    0x8(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <localtime_r@plt>
mov    %rbp,%rdi
call   1090 <mktime@plt>
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <gmtime_r@plt>
lea    0xe38(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rbp,%rcx
call   10a0 <strftime@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    0xe27(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
add    $0x110,%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"%s\00"
define void @send_date(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.tm
%5 = alloca i32
%6 = alloca %struct.tm
%7 = alloca i32
%8 = alloca [256 x i8]
store i32 %0, i32* %2
%9 = call i32 @time(i32* %3)
%10 = call i32 @localtime_r(i32* %3, %struct.tm* %4)
%11 = call i32 @mktime(%struct.tm* %4)
store i32 %11, i32* %5
%12 = call i32 @gmtime_r(i32* %3, %struct.tm* %6)
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
%16 = load i32, i32* %15
%17 = sub nsw i32 %14, %16
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, -12
br i1 %19, label %20, label %23
20: ; preds = %1
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 24
store i32 %22, i32* %7
br label %30
23: ; preds = %1
%24 = load i32, i32* %7
%25 = icmp sgt i32 %24, 12
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 24
store i32 %28, i32* %7
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %29, %20
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%32 = call i32 @strftime(i8* %31, i32 256, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%33 = load i32, i32* %2
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = call i32 @send(i32 %33, i8* %34, i32 %36, i32 0)
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %38)
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"%s\00"
define void @send_date(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm
%4 = alloca %struct.tm
%5 = alloca [256 x i8]
%6 = bitcast i32* %2 to i8*
%7 = bitcast %struct.tm* %3 to i8*
%8 = call i32 @time(i32* %2)
%9 = call i32 @localtime_r(i32* %2, %struct.tm* %3)
%10 = bitcast %struct.tm* %4 to i8*
%11 = call i32 @mktime(%struct.tm* %3)
%12 = call i32 @gmtime_r(i32* %2, %struct.tm* %4)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%14 = call i32 @strftime(i8* %13, i32 256, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%15 = call i32 @strlen(i8* %13)
%16 = call i32 @send(i32 %0, i8* %13, i32 %15, i32 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
ret void
}