// File: flordan[P]ipc_benchmark/pipe/consumer.cpp
// Function: main
int main()
{
    std::cout.precision(17);
    std::cout << "Consumer runnning" << std::endl;
    std::string mystr;
    struct timeval st;

    int max = 0;
    int min = 10000000;
    int total = 0;
    for (int i = 0; i < LATENCY_PROBES; i++)
    {
        std::cin >> mystr;
        gettimeofday(&st, NULL);
        double send;
        std::sscanf(mystr.c_str(), "%lf", &send);
        int send_secs = (int)send;
        int send_usec = ((send - send_secs)*10000000)-1000000;
        send = (double)send_secs+((double)send_usec/(double)1000000);
        double now = (double)st.tv_sec + ((double)st.tv_usec)/(double)1000000;
        double diff = (now - send) * 1000000;
        if (diff < 0)
        {
            diff += 1000000;
        }
        total += diff;
        if (diff > max)
        {
            max = diff;
        }
        if (diff < min)
        {
            min = diff;
        }
    }
    std::cout << "Latency test results" << std::endl;
    std::cout << "Average " << total / LATENCY_PROBES << " us" << std::endl;
    std::cout << "Max time " << max << " us" << std::endl;
    std::cout << "Min time " << min << " us" << std::endl;
}

// Assembly:
subq $0xc8, %rsp
movl $0x0, 0xc4(%rsp)
movq 0x2d87(%rip), %rax      # 0x3fd0
movq (%rax), %rax
movq 0x2d7d(%rip), %rdi      # 0x3fd0
addq -0x18(%rax), %rdi
movl $0x11, %esi
callq 0x1600
movq 0x2d68(%rip), %rdi      # 0x3fd0
leaq 0xdb1(%rip), %rsi       # 0x2020
callq 0x1070
movq %rax, %rdi
movq 0x2d42(%rip), %rsi      # 0x3fc0
callq 0x1080
leaq 0xa0(%rsp), %rdi
callq 0x10a0
movl $0x0, 0x8c(%rsp)
movl $0x989680, 0x88(%rsp) # imm = 0x989680
movl $0x0, 0x84(%rsp)
movl $0x0, 0x80(%rsp)
cmpl $0x3e8, 0x80(%rsp) # imm = 0x3E8
jge 0x1476
movq 0x2d0c(%rip), %rdi      # 0x3fe0
leaq 0xa0(%rsp), %rsi
callq 0x1090
jmp 0x12e3
leaq 0x90(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10c0
leaq 0xa0(%rsp), %rdi
callq 0x1030
movq %rax, %rdi
leaq 0xd27(%rip), %rsi       # 0x2032
leaq 0x68(%rsp), %rdx
movb $0x0, %al
callq 0x1060
cvttsd2si 0x68(%rsp), %eax
movl %eax, 0x64(%rsp)
movsd 0x68(%rsp), %xmm0
cvtsi2sdl 0x64(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd 0xcd7(%rip), %xmm1      # 0x2010
mulsd %xmm1, %xmm0
movsd 0xcd3(%rip), %xmm1      # 0x2018
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x60(%rsp)
cvtsi2sdl 0x64(%rsp), %xmm0
cvtsi2sdl 0x60(%rsp), %xmm1
movsd 0xca3(%rip), %xmm2      # 0x2008
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
cvtsi2sdq 0x90(%rsp), %xmm0
cvtsi2sdq 0x98(%rsp), %xmm1
movsd 0xc79(%rip), %xmm2      # 0x2008
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
subsd 0x68(%rsp), %xmm0
movsd 0xc57(%rip), %xmm1      # 0x2008
mulsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x50(%rsp), %xmm0
jbe 0x13fc
movsd 0xc3a(%rip), %xmm0      # 0x2008
addsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0x13fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x1040
jmp 0x15eb
movsd 0x50(%rsp), %xmm1
cvtsi2sdl 0x84(%rsp), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x84(%rsp)
movsd 0x50(%rsp), %xmm0
cvtsi2sdl 0x8c(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x143c
cvttsd2si 0x50(%rsp), %eax
movl %eax, 0x8c(%rsp)
movsd 0x50(%rsp), %xmm1
cvtsi2sdl 0x88(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x145e
cvttsd2si 0x50(%rsp), %eax
movl %eax, 0x88(%rsp)
jmp 0x1460
movl 0x80(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x12bc
movq 0x2b53(%rip), %rdi      # 0x3fd0
leaq 0xbb2(%rip), %rsi       # 0x2036
callq 0x1070
movq %rax, 0x48(%rsp)
jmp 0x1490
movq 0x48(%rsp), %rdi
movq 0x2b24(%rip), %rsi      # 0x3fc0
callq 0x1080
jmp 0x14a3
movq 0x2b26(%rip), %rdi      # 0x3fd0
leaq 0xb9a(%rip), %rsi       # 0x204b
callq 0x1070
movq %rax, 0x40(%rsp)
jmp 0x14bd
movq 0x40(%rsp), %rdi
movslq 0x84(%rsp), %rax
imulq $0x10624dd3, %rax, %rcx # imm = 0x10624DD3
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x26, %rcx
movl %ecx, %esi
addl %eax, %esi
callq 0x10d0
movq %rax, 0x38(%rsp)
jmp 0x14ec
movq 0x38(%rsp), %rdi
leaq 0xb5c(%rip), %rsi       # 0x2054
callq 0x1070
movq %rax, 0x30(%rsp)
jmp 0x1504
movq 0x30(%rsp), %rdi
movq 0x2ab0(%rip), %rsi      # 0x3fc0
callq 0x1080
jmp 0x1517
movq 0x2ab2(%rip), %rdi      # 0x3fd0
leaq 0xb33(%rip), %rsi       # 0x2058
callq 0x1070
movq %rax, 0x28(%rsp)
jmp 0x1531
movq 0x28(%rsp), %rdi
movl 0x8c(%rsp), %esi
callq 0x10d0
movq %rax, 0x20(%rsp)
jmp 0x1549
movq 0x20(%rsp), %rdi
leaq 0xaff(%rip), %rsi       # 0x2054
callq 0x1070
movq %rax, 0x18(%rsp)
jmp 0x1561
movq 0x18(%rsp), %rdi
movq 0x2a53(%rip), %rsi      # 0x3fc0
callq 0x1080
jmp 0x1574
movq 0x2a55(%rip), %rdi      # 0x3fd0
leaq 0xae0(%rip), %rsi       # 0x2062
callq 0x1070
movq %rax, 0x10(%rsp)
jmp 0x158e
movq 0x10(%rsp), %rdi
movl 0x88(%rsp), %esi
callq 0x10d0
movq %rax, 0x8(%rsp)
jmp 0x15a6
movq 0x8(%rsp), %rdi
leaq 0xaa2(%rip), %rsi       # 0x2054
callq 0x1070
movq %rax, (%rsp)
jmp 0x15bd
movq (%rsp), %rdi
movq 0x29f8(%rip), %rsi      # 0x3fc0
callq 0x1080
jmp 0x15cf
leaq 0xa0(%rsp), %rdi
callq 0x1040
movl 0xc4(%rsp), %eax
addq $0xc8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0x10e0
nopw %cs:(%rax,%rax)
nop