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

/* Variables and functions */
int GetMouseButton();
int ParsePos(int, int, int);
short GetCmd() {
  int c, c1;
  for (c = 255; c == 255;) {
    c = GetMouseButton();
    if (c >= 0) {
      c = ParsePos(c, -1, 0);
      c1 = ParsePos(c1, c, 1);
      if (c == c1 && (c >= 0 || c == -10)) {
        return c;
      }
      if (c >= 0 && c1 == -12) {
        return ((((((10) + 1) + 1)) + 1) << 7) | c;
      }
      c = 255;
    }
  }
}


x86 assembly (clang, -O0):
<GetCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xff,-0x8(%rbp)
cmpl   $0xff,-0x8(%rbp)
jne    11d2 <GetCmd+0xb2>
mov    $0x0,%al
call   1030 <GetMouseButton@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11cd <GetCmd+0xad>
mov    -0x8(%rbp),%edi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1040 <ParsePos@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1040 <ParsePos@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11a1 <GetCmd+0x81>
cmpl   $0x0,-0x8(%rbp)
jge    1195 <GetCmd+0x75>
cmpl   $0xfffffff6,-0x8(%rbp)
jne    11a1 <GetCmd+0x81>
mov    -0x8(%rbp),%eax
mov    %ax,-0x2(%rbp)
jmp    11d2 <GetCmd+0xb2>
cmpl   $0x0,-0x8(%rbp)
jl     11c6 <GetCmd+0xa6>
cmpl   $0xfffffff4,-0xc(%rbp)
jne    11c6 <GetCmd+0xa6>
mov    -0x8(%rbp),%eax
or     $0x680,%eax
mov    %ax,-0x2(%rbp)
jmp    11d2 <GetCmd+0xb2>
movl   $0xff,-0x8(%rbp)
jmp    112f <GetCmd+0xf>
movswl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetCmd>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <GetMouseButton@plt>
test   %eax,%eax
js     1183 <GetCmd+0x63>
jmp    113b <GetCmd+0x1b>
xor    %eax,%eax
call   1030 <GetMouseButton@plt>
test   %eax,%eax
js     1183 <GetCmd+0x63>
mov    %eax,%edi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1040 <ParsePos@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <ParsePos@plt>
cmp    %eax,%ebx
jne    1170 <GetCmd+0x50>
test   %ebx,%ebx
jns    1183 <GetCmd+0x63>
cmp    $0xfffffff6,%ebx
je     1183 <GetCmd+0x63>
mov    %ebx,%ebp
jmp    1130 <GetCmd+0x10>
nopw   0x0(%rax,%rax,1)
mov    %eax,%ebp
test   %ebx,%ebx
js     1130 <GetCmd+0x10>
cmp    $0xfffffff4,%ebp
jne    1130 <GetCmd+0x10>
or     $0x680,%ebx
jmp    1183 <GetCmd+0x63>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i16 @GetCmd() {
%1 = alloca i16
%2 = alloca i32
%3 = alloca i32
store i32 255, i32* %2
br label %4
4: ; preds = %40, %0
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 255
br i1 %6, label %7, label %41
7: ; preds = %4
%8 = call i32 (...) @GetMouseButton()
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %40
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i32 @ParsePos(i32 %12, i32 -1, i32 0)
store i32 %13, i32* %2
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = call i32 @ParsePos(i32 %14, i32 %15, i32 1)
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %11
%21 = load i32, i32* %2
%22 = icmp sge i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, -10
br i1 %25, label %26, label %29
26: ; preds = %23, %20
%27 = load i32, i32* %2
%28 = trunc i32 %27 to i16
store i16 %28, i16* %1
br label %41
29: ; preds = %23, %11
%30 = load i32, i32* %2
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, -12
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i32, i32* %2
%37 = or i32 1664, %36
%38 = trunc i32 %37 to i16
store i16 %38, i16* %1
br label %41
39: ; preds = %32, %29
store i32 255, i32* %2
br label %40
40: ; preds = %39, %7
br label %4
41: ; preds = %26, %35, %4
%42 = load i16, i16* %1
ret i16 %42
}

LLVM IR (-O2):
define signext i16 @GetCmd() {
%1 = tail call i32 (...) @GetMouseButton()
%2 = icmp sgt i32 %1, -1
br i1 %2, label %3, label %25
3: ; preds = %0, %21
%4 = phi i32 [ %23, %21 ], [ %1, %0 ]
%5 = phi i32 [ %22, %21 ], [ undef, %0 ]
%6 = tail call i32 @ParsePos(i32 %4, i32 -1, i32 0)
%7 = tail call i32 @ParsePos(i32 %5, i32 %6, i32 1)
%8 = icmp eq i32 %6, %7
%9 = icmp sgt i32 %6, -1
br i1 %8, label %10, label %15
10: ; preds = %3
%11 = icmp eq i32 %6, -10
%12 = or i1 %9, %11
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = trunc i32 %6 to i16
br label %25
15: ; preds = %3
%16 = icmp eq i32 %7, -12
%17 = select i1 %9, i1 %16, i1 false
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = trunc i32 %6 to i16
%20 = or i16 %19, 1664
br label %25
21: ; preds = %10, %15
%22 = phi i32 [ %7, %15 ], [ %6, %10 ]
%23 = tail call i32 (...) @GetMouseButton()
%24 = icmp sgt i32 %23, -1
br i1 %24, label %3, label %25
25: ; preds = %21, %0, %18, %13
%26 = phi i16 [ %14, %13 ], [ %20, %18 ], [ undef, %0 ], [ undef, %21 ]
ret i16 %26
}