// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/src/test_kmeans.c
// Function: main
int main(int argc VL_UNUSED, char ** argv VL_UNUSED)
{
  VlRand rand ;

  vl_size numData = 100000;
  vl_size dimension = 256;
  vl_size numCenters = 400;
  vl_size maxiter = 10;
  vl_size maxComp = 100;
  vl_size maxrep = 1;
  vl_size ntrees = 1;

  double * data;

  vl_size dataIdx, d;

  //VlKMeansAlgorithm algorithm = VlKMeansANN ;
  VlKMeansAlgorithm algorithm = VlKMeansLloyd ;
  //VlKMeansAlgorithm algorithm = VlKMeansElkan ;
  VlVectorComparisonType distance = VlDistanceL2 ;
  VlKMeans * kmeans = vl_kmeans_new (VL_TYPE_DOUBLE,distance) ;

  vl_rand_init (&rand) ;
  vl_rand_seed (&rand,  1000) ;

  data = vl_malloc(sizeof(double) * dimension * numData);

  for(dataIdx = 0; dataIdx < numData; dataIdx++) {
    for(d = 0; d < dimension; d++) {
      double randomNum = (double)vl_rand_real3(&rand)+1;
      data[dataIdx*dimension+d] = randomNum;
    }
  }

  vl_kmeans_set_verbosity	(kmeans,1);
  vl_kmeans_set_max_num_iterations (kmeans, maxiter) ;
  vl_kmeans_set_max_num_comparisons (kmeans, maxComp) ;
  vl_kmeans_set_num_repetitions (kmeans, maxrep) ;
  vl_kmeans_set_num_trees (kmeans, ntrees);
  vl_kmeans_set_algorithm (kmeans, algorithm);

  //struct timeval t1,t2;
  //gettimeofday(&t1, NULL);

  vl_kmeans_cluster(kmeans,data,dimension,numData,numCenters);

  //gettimeofday(&t2, NULL);

  //VL_PRINT("elapsed vlfeat: %f s\n",(double)(t2.tv_sec - t1.tv_sec) + ((double)(t2.tv_usec - t1.tv_usec))/1000000.);

  vl_kmeans_delete(kmeans);
  vl_free(data);

  return 0 ;
}

// Assembly:
subq $0xa48, %rsp            # imm = 0xA48
movl $0x0, 0xa44(%rsp)
movl %edi, 0xa40(%rsp)
movq %rsi, 0xa38(%rsp)
movq $0x186a0, 0x68(%rsp)    # imm = 0x186A0
movq $0x100, 0x60(%rsp)      # imm = 0x100
movq $0x190, 0x58(%rsp)      # imm = 0x190
movq $0xa, 0x50(%rsp)
movq $0x64, 0x48(%rsp)
movq $0x1, 0x40(%rsp)
movq $0x1, 0x38(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x1, 0x18(%rsp)
movl 0x18(%rsp), %esi
movl $0x2, %edi
callq 0x1030
movq %rax, 0x10(%rsp)
leaq 0x74(%rsp), %rdi
callq 0x10a0
leaq 0x74(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1060
movq 0x60(%rsp), %rdi
shlq $0x3, %rdi
imulq 0x68(%rsp), %rdi
callq 0x1090
movq %rax, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x28(%rsp), %rax
cmpq 0x68(%rsp), %rax
jae 0x12ed
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x60(%rsp), %rax
jae 0x12db
leaq 0x74(%rsp), %rdi
callq 0x1390
movsd 0xd67(%rip), %xmm1      # 0x2008
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
imulq 0x60(%rsp), %rcx
addq 0x20(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x1283
jmp 0x12dd
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x126e
movq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x13c0
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x13e0
movq 0x10(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x1400
movq 0x10(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x1420
movq 0x10(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x1440
movq 0x10(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x1460
movq 0x10(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x68(%rsp), %rcx
movq 0x58(%rsp), %r8
callq 0x1070
movq 0x10(%rsp), %rdi
callq 0x1040
movq 0x30(%rsp), %rdi
callq 0x1080
xorl %eax, %eax
addq $0xa48, %rsp            # imm = 0xA48
retq
nopw %cs:(%rax,%rax)