// File: yueww[P]TSR/produceFlows.c
// Function: produce(void*)
void* produce(void *argv){
    pthread_detach(pthread_self());
    rawData *pRawData=(rawData *)argv;
    int newFlows=(pRawData->length-PKTHEADERSIZE)/FLOWSIZE;
    pthread_mutex_lock(&mutex);
    while(n+newFlows>BLOCKSIZE) pthread_cond_wait(&cond_p,&mutex);
    if(in==BLOCKSIZE) in=0;
    if((in+newFlows)>BLOCKSIZE){
        memcpy(flowBlock+in,pRawData->buf+PKTHEADERSIZE,(BLOCKSIZE-in)*FLOWSIZE);
        memcpy(flowBlock,pRawData->buf+PKTHEADERSIZE+(BLOCKSIZE-in)*FLOWSIZE,(newFlows-(BLOCKSIZE-in))*FLOWSIZE);
        in=newFlows+in-BLOCKSIZE;
    }else{
        memcpy(flowBlock+in,pRawData->buf+PKTHEADERSIZE,newFlows*FLOWSIZE);
        in+=newFlows;
    }
    n+=newFlows;
    printf("add %d flows,current n is %d\n",newFlows,n);
    if(n>=FLOWSPERPROCESS) pthread_cond_signal(&cond_c);
    pthread_mutex_unlock(&mutex);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
callq 0x2290
movq %rax, %rdi
callq 0x21a0
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0x18, %eax
movl $0x30, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x14(%rbp)
leaq 0xc2f3(%rip), %rdi      # 0xf2e0
callq 0x2440
movl 0xc2dc(%rip), %eax      # 0xf2d4
addl -0x14(%rbp), %eax
cmpl $0x61a80, %eax          # imm = 0x61A80
jle 0x3017
leaq 0xc2ff(%rip), %rdi      # 0xf308
leaq 0xc2d0(%rip), %rsi      # 0xf2e0
callq 0x2480
jmp 0x2ff2
cmpl $0x61a80, 0xc2af(%rip)  # imm = 0x61A80
jne 0x302d
movl $0x0, 0xc2a3(%rip)      # 0xf2d0
movl 0xc29d(%rip), %eax      # 0xf2d0
addl -0x14(%rbp), %eax
cmpl $0x61a80, %eax          # imm = 0x61A80
jbe 0x30d0
movl 0xc289(%rip), %eax      # 0xf2d0
leaq 0x1c332(%rip), %rdi     # 0x1f380
imulq $0x30, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x4, %rsi
addq $0x18, %rsi
movl $0x61a80, %eax          # imm = 0x61A80
subl 0xc264(%rip), %eax      # 0xf2d0
imull $0x30, %eax, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x2260
movq -0x10(%rbp), %rsi
addq $0x4, %rsi
addq $0x18, %rsi
movl $0x61a80, %eax          # imm = 0x61A80
subl 0xc241(%rip), %eax      # 0xf2d0
imull $0x30, %eax, %eax
movl %eax, %eax
addq %rax, %rsi
movl -0x14(%rbp), %eax
movl $0x61a80, %ecx          # imm = 0x61A80
subl 0xc22b(%rip), %ecx      # 0xf2d0
subl %ecx, %eax
imull $0x30, %eax, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1c2cb(%rip), %rdi     # 0x1f380
callq 0x2260
movl -0x14(%rbp), %eax
addl 0xc20d(%rip), %eax      # 0xf2d0
subl $0x61a80, %eax          # imm = 0x61A80
movl %eax, 0xc202(%rip)      # 0xf2d0
jmp 0x310b
movl 0xc1fa(%rip), %eax      # 0xf2d0
leaq 0x1c2a3(%rip), %rdi     # 0x1f380
imulq $0x30, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x4, %rsi
addq $0x18, %rsi
imull $0x30, -0x14(%rbp), %eax
movslq %eax, %rdx
callq 0x2260
movl -0x14(%rbp), %eax
addl 0xc1cb(%rip), %eax      # 0xf2d0
movl %eax, 0xc1c5(%rip)      # 0xf2d0
movl -0x14(%rbp), %eax
addl 0xc1c0(%rip), %eax      # 0xf2d4
movl %eax, 0xc1ba(%rip)      # 0xf2d4
movl -0x14(%rbp), %esi
movl 0xc1b1(%rip), %edx      # 0xf2d4
leaq 0x6f0c(%rip), %rdi      # 0xa036
movb $0x0, %al
callq 0x2040
cmpl $0xfa0, 0xc199(%rip)    # imm = 0xFA0
jl 0x3149
leaq 0x6ab12ef4(%rip), %rdi  # 0x6ab16038
callq 0x2030
leaq 0xc190(%rip), %rdi      # 0xf2e0
callq 0x21f0
ud2
nopw (%rax,%rax)