#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_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int x;
  int y;
  int x_root;
  int y_root;
  int state;
  int /*<<< orphan*/ type;
  int /*<<< orphan*/ keycode;
  int /*<<< orphan*/ same_screen;
  int /*<<< orphan*/ time;
  int /*<<< orphan*/ subwindow;
  void *root;
  void *window;
  int /*<<< orphan*/ *display;
};
typedef TYPE_1__ XKeyEvent;
typedef void *Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ CurrentTime;
int /*<<< orphan*/ KeyPress;
int /*<<< orphan*/ KeyRelease;
int /*<<< orphan*/ None;
int /*<<< orphan*/ True;
int /*<<< orphan*/ XKeysymToKeycode(int /*<<< orphan*/ *, int);
XKeyEvent createKeyEvent(Display *display, Window win, Window winRoot,
                         int press, int keycode, int modifiers) {
  XKeyEvent event;
  event.display = display;
  event.window = win;
  event.root = winRoot;
  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 = modifiers;
  if (press)
    event.type = KeyPress;
  else
    event.type = KeyRelease;
  return event;
}


x86 assembly (clang, -O0):
<createKeyEvent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rax
mov    %rax,-0x30(%rbp)
mov    0x10(%rbp),%eax
mov    %rsi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,0x38(%rdi)
mov    -0x10(%rbp),%rax
mov    %rax,0x30(%rdi)
mov    -0x18(%rbp),%rax
mov    %rax,0x28(%rdi)
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rdi)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rdi)
movl   $0x1,(%rdi)
movl   $0x1,0x4(%rdi)
movl   $0x1,0x8(%rdi)
movl   $0x1,0xc(%rdi)
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rdi)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <XKeysymToKeycode@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,0x18(%rdi)
mov    0x10(%rbp),%eax
mov    %eax,0x10(%rdi)
cmpl   $0x0,-0x1c(%rbp)
je     11c9 <createKeyEvent+0xb9>
mov    -0x28(%rbp),%rax
mov    0x2e11(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x14(%rax)
jmp    11d9 <createKeyEvent+0xc9>
mov    -0x28(%rbp),%rax
mov    0x2dec(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x14(%rax)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createKeyEvent>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%ebp
mov    %rdi,%rbx
mov    0x20(%rsp),%r14d
mov    %rsi,0x38(%rdi)
mov    %rdx,0x30(%rdi)
mov    %rcx,0x28(%rdi)
mov    0x2eae(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rdi)
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rdi)
movaps 0xeb6(%rip),%xmm0
movups %xmm0,(%rdi)
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rdi)
mov    %rsi,%rdi
mov    %r9d,%esi
call   1030 <XKeysymToKeycode@plt>
mov    %eax,0x18(%rbx)
mov    %r14d,0x10(%rbx)
test   %ebp,%ebp
jne    1178 <createKeyEvent+0x68>
mov    0x2e4a(%rip),%rax
jmp    117f <createKeyEvent+0x6f>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rbx)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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