// File: CastellanZhang[P]lambdaFM/src/Frame/pc_frame.cpp
// Function: pc_frame::proThread()
void pc_frame::proThread()
{
    string line;
    int line_num = 0;
    int i = 0;
    bool finished_flag = false;
    bool first_line = true;
    string last_qid = "";
    vector<fm_sample> sampleGrp;
    while(true)
    {
        sem_wait(&semPro);
        bufMtx.lock();
        for(i = 0; i < bufSize;)
        {
            if(!getline(cin, line))
            {
                if(!sampleGrp.empty())
                {
                    buffer.push(sampleGrp);
                    sampleGrp.clear();
                }
                finished_flag = true;
                break;
            }
            line_num++;
            fm_sample sample(line);
            if(!first_line && last_qid != sample.qid)
            {
                buffer.push(sampleGrp);
                i += sampleGrp.size();
                sampleGrp.clear();
                last_qid = sample.qid;
            }
            sampleGrp.push_back(sample);
            if(first_line)
            {
                first_line = false;
                last_qid = sample.qid;
            }
            if(line_num%logNum == 0)
            {
                cout << line_num << " lines have finished" << endl;
            }
        }
        bufMtx.unlock();
        sem_post(&semCon);
        if(finished_flag)
        {
            break;
        }
    }
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x33f0
movl $0x0, 0xfc(%rsp)
movl $0x0, 0xf8(%rsp)
movb $0x0, 0xf7(%rsp)
movb $0x1, 0xf6(%rsp)
leaq 0xcf(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x3500
movq 0x38(%rsp), %rdx
leaq 0x6610(%rip), %rsi      # 0x122ed
leaq 0xd0(%rsp), %rdi
callq 0x33e0
jmp 0xbcec
leaq 0xcf(%rsp), %rdi
callq 0x3340
leaq 0xa0(%rsp), %rdi
callq 0xc410
jmp 0xbd08
movq 0x30(%rsp), %rdi
addq $0x38, %rdi
callq 0x31a0
jmp 0xbd18
movq 0x30(%rsp), %rdi
addq $0x10, %rdi
callq 0x53f0
jmp 0xbd28
movl $0x0, 0xf8(%rsp)
movq 0x30(%rsp), %rcx
movl 0xf8(%rsp), %eax
cmpl 0xe0(%rcx), %eax
jge 0xbf8c
movq 0xe28e(%rip), %rdi      # 0x19fe0
leaq 0x100(%rsp), %rsi
callq 0x3070
movq %rax, 0x28(%rsp)
jmp 0xbd66
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3150
movb %al, 0x27(%rsp)
jmp 0xbd80
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0xbd8d
jmp 0xbe11
leaq 0xa0(%rsp), %rdi
callq 0xc420
testb $0x1, %al
jne 0xbe04
movq 0x30(%rsp), %rdi
addq $0x78, %rdi
leaq 0xa0(%rsp), %rsi
callq 0xc470
jmp 0xbdb6
leaq 0xa0(%rsp), %rdi
callq 0xc4a0
jmp 0xbe04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
leaq 0xcf(%rsp), %rdi
callq 0x3340
jmp 0xc004
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
jmp 0xbfea
movb $0x1, 0xf7(%rsp)
jmp 0xbf8c
movl 0xfc(%rsp), %eax
incl %eax
movl %eax, 0xfc(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0xc4c0
jmp 0xbe35
testb $0x1, 0xf6(%rsp)
jne 0xbee2
leaq 0x40(%rsp), %rsi
addq $0x8, %rsi
leaq 0xd0(%rsp), %rdi
callq 0xcb50
testb $0x1, %al
jne 0xbe62
jmp 0xbee2
movq 0x30(%rsp), %rdi
addq $0x78, %rdi
leaq 0xa0(%rsp), %rsi
callq 0xc470
jmp 0xbe7a
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x5da0
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl 0xf8(%rsp), %eax
addl %ecx, %eax
movl %eax, 0xf8(%rsp)
callq 0xc4a0
leaq 0x48(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x3040
jmp 0xbebd
jmp 0xbee2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x8e10
jmp 0xbfea
leaq 0xa0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xcb80
jmp 0xbef6
testb $0x1, 0xf6(%rsp)
je 0xbf1e
movb $0x0, 0xf6(%rsp)
leaq 0x48(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x3040
jmp 0xbf1c
jmp 0xbf1e
movq 0x30(%rsp), %rcx
movl 0xfc(%rsp), %eax
cltd
idivl 0xe4(%rcx)
cmpl $0x0, %edx
jne 0xbf7d
movl 0xfc(%rsp), %esi
movq 0xe074(%rip), %rdi      # 0x19fb8
callq 0x34e0
movq %rax, 0x10(%rsp)
jmp 0xbf50
movq 0x10(%rsp), %rdi
leaq 0x634d(%rip), %rsi      # 0x122a9
callq 0x32f0
movq %rax, 0x8(%rsp)
jmp 0xbf68
movq 0x8(%rsp), %rdi
movq 0xe00c(%rip), %rsi      # 0x19f80
callq 0x3320
jmp 0xbf7b
jmp 0xbf7d
leaq 0x40(%rsp), %rdi
callq 0x8e10
jmp 0xbd33
movq 0x30(%rsp), %rdi
addq $0x10, %rdi
callq 0x5650
jmp 0xbf9c
movq 0x30(%rsp), %rdi
addq $0x58, %rdi
callq 0x34b0
testb $0x1, 0xf7(%rsp)
je 0xbfb6
jmp 0xbfbb
jmp 0xbd06
leaq 0xa0(%rsp), %rdi
callq 0x8ca0
leaq 0xd0(%rsp), %rdi
callq 0x3598
leaq 0x100(%rsp), %rdi
callq 0x3598
addq $0x128, %rsp            # imm = 0x128
retq
leaq 0xa0(%rsp), %rdi
callq 0x8ca0
leaq 0xd0(%rsp), %rdi
callq 0x3598
leaq 0x100(%rsp), %rdi
callq 0x3598
movq 0xc0(%rsp), %rdi
callq 0x34f0
nop