#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_16__ TYPE_7__;
typedef struct TYPE_15__ TYPE_6__;
typedef struct TYPE_14__ TYPE_5__;
typedef struct TYPE_13__ TYPE_4__;
typedef struct TYPE_12__ TYPE_3__;
typedef struct TYPE_11__ TYPE_2__;
typedef struct TYPE_10__ TYPE_1__;

/* Type definitions */
struct TYPE_12__ {
  int type;
  int /*<<< orphan*/ detail;
  scalar_t__ sequenceNumber;
};
struct TYPE_11__ {
  int /*<<< orphan*/ sameScreen;
  int /*<<< orphan*/ rootY;
  int /*<<< orphan*/ rootX;
  int /*<<< orphan*/ eventY;
  int /*<<< orphan*/ eventX;
  int /*<<< orphan*/ child;
  int /*<<< orphan*/ event;
  int /*<<< orphan*/ time;
  int /*<<< orphan*/ state;
  int /*<<< orphan*/ root;
};
struct TYPE_13__ {
  TYPE_3__ u;
  TYPE_2__ keyButtonPointer;
};
struct TYPE_14__ {
  TYPE_4__ u;
};
typedef TYPE_5__ xEvent;
struct TYPE_15__ {
  int /*<<< orphan*/ keycode;
  int /*<<< orphan*/ same_screen;
  int /*<<< orphan*/ y_root;
  int /*<<< orphan*/ x_root;
  int /*<<< orphan*/ y;
  int /*<<< orphan*/ x;
  int /*<<< orphan*/ subwindow;
  int /*<<< orphan*/ window;
  int /*<<< orphan*/ time;
  int /*<<< orphan*/ state;
  int /*<<< orphan*/ root;
};
typedef TYPE_6__ XKeyEvent;
struct TYPE_10__ {
  int serial;
};
struct TYPE_16__ {
  int type;
  TYPE_1__ xany;
};
typedef TYPE_7__ XEvent;
typedef scalar_t__ CARD16;

/* Variables and functions */
#define KeyPress 129
#define KeyRelease 128
void EventToWireEvent(XEvent *ev, xEvent *event, CARD16 *serial) {
  *serial = (CARD16)(ev->xany.serial >> 16);
  event->u.u.sequenceNumber = (CARD16)(ev->xany.serial & (unsigned long)0xFFFF);
  switch (ev->type) {
  case KeyPress:
  case KeyRelease: {
    XKeyEvent *kev = (XKeyEvent *)ev;
    event->u.u.type = ev->type;
    event->u.keyButtonPointer.root = kev->root;
    event->u.keyButtonPointer.state = kev->state;
    event->u.keyButtonPointer.time = kev->time;
    event->u.keyButtonPointer.event = kev->window;
    event->u.keyButtonPointer.child = kev->subwindow;
    event->u.keyButtonPointer.eventX = kev->x;
    event->u.keyButtonPointer.eventY = kev->y;
    event->u.keyButtonPointer.rootX = kev->x_root;
    event->u.keyButtonPointer.rootY = kev->y_root;
    event->u.keyButtonPointer.sameScreen = kev->same_screen;
    event->u.u.detail = kev->keycode;
  }
  }
}


