#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 */
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, char, int /*<<< orphan*/,
                          int /*<<< orphan*/, size_t);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void log_packet(const struct sockaddr_in *name, int received, size_t bytes) {
  printf("%ld: %c %s:%d %ld\n", time(NULL), (received ? '>' : '<'),
         inet_ntoa(name->sin_addr), htons(name->sin_port), bytes);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<log_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edx
mov    $0x3c,%eax
mov    $0x3e,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <htons@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%ecx
mov    %eax,%r8d
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%r9
lea    0xe4a(%rip),%rdi
movsbl %al,%edx
call   1050 <printf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_packet>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %esi,%r12d
mov    %rdi,%rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%r15d
xor    %ebp,%ebp
test   %r12d,%r12d
setne  %bpl
mov    0x4(%rbx),%edi
call   1030 <inet_ntoa@plt>
mov    %eax,%r12d
mov    (%rbx),%edi
call   1040 <htons@plt>
lea    0x3c(%rbp,%rbp,1),%edx
lea    0xe6f(%rip),%rdi
mov    %r15d,%esi
mov    %r12d,%ecx
mov    %eax,%r8d
mov    %r14,%r9
call   1050 <printf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fflush@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
@.str = [19 x i8] c"%ld: %c %s:%d %ld\0A\00"
@stdout = global i32 0
define void @log_packet(%struct.sockaddr_in* %0, i32 %1, i64 %2) {
%4 = alloca %struct.sockaddr_in*
%5 = alloca i32
%6 = alloca i64
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %4
store i32 %1, i32* %5
store i64 %2, i64* %6
%7 = call i32 @time(i32* null)
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i32 62, i32 60
%12 = trunc i32 %11 to i8
%13 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = call i32 @inet_ntoa(i32 %15)
%17 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @htons(i32 %19)
%21 = load i64, i64* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %7, i8 signext %12, i32 %16, i32 %20, i64 %21)
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
@.str = [19 x i8] c"%ld: %c %s:%d %ld\0A\00"
@stdout = global i32 0
define void @log_packet(%struct.sockaddr_in* nocapture %0, i32 %1, i64 %2) {
%4 = tail call i32 @time(i32* null)
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i8 60, i8 62
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1
%8 = load i32, i32* %7
%9 = tail call i32 @inet_ntoa(i32 %8)
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @htons(i32 %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %4, i8 signext %6, i32 %9, i32 %12, i64 %2)
%14 = load i32, i32* @stdout
%15 = tail call i32 @fflush(i32 %14)
ret void
}