// File: giovannarosone[P]BCR_LCP_GSA/Timer.cpp
// Function: Timer::print(std::ostream&)
std::ostream& Timer::print(std::ostream& os)
{
    if (gettimeofday(&thisTime_, NULL) != 0)
        exit(-1);
    if (getrusage(RUSAGE_SELF, &thisUsage_) != 0)
        exit(-1);

    static double elapsedActual, elapsedUser, elapsedSystem;

    elapsedUser = thisUsage_.ru_utime.tv_sec - lastUsage_.ru_utime.tv_sec
            + (thisUsage_.ru_utime.tv_usec
                    - (double) lastUsage_.ru_utime.tv_usec) / 1000000;

    elapsedSystem = thisUsage_.ru_stime.tv_sec - lastUsage_.ru_stime.tv_sec
            + (thisUsage_.ru_stime.tv_usec
                    - (double) lastUsage_.ru_stime.tv_usec) / 1000000;

    elapsedActual = thisTime_.tv_sec - lastTime_.tv_sec + (thisTime_.tv_usec
            - (double) lastTime_.tv_usec) / 1000000;

    os << "User: " << elapsedUser << "s System: " << elapsedSystem
            << "s Actual: " << elapsedActual << "s Efficiency: "
            << ((elapsedActual == 0) ? 0 : ((elapsedUser + elapsedSystem)
                    * 100.0 / elapsedActual)) << '\045'; // only way to print % liked by both Intel and gcc!
    lastTime_ = thisTime_;
    lastUsage_ = thisUsage_;
    return os;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rdi
movq %rdi, 0x10(%rsp)
addq $0x120, %rdi            # imm = 0x120
xorl %eax, %eax
movl %eax, %esi
callq 0x3420
cmpl $0x0, %eax
je 0x17547
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3300
movq 0x10(%rsp), %rsi
xorl %edi, %edi
callq 0x3160
cmpl $0x0, %eax
je 0x17562
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3300
movq 0x10(%rsp), %rax
movq (%rax), %rcx
subq 0x90(%rax), %rcx
cvtsi2sd %rcx, %xmm0
cvtsi2sdq 0x8(%rax), %xmm1
cvtsi2sdq 0x98(%rax), %xmm2
subsd %xmm2, %xmm1
movsd 0x21e7(%rip), %xmm2     # 0x19778
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x8dc7(%rip)     # 0x20368
movq 0x10(%rax), %rcx
subq 0xa0(%rax), %rcx
cvtsi2sd %rcx, %xmm0
cvtsi2sdq 0x18(%rax), %xmm1
cvtsi2sdq 0xa8(%rax), %xmm2
subsd %xmm2, %xmm1
movsd 0x21ac(%rip), %xmm2     # 0x19778
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x8d94(%rip)     # 0x20370
movq 0x120(%rax), %rcx
subq 0x130(%rax), %rcx
cvtsi2sd %rcx, %xmm0
cvtsi2sdq 0x128(%rax), %xmm1
cvtsi2sdq 0x138(%rax), %xmm2
subsd %xmm2, %xmm1
movsd 0x216b(%rip), %xmm2     # 0x19778
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x8d43(%rip)     # 0x20360
movq 0x18(%rsp), %rdi
leaq 0x215f(%rip), %rsi      # 0x19788
callq 0x3260
movq %rax, %rdi
movsd 0x8d2f(%rip), %xmm0     # 0x20368
callq 0x3500
movq %rax, %rdi
leaq 0x2147(%rip), %rsi      # 0x1978f
callq 0x3260
movq %rax, %rdi
movsd 0x8d18(%rip), %xmm0     # 0x20370
callq 0x3500
movq %rax, %rdi
leaq 0x2133(%rip), %rsi      # 0x1979a
callq 0x3260
movq %rax, %rdi
movsd 0x8ce9(%rip), %xmm0     # 0x20360
callq 0x3500
movq %rax, %rdi
leaq 0x211f(%rip), %rsi      # 0x197a5
callq 0x3260
movq %rax, 0x8(%rsp)
movsd 0x8cc8(%rip), %xmm0     # 0x20360
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x176ad
jp 0x176ad
xorps %xmm0, %xmm0
movsd %xmm0, (%rsp)
jmp 0x176d6
movsd 0x8cb3(%rip), %xmm0     # 0x20368
addsd 0x8cb3(%rip), %xmm0     # 0x20370
movsd 0x20bb(%rip), %xmm1     # 0x19780
mulsd %xmm1, %xmm0
divsd 0x8c8f(%rip), %xmm0     # 0x20360
movsd %xmm0, (%rsp)
movq 0x8(%rsp), %rdi
movsd (%rsp), %xmm0
callq 0x3500
movq %rax, %rdi
movl $0x25, %esi
callq 0x32d0
movq 0x10(%rsp), %rsi
movq 0x120(%rsi), %rax
movq %rax, 0x130(%rsi)
movq 0x128(%rsi), %rax
movq %rax, 0x138(%rsi)
movq %rsi, %rdi
addq $0x90, %rdi
movl $0x90, %edx
callq 0x3200
movq 0x18(%rsp), %rax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)