// File: /workspace/github_c_makefile_star2_O0/pencode-lab[P]Shoit/shoit_receiver.c
// Function: progress_thread_run
static void progress_thread_run(void *argv)
{
    shoit_core_t *receiver = (shoit_core_t*)argv; 
    int done=0;
    int prog=0;
    struct timeval curTime, startTime;

    sem_wait(&receiver->progSem);
    if(!receiver->runing) pthread_exit(0);

    shoit_progress_init(&progress, "", 100, PROGRESS_NUM_STYLE);
    if(receiver->iStream){
        SHOIT_LOG("Mbit/s      Recv(Kbytes)  time(s)\n") ;
        gettimeofday(&startTime, NULL);
        while(!done && receiver->runing){
            gettimeofday(&curTime, NULL);
            progress.utime = (curTime.tv_sec - startTime.tv_sec) + 1e-6*(curTime.tv_usec - startTime.tv_usec);
            shoit_progress_for_stream(receiver->log,&progress,0);
            usleep(1000000);
        }                                                                                                                            
                                                                                                                                     
    }else{    

        SHOIT_LOG("Mbit/s      recv/total(Kbytes)  time(s)     progress\n") ;
        gettimeofday(&startTime, NULL);
        while(!done && receiver->runing){
            prog = (float) progress.total / (float) receiver->fileSize * 100;
            gettimeofday(&curTime, NULL);
            progress.utime = (curTime.tv_sec - startTime.tv_sec) +1e-6*(curTime.tv_usec - startTime.tv_usec);
            shoit_progress_show_all(receiver->log,&progress,(int)prog/100.0f,(long)(receiver->fileSize >>10));
            usleep(1000000);
        }
    }

    gettimeofday(&curTime, NULL);
    SHOIT_LOG("\n");
    {//show complete info

        float dt = (curTime.tv_sec - startTime.tv_sec) + 1e-6*(curTime.tv_usec - startTime.tv_usec-1000000);
        uint64_t got =progress.total; 
        float mbps = 1e-6 * 8 * got / (dt==0 ? .01 : dt);                                                                        

        if(receiver->iStream)
            SHOIT_LOG("\nComplete transfer %dK in %.2fs (%g Mbit/s)",(long)(got>>10), dt, mbps);
        else
            SHOIT_LOG("\nComplete transfer %d/%dK in %.2fs (%g Mbit/s)",(long)(got>>10), (long)(receiver->bucketSize>>10), dt, mbps);
    }
    shoit_progress_destroy(&progress);
    pthread_exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
callq 0x2080
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1a8(%rax)
jne 0x688b
xorl %eax, %eax
movl %eax, %edi
callq 0x22d0
leaq 0x5a46(%rip), %rdi      # 0xc2d8
leaq 0x2a24(%rip), %rsi      # 0x92bd
movl $0x64, %edx
xorl %ecx, %ecx
callq 0x41d0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1a4(%rax)
je 0x6974
jmp 0x68b8
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
leaq 0x33dd(%rip), %rsi      # 0x9ca7
movb $0x0, %al
callq 0x3df0
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2180
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0x4d(%rbp)
jne 0x68fa
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1a8(%rax)
setne %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x6903
jmp 0x696f
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2180
movq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
cvtsi2sd %rax, %xmm1
movq -0x20(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x2dbe(%rip), %xmm2     # 0x96f0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x59c2(%rip)     # 0xc308
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
leaq 0x5980(%rip), %rsi      # 0xc2d8
xorps %xmm0, %xmm0
callq 0x45b0
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x24a0
jmp 0x68de
jmp 0x6af0
jmp 0x6976
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
leaq 0x3342(%rip), %rsi      # 0x9cca
movb $0x0, %al
callq 0x3df0
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2180
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0x4e(%rbp)
jne 0x69b8
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1a8(%rax)
setne %al
movb %al, -0x4e(%rbp)
movb -0x4e(%rbp), %al
testb $0x1, %al
jne 0x69c4
jmp 0x6aee
movq 0x5935(%rip), %rax      # 0xc300
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x58(%rbp)
testq %rax, %rax
movss %xmm0, -0x54(%rbp)
js 0x6a00
movss -0x58(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x60(%rbp)
testq %rax, %rax
movss %xmm0, -0x5c(%rbp)
js 0x6a47
movss -0x60(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
movss -0x64(%rbp), %xmm0
movss -0x5c(%rbp), %xmm1
divss %xmm1, %xmm0
movss 0x2b87(%rip), %xmm1     # 0x95e4
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x18(%rbp)
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2180
movq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
cvtsi2sd %rax, %xmm1
movq -0x20(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x2c59(%rip), %xmm2     # 0x96f0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x585d(%rip)     # 0xc308
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
cvtsi2ssl -0x18(%rbp), %xmm0
movss 0x2b21(%rip), %xmm1     # 0x95e4
divss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
shrq $0xa, %rdx
leaq 0x57fe(%rip), %rsi      # 0xc2d8
callq 0x4410
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x24a0
jmp 0x699c
jmp 0x6af0
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2180
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
leaq 0x27ad(%rip), %rsi      # 0x92bc
movb $0x0, %al
callq 0x3df0
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rcx
subq %rsi, %rdx
cvtsi2sd %rdx, %xmm1
subq %rcx, %rax
addq $-0xf4240, %rax         # imm = 0xFFF0BDC0
cvtsi2sd %rax, %xmm0
movsd 0x2bac(%rip), %xmm2     # 0x96f0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
movq 0x57a4(%rip), %rax      # 0xc300
movq %rax, -0x48(%rbp)
movaps 0x2a99(%rip), %xmm0     # 0x9600
movq -0x48(%rbp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x2a98(%rip), %xmm0     # 0x9610
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x2a59(%rip), %xmm0     # 0x95e8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movss -0x3c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x6bb6
jp 0x6bb6
movsd 0x2a41(%rip), %xmm0     # 0x95f0
movsd %xmm0, -0x78(%rbp)
jmp 0x6bc4
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x70(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x4c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1a4(%rax)
je 0x6c1f
jmp 0x6bea
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
movq -0x48(%rbp), %rdx
shrq $0xa, %rdx
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x4c(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x2e8f(%rip), %rsi      # 0x9aa5
movb $0x2, %al
callq 0x3df0
jmp 0x6c62
jmp 0x6c21
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rdi
movq -0x48(%rbp), %rdx
shrq $0xa, %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0xa, %rcx
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x4c(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x2e78(%rip), %rsi      # 0x9ad1
movb $0x2, %al
callq 0x3df0
jmp 0x6c62
leaq 0x566f(%rip), %rdi      # 0xc2d8
callq 0x4710
xorl %eax, %eax
movl %eax, %edi
callq 0x22d0
nopw (%rax,%rax)