double QP2Qstep(int QP) {
  int i;
  double Qstep;
  static const double QP2QSTEP[6] = {0.625, 0.6875, 0.8125, 0.875, 1.0, 1.125};
  Qstep = QP2QSTEP[QP % 6];
  for (i = 0; i < (QP / 6); i++)
    Qstep *= 2;
  return Qstep;
}


x86 assembly (clang, -O0):
<QP2Qstep>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0xef4(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    116b <QP2Qstep+0x6b>
movsd  0xead(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112d <QP2Qstep+0x2d>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<QP2Qstep>:
movslq %edi,%rax
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,2),%edx
mov    %eax,%esi
sub    %edx,%esi
movslq %esi,%rdx
lea    0xed5(%rip),%rsi
movsd  (%rsi,%rdx,8),%xmm0
cmp    $0x6,%eax
jl     1189 <QP2Qstep+0x89>
lea    -0x1(%rcx),%edx
mov    %ecx,%eax
and    $0x7,%eax
cmp    $0x7,%edx
jb     1175 <QP2Qstep+0x75>
and    $0xfffffff8,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
add    $0xfffffff8,%ecx
jne    1150 <QP2Qstep+0x50>
test   %eax,%eax
je     1189 <QP2Qstep+0x89>
nopl   0x0(%rax)
addsd  %xmm0,%xmm0
add    $0xffffffff,%eax
jne    1180 <QP2Qstep+0x80>
ret

LLVM IR (-O0):
@QP2Qstep.QP2QSTEP = internal constant [6 x double] [double 6.250000e-01, double 6.875000e-01, double 8.125000e-01, double 8.750000e-01, double 1.000000e+00, double 1.125000e+00]
define double @QP2Qstep(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = srem i32 %5, 6
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [6 x double], [6 x double]* @QP2Qstep.QP2QSTEP, i64 0, i64 %7
%9 = load double, double* %8
store double %9, double* %4
store i32 0, i32* %3
br label %10
10: ; preds = %18, %1
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 6
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load double, double* %4
%17 = fmul double %16, 2.000000e+00
store double %17, double* %4
br label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %10
21: ; preds = %10
%22 = load double, double* %4
ret double %22
}

LLVM IR (-O2):
@QP2Qstep.QP2QSTEP = internal unnamed_addr constant [6 x double] [double 6.250000e-01, double 6.875000e-01, double 8.125000e-01, double 8.750000e-01, double 1.000000e+00, double 1.125000e+00]
define double @QP2Qstep(i32 %0) {
%2 = srem i32 %0, 6
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds [6 x double], [6 x double]* @QP2Qstep.QP2QSTEP, i64 0, i64 %3
%5 = load double, double* %4
%6 = sdiv i32 %0, 6
%7 = icmp sgt i32 %0, 5
br i1 %7, label %8, label %37
8: ; preds = %1
%9 = add nsw i32 %6, -1
%10 = and i32 %6, 7
%11 = icmp ult i32 %9, 7
br i1 %11, label %27, label %12
12: ; preds = %8
%13 = and i32 %6, -8
br label %14
14: ; preds = %14, %12
%15 = phi double [ %5, %12 ], [ %24, %14 ]
%16 = phi i32 [ 0, %12 ], [ %25, %14 ]
%17 = fmul double %15, 2.000000e+00
%18 = fmul double %17, 2.000000e+00
%19 = fmul double %18, 2.000000e+00
%20 = fmul double %19, 2.000000e+00
%21 = fmul double %20, 2.000000e+00
%22 = fmul double %21, 2.000000e+00
%23 = fmul double %22, 2.000000e+00
%24 = fmul double %23, 2.000000e+00
%25 = add i32 %16, 8
%26 = icmp eq i32 %25, %13
br i1 %26, label %27, label %14
27: ; preds = %14, %8
%28 = phi double [ undef, %8 ], [ %24, %14 ]
%29 = phi double [ %5, %8 ], [ %24, %14 ]
%30 = icmp eq i32 %10, 0
br i1 %30, label %37, label %31
31: ; preds = %27, %31
%32 = phi double [ %34, %31 ], [ %29, %27 ]
%33 = phi i32 [ %35, %31 ], [ 0, %27 ]
%34 = fmul double %32, 2.000000e+00
%35 = add i32 %33, 1
%36 = icmp eq i32 %35, %10
br i1 %36, label %37, label %31
37: ; preds = %27, %31, %1
%38 = phi double [ %5, %1 ], [ %28, %27 ], [ %34, %31 ]
ret double %38
}