#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 /*<<< orphan*/ furthest_first(double *, double const *, unsigned int,
                                  unsigned int, unsigned int);
unsigned int rand();
void rand_ff(double *CX, const double *X, unsigned int dim, unsigned int npts,
             unsigned int nclus) {
  int r = rand() % npts;
  const double *a = X + r * dim;
  for (int i = 0; i < dim; i++)
    CX[i] = a[i];
  furthest_first(CX, X, dim, npts, nclus);
}


x86 assembly (clang, -O0):
<rand_ff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
xor    %edx,%edx
divl   -0x18(%rbp)
mov    %edx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x14(%rbp),%ecx
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    119c <rand_ff+0x7c>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1168 <rand_ff+0x48>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1030 <furthest_first@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_ff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %eax,%eax
call   1040 <rand@plt>
xor    %edx,%edx
div    %r12d
test   %r13d,%r13d
je     12e8 <rand_ff+0x1c8>
imul   %r13d,%edx
lea    (%r15,%rdx,8),%rax
mov    %r13d,%r9d
cmp    $0x4,%r13d
jb     1180 <rand_ff+0x60>
add    %r9,%rdx
lea    (%r15,%rdx,8),%rdx
cmp    %rbp,%rdx
jbe    11fd <rand_ff+0xdd>
lea    0x0(,%r9,8),%rdx
add    %rbp,%rdx
cmp    %rdx,%rax
jae    11fd <rand_ff+0xdd>
xor    %edx,%edx
mov    %rdx,%rsi
not    %rsi
add    %r9,%rsi
mov    %r9,%rdi
and    $0x3,%rdi
je     11b5 <rand_ff+0x95>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rax,%rdx,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rdi
jne    11a0 <rand_ff+0x80>
cmp    $0x3,%rsi
jb     12e8 <rand_ff+0x1c8>
nop
movsd  (%rax,%rdx,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rdx,8)
movsd  0x8(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rbp,%rdx,8)
movsd  0x10(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rbp,%rdx,8)
movsd  0x18(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rbp,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%r9
jne    11c0 <rand_ff+0xa0>
jmp    12e8 <rand_ff+0x1c8>
mov    %r9d,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rdi
mov    %rdi,%r10
shr    $0x2,%r10
add    $0x1,%r10
mov    %r10d,%r8d
and    $0x3,%r8d
cmp    $0xc,%rdi
jae    1226 <rand_ff+0x106>
xor    %edi,%edi
jmp    12a0 <rand_ff+0x180>
and    $0xfffffffffffffffc,%r10
xor    %edi,%edi
nopl   0x0(%rax)
lea    0x0(,%rdi,8),%rsi
movups (%rax,%rdi,8),%xmm0
movups 0x10(%rax,%rdi,8),%xmm1
movups %xmm0,0x0(%rbp,%rdi,8)
movups %xmm1,0x10(%rbp,%rdi,8)
mov    %rsi,%rbx
or     $0x20,%rbx
movups (%rax,%rbx,1),%xmm0
movups 0x10(%rax,%rbx,1),%xmm1
movups %xmm0,0x20(%rbp,%rdi,8)
movups %xmm1,0x30(%rbp,%rdi,8)
mov    %rsi,%rcx
or     $0x40,%rcx
movups (%rax,%rcx,1),%xmm0
movups 0x10(%rax,%rcx,1),%xmm1
movups %xmm0,0x40(%rbp,%rdi,8)
movups %xmm1,0x50(%rbp,%rdi,8)
or     $0x60,%rsi
movups (%rax,%rsi,1),%xmm0
movups 0x10(%rax,%rsi,1),%xmm1
movups %xmm0,0x60(%rbp,%rdi,8)
movups %xmm1,0x70(%rbp,%rdi,8)
add    $0x10,%rdi
add    $0xfffffffffffffffc,%r10
jne    1230 <rand_ff+0x110>
test   %r8,%r8
je     12df <rand_ff+0x1bf>
lea    0x10(,%rdi,8),%rsi
add    %rbp,%rsi
shl    $0x5,%r8
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movups (%rax,%rdi,8),%xmm0
movups 0x10(%rax,%rdi,8),%xmm1
movups %xmm0,-0x10(%rsi,%rbx,1)
movups %xmm1,(%rsi,%rbx,1)
add    $0x4,%rdi
add    $0x20,%rbx
cmp    %rbx,%r8
jne    12c0 <rand_ff+0x1a0>
cmp    %r9,%rdx
jne    1182 <rand_ff+0x62>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <furthest_first@plt>

LLVM IR (-O0):
define void @rand_ff(double* %0, double* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
%13 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = call i32 (...) @rand()
%15 = load i32, i32* %9
%16 = urem i32 %14, %15
store i32 %16, i32* %11
%17 = load double*, double** %7
%18 = load i32, i32* %11
%19 = load i32, i32* %8
%20 = mul i32 %18, %19
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds double, double* %17, i64 %21
store double* %22, double** %12
store i32 0, i32* %13
br label %23
23: ; preds = %37, %5
%24 = load i32, i32* %13
%25 = load i32, i32* %8
%26 = icmp ult i32 %24, %25
br i1 %26, label %27, label %40
27: ; preds = %23
%28 = load double*, double** %12
%29 = load i32, i32* %13
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = load double*, double** %6
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
br label %37
37: ; preds = %27
%38 = load i32, i32* %13
%39 = add nsw i32 %38, 1
store i32 %39, i32* %13
br label %23
40: ; preds = %23
%41 = load double*, double** %6
%42 = load double*, double** %7
%43 = load i32, i32* %8
%44 = load i32, i32* %9
%45 = load i32, i32* %10
%46 = call i32 @furthest_first(double* %41, double* %42, i32 %43, i32 %44, i32 %45)
ret void
}

LLVM IR (-O2):
define void @rand_ff(double* %0, double* %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 (...) @rand()
%7 = urem i32 %6, %3
%8 = mul i32 %7, %2
%9 = zext i32 %8 to i64
%10 = getelementptr double, double* %1, i64 %9
%11 = icmp eq i32 %2, 0
br i1 %11, label %119, label %12
12: ; preds = %5
%13 = zext i32 %2 to i64
%14 = icmp ult i32 %2, 4
br i1 %14, label %101, label %15
15: ; preds = %12
%16 = getelementptr double, double* %0, i64 %13
%17 = add nuw nsw i64 %13, %9
%18 = getelementptr double, double* %1, i64 %17
%19 = icmp ugt double* %18, %0
%20 = icmp ult double* %10, %16
%21 = and i1 %19, %20
br i1 %21, label %101, label %22
22: ; preds = %15
%23 = and i64 %13, 4294967292
%24 = add nsw i64 %23, -4
%25 = lshr exact i64 %24, 2
%26 = add nuw nsw i64 %25, 1
%27 = and i64 %26, 3
%28 = icmp ult i64 %24, 12
br i1 %28, label %80, label %29
29: ; preds = %22
%30 = and i64 %26, 9223372036854775804
br label %31
31: ; preds = %31, %29
%32 = phi i64 [ 0, %29 ], [ %77, %31 ]
%33 = phi i64 [ 0, %29 ], [ %78, %31 ]
%34 = getelementptr inbounds double, double* %10, i64 %32
%35 = bitcast double* %34 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
%37 = getelementptr inbounds double, double* %34, i64 2
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = getelementptr inbounds double, double* %0, i64 %32
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> %36, <2 x double>* %41
%42 = getelementptr inbounds double, double* %40, i64 2
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> %39, <2 x double>* %43
%44 = or i64 %32, 4
%45 = getelementptr inbounds double, double* %10, i64 %44
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = getelementptr inbounds double, double* %45, i64 2
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = getelementptr inbounds double, double* %0, i64 %44
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %47, <2 x double>* %52
%53 = getelementptr inbounds double, double* %51, i64 2
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %50, <2 x double>* %54
%55 = or i64 %32, 8
%56 = getelementptr inbounds double, double* %10, i64 %55
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = getelementptr inbounds double, double* %56, i64 2
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = getelementptr inbounds double, double* %0, i64 %55
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> %58, <2 x double>* %63
%64 = getelementptr inbounds double, double* %62, i64 2
%65 = bitcast double* %64 to <2 x double>*
store <2 x double> %61, <2 x double>* %65
%66 = or i64 %32, 12
%67 = getelementptr inbounds double, double* %10, i64 %66
%68 = bitcast double* %67 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = getelementptr inbounds double, double* %67, i64 2
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = getelementptr inbounds double, double* %0, i64 %66
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %69, <2 x double>* %74
%75 = getelementptr inbounds double, double* %73, i64 2
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %72, <2 x double>* %76
%77 = add nuw i64 %32, 16
%78 = add nuw i64 %33, 4
%79 = icmp eq i64 %78, %30
br i1 %79, label %80, label %31
80: ; preds = %31, %22
%81 = phi i64 [ 0, %22 ], [ %77, %31 ]
%82 = icmp eq i64 %27, 0
br i1 %82, label %99, label %83
83: ; preds = %80, %83
%84 = phi i64 [ %96, %83 ], [ %81, %80 ]
%85 = phi i64 [ %97, %83 ], [ 0, %80 ]
%86 = getelementptr inbounds double, double* %10, i64 %84
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = getelementptr inbounds double, double* %86, i64 2
%90 = bitcast double* %89 to <2 x double>*
%91 = load <2 x double>, <2 x double>* %90
%92 = getelementptr inbounds double, double* %0, i64 %84
%93 = bitcast double* %92 to <2 x double>*
store <2 x double> %88, <2 x double>* %93
%94 = getelementptr inbounds double, double* %92, i64 2
%95 = bitcast double* %94 to <2 x double>*
store <2 x double> %91, <2 x double>* %95
%96 = add nuw i64 %84, 4
%97 = add i64 %85, 1
%98 = icmp eq i64 %97, %27
br i1 %98, label %99, label %83
99: ; preds = %83, %80
%100 = icmp eq i64 %23, %13
br i1 %100, label %119, label %101
101: ; preds = %15, %12, %99
%102 = phi i64 [ 0, %15 ], [ 0, %12 ], [ %23, %99 ]
%103 = xor i64 %102, -1
%104 = add nsw i64 %103, %13
%105 = and i64 %13, 3
%106 = icmp eq i64 %105, 0
br i1 %106, label %116, label %107
107: ; preds = %101, %107
%108 = phi i64 [ %113, %107 ], [ %102, %101 ]
%109 = phi i64 [ %114, %107 ], [ 0, %101 ]
%110 = getelementptr inbounds double, double* %10, i64 %108
%111 = load double, double* %110
%112 = getelementptr inbounds double, double* %0, i64 %108
store double %111, double* %112
%113 = add nuw nsw i64 %108, 1
%114 = add i64 %109, 1
%115 = icmp eq i64 %114, %105
br i1 %115, label %116, label %107
116: ; preds = %107, %101
%117 = phi i64 [ %102, %101 ], [ %113, %107 ]
%118 = icmp ult i64 %104, 3
br i1 %118, label %119, label %121
119: ; preds = %116, %121, %99, %5
%120 = tail call i32 @furthest_first(double* %0, double* %1, i32 %2, i32 %3, i32 %4)
ret void
121: ; preds = %116, %121
%122 = phi i64 [ %138, %121 ], [ %117, %116 ]
%123 = getelementptr inbounds double, double* %10, i64 %122
%124 = load double, double* %123
%125 = getelementptr inbounds double, double* %0, i64 %122
store double %124, double* %125
%126 = add nuw nsw i64 %122, 1
%127 = getelementptr inbounds double, double* %10, i64 %126
%128 = load double, double* %127
%129 = getelementptr inbounds double, double* %0, i64 %126
store double %128, double* %129
%130 = add nuw nsw i64 %122, 2
%131 = getelementptr inbounds double, double* %10, i64 %130
%132 = load double, double* %131
%133 = getelementptr inbounds double, double* %0, i64 %130
store double %132, double* %133
%134 = add nuw nsw i64 %122, 3
%135 = getelementptr inbounds double, double* %10, i64 %134
%136 = load double, double* %135
%137 = getelementptr inbounds double, double* %0, i64 %134
store double %136, double* %137
%138 = add nuw nsw i64 %122, 4
%139 = icmp eq i64 %138, %13
br i1 %139, label %119, label %121
}