#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 {
  int dummy;
};
struct input_event {
  int type;
  int code;
  int value;
  int /*<<< orphan*/ time;
};

/* Variables and functions */
int /*<<< orphan*/ time_increment_and_copy(struct timeval *,
                                           int /*<<< orphan*/ *, int);
void queue_event(int type, int code, int value, struct input_event *queue,
                 int *queue_index, struct timeval *time) {
  queue[*queue_index].type = type;
  queue[*queue_index].code = code;
  queue[*queue_index].value = value;
  time_increment_and_copy(time, &queue[*queue_index].time, 2000);
  (*queue_index)++;
}


x86 assembly (clang, -O0):
<queue_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdx
movslq (%rdx),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdx
movslq (%rdx),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdx
movslq (%rdx),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %ecx,0x8(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
movslq (%rax),%rax
shl    $0x4,%rax
add    %rax,%rsi
add    $0xc,%rsi
mov    $0x7d0,%edx
call   1030 <time_increment_and_copy@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<queue_event>:
push   %rbx
mov    %r8,%rbx
movslq (%r8),%rax
shl    $0x4,%rax
mov    %edi,(%rcx,%rax,1)
movslq (%r8),%rax
shl    $0x4,%rax
mov    %esi,0x4(%rcx,%rax,1)
movslq (%r8),%rax
shl    $0x4,%rax
mov    %edx,0x8(%rcx,%rax,1)
movslq (%r8),%rax
shl    $0x4,%rax
lea    (%rcx,%rax,1),%rsi
add    $0xc,%rsi
mov    %r9,%rdi
mov    $0x7d0,%edx
call   1030 <time_increment_and_copy@plt>
addl   $0x1,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
%struct.input_event = type { i32, i32, i32, i32 }
%struct.timeval = type { i32 }
define void @queue_event(i32 %0, i32 %1, i32 %2, %struct.input_event* %3, i32* %4, %struct.timeval* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.input_event*
%11 = alloca i32*
%12 = alloca %struct.timeval*
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store %struct.input_event* %3, %struct.input_event** %10
store i32* %4, i32** %11
store %struct.timeval* %5, %struct.timeval** %12
%13 = load i32, i32* %7
%14 = load %struct.input_event*, %struct.input_event** %10
%15 = load i32*, i32** %11
%16 = load i32, i32* %15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds %struct.input_event, %struct.input_event* %14, i64 %17
%19 = getelementptr inbounds %struct.input_event, %struct.input_event* %18, i32 0, i32 0
store i32 %13, i32* %19
%20 = load i32, i32* %8
%21 = load %struct.input_event*, %struct.input_event** %10
%22 = load i32*, i32** %11
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds %struct.input_event, %struct.input_event* %21, i64 %24
%26 = getelementptr inbounds %struct.input_event, %struct.input_event* %25, i32 0, i32 1
store i32 %20, i32* %26
%27 = load i32, i32* %9
%28 = load %struct.input_event*, %struct.input_event** %10
%29 = load i32*, i32** %11
%30 = load i32, i32* %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds %struct.input_event, %struct.input_event* %28, i64 %31
%33 = getelementptr inbounds %struct.input_event, %struct.input_event* %32, i32 0, i32 2
store i32 %27, i32* %33
%34 = load %struct.timeval*, %struct.timeval** %12
%35 = load %struct.input_event*, %struct.input_event** %10
%36 = load i32*, i32** %11
%37 = load i32, i32* %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds %struct.input_event, %struct.input_event* %35, i64 %38
%40 = getelementptr inbounds %struct.input_event, %struct.input_event* %39, i32 0, i32 3
%41 = call i32 @time_increment_and_copy(%struct.timeval* %34, i32* %40, i32 2000)
%42 = load i32*, i32** %11
%43 = load i32, i32* %42
%44 = add nsw i32 %43, 1
store i32 %44, i32* %42
ret void
}

LLVM IR (-O2):
%struct.input_event = type { i32, i32, i32, i32 }
%struct.timeval = type { i32 }
define void @queue_event(i32 %0, i32 %1, i32 %2, %struct.input_event* %3, i32* nocapture %4, %struct.timeval* %5) {
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 %8, i32 0
store i32 %0, i32* %9
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 %11, i32 1
store i32 %1, i32* %12
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 %14, i32 2
store i32 %2, i32* %15
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 %17, i32 3
%19 = tail call i32 @time_increment_and_copy(%struct.timeval* %5, i32* %18, i32 2000)
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
ret void
}