// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0x1, %edi
xorl %esi, %esi
callq 0x20c0
callq 0x2270
movq %rax, %rdi
callq 0x2190
leaq 0x42b5(%rip), %rdi      # 0x7061
leaq 0x42b5(%rip), %rsi      # 0x7068
callq 0x2320
testq %rax, %rax
je 0x2f1a
movq %rax, %rbx
movq %rax, %rdi
callq 0x2460
testl %eax, %eax
jne 0x2f04
leaq 0x74e5(%rip), %r14      # 0xa2c0
leaq 0x7506(%rip), %r15      # 0xa2e8
leaq 0x17577(%rip), %r12     # 0x1a360
movq %r14, %rdi
callq 0x23f0
cmpl $0x60ae1, 0x74b9(%rip)  # imm = 0x60AE1
jl 0x2e14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2430
cmpl $0x60ae0, 0x74a2(%rip)  # imm = 0x60AE0
jg 0x2dfd
cmpl $0x61a80, 0x7492(%rip)  # imm = 0x61A80
jne 0x2e2a
movl $0x0, 0x7486(%rip)      # 0xa2b0
movl 0x7480(%rip), %eax      # 0xa2b0
leal -0x60ae1(%rax), %ecx
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %r12, %rdi
cmpl $0xfff9e57e, %ecx       # imm = 0xFFF9E57E
ja 0x2e93
movl $0x61a80, %edx          # imm = 0x61A80
subl %eax, %edx
movl $0x30, %esi
movq %rbx, %rcx
callq 0x2410
movq %rax, %r13
movl 0x744a(%rip), %edx      # 0xa2b0
movl $0xfff9f520, %eax       # imm = 0xFFF9F520
addl %eax, %edx
movl $0x30, %esi
movq %r12, %rdi
movq %rbx, %rcx
callq 0x2410
addl %eax, %r13d
jne 0x2ead
leaq 0x420f(%rip), %rdi      # 0x7098
callq 0x2450
xorl %r13d, %r13d
jmp 0x2eb4
movl $0x30, %esi
movl $0xfa0, %edx            # imm = 0xFA0
movq %rbx, %rcx
callq 0x2410
movq %rax, %r13
testl %r13d, %r13d
je 0x2e82
addl %r13d, 0x73fc(%rip)     # 0xa2b0
movl 0x73fa(%rip), %edx      # 0xa2b4
addl %r13d, %edx
movl %edx, 0x73f1(%rip)      # 0xa2b4
leaq 0x4179(%rip), %rdi      # 0x7043
movl %r13d, %esi
xorl %eax, %eax
callq 0x2040
cmpl $0xfa0, 0x73d6(%rip)    # imm = 0xFA0
jl 0x2eec
leaq 0x6ab0e131(%rip), %rdi  # 0x6ab11018
callq 0x2030
movq %r14, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x2460
testl %eax, %eax
je 0x2de9
movq %rbx, %rdi
callq 0x22c0
leaq 0x4165(%rip), %rdi      # 0x7078
callq 0x2450
jmp 0x2f18
leaq 0x41a3(%rip), %rdi      # 0x70c4
callq 0x2450
xorl %edi, %edi
callq 0x2350
nopl (%rax)