x86 assembly (clang, -O0):
<EventToWireEvent>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movswq 0x6(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
movzwl 0x4(%rax),%eax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
sub    $0x1,%eax
ja     11f6 <EventToWireEvent+0xf6>
jmp    1149 <EventToWireEvent+0x49>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    0x28(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x34(%rax)
mov    -0x20(%rbp),%rax
mov    0x24(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    -0x20(%rbp),%rax
mov    0x1c(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<EventToWireEvent>:
mov    0x4(%rdi),%eax
mov    %eax,%ecx
sar    $0x10,%ecx
movslq %ecx,%rcx
mov    %rcx,(%rdx)
movzwl %ax,%ecx
mov    %rcx,0x8(%rsi)
mov    (%rdi),%ecx
mov    %ecx,%edx
and    $0xfffffffe,%edx
cmp    $0x80,%edx
jne    1142 <EventToWireEvent+0x42>
mov    %ecx,(%rsi)
mov    0x28(%rdi),%edx
mov    %edx,0x34(%rsi)
movups 0x18(%rdi),%xmm0
movups %xmm0,0x24(%rsi)
movups 0x8(%rdi),%xmm0
movups %xmm0,0x14(%rsi)
mov    %eax,0x10(%rsi)
mov    %ecx,0x4(%rsi)
ret

LLVM IR (-O0):
%struct.TYPE_16__ = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_14__ = type { %struct.TYPE_13__ }
%struct.TYPE_13__ = type { %struct.TYPE_12__, %struct.TYPE_11__ }
%struct.TYPE_12__ = type { i32, i32, i64 }
%struct.TYPE_11__ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.TYPE_15__ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
define void @EventToWireEvent(%struct.TYPE_16__* %0, %struct.TYPE_14__* %1, i64* %2) {
%4 = alloca %struct.TYPE_16__*
%5 = alloca %struct.TYPE_14__*
%6 = alloca i64*
%7 = alloca %struct.TYPE_15__*
store %struct.TYPE_16__* %0, %struct.TYPE_16__** %4
store %struct.TYPE_14__* %1, %struct.TYPE_14__** %5
store i64* %2, i64** %6
%8 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%9 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %8, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = ashr i32 %11, 16
%13 = sext i32 %12 to i64
%14 = load i64*, i64** %6
store i64 %13, i64* %14
%15 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%16 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %15, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = and i64 %19, 65535
%21 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%22 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %21, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %22, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %23, i32 0, i32 2
store i64 %20, i64* %24
%25 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%26 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %25, i32 0, i32 0
%27 = load i32, i32* %26
switch i32 %27, label %115 [
i32 129, label %28
i32 128, label %28
]
28: ; preds = %3, %3
%29 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%30 = bitcast %struct.TYPE_16__* %29 to %struct.TYPE_15__*
store %struct.TYPE_15__* %30, %struct.TYPE_15__** %7
%31 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%32 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%35 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %34, i32 0, i32 0
%36 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %35, i32 0, i32 0
%37 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %36, i32 0, i32 0
store i32 %33, i32* %37
%38 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%39 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %38, i32 0, i32 10
%40 = load i32, i32* %39
%41 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%42 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %41, i32 0, i32 0
%43 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %42, i32 0, i32 1
%44 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %43, i32 0, i32 9
store i32 %40, i32* %44
%45 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%46 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %45, i32 0, i32 9
%47 = load i32, i32* %46
%48 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%49 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %48, i32 0, i32 0
%50 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %49, i32 0, i32 1
%51 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %50, i32 0, i32 8
store i32 %47, i32* %51
%52 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%53 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %52, i32 0, i32 8
%54 = load i32, i32* %53
%55 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%56 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %55, i32 0, i32 0
%57 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %56, i32 0, i32 1
%58 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %57, i32 0, i32 7
store i32 %54, i32* %58
%59 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%60 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %59, i32 0, i32 7
%61 = load i32, i32* %60
%62 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%63 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %62, i32 0, i32 0
%64 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %63, i32 0, i32 1
%65 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %64, i32 0, i32 6
store i32 %61, i32* %65
%66 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%67 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %66, i32 0, i32 6
%68 = load i32, i32* %67
%69 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%70 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %69, i32 0, i32 0
%71 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %70, i32 0, i32 1
%72 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %71, i32 0, i32 5
store i32 %68, i32* %72
%73 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%74 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %73, i32 0, i32 5
%75 = load i32, i32* %74
%76 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%77 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %76, i32 0, i32 0
%78 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %77, i32 0, i32 1
%79 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %78, i32 0, i32 4
store i32 %75, i32* %79
%80 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%81 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %80, i32 0, i32 4
%82 = load i32, i32* %81
%83 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%84 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %83, i32 0, i32 0
%85 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %84, i32 0, i32 1
%86 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %85, i32 0, i32 3
store i32 %82, i32* %86
%87 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%88 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %87, i32 0, i32 3
%89 = load i32, i32* %88
%90 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%91 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %90, i32 0, i32 0
%92 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %91, i32 0, i32 1
%93 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %92, i32 0, i32 2
store i32 %89, i32* %93
%94 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%95 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %94, i32 0, i32 2
%96 = load i32, i32* %95
%97 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%98 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %97, i32 0, i32 0
%99 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %98, i32 0, i32 1
%100 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %99, i32 0, i32 1
store i32 %96, i32* %100
%101 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%102 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %101, i32 0, i32 1
%103 = load i32, i32* %102
%104 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%105 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %104, i32 0, i32 0
%106 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %105, i32 0, i32 1
%107 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %106, i32 0, i32 0
store i32 %103, i32* %107
%108 = load %struct.TYPE_15__*, %struct.TYPE_15__** %7
%109 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %108, i32 0, i32 0
%110 = load i32, i32* %109
%111 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%112 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %111, i32 0, i32 0
%113 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %112, i32 0, i32 0
%114 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %113, i32 0, i32 1
store i32 %110, i32* %114
br label %115
115: ; preds = %28, %3
ret void
}

LLVM IR (-O2):
%struct.TYPE_16__ = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_14__ = type { %struct.TYPE_13__ }
%struct.TYPE_13__ = type { %struct.TYPE_12__, %struct.TYPE_11__ }
%struct.TYPE_12__ = type { i32, i32, i64 }
%struct.TYPE_11__ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
define void @EventToWireEvent(%struct.TYPE_16__* nocapture %0, %struct.TYPE_14__* nocapture writeonly %1, i64* nocapture writeonly %2) {
%4 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 0, i32 1, i32 0
%5 = load i32, i32* %4
%6 = ashr i32 %5, 16
%7 = sext i32 %6 to i64
store i64 %7, i64* %2
%8 = and i32 %5, 65535
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %1, i64 0, i32 0, i32 0, i32 2
store i64 %9, i64* %10
%11 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 0, i32 0
%12 = load i32, i32* %11
%13 = and i32 %12, -2
%14 = icmp eq i32 %13, 128
br i1 %14, label %15, label %32
15: ; preds = %3
%16 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %1, i64 0, i32 0, i32 0, i32 0
store i32 %12, i32* %16
%17 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 5, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %1, i64 0, i32 0, i32 1, i32 9
store i32 %18, i32* %19
%20 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 3, i32 0
%21 = bitcast i32* %20 to <4 x i32>*
%22 = load <4 x i32>, <4 x i32>* %21
%23 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %1, i64 0, i32 0, i32 1, i32 5
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> %22, <4 x i32>* %24
%25 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 1, i32 0
%26 = bitcast i32* %25 to <4 x i32>*
%27 = load <4 x i32>, <4 x i32>* %26
%28 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %1, i64 0, i32 0, i32 1, i32 1
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %29
%30 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %1, i64 0, i32 0, i32 1, i32 0
store i32 %5, i32* %30
%31 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %1, i64 0, i32 0, i32 0, i32 1
store i32 %12, i32* %31
br label %32
32: ; preds = %3, %15
ret void
}