#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 DBL_MAX;
double RAND_MAX;
double compute_distance(double *, double const *, unsigned int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(unsigned int);
scalar_t__ rand();
void furthest_first_sample(double *CX, const double *X, double *W,
                           unsigned int dim, unsigned int npts,
                           unsigned int nclus) {
  int ind;
  double *distances, r;
  distances = (double *)malloc(npts * sizeof(*distances));
  for (int i = 0; i < npts; i++)
    distances[i] = DBL_MAX;
  for (int i = 1; i < nclus; i++) {
    double *a = CX + (i - 1) * dim;
    for (int j = 0; j < npts; j++) {
      double d = compute_distance(a, X + j * dim, dim);
      if (d < distances[j])
        distances[j] = d;
    }
    ind = 0;
    double sum = W[0] * distances[0] * distances[0];
    for (int j = 1; j < npts; j++) {
      double d = W[j] * distances[j] * distances[j];
      sum += d;
      r = ((double)rand() / RAND_MAX) * sum;
      if (r < d)
        ind = j;
    }
    a = CX + i * dim;
    const double *b = X + ind * dim;
    for (int j = 0; j < dim; j++)
      a[j] = b[j];
  }
  free(distances);
}


x86 assembly (clang, -O0):
<furthest_first_sample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x20(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    11ad <furthest_first_sample+0x6d>
mov    0x2e4a(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    117b <furthest_first_sample+0x3b>
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    1392 <furthest_first_sample+0x252>
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x1c(%rbp),%ecx
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    1254 <furthest_first_sample+0x114>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x4c(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,%eax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1050 <compute_distance@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1241 <furthest_first_sample+0x101>
movsd  -0x58(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1246 <furthest_first_sample+0x106>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11e2 <furthest_first_sample+0xa2>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x1,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    1314 <furthest_first_sample+0x1d4>
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x64(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x64(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2d0f(%rip),%rax
divsd  (%rax),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1301 <furthest_first_sample+0x1c1>
mov    -0x64(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1306 <furthest_first_sample+0x1c6>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    127f <furthest_first_sample+0x13f>
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    137f <furthest_first_sample+0x23f>
mov    -0x78(%rbp),%rax
movslq -0x7c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x7c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    134b <furthest_first_sample+0x20b>
jmp    1384 <furthest_first_sample+0x244>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11b4 <furthest_first_sample+0x74>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<furthest_first_sample>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %r9d,%ebx
mov    %r8d,%r12d
mov    %ecx,0xc(%rsp)
mov    %rdx,%r14
mov    %rsi,0x20(%rsp)
mov    %rdi,0x10(%rsp)
lea    0x0(,%r12,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    %r12d,%r15d
test   %r12d,%r12d
je     12fd <furthest_first_sample+0x1bd>
cmp    $0x4,%r12d
jb     11b6 <furthest_first_sample+0x76>
mov    0x2e47(%rip),%rcx
lea    0x8(%rcx),%rax
cmp    %rax,%r13
jae    124a <furthest_first_sample+0x10a>
lea    0x0(,%r15,8),%rax
add    %r13,%rax
cmp    0x2e28(%rip),%rax
jbe    124a <furthest_first_sample+0x10a>
xor    %eax,%eax
mov    %rax,%rcx
not    %rcx
add    %r15,%rcx
mov    %r15,%rdx
and    $0x3,%rdx
je     11f5 <furthest_first_sample+0xb5>
mov    0x2e07(%rip),%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsi),%xmm0
movsd  %xmm0,0x0(%r13,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
jne    11e0 <furthest_first_sample+0xa0>
cmp    $0x3,%rcx
jb     12fd <furthest_first_sample+0x1bd>
mov    0x2dd2(%rip),%rcx
cs nopw 0x0(%rax,%rax,1)
movsd  (%rcx),%xmm0
movsd  %xmm0,0x0(%r13,%rax,8)
movsd  (%rcx),%xmm0
movsd  %xmm0,0x8(%r13,%rax,8)
movsd  (%rcx),%xmm0
movsd  %xmm0,0x10(%r13,%rax,8)
movsd  (%rcx),%xmm0
movsd  %xmm0,0x18(%r13,%rax,8)
add    $0x4,%rax
cmp    %rax,%r15
jne    1210 <furthest_first_sample+0xd0>
jmp    12fd <furthest_first_sample+0x1bd>
mov    %r15d,%eax
and    $0xfffffffc,%eax
lea    -0x4(%rax),%rdi
mov    %rdi,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0xc,%rdi
jae    126e <furthest_first_sample+0x12e>
xor    %edi,%edi
jmp    12c2 <furthest_first_sample+0x182>
and    $0xfffffffffffffffc,%rsi
movsd  (%rcx),%xmm0
unpcklpd %xmm0,%xmm0
xor    %edi,%edi
nopl   0x0(%rax)
movupd %xmm0,0x0(%r13,%rdi,8)
movupd %xmm0,0x10(%r13,%rdi,8)
movupd %xmm0,0x20(%r13,%rdi,8)
movupd %xmm0,0x30(%r13,%rdi,8)
movupd %xmm0,0x40(%r13,%rdi,8)
movupd %xmm0,0x50(%r13,%rdi,8)
movupd %xmm0,0x60(%r13,%rdi,8)
movupd %xmm0,0x70(%r13,%rdi,8)
add    $0x10,%rdi
add    $0xfffffffffffffffc,%rsi
jne    1280 <furthest_first_sample+0x140>
test   %rdx,%rdx
je     12f4 <furthest_first_sample+0x1b4>
movsd  (%rcx),%xmm0
unpcklpd %xmm0,%xmm0
lea    0x10(,%rdi,8),%rcx
add    %r13,%rcx
shl    $0x5,%rdx
xor    %esi,%esi
movupd %xmm0,-0x10(%rcx,%rsi,1)
movupd %xmm0,(%rcx,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%rdx
jne    12e0 <furthest_first_sample+0x1a0>
cmp    %r15,%rax
jne    11b8 <furthest_first_sample+0x78>
mov    %r14,0xb8(%rsp)
cmp    $0x2,%ebx
mov    0xc(%rsp),%r11d
jb     1745 <furthest_first_sample+0x605>
mov    %ebx,%eax
mov    %rax,0xb0(%rsp)
mov    %r11d,%r10d
mov    0x10(%rsp),%rcx
lea    (%rcx,%r10,8),%rax
mov    %rax,0x78(%rsp)
mov    0x20(%rsp),%rax
lea    (%rax,%r10,8),%rdx
mov    %rdx,0x90(%rsp)
mov    %r10d,%edx
and    $0xfffffffc,%edx
mov    %rdx,0x70(%rsp)
add    $0xfffffffffffffffc,%rdx
mov    %rdx,0x68(%rsp)
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %edx,%esi
and    $0x3,%esi
and    $0xfffffffffffffffc,%rdx
mov    %rdx,0x48(%rsp)
mov    %r10d,%r8d
and    $0x3,%r8d
lea    0x70(%rax),%rdx
mov    %rdx,0x40(%rsp)
lea    0x70(%rcx),%rdx
mov    %rdx,0x38(%rsp)
lea    0x10(%rcx),%rdx
mov    %rdx,0x58(%rsp)
lea    0x10(%rax),%rdx
mov    %rdx,0x50(%rsp)
mov    %rsi,0x60(%rsp)
mov    %rsi,%r9
shl    $0x5,%r9
add    $0x18,%rcx
mov    %rcx,0x88(%rsp)
add    $0x18,%rax
mov    %rax,0x80(%rsp)
mov    $0x1,%eax
mov    %rax,0x18(%rsp)
mov    %r11d,%ebx
xor    %r14d,%r14d
mov    %r12,0x30(%rsp)
mov    %r10,0xa8(%rsp)
mov    %r8,0xa0(%rsp)
mov    %r9,0x98(%rsp)
jmp    1413 <furthest_first_sample+0x2d3>
nopw   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rax
add    $0x1,%rax
add    $0x1,%r14d
add    %r11d,%ebx
mov    %rax,0x18(%rsp)
cmp    0xb0(%rsp),%rax
je     1745 <furthest_first_sample+0x605>
mov    %r14d,0x2c(%rsp)
mov    %rbx,0xc0(%rsp)
test   %r12d,%r12d
je     1490 <furthest_first_sample+0x350>
mov    0x18(%rsp),%rax
add    $0xffffffff,%eax
imul   %r11d,%eax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1452 <furthest_first_sample+0x312>
add    $0x1,%rbp
add    %r14d,%ebx
mov    %r15,%rax
cmp    %rbp,%r15
mov    %r14d,%r11d
je     1490 <furthest_first_sample+0x350>
mov    %ebx,%eax
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
mov    %r12,%rdi
mov    %r11d,%edx
mov    %r11d,%r14d
call   1050 <compute_distance@plt>
movsd  0x0(%r13,%rbp,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    1440 <furthest_first_sample+0x300>
movsd  %xmm0,0x0(%r13,%rbp,8)
jmp    1440 <furthest_first_sample+0x300>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cmpl   $0x2,0x30(%rsp)
mov    0xb8(%rsp),%r12
mov    0x2b42(%rip),%r14
jb     1538 <furthest_first_sample+0x3f8>
movsd  0x0(%r13),%xmm0
movsd  (%r12),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
xor    %ebp,%ebp
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
movsd  0x0(%r13,%rbx,8),%xmm0
movsd  (%r12,%rbx,8),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,0xc8(%rsp)
addsd  %xmm2,%xmm1
movsd  %xmm1,0xd0(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movsd  0xd0(%rsp),%xmm1
mov    %r15,%rcx
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xc8(%rsp),%xmm2
ucomisd %xmm0,%xmm2
cmova  %ebx,%ebp
add    $0x1,%rbx
cmp    %rbx,%r15
jne    14d0 <furthest_first_sample+0x390>
mov    0xc0(%rsp),%rbx
mov    %ebx,%ebx
mov    0xc(%rsp),%r11d
test   %r11d,%r11d
mov    0x30(%rsp),%r12
mov    0xa8(%rsp),%r10
mov    0xa0(%rsp),%r8
mov    0x98(%rsp),%r9
mov    0x2c(%rsp),%r14d
je     13f0 <furthest_first_sample+0x2b0>
imul   %r11d,%ebp
mov    0x20(%rsp),%rax
lea    (%rax,%rbp,8),%rax
cmp    $0x4,%r11d
jb     15bf <furthest_first_sample+0x47f>
mov    %r14d,%ecx
imul   %r11d,%ecx
add    %r11d,%ecx
mov    0x10(%rsp),%rdx
lea    (%rdx,%rcx,8),%rdx
mov    0x90(%rsp),%rsi
lea    (%rsi,%rbp,8),%rsi
cmp    %rsi,%rdx
jae    165c <furthest_first_sample+0x51c>
mov    0x78(%rsp),%rdx
lea    (%rdx,%rcx,8),%rcx
cmp    %rcx,%rax
jae    165c <furthest_first_sample+0x51c>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %r10,%rdx
test   %r8,%r8
je     15f4 <furthest_first_sample+0x4b4>
mov    0x10(%rsp),%rsi
lea    (%rsi,%rbx,8),%rsi
mov    %r8,%rdi
nopl   0x0(%rax,%rax,1)
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rsi,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdi
jne    15e0 <furthest_first_sample+0x4a0>
cmp    $0x3,%rdx
jb     13f0 <furthest_first_sample+0x2b0>
mov    0x88(%rsp),%rax
lea    (%rax,%rbx,8),%rax
mov    0x80(%rsp),%rdx
lea    (%rdx,%rbp,8),%rdx
cs nopw 0x0(%rax,%rax,1)
movsd  -0x18(%rdx,%rcx,8),%xmm0
movsd  %xmm0,-0x18(%rax,%rcx,8)
movsd  -0x10(%rdx,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rax,%rcx,8)
movsd  -0x8(%rdx,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%rax,%rcx,8)
movsd  (%rdx,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r10
jne    1620 <furthest_first_sample+0x4e0>
jmp    13f0 <furthest_first_sample+0x2b0>
cmpq   $0xc,0x68(%rsp)
jae    166b <furthest_first_sample+0x52b>
xor    %ecx,%ecx
jmp    16ec <furthest_first_sample+0x5ac>
mov    0x38(%rsp),%rcx
lea    (%rcx,%rbx,8),%rdx
mov    0x40(%rsp),%rcx
lea    (%rcx,%rbp,8),%rsi
mov    0x48(%rsp),%rdi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movups -0x70(%rsi,%rcx,8),%xmm0
movups -0x60(%rsi,%rcx,8),%xmm1
movups %xmm0,-0x70(%rdx,%rcx,8)
movups %xmm1,-0x60(%rdx,%rcx,8)
movups -0x50(%rsi,%rcx,8),%xmm0
movups -0x40(%rsi,%rcx,8),%xmm1
movups %xmm0,-0x50(%rdx,%rcx,8)
movups %xmm1,-0x40(%rdx,%rcx,8)
movups -0x30(%rsi,%rcx,8),%xmm0
movups -0x20(%rsi,%rcx,8),%xmm1
movups %xmm0,-0x30(%rdx,%rcx,8)
movups %xmm1,-0x20(%rdx,%rcx,8)
movupd -0x10(%rsi,%rcx,8),%xmm0
movupd (%rsi,%rcx,8),%xmm1
movupd %xmm0,-0x10(%rdx,%rcx,8)
movupd %xmm1,(%rdx,%rcx,8)
add    $0x10,%rcx
add    $0xfffffffffffffffc,%rdi
jne    1690 <furthest_first_sample+0x550>
cmpq   $0x0,0x60(%rsp)
je     172f <furthest_first_sample+0x5ef>
lea    (%rcx,%rbx,1),%rdx
mov    0x58(%rsp),%rsi
lea    (%rsi,%rdx,8),%rdx
add    %rbp,%rcx
mov    0x50(%rsp),%rsi
lea    (%rsi,%rcx,8),%rcx
xor    %esi,%esi
nop
movupd -0x10(%rcx,%rsi,1),%xmm0
movupd (%rcx,%rsi,1),%xmm1
movupd %xmm0,-0x10(%rdx,%rsi,1)
movupd %xmm1,(%rdx,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%r9
jne    1710 <furthest_first_sample+0x5d0>
mov    0x70(%rsp),%rdx
mov    %rdx,%rcx
cmp    %r10,%rdx
je     13f0 <furthest_first_sample+0x2b0>
jmp    15c1 <furthest_first_sample+0x481>
mov    %r13,%rdi
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@DBL_MAX = global double 0.000000e+00
@RAND_MAX = global double 0.000000e+00
define void @furthest_first_sample(double* %0, double* %1, double* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca double*
%19 = alloca i32
%20 = alloca double
%21 = alloca double
%22 = alloca i32
%23 = alloca double
%24 = alloca double*
%25 = alloca i32
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%26 = load i32, i32* %11
%27 = zext i32 %26 to i64
%28 = mul i64 %27, 8
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to double*
store double* %31, double** %14
store i32 0, i32* %16
br label %32
32: ; preds = %42, %6
%33 = load i32, i32* %16
%34 = load i32, i32* %11
%35 = icmp ult i32 %33, %34
br i1 %35, label %36, label %45
36: ; preds = %32
%37 = load double, double* @DBL_MAX
%38 = load double*, double** %14
%39 = load i32, i32* %16
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
br label %42
42: ; preds = %36
%43 = load i32, i32* %16
%44 = add nsw i32 %43, 1
store i32 %44, i32* %16
br label %32
45: ; preds = %32
store i32 1, i32* %17
br label %46
46: ; preds = %172, %45
%47 = load i32, i32* %17
%48 = load i32, i32* %12
%49 = icmp ult i32 %47, %48
br i1 %49, label %50, label %175
50: ; preds = %46
%51 = load double*, double** %7
%52 = load i32, i32* %17
%53 = sub nsw i32 %52, 1
%54 = load i32, i32* %10
%55 = mul i32 %53, %54
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds double, double* %51, i64 %56
store double* %57, double** %18
store i32 0, i32* %19
br label %58
58: ; preds = %86, %50
%59 = load i32, i32* %19
%60 = load i32, i32* %11
%61 = icmp ult i32 %59, %60
br i1 %61, label %62, label %89
62: ; preds = %58
%63 = load double*, double** %18
%64 = load double*, double** %8
%65 = load i32, i32* %19
%66 = load i32, i32* %10
%67 = mul i32 %65, %66
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds double, double* %64, i64 %68
%70 = load i32, i32* %10
%71 = call double @compute_distance(double* %63, double* %69, i32 %70)
store double %71, double* %20
%72 = load double, double* %20
%73 = load double*, double** %14
%74 = load i32, i32* %19
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = fcmp olt double %72, %77
br i1 %78, label %79, label %85
79: ; preds = %62
%80 = load double, double* %20
%81 = load double*, double** %14
%82 = load i32, i32* %19
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %81, i64 %83
store double %80, double* %84
br label %85
85: ; preds = %79, %62
br label %86
86: ; preds = %85
%87 = load i32, i32* %19
%88 = add nsw i32 %87, 1
store i32 %88, i32* %19
br label %58
89: ; preds = %58
store i32 0, i32* %13
%90 = load double*, double** %9
%91 = getelementptr inbounds double, double* %90, i64 0
%92 = load double, double* %91
%93 = load double*, double** %14
%94 = getelementptr inbounds double, double* %93, i64 0
%95 = load double, double* %94
%96 = fmul double %92, %95
%97 = load double*, double** %14
%98 = getelementptr inbounds double, double* %97, i64 0
%99 = load double, double* %98
%100 = fmul double %96, %99
store double %100, double* %21
store i32 1, i32* %22
br label %101
101: ; preds = %138, %89
%102 = load i32, i32* %22
%103 = load i32, i32* %11
%104 = icmp ult i32 %102, %103
br i1 %104, label %105, label %141
105: ; preds = %101
%106 = load double*, double** %9
%107 = load i32, i32* %22
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
%110 = load double, double* %109
%111 = load double*, double** %14
%112 = load i32, i32* %22
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
%115 = load double, double* %114
%116 = fmul double %110, %115
%117 = load double*, double** %14
%118 = load i32, i32* %22
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %117, i64 %119
%121 = load double, double* %120
%122 = fmul double %116, %121
store double %122, double* %23
%123 = load double, double* %23
%124 = load double, double* %21
%125 = fadd double %124, %123
store double %125, double* %21
%126 = call i64 (...) @rand()
%127 = sitofp i64 %126 to double
%128 = load double, double* @RAND_MAX
%129 = fdiv double %127, %128
%130 = load double, double* %21
%131 = fmul double %129, %130
store double %131, double* %15
%132 = load double, double* %15
%133 = load double, double* %23
%134 = fcmp olt double %132, %133
br i1 %134, label %135, label %137
135: ; preds = %105
%136 = load i32, i32* %22
store i32 %136, i32* %13
br label %137
137: ; preds = %135, %105
br label %138
138: ; preds = %137
%139 = load i32, i32* %22
%140 = add nsw i32 %139, 1
store i32 %140, i32* %22
br label %101
141: ; preds = %101
%142 = load double*, double** %7
%143 = load i32, i32* %17
%144 = load i32, i32* %10
%145 = mul i32 %143, %144
%146 = zext i32 %145 to i64
%147 = getelementptr inbounds double, double* %142, i64 %146
store double* %147, double** %18
%148 = load double*, double** %8
%149 = load i32, i32* %13
%150 = load i32, i32* %10
%151 = mul i32 %149, %150
%152 = zext i32 %151 to i64
%153 = getelementptr inbounds double, double* %148, i64 %152
store double* %153, double** %24
store i32 0, i32* %25
br label %154
154: ; preds = %168, %141
%155 = load i32, i32* %25
%156 = load i32, i32* %10
%157 = icmp ult i32 %155, %156
br i1 %157, label %158, label %171
158: ; preds = %154
%159 = load double*, double** %24
%160 = load i32, i32* %25
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds double, double* %159, i64 %161
%163 = load double, double* %162
%164 = load double*, double** %18
%165 = load i32, i32* %25
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds double, double* %164, i64 %166
store double %163, double* %167
br label %168
168: ; preds = %158
%169 = load i32, i32* %25
%170 = add nsw i32 %169, 1
store i32 %170, i32* %25
br label %154
171: ; preds = %154
br label %172
172: ; preds = %171
%173 = load i32, i32* %17
%174 = add nsw i32 %173, 1
store i32 %174, i32* %17
br label %46
175: ; preds = %46
%176 = load double*, double** %14
%177 = call i32 @free(double* %176)
ret void
}

LLVM IR (-O2):
@DBL_MAX = global double 0.000000e+00
@RAND_MAX = global double 0.000000e+00
define void @furthest_first_sample(double* %0, double* %1, double* nocapture %2, i32 %3, i32 %4, i32 %5) {
%7 = shl i32 %4, 3
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to double*
%10 = inttoptr i64 %8 to i8*
%11 = icmp eq i32 %4, 0
br i1 %11, label %112, label %12
12: ; preds = %6
%13 = zext i32 %4 to i64
%14 = icmp ult i32 %4, 4
br i1 %14, label %95, label %15
15: ; preds = %12
%16 = getelementptr double, double* %9, i64 %13
%17 = icmp ult i8* %10, bitcast (double* getelementptr inbounds (double, double* @DBL_MAX, i64 1) to i8*)
%18 = icmp ugt double* %16, @DBL_MAX
%19 = and i1 %17, %18
br i1 %19, label %95, label %20
20: ; preds = %15
%21 = and i64 %13, 4294967292
%22 = add nsw i64 %21, -4
%23 = lshr exact i64 %22, 2
%24 = add nuw nsw i64 %23, 1
%25 = and i64 %24, 3
%26 = icmp ult i64 %22, 12
br i1 %26, label %74, label %27
27: ; preds = %20
%28 = and i64 %24, 9223372036854775804
%29 = load double, double* @DBL_MAX
%30 = insertelement <2 x double> poison, double %29, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = insertelement <2 x double> poison, double %29, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = load double, double* @DBL_MAX
%35 = insertelement <2 x double> poison, double %34, i64 0
%36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> zeroinitializer
%37 = insertelement <2 x double> poison, double %34, i64 0
%38 = shufflevector <2 x double> %37, <2 x double> poison, <2 x i32> zeroinitializer
%39 = load double, double* @DBL_MAX
%40 = insertelement <2 x double> poison, double %39, i64 0
%41 = shufflevector <2 x double> %40, <2 x double> poison, <2 x i32> zeroinitializer
%42 = insertelement <2 x double> poison, double %39, i64 0
%43 = shufflevector <2 x double> %42, <2 x double> poison, <2 x i32> zeroinitializer
%44 = load double, double* @DBL_MAX
%45 = insertelement <2 x double> poison, double %44, i64 0
%46 = shufflevector <2 x double> %45, <2 x double> poison, <2 x i32> zeroinitializer
%47 = insertelement <2 x double> poison, double %44, i64 0
%48 = shufflevector <2 x double> %47, <2 x double> poison, <2 x i32> zeroinitializer
br label %49
49: ; preds = %49, %27
%50 = phi i64 [ 0, %27 ], [ %71, %49 ]
%51 = phi i64 [ 0, %27 ], [ %72, %49 ]
%52 = getelementptr inbounds double, double* %9, i64 %50
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> %31, <2 x double>* %53
%54 = getelementptr inbounds double, double* %52, i64 2
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> %33, <2 x double>* %55
%56 = or i64 %50, 4
%57 = getelementptr inbounds double, double* %9, i64 %56
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> %36, <2 x double>* %58
%59 = getelementptr inbounds double, double* %57, i64 2
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> %38, <2 x double>* %60
%61 = or i64 %50, 8
%62 = getelementptr inbounds double, double* %9, i64 %61
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> %41, <2 x double>* %63
%64 = getelementptr inbounds double, double* %62, i64 2
%65 = bitcast double* %64 to <2 x double>*
store <2 x double> %43, <2 x double>* %65
%66 = or i64 %50, 12
%67 = getelementptr inbounds double, double* %9, i64 %66
%68 = bitcast double* %67 to <2 x double>*
store <2 x double> %46, <2 x double>* %68
%69 = getelementptr inbounds double, double* %67, i64 2
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %48, <2 x double>* %70
%71 = add nuw i64 %50, 16
%72 = add nuw i64 %51, 4
%73 = icmp eq i64 %72, %28
br i1 %73, label %74, label %49
74: ; preds = %49, %20
%75 = phi i64 [ 0, %20 ], [ %71, %49 ]
%76 = icmp eq i64 %25, 0
br i1 %76, label %93, label %77
77: ; preds = %74
%78 = load double, double* @DBL_MAX
%79 = insertelement <2 x double> poison, double %78, i64 0
%80 = shufflevector <2 x double> %79, <2 x double> poison, <2 x i32> zeroinitializer
%81 = insertelement <2 x double> poison, double %78, i64 0
%82 = shufflevector <2 x double> %81, <2 x double> poison, <2 x i32> zeroinitializer
br label %83
83: ; preds = %83, %77
%84 = phi i64 [ %75, %77 ], [ %90, %83 ]
%85 = phi i64 [ 0, %77 ], [ %91, %83 ]
%86 = getelementptr inbounds double, double* %9, i64 %84
%87 = bitcast double* %86 to <2 x double>*
store <2 x double> %80, <2 x double>* %87
%88 = getelementptr inbounds double, double* %86, i64 2
%89 = bitcast double* %88 to <2 x double>*
store <2 x double> %82, <2 x double>* %89
%90 = add nuw i64 %84, 4
%91 = add i64 %85, 1
%92 = icmp eq i64 %91, %25
br i1 %92, label %93, label %83
93: ; preds = %83, %74
%94 = icmp eq i64 %21, %13
br i1 %94, label %112, label %95
95: ; preds = %15, %12, %93
%96 = phi i64 [ 0, %15 ], [ 0, %12 ], [ %21, %93 ]
%97 = xor i64 %96, -1
%98 = add nsw i64 %97, %13
%99 = and i64 %13, 3
%100 = icmp eq i64 %99, 0
br i1 %100, label %109, label %101
101: ; preds = %95, %101
%102 = phi i64 [ %106, %101 ], [ %96, %95 ]
%103 = phi i64 [ %107, %101 ], [ 0, %95 ]
%104 = load double, double* @DBL_MAX
%105 = getelementptr inbounds double, double* %9, i64 %102
store double %104, double* %105
%106 = add nuw nsw i64 %102, 1
%107 = add i64 %103, 1
%108 = icmp eq i64 %107, %99
br i1 %108, label %109, label %101
109: ; preds = %101, %95
%110 = phi i64 [ %96, %95 ], [ %106, %101 ]
%111 = icmp ult i64 %98, 3
br i1 %111, label %112, label %136
112: ; preds = %109, %136, %93, %6
%113 = icmp ugt i32 %5, 1
br i1 %113, label %114, label %151
114: ; preds = %112
%115 = icmp ugt i32 %4, 1
%116 = icmp eq i32 %3, 0
%117 = zext i32 %5 to i64
%118 = zext i32 %4 to i64
%119 = zext i32 %4 to i64
%120 = zext i32 %3 to i64
%121 = getelementptr double, double* %0, i64 %120
%122 = getelementptr double, double* %1, i64 %120
%123 = and i64 %120, 4294967292
%124 = add nsw i64 %123, -4
%125 = lshr exact i64 %124, 2
%126 = add nuw nsw i64 %125, 1
%127 = icmp ult i32 %3, 4
%128 = and i64 %120, 4294967292
%129 = and i64 %126, 3
%130 = icmp ult i64 %124, 12
%131 = and i64 %126, 9223372036854775804
%132 = icmp eq i64 %129, 0
%133 = icmp eq i64 %128, %120
%134 = and i64 %120, 3
%135 = icmp eq i64 %134, 0
br label %153
136: ; preds = %109, %136
%137 = phi i64 [ %149, %136 ], [ %110, %109 ]
%138 = load double, double* @DBL_MAX
%139 = getelementptr inbounds double, double* %9, i64 %137
store double %138, double* %139
%140 = add nuw nsw i64 %137, 1
%141 = load double, double* @DBL_MAX
%142 = getelementptr inbounds double, double* %9, i64 %140
store double %141, double* %142
%143 = add nuw nsw i64 %137, 2
%144 = load double, double* @DBL_MAX
%145 = getelementptr inbounds double, double* %9, i64 %143
store double %144, double* %145
%146 = add nuw nsw i64 %137, 3
%147 = load double, double* @DBL_MAX
%148 = getelementptr inbounds double, double* %9, i64 %146
store double %147, double* %148
%149 = add nuw nsw i64 %137, 4
%150 = icmp eq i64 %149, %13
br i1 %150, label %112, label %136
151: ; preds = %307, %112
%152 = tail call i32 @free(double* %9)
ret void
153: ; preds = %114, %307
%154 = phi i32 [ 0, %114 ], [ %310, %307 ]
%155 = phi i64 [ 1, %114 ], [ %308, %307 ]
%156 = mul i32 %154, %3
%157 = add i32 %156, %3
%158 = zext i32 %157 to i64
%159 = getelementptr double, double* %0, i64 %158
%160 = getelementptr double, double* %121, i64 %158
%161 = trunc i64 %155 to i32
%162 = add i32 %161, -1
%163 = mul i32 %162, %3
%164 = zext i32 %163 to i64
%165 = getelementptr inbounds double, double* %0, i64 %164
br i1 %11, label %166, label %172
166: ; preds = %183, %153
%167 = load double, double* %9
br i1 %115, label %168, label %186
168: ; preds = %166
%169 = load double, double* %2
%170 = fmul double %169, %167
%171 = fmul double %167, %170
br label %286
172: ; preds = %153, %183
%173 = phi i64 [ %184, %183 ], [ 0, %153 ]
%174 = trunc i64 %173 to i32
%175 = mul i32 %174, %3
%176 = zext i32 %175 to i64
%177 = getelementptr inbounds double, double* %1, i64 %176
%178 = tail call double @compute_distance(double* %165, double* %177, i32 %3)
%179 = getelementptr inbounds double, double* %9, i64 %173
%180 = load double, double* %179
%181 = fcmp olt double %178, %180
br i1 %181, label %182, label %183
182: ; preds = %172
store double %178, double* %179
br label %183
183: ; preds = %182, %172
%184 = add nuw nsw i64 %173, 1
%185 = icmp eq i64 %184, %118
br i1 %185, label %166, label %172
186: ; preds = %286, %166
%187 = phi i32 [ 0, %166 ], [ %304, %286 ]
%188 = trunc i64 %155 to i32
%189 = mul i32 %188, %3
%190 = zext i32 %189 to i64
%191 = getelementptr inbounds double, double* %0, i64 %190
%192 = mul i32 %187, %3
%193 = zext i32 %192 to i64
%194 = getelementptr double, double* %1, i64 %193
br i1 %116, label %307, label %195
195: ; preds = %186
br i1 %127, label %270, label %196
196: ; preds = %195
%197 = getelementptr double, double* %122, i64 %193
%198 = icmp ult double* %159, %197
%199 = icmp ult double* %194, %160
%200 = and i1 %198, %199
br i1 %200, label %270, label %201
201: ; preds = %196
br i1 %130, label %251, label %202
202: ; preds = %201, %202
%203 = phi i64 [ %248, %202 ], [ 0, %201 ]
%204 = phi i64 [ %249, %202 ], [ 0, %201 ]
%205 = getelementptr inbounds double, double* %194, i64 %203
%206 = bitcast double* %205 to <2 x double>*
%207 = load <2 x double>, <2 x double>* %206
%208 = getelementptr inbounds double, double* %205, i64 2
%209 = bitcast double* %208 to <2 x double>*
%210 = load <2 x double>, <2 x double>* %209
%211 = getelementptr inbounds double, double* %191, i64 %203
%212 = bitcast double* %211 to <2 x double>*
store <2 x double> %207, <2 x double>* %212
%213 = getelementptr inbounds double, double* %211, i64 2
%214 = bitcast double* %213 to <2 x double>*
store <2 x double> %210, <2 x double>* %214
%215 = or i64 %203, 4
%216 = getelementptr inbounds double, double* %194, i64 %215
%217 = bitcast double* %216 to <2 x double>*
%218 = load <2 x double>, <2 x double>* %217
%219 = getelementptr inbounds double, double* %216, i64 2
%220 = bitcast double* %219 to <2 x double>*
%221 = load <2 x double>, <2 x double>* %220
%222 = getelementptr inbounds double, double* %191, i64 %215
%223 = bitcast double* %222 to <2 x double>*
store <2 x double> %218, <2 x double>* %223
%224 = getelementptr inbounds double, double* %222, i64 2
%225 = bitcast double* %224 to <2 x double>*
store <2 x double> %221, <2 x double>* %225
%226 = or i64 %203, 8
%227 = getelementptr inbounds double, double* %194, i64 %226
%228 = bitcast double* %227 to <2 x double>*
%229 = load <2 x double>, <2 x double>* %228
%230 = getelementptr inbounds double, double* %227, i64 2
%231 = bitcast double* %230 to <2 x double>*
%232 = load <2 x double>, <2 x double>* %231
%233 = getelementptr inbounds double, double* %191, i64 %226
%234 = bitcast double* %233 to <2 x double>*
store <2 x double> %229, <2 x double>* %234
%235 = getelementptr inbounds double, double* %233, i64 2
%236 = bitcast double* %235 to <2 x double>*
store <2 x double> %232, <2 x double>* %236
%237 = or i64 %203, 12
%238 = getelementptr inbounds double, double* %194, i64 %237
%239 = bitcast double* %238 to <2 x double>*
%240 = load <2 x double>, <2 x double>* %239
%241 = getelementptr inbounds double, double* %238, i64 2
%242 = bitcast double* %241 to <2 x double>*
%243 = load <2 x double>, <2 x double>* %242
%244 = getelementptr inbounds double, double* %191, i64 %237
%245 = bitcast double* %244 to <2 x double>*
store <2 x double> %240, <2 x double>* %245
%246 = getelementptr inbounds double, double* %244, i64 2
%247 = bitcast double* %246 to <2 x double>*
store <2 x double> %243, <2 x double>* %247
%248 = add nuw i64 %203, 16
%249 = add nuw i64 %204, 4
%250 = icmp eq i64 %249, %131
br i1 %250, label %251, label %202
251: ; preds = %202, %201
%252 = phi i64 [ 0, %201 ], [ %248, %202 ]
br i1 %132, label %269, label %253
253: ; preds = %251, %253
%254 = phi i64 [ %266, %253 ], [ %252, %251 ]
%255 = phi i64 [ %267, %253 ], [ 0, %251 ]
%256 = getelementptr inbounds double, double* %194, i64 %254
%257 = bitcast double* %256 to <2 x double>*
%258 = load <2 x double>, <2 x double>* %257
%259 = getelementptr inbounds double, double* %256, i64 2
%260 = bitcast double* %259 to <2 x double>*
%261 = load <2 x double>, <2 x double>* %260
%262 = getelementptr inbounds double, double* %191, i64 %254
%263 = bitcast double* %262 to <2 x double>*
store <2 x double> %258, <2 x double>* %263
%264 = getelementptr inbounds double, double* %262, i64 2
%265 = bitcast double* %264 to <2 x double>*
store <2 x double> %261, <2 x double>* %265
%266 = add nuw i64 %254, 4
%267 = add i64 %255, 1
%268 = icmp eq i64 %267, %129
br i1 %268, label %269, label %253
269: ; preds = %253, %251
br i1 %133, label %307, label %270
270: ; preds = %196, %195, %269
%271 = phi i64 [ 0, %196 ], [ 0, %195 ], [ %128, %269 ]
%272 = xor i64 %271, -1
%273 = add nsw i64 %272, %120
br i1 %135, label %283, label %274
274: ; preds = %270, %274
%275 = phi i64 [ %280, %274 ], [ %271, %270 ]
%276 = phi i64 [ %281, %274 ], [ 0, %270 ]
%277 = getelementptr inbounds double, double* %194, i64 %275
%278 = load double, double* %277
%279 = getelementptr inbounds double, double* %191, i64 %275
store double %278, double* %279
%280 = add nuw nsw i64 %275, 1
%281 = add i64 %276, 1
%282 = icmp eq i64 %281, %134
br i1 %282, label %283, label %274
283: ; preds = %274, %270
%284 = phi i64 [ %271, %270 ], [ %280, %274 ]
%285 = icmp ult i64 %273, 3
br i1 %285, label %307, label %311
286: ; preds = %168, %286
%287 = phi i64 [ 1, %168 ], [ %305, %286 ]
%288 = phi i32 [ 0, %168 ], [ %304, %286 ]
%289 = phi double [ %171, %168 ], [ %296, %286 ]
%290 = getelementptr inbounds double, double* %2, i64 %287
%291 = load double, double* %290
%292 = getelementptr inbounds double, double* %9, i64 %287
%293 = load double, double* %292
%294 = fmul double %291, %293
%295 = fmul double %293, %294
%296 = fadd double %289, %295
%297 = tail call i64 (...) @rand()
%298 = sitofp i64 %297 to double
%299 = load double, double* @RAND_MAX
%300 = fdiv double %298, %299
%301 = fmul double %300, %296
%302 = fcmp olt double %301, %295
%303 = trunc i64 %287 to i32
%304 = select i1 %302, i32 %303, i32 %288
%305 = add nuw nsw i64 %287, 1
%306 = icmp eq i64 %305, %119
br i1 %306, label %186, label %286
307: ; preds = %283, %311, %269, %186
%308 = add nuw nsw i64 %155, 1
%309 = icmp eq i64 %308, %117
%310 = add i32 %154, 1
br i1 %309, label %151, label %153
311: ; preds = %283, %311
%312 = phi i64 [ %328, %311 ], [ %284, %283 ]
%313 = getelementptr inbounds double, double* %194, i64 %312
%314 = load double, double* %313
%315 = getelementptr inbounds double, double* %191, i64 %312
store double %314, double* %315
%316 = add nuw nsw i64 %312, 1
%317 = getelementptr inbounds double, double* %194, i64 %316
%318 = load double, double* %317
%319 = getelementptr inbounds double, double* %191, i64 %316
store double %318, double* %319
%320 = add nuw nsw i64 %312, 2
%321 = getelementptr inbounds double, double* %194, i64 %320
%322 = load double, double* %321
%323 = getelementptr inbounds double, double* %191, i64 %320
store double %322, double* %323
%324 = add nuw nsw i64 %312, 3
%325 = getelementptr inbounds double, double* %194, i64 %324
%326 = load double, double* %325
%327 = getelementptr inbounds double, double* %191, i64 %324
store double %326, double* %327
%328 = add nuw nsw i64 %312, 4
%329 = icmp eq i64 %328, %120
br i1 %329, label %307, label %311
}