int ordered_dither_lowlevel(double fraction, int x, int y) {
  double threshold;
  static const float pattern[64] = {
      0.5 / 64,  48.5 / 64, 12.5 / 64, 60.5 / 64, 3.5 / 64,  51.5 / 64,
      15.5 / 64, 63.5 / 64, 32.5 / 64, 16.5 / 64, 44.5 / 64, 28.5 / 64,
      35.5 / 64, 19.5 / 64, 47.5 / 64, 31.5 / 64, 8.5 / 64,  56.5 / 64,
      4.5 / 64,  52.5 / 64, 11.5 / 64, 59.5 / 64, 7.5 / 64,  55.5 / 64,
      40.5 / 64, 24.5 / 64, 36.5 / 64, 20.5 / 64, 43.5 / 64, 27.5 / 64,
      39.5 / 64, 23.5 / 64, 2.5 / 64,  50.5 / 64, 14.5 / 64, 62.5 / 64,
      1.5 / 64,  49.5 / 64, 13.5 / 64, 61.5 / 64, 34.5 / 64, 18.5 / 64,
      46.5 / 64, 30.5 / 64, 33.5 / 64, 17.5 / 64, 45.5 / 64, 29.5 / 64,
      10.5 / 64, 58.5 / 64, 6.5 / 64,  54.5 / 64, 9.5 / 64,  57.5 / 64,
      5.5 / 64,  53.5 / 64, 42.5 / 64, 26.5 / 64, 38.5 / 64, 22.5 / 64,
      41.5 / 64, 25.5 / 64, 37.5 / 64, 21.5 / 64};
  threshold = pattern[(x % 8) + 8 * (y % 8)];
  return (fraction >= threshold) ? 1 : 0;
}


