float do_compute(comp_delay)
float comp_delay;
{
  double starttime, tmptime;
  if (comp_delay == (float)0.0)
    return (0.0);
  starttime = time_so_far();
  while (1) {
    tmptime = time_so_far() - starttime;
    if (tmptime >= (double)comp_delay)
      return (tmptime);
  }
}


x86 assembly (clang, -O0):
<do_compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1145 <do_compute+0x35>
jp     1145 <do_compute+0x35>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    119a <do_compute+0x8a>
mov    $0x0,%al
call   1030 <time_so_far@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <time_so_far@plt>
cvtsi2sd %eax,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1195 <do_compute+0x85>
movsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    119a <do_compute+0x8a>
jmp    1155 <do_compute+0x45>
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_compute>:
cvtsd2ss %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    111f <do_compute+0xf>
jp     111f <do_compute+0xf>
ret
sub    $0x18,%rsp
xor    %eax,%eax
movss  %xmm1,0x8(%rsp)
call   1030 <time_so_far@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
nopl   (%rax)
xor    %eax,%eax
call   1030 <time_so_far@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
subsd  0x10(%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
jb     1150 <do_compute+0x40>
cvtsd2ss %xmm0,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @do_compute(double %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca double
%5 = alloca double
%6 = fptrunc double %0 to float
store float %6, float* %3
%7 = load float, float* %3
%8 = fcmp oeq float %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %1
store float 0.000000e+00, float* %2
br label %26
10: ; preds = %1
%11 = call i32 (...) @time_so_far()
%12 = sitofp i32 %11 to double
store double %12, double* %4
br label %13
13: ; preds = %10, %25
%14 = call i32 (...) @time_so_far()
%15 = sitofp i32 %14 to double
%16 = load double, double* %4
%17 = fsub double %15, %16
store double %17, double* %5
%18 = load double, double* %5
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = fcmp oge double %18, %20
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = load double, double* %5
%24 = fptrunc double %23 to float
store float %24, float* %2
br label %26
25: ; preds = %13
br label %13
26: ; preds = %22, %9
%27 = load float, float* %2
ret float %27
}

LLVM IR (-O2):
define float @do_compute(double %0) {
%2 = fptrunc double %0 to float
%3 = fcmp oeq float %2, 0.000000e+00
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = tail call i32 (...) @time_so_far()
%6 = sitofp i32 %5 to double
%7 = fpext float %2 to double
br label %8
8: ; preds = %8, %4
%9 = tail call i32 (...) @time_so_far()
%10 = sitofp i32 %9 to double
%11 = fsub double %10, %6
%12 = fcmp ult double %11, %7
br i1 %12, label %8, label %13
13: ; preds = %8
%14 = fptrunc double %11 to float
br label %15
15: ; preds = %1, %13
%16 = phi float [ %14, %13 ], [ 0.000000e+00, %1 ]
ret float %16
}