#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) {
  int i;
  double Gamma, Simil, C;
  Gamma = log(0.25) / log(1.0 - Dist25 / 255.0 - 0.00001);
  for (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,-0x20(%rbp)
movl   $0xfffff010,-0x14(%rbp)
cmpl   $0xff0,-0x14(%rbp)
jg     1269 <PrecalcCoefs+0x139>
mov    -0x14(%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,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1050 <pow@plt>
movsd  0xe42(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe25(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    122d <PrecalcCoefs+0xfd>
movsd  -0x30(%rbp),%xmm0
movsd  0xe19(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    123f <PrecalcCoefs+0x10f>
movsd  0xe03(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
cvttsd2si %xmm0,%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1000,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%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 i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
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* %6
store i32 -4080, i32* %5
br label %16
16: ; preds = %49, %2
%17 = load i32, i32* %5
%18 = icmp sle i32 %17, 4080
br i1 %18, label %19, label %52
19: ; preds = %16
%20 = load i32, i32* %5
%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* %7
%25 = load double, double* %7
%26 = load double, double* %6
%27 = call double @pow(double %25, double %26)
%28 = fmul double %27, 6.553600e+04
%29 = load i32, i32* %5
%30 = sitofp i32 %29 to double
%31 = fmul double %28, %30
%32 = fdiv double %31, 1.600000e+01
store double %32, double* %8
%33 = load double, double* %8
%34 = fcmp olt double %33, 0.000000e+00
br i1 %34, label %35, label %38
35: ; preds = %19
%36 = load double, double* %8
%37 = fsub double %36, 5.000000e-01
br label %41
38: ; preds = %19
%39 = load double, double* %8
%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* %5
%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* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
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 %8
8: ; preds = %2, %8
%9 = phi i64 [ -4080, %2 ], [ %26, %8 ]
%10 = trunc i64 %9 to i32
%11 = tail call i32 @llvm.abs.i32(i32 %10, i1 true)
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 4.080000e+03
%14 = fsub double 1.000000e+00, %13
%15 = tail call double @pow(double %14, double %7)
%16 = fmul double %15, 6.553600e+04
%17 = sitofp i32 %10 to double
%18 = fmul double %16, %17
%19 = fmul double %18, 6.250000e-02
%20 = fcmp olt double %19, 0.000000e+00
%21 = select i1 %20, double -5.000000e-01, double 5.000000e-01
%22 = fadd double %19, %21
%23 = fptosi double %22 to i32
%24 = add nsw i64 %9, 4096
%25 = getelementptr inbounds i32, i32* %0, i64 %24
store i32 %23, i32* %25
%26 = add nsw i64 %9, 1
%27 = icmp eq i64 %26, 4081
br i1 %27, label %28, label %8
28: ; preds = %8
%29 = fcmp une double %1, 0.000000e+00
%30 = zext i1 %29 to i32
store i32 %30, i32* %0
ret void
}