// File: dsudheerdantuluri[P]quantlab/tradecal.cc
// Function: main
int main()
{
  std::shared_ptr<TradeOperation> p_mtg = std::make_shared<TradeMTGap>();
  std::shared_ptr<TradeOperation> p_tv = std::make_shared<TradeVolume>();
  std::shared_ptr<TradeOperation> p_wap = std::make_shared<TradeWAP>();
  std::shared_ptr<TradeOperation> p_tm = std::make_shared<TradeMax>();

  TradeProcessor tp;
  tp.addOperation(p_mtg.get());
  tp.addOperation(p_tv.get());
  tp.addOperation(p_wap.get());
  tp.addOperation(p_tm.get());

  try {
    TradeStreamReader tr("input.csv");
    while (tr.hasNext()) {
      Trade t = tr.next();
      tp.process(t);
    }

    tp.dumpResults("output.csv");
  } catch(std::exception &e) {
    std::cout << e.what() << '\n';
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3c0, %rsp            # imm = 0x3C0
movl $0x0, -0x4(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x380(%rbp)
callq 0x3940
movq -0x380(%rbp), %rsi
leaq -0x18(%rbp), %rdi
callq 0x39b0
movq -0x380(%rbp), %rdi
callq 0x39e0
leaq -0x48(%rbp), %rdi
callq 0x3a00
jmp 0x3529
leaq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movq %rsi, -0x388(%rbp)
callq 0x3a70
movq -0x388(%rbp), %rdi
callq 0x3aa0
leaq -0x78(%rbp), %rdi
callq 0x3ac0
jmp 0x3554
leaq -0x68(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movq %rsi, -0x390(%rbp)
callq 0x3b30
movq -0x390(%rbp), %rdi
callq 0x3b60
leaq -0x98(%rbp), %rdi
callq 0x3b80
jmp 0x3582
leaq -0x88(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movq %rsi, -0x3a0(%rbp)
callq 0x3bf0
movq -0x3a0(%rbp), %rdi
callq 0x3c20
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x398(%rbp)
callq 0x3c40
leaq -0x18(%rbp), %rdi
callq 0x3c70
movq -0x398(%rbp), %rdi
movq %rax, %rsi
callq 0x9730
jmp 0x35d5
leaq -0x38(%rbp), %rdi
callq 0x3c70
movq %rax, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x9730
jmp 0x35ef
leaq -0x68(%rbp), %rdi
callq 0x3c70
movq %rax, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x9730
jmp 0x3609
leaq -0x88(%rbp), %rdi
callq 0x3c70
movq %rax, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x9730
jmp 0x3626
leaq -0x309(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x3370
movq -0x3a8(%rbp), %rdx
leaq 0xb9c1(%rip), %rsi      # 0xf008
leaq -0x308(%rbp), %rdi
callq 0x32a0
jmp 0x3655
leaq -0x2e8(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x8460
jmp 0x366a
leaq -0x308(%rbp), %rdi
callq 0x3180
leaq -0x309(%rbp), %rdi
callq 0x3220
leaq -0x2e8(%rbp), %rdi
callq 0x3c90
movb %al, -0x3a9(%rbp)
jmp 0x3696
movb -0x3a9(%rbp), %al
testb $0x1, %al
jne 0x36a5
jmp 0x3786
leaq -0x348(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x84f0
jmp 0x36ba
leaq -0xe0(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x9760
jmp 0x36cf
leaq -0x348(%rbp), %rdi
callq 0x3cc0
jmp 0x3682
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x391a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3911
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3908
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x38f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3747
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x3180
leaq -0x309(%rbp), %rdi
callq 0x3220
jmp 0x3831
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3825
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x3cc0
jmp 0x3825
leaq -0x369(%rbp), %rdi
movq %rdi, -0x3b8(%rbp)
callq 0x3370
movq -0x3b8(%rbp), %rdx
leaq 0xb86b(%rip), %rsi      # 0xf012
leaq -0x368(%rbp), %rdi
callq 0x32a0
jmp 0x37b5
leaq -0xe0(%rbp), %rdi
leaq -0x368(%rbp), %rsi
callq 0x9850
jmp 0x37ca
leaq -0x368(%rbp), %rdi
callq 0x3180
leaq -0x369(%rbp), %rdi
callq 0x3220
leaq -0x2e8(%rbp), %rdi
callq 0x87b0
jmp 0x3895
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3819
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x3180
leaq -0x369(%rbp), %rdi
callq 0x3220
leaq -0x2e8(%rbp), %rdi
callq 0x87b0
movl -0x54(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x38f0
movq -0x50(%rbp), %rdi
callq 0x30f0
movq %rax, -0x378(%rbp)
movq -0x378(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x1576d(%rip), %rdi     # 0x18fd8
callq 0x31f0
movq %rax, -0x3c0(%rbp)
jmp 0x3879
movq -0x3c0(%rbp), %rdi
movl $0xa, %esi
callq 0x3250
jmp 0x388c
callq 0x3340
jmp 0x3893
jmp 0x3895
movl $0x0, -0x4(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3cf0
leaq -0x88(%rbp), %rdi
callq 0x3d20
leaq -0x68(%rbp), %rdi
callq 0x3d20
leaq -0x38(%rbp), %rdi
callq 0x3d20
leaq -0x18(%rbp), %rdi
callq 0x3d20
movl -0x4(%rbp), %eax
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x3340
jmp 0x38ee
jmp 0x38f0
leaq -0xe0(%rbp), %rdi
callq 0x3cf0
leaq -0x88(%rbp), %rdi
callq 0x3d20
leaq -0x68(%rbp), %rdi
callq 0x3d20
leaq -0x38(%rbp), %rdi
callq 0x3d20
leaq -0x18(%rbp), %rdi
callq 0x3d20
movq -0x50(%rbp), %rdi
callq 0x3360
movq %rax, %rdi
callq 0x3ce0
nopw %cs:(%rax,%rax)
nop