#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__ {
  int x;
  int y;
  int x_root;
  int y_root;
  scalar_t__ state;
  int /*<<< orphan*/ keycode;
  int /*<<< orphan*/ same_screen;
  int /*<<< orphan*/ time;
  int /*<<< orphan*/ subwindow;
  void *root;
  void *window;
  int /*<<< orphan*/ *display;
  int /*<<< orphan*/ type;
};
typedef TYPE_1__ XKeyEvent;
typedef int /*<<< orphan*/ XEvent;
typedef void *Window;
typedef int /*<<< orphan*/ Status;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ CurrentTime;
int /*<<< orphan*/ KeyPress;
int /*<<< orphan*/ KeyPressMask;
int /*<<< orphan*/ KeyRelease;
int /*<<< orphan*/ None;
int /*<<< orphan*/ True;
int /*<<< orphan*/ XKeysymToKeycode(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XSendEvent(int /*<<< orphan*/ *, void *, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/ *);
Status sendInput(Display *display, Window win, Window root, int pressed,
                 int keycode) {
  XKeyEvent event;
  event.type = (pressed ? KeyPress : KeyRelease);
  event.display = display;
  event.window = win;
  event.root = root;
  event.subwindow = None;
  event.time = CurrentTime;
  event.x = 1;
  event.y = 1;
  event.x_root = 1;
  event.y_root = 1;
  event.same_screen = True;
  event.keycode = XKeysymToKeycode(display, keycode);
  event.state = 0;
  return XSendEvent(display, win, True, KeyPressMask, (XEvent *)&event);
}


x86 assembly (clang, -O0):
<sendInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1156 <sendInput+0x36>
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
jmp    1162 <sendInput+0x42>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
movl   $0x1,-0x68(%rbp)
movl   $0x1,-0x64(%rbp)
movl   $0x1,-0x60(%rbp)
movl   $0x1,-0x5c(%rbp)
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <XKeysymToKeycode@plt>
mov    %eax,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2dea(%rip),%rax
mov    (%rax),%edx
mov    0x2df1(%rip),%rax
mov    (%rax),%ecx
lea    -0x68(%rbp),%r8
call   1030 <XSendEvent@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendInput>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
test   %ecx,%ecx
jne    113c <sendInput+0x1c>
mov    0x2e7e(%rip),%rax
jmp    1143 <sendInput+0x23>
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
mov    %rbx,0x38(%rsp)
mov    %r14,0x30(%rsp)
mov    %rdx,0x28(%rsp)
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
movaps 0xe87(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e4c(%rip),%r15
mov    (%r15),%eax
mov    %eax,0x1c(%rsp)
mov    %rbx,%rdi
mov    %r8d,%esi
call   1040 <XKeysymToKeycode@plt>
mov    %eax,0x18(%rsp)
movq   $0x0,0x10(%rsp)
mov    (%r15),%edx
mov    0x2e33(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%r8
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <XSendEvent@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i32, i32, i32, i32, i64, i32, i32, i32, i32, i8*, i8*, i32*, i32 }
@KeyPress = global i32 0
@KeyRelease = global i32 0
@None = global i32 0
@CurrentTime = global i32 0
@True = global i32 0
@KeyPressMask = global i32 0
define i32 @sendInput(i32* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.TYPE_2__
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %9
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %5
%15 = load i32, i32* @KeyPress
br label %18
16: ; preds = %5
%17 = load i32, i32* @KeyRelease
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %15, %14 ], [ %17, %16 ]
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 12
store i32 %19, i32* %20
%21 = load i32*, i32** %6
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 11
store i32* %21, i32** %22
%23 = load i8*, i8** %7
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 10
store i8* %23, i8** %24
%25 = load i8*, i8** %8
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 9
store i8* %25, i8** %26
%27 = load i32, i32* @None
%28 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 8
store i32 %27, i32* %28
%29 = load i32, i32* @CurrentTime
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 7
store i32 %29, i32* %30
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 0
store i32 1, i32* %31
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 1
store i32 1, i32* %32
%33 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 2
store i32 1, i32* %33
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 3
store i32 1, i32* %34
%35 = load i32, i32* @True
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 6
store i32 %35, i32* %36
%37 = load i32*, i32** %6
%38 = load i32, i32* %10
%39 = call i32 @XKeysymToKeycode(i32* %37, i32 %38)
%40 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 5
store i32 %39, i32* %40
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 4
store i64 0, i64* %41
%42 = load i32*, i32** %6
%43 = load i8*, i8** %7
%44 = load i32, i32* @True
%45 = load i32, i32* @KeyPressMask
%46 = bitcast %struct.TYPE_2__* %11 to i32*
%47 = call i32 @XSendEvent(i32* %42, i8* %43, i32 %44, i32 %45, i32* %46)
ret i32 %47
}

LLVM IR (-O2):
%struct.TYPE_2__ = type { i32, i32, i32, i32, i64, i32, i32, i32, i32, i8*, i8*, i32*, i32 }
@KeyPress = global i32 0
@KeyRelease = global i32 0
@None = global i32 0
@CurrentTime = global i32 0
@True = global i32 0
@KeyPressMask = global i32 0
define i32 @sendInput(i32* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca %struct.TYPE_2__
%7 = bitcast %struct.TYPE_2__* %6 to i8*
%8 = icmp eq i32 %3, 0
%9 = load i32, i32* @KeyPress
%10 = load i32, i32* @KeyRelease
%11 = select i1 %8, i32 %10, i32 %9
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 12
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 11
store i32* %0, i32** %13
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 10
store i8* %1, i8** %14
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 9
store i8* %2, i8** %15
%16 = load i32, i32* @None
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 8
store i32 %16, i32* %17
%18 = load i32, i32* @CurrentTime
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 7
store i32 %18, i32* %19
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 0
%21 = bitcast %struct.TYPE_2__* %6 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %21
%22 = load i32, i32* @True
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 6
store i32 %22, i32* %23
%24 = tail call i32 @XKeysymToKeycode(i32* %0, i32 %4)
%25 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 5
store i32 %24, i32* %25
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i64 0, i32 4
store i64 0, i64* %26
%27 = load i32, i32* @True
%28 = load i32, i32* @KeyPressMask
%29 = call i32 @XSendEvent(i32* %0, i8* %1, i32 %27, i32 %28, i32* %20)
ret i32 %29
}