// File: /workspace/github_cpp_makefile_star2_O2/elarielcl[P]ArielsSequitur/Sequitur.cpp
// Function: main
int main(int argc, char **argv) {
  extern char *optarg;
  extern int optind, opterr;
  FILE *fp = stdin;

  int c;

  while ((c = getopt(argc, argv, "f:")) != -1) {
    switch (c) {
      case 'f':
      fp = fopen(optarg, "r");
      if (fp == NULL) {
        cerr << "Error oppening \"" << optarg << "\" file" << endl;
        exit(1);
      } break;
    }
  }

  SequiturGrammar grammar;
  while (!feof(fp)) {
    int c = fgetc(fp);
    if (c == EOF) break;
    grammar.put(c);
  }

  fprintf (stderr,"\nSequitur succeeded\n\n");
  fprintf (stderr,"Grammar\n\n");
  grammar.print();

  fprintf (stderr,"Original chars: %i\n",grammar.inputSize);
  fprintf (stderr,"Number of rules: %i\n",grammar.numberOfRules);
  fprintf (stderr,"Grammar Size: %i\n",grammar.grammarSize);
  fprintf (stderr,"Compression ratio: %0.2f%%\n",
			100.0*blog(grammar.M+grammar.numberOfRules)*grammar.grammarSize/(8.0*grammar.inputSize)); // In case we code the grammar with log |R|+|$\Sigma$| bits

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movl %edi, %r15d
movq 0x3be4(%rip), %rax      # 0x4fc0
movq (%rax), %rbx
leaq 0x1c32(%rip), %r12      # 0x3018
leaq 0x1c2e(%rip), %r13      # 0x301b
movl %r15d, %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1040
cmpl $0x66, %eax
je 0x1407
cmpl $-0x1, %eax
jne 0x13ed
jmp 0x1465
movq 0x3ba2(%rip), %rax      # 0x4fb0
movq (%rax), %rdi
movq %r13, %rsi
callq 0x1110
movq %rax, %rbx
testq %rax, %rax
jne 0x13ed
movq 0x3bc8(%rip), %rdi      # 0x4ff0
leaq 0x1bee(%rip), %rsi      # 0x301d
callq 0x10d0
movq 0x3b75(%rip), %rcx      # 0x4fb0
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x10d0
leaq 0x1be1(%rip), %rsi      # 0x302e
movq %rax, %rdi
callq 0x10d0
movq %rax, %rdi
callq 0x1080
pushq $0x1
popq %rdi
callq 0x1120
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0x774dfe0, %edx        # imm = 0x774DFE0
callq 0x1574
movq %rbx, %rdi
callq 0x1150
testl %eax, %eax
jne 0x14a0
movq %rbx, %rdi
callq 0x1160
cmpl $-0x1, %eax
je 0x14a0
movq %r14, %rdi
movl %eax, %esi
callq 0x15fe
jmp 0x147b
movq 0x3b29(%rip), %r14      # 0x4fd0
movq (%r14), %rcx
leaq 0x1b84(%rip), %rdi      # 0x3035
pushq $0x15
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x11a0
movq (%r14), %rcx
leaq 0x1b82(%rip), %rdi      # 0x304b
pushq $0x9
popq %rsi
movq %rbx, %rdx
callq 0x11a0
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
callq 0x16ce
movq (%r14), %rdi
movl 0x14(%rbx), %edx
leaq 0x1b68(%rip), %rsi      # 0x3055
xorl %eax, %eax
callq 0x1130
movq (%r14), %rdi
movl 0x18(%rbx), %edx
leaq 0x1b68(%rip), %rsi      # 0x3069
xorl %eax, %eax
callq 0x1130
movq (%r14), %rdi
movl 0x10(%rbx), %edx
leaq 0x1b69(%rip), %rsi      # 0x307e
xorl %eax, %eax
callq 0x1130
movq (%r14), %r14
movl 0x18(%rbx), %edi
addl 0x20(%rbx), %edi
callq 0x13ac
cvtsi2sd %eax, %xmm1
mulsd 0x1ad2(%rip), %xmm1     # 0x3008
cvtsi2sdl 0x10(%rbx), %xmm0
cvtsi2sdl 0x14(%rbx), %xmm2
mulsd %xmm1, %xmm0
mulsd 0x1ac4(%rip), %xmm2     # 0x3010
divsd %xmm2, %xmm0
leaq 0x1b39(%rip), %rsi      # 0x3090
movq %r14, %rdi
movb $0x1, %al
callq 0x1130
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop