#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*/ fprintf(int /*<<< orphan*/, char *, long, long, int, char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void __rs232_desc_xfer(int length, int is_read) {
  struct timeval tv;
  gettimeofday(&tv, 0);
  fprintf(stderr, "[%ld.%ld] Transferring %d bytes %s\n", (long)tv.tv_sec,
          (long)tv.tv_usec, length, is_read ? "in" : "out");
}


x86 assembly (clang, -O0):
<__rs232_desc_xfer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%r8d
mov    -0x8(%rbp),%esi
lea    0xecf(%rip),%r9
lea    0xec5(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r9
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__rs232_desc_xfer>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%rdx
test   %ebx,%ebx
lea    0xed5(%rip),%rax
lea    0xecb(%rip),%r9
cmove  %rax,%r9
lea    0xe9c(%rip),%rsi
mov    %ebp,%r8d
call   1040 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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