#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 markov_model {
  int dummy;
};
typedef int /*<<< orphan*/ line;

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ mm_learn_file(struct markov_model *, char *);
struct markov_model *mm_new();
int /*<<< orphan*/ mm_print(struct markov_model *);
int /*<<< orphan*/ mm_respond_and_learn(struct markov_model *, char *, char *,
                                        char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
unsigned int time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i;
  char c;
  struct markov_model *model;
  char line[512];
  char response[512];
  char dump_table = 0;
  char opt_learn = 0;
  unsigned int seed = 0;
  model = mm_new();
  if (!model) {
    fprintf(stderr, "Unable to create markov model\n");
    return 1;
  }
  for (i = 1; i < argc; i++) {
    c = argv[i][1];
    if (argv[i][0] != '-' || argv[i][2]) {
      c = -1;
    }
    switch (c) {
    case 'd':
      dump_table = 1;
      break;
    case 's':
      if (++i < argc)
        seed = strtoul(argv[i], NULL, 10);
      break;
    case 'l':
      opt_learn = 1;
      break;
    case 'f':
      if (++i < argc && !mm_learn_file(model, argv[i])) {
        fprintf(stderr, "Unable to learn corpus\n");
      }
      break;
    case 'v':
      fprintf(stderr, "chains, © 2014 Charles Lehner\n");
      return 1;
    case 'h':
    default:
      fprintf(stderr,
              "Usage: chains [-h] [-v] [-s seed] [-d] [-l] [-f corpus_file]\n");
      return 1;
    }
  }
  if (!seed) {
    srand(time(NULL));
  } else if (seed != 1) {
    srand(seed);
  }
  if (dump_table) {
    mm_print(model);
    return 0;
  }
  while (!feof(stdin)) {
    printf("> ");
    if (!fgets(line, sizeof(line), stdin)) {
      break;
    }
    response[0] = '\0';
    if (!mm_respond_and_learn(model, line, response, opt_learn)) {
      fprintf(stderr, "Failed to respond\n");
    } else {
      printf("%s\n", response);
      fflush(stdout);
    }
  }
  puts("");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x421(%rbp)
movb   $0x0,-0x422(%rbp)
movl   $0x0,-0x428(%rbp)
mov    $0x0,%al
call   10e0 <mm_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1238 <main+0x68>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f0 <main+0x320>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13b5 <main+0x1e5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x1(%rax),%al
mov    %al,-0x15(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    128e <main+0xbe>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
je     1292 <main+0xc2>
movb   $0xff,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x430(%rbp)
sub    $0x12,%eax
ja     1381 <main+0x1b1>
mov    -0x430(%rbp),%rax
lea    0xd47(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x1,-0x421(%rbp)
jmp    13a2 <main+0x1d2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x8(%rbp),%eax
jge    1300 <main+0x130>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %eax,-0x428(%rbp)
jmp    13a2 <main+0x1d2>
movb   $0x1,-0x422(%rbp)
jmp    13a2 <main+0x1d2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x8(%rbp),%eax
jge    1356 <main+0x186>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10a0 <mm_learn_file@plt>
cmp    $0x0,%eax
jne    1356 <main+0x186>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
lea    0xd1a(%rip),%rsi
call   1070 <fprintf@plt>
jmp    13a2 <main+0x1d2>
mov    0x2c76(%rip),%rax
mov    (%rax),%edi
lea    0xd18(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f0 <main+0x320>
jmp    1381 <main+0x1b1>
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
lea    0xd12(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f0 <main+0x320>
jmp    13a7 <main+0x1d7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123f <main+0x6f>
cmpl   $0x0,-0x428(%rbp)
jne    13d7 <main+0x207>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
jmp    13f4 <main+0x224>
cmpl   $0x1,-0x428(%rbp)
je     13ef <main+0x21f>
mov    -0x428(%rbp),%edi
call   1050 <srand@plt>
jmp    13f4 <main+0x224>
cmpb   $0x0,-0x421(%rbp)
je     1416 <main+0x246>
mov    -0x20(%rbp),%rdi
call   10d0 <mm_print@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f0 <main+0x320>
jmp    141b <main+0x24b>
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    143e <main+0x26e>
jmp    14e4 <main+0x314>
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x220(%rbp),%rdi
mov    0x2b8e(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%eax
jne    1474 <main+0x2a4>
jmp    14e4 <main+0x314>
movb   $0x0,-0x420(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x220(%rbp),%rsi
lea    -0x420(%rbp),%rdx
movsbl -0x422(%rbp),%ecx
call   10b0 <mm_respond_and_learn@plt>
cmp    $0x0,%eax
jne    14bc <main+0x2ec>
mov    0x2b2f(%rip),%rax
mov    (%rax),%edi
lea    0xc32(%rip),%rsi
call   1070 <fprintf@plt>
jmp    14df <main+0x30f>
lea    -0x420(%rbp),%rsi
lea    0xc2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2af8(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
jmp    141b <main+0x24b>
lea    0xbf5(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   10f0 <mm_new@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1307 <main+0x127>
xor    %edi,%edi
mov    $0x0,%r12d
mov    $0x0,%r15d
cmp    $0x2,%ebp
jl     1343 <main+0x163>
mov    $0x1,%r12d
lea    0xdd1(%rip),%r13
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
jmp    1257 <main+0x77>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%al
mov    %rax,0x8(%rsp)
mov    %r14d,%r15d
add    $0x1,%r12d
cmp    %ebp,%r12d
jge    1335 <main+0x155>
movslq %r12d,%rax
mov    (%rbx,%rax,8),%rax
cmpb   $0x2d,(%rax)
jne    1319 <main+0x139>
cmpb   $0x0,0x2(%rax)
jne    1319 <main+0x139>
movsbl 0x1(%rax),%eax
add    $0xffffff9c,%eax
cmp    $0x12,%eax
ja     1319 <main+0x139>
mov    %r15d,%r14d
mov    $0x1,%r15b
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
add    $0x1,%r12d
cmp    %ebp,%r12d
jge    1247 <main+0x67>
mov    %rdi,0x18(%rsp)
movslq %r12d,%rax
mov    (%rbx,%rax,8),%rsi
mov    0x10(%rsp),%rdi
call   10b0 <mm_learn_file@plt>
test   %eax,%eax
jne    12c9 <main+0xe9>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
lea    0xda7(%rip),%rsi
call   1080 <fprintf@plt>
mov    %r14d,%r15d
mov    0x18(%rsp),%rdi
jmp    124a <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r12d
cmp    %ebp,%r12d
jge    1247 <main+0x67>
movslq %r12d,%rax
mov    (%rbx,%rax,8),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1100 <strtoul@plt>
mov    %eax,%edi
jmp    1247 <main+0x67>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
lea    0xd35(%rip),%rsi
jmp    1329 <main+0x149>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
lea    0xd7a(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    138b <main+0x1ab>
cmp    $0x1,%edi
je     1362 <main+0x182>
test   %edi,%edi
mov    0x8(%rsp),%r12
jne    134c <main+0x16c>
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
test   %r15b,%r15b
je     136c <main+0x18c>
mov    0x10(%rsp),%rdi
call   10e0 <mm_print@plt>
jmp    1389 <main+0x1a9>
mov    0x8(%rsp),%r12
test   %r15b,%r15b
jne    1356 <main+0x176>
mov    0x2c75(%rip),%r14
mov    (%r14),%edi
call   1090 <feof@plt>
test   %eax,%eax
je     139d <main+0x1bd>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd3d(%rip),%r15
lea    0x220(%rsp),%rbp
movsbl %r12b,%ebx
lea    0x20(%rsp),%r12
mov    0x2c14(%rip),%r13
jmp    13dd <main+0x1fd>
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <puts@plt>
mov    0x0(%r13),%edi
call   10d0 <fflush@plt>
mov    (%r14),%edi
call   1090 <feof@plt>
test   %eax,%eax
jne    137f <main+0x19f>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r14),%edx
mov    %rbp,%rdi
mov    $0x200,%esi
call   1070 <fgets@plt>
test   %eax,%eax
je     137f <main+0x19f>
movb   $0x0,0x20(%rsp)
mov    0x10(%rsp),%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %ebx,%ecx
call   10c0 <mm_respond_and_learn@plt>
test   %eax,%eax
jne    13c0 <main+0x1e0>
mov    0x2bb7(%rip),%rax
mov    (%rax),%edi
lea    0xcba(%rip),%rsi
call   1080 <fprintf@plt>
jmp    13d1 <main+0x1f1>
mov    0x2ba0(%rip),%rax
mov    (%rax),%edi
lea    0xc42(%rip),%rsi
jmp    1329 <main+0x149>

LLVM IR (-O0):
%struct.markov_model = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"Unable to create markov model\0A\00"
@.str.1 = [24 x i8] c"Unable to learn corpus\0A\00"
@.str.2 = [32 x i8] c"chains, \C2\A9 2014 Charles Lehner\0A\00"
@.str.3 = [62 x i8] c"Usage: chains [-h] [-v] [-s seed] [-d] [-l] [-f corpus_file]\0A\00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"> \00"
@.str.5 = [19 x i8] c"Failed to respond\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
@.str.7 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca %struct.markov_model*
%9 = alloca [512 x i8]
%10 = alloca [512 x i8]
%11 = alloca i8
%12 = alloca i8
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %11
store i8 0, i8* %12
store i32 0, i32* %13
%14 = call %struct.markov_model* (...) @mm_new()
store %struct.markov_model* %14, %struct.markov_model** %8
%15 = load %struct.markov_model*, %struct.markov_model** %8
%16 = icmp ne %struct.markov_model* %15, null
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %151
20: ; preds = %2
store i32 1, i32* %6
br label %21
21: ; preds = %97, %20
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %100
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
store i8 %32, i8* %7
%33 = load i8**, i8*** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 45
br i1 %41, label %52, label %42
42: ; preds = %25
%43 = load i8**, i8*** %5
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = getelementptr inbounds i8, i8* %47, i64 2
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %42, %25
store i8 -1, i8* %7
br label %53
53: ; preds = %52, %42
%54 = load i8, i8* %7
%55 = sext i8 %54 to i32
switch i32 %55, label %93 [
i32 100, label %56
i32 115, label %57
i32 108, label %70
i32 102, label %71
i32 118, label %89
i32 104, label %92
]
56: ; preds = %53
store i8 1, i8* %11
br label %96
57: ; preds = %53
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
%60 = load i32, i32* %4
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %69
62: ; preds = %57
%63 = load i8**, i8*** %5
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 @strtoul(i8* %67, i32* null, i32 10)
store i32 %68, i32* %13
br label %69
69: ; preds = %62, %57
br label %96
70: ; preds = %53
store i8 1, i8* %12
br label %96
71: ; preds = %53
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %6
%74 = load i32, i32* %4
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %88
76: ; preds = %71
%77 = load %struct.markov_model*, %struct.markov_model** %8
%78 = load i8**, i8*** %5
%79 = load i32, i32* %6
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
%82 = load i8*, i8** %81
%83 = call i32 @mm_learn_file(%struct.markov_model* %77, i8* %82)
%84 = icmp ne i32 %83, 0
br i1 %84, label %88, label %85
85: ; preds = %76
%86 = load i32, i32* @stderr
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %88
88: ; preds = %85, %76, %71
br label %96
89: ; preds = %53
%90 = load i32, i32* @stderr
%91 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %151
92: ; preds = %53
br label %93
93: ; preds = %53, %92
%94 = load i32, i32* @stderr
%95 = call i32 @fprintf(i32 %94, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %151
96: ; preds = %88, %70, %69, %56
br label %97
97: ; preds = %96
%98 = load i32, i32* %6
%99 = add nsw i32 %98, 1
store i32 %99, i32* %6
br label %21
100: ; preds = %21
%101 = load i32, i32* %13
%102 = icmp ne i32 %101, 0
br i1 %102, label %106, label %103
103: ; preds = %100
%104 = call i32 @time(i32* null)
%105 = call i32 @srand(i32 %104)
br label %113
106: ; preds = %100
%107 = load i32, i32* %13
%108 = icmp ne i32 %107, 1
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = load i32, i32* %13
%111 = call i32 @srand(i32 %110)
br label %112
112: ; preds = %109, %106
br label %113
113: ; preds = %112, %103
%114 = load i8, i8* %11
%115 = icmp ne i8 %114, 0
br i1 %115, label %116, label %119
116: ; preds = %113
%117 = load %struct.markov_model*, %struct.markov_model** %8
%118 = call i32 @mm_print(%struct.markov_model* %117)
store i32 0, i32* %3
br label %151
119: ; preds = %113
br label %120
120: ; preds = %148, %119
%121 = load i32, i32* @stdin
%122 = call i32 @feof(i32 %121)
%123 = icmp ne i32 %122, 0
%124 = xor i1 %123, true
br i1 %124, label %125, label %149
125: ; preds = %120
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%127 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%128 = load i32, i32* @stdin
%129 = call i32 @fgets(i8* %127, i32 512, i32 %128)
%130 = icmp ne i32 %129, 0
br i1 %130, label %132, label %131
131: ; preds = %125
br label %149
132: ; preds = %125
%133 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
store i8 0, i8* %133
%134 = load %struct.markov_model*, %struct.markov_model** %8
%135 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%136 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%137 = load i8, i8* %12
%138 = call i32 @mm_respond_and_learn(%struct.markov_model* %134, i8* %135, i8* %136, i8 signext %137)
%139 = icmp ne i32 %138, 0
br i1 %139, label %143, label %140
140: ; preds = %132
%141 = load i32, i32* @stderr
%142 = call i32 @fprintf(i32 %141, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %148
143: ; preds = %132
%144 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %144)
%146 = load i32, i32* @stdout
%147 = call i32 @fflush(i32 %146)
br label %148
148: ; preds = %143, %140
br label %120
149: ; preds = %131, %120
%150 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %151
151: ; preds = %149, %116, %93, %89, %17
%152 = load i32, i32* %3
ret i32 %152
}

LLVM IR (-O2):
%struct.markov_model = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"Unable to create markov model\0A\00"
@.str.1 = [24 x i8] c"Unable to learn corpus\0A\00"
@.str.2 = [32 x i8] c"chains, \C2\A9 2014 Charles Lehner\0A\00"
@.str.3 = [62 x i8] c"Usage: chains [-h] [-v] [-s seed] [-d] [-l] [-f corpus_file]\0A\00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"> \00"
@.str.5 = [19 x i8] c"Failed to respond\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = tail call %struct.markov_model* (...) @mm_new()
%8 = icmp eq %struct.markov_model* %7, null
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = icmp sgt i32 %0, 1
br i1 %10, label %14, label %67
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %107
14: ; preds = %9, %59
%15 = phi i32 [ %63, %59 ], [ 0, %9 ]
%16 = phi i8 [ %62, %59 ], [ 0, %9 ]
%17 = phi i8 [ %61, %59 ], [ 0, %9 ]
%18 = phi i32 [ %64, %59 ], [ 1, %9 ]
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 45
br i1 %23, label %24, label %56
24: ; preds = %14
%25 = getelementptr inbounds i8, i8* %21, i64 2
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %56
28: ; preds = %24
%29 = getelementptr inbounds i8, i8* %21, i64 1
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
switch i32 %31, label %56 [
i32 100, label %59
i32 115, label %32
i32 108, label %40
i32 102, label %41
i32 118, label %53
]
32: ; preds = %28
%33 = add nsw i32 %18, 1
%34 = icmp slt i32 %33, %0
br i1 %34, label %35, label %59
35: ; preds = %32
%36 = sext i32 %33 to i64
%37 = getelementptr inbounds i8*, i8** %1, i64 %36
%38 = load i8*, i8** %37
%39 = tail call i32 @strtoul(i8* nocapture %38, i32* null, i32 10)
br label %59
40: ; preds = %28
br label %59
41: ; preds = %28
%42 = add nsw i32 %18, 1
%43 = icmp slt i32 %42, %0
br i1 %43, label %44, label %59
44: ; preds = %41
%45 = sext i32 %42 to i64
%46 = getelementptr inbounds i8*, i8** %1, i64 %45
%47 = load i8*, i8** %46
%48 = tail call i32 @mm_learn_file(%struct.markov_model* %7, i8* %47)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %59
50: ; preds = %44
%51 = load i32, i32* @stderr
%52 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %59
53: ; preds = %28
%54 = load i32, i32* @stderr
%55 = tail call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %107
56: ; preds = %24, %14, %28
%57 = load i32, i32* @stderr
%58 = tail call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0))
br label %107
59: ; preds = %28, %40, %35, %32, %50, %44, %41
%60 = phi i32 [ %42, %44 ], [ %42, %50 ], [ %42, %41 ], [ %18, %40 ], [ %33, %35 ], [ %33, %32 ], [ %18, %28 ]
%61 = phi i8 [ %17, %44 ], [ %17, %50 ], [ %17, %41 ], [ %17, %40 ], [ %17, %35 ], [ %17, %32 ], [ 1, %28 ]
%62 = phi i8 [ %16, %44 ], [ %16, %50 ], [ %16, %41 ], [ 1, %40 ], [ %16, %35 ], [ %16, %32 ], [ %16, %28 ]
%63 = phi i32 [ %15, %44 ], [ %15, %50 ], [ %15, %41 ], [ %15, %40 ], [ %39, %35 ], [ %15, %32 ], [ %15, %28 ]
%64 = add nsw i32 %60, 1
%65 = icmp slt i32 %64, %0
br i1 %65, label %14, label %66
66: ; preds = %59
switch i32 %63, label %71 [
i32 0, label %67
i32 1, label %76
]
67: ; preds = %9, %66
%68 = phi i8 [ %62, %66 ], [ 0, %9 ]
%69 = phi i8 [ %61, %66 ], [ 0, %9 ]
%70 = tail call i32 @time(i32* null)
br label %71
71: ; preds = %66, %67
%72 = phi i32 [ %70, %67 ], [ %63, %66 ]
%73 = phi i8 [ %68, %67 ], [ %62, %66 ]
%74 = phi i8 [ %69, %67 ], [ %61, %66 ]
%75 = tail call i32 @srand(i32 %72)
br label %76
76: ; preds = %71, %66
%77 = phi i8 [ %62, %66 ], [ %73, %71 ]
%78 = phi i8 [ %61, %66 ], [ %74, %71 ]
%79 = icmp eq i8 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %76
%81 = load i32, i32* @stdin
%82 = call i32 @feof(i32 %81)
%83 = icmp eq i32 %82, 0
br i1 %83, label %86, label %105
84: ; preds = %76
%85 = tail call i32 @mm_print(%struct.markov_model* %7)
br label %107
86: ; preds = %80, %101
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%88 = load i32, i32* @stdin
%89 = call i32 @fgets(i8* %5, i32 512, i32 %88)
%90 = icmp eq i32 %89, 0
br i1 %90, label %105, label %91
91: ; preds = %86
store i8 0, i8* %6
%92 = call i32 @mm_respond_and_learn(%struct.markov_model* %7, i8* %5, i8* %6, i8 signext %77)
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %91
%95 = load i32, i32* @stderr
%96 = call i32 @fprintf(i32 %95, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %101
97: ; preds = %91
%98 = call i32 @puts(i8* %6)
%99 = load i32, i32* @stdout
%100 = call i32 @fflush(i32 %99)
br label %101
101: ; preds = %97, %94
%102 = load i32, i32* @stdin
%103 = call i32 @feof(i32 %102)
%104 = icmp eq i32 %103, 0
br i1 %104, label %86, label %105
105: ; preds = %101, %86, %80
%106 = call i32 @putchar(i32 10)
br label %107
107: ; preds = %105, %84, %56, %53, %11
%108 = phi i32 [ 1, %56 ], [ 1, %53 ], [ 0, %84 ], [ 0, %105 ], [ 1, %11 ]
ret i32 %108
}