#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 atoi(char *);
int /*<<< orphan*/ db_init(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ play();
int /*<<< orphan*/ trm_init(int, int, char *);
int /*<<< orphan*/ writes(char *);
void main(int argc, char *argv[]) {
  char *fname, *lname;
  int rows, cols, i;
  writes("ADVINT v1.2 - Copyright (c) 1986, by David Betz\n");
  writes("ANSI-fied by Matt Ackeret (unknown@apple.com or "
         "unknown@ucscb.ucsc.edu).\n");
  writes("ANSI-compliant source is available on ftp.gmd.de (mirrored "
         "on\nwuarchive.wustl.edu). "
         "Other games are available there also.\n");
  fname = NULL;
  lname = NULL;
  rows = 24;
  cols = 80;
  for (i = 1; i < argc; i++)
    if (argv[i][0] == '-')
      switch (argv[i][1]) {
      case 'r':
      case 'R':
        rows = atoi(&argv[i][2]);
        break;
      case 'c':
      case 'C':
        cols = atoi(&argv[i][2]);
        break;
      case 'l':
      case 'L':
        lname = &argv[i][2];
        break;
      }
    else
      fname = argv[i];
  if (fname == NULL) {
    writes("usage: advint [-r<rows>] [-c<columns>] [-l<log-file>] <file>\n");
    exit(1);
  }
  trm_init(rows, cols, lname);
  db_init(fname);
  play();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe8a(%rip),%rdi
call   1040 <writes@plt>
lea    0xeaf(%rip),%rdi
call   1040 <writes@plt>
lea    0xeed(%rip),%rdi
call   1040 <writes@plt>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x18,-0x24(%rbp)
movl   $0x50,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c8 <main+0x168>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12a5 <main+0x145>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x30(%rbp)
sub    $0x43,%eax
je     126f <main+0x10f>
jmp    11fd <main+0x9d>
mov    -0x30(%rbp),%eax
sub    $0x4c,%eax
je     128c <main+0x12c>
jmp    120e <main+0xae>
mov    -0x30(%rbp),%eax
sub    $0x52,%eax
je     1252 <main+0xf2>
jmp    121f <main+0xbf>
mov    -0x30(%rbp),%eax
sub    $0x63,%eax
je     126f <main+0x10f>
jmp    1230 <main+0xd0>
mov    -0x30(%rbp),%eax
sub    $0x6c,%eax
je     128c <main+0x12c>
jmp    1241 <main+0xe1>
mov    -0x30(%rbp),%eax
sub    $0x72,%eax
jne    12a0 <main+0x140>
jmp    1252 <main+0xf2>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x2,%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    12a0 <main+0x140>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x2,%rdi
call   1070 <atoi@plt>
mov    %eax,-0x28(%rbp)
jmp    12a0 <main+0x140>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    12b5 <main+0x155>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
jmp    12ba <main+0x15a>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b8 <main+0x58>
cmpq   $0x0,-0x18(%rbp)
jne    12e9 <main+0x189>
lea    0xe1c(%rip),%rdi
call   1040 <writes@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1050 <trm_init@plt>
mov    -0x18(%rbp),%rdi
call   1030 <db_init@plt>
mov    $0x0,%al
call   1060 <play@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe86(%rip),%rdi
call   1040 <writes@plt>
lea    0xeab(%rip),%rdi
call   1040 <writes@plt>
lea    0xee9(%rip),%rdi
call   1040 <writes@plt>
cmp    $0x2,%ebp
jl     1272 <main+0x112>
mov    %ebp,%ebp
mov    $0x18,%r13d
movl   $0x50,0xc(%rsp)
mov    $0x1,%r14d
xor    %eax,%eax
mov    %rax,0x10(%rsp)
movabs $0x100000001,%r12
xor    %r15d,%r15d
jmp    11dc <main+0x7c>
nopl   0x0(%rax)
mov    %rdi,%r15
add    $0x1,%r14
cmp    %r14,%rbp
je     123f <main+0xdf>
mov    (%rbx,%r14,8),%rdi
cmpb   $0x2d,(%rdi)
jne    11d0 <main+0x70>
movsbl 0x1(%rdi),%eax
add    $0xffffffbd,%eax
cmp    $0x2f,%eax
ja     11d3 <main+0x73>
bt     %rax,%r12
jb     1230 <main+0xd0>
movabs $0x20000000200,%rcx
bt     %rax,%rcx
jb     1225 <main+0xc5>
movabs $0x800000008000,%rcx
bt     %rax,%rcx
jae    11d3 <main+0x73>
add    $0x2,%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
jmp    11d3 <main+0x73>
add    $0x2,%rdi
mov    %rdi,0x10(%rsp)
jmp    11d3 <main+0x73>
add    $0x2,%rdi
call   1070 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    11d3 <main+0x73>
test   %r15,%r15
je     1272 <main+0x112>
mov    %r13d,%edi
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%rdx
call   1050 <trm_init@plt>
mov    %r15,%rdi
call   1030 <db_init@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <play@plt>
lea    0xe7d(%rip),%rdi
call   1040 <writes@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"ADVINT v1.2 - Copyright (c) 1986, by David Betz\0A\00"
@.str.1 = [74 x i8] c"ANSI-fied by Matt Ackeret (unknown@apple.com or unknown@ucscb.ucsc.edu).\0A\00"
@.str.2 = [123 x i8] c"ANSI-compliant source is available on ftp.gmd.de (mirrored on\0Awuarchive.wustl.edu). Other games are available there also.\0A\00"
@.str.3 = [62 x i8] c"usage: advint [-r<rows>] [-c<columns>] [-l<log-file>] <file>\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = call i32 @writes(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @writes(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @writes(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %5
store i8* null, i8** %6
store i32 24, i32* %7
store i32 80, i32* %8
store i32 1, i32* %9
br label %13
13: ; preds = %67, %2
%14 = load i32, i32* %9
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %70
17: ; preds = %13
%18 = load i8**, i8*** %4
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 45
br i1 %26, label %27, label %60
27: ; preds = %17
%28 = load i8**, i8*** %4
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
switch i32 %35, label %59 [
i32 114, label %36
i32 82, label %36
i32 99, label %44
i32 67, label %44
i32 108, label %52
i32 76, label %52
]
36: ; preds = %27, %27
%37 = load i8**, i8*** %4
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = getelementptr inbounds i8, i8* %41, i64 2
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* %7
br label %59
44: ; preds = %27, %27
%45 = load i8**, i8*** %4
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8, i8* %49, i64 2
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %8
br label %59
52: ; preds = %27, %27
%53 = load i8**, i8*** %4
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 2
store i8* %58, i8** %6
br label %59
59: ; preds = %27, %52, %44, %36
br label %66
60: ; preds = %17
%61 = load i8**, i8*** %4
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
store i8* %65, i8** %5
br label %66
66: ; preds = %60, %59
br label %67
67: ; preds = %66
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
br label %13
70: ; preds = %13
%71 = load i8*, i8** %5
%72 = icmp eq i8* %71, null
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = call i32 @writes(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %70
%77 = load i32, i32* %7
%78 = load i32, i32* %8
%79 = load i8*, i8** %6
%80 = call i32 @trm_init(i32 %77, i32 %78, i8* %79)
%81 = load i8*, i8** %5
%82 = call i32 @db_init(i8* %81)
%83 = call i32 (...) @play()
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"ADVINT v1.2 - Copyright (c) 1986, by David Betz\0A\00"
@.str.1 = [74 x i8] c"ANSI-fied by Matt Ackeret (unknown@apple.com or unknown@ucscb.ucsc.edu).\0A\00"
@.str.2 = [123 x i8] c"ANSI-compliant source is available on ftp.gmd.de (mirrored on\0Awuarchive.wustl.edu). Other games are available there also.\0A\00"
@.str.3 = [62 x i8] c"usage: advint [-r<rows>] [-c<columns>] [-l<log-file>] <file>\0A\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @writes(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @writes(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @writes(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %40
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %31
%10 = phi i64 [ 1, %7 ], [ %36, %31 ]
%11 = phi i32 [ 80, %7 ], [ %35, %31 ]
%12 = phi i32 [ 24, %7 ], [ %34, %31 ]
%13 = phi i8* [ null, %7 ], [ %33, %31 ]
%14 = phi i8* [ null, %7 ], [ %32, %31 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %10
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 45
br i1 %18, label %19, label %31
19: ; preds = %9
%20 = getelementptr inbounds i8, i8* %16, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %31 [
i32 114, label %23
i32 82, label %23
i32 99, label %26
i32 67, label %26
i32 108, label %29
i32 76, label %29
]
23: ; preds = %19, %19
%24 = getelementptr inbounds i8, i8* %16, i64 2
%25 = tail call i32 @atoi(i8* %24)
br label %31
26: ; preds = %19, %19
%27 = getelementptr inbounds i8, i8* %16, i64 2
%28 = tail call i32 @atoi(i8* %27)
br label %31
29: ; preds = %19, %19
%30 = getelementptr inbounds i8, i8* %16, i64 2
br label %31
31: ; preds = %9, %19, %29, %26, %23
%32 = phi i8* [ %14, %19 ], [ %14, %29 ], [ %14, %26 ], [ %14, %23 ], [ %16, %9 ]
%33 = phi i8* [ %13, %19 ], [ %30, %29 ], [ %13, %26 ], [ %13, %23 ], [ %13, %9 ]
%34 = phi i32 [ %12, %19 ], [ %12, %29 ], [ %12, %26 ], [ %25, %23 ], [ %12, %9 ]
%35 = phi i32 [ %11, %19 ], [ %11, %29 ], [ %28, %26 ], [ %11, %23 ], [ %11, %9 ]
%36 = add nuw nsw i64 %10, 1
%37 = icmp eq i64 %36, %8
br i1 %37, label %38, label %9
38: ; preds = %31
%39 = icmp eq i8* %32, null
br i1 %39, label %40, label %43
40: ; preds = %2, %38
%41 = tail call i32 @writes(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0))
%42 = tail call i32 @exit(i32 1)
unreachable
43: ; preds = %38
%44 = tail call i32 @trm_init(i32 %34, i32 %35, i8* %33)
%45 = tail call i32 @db_init(i8* %32)
%46 = tail call i32 (...) @play()
ret void
}