#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 CLOCKS_PER_SEC;
double clock();
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, int, char const *, char const *,
                          char const *, char const *, char const *,
                          char const *, int const, int const);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void rdp_log_packet(const char *event, const char *source_ip,
                    const char *source_port, const char *destination_ip,
                    const char *destination_port, const char *packet_type,
                    const int seq_ack_number, const int size) {
  time_t timer;
  char buffer[26];
  struct tm *tm_info;
  time(&timer);
  tm_info = localtime(&timer);
  strftime(buffer, 26, "%H:%M:%S", tm_info);
  int clocks = clock() * 1.0;
  int micro = ((int)(clocks / (CLOCKS_PER_SEC / 1000000))) -
              (((int)(clocks / CLOCKS_PER_SEC)) * 1000000);
  printf("%s.%06d %s %s:%s %s:%s %s %d %d\n", buffer, micro, event, source_ip,
         source_port, destination_ip, destination_port, packet_type,
         seq_ack_number, size);
}


x86 assembly (clang, -O0):
<rdp_log_packet>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
lea    -0x44(%rbp),%rdi
call   1060 <time@plt>
lea    -0x44(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rcx
mov    $0x1a,%esi
lea    0xe62(%rip),%rdx
call   1070 <strftime@plt>
mov    $0x0,%al
call   1040 <clock@plt>
movsd  0xe46(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x74(%rbp)
mov    -0x6c(%rbp),%eax
mov    0x2df7(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
imul   $0xf4240,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x70(%rbp)
lea    -0x60(%rbp),%rsi
mov    -0x70(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%r14
mov    -0x38(%rbp),%rbx
mov    -0x40(%rbp),%r11
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
lea    0xde0(%rip),%rdi
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1050 <printf@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdp_log_packet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,%r12
mov    %r8,0x8(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0x1c(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe70(%rip),%rdx
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x1a,%esi
mov    %rax,%rcx
call   1070 <strftime@plt>
xor    %eax,%eax
call   1040 <clock@plt>
cvttsd2si %xmm0,%ecx
mov    0x2e31(%rip),%rax
movslq (%rax),%rdi
imul   $0x431bde83,%rdi,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x32,%rsi
add    %eax,%esi
mov    %ecx,%eax
cltd
idiv   %esi
mov    %eax,%esi
mov    %ecx,%eax
cltd
idiv   %edi
imul   $0xfff0bdc0,%eax,%edx
add    %esi,%edx
sub    $0x8,%rsp
lea    0xe1c(%rip),%rdi
mov    %r14,%rsi
mov    %rbp,%rcx
mov    %r15,%r8
mov    %r13,%r9
mov    0x90(%rsp),%eax
push   %rax
mov    0x90(%rsp),%eax
push   %rax
push   %r12
push   0x28(%rsp)
push   0x38(%rsp)
call   1050 <printf@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
@CLOCKS_PER_SEC = global i32 0
@.str.1 = [33 x i8] c"%s.%06d %s %s:%s %s:%s %s %d %d\0A\00"
define void @rdp_log_packet(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i32 %6, i32 %7) {
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [26 x i8]
%19 = alloca %struct.tm*
%20 = alloca i32
%21 = alloca i32
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i8* %5, i8** %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%22 = call i32 @time(i32* %17)
%23 = call %struct.tm* @localtime(i32* %17)
store %struct.tm* %23, %struct.tm** %19
%24 = getelementptr inbounds [26 x i8], [26 x i8]* %18, i64 0, i64 0
%25 = load %struct.tm*, %struct.tm** %19
%26 = call i32 @strftime(i8* %24, i32 26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %25)
%27 = call double (...) @clock()
%28 = fmul double %27, 1.000000e+00
%29 = fptosi double %28 to i32
store i32 %29, i32* %20
%30 = load i32, i32* %20
%31 = load i32, i32* @CLOCKS_PER_SEC
%32 = sdiv i32 %31, 1000000
%33 = sdiv i32 %30, %32
%34 = load i32, i32* %20
%35 = load i32, i32* @CLOCKS_PER_SEC
%36 = sdiv i32 %34, %35
%37 = mul nsw i32 %36, 1000000
%38 = sub nsw i32 %33, %37
store i32 %38, i32* %21
%39 = getelementptr inbounds [26 x i8], [26 x i8]* %18, i64 0, i64 0
%40 = load i32, i32* %21
%41 = load i8*, i8** %9
%42 = load i8*, i8** %10
%43 = load i8*, i8** %11
%44 = load i8*, i8** %12
%45 = load i8*, i8** %13
%46 = load i8*, i8** %14
%47 = load i32, i32* %15
%48 = load i32, i32* %16
%49 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %39, i32 %40, i8* %41, i8* %42, i8* %43, i8* %44, i8* %45, i8* %46, i32 %47, i32 %48)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
@CLOCKS_PER_SEC = global i32 0
@.str.1 = [33 x i8] c"%s.%06d %s %s:%s %s:%s %s %d %d\0A\00"
define void @rdp_log_packet(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca [26 x i8]
%11 = bitcast i32* %9 to i8*
%12 = getelementptr inbounds [26 x i8], [26 x i8]* %10, i64 0, i64 0
%13 = call i32 @time(i32* %9)
%14 = call %struct.tm* @localtime(i32* %9)
%15 = call i32 @strftime(i8* %12, i32 26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %14)
%16 = call double (...) @clock()
%17 = fptosi double %16 to i32
%18 = load i32, i32* @CLOCKS_PER_SEC
%19 = sdiv i32 %18, 1000000
%20 = sdiv i32 %17, %19
%21 = sdiv i32 %17, %18
%22 = mul i32 %21, -1000000
%23 = add i32 %22, %20
%24 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %23, i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i32 %6, i32 %7)
ret void
}