// File: yueww[P]TSR/produceFlows.c
// Function: receiveData(void*)
void *receiveData(void *argv){
    pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL);
    pThreadPool=threadpool_init(4,rDataCacheSize);
    pthread_cleanup_push(cleanup,(void *)pThreadPool);
    int sockfd;
    struct sockaddr_in servaddr;
    sockfd=socket(AF_INET,SOCK_DGRAM,0);
    memset(&servaddr,0,sizeof(servaddr));
    servaddr.sin_family=AF_INET;
    servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
    servaddr.sin_port=htons(555);
    int res=bind(sockfd,(struct sockaddr *)&servaddr,sizeof(servaddr));
    if(res==-1){
        printf("bind failed!\n");
        pthread_exit(0);
    }
    long long  count=0;
    pthread_t tid;
    while(1){
        rDataCache[count%rDataCacheSize].length=recvfrom(sockfd,rDataCache[count%rDataCacheSize].buf,BUFSIZE,0,0,0);
        //pthread_create(&tid,0,produce,(void *)&rDataCache[count%rDataCacheSize]);
        threadpool_add_task(pThreadPool,produce,(void *)&rDataCache[count%rDataCacheSize]);
        count++;
    }
    pthread_cleanup_pop(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x20d0
movl $0x4, %edi
movl $0x10, %esi
callq 0x2740
movq %rax, 0xc4c8(%rip)      # 0xf2d8
movq 0xc4c1(%rip), %rdx      # 0xf2d8
leaq -0x20(%rbp), %rdi
leaq -0xc2(%rip), %rsi       # 0x2d60
callq 0x3390
movl $0x2, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x20a0
movl %eax, -0x24(%rbp)
leaq -0x34(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2170
movw $0x2, -0x34(%rbp)
xorl %edi, %edi
callq 0x2200
movl %eax, -0x30(%rbp)
movl $0x22b, %edi            # imm = 0x22B
callq 0x2050
movw %ax, -0x32(%rbp)
movl -0x24(%rbp), %edi
leaq -0x34(%rbp), %rsi
movl $0x10, %edx
callq 0x2070
movl %eax, -0x38(%rbp)
cmpl $-0x1, -0x38(%rbp)
jne 0x2eb5
leaq 0x71a1(%rip), %rdi      # 0xa028
xorl %eax, %eax
callq 0x2040
jmp 0x2e90
xorl %eax, %eax
movl %eax, %edi
callq 0x24f0
jmp 0x2e9b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x33c0
jmp 0x2fa5
movq $0x0, -0x50(%rbp)
jmp 0x2ebf
movl -0x24(%rbp), %edi
movq -0x50(%rbp), %rcx
movq %rcx, %rdx
addq $0xf, %rdx
testq %rcx, %rcx
movq %rcx, %rax
cmovsq %rdx, %rax
movabsq $0x3ffffffffffffff0, %rdx # imm = 0x3FFFFFFFFFFFFFF0
andq %rdx, %rax
subq %rax, %rcx
movq %rcx, %rax
shlq $0xc, %rax
leaq (%rax,%rcx,4), %rcx
leaq 0xc447(%rip), %rax      # 0xf340
leaq 0x4(%rax,%rcx), %rsi
xorl %ecx, %ecx
movl %ecx, %r9d
movl $0x1000, %edx           # imm = 0x1000
movq %r9, %r8
callq 0x2210
movq %rax, -0x60(%rbp)
jmp 0x2f16
movq -0x60(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rdx
movq %rdx, %rsi
addq $0xf, %rsi
testq %rdx, %rdx
movq %rdx, %rax
cmovsq %rsi, %rax
movabsq $0x3ffffffffffffff0, %rsi # imm = 0x3FFFFFFFFFFFFFF0
andq %rsi, %rax
subq %rax, %rdx
movq %rdx, %rax
shlq $0xc, %rax
leaq (%rax,%rdx,4), %rax
leaq 0xc3ed(%rip), %rdx      # 0xf340
movl %ecx, (%rdx,%rax)
movq 0xc37b(%rip), %rdi      # 0xf2d8
movq -0x50(%rbp), %rcx
movq %rcx, %r8
addq $0xf, %r8
testq %rcx, %rcx
movq %rcx, %rax
cmovsq %r8, %rax
andq %rsi, %rax
subq %rax, %rcx
movq %rcx, %rax
shlq $0xc, %rax
leaq (%rax,%rcx,4), %rax
addq %rax, %rdx
leaq 0x23(%rip), %rsi        # 0x2fb0
callq 0x2b90
jmp 0x2f94
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x2ebd
movq -0x40(%rbp), %rdi
callq 0x24e0
nop