// File: /workspace/github_cpp_makefile_star2_O3/junhe[P]libpatterndetector/pattern.cpp
// Function: PatternUtil::getReqPatList(std::vector<Request, std::allocator<Request>> const&, RequestPatternList&)
int
PatternUtil::getReqPatList( const vector<Request> &reqs,
                            RequestPatternList &patlist )
{
    vector<off_t> offsets; 
    vector<off_t> lengths;

    vector<Request>::const_iterator it;

    for ( it = reqs.begin() ; 
          it != reqs.end();
          it++ )
    {
        offsets.push_back(it->offset);
        lengths.push_back(it->length);
    }

    // Get the patterns of logical offsets first
    PatChain<PatternUnit>
        offset_pat = getPatChainFromSeq(offsets);
    
    //cout << "before show. offset.size()=" <<
    //     offsets.size() << endl;
    //cout << offset_pat.show() << endl;

    vector<PatternUnit>::const_iterator chain_iter;
    int range_start = 0, range_end; //the range currently processing
    for (chain_iter = offset_pat.begin();
            chain_iter != offset_pat.end();
            chain_iter++ ) 
    {
        RequestPattern reqpat;
        range_end = range_start
                  + max( int(chain_iter->cnt 
                             * chain_iter->seq.size()), 1 );  
        assert( ((ssize_t) range_end) <= offsets.size() );
        
        reqpat.offset = *chain_iter;
        vector<off_t> length_seq(lengths.begin()+range_start,
                                 lengths.begin()+range_end);
        reqpat.length = getPatChainFromSeq(length_seq);

        patlist.list.push_back( reqpat );
        
        range_start = range_end;
    }
    
    //cout << patlist.show();
    
    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq (%rdi), %r14
cmpq 0x8(%rdi), %r14
je 0x332a
movq %rdi, %rbx
addq $0x8, %r14
movq %rsp, %r15
leaq 0x20(%rsp), %r12
leaq -0x8(%r14), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x32e9
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x32f1
movq %r15, %rdi
callq 0x4dc0
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x330e
movq (%r14), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x3319
movq %r12, %rdi
movq %r14, %rdx
callq 0x4dc0
leaq 0x10(%r14), %rax
addq $0x8, %r14
cmpq 0x8(%rbx), %r14
movq %rax, %r14
jne 0x32c8
leaq 0x48(%rsp), %rdi
movq %rsp, %rsi
callq 0x475e
leaq 0x60(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x36b0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x335d
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
leaq 0x68(%rsp), %rax
movq (%rax), %rbp
cmpq 0x8(%rax), %rbp
je 0x356f
leaq 0xb8(%rsp), %rdi
leaq 0x108(%rsp), %r13
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
leaq 0x59cc(%rip), %rcx      # 0x8d60
movq %rcx, 0xb0(%rsp)
leaq 0xe8(%rsp), %rcx
movq %rax, 0x10(%rcx)
movups %xmm0, (%rcx)
leaq 0x59de(%rip), %rax      # 0x8d90
movq %rax, 0xe0(%rsp)
movq 0x10(%rbp), %r14
subq 0x8(%rbp), %r14
shrq $0x3, %r14
imull 0x20(%rbp), %r14d
cmpl $0x2, %r14d
jge 0x33d7
movl $0x1, %r14d
addl %ebx, %r14d
movq 0x8(%rsp), %rax
subq (%rsp), %rax
sarq $0x3, %rax
cmpq %r14, %rax
jb 0x35c6
leaq 0x8(%rbp), %rsi
movq %rdi, %r12
callq 0x4a46
movups 0x20(%rbp), %xmm0
movups %xmm0, 0xd0(%rsp)
movq 0x20(%rsp), %rax
movl %ebx, %ecx
leaq (%rax,%rcx,8), %rsi
leaq (%rax,%r14,8), %rdx
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
leaq 0x100(%rsp), %rcx
callq 0x47de
leaq 0x80(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x475e
leaq 0x100(%rsp), %rdi
movq %r15, %rsi
callq 0x36b0
movq 0xf8(%rsp), %rax
movups 0x108(%rsp), %xmm0
movq 0x118(%rsp), %rcx
movq %rcx, 0xf8(%rsp)
movups 0xe8(%rsp), %xmm1
movups %xmm0, 0xe8(%rsp)
movaps %xmm1, 0x120(%rsp)
movq %rax, 0x130(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movq $0x0, 0x10(%r13)
leaq 0x120(%rsp), %rdi
callq 0x26d6
leaq 0x585a(%rip), %rax      # 0x8d10
movq %rax, 0x100(%rsp)
movq %r13, %rdi
callq 0x26d6
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x34e3
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq 0x40(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x4820
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x3512
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
leaq 0x57f7(%rip), %rax      # 0x8d10
movq %rax, 0xe0(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x26d6
leaq 0x5803(%rip), %rax      # 0x8d38
movq %rax, 0xb0(%rsp)
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x355a
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq $0x30, %rbp
movl %r14d, %ebx
cmpq 0x70(%rsp), %rbp
movq %r12, %rdi
jne 0x3381
leaq 0x579a(%rip), %rax      # 0x8d10
movq %rax, 0x60(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x26d6
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x359c
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x35b2
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b84(%rip), %rdi      # 0x6151
leaq 0x2b43(%rip), %rsi      # 0x6117
leaq 0x2b9e(%rip), %rcx      # 0x6179
movl $0x137, %edx            # imm = 0x137
callq 0x20c0
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x367a
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
jmp 0x367a
jmp 0x3607
movq %rax, %rbx
jmp 0x367a
jmp 0x360e
movq %rax, %rbx
jmp 0x3657
jmp 0x3637
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x363a
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
jmp 0x363a
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x3657
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
leaq 0xb0(%rsp), %rdi
callq 0x484a
leaq 0x56a5(%rip), %rax      # 0x8d10
movq %rax, 0x60(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x26d6
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3691
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x36a7
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x21c0
nop