#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ XPropertyEvent;
struct TYPE_4__ {
  int /*<<< orphan*/ window;
};
struct TYPE_5__ {
  int type;
  TYPE_1__ xany;
};
typedef TYPE_2__ XEvent;

/* Variables and functions */
#define CreateNotify 132
#define DestroyNotify 131
#define MapNotify 130
#define PropertyNotify 129
#define UnmapNotify 128
int /*<<< orphan*/ *win_list_add(int /*<<< orphan*/);
int /*<<< orphan*/ win_list_get(int /*<<< orphan*/);
int win_list_remove(int /*<<< orphan*/);
int x11_handle_property_event(int /*<<< orphan*/ *);
int x11_handle_event(XEvent *ev) {
  switch (ev->type) {
  case PropertyNotify:
    return x11_handle_property_event((XPropertyEvent *)ev);
  case CreateNotify:
    return win_list_add(ev->xany.window) != NULL;
  case DestroyNotify:
    return win_list_remove(win_list_get(ev->xany.window));
  case MapNotify:
  case UnmapNotify:
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<x11_handle_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     11c9 <x11_handle_event+0x89>
mov    -0x18(%rbp),%rax
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
call   1040 <x11_handle_property_event@plt>
mov    %eax,-0x4(%rbp)
jmp    11d0 <x11_handle_event+0x90>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <win_list_add@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11d0 <x11_handle_event+0x90>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1050 <win_list_get@plt>
mov    %eax,%edi
call   1060 <win_list_remove@plt>
mov    %eax,-0x4(%rbp)
jmp    11d0 <x11_handle_event+0x90>
jmp    11c9 <x11_handle_event+0x89>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x11_handle_event>:
push   %rax
mov    (%rdi),%ecx
cmp    $0x84,%ecx
je     1163 <x11_handle_event+0x23>
cmp    $0x83,%ecx
je     1178 <x11_handle_event+0x38>
xor    %eax,%eax
cmp    $0x81,%ecx
jne    1176 <x11_handle_event+0x36>
pop    %rax
jmp    1040 <x11_handle_property_event@plt>
mov    0x4(%rdi),%edi
call   1030 <win_list_add@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rcx
ret
mov    0x4(%rdi),%edi
call   1050 <win_list_get@plt>
mov    %eax,%edi
pop    %rax
jmp    1060 <win_list_remove@plt>

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
define i32 @x11_handle_event(%struct.TYPE_5__* %0) {
%2 = alloca i32
%3 = alloca %struct.TYPE_5__*
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %3
%4 = load %struct.TYPE_5__*, %struct.TYPE_5__** %3
%5 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 0
%6 = load i32, i32* %5
switch i32 %6, label %27 [
i32 129, label %7
i32 132, label %11
i32 131, label %19
i32 130, label %26
i32 128, label %26
]
7: ; preds = %1
%8 = load %struct.TYPE_5__*, %struct.TYPE_5__** %3
%9 = bitcast %struct.TYPE_5__* %8 to i32*
%10 = call i32 @x11_handle_property_event(i32* %9)
store i32 %10, i32* %2
br label %28
11: ; preds = %1
%12 = load %struct.TYPE_5__*, %struct.TYPE_5__** %3
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 1
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32* @win_list_add(i32 %15)
%17 = icmp ne i32* %16, null
%18 = zext i1 %17 to i32
store i32 %18, i32* %2
br label %28
19: ; preds = %1
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** %3
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 1
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call i32 @win_list_get(i32 %23)
%25 = call i32 @win_list_remove(i32 %24)
store i32 %25, i32* %2
br label %28
26: ; preds = %1, %1
br label %27
27: ; preds = %1, %26
store i32 0, i32* %2
br label %28
28: ; preds = %27, %19, %11, %7
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
define i32 @x11_handle_event(%struct.TYPE_5__* %0) {
%2 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0
%3 = load i32, i32* %2
switch i32 %3, label %17 [
i32 129, label %4
i32 132, label %6
i32 131, label %12
]
4: ; preds = %1
%5 = tail call i32 @x11_handle_property_event(i32* %2)
br label %17
6: ; preds = %1
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 1, i32 0
%8 = load i32, i32* %7
%9 = tail call i32* @win_list_add(i32 %8)
%10 = icmp ne i32* %9, null
%11 = zext i1 %10 to i32
br label %17
12: ; preds = %1
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 1, i32 0
%14 = load i32, i32* %13
%15 = tail call i32 @win_list_get(i32 %14)
%16 = tail call i32 @win_list_remove(i32 %15)
br label %17
17: ; preds = %1, %12, %6, %4
%18 = phi i32 [ %16, %12 ], [ %11, %6 ], [ %5, %4 ], [ 0, %1 ]
ret i32 %18
}