#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ tv_usec;
  int /*<<< orphan*/ tv_sec;
};
struct input_event {
  int type;
  int code;
  int value;
  TYPE_1__ time;
};
typedef int /*<<< orphan*/ ev;

/* Variables and functions */
int /*<<< orphan*/ time(int /*<<< orphan*/);
int write(int, struct input_event *, int);
int report_ev(int f, int type, int code, int value) {
  struct input_event ev;
  ev.time.tv_sec = time(0);
  ev.time.tv_usec = 0;
  ev.type = type;
  ev.code = code;
  ev.value = value;
  return write(f, &ev, sizeof(ev));
}


x86 assembly (clang, -O0):
<report_ev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x20,%edx
call   1030 <write@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<report_ev>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r15d
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x20(%rsp)
movq   $0x0,0x18(%rsp)
mov    %ebx,0x8(%rsp)
mov    %ebp,0xc(%rsp)
mov    %r14d,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    %r15d,%edi
mov    $0x20,%edx
call   1030 <write@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.input_event = type { i32, i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64, i32 }
define i32 @report_ev(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.input_event
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = call i32 @time(i32 0)
%11 = getelementptr inbounds %struct.input_event, %struct.input_event* %9, i32 0, i32 3
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 1
store i32 %10, i32* %12
%13 = getelementptr inbounds %struct.input_event, %struct.input_event* %9, i32 0, i32 3
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
store i64 0, i64* %14
%15 = load i32, i32* %6
%16 = getelementptr inbounds %struct.input_event, %struct.input_event* %9, i32 0, i32 0
store i32 %15, i32* %16
%17 = load i32, i32* %7
%18 = getelementptr inbounds %struct.input_event, %struct.input_event* %9, i32 0, i32 1
store i32 %17, i32* %18
%19 = load i32, i32* %8
%20 = getelementptr inbounds %struct.input_event, %struct.input_event* %9, i32 0, i32 2
store i32 %19, i32* %20
%21 = load i32, i32* %5
%22 = call i32 @write(i32 %21, %struct.input_event* %9, i32 32)
ret i32 %22
}

LLVM IR (-O2):
%struct.input_event = type { i32, i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64, i32 }
define i32 @report_ev(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.input_event
%6 = bitcast %struct.input_event* %5 to i8*
%7 = tail call i32 @time(i32 0)
%8 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i64 0, i32 3, i32 1
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i64 0, i32 3, i32 0
store i64 0, i64* %9
%10 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i64 0, i32 0
store i32 %1, i32* %10
%11 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i64 0, i32 1
store i32 %2, i32* %11
%12 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i64 0, i32 2
store i32 %3, i32* %12
%13 = call i32 @write(i32 %0, %struct.input_event* %5, i32 32)
ret i32 %13
}