#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 same_screen;
  unsigned int state;
  int /*<<< orphan*/ keycode;
  int /*<<< orphan*/ type;
  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*/ XKeysymToKeycode(int /*<<< orphan*/ *, int);
XKeyEvent createKeyEvent(Display *dis, Window win, Window winRoot, int press,
                         int keysym, unsigned int modifiers) {
  XKeyEvent event;
  event.display = dis;
  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 = 1;
  event.type = press ? KeyPress : KeyRelease;
  event.keycode = XKeysymToKeycode(dis, keysym);
  event.state = modifiers;
  return event;
}


x86 assembly (clang, -O0):
<createKeyEvent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rax
mov    %rax,-0x28(%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)
movl   $0x1,0x10(%rdi)
cmpl   $0x0,-0x1c(%rbp)
je     11a7 <createKeyEvent+0x97>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    11b3 <createKeyEvent+0xa3>
mov    0x2e1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,0x1c(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <XKeysymToKeycode@plt>
mov    -0x30(%rbp),%rcx
mov    %eax,%edx
mov    -0x28(%rbp),%rax
mov    %edx,0x18(%rcx)
mov    0x10(%rbp),%edx
mov    %edx,0x14(%rcx)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createKeyEvent>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x20(%rsp),%ebp
mov    %rsi,0x38(%rdi)
mov    %rdx,0x30(%rdi)
mov    %rcx,0x28(%rdi)
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rdi)
mov    0x2eaf(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rdi)
movaps 0xebb(%rip),%xmm0
movups %xmm0,(%rdi)
movl   $0x1,0x10(%rdi)
test   %r8d,%r8d
jne    115d <createKeyEvent+0x4d>
mov    0x2e6d(%rip),%rax
jmp    1164 <createKeyEvent+0x54>
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rbx)
mov    %rsi,%rdi
mov    %r9d,%esi
call   1030 <XKeysymToKeycode@plt>
mov    %eax,0x18(%rbx)
mov    %ebp,0x14(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
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
@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 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i32 0, i32 4
store i32 1, i32* %28
%29 = load i32, i32* %11
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %7
%32 = load i32, i32* @KeyPress
br label %35
33: ; preds = %7
%34 = load i32, i32* @KeyRelease
br label %35
35: ; preds = %33, %31
%36 = phi i32 [ %32, %31 ], [ %34, %33 ]
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i32 0, i32 7
store i32 %36, i32* %37
%38 = load i32*, i32** %8
%39 = load i32, i32* %12
%40 = call i32 @XKeysymToKeycode(i32* %38, i32 %39)
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i32 0, i32 6
store i32 %40, i32* %41
%42 = load i32, i32* %13
%43 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i32 0, i32 5
store i32 %42, i32* %43
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
@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 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 4
store i32 1, i32* %16
%17 = icmp eq i32 %4, 0
%18 = load i32, i32* @KeyPress
%19 = load i32, i32* @KeyRelease
%20 = select i1 %17, i32 %19, i32 %18
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 7
store i32 %20, i32* %21
%22 = tail call i32 @XKeysymToKeycode(i32* %1, i32 %5)
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 6
store i32 %22, i32* %23
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 5
store i32 %6, i32* %24
ret void
}