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

/* Variables and functions */
int /*<<< orphan*/ EV_REL;
int /*<<< orphan*/ REL_X;
int /*<<< orphan*/ REL_Y;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memset(struct input_event *, int /*<<< orphan*/, int);
int write(int, struct input_event *, int);
void uinput_movement(int fd, int x, int y) {
  struct input_event ev;
  int rc;
  memset(&ev, 0, sizeof(ev));
  ev.type = EV_REL;
  ev.code = REL_X;
  ev.value = x;
  rc = write(fd, &ev, sizeof(ev));
  assert(rc == sizeof(ev));
  ev.code = REL_Y;
  ev.value = y;
  rc = write(fd, &ev, sizeof(ev));
  assert(rc == sizeof(ev));
}


x86 assembly (clang, -O0):
<uinput_movement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0xc,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0xc,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uinput_movement>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    %ebp,0x8(%rsp)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1030 <write@plt>
xor    %edi,%edi
cmp    $0xc,%eax
sete   %dil
call   1050 <assert@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1030 <write@plt>
xor    %edi,%edi
cmp    $0xc,%eax
sete   %dil
call   1050 <assert@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.input_event = type { i32, i32, i32 }
@EV_REL = global i32 0
@REL_X = global i32 0
@REL_Y = global i32 0
define void @uinput_movement(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.input_event
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = call i32 @memset(%struct.input_event* %7, i32 0, i32 12)
%10 = load i32, i32* @EV_REL
%11 = getelementptr inbounds %struct.input_event, %struct.input_event* %7, i32 0, i32 2
store i32 %10, i32* %11
%12 = load i32, i32* @REL_X
%13 = getelementptr inbounds %struct.input_event, %struct.input_event* %7, i32 0, i32 1
store i32 %12, i32* %13
%14 = load i32, i32* %5
%15 = getelementptr inbounds %struct.input_event, %struct.input_event* %7, i32 0, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* %4
%17 = call i32 @write(i32 %16, %struct.input_event* %7, i32 12)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = icmp eq i64 %19, 12
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* @REL_Y
%24 = getelementptr inbounds %struct.input_event, %struct.input_event* %7, i32 0, i32 1
store i32 %23, i32* %24
%25 = load i32, i32* %6
%26 = getelementptr inbounds %struct.input_event, %struct.input_event* %7, i32 0, i32 0
store i32 %25, i32* %26
%27 = load i32, i32* %4
%28 = call i32 @write(i32 %27, %struct.input_event* %7, i32 12)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = icmp eq i64 %30, 12
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
ret void
}

LLVM IR (-O2):
%struct.input_event = type { i32, i32, i32 }
@EV_REL = global i32 0
@REL_X = global i32 0
@REL_Y = global i32 0
define void @uinput_movement(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.input_event
%5 = bitcast %struct.input_event* %4 to i8*
%6 = call i32 @memset(%struct.input_event* %4, i32 0, i32 12)
%7 = load i32, i32* @EV_REL
%8 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i64 0, i32 2
store i32 %7, i32* %8
%9 = load i32, i32* @REL_X
%10 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i64 0, i32 1
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i64 0, i32 0
store i32 %1, i32* %11
%12 = call i32 @write(i32 %0, %struct.input_event* %4, i32 12)
%13 = icmp eq i32 %12, 12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* @REL_Y
store i32 %16, i32* %10
store i32 %2, i32* %11
%17 = call i32 @write(i32 %0, %struct.input_event* %4, i32 12)
%18 = icmp eq i32 %17, 12
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
ret void
}