x86 assembly (clang, -O0):
<ordered_dither_lowlevel>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x1c(%rbp),%edx
shl    $0x3,%eax
add    %eax,%edx
movslq %edx,%rcx
lea    0xec4(%rip),%rax
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
xor    %eax,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ordered_dither_lowlevel>:
lea    0x7(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffff8,%eax
sub    %eax,%edi
lea    0x7(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
and    $0x1ffffff8,%eax
sub    %eax,%esi
lea    (%rdi,%rsi,8),%eax
cltq
lea    0xed8(%rip),%rcx
movss  (%rcx,%rax,4),%xmm1
cvtss2sd %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
setae  %al
ret

LLVM IR (-O0):
@ordered_dither_lowlevel.pattern = internal constant [64 x float] [float 7.812500e-03, float 0x3FE8400000000000, float 0x3FC9000000000000, float 0x3FEE400000000000, float 5.468750e-02, float 0x3FE9C00000000000, float 0x3FCF000000000000, float 0x3FEFC00000000000, float 0x3FE0400000000000, float 0x3FD0800000000000, float 0x3FE6400000000000, float 0x3FDC800000000000, float 0x3FE1C00000000000, float 0x3FD3800000000000, float 0x3FE7C00000000000, float 0x3FDF800000000000, float 0x3FC1000000000000, float 0x3FEC400000000000, float 7.031250e-02, float 0x3FEA400000000000, float 0x3FC7000000000000, float 0x3FEDC00000000000, float 0x3FBE000000000000, float 0x3FEBC00000000000, float 0x3FE4400000000000, float 0x3FD8800000000000, float 0x3FE2400000000000, float 0x3FD4800000000000, float 0x3FE5C00000000000, float 0x3FDB800000000000, float 0x3FE3C00000000000, float 0x3FD7800000000000, float 3.906250e-02, float 0x3FE9400000000000, float 0x3FCD000000000000, float 0x3FEF400000000000, float 2.343750e-02, float 0x3FE8C00000000000, float 0x3FCB000000000000, float 0x3FEEC00000000000, float 0x3FE1400000000000, float 0x3FD2800000000000, float 0x3FE7400000000000, float 0x3FDE800000000000, float 0x3FE0C00000000000, float 0x3FD1800000000000, float 0x3FE6C00000000000, float 0x3FDD800000000000, float 0x3FC5000000000000, float 0x3FED400000000000, float 0x3FBA000000000000, float 0x3FEB400000000000, float 0x3FC3000000000000, float 0x3FECC00000000000, float 8.593750e-02, float 0x3FEAC00000000000, float 0x3FE5400000000000, float 0x3FDA800000000000, float 0x3FE3400000000000, float 0x3FD6800000000000, float 0x3FE4C00000000000, float 0x3FD9800000000000, float 0x3FE2C00000000000, float 0x3FD5800000000000]
define i32 @ordered_dither_lowlevel(double %0, i32 %1, i32 %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store double %0, double* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = srem i32 %8, 8
%10 = load i32, i32* %6
%11 = srem i32 %10, 8
%12 = mul nsw i32 8, %11
%13 = add nsw i32 %9, %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [64 x float], [64 x float]* @ordered_dither_lowlevel.pattern, i64 0, i64 %14
%16 = load float, float* %15
%17 = fpext float %16 to double
store double %17, double* %7
%18 = load double, double* %4
%19 = load double, double* %7
%20 = fcmp oge double %18, %19
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 1, i32 0
ret i32 %22
}

LLVM IR (-O2):
@ordered_dither_lowlevel.pattern = internal unnamed_addr constant [64 x float] [float 7.812500e-03, float 0x3FE8400000000000, float 0x3FC9000000000000, float 0x3FEE400000000000, float 5.468750e-02, float 0x3FE9C00000000000, float 0x3FCF000000000000, float 0x3FEFC00000000000, float 0x3FE0400000000000, float 0x3FD0800000000000, float 0x3FE6400000000000, float 0x3FDC800000000000, float 0x3FE1C00000000000, float 0x3FD3800000000000, float 0x3FE7C00000000000, float 0x3FDF800000000000, float 0x3FC1000000000000, float 0x3FEC400000000000, float 7.031250e-02, float 0x3FEA400000000000, float 0x3FC7000000000000, float 0x3FEDC00000000000, float 0x3FBE000000000000, float 0x3FEBC00000000000, float 0x3FE4400000000000, float 0x3FD8800000000000, float 0x3FE2400000000000, float 0x3FD4800000000000, float 0x3FE5C00000000000, float 0x3FDB800000000000, float 0x3FE3C00000000000, float 0x3FD7800000000000, float 3.906250e-02, float 0x3FE9400000000000, float 0x3FCD000000000000, float 0x3FEF400000000000, float 2.343750e-02, float 0x3FE8C00000000000, float 0x3FCB000000000000, float 0x3FEEC00000000000, float 0x3FE1400000000000, float 0x3FD2800000000000, float 0x3FE7400000000000, float 0x3FDE800000000000, float 0x3FE0C00000000000, float 0x3FD1800000000000, float 0x3FE6C00000000000, float 0x3FDD800000000000, float 0x3FC5000000000000, float 0x3FED400000000000, float 0x3FBA000000000000, float 0x3FEB400000000000, float 0x3FC3000000000000, float 0x3FECC00000000000, float 8.593750e-02, float 0x3FEAC00000000000, float 0x3FE5400000000000, float 0x3FDA800000000000, float 0x3FE3400000000000, float 0x3FD6800000000000, float 0x3FE4C00000000000, float 0x3FD9800000000000, float 0x3FE2C00000000000, float 0x3FD5800000000000]
define i32 @ordered_dither_lowlevel(double %0, i32 %1, i32 %2) {
%4 = srem i32 %1, 8
%5 = srem i32 %2, 8
%6 = shl nsw i32 %5, 3
%7 = add nsw i32 %6, %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [64 x float], [64 x float]* @ordered_dither_lowlevel.pattern, i64 0, i64 %8
%10 = load float, float* %9
%11 = fpext float %10 to double
%12 = fcmp ole double %11, %0
%13 = zext i1 %12 to i32
ret i32 %13
}