#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 */
scalar_t__ spaceball_cmd(int, char *, char *);
scalar_t__ spaceball_waitchar(int, int, char *, int);
scalar_t__ spaceball_waitcmd(int, char, char *);
scalar_t__ strncmp(char *, char *, int);
scalar_t__ strstr(char *, char *);
int spaceball_init(int fd, long *id, long *extra) {
  char r[64];
  if (spaceball_waitchar(fd, 0x11, r, 4000) ||
      spaceball_waitchar(fd, 0x0d, r, 1000))
    return -1;
  if (spaceball_waitcmd(fd, '@', r))
    return -1;
  if (strncmp("@1 Spaceball alive", r, 18))
    return -1;
  if (spaceball_waitcmd(fd, '@', r))
    return -1;
  if (spaceball_cmd(fd, "hm", r))
    return -1;
  if (!strncmp("Hm2003B", r, 7))
    *id = 3;
  if (!strncmp("Hm2003C", r, 7))
    *id = 4;
  if (!strncmp("Hm3003C", r, 7))
    *id = 7;
  if (!strncmp("HvFirmware", r, 10)) {
    if (spaceball_cmd(fd, "\"", r))
      return -1;
    if (strncmp("\"1 Spaceball 4000 FLX", r, 21))
      return -1;
    if (spaceball_waitcmd(fd, '"', r))
      return -1;
    if (strstr(r, " L "))
      *id = 9;
    else
      *id = 8;
    if (spaceball_waitcmd(fd, '"', r))
      return -1;
    if (spaceball_cmd(fd, "YS", r))
      return -1;
    if (spaceball_cmd(fd, "M", r))
      return -1;
    return 0;
  }
  if (spaceball_cmd(fd, "P@A@A", r) || spaceball_cmd(fd, "FT@", r) ||
      spaceball_cmd(fd, "MSS", r))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<spaceball_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
mov    $0x11,%esi
mov    $0xfa0,%ecx
call   1050 <spaceball_waitchar@plt>
cmp    $0x0,%rax
jne    11a3 <spaceball_init+0x53>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
mov    $0xd,%esi
mov    $0x3e8,%ecx
call   1050 <spaceball_waitchar@plt>
cmp    $0x0,%rax
je     11af <spaceball_init+0x5f>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
mov    $0x40,%esi
call   1060 <spaceball_waitcmd@plt>
cmp    $0x0,%rax
je     11d6 <spaceball_init+0x86>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
lea    -0x60(%rbp),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x12,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1201 <spaceball_init+0xb1>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
mov    $0x40,%esi
call   1060 <spaceball_waitcmd@plt>
cmp    $0x0,%rax
je     1228 <spaceball_init+0xd8>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
lea    0xddd(%rip),%rsi
call   1040 <spaceball_cmd@plt>
cmp    $0x0,%rax
je     1251 <spaceball_init+0x101>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
lea    -0x60(%rbp),%rsi
lea    0xdba(%rip),%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    127b <spaceball_init+0x12b>
mov    -0x10(%rbp),%rax
movq   $0x3,(%rax)
lea    -0x60(%rbp),%rsi
lea    0xd98(%rip),%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12a5 <spaceball_init+0x155>
mov    -0x10(%rbp),%rax
movq   $0x4,(%rax)
lea    -0x60(%rbp),%rsi
lea    0xd76(%rip),%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12cf <spaceball_init+0x17f>
mov    -0x10(%rbp),%rax
movq   $0x7,(%rax)
lea    -0x60(%rbp),%rsi
lea    0xd54(%rip),%rdi
mov    $0xa,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1423 <spaceball_init+0x2d3>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
lea    0xd3d(%rip),%rsi
call   1040 <spaceball_cmd@plt>
cmp    $0x0,%rax
je     1317 <spaceball_init+0x1c7>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
lea    -0x60(%rbp),%rsi
lea    0xd19(%rip),%rdi
mov    $0x15,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1342 <spaceball_init+0x1f2>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
mov    $0x22,%esi
call   1060 <spaceball_waitcmd@plt>
cmp    $0x0,%rax
je     1369 <spaceball_init+0x219>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
lea    -0x60(%rbp),%rdi
lea    0xcdd(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1393 <spaceball_init+0x243>
mov    -0x10(%rbp),%rax
movq   $0x9,(%rax)
jmp    139e <spaceball_init+0x24e>
mov    -0x10(%rbp),%rax
movq   $0x8,(%rax)
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
mov    $0x22,%esi
call   1060 <spaceball_waitcmd@plt>
cmp    $0x0,%rax
je     13c5 <spaceball_init+0x275>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
lea    0xc82(%rip),%rsi
call   1040 <spaceball_cmd@plt>
cmp    $0x0,%rax
je     13ee <spaceball_init+0x29e>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
lea    0xc5c(%rip),%rsi
call   1040 <spaceball_cmd@plt>
cmp    $0x0,%rax
je     1417 <spaceball_init+0x2c7>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
movl   $0x0,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
lea    0xc29(%rip),%rsi
call   1040 <spaceball_cmd@plt>
cmp    $0x0,%rax
jne    147a <spaceball_init+0x32a>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
lea    0xc12(%rip),%rsi
call   1040 <spaceball_cmd@plt>
cmp    $0x0,%rax
jne    147a <spaceball_init+0x32a>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
lea    0xbf9(%rip),%rsi
call   1040 <spaceball_cmd@plt>
cmp    $0x0,%rax
je     1486 <spaceball_init+0x336>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <spaceball_init+0x33d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spaceball_init>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rsp,%rdx
mov    $0x11,%esi
mov    $0xfa0,%ecx
call   1050 <spaceball_waitchar@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
mov    %rsp,%rdx
mov    %ebp,%edi
mov    $0xd,%esi
mov    $0x3e8,%ecx
call   1050 <spaceball_waitchar@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
mov    %rsp,%rdx
mov    %ebp,%edi
mov    $0x40,%esi
call   1060 <spaceball_waitcmd@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
lea    0xe51(%rip),%rdi
mov    %rsp,%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
mov    %rsp,%rdx
mov    %ebp,%edi
mov    $0x40,%esi
call   1060 <spaceball_waitcmd@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
lea    0xe37(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1040 <spaceball_cmd@plt>
test   %rax,%rax
je     11f8 <spaceball_init+0xa8>
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe17(%rip),%rdi
mov    %rsp,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1218 <spaceball_init+0xc8>
movq   $0x3,(%r14)
lea    0xdff(%rip),%rdi
mov    %rsp,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1238 <spaceball_init+0xe8>
movq   $0x4,(%r14)
lea    0xde7(%rip),%rdi
mov    %rsp,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1258 <spaceball_init+0x108>
movq   $0x7,(%r14)
lea    0xdcf(%rip),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12c0 <spaceball_init+0x170>
lea    0xde2(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1040 <spaceball_cmd@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
lea    0xdce(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1040 <spaceball_cmd@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
lea    0xdb8(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1040 <spaceball_cmd@plt>
neg    %rax
sbb    %ebx,%ebx
jmp    11eb <spaceball_init+0x9b>
lea    0xd72(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1040 <spaceball_cmd@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
lea    0xd5a(%rip),%rdi
mov    %rsp,%rsi
mov    $0x15,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
mov    %rsp,%rdx
mov    %ebp,%edi
mov    $0x22,%esi
call   1060 <spaceball_waitcmd@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
lea    0xd3b(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1070 <strstr@plt>
cmp    $0x1,%rax
mov    $0x9,%eax
sbb    $0x0,%rax
mov    %rax,(%r14)
mov    %ebp,%edi
mov    $0x22,%esi
mov    %r15,%rdx
call   1060 <spaceball_waitcmd@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
lea    0xd05(%rip),%rsi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1040 <spaceball_cmd@plt>
test   %rax,%rax
jne    11eb <spaceball_init+0x9b>
lea    0xcee(%rip),%rsi
jmp    12ac <spaceball_init+0x15c>

LLVM IR (-O0):
@.str = [19 x i8] c"@1 Spaceball alive\00"
@.str.1 = [3 x i8] c"hm\00"
@.str.2 = [8 x i8] c"Hm2003B\00"
@.str.3 = [8 x i8] c"Hm2003C\00"
@.str.4 = [8 x i8] c"Hm3003C\00"
@.str.5 = [11 x i8] c"HvFirmware\00"
@.str.6 = [2 x i8] c"\22\00"
@.str.7 = [22 x i8] c"\221 Spaceball 4000 FLX\00"
@.str.8 = [4 x i8] c" L \00"
@.str.9 = [3 x i8] c"YS\00"
@.str.10 = [2 x i8] c"M\00"
@.str.11 = [6 x i8] c"P@A@A\00"
@.str.12 = [4 x i8] c"FT@\00"
@.str.13 = [4 x i8] c"MSS\00"
define i32 @spaceball_init(i32 %0, i64* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca [64 x i8]
store i32 %0, i32* %5
store i64* %1, i64** %6
store i64* %2, i64** %7
%9 = load i32, i32* %5
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%11 = call i64 @spaceball_waitchar(i32 %9, i32 17, i8* %10, i32 4000)
%12 = icmp ne i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %3
%14 = load i32, i32* %5
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%16 = call i64 @spaceball_waitchar(i32 %14, i32 13, i8* %15, i32 1000)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13, %3
store i32 -1, i32* %4
br label %125
19: ; preds = %13
%20 = load i32, i32* %5
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%22 = call i64 @spaceball_waitcmd(i32 %20, i8 signext 64, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 -1, i32* %4
br label %125
25: ; preds = %19
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%27 = call i64 @strncmp(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %26, i32 18)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 -1, i32* %4
br label %125
30: ; preds = %25
%31 = load i32, i32* %5
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%33 = call i64 @spaceball_waitcmd(i32 %31, i8 signext 64, i8* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 -1, i32* %4
br label %125
36: ; preds = %30
%37 = load i32, i32* %5
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%39 = call i64 @spaceball_cmd(i32 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %36
store i32 -1, i32* %4
br label %125
42: ; preds = %36
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%44 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %43, i32 7)
%45 = icmp ne i64 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %42
%47 = load i64*, i64** %6
store i64 3, i64* %47
br label %48
48: ; preds = %46, %42
%49 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%50 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %49, i32 7)
%51 = icmp ne i64 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %48
%53 = load i64*, i64** %6
store i64 4, i64* %53
br label %54
54: ; preds = %52, %48
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%56 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %55, i32 7)
%57 = icmp ne i64 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %54
%59 = load i64*, i64** %6
store i64 7, i64* %59
br label %60
60: ; preds = %58, %54
%61 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%62 = call i64 @strncmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %61, i32 10)
%63 = icmp ne i64 %62, 0
br i1 %63, label %108, label %64
64: ; preds = %60
%65 = load i32, i32* %5
%66 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%67 = call i64 @spaceball_cmd(i32 %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %64
store i32 -1, i32* %4
br label %125
70: ; preds = %64
%71 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%72 = call i64 @strncmp(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %71, i32 21)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %70
store i32 -1, i32* %4
br label %125
75: ; preds = %70
%76 = load i32, i32* %5
%77 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%78 = call i64 @spaceball_waitcmd(i32 %76, i8 signext 34, i8* %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %75
store i32 -1, i32* %4
br label %125
81: ; preds = %75
%82 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%83 = call i64 @strstr(i8* %82, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %81
%86 = load i64*, i64** %6
store i64 9, i64* %86
br label %89
87: ; preds = %81
%88 = load i64*, i64** %6
store i64 8, i64* %88
br label %89
89: ; preds = %87, %85
%90 = load i32, i32* %5
%91 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%92 = call i64 @spaceball_waitcmd(i32 %90, i8 signext 34, i8* %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %95
94: ; preds = %89
store i32 -1, i32* %4
br label %125
95: ; preds = %89
%96 = load i32, i32* %5
%97 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%98 = call i64 @spaceball_cmd(i32 %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %97)
%99 = icmp ne i64 %98, 0
br i1 %99, label %100, label %101
100: ; preds = %95
store i32 -1, i32* %4
br label %125
101: ; preds = %95
%102 = load i32, i32* %5
%103 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%104 = call i64 @spaceball_cmd(i32 %102, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* %103)
%105 = icmp ne i64 %104, 0
br i1 %105, label %106, label %107
106: ; preds = %101
store i32 -1, i32* %4
br label %125
107: ; preds = %101
store i32 0, i32* %4
br label %125
108: ; preds = %60
%109 = load i32, i32* %5
%110 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%111 = call i64 @spaceball_cmd(i32 %109, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %110)
%112 = icmp ne i64 %111, 0
br i1 %112, label %123, label %113
113: ; preds = %108
%114 = load i32, i32* %5
%115 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%116 = call i64 @spaceball_cmd(i32 %114, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %115)
%117 = icmp ne i64 %116, 0
br i1 %117, label %123, label %118
118: ; preds = %113
%119 = load i32, i32* %5
%120 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%121 = call i64 @spaceball_cmd(i32 %119, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %120)
%122 = icmp ne i64 %121, 0
br i1 %122, label %123, label %124
123: ; preds = %118, %113, %108
store i32 -1, i32* %4
br label %125
124: ; preds = %118
store i32 0, i32* %4
br label %125
125: ; preds = %124, %123, %107, %106, %100, %94, %80, %74, %69, %41, %35, %29, %24, %18
%126 = load i32, i32* %4
ret i32 %126
}

LLVM IR (-O2):
@.str = [19 x i8] c"@1 Spaceball alive\00"
@.str.1 = [3 x i8] c"hm\00"
@.str.2 = [8 x i8] c"Hm2003B\00"
@.str.3 = [8 x i8] c"Hm2003C\00"
@.str.4 = [8 x i8] c"Hm3003C\00"
@.str.5 = [11 x i8] c"HvFirmware\00"
@.str.6 = [2 x i8] c"\22\00"
@.str.7 = [22 x i8] c"\221 Spaceball 4000 FLX\00"
@.str.8 = [4 x i8] c" L \00"
@.str.9 = [3 x i8] c"YS\00"
@.str.10 = [2 x i8] c"M\00"
@.str.11 = [6 x i8] c"P@A@A\00"
@.str.12 = [4 x i8] c"FT@\00"
@.str.13 = [4 x i8] c"MSS\00"
define i32 @spaceball_init(i32 %0, i64* nocapture writeonly %1, i64* nocapture readnone %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = call i64 @spaceball_waitchar(i32 %0, i32 17, i8* %5, i32 4000)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %67
8: ; preds = %3
%9 = call i64 @spaceball_waitchar(i32 %0, i32 13, i8* %5, i32 1000)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %67
11: ; preds = %8
%12 = call i64 @spaceball_waitcmd(i32 %0, i8 signext 64, i8* %5)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %67
14: ; preds = %11
%15 = call i64 @strncmp(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %5, i32 18)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %67
17: ; preds = %14
%18 = call i64 @spaceball_waitcmd(i32 %0, i8 signext 64, i8* %5)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %67
20: ; preds = %17
%21 = call i64 @spaceball_cmd(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %67
23: ; preds = %20
%24 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 7)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23
store i64 3, i64* %1
br label %27
27: ; preds = %26, %23
%28 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %5, i32 7)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %27
store i64 4, i64* %1
br label %31
31: ; preds = %30, %27
%32 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %5, i32 7)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %31
store i64 7, i64* %1
br label %35
35: ; preds = %34, %31
%36 = call i64 @strncmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %5, i32 10)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %56
38: ; preds = %35
%39 = call i64 @spaceball_cmd(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %67
41: ; preds = %38
%42 = call i64 @strncmp(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %5, i32 21)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %67
44: ; preds = %41
%45 = call i64 @spaceball_waitcmd(i32 %0, i8 signext 34, i8* %5)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %67
47: ; preds = %44
%48 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
%50 = select i1 %49, i64 8, i64 9
store i64 %50, i64* %1
%51 = call i64 @spaceball_waitcmd(i32 %0, i8 signext 34, i8* %5)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %67
53: ; preds = %47
%54 = call i64 @spaceball_cmd(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %5)
%55 = icmp eq i64 %54, 0
br i1 %55, label %62, label %67
56: ; preds = %35
%57 = call i64 @spaceball_cmd(i32 %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %5)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %67
59: ; preds = %56
%60 = call i64 @spaceball_cmd(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %5)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %59, %53
%63 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), %53 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), %59 ]
%64 = call i64 @spaceball_cmd(i32 %0, i8* %63, i8* %5)
%65 = icmp ne i64 %64, 0
%66 = sext i1 %65 to i32
br label %67
67: ; preds = %62, %56, %59, %53, %47, %44, %41, %38, %20, %17, %14, %11, %3, %8
%68 = phi i32 [ -1, %8 ], [ -1, %3 ], [ -1, %11 ], [ -1, %14 ], [ -1, %17 ], [ -1, %20 ], [ -1, %38 ], [ -1, %41 ], [ -1, %44 ], [ -1, %47 ], [ -1, %53 ], [ -1, %59 ], [ -1, %56 ], [ %66, %62 ]
ret i32 %68
}