// File: /workspace/github_cpp_makefile_star2_O3/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 0x42bc(%rip), %rdi      # 0x7061
leaq 0x42bc(%rip), %rsi      # 0x7068
callq 0x2320
testq %rax, %rax
je 0x2f20
movq %rax, %rbx
movq %rax, %rdi
callq 0x2450
testl %eax, %eax
jne 0x2f0a
leaq 0x74dc(%rip), %r14      # 0xa2b0
leaq 0x74fd(%rip), %r15      # 0xa2d8
leaq 0x1756e(%rip), %r12     # 0x1a350
movq %r14, %rdi
callq 0x23e0
cmpl $0x60ae1, 0x74b0(%rip)  # imm = 0x60AE1
jl 0x2e0d
movq %r15, %rdi
movq %r14, %rsi
callq 0x2420
cmpl $0x60ae0, 0x7499(%rip)  # imm = 0x60AE0
jg 0x2df6
movl 0x748d(%rip), %eax      # 0xa2a0
cmpq $0x61a80, %rax          # imm = 0x61A80
jne 0x2e29
movl $0x0, 0x747b(%rip)      # 0xa2a0
xorl %eax, %eax
jmp 0x2e8c
leal -0x60ae1(%rax), %ecx
cmpl $0xfff9e57e, %ecx       # imm = 0xFFF9E57E
ja 0x2e8c
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %r12, %rdi
movl $0x61a80, %edx          # imm = 0x61A80
subl %eax, %edx
movl $0x30, %esi
movq %rbx, %rcx
callq 0x2400
movq %rax, %r13
movl 0x7441(%rip), %edx      # 0xa2a0
movl $0xfff9f520, %eax       # imm = 0xFFF9F520
addl %eax, %edx
movl $0x30, %esi
movq %r12, %rdi
movq %rbx, %rcx
callq 0x2400
addl %eax, %r13d
jne 0x2eb3
leaq 0x4216(%rip), %rdi      # 0x7098
callq 0x2440
xorl %r13d, %r13d
jmp 0x2eba
movl %eax, %eax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %r12, %rdi
movl $0x30, %esi
movl $0xfa0, %edx            # imm = 0xFA0
movq %rbx, %rcx
callq 0x2400
movq %rax, %r13
testl %r13d, %r13d
je 0x2e7b
addl %r13d, 0x73e6(%rip)     # 0xa2a0
movl 0x73e4(%rip), %edx      # 0xa2a4
addl %r13d, %edx
movl %edx, 0x73db(%rip)      # 0xa2a4
leaq 0x4173(%rip), %rdi      # 0x7043
movl %r13d, %esi
xorl %eax, %eax
callq 0x2040
cmpl $0xfa0, 0x73c0(%rip)    # imm = 0xFA0
jl 0x2ef2
leaq 0x6ab0e11b(%rip), %rdi  # 0x6ab11008
callq 0x2030
movq %r14, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x2450
testl %eax, %eax
je 0x2de2
movq %rbx, %rdi
callq 0x22c0
leaq 0x415f(%rip), %rdi      # 0x7078
callq 0x2440
jmp 0x2f1e
leaq 0x419d(%rip), %rdi      # 0x70c4
callq 0x2440
xorl %edi, %edi
callq 0x2350
nop