void make_table(unsigned char *tab, double val) {
  unsigned int ival;
  register int i;
  for (i = 0; i < 256; i++) {
    ival = (val * i + .5);
    tab[i] = ival > 255 ? (unsigned char)255 : (unsigned char)ival;
  }
}


x86 assembly (clang, -O0):
<make_table>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x100,-0x18(%rbp)
jge    1184 <make_table+0x84>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xec9(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x14(%rbp)
cmpl   $0xff,-0x14(%rbp)
jbe    115d <make_table+0x5d>
mov    $0xff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1166 <make_table+0x66>
mov    -0x14(%rbp),%eax
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1114 <make_table+0x14>
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_table>:
unpcklpd %xmm0,%xmm0
movdqa 0xef4(%rip),%xmm3
movdqa 0xefb(%rip),%xmm11
movdqa 0xf02(%rip),%xmm12
movdqa 0xf09(%rip),%xmm13
xor    %eax,%eax
movapd 0xf0e(%rip),%xmm14
movapd 0xf15(%rip),%xmm15
nopl   0x0(%rax,%rax,1)
movdqa %xmm3,-0x18(%rsp)
cvtdq2pd %xmm12,%xmm2
pshufd $0xee,%xmm12,%xmm1
cvtdq2pd %xmm1,%xmm10
cvtdq2pd %xmm13,%xmm5
pshufd $0xee,%xmm13,%xmm1
cvtdq2pd %xmm1,%xmm6
cvtdq2pd %xmm3,%xmm1
mulpd  %xmm0,%xmm10
addpd  %xmm14,%xmm10
mulpd  %xmm0,%xmm2
addpd  %xmm14,%xmm2
cvttpd2dq %xmm2,%xmm9
movapd %xmm9,%xmm8
psrad  $0x1f,%xmm8
subpd  %xmm15,%xmm2
cvttpd2dq %xmm2,%xmm7
andpd  %xmm8,%xmm7
orpd   %xmm9,%xmm7
cvttpd2dq %xmm10,%xmm3
movapd %xmm3,%xmm2
psrad  $0x1f,%xmm2
subpd  %xmm15,%xmm10
cvttpd2dq %xmm10,%xmm4
andpd  %xmm2,%xmm4
pshufd $0xee,-0x18(%rsp),%xmm2
cvtdq2pd %xmm2,%xmm2
mulpd  %xmm0,%xmm6
addpd  %xmm14,%xmm6
mulpd  %xmm0,%xmm5
addpd  %xmm14,%xmm5
orpd   %xmm3,%xmm4
unpcklpd %xmm4,%xmm7
cvttpd2dq %xmm5,%xmm3
movapd %xmm3,%xmm4
psrad  $0x1f,%xmm4
subpd  %xmm15,%xmm5
cvttpd2dq %xmm5,%xmm5
andpd  %xmm4,%xmm5
orpd   %xmm3,%xmm5
cvttpd2dq %xmm6,%xmm3
movapd %xmm3,%xmm4
psrad  $0x1f,%xmm4
subpd  %xmm15,%xmm6
cvttpd2dq %xmm6,%xmm6
andpd  %xmm4,%xmm6
cvtdq2pd %xmm11,%xmm4
mulpd  %xmm0,%xmm2
addpd  %xmm14,%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm14,%xmm1
orpd   %xmm3,%xmm6
unpcklpd %xmm6,%xmm5
cvttpd2dq %xmm1,%xmm3
movapd %xmm3,%xmm6
psrad  $0x1f,%xmm6
subpd  %xmm15,%xmm1
cvttpd2dq %xmm1,%xmm1
andpd  %xmm6,%xmm1
orpd   %xmm3,%xmm1
cvttpd2dq %xmm2,%xmm3
movapd %xmm3,%xmm6
psrad  $0x1f,%xmm6
subpd  %xmm15,%xmm2
cvttpd2dq %xmm2,%xmm2
andpd  %xmm6,%xmm2
pshufd $0xee,%xmm11,%xmm6
cvtdq2pd %xmm6,%xmm6
mulpd  %xmm0,%xmm6
addpd  %xmm14,%xmm6
mulpd  %xmm0,%xmm4
addpd  %xmm14,%xmm4
orpd   %xmm3,%xmm2
unpcklpd %xmm2,%xmm1
cvttpd2dq %xmm4,%xmm2
movapd %xmm2,%xmm3
psrad  $0x1f,%xmm3
subpd  %xmm15,%xmm4
cvttpd2dq %xmm4,%xmm4
andpd  %xmm3,%xmm4
orpd   %xmm2,%xmm4
cvttpd2dq %xmm6,%xmm2
movapd %xmm2,%xmm3
psrad  $0x1f,%xmm3
subpd  %xmm15,%xmm6
cvttpd2dq %xmm6,%xmm6
andpd  %xmm3,%xmm6
orpd   %xmm2,%xmm6
unpcklpd %xmm6,%xmm4
movapd %xmm4,%xmm3
movapd 0xd90(%rip),%xmm9
xorpd  %xmm9,%xmm3
movdqa 0xd93(%rip),%xmm6
movdqa %xmm6,%xmm2
pcmpgtd %xmm3,%xmm2
andpd  %xmm2,%xmm4
movapd 0xd5e(%rip),%xmm10
andnpd %xmm10,%xmm2
orpd   %xmm4,%xmm2
movapd %xmm1,%xmm3
xorpd  %xmm9,%xmm3
movdqa %xmm6,%xmm4
pcmpgtd %xmm3,%xmm4
andpd  %xmm4,%xmm1
andnpd %xmm10,%xmm4
orpd   %xmm1,%xmm4
packuswb %xmm4,%xmm2
movapd %xmm5,%xmm1
xorpd  %xmm9,%xmm1
movdqa %xmm6,%xmm3
pcmpgtd %xmm1,%xmm3
andpd  %xmm3,%xmm5
andnpd %xmm10,%xmm3
orpd   %xmm5,%xmm3
movapd %xmm7,%xmm1
xorpd  %xmm9,%xmm1
movdqa %xmm6,%xmm4
pcmpgtd %xmm1,%xmm4
andpd  %xmm4,%xmm7
andnpd %xmm10,%xmm4
orpd   %xmm7,%xmm4
packuswb %xmm4,%xmm3
packuswb %xmm2,%xmm3
movdqu %xmm3,(%rdi,%rax,1)
movdqa -0x18(%rsp),%xmm1
movdqa 0xd0b(%rip),%xmm9
paddd  %xmm9,%xmm1
movdqa %xmm13,%xmm3
paddd  %xmm9,%xmm3
movdqa %xmm12,%xmm2
paddd  %xmm9,%xmm2
cvtdq2pd %xmm2,%xmm7
pshufd $0xee,%xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
cvtdq2pd %xmm3,%xmm5
pshufd $0xee,%xmm3,%xmm3
cvtdq2pd %xmm3,%xmm6
mulpd  %xmm0,%xmm2
mulpd  %xmm0,%xmm7
addpd  %xmm14,%xmm7
cvttpd2dq %xmm7,%xmm3
addpd  %xmm14,%xmm2
movapd %xmm3,%xmm4
subpd  %xmm15,%xmm7
cvttpd2dq %xmm7,%xmm8
psrad  $0x1f,%xmm4
andpd  %xmm4,%xmm8
cvttpd2dq %xmm2,%xmm4
orpd   %xmm3,%xmm8
movapd %xmm4,%xmm3
subpd  %xmm15,%xmm2
cvttpd2dq %xmm2,%xmm2
psrad  $0x1f,%xmm3
andpd  %xmm3,%xmm2
cvtdq2pd %xmm1,%xmm3
mulpd  %xmm0,%xmm6
addpd  %xmm14,%xmm6
mulpd  %xmm0,%xmm5
addpd  %xmm14,%xmm5
orpd   %xmm4,%xmm2
unpcklpd %xmm2,%xmm8
cvttpd2dq %xmm5,%xmm2
movapd %xmm2,%xmm4
psrad  $0x1f,%xmm4
subpd  %xmm15,%xmm5
cvttpd2dq %xmm5,%xmm5
andpd  %xmm4,%xmm5
orpd   %xmm2,%xmm5
cvttpd2dq %xmm6,%xmm2
movapd %xmm2,%xmm4
psrad  $0x1f,%xmm4
subpd  %xmm15,%xmm6
cvttpd2dq %xmm6,%xmm6
andpd  %xmm4,%xmm6
movdqa %xmm11,%xmm4
pshufd $0xee,%xmm1,%xmm1
cvtdq2pd %xmm1,%xmm7
paddd  %xmm9,%xmm4
mulpd  %xmm0,%xmm7
addpd  %xmm14,%xmm7
mulpd  %xmm0,%xmm3
addpd  %xmm14,%xmm3
orpd   %xmm2,%xmm6
cvttpd2dq %xmm3,%xmm2
unpcklpd %xmm6,%xmm5
movapd %xmm2,%xmm6
subpd  %xmm15,%xmm3
cvttpd2dq %xmm3,%xmm1
psrad  $0x1f,%xmm6
andpd  %xmm6,%xmm1
cvttpd2dq %xmm7,%xmm3
orpd   %xmm2,%xmm1
movapd %xmm3,%xmm2
subpd  %xmm15,%xmm7
cvttpd2dq %xmm7,%xmm6
psrad  $0x1f,%xmm2
andpd  %xmm2,%xmm6
cvtdq2pd %xmm4,%xmm2
pshufd $0xee,%xmm4,%xmm4
cvtdq2pd %xmm4,%xmm4
mulpd  %xmm0,%xmm4
addpd  %xmm14,%xmm4
mulpd  %xmm0,%xmm2
addpd  %xmm14,%xmm2
orpd   %xmm3,%xmm6
unpcklpd %xmm6,%xmm1
cvttpd2dq %xmm2,%xmm3
movapd %xmm3,%xmm6
psrad  $0x1f,%xmm6
subpd  %xmm15,%xmm2
cvttpd2dq %xmm2,%xmm7
andpd  %xmm6,%xmm7
orpd   %xmm3,%xmm7
cvttpd2dq %xmm4,%xmm2
movapd %xmm2,%xmm3
psrad  $0x1f,%xmm3
subpd  %xmm15,%xmm4
cvttpd2dq %xmm4,%xmm4
andpd  %xmm3,%xmm4
orpd   %xmm2,%xmm4
unpcklpd %xmm4,%xmm7
movapd %xmm7,%xmm3
movapd 0xb3c(%rip),%xmm4
xorpd  %xmm4,%xmm3
movdqa 0xb40(%rip),%xmm6
movdqa %xmm6,%xmm2
pcmpgtd %xmm3,%xmm2
andpd  %xmm2,%xmm7
andnpd %xmm10,%xmm2
orpd   %xmm7,%xmm2
movapd %xmm1,%xmm3
xorpd  %xmm4,%xmm3
movapd %xmm4,%xmm7
movdqa %xmm6,%xmm4
pcmpgtd %xmm3,%xmm4
andpd  %xmm4,%xmm1
andnpd %xmm10,%xmm4
orpd   %xmm1,%xmm4
packuswb %xmm4,%xmm2
movapd %xmm5,%xmm1
xorpd  %xmm7,%xmm1
movdqa %xmm6,%xmm3
pcmpgtd %xmm1,%xmm3
andpd  %xmm3,%xmm5
andnpd %xmm10,%xmm3
orpd   %xmm5,%xmm3
movapd %xmm8,%xmm1
xorpd  %xmm7,%xmm1
movdqa %xmm6,%xmm4
pcmpgtd %xmm1,%xmm4
andpd  %xmm4,%xmm8
andnpd %xmm10,%xmm4
orpd   %xmm8,%xmm4
packuswb %xmm4,%xmm3
packuswb %xmm2,%xmm3
movdqu %xmm3,0x10(%rdi,%rax,1)
movdqa -0x18(%rsp),%xmm3
add    $0x20,%rax
movdqa 0xac9(%rip),%xmm1
paddd  %xmm1,%xmm13
paddd  %xmm1,%xmm12
paddd  %xmm1,%xmm11
paddd  %xmm1,%xmm3
cmp    $0x100,%rax
jne    1140 <make_table+0x40>
ret

LLVM IR (-O0):
define void @make_table(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store double %1, double* %4
store i32 0, i32* %6
br label %7
7: ; preds = %30, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 256
br i1 %9, label %10, label %33
10: ; preds = %7
%11 = load double, double* %4
%12 = load i32, i32* %6
%13 = sitofp i32 %12 to double
%14 = call double @llvm.fmuladd.f64(double %11, double %13, double 5.000000e-01)
%15 = fptoui double %14 to i32
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = icmp ugt i32 %16, 255
br i1 %17, label %18, label %19
18: ; preds = %10
br label %23
19: ; preds = %10
%20 = load i32, i32* %5
%21 = trunc i32 %20 to i8
%22 = zext i8 %21 to i32
br label %23
23: ; preds = %19, %18
%24 = phi i32 [ 255, %18 ], [ %22, %19 ]
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %3
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 %25, i8* %29
br label %30
30: ; preds = %23
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %7
33: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @make_table(i8* nocapture writeonly %0, double %1) {
%3 = insertelement <16 x double> poison, double %1, i64 0
%4 = shufflevector <16 x double> %3, <16 x double> poison, <16 x i32> zeroinitializer
br label %5
5: ; preds = %5, %2
%6 = phi i64 [ 0, %2 ], [ %26, %5 ]
%7 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %2 ], [ %27, %5 ]
%8 = sitofp <16 x i32> %7 to <16 x double>
%9 = call <16 x double> @llvm.fmuladd.v16f64(<16 x double> %4, <16 x double> %8, <16 x double> <double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01>)
%10 = fptoui <16 x double> %9 to <16 x i32>
%11 = icmp ult <16 x i32> %10, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%12 = select <16 x i1> %11, <16 x i32> %10, <16 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%13 = trunc <16 x i32> %12 to <16 x i8>
%14 = getelementptr inbounds i8, i8* %0, i64 %6
%15 = bitcast i8* %14 to <16 x i8>*
store <16 x i8> %13, <16 x i8>* %15
%16 = or i64 %6, 16
%17 = add <16 x i32> %7, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
%18 = sitofp <16 x i32> %17 to <16 x double>
%19 = call <16 x double> @llvm.fmuladd.v16f64(<16 x double> %4, <16 x double> %18, <16 x double> <double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01>)
%20 = fptoui <16 x double> %19 to <16 x i32>
%21 = icmp ult <16 x i32> %20, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%22 = select <16 x i1> %21, <16 x i32> %20, <16 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%23 = trunc <16 x i32> %22 to <16 x i8>
%24 = getelementptr inbounds i8, i8* %0, i64 %16
%25 = bitcast i8* %24 to <16 x i8>*
store <16 x i8> %23, <16 x i8>* %25
%26 = add nuw nsw i64 %6, 32
%27 = add <16 x i32> %7, <i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32>
%28 = icmp eq i64 %26, 256
br i1 %28, label %29, label %5
29: ; preds = %5
ret void
}