#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 */
typedef scalar_t__ clock_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ del_dmat(double **);
int /*<<< orphan*/ del_ivec(int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
double kmeans(int, int, int, int, double **, int *, int *);
int /*<<< orphan*/ memcpy(int *, int *, int);
double **new_dmat(int, int);
int *new_ivec(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ save_ivec(char *, int, int *);
int main(int argc, char *argv[]) {
  int _size = 1;
  int _rank = 0;
  if (_rank == 0)
    printf("Number of processors %d\n", _size);
  printf("Start on processor %d\n", _rank);
  clock_t tic = 0, toc = 0;
  if (_rank == 0)
    tic = clock();
  int nk = 0, nt = 0, nc = 0, nv = 0, ns = 0;
  char fileconf[256], filecent[256], fileasgn[256];
  FILE *fini = fopen("input", "r");
  fscanf(fini, "%d%d%d%d%d%s%s%s", &nk, &nt, &nc, &nv, &ns, fileconf, filecent,
         fileasgn);
  fclose(fini);
  double **data = new_dmat(nt, nv);
  int *assignment = new_ivec(nt);
  int *cents = new_ivec(nk);
  int *assignment_bak = new_ivec(nt);
  int *cents_bak = new_ivec(nk);
  FILE *fconf = fopen(fileconf, "r");
  double dtmp = 0;
  for (int i = 0; i < nt; ++i) {
    for (int c = 0; c < nc; ++c) {
      fscanf(fconf, "%lf", &dtmp);
      if (c < nv)
        data[i][c] = dtmp;
    }
  }
  fclose(fconf);
  double minsumdist = 1.e60;
  while (ns--) {
    printf("sample count down: %d\n", ns);
    double sumdist = kmeans(1, nk, nt, nv, data, cents, assignment);
    if (sumdist < minsumdist) {
      memcpy(cents_bak, cents, nk * sizeof(int));
      memcpy(assignment_bak, assignment, nt * sizeof(int));
    }
  }
  save_ivec(filecent, nk, cents_bak);
  save_ivec(fileasgn, nt, assignment_bak);
  del_ivec(cents_bak);
  del_ivec(assignment_bak);
  del_ivec(cents);
  del_ivec(assignment);
  del_dmat(data);
  if (_rank == 0) {
    toc = clock();
    printf("cputime: %16.6e seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x3c8,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1203 <main+0x43>
cvtsi2sdl -0x1c(%rbp),%xmm0
lea    0xe0a(%rip),%rdi
call   1060 <printf@plt>
cvtsi2sdl -0x20(%rbp),%xmm0
lea    0xe12(%rip),%rdi
call   1060 <printf@plt>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1239 <main+0x79>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xdd5(%rip),%rdi
lea    0xdd4(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x358(%rbp)
mov    -0x358(%rbp),%rdi
lea    -0x150(%rbp),%r11
lea    -0x250(%rbp),%r10
lea    -0x350(%rbp),%rax
lea    0xda7(%rip),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x44(%rbp),%rbx
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x358(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%edi
mov    -0x40(%rbp),%esi
call   10e0 <new_dmat@plt>
mov    %rax,-0x360(%rbp)
mov    -0x38(%rbp),%edi
call   10a0 <new_ivec@plt>
mov    %rax,-0x368(%rbp)
mov    -0x34(%rbp),%edi
call   10a0 <new_ivec@plt>
mov    %rax,-0x370(%rbp)
mov    -0x38(%rbp),%edi
call   10a0 <new_ivec@plt>
mov    %rax,-0x378(%rbp)
mov    -0x34(%rbp),%edi
call   10a0 <new_ivec@plt>
mov    %rax,-0x380(%rbp)
lea    -0x150(%rbp),%rdi
lea    0xd0f(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x388(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x390(%rbp)
ff
movl   $0x0,-0x394(%rbp)
mov    -0x394(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    13fb <main+0x23b>
movl   $0x0,-0x398(%rbp)
mov    -0x398(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    13e2 <main+0x222>
mov    -0x388(%rbp),%rdi
lea    0xccb(%rip),%rsi
lea    -0x390(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x398(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    13c9 <main+0x209>
movsd  -0x390(%rbp),%xmm0
ff
mov    -0x360(%rbp),%rax
movslq -0x394(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x398(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    13ce <main+0x20e>
mov    -0x398(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x398(%rbp)
jmp    1369 <main+0x1a9>
jmp    13e7 <main+0x227>
mov    -0x394(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x394(%rbp)
jmp    1350 <main+0x190>
mov    -0x388(%rbp),%rdi
call   1050 <fclose@plt>
movsd  0xbf1(%rip),%xmm0
movsd  %xmm0,-0x3a0(%rbp)
ff
mov    -0x44(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x44(%rbp)
cmp    $0x0,%eax
je     14c9 <main+0x309>
cvtsi2sdl -0x44(%rbp),%xmm0
lea    0xc1e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x360(%rbp),%r8
mov    -0x370(%rbp),%r9
mov    -0x368(%rbp),%rax
mov    $0x1,%edi
mov    %rax,(%rsp)
call   10c0 <kmeans@plt>
movsd  %xmm0,-0x3a8(%rbp)
ff
movsd  -0x3a8(%rbp),%xmm1
ff
movsd  -0x3a0(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    14c4 <main+0x304>
mov    -0x380(%rbp),%rdi
mov    -0x370(%rbp),%rsi
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   10b0 <memcpy@plt>
mov    -0x378(%rbp),%rdi
mov    -0x368(%rbp),%rsi
movslq -0x38(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   10b0 <memcpy@plt>
jmp    1417 <main+0x257>
lea    -0x250(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x380(%rbp),%rdx
call   1090 <save_ivec@plt>
lea    -0x350(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x378(%rbp),%rdx
call   1090 <save_ivec@plt>
mov    -0x380(%rbp),%rdi
call   1080 <del_ivec@plt>
mov    -0x378(%rbp),%rdi
call   1080 <del_ivec@plt>
mov    -0x370(%rbp),%rdi
call   1080 <del_ivec@plt>
mov    -0x368(%rbp),%rdi
call   1080 <del_ivec@plt>
mov    -0x360(%rbp),%rdi
call   1030 <del_dmat@plt>
cmpl   $0x0,-0x20(%rbp)
jne    156a <main+0x3aa>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2a8e(%rip),%rax
divsd  (%rax),%xmm0
lea    0xb07(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x3c8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x358,%rsp
lea    0xe38(%rip),%rdi
movsd  0xe20(%rip),%xmm0
call   1060 <printf@plt>
lea    0xe3d(%rip),%rdi
xorpd  %xmm0,%xmm0
call   1060 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,0x48(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
lea    0xe10(%rip),%rdi
lea    0xe0f(%rip),%r15
mov    %r15,%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbx
lea    0x50(%rsp),%rbp
lea    0x150(%rsp),%r10
lea    0x250(%rsp),%r14
lea    0x14(%rsp),%r11
lea    0xde5(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
mov    %rax,%rdi
xor    %eax,%eax
push   %rbp
push   %r10
push   %r14
push   %r11
call   1070 <fscanf@plt>
add    $0x20,%rsp
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0xc(%rsp),%edi
mov    0x18(%rsp),%esi
call   10e0 <new_dmat@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
call   10a0 <new_ivec@plt>
mov    %rax,0x40(%rsp)
mov    0x10(%rsp),%edi
call   10a0 <new_ivec@plt>
mov    %rax,0x38(%rsp)
mov    0xc(%rsp),%edi
call   10a0 <new_ivec@plt>
mov    %rax,0x30(%rsp)
mov    0x10(%rsp),%edi
call   10a0 <new_ivec@plt>
mov    %rax,0x28(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   10d0 <fopen@plt>
mov    %rax,%r14
movq   $0x0,0x20(%rsp)
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    136a <main+0x1aa>
mov    0x1c(%rsp),%eax
lea    0xd53(%rip),%r13
lea    0x20(%rsp),%rbp
xor    %r15d,%r15d
jmp    1320 <main+0x160>
mov    0xc(%rsp),%ecx
add    $0x1,%r15
movslq %ecx,%rdx
cmp    %rdx,%r15
jge    136a <main+0x1aa>
test   %eax,%eax
jle    1314 <main+0x154>
xor    %r12d,%r12d
jmp    133e <main+0x17e>
nopl   0x0(%rax)
add    $0x1,%r12
movslq 0x1c(%rsp),%rax
cmp    %rax,%r12
jge    1310 <main+0x150>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <fscanf@plt>
movslq 0x18(%rsp),%rax
cmp    %rax,%r12
jge    1330 <main+0x170>
movsd  0x20(%rsp),%xmm0
mov    (%rbx,%r15,8),%rax
movsd  %xmm0,(%rax,%r12,8)
jmp    1330 <main+0x170>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x14(%rsp),%eax
sub    $0x1,%eax
mov    %eax,0x14(%rsp)
mov    0x40(%rsp),%r15
mov    0x38(%rsp),%rbp
mov    0x30(%rsp),%r12
mov    0x28(%rsp),%r13
jae    1423 <main+0x263>
mov    0x10(%rsp),%esi
lea    0x150(%rsp),%rdi
mov    %r13,%rdx
call   1090 <save_ivec@plt>
mov    0xc(%rsp),%esi
lea    0x50(%rsp),%rdi
mov    %r12,%rdx
call   1090 <save_ivec@plt>
mov    %r13,%rdi
call   1080 <del_ivec@plt>
mov    %r12,%rdi
call   1080 <del_ivec@plt>
mov    %rbp,%rdi
call   1080 <del_ivec@plt>
mov    %r15,%rdi
call   1080 <del_ivec@plt>
mov    %rbx,%rdi
call   1030 <del_dmat@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    0x48(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2be9(%rip),%rax
divsd  (%rax),%xmm0
lea    0xc6a(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x358,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc33(%rip),%r14
jmp    1441 <main+0x281>
nopl   0x0(%rax)
mov    0x14(%rsp),%eax
sub    $0x1,%eax
mov    %eax,0x14(%rsp)
jb     1397 <main+0x1d7>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %r14,%rdi
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x18(%rsp),%ecx
sub    $0x8,%rsp
mov    $0x1,%edi
mov    %rbx,%r8
mov    %rbp,%r9
push   %r15
call   10c0 <kmeans@plt>
add    $0x10,%rsp
movsd  0xb8a(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1430 <main+0x270>
mov    0x10(%rsp),%edx
shl    $0x2,%edx
mov    %r13,%rdi
mov    %rbp,%rsi
call   10b0 <memcpy@plt>
mov    0xc(%rsp),%edx
shl    $0x2,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   10b0 <memcpy@plt>
jmp    1430 <main+0x270>

LLVM IR (-O0):
@.str = [25 x i8] c"Number of processors %d\0A\00"
@.str.1 = [23 x i8] c"Start on processor %d\0A\00"
@.str.2 = [6 x i8] c"input\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [17 x i8] c"%d%d%d%d%d%s%s%s\00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [23 x i8] c"sample count down: %d\0A\00"
@.str.7 = [25 x i8] c"cputime: %16.6e seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [256 x i8]
%16 = alloca [256 x i8]
%17 = alloca [256 x i8]
%18 = alloca i32*
%19 = alloca double**
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca double
%26 = alloca i32
%27 = alloca i32
%28 = alloca double
%29 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 0, i32* %7
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %2
%33 = load i32, i32* %6
%34 = sitofp i32 %33 to double
%35 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %34)
br label %36
36: ; preds = %32, %2
%37 = load i32, i32* %7
%38 = sitofp i32 %37 to double
%39 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %38)
store i64 0, i64* %8
store i64 0, i64* %9
%40 = load i32, i32* %7
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i64 (...) @clock()
store i64 %43, i64* %8
br label %44
44: ; preds = %42, %36
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
%45 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %45, i32** %18
%46 = load i32*, i32** %18
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%50 = call i32 (i32*, i8*, ...) @fscanf(i32* %46, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i8* %47, i8* %48, i8* %49)
%51 = load i32*, i32** %18
%52 = call i32 @fclose(i32* %51)
%53 = load i32, i32* %11
%54 = load i32, i32* %13
%55 = call double** @new_dmat(i32 %53, i32 %54)
store double** %55, double*** %19
%56 = load i32, i32* %11
%57 = call i32* @new_ivec(i32 %56)
store i32* %57, i32** %20
%58 = load i32, i32* %10
%59 = call i32* @new_ivec(i32 %58)
store i32* %59, i32** %21
%60 = load i32, i32* %11
%61 = call i32* @new_ivec(i32 %60)
store i32* %61, i32** %22
%62 = load i32, i32* %10
%63 = call i32* @new_ivec(i32 %62)
store i32* %63, i32** %23
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%65 = call i32* @fopen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %65, i32** %24
store double 0.000000e+00, double* %25
store i32 0, i32* %26
br label %66
66: ; preds = %96, %44
%67 = load i32, i32* %26
%68 = load i32, i32* %11
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %99
70: ; preds = %66
store i32 0, i32* %27
br label %71
71: ; preds = %92, %70
%72 = load i32, i32* %27
%73 = load i32, i32* %12
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %95
75: ; preds = %71
%76 = load i32*, i32** %24
%77 = call i32 (i32*, i8*, ...) @fscanf(i32* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %25)
%78 = load i32, i32* %27
%79 = load i32, i32* %13
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %91
81: ; preds = %75
%82 = load double, double* %25
%83 = load double**, double*** %19
%84 = load i32, i32* %26
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double*, double** %83, i64 %85
%87 = load double*, double** %86
%88 = load i32, i32* %27
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %87, i64 %89
store double %82, double* %90
br label %91
91: ; preds = %81, %75
br label %92
92: ; preds = %91
%93 = load i32, i32* %27
%94 = add nsw i32 %93, 1
store i32 %94, i32* %27
br label %71
95: ; preds = %71
br label %96
96: ; preds = %95
%97 = load i32, i32* %26
%98 = add nsw i32 %97, 1
store i32 %98, i32* %26
br label %66
99: ; preds = %66
%100 = load i32*, i32** %24
%101 = call i32 @fclose(i32* %100)
store double 0x4C63E9E4E4C2F344, double* %28
br label %102
102: ; preds = %135, %99
%103 = load i32, i32* %14
%104 = add nsw i32 %103, -1
store i32 %104, i32* %14
%105 = icmp ne i32 %103, 0
br i1 %105, label %106, label %136
106: ; preds = %102
%107 = load i32, i32* %14
%108 = sitofp i32 %107 to double
%109 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), double %108)
%110 = load i32, i32* %10
%111 = load i32, i32* %11
%112 = load i32, i32* %13
%113 = load double**, double*** %19
%114 = load i32*, i32** %21
%115 = load i32*, i32** %20
%116 = call double @kmeans(i32 1, i32 %110, i32 %111, i32 %112, double** %113, i32* %114, i32* %115)
store double %116, double* %29
%117 = load double, double* %29
%118 = load double, double* %28
%119 = fcmp olt double %117, %118
br i1 %119, label %120, label %135
120: ; preds = %106
%121 = load i32*, i32** %23
%122 = load i32*, i32** %21
%123 = load i32, i32* %10
%124 = sext i32 %123 to i64
%125 = mul i64 %124, 4
%126 = trunc i64 %125 to i32
%127 = call i32 @memcpy(i32* %121, i32* %122, i32 %126)
%128 = load i32*, i32** %22
%129 = load i32*, i32** %20
%130 = load i32, i32* %11
%131 = sext i32 %130 to i64
%132 = mul i64 %131, 4
%133 = trunc i64 %132 to i32
%134 = call i32 @memcpy(i32* %128, i32* %129, i32 %133)
br label %135
135: ; preds = %120, %106
br label %102
136: ; preds = %102
%137 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%138 = load i32, i32* %10
%139 = load i32*, i32** %23
%140 = call i32 @save_ivec(i8* %137, i32 %138, i32* %139)
%141 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%142 = load i32, i32* %11
%143 = load i32*, i32** %22
%144 = call i32 @save_ivec(i8* %141, i32 %142, i32* %143)
%145 = load i32*, i32** %23
%146 = call i32 @del_ivec(i32* %145)
%147 = load i32*, i32** %22
%148 = call i32 @del_ivec(i32* %147)
%149 = load i32*, i32** %21
%150 = call i32 @del_ivec(i32* %149)
%151 = load i32*, i32** %20
%152 = call i32 @del_ivec(i32* %151)
%153 = load double**, double*** %19
%154 = call i32 @del_dmat(double** %153)
%155 = load i32, i32* %7
%156 = icmp eq i32 %155, 0
br i1 %156, label %157, label %166
157: ; preds = %136
%158 = call i64 (...) @clock()
store i64 %158, i64* %9
%159 = load i64, i64* %9
%160 = load i64, i64* %8
%161 = sub nsw i64 %159, %160
%162 = sitofp i64 %161 to double
%163 = load double, double* @CLOCKS_PER_SEC
%164 = fdiv double %162, %163
%165 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), double %164)
br label %166
166: ; preds = %157, %136
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Number of processors %d\0A\00"
@.str.1 = [23 x i8] c"Start on processor %d\0A\00"
@.str.2 = [6 x i8] c"input\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [17 x i8] c"%d%d%d%d%d%s%s%s\00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [23 x i8] c"sample count down: %d\0A\00"
@.str.7 = [25 x i8] c"cputime: %16.6e seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca double
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double 1.000000e+00)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double 0.000000e+00)
%14 = tail call i64 (...) @clock()
%15 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%16 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%17 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%18 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%19 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%23 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 (i32*, i8*, ...) @fscanf(i32* %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i8* %20, i8* %21, i8* %22)
%25 = call i32 @fclose(i32* %23)
%26 = load i32, i32* %4
%27 = load i32, i32* %6
%28 = call double** @new_dmat(i32 %26, i32 %27)
%29 = load i32, i32* %4
%30 = call i32* @new_ivec(i32 %29)
%31 = load i32, i32* %3
%32 = call i32* @new_ivec(i32 %31)
%33 = load i32, i32* %4
%34 = call i32* @new_ivec(i32 %33)
%35 = load i32, i32* %3
%36 = call i32* @new_ivec(i32 %35)
%37 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%38 = bitcast double* %11 to i8*
store double 0.000000e+00, double* %11
%39 = load i32, i32* %4
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %50
41: ; preds = %2
%42 = load i32, i32* %5
br label %43
43: ; preds = %41, %57
%44 = phi i32 [ %39, %41 ], [ %58, %57 ]
%45 = phi i32 [ %42, %41 ], [ %59, %57 ]
%46 = phi i64 [ 0, %41 ], [ %60, %57 ]
%47 = icmp sgt i32 %45, 0
br i1 %47, label %48, label %57
48: ; preds = %43
%49 = getelementptr inbounds double*, double** %28, i64 %46
br label %63
50: ; preds = %57, %2
%51 = call i32 @fclose(i32* %37)
%52 = load i32, i32* %7
%53 = add nsw i32 %52, -1
store i32 %53, i32* %7
%54 = icmp eq i32 %52, 0
br i1 %54, label %98, label %78
55: ; preds = %73
%56 = load i32, i32* %4
br label %57
57: ; preds = %55, %43
%58 = phi i32 [ %56, %55 ], [ %44, %43 ]
%59 = phi i32 [ %75, %55 ], [ %45, %43 ]
%60 = add nuw nsw i64 %46, 1
%61 = sext i32 %58 to i64
%62 = icmp slt i64 %60, %61
br i1 %62, label %43, label %50
63: ; preds = %48, %73
%64 = phi i64 [ 0, %48 ], [ %74, %73 ]
%65 = call i32 (i32*, i8*, ...) @fscanf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %11)
%66 = load i32, i32* %6
%67 = sext i32 %66 to i64
%68 = icmp slt i64 %64, %67
br i1 %68, label %69, label %73
69: ; preds = %63
%70 = load double, double* %11
%71 = load double*, double** %49
%72 = getelementptr inbounds double, double* %71, i64 %64
store double %70, double* %72
br label %73
73: ; preds = %63, %69
%74 = add nuw nsw i64 %64, 1
%75 = load i32, i32* %5
%76 = sext i32 %75 to i64
%77 = icmp slt i64 %74, %76
br i1 %77, label %63, label %55
78: ; preds = %50, %94
%79 = phi i32 [ %96, %94 ], [ %53, %50 ]
%80 = sitofp i32 %79 to double
%81 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), double %80)
%82 = load i32, i32* %3
%83 = load i32, i32* %4
%84 = load i32, i32* %6
%85 = call double @kmeans(i32 1, i32 %82, i32 %83, i32 %84, double** %28, i32* %32, i32* %30)
%86 = fcmp olt double %85, 0x4C63E9E4E4C2F344
br i1 %86, label %87, label %94
87: ; preds = %78
%88 = load i32, i32* %3
%89 = shl i32 %88, 2
%90 = call i32 @memcpy(i32* %36, i32* %32, i32 %89)
%91 = load i32, i32* %4
%92 = shl i32 %91, 2
%93 = call i32 @memcpy(i32* %34, i32* %30, i32 %92)
br label %94
94: ; preds = %87, %78
%95 = load i32, i32* %7
%96 = add nsw i32 %95, -1
store i32 %96, i32* %7
%97 = icmp eq i32 %95, 0
br i1 %97, label %98, label %78
98: ; preds = %94, %50
%99 = load i32, i32* %3
%100 = call i32 @save_ivec(i8* %21, i32 %99, i32* %36)
%101 = load i32, i32* %4
%102 = call i32 @save_ivec(i8* %22, i32 %101, i32* %34)
%103 = call i32 @del_ivec(i32* %36)
%104 = call i32 @del_ivec(i32* %34)
%105 = call i32 @del_ivec(i32* %32)
%106 = call i32 @del_ivec(i32* %30)
%107 = call i32 @del_dmat(double** %28)
%108 = call i64 (...) @clock()
%109 = sub nsw i64 %108, %14
%110 = sitofp i64 %109 to double
%111 = load double, double* @CLOCKS_PER_SEC
%112 = fdiv double %110, %111
%113 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), double %112)
ret i32 0
}