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

/* Variables and functions */
int /*<<< orphan*/ EV_KEY;
int /*<<< orphan*/ EV_SYN;
int /*<<< orphan*/ memset(struct input_event *, int /*<<< orphan*/, int);
scalar_t__ write(int, struct input_event *, int);
void send_key_up_event(int uinput_fd, int code) {
  struct input_event ev;
  memset(&ev, 0, sizeof(struct input_event));
  ev.type = EV_KEY;
  ev.code = code;
  ev.value = 0;
  if (write(uinput_fd, &ev, sizeof(struct input_event)) < 0)
    return;
  memset(&ev, 0, sizeof(struct input_event));
  ev.type = EV_SYN;
  if (write(uinput_fd, &ev, sizeof(struct input_event)) < 0)
    return;
}


x86 assembly (clang, -O0):
<send_key_up_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    1178 <send_key_up_event+0x58>
jmp    11b4 <send_key_up_event+0x94>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    11b4 <send_key_up_event+0x94>
jmp    11b4 <send_key_up_event+0x94>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_key_up_event>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %ebp,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x10,%edx
call   1030 <write@plt>
test   %rax,%rax
js     1199 <send_key_up_event+0x79>
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x10,%edx
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.input_event = type { i32, i32, i64 }
@EV_KEY = global i32 0
@EV_SYN = global i32 0
define void @send_key_up_event(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 16)
%7 = load i32, i32* @EV_KEY
%8 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i32 0, i32 1
store i32 %7, i32* %8
%9 = load i32, i32* %4
%10 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i32 0, i32 0
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i32 0, i32 2
store i64 0, i64* %11
%12 = load i32, i32* %3
%13 = call i64 @write(i32 %12, %struct.input_event* %5, i32 16)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
br label %24
16: ; preds = %2
%17 = call i32 @memset(%struct.input_event* %5, i32 0, i32 16)
%18 = load i32, i32* @EV_SYN
%19 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i32 0, i32 1
store i32 %18, i32* %19
%20 = load i32, i32* %3
%21 = call i64 @write(i32 %20, %struct.input_event* %5, i32 16)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
br label %24
24: ; preds = %15, %23, %16
ret void
}

LLVM IR (-O2):
%struct.input_event = type { i32, i32, i64 }
@EV_KEY = global i32 0
@EV_SYN = global i32 0
define void @send_key_up_event(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 16)
%6 = load i32, i32* @EV_KEY
%7 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 1
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 0
store i32 %1, i32* %8
%9 = getelementptr inbounds %struct.input_event, %struct.input_event* %3, i64 0, i32 2
store i64 0, i64* %9
%10 = call i64 @write(i32 %0, %struct.input_event* %3, i32 16)
%11 = icmp slt i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = call i32 @memset(%struct.input_event* %3, i32 0, i32 16)
%14 = load i32, i32* @EV_SYN
store i32 %14, i32* %7
%15 = call i64 @write(i32 %0, %struct.input_event* %3, i32 16)
br label %16
16: ; preds = %12, %2
ret void
}