#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 timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ __xdump(void *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long, long, int, char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void __rs232_xdump(void *x, int length, int is_read) {
  struct timeval tv;
  gettimeofday(&tv, 0);
  fprintf(stderr, "[%ld.%ld] Transferred %d bytes %s:\n", (long)tv.tv_sec,
          (long)tv.tv_usec, length, is_read ? "in" : "out");
  __xdump(x, length);
}


x86 assembly (clang, -O0):
<__rs232_xdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    -0x10(%rbp),%esi
lea    0xebb(%rip),%r9
lea    0xeb1(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r9
lea    0xe7f(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <__xdump@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__rs232_xdump>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rcx
mov    0x8(%rsp),%rdx
test   %ebx,%ebx
lea    0xec3(%rip),%rax
lea    0xeb9(%rip),%r9
cmove  %rax,%r9
lea    0xe8a(%rip),%rsi
mov    %ebp,%r8d
call   1040 <fprintf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <__xdump@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@stderr = global i32 0
@.str = [36 x i8] c"[%ld.%ld] Transferred %d bytes %s:\0A\00"
@.str.1 = [3 x i8] c"in\00"
@.str.2 = [4 x i8] c"out\00"
define void @__rs232_xdump(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.timeval
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = call i32 @gettimeofday(%struct.timeval* %7, i32 0)
%9 = load i32, i32* @stderr
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%11 = load i64, i64* %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%19 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %13, i32 %14, i8* %18)
%20 = load i8*, i8** %4
%21 = load i32, i32* %5
%22 = call i32 @__xdump(i8* %20, i32 %21)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@stderr = global i32 0
@.str = [36 x i8] c"[%ld.%ld] Transferred %d bytes %s:\0A\00"
@.str.1 = [3 x i8] c"in\00"
@.str.2 = [4 x i8] c"out\00"
define void @__rs232_xdump(i8* %0, i32 %1, i32 %2) {
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %4 to i8*
%6 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%7 = load i32, i32* @stderr
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%11 = load i64, i64* %10
%12 = icmp eq i32 %2, 0
%13 = select i1 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%14 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 %9, i64 %11, i32 %1, i8* %13)
%15 = call i32 @__xdump(i8* %0, i32 %1)
ret void
}