#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*/ 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), name->sin_port, bytes);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<log_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x20(%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    -0x20(%rbp),%esi
mov    %eax,%ecx
mov    -0x19(%rbp),%al
mov    -0x8(%rbp),%rdx
mov    (%rdx),%r8d
mov    -0x18(%rbp),%r9
lea    0xe65(%rip),%rdi
movsbl %al,%edx
call   1040 <printf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x20,%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   1050 <time@plt>
mov    %eax,%r15d
xor    %ebp,%ebp
test   %r12d,%r12d
setne  %bpl
mov    0x4(%rbx),%edi
call   1030 <inet_ntoa@plt>
mov    (%rbx),%r8d
lea    0x3c(%rbp,%rbp,1),%edx
lea    0xe86(%rip),%rdi
mov    %r15d,%esi
mov    %eax,%ecx
mov    %r14,%r9
call   1040 <printf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <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 = load i64, i64* %6
%21 = 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 %19, i64 %20)
%22 = load i32, i32* @stdout
%23 = call i32 @fflush(i32 %22)
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 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %4, i8 signext %6, i32 %9, i32 %11, i64 %2)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
ret void
}