#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_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
struct timeval {
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_senddata(char *, unsigned int);
int /*<<< orphan*/ printf(char *, int, int, int, int, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, unsigned int);
int send_data(int fd, char *buf, unsigned int size) {
  time_t crt_time;
  struct tm *time_p;
  struct timeval tv;
  write(fd, buf, size);
  time(&crt_time);
  time_p = gmtime(&crt_time);
  gettimeofday(&tv, NULL);
  printf("%d-%02d-%d %02d:%02d:%02d:%03d", time_p->tm_year + 1900,
         time_p->tm_mon + 1, time_p->tm_mday, time_p->tm_hour + 8,
         time_p->tm_min, time_p->tm_sec, tv.tv_usec / 1000);
  print_senddata(buf, size);
}


x86 assembly (clang, -O0):
<send_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
lea    -0x18(%rbp),%rdi
call   1060 <time@plt>
lea    -0x18(%rbp),%rdi
call   1070 <gmtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
add    $0x76c,%esi
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r8d
add    $0x8,%r8d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%r10d
mov    -0x28(%rbp),%eax
mov    $0x3e8,%edi
cltd
idiv   %edi
mov    -0x2c(%rbp),%edx
lea    0xe0b(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <print_senddata@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_data>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
call   1030 <write@plt>
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <time@plt>
mov    %rbp,%rdi
call   1070 <gmtime@plt>
mov    %rax,%rbp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    $0x76c,%esi
add    0x0(%rbp),%esi
mov    0x4(%rbp),%edx
mov    0x8(%rbp),%ecx
add    $0x1,%edx
mov    0xc(%rbp),%r8d
add    $0x8,%r8d
mov    0x10(%rbp),%r9d
mov    0x14(%rbp),%eax
movslq 0x8(%rsp),%rdi
imul   $0x10624dd3,%rdi,%rbp
mov    %rbp,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rbp
add    %edi,%ebp
lea    0xe29(%rip),%rdi
push   %rbp
push   %rax
call   1040 <printf@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
mov    %r14d,%esi
call   1080 <print_senddata@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
%struct.timeval = type { i32 }
@.str = [31 x i8] c"%d-%02d-%d %02d:%02d:%02d:%03d\00"
define i32 @send_data(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.tm*
%10 = alloca %struct.timeval
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%11 = load i32, i32* %5
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = call i32 @write(i32 %11, i8* %12, i32 %13)
%15 = call i32 @time(i32* %8)
%16 = call %struct.tm* @gmtime(i32* %8)
store %struct.tm* %16, %struct.tm** %9
%17 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%18 = load %struct.tm*, %struct.tm** %9
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1900
%22 = load %struct.tm*, %struct.tm** %9
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
%26 = load %struct.tm*, %struct.tm** %9
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 2
%28 = load i32, i32* %27
%29 = load %struct.tm*, %struct.tm** %9
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 3
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 8
%33 = load %struct.tm*, %struct.tm** %9
%34 = getelementptr inbounds %struct.tm, %struct.tm* %33, i32 0, i32 4
%35 = load i32, i32* %34
%36 = load %struct.tm*, %struct.tm** %9
%37 = getelementptr inbounds %struct.tm, %struct.tm* %36, i32 0, i32 5
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%40 = load i32, i32* %39
%41 = sdiv i32 %40, 1000
%42 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %25, i32 %28, i32 %32, i32 %35, i32 %38, i32 %41)
%43 = load i8*, i8** %6
%44 = load i32, i32* %7
%45 = call i32 @print_senddata(i8* %43, i32 %44)
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [31 x i8] c"%d-%02d-%d %02d:%02d:%02d:%03d\00"
define i32 @send_data(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = bitcast i32* %4 to i8*
%7 = bitcast %struct.timeval* %5 to i8*
%8 = tail call i32 @write(i32 %0, i8* %1, i32 %2)
%9 = call i32 @time(i32* %4)
%10 = call %struct.tm* @gmtime(i32* %4)
%11 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%12 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 0
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1900
%15 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 1
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 2
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 3
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 8
%23 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 4
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 5
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%28 = load i32, i32* %27
%29 = sdiv i32 %28, 1000
%30 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %17, i32 %19, i32 %22, i32 %24, i32 %26, i32 %29)
%31 = call i32 @print_senddata(i8* %1, i32 %2)
ret i32 undef
}