#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 */
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 - ((i) > 0 ? (i) : -(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    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  0xedf(%rip),%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xec0(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xeac(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe98(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <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     1271 <PrecalcCoefs+0x151>
cmpl   $0x0,-0x14(%rbp)
jle    11ab <PrecalcCoefs+0x8b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    11b3 <PrecalcCoefs+0x93>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe6e(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe3a(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <pow@plt>
movsd  0xe3a(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe1d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1235 <PrecalcCoefs+0x115>
movsd  -0x30(%rbp),%xmm0
movsd  0xe11(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1247 <PrecalcCoefs+0x127>
movsd  0xdfb(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%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    1189 <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    $0x50,%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 = %56, %2
%17 = load i32, i32* %5
%18 = icmp sle i32 %17, 4080
br i1 %18, label %19, label %59
19: ; preds = %16
%20 = load i32, i32* %5
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = load i32, i32* %5
br label %27
24: ; preds = %19
%25 = load i32, i32* %5
%26 = sub nsw i32 0, %25
br label %27
27: ; preds = %24, %22
%28 = phi i32 [ %23, %22 ], [ %26, %24 ]
%29 = sitofp i32 %28 to double
%30 = fdiv double %29, 4.080000e+03
%31 = fsub double 1.000000e+00, %30
store double %31, double* %7
%32 = load double, double* %7
%33 = load double, double* %6
%34 = call double @pow(double %32, double %33)
%35 = fmul double %34, 6.553600e+04
%36 = load i32, i32* %5
%37 = sitofp i32 %36 to double
%38 = fmul double %35, %37
%39 = fdiv double %38, 1.600000e+01
store double %39, double* %8
%40 = load double, double* %8
%41 = fcmp olt double %40, 0.000000e+00
br i1 %41, label %42, label %45
42: ; preds = %27
%43 = load double, double* %8
%44 = fsub double %43, 5.000000e-01
br label %48
45: ; preds = %27
%46 = load double, double* %8
%47 = fadd double %46, 5.000000e-01
br label %48
48: ; preds = %45, %42
%49 = phi double [ %44, %42 ], [ %47, %45 ]
%50 = fptosi double %49 to i32
%51 = load i32*, i32** %3
%52 = load i32, i32* %5
%53 = add nsw i32 4096, %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %51, i64 %54
store i32 %50, i32* %55
br label %56
56: ; preds = %48
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
br label %16
59: ; preds = %16
%60 = load double, double* %4
%61 = fcmp une double %60, 0.000000e+00
%62 = zext i1 %61 to i32
%63 = load i32*, i32** %3
%64 = getelementptr inbounds i32, i32* %63, i64 0
store i32 %62, i32* %64
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
}