float conv_tempo(smftempo)
long smftempo;
{
  float ftempo, ftempo_better, sc;
  int i;
  if (smftempo == 0)
    smftempo = 1;
  ftempo = 6e7 / smftempo;
  sc = 1.0;
  for (i = 0; i < 4; i++) {
    ftempo_better = floor(ftempo * sc + .5) / sc;
    if (smftempo == floor(6e7 / ftempo_better + .5)) {
      return ftempo_better;
    }
    sc *= 10.0;
  }
  return ftempo;
}


x86 assembly (clang, -O0):
<conv_tempo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    112f <conv_tempo+0x1f>
movq   $0x1,-0x10(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xecb(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xeae(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    1221 <conv_tempo+0x111>
movss  -0x14(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe92(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe4f(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0xe4b(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    11f5 <conv_tempo+0xe5>
jp     11f5 <conv_tempo+0xe5>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    122b <conv_tempo+0x11b>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe12(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115e <conv_tempo+0x4e>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_tempo>:
sub    $0x18,%rsp
test   %rdi,%rdi
mov    $0x1,%eax
cmovne %rdi,%rax
cvtsi2sd %rax,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xecd(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
addsd  0xebb(%rip),%xmm0
call   1030 <floor@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe95(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  0xe91(%rip),%xmm0
call   1030 <floor@plt>
ucomisd 0x10(%rsp),%xmm0
jne    118a <conv_tempo+0x7a>
jnp    12b7 <conv_tempo+0x1a7>
movss  0xe96(%rip),%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe64(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
divsd  0xe5b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe32(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  0xe2e(%rip),%xmm0
call   1030 <floor@plt>
ucomisd 0x10(%rsp),%xmm0
jne    11ed <conv_tempo+0xdd>
jnp    12b7 <conv_tempo+0x1a7>
movss  0xe37(%rip),%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe01(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
divsd  0xe00(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xdcf(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  0xdcb(%rip),%xmm0
call   1030 <floor@plt>
ucomisd 0x10(%rsp),%xmm0
jne    124c <conv_tempo+0x13c>
jnp    12b7 <conv_tempo+0x1a7>
movss  0xddc(%rip),%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xda2(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
divsd  0xda9(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xd70(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  0xd6c(%rip),%xmm0
call   1030 <floor@plt>
ucomisd 0x10(%rsp),%xmm0
jne    12ab <conv_tempo+0x19b>
jnp    12b7 <conv_tempo+0x1a7>
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @conv_tempo(i64 %0) {
%2 = alloca float
%3 = alloca i64
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
store i64 %0, i64* %3
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i64 1, i64* %3
br label %11
11: ; preds = %10, %1
%12 = load i64, i64* %3
%13 = sitofp i64 %12 to double
%14 = fdiv double 6.000000e+07, %13
%15 = fptrunc double %14 to float
store float %15, float* %4
store float 1.000000e+00, float* %6
store i32 0, i32* %7
br label %16
16: ; preds = %45, %11
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 4
br i1 %18, label %19, label %48
19: ; preds = %16
%20 = load float, float* %4
%21 = load float, float* %6
%22 = fmul float %20, %21
%23 = fpext float %22 to double
%24 = fadd double %23, 5.000000e-01
%25 = call double @llvm.floor.f64(double %24)
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = fdiv double %25, %27
%29 = fptrunc double %28 to float
store float %29, float* %5
%30 = load i64, i64* %3
%31 = sitofp i64 %30 to double
%32 = load float, float* %5
%33 = fpext float %32 to double
%34 = fdiv double 6.000000e+07, %33
%35 = fadd double %34, 5.000000e-01
%36 = call double @llvm.floor.f64(double %35)
%37 = fcmp oeq double %31, %36
br i1 %37, label %38, label %40
38: ; preds = %19
%39 = load float, float* %5
store float %39, float* %2
br label %50
40: ; preds = %19
%41 = load float, float* %6
%42 = fpext float %41 to double
%43 = fmul double %42, 1.000000e+01
%44 = fptrunc double %43 to float
store float %44, float* %6
br label %45
45: ; preds = %40
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %16
48: ; preds = %16
%49 = load float, float* %4
store float %49, float* %2
br label %50
50: ; preds = %48, %38
%51 = load float, float* %2
ret float %51
}

LLVM IR (-O2):
define float @conv_tempo(i64 %0) {
%2 = icmp eq i64 %0, 0
%3 = select i1 %2, i64 1, i64 %0
%4 = sitofp i64 %3 to double
%5 = fdiv double 6.000000e+07, %4
%6 = fptrunc double %5 to float
%7 = fpext float %6 to double
%8 = fadd double %7, 5.000000e-01
%9 = tail call double @llvm.floor.f64(double %8)
%10 = fptrunc double %9 to float
%11 = fpext float %10 to double
%12 = fdiv double 6.000000e+07, %11
%13 = fadd double %12, 5.000000e-01
%14 = tail call double @llvm.floor.f64(double %13)
%15 = fcmp oeq double %14, %4
br i1 %15, label %53, label %16
16: ; preds = %1
%17 = fmul float %6, 1.000000e+01
%18 = fpext float %17 to double
%19 = fadd double %18, 5.000000e-01
%20 = tail call double @llvm.floor.f64(double %19)
%21 = fdiv double %20, 1.000000e+01
%22 = fptrunc double %21 to float
%23 = fpext float %22 to double
%24 = fdiv double 6.000000e+07, %23
%25 = fadd double %24, 5.000000e-01
%26 = tail call double @llvm.floor.f64(double %25)
%27 = fcmp oeq double %26, %4
br i1 %27, label %53, label %28
28: ; preds = %16
%29 = fmul float %6, 1.000000e+02
%30 = fpext float %29 to double
%31 = fadd double %30, 5.000000e-01
%32 = tail call double @llvm.floor.f64(double %31)
%33 = fdiv double %32, 1.000000e+02
%34 = fptrunc double %33 to float
%35 = fpext float %34 to double
%36 = fdiv double 6.000000e+07, %35
%37 = fadd double %36, 5.000000e-01
%38 = tail call double @llvm.floor.f64(double %37)
%39 = fcmp oeq double %38, %4
br i1 %39, label %53, label %40
40: ; preds = %28
%41 = fmul float %6, 1.000000e+03
%42 = fpext float %41 to double
%43 = fadd double %42, 5.000000e-01
%44 = tail call double @llvm.floor.f64(double %43)
%45 = fdiv double %44, 1.000000e+03
%46 = fptrunc double %45 to float
%47 = fpext float %46 to double
%48 = fdiv double 6.000000e+07, %47
%49 = fadd double %48, 5.000000e-01
%50 = tail call double @llvm.floor.f64(double %49)
%51 = fcmp oeq double %50, %4
br i1 %51, label %53, label %52
52: ; preds = %40
br label %53
53: ; preds = %52, %40, %28, %16, %1
%54 = phi float [ %10, %1 ], [ %22, %16 ], [ %34, %28 ], [ %46, %40 ], [ %6, %52 ]
ret float %54
}