// File: /workspace/github_cpp_makefile_star2_O1/byronknoll[P]paqclass/runner.cpp
// Function: main
int main(int argc, char** argv) {
  if (argc < 3 || argc > 4) return -1;
  string train = argv[1];
  if (train[train.length() - 1] != '/') train += '/';
  string test = argv[2];
  string compression_level = "5";
  if (argc == 4) compression_level = argv[3];
  vector<string> labels;
  list(train, &labels);
  map<string, vector<double> > results;
  for (int i = 0; i < labels.size(); ++i) {
    string command = "./PAQclass -" + compression_level + " temp ";
    command += train + labels[i] + " " + test;
    string output = exec(command);
    vector<string> lines;
    split(output, '\n', &lines);
    for (int j = 0; j < lines.size(); ++j) {
      vector<string> cols;
      split(lines[j], '\t', &cols);
      results[cols[0]].push_back(atof(cols[1].c_str()));
    }
  }

  cout << "name\tclass";
  for (int i = 0; i < labels.size(); ++i) {
    cout << "\t" << labels[i];
  }
  cout << endl;

  map<string, vector<double> >::iterator it;
  for (it = results.begin(); it != results.end(); it++) {
    cout << it->first;
    double best = 100;
    int best_index = 0;
    for (int i = 0; i < it->second.size(); ++i) {
      if (it->second[i] < best) {
        best = it->second[i];
        best_index = i;
      }
    }
    cout << "\t" << labels[best_index];
    for (int i = 0; i < it->second.size(); ++i) {
      cout << "\t" << it->second[i];
    }
    cout << endl;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %edi, %r14d
leal -0x5(%r14), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $-0x2, %ecx
jb 0x2dc2
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq 0xc8(%rsp), %r15
leaq 0x108(%rsp), %rdx
movq %r15, %rdi
callq 0x2f82
movq (%r15), %rax
movq 0x8(%r15), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x2779
leaq 0xc8(%rsp), %rdi
movl $0x2f, %esi
callq 0x2160
movq 0x10(%rbx), %rsi
leaq 0xe8(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x2f82
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1886(%rip), %rsi      # 0x402b
leaq 0x1880(%rip), %rdx      # 0x402c
leaq 0xa0(%rsp), %rdi
callq 0x3252
cmpl $0x4, %r14d
jne 0x27ea
movq 0x18(%rbx), %rbx
leaq 0xa0(%rsp), %r14
movq 0x8(%r14), %r15
movq %rbx, %rdi
callq 0x20e0
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x2230
xorpd %xmm0, %xmm0
leaq 0x40(%rsp), %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0xc8(%rsp), %rdi
callq 0x2617
leaq 0x110(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x2b6d
leaq 0x70(%rsp), %rbx
leaq 0x30(%rsp), %r14
xorl %r15d, %r15d
leaq 0x80(%rsp), %r13
leaq 0x108(%rsp), %rbp
movq %rsp, %r12
movq %r12, %rdi
leaq 0x17c7(%rip), %rsi      # 0x402d
leaq 0xa0(%rsp), %rdx
callq 0x2ffd
movq %r12, %rdi
leaq 0x17bd(%rip), %rsi      # 0x403a
callq 0x22f0
movq %rbx, 0x60(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x28a5
movq %rdx, 0x60(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x70(%rsp)
jmp 0x28ad
movupd (%rcx), %xmm0
movupd %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0x68(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x28e0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %r15, %rdx
shlq $0x5, %rdx
addq 0x40(%rsp), %rdx
movq %r13, %rdi
leaq 0xc8(%rsp), %rsi
callq 0x3085
movq %r13, %rdi
leaq 0x1739(%rip), %rsi      # 0x403f
callq 0x22f0
movq %r14, 0x20(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x292e
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x2937
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xe8(%rsp), %rsi
movq 0xf0(%rsp), %rdx
leaq 0x20(%rsp), %rdi
callq 0x20a0
leaq 0x10(%rsp), %rsi
movq %rsi, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x298f
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x2997
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x20a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x29dd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x29f4
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
movq %rsp, %rbx
je 0x2a1c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0x244c
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq %rbx, %rdi
movl $0xa, %esi
leaq 0x20(%rsp), %rdx
callq 0x2520
movq 0x20(%rsp), %rdi
cmpq %rdi, 0x28(%rsp)
je 0x2b0d
xorl %r14d, %r14d
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
addq %r14, %rdi
movl $0x9, %esi
movq %r13, %rdx
callq 0x2520
movq 0x80(%rsp), %rsi
movq %rbp, %rdi
callq 0x30e0
movq %rax, %r12
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x21d0
movsd %xmm0, 0xc0(%rsp)
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x2ad4
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r12)
jmp 0x2ae4
movq %r12, %rdi
leaq 0xc0(%rsp), %rdx
callq 0x3930
movq %r13, %rdi
callq 0x315c
incq %rbx
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
subq %rdi, %rax
sarq $0x5, %rax
addq $0x20, %r14
cmpq %rbx, %rax
ja 0x2a63
leaq 0x20(%rsp), %rdi
callq 0x315c
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x2b32
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rbx
cmpq %rbx, %rdi
leaq 0x30(%rsp), %r14
je 0x2b53
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
incq %r15
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
sarq $0x5, %rax
cmpq %r15, %rax
ja 0x2859
movq 0x3464(%rip), %rbx      # 0x5fd8
leaq 0x14c6(%rip), %rsi      # 0x4041
movl $0xa, %edx
movq %rbx, %rdi
callq 0x21c0
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x2beb
movl $0x8, %r12d
xorl %r13d, %r13d
movq 0x3434(%rip), %r14      # 0x5fd8
leaq 0x14a1(%rip), %r15      # 0x404c
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq 0x40(%rsp), %rax
movq -0x8(%rax,%r12), %rsi
movq (%rax,%r12), %rdx
movq %r14, %rdi
callq 0x21c0
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
incq %r13
sarq $0x5, %rax
addq $0x20, %r12
cmpq %r13, %rax
ja 0x2bab
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq 0x33cf(%rip), %rbx      # 0x5fd8
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq 0x120(%rsp), %r14
leaq 0x110(%rsp), %rax
cmpq %rax, %r14
je 0x2d42
leaq 0x1413(%rip), %r15      # 0x404c
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %rbx, %rdi
callq 0x21c0
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
subq %rax, %rcx
je 0x2c8f
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
xorl %esi, %esi
movsd 0x139a(%rip), %xmm0     # 0x4008
movsd (%rax,%rdx,8), %xmm1
ucomisd %xmm1, %xmm0
cmoval %edx, %esi
minsd %xmm0, %xmm1
incq %rdx
movapd %xmm1, %xmm0
cmpq %rdx, %rcx
jne 0x2c6e
movslq %esi, %r12
jmp 0x2c92
xorl %r12d, %r12d
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21c0
movq 0x40(%rsp), %rax
shlq $0x5, %r12
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
movq %rbx, %rdi
callq 0x21c0
movq 0x48(%r14), %rax
cmpq 0x40(%r14), %rax
je 0x2cff
xorl %r12d, %r12d
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21c0
movq 0x40(%r14), %rax
movsd (%rax,%r12,8), %xmm0
movq %rbx, %rdi
callq 0x2290
incq %r12
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
sarq $0x3, %rax
cmpq %r12, %rax
ja 0x2cc9
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq %r14, %rdi
callq 0x2110
movq %rax, %r14
leaq 0x110(%rsp), %rax
cmpq %rax, %r14
jne 0x2c39
leaq 0x108(%rsp), %rdi
callq 0x31c2
leaq 0x40(%rsp), %rdi
callq 0x315c
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2d7e
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0xf8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2d9f
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2dc0
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x21a0
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2f13
jmp 0x2dee
movq %rax, %rbx
jmp 0x2f09
movq %rax, %rbx
jmp 0x2f38
movq %rax, %rbx
jmp 0x2f59
jmp 0x2ea6
jmp 0x2ea6
jmp 0x2ea6
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x2efc
movq 0x10(%rsp), %rsi
jmp 0x2ef4
jmp 0x2e91
movq %rax, %rbx
jmp 0x2e6a
movq %rax, %rbx
jmp 0x2e4e
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x2e4e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2e6a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x2e94
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x2e94
movq %rax, %rbx
leaq 0x70(%rsp), %r14
jmp 0x2ee5
movq %rax, %rbx
jmp 0x2ebb
jmp 0x2ea6
jmp 0x2ea6
jmp 0x2eab
movq %rax, %rbx
jmp 0x2efc
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x315c
leaq 0x70(%rsp), %r14
leaq 0x10(%rsp), %r15
leaq 0x20(%rsp), %rdi
callq 0x315c
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2ee5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0x2efc
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x108(%rsp), %rdi
callq 0x31c2
leaq 0x40(%rsp), %rdi
callq 0x315c
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2f38
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0xf8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f59
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f7a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22c0