#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 */

/* Type definitions */
struct xrdp_wm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ xrdp_wm_mouse_click(struct xrdp_wm *, int, int, int, int);
int /*<<< orphan*/ xrdp_wm_mouse_move(struct xrdp_wm *, int, int);
int xrdp_wm_process_input_mouse(struct xrdp_wm *self, int device_flags, int x,
                                int y) {
  ;
  if (device_flags & 0x0800) {
    xrdp_wm_mouse_move(self, x, y);
  }
  if (device_flags & 0x1000) {
    if (device_flags & 0x8000) {
      xrdp_wm_mouse_click(self, x, y, 1, 1);
    } else {
      xrdp_wm_mouse_click(self, x, y, 1, 0);
    }
  }
  if (device_flags & 0x2000) {
    if (device_flags & 0x8000) {
      xrdp_wm_mouse_click(self, x, y, 2, 1);
    } else {
      xrdp_wm_mouse_click(self, x, y, 2, 0);
    }
  }
  if (device_flags & 0x4000) {
    if (device_flags & 0x8000) {
      xrdp_wm_mouse_click(self, x, y, 3, 1);
    } else {
      xrdp_wm_mouse_click(self, x, y, 3, 0);
    }
  }
  if (device_flags == 0x0280 || device_flags == 0x0278) {
    xrdp_wm_mouse_click(self, 0, 0, 4, 0);
  }
  if (device_flags == 0x0380 || device_flags == 0x0388) {
    xrdp_wm_mouse_click(self, 0, 0, 5, 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<xrdp_wm_process_input_mouse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
and    $0x800,%eax
cmp    $0x0,%eax
je     1155 <xrdp_wm_process_input_mouse+0x35>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <xrdp_wm_mouse_move@plt>
mov    -0xc(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     11b0 <xrdp_wm_process_input_mouse+0x90>
mov    -0xc(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1194 <xrdp_wm_process_input_mouse+0x74>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x1,%r8d
mov    %r8d,%ecx
call   1030 <xrdp_wm_mouse_click@plt>
jmp    11ab <xrdp_wm_process_input_mouse+0x8b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <xrdp_wm_mouse_click@plt>
jmp    11b0 <xrdp_wm_process_input_mouse+0x90>
mov    -0xc(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     120d <xrdp_wm_process_input_mouse+0xed>
mov    -0xc(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     11f1 <xrdp_wm_process_input_mouse+0xd1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x2,%ecx
mov    $0x1,%r8d
call   1030 <xrdp_wm_mouse_click@plt>
jmp    1208 <xrdp_wm_process_input_mouse+0xe8>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1030 <xrdp_wm_mouse_click@plt>
jmp    120d <xrdp_wm_process_input_mouse+0xed>
mov    -0xc(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     126a <xrdp_wm_process_input_mouse+0x14a>
mov    -0xc(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     124e <xrdp_wm_process_input_mouse+0x12e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x3,%ecx
mov    $0x1,%r8d
call   1030 <xrdp_wm_mouse_click@plt>
jmp    1265 <xrdp_wm_process_input_mouse+0x145>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x3,%ecx
xor    %r8d,%r8d
call   1030 <xrdp_wm_mouse_click@plt>
jmp    126a <xrdp_wm_process_input_mouse+0x14a>
cmpl   $0x280,-0xc(%rbp)
je     1284 <xrdp_wm_process_input_mouse+0x164>
cmpl   $0x278,-0xc(%rbp)
jne    129b <xrdp_wm_process_input_mouse+0x17b>
mov    -0x8(%rbp),%rdi
xor    %r8d,%r8d
mov    $0x4,%ecx
mov    %r8d,%esi
mov    %r8d,%edx
call   1030 <xrdp_wm_mouse_click@plt>
cmpl   $0x380,-0xc(%rbp)
je     12b5 <xrdp_wm_process_input_mouse+0x195>
cmpl   $0x388,-0xc(%rbp)
jne    12cc <xrdp_wm_process_input_mouse+0x1ac>
mov    -0x8(%rbp),%rdi
xor    %r8d,%r8d
mov    $0x5,%ecx
mov    %r8d,%esi
mov    %r8d,%edx
call   1030 <xrdp_wm_mouse_click@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrdp_wm_process_input_mouse>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r15
test   $0x800,%esi
jne    1162 <xrdp_wm_process_input_mouse+0x42>
test   $0x1000,%ebp
jne    1177 <xrdp_wm_process_input_mouse+0x57>
test   $0x2000,%ebp
jne    119c <xrdp_wm_process_input_mouse+0x7c>
test   $0x4000,%ebp
jne    11c1 <xrdp_wm_process_input_mouse+0xa1>
cmp    $0x280,%ebp
jne    11e6 <xrdp_wm_process_input_mouse+0xc6>
jmp    11ee <xrdp_wm_process_input_mouse+0xce>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
call   1040 <xrdp_wm_mouse_move@plt>
test   $0x1000,%ebp
je     1141 <xrdp_wm_process_input_mouse+0x21>
mov    %ebp,%r8d
shr    $0xf,%r8d
and    $0x1,%r8d
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    $0x1,%ecx
call   1030 <xrdp_wm_mouse_click@plt>
test   $0x2000,%ebp
je     1149 <xrdp_wm_process_input_mouse+0x29>
mov    %ebp,%r8d
shr    $0xf,%r8d
and    $0x1,%r8d
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    $0x2,%ecx
call   1030 <xrdp_wm_mouse_click@plt>
test   $0x4000,%ebp
je     1151 <xrdp_wm_process_input_mouse+0x31>
mov    %ebp,%r8d
shr    $0xf,%r8d
and    $0x1,%r8d
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    $0x3,%ecx
call   1030 <xrdp_wm_mouse_click@plt>
cmp    $0x280,%ebp
je     11ee <xrdp_wm_process_input_mouse+0xce>
cmp    $0x278,%ebp
jne    1202 <xrdp_wm_process_input_mouse+0xe2>
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x4,%ecx
xor    %r8d,%r8d
call   1030 <xrdp_wm_mouse_click@plt>
and    $0xfffffff7,%ebp
cmp    $0x380,%ebp
jne    1221 <xrdp_wm_process_input_mouse+0x101>
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x5,%ecx
xor    %r8d,%r8d
call   1030 <xrdp_wm_mouse_click@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.xrdp_wm = type { i32 }
define i32 @xrdp_wm_process_input_mouse(%struct.xrdp_wm* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.xrdp_wm*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.xrdp_wm* %0, %struct.xrdp_wm** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %6
%10 = and i32 %9, 2048
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 @xrdp_wm_mouse_move(%struct.xrdp_wm* %13, i32 %14, i32 %15)
br label %17
17: ; preds = %12, %4
%18 = load i32, i32* %6
%19 = and i32 %18, 4096
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load i32, i32* %6
%23 = and i32 %22, 32768
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %26, i32 %27, i32 %28, i32 1, i32 1)
br label %35
30: ; preds = %21
%31 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %31, i32 %32, i32 %33, i32 1, i32 0)
br label %35
35: ; preds = %30, %25
br label %36
36: ; preds = %35, %17
%37 = load i32, i32* %6
%38 = and i32 %37, 8192
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %55
40: ; preds = %36
%41 = load i32, i32* %6
%42 = and i32 %41, 32768
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %45, i32 %46, i32 %47, i32 2, i32 1)
br label %54
49: ; preds = %40
%50 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %50, i32 %51, i32 %52, i32 2, i32 0)
br label %54
54: ; preds = %49, %44
br label %55
55: ; preds = %54, %36
%56 = load i32, i32* %6
%57 = and i32 %56, 16384
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %74
59: ; preds = %55
%60 = load i32, i32* %6
%61 = and i32 %60, 32768
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %68
63: ; preds = %59
%64 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%65 = load i32, i32* %7
%66 = load i32, i32* %8
%67 = call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %64, i32 %65, i32 %66, i32 3, i32 1)
br label %73
68: ; preds = %59
%69 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%70 = load i32, i32* %7
%71 = load i32, i32* %8
%72 = call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %69, i32 %70, i32 %71, i32 3, i32 0)
br label %73
73: ; preds = %68, %63
br label %74
74: ; preds = %73, %55
%75 = load i32, i32* %6
%76 = icmp eq i32 %75, 640
br i1 %76, label %80, label %77
77: ; preds = %74
%78 = load i32, i32* %6
%79 = icmp eq i32 %78, 632
br i1 %79, label %80, label %83
80: ; preds = %77, %74
%81 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%82 = call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %81, i32 0, i32 0, i32 4, i32 0)
br label %83
83: ; preds = %80, %77
%84 = load i32, i32* %6
%85 = icmp eq i32 %84, 896
br i1 %85, label %89, label %86
86: ; preds = %83
%87 = load i32, i32* %6
%88 = icmp eq i32 %87, 904
br i1 %88, label %89, label %92
89: ; preds = %86, %83
%90 = load %struct.xrdp_wm*, %struct.xrdp_wm** %5
%91 = call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %90, i32 0, i32 0, i32 5, i32 0)
br label %92
92: ; preds = %89, %86
ret i32 0
}

LLVM IR (-O2):
%struct.xrdp_wm = type { i32 }
define i32 @xrdp_wm_process_input_mouse(%struct.xrdp_wm* %0, i32 %1, i32 %2, i32 %3) {
%5 = and i32 %1, 2048
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @xrdp_wm_mouse_move(%struct.xrdp_wm* %0, i32 %2, i32 %3)
br label %9
9: ; preds = %7, %4
%10 = and i32 %1, 4096
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = lshr i32 %1, 15
%14 = and i32 %13, 1
%15 = tail call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %0, i32 %2, i32 %3, i32 1, i32 %14)
br label %16
16: ; preds = %12, %9
%17 = and i32 %1, 8192
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = lshr i32 %1, 15
%21 = and i32 %20, 1
%22 = tail call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %0, i32 %2, i32 %3, i32 2, i32 %21)
br label %23
23: ; preds = %19, %16
%24 = and i32 %1, 16384
%25 = icmp eq i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = lshr i32 %1, 15
%28 = and i32 %27, 1
%29 = tail call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %0, i32 %2, i32 %3, i32 3, i32 %28)
br label %30
30: ; preds = %26, %23
switch i32 %1, label %33 [
i32 640, label %31
i32 632, label %31
]
31: ; preds = %30, %30
%32 = tail call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %0, i32 0, i32 0, i32 4, i32 0)
br label %33
33: ; preds = %30, %31
%34 = and i32 %1, -9
%35 = icmp eq i32 %34, 896
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = tail call i32 @xrdp_wm_mouse_click(%struct.xrdp_wm* %0, i32 0, i32 0, i32 5, i32 0)
br label %38
38: ; preds = %33, %36
ret i32 0
}