#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int abs(int);
double log(double);
double pow(double, double);
void PrecalcCoefs(int *Ct, double Dist25) {
  double Gamma, Simil, C;
  Gamma = log(0.25) / log(1.0 - Dist25 / 255.0 - 0.00001);
  for (int i = -255 * 16; i <= 255 * 16; i++) {
    Simil = 1.0 - abs(i) / (16 * 255.0);
    C = pow(Simil, Gamma) * 65536.0 * (double)i / 16.0;
    Ct[16 * 256 + i] = (C < 0) ? (C - 0.5) : (C + 0.5);
  }
  Ct[0] = (Dist25 != 0);
}


x86 assembly (clang, -O0):
<PrecalcCoefs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  0xecf(%rip),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xeb0(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe9c(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe88(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0xfffff010,-0x2c(%rbp)
cmpl   $0xff0,-0x2c(%rbp)
jg     1269 <PrecalcCoefs+0x139>
mov    -0x2c(%rbp),%edi
call   1030 <abs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe76(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe42(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <pow@plt>
movsd  0xe42(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe25(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    122d <PrecalcCoefs+0xfd>
movsd  -0x28(%rbp),%xmm0
movsd  0xe19(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    123f <PrecalcCoefs+0x10f>
movsd  0xe03(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
cvttsd2si %xmm0,%edx
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1000,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1199 <PrecalcCoefs+0x69>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrecalcCoefs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movsd  %xmm0,0x8(%rsp)
divsd  0xec5(%rip),%xmm0
addsd  0xec5(%rip),%xmm0
addsd  0xec5(%rip),%xmm0
call   1030 <log@plt>
movsd  0xec0(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
xor    %ebx,%ebx
lea    0xed5(%rip),%r15
nopl   0x0(%rax,%rax,1)
lea    -0xff0(%rbx),%ebp
mov    %ebp,%eax
neg    %eax
cmovs  %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe94(%rip),%xmm0
addsd  0xe74(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
call   1040 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  0xe7a(%rip),%xmm0
mulsd  %xmm0,%xmm1
mulsd  0xe76(%rip),%xmm1
xor    %eax,%eax
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
seta   %al
addsd  (%r15,%rax,8),%xmm1
cvttsd2si %xmm1,%eax
mov    %eax,0x40(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x1fe1,%rbx
jne    1170 <PrecalcCoefs+0x50>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
cmpneqsd %xmm0,%xmm1
movq   %xmm1,%rax
and    $0x1,%eax
mov    %eax,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @PrecalcCoefs(i32* %0, double %1) {
%3 = alloca i32*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32* %0, i32** %3
store double %1, double* %4
%9 = call double @log(double 2.500000e-01)
%10 = load double, double* %4
%11 = fdiv double %10, 2.550000e+02
%12 = fsub double 1.000000e+00, %11
%13 = fsub double %12, 1.000000e-05
%14 = call double @log(double %13)
%15 = fdiv double %9, %14
store double %15, double* %5
store i32 -4080, i32* %8
br label %16
16: ; preds = %49, %2
%17 = load i32, i32* %8
%18 = icmp sle i32 %17, 4080
br i1 %18, label %19, label %52
19: ; preds = %16
%20 = load i32, i32* %8
%21 = call i32 @abs(i32 %20)
%22 = sitofp i32 %21 to double
%23 = fdiv double %22, 4.080000e+03
%24 = fsub double 1.000000e+00, %23
store double %24, double* %6
%25 = load double, double* %6
%26 = load double, double* %5
%27 = call double @pow(double %25, double %26)
%28 = fmul double %27, 6.553600e+04
%29 = load i32, i32* %8
%30 = sitofp i32 %29 to double
%31 = fmul double %28, %30
%32 = fdiv double %31, 1.600000e+01
store double %32, double* %7
%33 = load double, double* %7
%34 = fcmp olt double %33, 0.000000e+00
br i1 %34, label %35, label %38
35: ; preds = %19
%36 = load double, double* %7
%37 = fsub double %36, 5.000000e-01
br label %41
38: ; preds = %19
%39 = load double, double* %7
%40 = fadd double %39, 5.000000e-01
br label %41
41: ; preds = %38, %35
%42 = phi double [ %37, %35 ], [ %40, %38 ]
%43 = fptosi double %42 to i32
%44 = load i32*, i32** %3
%45 = load i32, i32* %8
%46 = add nsw i32 4096, %45
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %44, i64 %47
store i32 %43, i32* %48
br label %49
49: ; preds = %41
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %16
52: ; preds = %16
%53 = load double, double* %4
%54 = fcmp une double %53, 0.000000e+00
%55 = zext i1 %54 to i32
%56 = load i32*, i32** %3
%57 = getelementptr inbounds i32, i32* %56, i64 0
store i32 %55, i32* %57
ret void
}

LLVM IR (-O2):
define void @PrecalcCoefs(i32* nocapture writeonly %0, double %1) {
%3 = fdiv double %1, 2.550000e+02
%4 = fsub double 1.000000e+00, %3
%5 = fadd double %4, -1.000000e-05
%6 = tail call double @log(double %5)
%7 = fdiv double 0xBFF62E42FEFA39EF, %6
br label %11
8: ; preds = %11
%9 = fcmp une double %1, 0.000000e+00
%10 = zext i1 %9 to i32
store i32 %10, i32* %0
ret void
11: ; preds = %2, %11
%12 = phi i64 [ -4080, %2 ], [ %29, %11 ]
%13 = trunc i64 %12 to i32
%14 = tail call i32 @llvm.abs.i32(i32 %13, i1 true)
%15 = sitofp i32 %14 to double
%16 = fdiv double %15, 4.080000e+03
%17 = fsub double 1.000000e+00, %16
%18 = tail call double @pow(double %17, double %7)
%19 = fmul double %18, 6.553600e+04
%20 = sitofp i32 %13 to double
%21 = fmul double %19, %20
%22 = fmul double %21, 6.250000e-02
%23 = fcmp olt double %22, 0.000000e+00
%24 = select i1 %23, double -5.000000e-01, double 5.000000e-01
%25 = fadd double %22, %24
%26 = fptosi double %25 to i32
%27 = add nsw i64 %12, 4096
%28 = getelementptr inbounds i32, i32* %0, i64 %27
store i32 %26, i32* %28
%29 = add nsw i64 %12, 1
%30 = icmp eq i64 %29, 4081
br i1 %30, label %8, label %11
}