// File: /workspace/github_cpp_makefile_star2_O2/yueww[P]TSR/produceFlows.c
// Function: produceFromFile(void*)
void *produceFromFile(void *arg){
    pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL);
    pthread_detach(pthread_self());
    FILE *fp=fopen("./data","rb");
    if(fp==NULL){
        printf("fail to open file!\n");
        exit(0);
    }
    while(!feof(fp)){
        int newFlows=FLOWSPERPROCESS;
        int readNum=0;
        pthread_mutex_lock(&mutex);
        while(n+newFlows>BLOCKSIZE) pthread_cond_wait(&cond_p,&mutex);
        if(in==BLOCKSIZE) in=0;
        if((in+newFlows)>BLOCKSIZE){
            readNum=fread(flowBlock+in,FLOWSIZE,BLOCKSIZE-in,fp);
            readNum+=fread(flowBlock,FLOWSIZE,(newFlows-(BLOCKSIZE-in)),fp);
            if(readNum==0){
                printf("error in reading flows or come to file end!\n");
            }else{
                in+=readNum;
            }
        }else{
            readNum=fread(flowBlock+in,FLOWSIZE,newFlows,fp);
            if(readNum==0){
                printf("error in reading flows or come to file end!\n");
            }else{
                in+=readNum;
            }
        }
        n+=readNum;
        printf("add %d flows,current n is %d\n",readNum,n);
        if(n>=FLOWSPERPROCESS) pthread_cond_signal(&cond_c);
        pthread_mutex_unlock(&mutex);
    }
    fclose(fp);
    printf("there is no more flows in flie!\n");
    while(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
pushq $0x1
popq %rdi
xorl %esi, %esi
callq 0x20c0
callq 0x2280
movq %rax, %rdi
callq 0x21a0
leaq 0x33a3(%rip), %rdi      # 0x6061
leaq 0x33a3(%rip), %rsi      # 0x6068
callq 0x2330
testq %rax, %rax
je 0x2e2d
movq %rax, %rbx
leaq 0x65d3(%rip), %r14      # 0x92b0
leaq 0x65f4(%rip), %r15      # 0x92d8
pushq $0x30
popq %r13
movq %rax, -0x30(%rbp)
movq %rbx, %rdi
callq 0x2460
testl %eax, %eax
jne 0x2e17
movq %r14, %rdi
callq 0x23f0
cmpl $0x60ae1, 0x6596(%rip)  # imm = 0x60AE1
jl 0x2d1d
movq %r15, %rdi
movq %r14, %rsi
callq 0x2430
jmp 0x2d04
movl 0x657d(%rip), %eax      # 0x92a0
cmpq $0x61a80, %rax          # imm = 0x61A80
jne 0x2d36
andl $0x0, 0x656e(%rip)      # 0x92a0
xorl %eax, %eax
jmp 0x2da3
leal -0x60ae1(%rax), %ecx
cmpl $0xfff9e57e, %ecx       # imm = 0xFFF9E57E
ja 0x2da3
imulq $0x30, %rax, %rdi
movq %r13, %rbx
leaq 0x165fe(%rip), %r13     # 0x19350
addq %r13, %rdi
movl $0x61a80, %edx          # imm = 0x61A80
subl %eax, %edx
movq %rbx, %rsi
movq -0x30(%rbp), %rcx
callq 0x2410
movq %rax, %r12
movl 0x652f(%rip), %edx      # 0x92a0
movl $0xfff9f520, %eax       # imm = 0xFFF9F520
addl %eax, %edx
movq %r13, %rdi
movq %rbx, %r13
movq -0x30(%rbp), %rbx
movq %r13, %rsi
movq %rbx, %rcx
callq 0x2410
addl %eax, %r12d
jne 0x2dcb
leaq 0x32ff(%rip), %rdi      # 0x6098
callq 0x2450
xorl %r12d, %r12d
jmp 0x2dd2
movl %eax, %eax
imulq $0x30, %rax, %rdi
leaq 0x165a0(%rip), %rax     # 0x19350
addq %rax, %rdi
movl $0xfa0, %edx            # imm = 0xFA0
movq %r13, %rsi
movq %rbx, %rcx
callq 0x2410
movq %rax, %r12
testl %r12d, %r12d
je 0x2d92
addl %r12d, 0x64ce(%rip)     # 0x92a0
movl 0x64cc(%rip), %edx      # 0x92a4
addl %r12d, %edx
movl %edx, 0x64c3(%rip)      # 0x92a4
leaq 0x325b(%rip), %rdi      # 0x6043
movl %r12d, %esi
xorl %eax, %eax
callq 0x2040
cmpl $0xfa0, 0x64a8(%rip)    # imm = 0xFA0
jl 0x2e0a
leaq 0x6ab0d203(%rip), %rdi  # 0x6ab10008
callq 0x2030
movq %r14, %rdi
callq 0x21f0
jmp 0x2cec
movq %rbx, %rdi
callq 0x22d0
leaq 0x3252(%rip), %rdi      # 0x6078
callq 0x2450
jmp 0x2e2b
leaq 0x3290(%rip), %rdi      # 0x60c4
callq 0x2450
xorl %edi, %edi
callq 0x2360