// File: /workspace/github_cpp_makefile_star2_O1/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), %r15
cmpq 0x8(%rdi), %r15
je 0x3396
movq %rdi, %r14
addq $0x8, %r15
movq %rsp, %r12
leaq 0x20(%rsp), %r13
leaq -0x8(%r15), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x3355
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x335d
movq %r12, %rdi
callq 0x4eba
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x337a
movq (%r15), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x3385
movq %r13, %rdi
movq %r15, %rdx
callq 0x4eba
leaq 0x10(%r15), %rax
addq $0x8, %r15
cmpq 0x8(%r14), %r15
movq %rax, %r15
jne 0x3334
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
callq 0x485e
leaq 0x80(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3734
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x33cc
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
leaq 0x88(%rsp), %rax
movq (%rax), %rbx
cmpq 0x8(%rax), %rbx
je 0x35e7
leaq 0xf0(%rsp), %r15
leaq 0x120(%rsp), %r12
leaq 0xb8(%rsp), %r13
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
xorl %eax, %eax
movq %rax, 0x10(%r15)
leaq 0x5950(%rip), %rcx      # 0x8d60
movq %rcx, 0xe8(%rsp)
movq %rax, 0x10(%r12)
movups %xmm0, (%r12)
leaq 0x5967(%rip), %rax      # 0x8d90
movq %rax, 0x118(%rsp)
movq 0x10(%rbx), %rbp
subq 0x8(%rbx), %rbp
shrq $0x3, %rbp
imull 0x20(%rbx), %ebp
cmpl $0x2, %ebp
jge 0x344b
movl $0x1, %ebp
addl %r14d, %ebp
movq 0x8(%rsp), %rax
subq (%rsp), %rax
sarq $0x3, %rax
cmpq %rbp, %rax
jb 0x3644
leaq 0x8(%rbx), %rsi
movq %r15, %rdi
callq 0x4b4e
movq 0x20(%rbx), %rax
movq %rax, 0x108(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x110(%rsp)
movq 0x20(%rsp), %rax
movl %r14d, %ecx
leaq (%rax,%rcx,8), %rsi
leaq (%rax,%rbp,8), %rdx
leaq 0xd0(%rsp), %r14
movq %r14, %rdi
leaq 0x48(%rsp), %rcx
callq 0x48de
movq %r13, %rdi
movq %r14, %rsi
callq 0x485e
leaq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x3734
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movups 0x120(%rsp), %xmm0
movq 0x130(%rsp), %rax
movups 0x50(%rsp), %xmm1
movups %xmm1, 0x120(%rsp)
movq 0x60(%rsp), %rcx
movq %rcx, 0x130(%rsp)
movaps 0xa0(%rsp), %xmm1
movaps %xmm0, 0xa0(%rsp)
movq %rax, 0xb0(%rsp)
movups %xmm1, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x26dc
leaq 0x57dc(%rip), %rax      # 0x8d10
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x26dc
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x3560
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq 0x40(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x4920
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x358f
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
leaq 0x577a(%rip), %rax      # 0x8d10
movq %rax, 0x118(%rsp)
movq %r12, %rdi
callq 0x26dc
leaq 0x578b(%rip), %rax      # 0x8d38
movq %rax, 0xe8(%rsp)
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x35d2
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq $0x30, %rbx
movl %ebp, %r14d
cmpq 0x90(%rsp), %rbx
jne 0x33fc
leaq 0x5722(%rip), %rax      # 0x8d10
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x26dc
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x361a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3630
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 0x2b76(%rip), %rdi      # 0x61c1
leaq 0x2b35(%rip), %rsi      # 0x6187
leaq 0x2b90(%rip), %rcx      # 0x61e9
movl $0x137, %edx            # imm = 0x137
callq 0x20c0
movq %rax, %r14
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x36fe
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
jmp 0x36fe
jmp 0x3685
movq %rax, %r14
jmp 0x36fe
jmp 0x368c
movq %rax, %r14
jmp 0x36d5
jmp 0x36b5
movq %rax, %r14
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x36b8
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
jmp 0x36b8
movq %rax, %r14
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x36d5
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
leaq 0xe8(%rsp), %rdi
callq 0x494a
leaq 0x5627(%rip), %rax      # 0x8d10
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x26dc
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3715
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x372b
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq %r14, %rdi
callq 0x21c0
nop