// File: junhe[P]libpatterndetector/example.cpp
// Function: main
int main()
{
    // build the vector for requests
    vector<Request> reqs;
    off_t offs[] = {0,3,7,14,17,21,28,31,35,42,46,50,54,58};
    off_t lens[] = {2,2,2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
    
    int n = sizeof(offs)/sizeof(off_t);
    int i;
    for ( i = 0 ; i < n ; i++ ) {
        reqs.push_back( Request( offs[i], lens[i] ) ); 
    }

    // check the requests, just to make sure
    cout << "*** Offset;Length ***" << endl;
    vector<Request>::iterator it;
    for ( it = reqs.begin() ; it != reqs.end() ; it++ ) {
        cout << it->offset << ";" << it->length << endl;
    }

    // OK, detect and show the patterns
    cout << endl;
    cout << "*** Pattern Found ***" << endl;
    RequestPatternList plist;
    PatternUtil::getReqPatList( reqs, plist );
    cout << plist.show() << endl;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movl $0x0, -0x4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2680
leaq -0x90(%rbp), %rdi
leaq 0xac97(%rip), %rsi      # 0xd010
movl $0x70, %edx
callq 0x20c0
leaq -0x100(%rbp), %rdi
leaq 0xacef(%rip), %rsi      # 0xd080
movl $0x70, %edx
callq 0x20c0
movl $0xe, -0x104(%rbp)
movl $0x0, -0x108(%rbp)
movl -0x108(%rbp), %eax
cmpl -0x104(%rbp), %eax
jge 0x241e
movslq -0x108(%rbp), %rax
movq -0x90(%rbp,%rax,8), %rsi
movq -0x100(%rbp,%rax,8), %rdx
leaq -0x118(%rbp), %rdi
callq 0x42b0
jmp 0x23e2
leaq -0x20(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x26a0
jmp 0x23f4
jmp 0x23f6
movl -0x108(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x108(%rbp)
jmp 0x23af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
jmp 0x265e
movq 0x11bb3(%rip), %rdi     # 0x13fd8
leaq 0xacc4(%rip), %rsi      # 0xd0f0
callq 0x20f0
movq %rax, -0x188(%rbp)
jmp 0x243a
movq -0x188(%rbp), %rdi
movq 0x11b80(%rip), %rsi     # 0x13fc8
callq 0x2130
jmp 0x244f
leaq -0x130(%rbp), %rdi
callq 0x26d0
leaq -0x20(%rbp), %rdi
callq 0x26f0
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2760
movq %rax, -0x140(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x2720
testb $0x1, %al
jne 0x24a5
jmp 0x253b
leaq -0x130(%rbp), %rdi
callq 0x2790
movq (%rax), %rsi
movq 0x11b1d(%rip), %rdi     # 0x13fd8
callq 0x21b0
movq %rax, -0x190(%rbp)
jmp 0x24c9
movq -0x190(%rbp), %rdi
leaq 0xac2f(%rip), %rsi      # 0xd106
callq 0x20f0
movq %rax, -0x198(%rbp)
jmp 0x24e5
leaq -0x130(%rbp), %rdi
callq 0x2790
movq -0x198(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0x21b0
movq %rax, -0x1a0(%rbp)
jmp 0x250a
movq -0x1a0(%rbp), %rdi
movq 0x11ab0(%rip), %rsi     # 0x13fc8
callq 0x2130
jmp 0x251f
jmp 0x2521
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
callq 0x27b0
movq %rax, -0x148(%rbp)
jmp 0x2479
movq 0x11a96(%rip), %rdi     # 0x13fd8
movq 0x11a7f(%rip), %rsi     # 0x13fc8
callq 0x2130
jmp 0x2550
movq 0x11a81(%rip), %rdi     # 0x13fd8
leaq 0xabaa(%rip), %rsi      # 0xd108
callq 0x20f0
movq %rax, -0x1a8(%rbp)
jmp 0x256c
movq -0x1a8(%rbp), %rdi
movq 0x11a4e(%rip), %rsi     # 0x13fc8
callq 0x2130
jmp 0x2581
leaq -0x160(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x27f0
movq -0x1b0(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x4d70
jmp 0x25a6
leaq -0x180(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x60c0
jmp 0x25bb
movq 0x11a16(%rip), %rdi     # 0x13fd8
leaq -0x180(%rbp), %rsi
callq 0x20e0
movq %rax, -0x1b8(%rbp)
jmp 0x25d7
movq -0x1b8(%rbp), %rdi
movq 0x119e3(%rip), %rsi     # 0x13fc8
callq 0x2130
jmp 0x25ec
leaq -0x180(%rbp), %rdi
callq 0x2090
movl $0x0, -0x4(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x2810
leaq -0x20(%rbp), %rdi
callq 0x2830
movl -0x4(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
jmp 0x2652
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x2090
leaq -0x160(%rbp), %rdi
callq 0x2810
leaq -0x20(%rbp), %rdi
callq 0x2830
movq -0x120(%rbp), %rdi
callq 0x21a0
nopw %cs:(%rax,%rax)
nopl (%rax)