// File: sehe[P]spirit-v2-json/test.cpp
// Function: main
int main(int argc, char** argv) {
    
    if (argc < 2)
        return -1;
    
    std::ifstream inputfile(argv[1]);
    std::string to_parse;
    int count;

    inputfile.seekg(0, std::ios::end);   
    to_parse.reserve(inputfile.tellg());
    inputfile.seekg(0, std::ios::beg);

    to_parse.assign((std::istreambuf_iterator<char>(inputfile)),
                     std::istreambuf_iterator<char>());
    
    steady_clock::time_point start_time = steady_clock::now();
    for (unsigned i = 0; i < ntimes; ++i) {
        JSON::Value parsed = JSON::parse(to_parse);
    }
    steady_clock::time_point end_time = steady_clock::now();
    microseconds us = duration_cast<microseconds>(end_time - start_time);
    std::cout << "[+] Finished successfully with an average of: " << (us.count() / ntimes) << " us\n";
}

// Assembly:
subq $0x328, %rsp            # imm = 0x328
movl $0x0, 0x324(%rsp)
movl %edi, 0x320(%rsp)
movq %rsi, 0x318(%rsp)
cmpl $0x2, 0x320(%rsp)
jge 0x5ddb
movl $0xffffffff, 0x324(%rsp) # imm = 0xFFFFFFFF
jmp 0x6036
movq 0x318(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x110(%rsp), %rdi
movq %rdi, 0x40(%rsp)
movl $0x8, %edx
callq 0x5670
leaq 0xf0(%rsp), %rdi
callq 0x54b0
movq 0x40(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x5490
jmp 0x5e20
leaq 0x110(%rsp), %rdi
callq 0x5600
movq %rdx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
jmp 0x5e39
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0xc8(%rsp)
movq %rax, 0xd0(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x6060
movq %rax, 0x28(%rsp)
jmp 0x5e67
movq 0x28(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x5530
jmp 0x5e7b
xorl %edx, %edx
movl %edx, %esi
leaq 0x110(%rsp), %rdi
callq 0x5490
jmp 0x5e8e
leaq 0xb8(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x6140
leaq 0xa8(%rsp), %rdi
callq 0x61a0
movq 0xb8(%rsp), %rsi
movl 0xc0(%rsp), %edx
movq 0xa8(%rsp), %rcx
movl 0xb0(%rsp), %r8d
leaq 0xf0(%rsp), %rdi
callq 0x6070
jmp 0x5ede
callq 0x5460
movq %rax, 0xa0(%rsp)
movl $0x0, 0x9c(%rsp)
cmpl $0xa, 0x9c(%rsp)
jae 0x5f64
leaq 0x60(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x8790
jmp 0x5f14
leaq 0x60(%rsp), %rdi
callq 0x61d0
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x5ef6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x51d0
leaq 0x110(%rsp), %rdi
callq 0x5090
jmp 0x6045
callq 0x5460
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x6230
movq %rax, 0x20(%rsp)
jmp 0x5f87
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x6200
movq %rax, 0x18(%rsp)
jmp 0x5fa2
movq 0x18(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x10601d(%rip), %rdi    # 0x10bfd0
leaq 0xb009a(%rip), %rsi     # 0xb6054
callq 0x5350
movq %rax, 0x10(%rsp)
jmp 0x5fc6
leaq 0x50(%rsp), %rdi
callq 0x6280
movq %rax, 0x8(%rsp)
jmp 0x5fd7
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
movabsq $0x6666666666666667, %rcx # imm = 0x6666666666666667
imulq %rcx
movq %rdx, %rsi
movq %rsi, %rdx
shrq $0x3f, %rdx
sarq $0x2, %rsi
addq %rdx, %rsi
callq 0x5660
movq %rax, (%rsp)
jmp 0x600a
movq (%rsp), %rdi
leaq 0xb006e(%rip), %rsi     # 0xb6083
callq 0x5350
jmp 0x601c
leaq 0xf0(%rsp), %rdi
callq 0x51d0
leaq 0x110(%rsp), %rdi
callq 0x5090
movl 0x324(%rsp), %eax
addq $0x328, %rsp            # imm = 0x328
retq
movq 0xe0(%rsp), %rdi
callq 0x5620
nopw %cs:(%rax,%rax)
nopl (%rax)