#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;
};
typedef TYPE_1__ MEVENT;

/* Variables and functions */
int KEY_MOUSE;
scalar_t__ OK;
int getch();
scalar_t__ getmouse(TYPE_1__ *);
unsigned char get_mouse_input() {
  int ch = getch();
  if (ch == KEY_MOUSE) {
    MEVENT event;
    if (getmouse(&event) == OK) {
      if (event.x <= 75 && event.x >= 3) {
        if (event.y <= 33 && event.y >= 1) {
          unsigned char x = (event.x - 4) / 9;
          unsigned char y = 7 - (event.y - 2) / 4;
          unsigned char ret = (y << 4) | x;
          return ret;
        }
      }
    }
  }
  return 0xFF;
}


x86 assembly (clang, -O0):
<get_mouse_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1040 <getch@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2eac(%rip),%rcx
cmp    (%rcx),%eax
jne    11da <get_mouse_input+0xba>
lea    -0x10(%rbp),%rdi
call   1030 <getmouse@plt>
mov    0x2e84(%rip),%rcx
cmp    (%rcx),%rax
jne    11d5 <get_mouse_input+0xb5>
cmpl   $0x4b,-0x10(%rbp)
jg     11d0 <get_mouse_input+0xb0>
cmpl   $0x3,-0x10(%rbp)
jl     11d0 <get_mouse_input+0xb0>
cmpl   $0x21,-0xc(%rbp)
jg     11cb <get_mouse_input+0xab>
cmpl   $0x1,-0xc(%rbp)
jl     11cb <get_mouse_input+0xab>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
mov    %al,-0x11(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x7,%eax
sub    %ecx,%eax
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
shl    $0x4,%eax
movzbl -0x11(%rbp),%ecx
or     %ecx,%eax
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11de <get_mouse_input+0xbe>
jmp    11d0 <get_mouse_input+0xb0>
jmp    11d5 <get_mouse_input+0xb5>
jmp    11da <get_mouse_input+0xba>
movb   $0xff,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mouse_input>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <getch@plt>
mov    0x2eb5(%rip),%rcx
mov    $0xff,%bl
cmp    (%rcx),%eax
jne    1193 <get_mouse_input+0x73>
lea    0x8(%rsp),%rdi
call   1030 <getmouse@plt>
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%rax
jne    1193 <get_mouse_input+0x73>
mov    0x8(%rsp),%ecx
lea    -0x3(%rcx),%eax
cmp    $0x48,%eax
ja     1193 <get_mouse_input+0x73>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%edx
cmp    $0x21,%edx
jae    1193 <get_mouse_input+0x73>
add    $0xfc,%cl
movsbl %cl,%ecx
imul   $0x39,%ecx,%ecx
movzwl %cx,%edx
shr    $0x9,%ecx
shr    $0xf,%edx
add    %cl,%dl
add    $0xfe,%al
mov    %eax,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %al,%cl
shl    $0x2,%cl
and    $0xf0,%cl
mov    $0x70,%bl
sub    %cl,%bl
or     %dl,%bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@KEY_MOUSE = global i32 0
@OK = global i64 0
define zeroext i8 @get_mouse_input() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca %struct.TYPE_3__
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = call i32 (...) @getch()
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = load i32, i32* @KEY_MOUSE
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %54
11: ; preds = %0
%12 = call i64 @getmouse(%struct.TYPE_3__* %3)
%13 = load i64, i64* @OK
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %53
15: ; preds = %11
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 0
%17 = load i32, i32* %16
%18 = icmp sle i32 %17, 75
br i1 %18, label %19, label %52
19: ; preds = %15
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 0
%21 = load i32, i32* %20
%22 = icmp sge i32 %21, 3
br i1 %22, label %23, label %52
23: ; preds = %19
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 1
%25 = load i32, i32* %24
%26 = icmp sle i32 %25, 33
br i1 %26, label %27, label %51
27: ; preds = %23
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 1
%29 = load i32, i32* %28
%30 = icmp sge i32 %29, 1
br i1 %30, label %31, label %51
31: ; preds = %27
%32 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 0
%33 = load i32, i32* %32
%34 = sub nsw i32 %33, 4
%35 = sdiv i32 %34, 9
%36 = trunc i32 %35 to i8
store i8 %36, i8* %4
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 1
%38 = load i32, i32* %37
%39 = sub nsw i32 %38, 2
%40 = sdiv i32 %39, 4
%41 = sub nsw i32 7, %40
%42 = trunc i32 %41 to i8
store i8 %42, i8* %5
%43 = load i8, i8* %5
%44 = zext i8 %43 to i32
%45 = shl i32 %44, 4
%46 = load i8, i8* %4
%47 = zext i8 %46 to i32
%48 = or i32 %45, %47
%49 = trunc i32 %48 to i8
store i8 %49, i8* %6
%50 = load i8, i8* %6
store i8 %50, i8* %1
br label %55
51: ; preds = %27, %23
br label %52
52: ; preds = %51, %19, %15
br label %53
53: ; preds = %52, %11
br label %54
54: ; preds = %53, %0
store i8 -1, i8* %1
br label %55
55: ; preds = %54, %31
%56 = load i8, i8* %1
ret i8 %56
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@KEY_MOUSE = global i32 0
@OK = global i64 0
define zeroext i8 @get_mouse_input() {
%1 = alloca %struct.TYPE_3__
%2 = tail call i32 (...) @getch()
%3 = load i32, i32* @KEY_MOUSE
%4 = icmp eq i32 %2, %3
br i1 %4, label %5, label %31
5: ; preds = %0
%6 = bitcast %struct.TYPE_3__* %1 to i8*
%7 = call i64 @getmouse(%struct.TYPE_3__* %1)
%8 = load i64, i64* @OK
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%12 = load i32, i32* %11
%13 = add i32 %12, -3
%14 = icmp ult i32 %13, 73
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%17 = load i32, i32* %16
%18 = add i32 %17, -1
%19 = icmp ult i32 %18, 33
br i1 %19, label %21, label %20
20: ; preds = %10, %15, %5
br label %31
21: ; preds = %15
%22 = trunc i32 %12 to i8
%23 = add nsw i8 %22, -4
%24 = sdiv i8 %23, 9
%25 = trunc i32 %17 to i8
%26 = add nsw i8 %25, -2
%27 = sdiv i8 %26, -4
%28 = shl nsw i8 %27, 4
%29 = add i8 %28, 112
%30 = or i8 %29, %24
br label %31
31: ; preds = %0, %20, %21
%32 = phi i8 [ %30, %21 ], [ -1, %20 ], [ -1, %0 ]
ret i8 %32
}