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

/* Variables and functions */
int /*<<< orphan*/ EV_MSC;
int /*<<< orphan*/ MSC_SCAN;
int /*<<< orphan*/ memset(struct input_event *, int /*<<< orphan*/, int);
int /*<<< orphan*/ write(int, struct input_event *, int);
void uinput_scan(int fd, __s32 val) {
  struct input_event ev;
  memset(&ev, 0, sizeof(ev));
  ev.type = EV_MSC;
  ev.code = MSC_SCAN;
  ev.value = val;
  write(fd, &ev, sizeof(ev));
}


x86 assembly (clang, -O0):
<uinput_scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e87(%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>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uinput_scan>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %ebx,(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.input_event = type { i32, i32, i32 }
@EV_MSC = global i32 0
@MSC_SCAN = global i32 0
define void @uinput_scan(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.input_event
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 @memset(%struct.input_event* %5, i32 0, i32 12)
%7 = load i32, i32* @EV_MSC
%8 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i32 0, i32 2
store i32 %7, i32* %8
%9 = load i32, i32* @MSC_SCAN
%10 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i32 0, i32 1
store i32 %9, i32* %10
%11 = load i32, i32* %4
%12 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i32 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* %3
%14 = call i32 @write(i32 %13, %struct.input_event* %5, i32 12)
ret void
}

LLVM IR (-O2):
%struct.input_event = type { i32, i32, i32 }
@EV_MSC = global i32 0
@MSC_SCAN = global i32 0
define void @uinput_scan(i32 %0, i32 %1) {
%3 = alloca %struct.input_event
%4 = bitcast %struct.input_event* %3 to i8*
%5 = call i32 @memset(%struct.input_event* %3, i32 0, i32 12)
%6 = load i32, i32* @EV_MSC
%7 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 2
store i32 %6, i32* %7
%8 = load i32, i32* @MSC_SCAN
%9 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 1
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 0
store i32 %1, i32* %10
%11 = call i32 @write(i32 %0, %struct.input_event* %3, i32 12)
ret void
}