#include <stdio.h>
#include <stdlib.h>

#include <math.h>
#include <iostream>     // std::cout
#include <algorithm>    // std::sort
#include <vector>       // std::vector
#include <time.h>
using namespace std;

#define PINNED 1
#define THREADS 1000

struct Point
{
    float x, y;     // Co-ordinate of point
};

void selectionSort(float *result_prediction_host, float *ref_points_host_val, int n) {
   int i, j, min, temp, temp2;
   for (i = 0; i < n - 1; i++) {
      min = i;
      for (j = i + 1; j < n; j++)
         if (result_prediction_host[j] < result_prediction_host[min])
            min = j;
      temp = result_prediction_host[i];
      temp2 = ref_points_host_val[i];
      result_prediction_host[i] = result_prediction_host[min];
      ref_points_host_val[i] = ref_points_host_val[min];
      result_prediction_host[min] = temp;
      ref_points_host_val[min] = temp2;
   }
}

/**
 * @param arr    refence points
 * @param n      number of reference points
 * @param k      number of points we want to use for the prediction
 * @param p      point we want to predict
 */
int classifyAPoint(Point arr[], float *val, int n, int k, Point p)
{
	float distance[n];
    // Fill distances of all points from p
    for (int i = 0; i < n; i++)
        distance[i] =
            sqrt((arr[i].x - p.x) * (arr[i].x - p.x) +
                 (arr[i].y - p.y) * (arr[i].y - p.y));

    // Sort the Points by distance from p
    selectionSort(distance, val, n);

    // Now consider the first k elements and only
    // two groups
    int freq1 = 0;     // Frequency of group 0
    int freq2 = 0;     // Frequency of group 1
    for (int i = 0; i < k; i++)
    {
        if (val[i] == 0)
            freq1++;
        else if (val[i] == 1)
            freq2++;
    }
	
    printf ("freq1 is %d.\n", freq1);
    printf ("freq2 is %d.\n", freq2);

    return (freq1 > freq2 ? 0 : 1);
}

void InitHostInput(Point arr[], float *val, int n, Point p, float *ref_points_host_x, float *ref_points_host_y, float *ref_points_host_val) {

    for (int i=0; i<n; i++) {
        ref_points_host_x[i] = arr[i].x;
        ref_points_host_y[i] = arr[i].y;
        ref_points_host_val[i] = val[i];
    }

}

void InitHostFreq(unsigned int *freq1_host, unsigned int *freq2_host) {

    freq1_host[0] = 0;
    freq2_host[0] = 0;

}

__global__ void calculateDistance(int n, Point p, float *ref_points_dev_x, float *ref_points_dev_y, float *result_prediction_dev) {

    int i = blockIdx.x * blockDim.x + threadIdx.x;
    // Fill distances of all points from p

        result_prediction_dev[i] =
            sqrt((ref_points_dev_x[i] - p.x) * (ref_points_dev_x[i] - p.x) +
                 (ref_points_dev_y[i] - p.y) * (ref_points_dev_y[i] - p.y));


}

__global__ void calculateFreq(int k, float *ref_points_host_val, unsigned int *freq1_dev, unsigned int *freq2_dev) {

    int i = blockIdx.x * blockDim.x + threadIdx.x;

    if(i < k) {
        if (ref_points_host_val[i] == 0) {
            atomicAdd(&freq1_dev[0], 1);
        }
        else if (ref_points_host_val[i] == 1) {
            atomicAdd(&freq2_dev[0], 1);

        }
    }
}

int classifyAPointCUDA(Point arr[], float *val, int n, int k, Point p)
{
    unsigned int N;
    unsigned int numBytes;
    unsigned int nBlocks, nThreads;

    float TiempoKernelDistance, TiempoSort, TiempoKernelFreq, TiempoAllOperations, TiempoProva;
    cudaEvent_t E0, E1, E2, E3, E4, E5, E6, E7;

    cudaEventCreate(&E0);
    cudaEventCreate(&E1);
    cudaEventCreate(&E2);
    cudaEventCreate(&E3);
    cudaEventCreate(&E4);
    cudaEventCreate(&E5);
    cudaEventCreate(&E6);
    cudaEventCreate(&E7);

    cudaEventRecord(E6, 0);

    float *ref_points_dev_x   = NULL;
    float *ref_points_dev_y   = NULL;
    float *ref_points_dev_val   = NULL;
    float *result_prediction_dev  = NULL;

    float *ref_points_host_x   = NULL;
    float *ref_points_host_y = NULL;
    float *ref_points_host_val   = NULL;
    float *result_prediction_host  = NULL;

    unsigned int *freq1_dev = NULL;
    unsigned int *freq2_dev = NULL;
    unsigned int *freq1_host = NULL;
    unsigned int *freq2_host = NULL;


    // numero de Threads
    nThreads = THREADS;

    // numero de Blocks en cada dimension
    nBlocks = (n+nThreads-1)/nThreads;
    printf("nBlocks = %d \n", nBlocks);

    numBytes = nBlocks * nThreads * sizeof(float);
    printf("numBytes = %d \n", numBytes);

    if (PINNED) {
        // Obtiene Memoria [pinned] en el host
        cudaMallocHost((float**)&ref_points_host_x, numBytes);
        cudaMallocHost((float**)&ref_points_host_y, numBytes);
        cudaMallocHost((float**)&ref_points_host_val, numBytes);
        cudaMallocHost((float**)&result_prediction_host, numBytes);

        cudaMallocHost((unsigned int**)&freq1_host, sizeof(unsigned int));
        cudaMallocHost((unsigned int**)&freq2_host, sizeof(unsigned int));

    } else {
        // Obtener Memoria en el host
        ref_points_host_x = (float*) malloc(numBytes);
        ref_points_host_y = (float*) malloc(numBytes);
        ref_points_host_val = (float*) malloc(numBytes);
        result_prediction_host = (float*) malloc(numBytes);

        freq1_host = (unsigned int*) malloc(sizeof(unsigned int));
        freq2_host = (unsigned int*) malloc(sizeof(unsigned int));
    }

    InitHostInput(arr,val, n, p, ref_points_host_x, ref_points_host_y, ref_points_host_val);

    InitHostFreq(freq1_host, freq2_host);

    // Obtener Memoria en el device
    cudaMalloc((float**)&ref_points_dev_x, numBytes);
    cudaMalloc((float**)&ref_points_dev_y, numBytes);
    cudaMalloc((float**)&ref_points_dev_val, numBytes);
    cudaMalloc((float**)&result_prediction_dev, numBytes);

    cudaMalloc((unsigned int**)&freq1_dev, sizeof(unsigned int));
    cudaMalloc((unsigned int**)&freq2_dev, sizeof(unsigned int));


    // Copiar datos desde el host en el device
    cudaMemcpy(ref_points_dev_x, ref_points_host_x, numBytes, cudaMemcpyHostToDevice);
    cudaMemcpy(ref_points_dev_y, ref_points_host_y, numBytes, cudaMemcpyHostToDevice);
    cudaMemcpy(ref_points_dev_val, ref_points_host_val, numBytes, cudaMemcpyHostToDevice);
    cudaMemcpy(result_prediction_dev, result_prediction_host,numBytes, cudaMemcpyHostToDevice);

    cudaMemcpy(freq1_dev, freq1_host, sizeof(unsigned int), cudaMemcpyHostToDevice);
    cudaMemcpy(freq2_dev, freq2_host, sizeof(unsigned int), cudaMemcpyHostToDevice);

    nBlocks = nBlocks-1;


    cudaEventRecord(E0, 0);

    // Ejecutar el kernel
    calculateDistance<<<nBlocks, nThreads>>>(n, p, ref_points_dev_x, ref_points_dev_y, result_prediction_dev);

    cudaEventRecord(E1, 0); cudaEventSynchronize(E1);
    cudaEventElapsedTime(&TiempoKernelDistance,  E0, E1);

    // Obtener el resultado desde el host
    cudaMemcpy(result_prediction_host, result_prediction_dev, numBytes, cudaMemcpyDeviceToHost);

    // Liberar Memoria del device
    cudaFree(ref_points_dev_x);
    cudaFree(ref_points_dev_y);
    cudaFree(result_prediction_dev);

    cudaEventRecord(E4, 0);
    
    // Sort the Points by distance from p
    selectionSort(result_prediction_host, ref_points_host_val, n);

    cudaEventRecord(E5, 0); cudaEventSynchronize(E5);
    cudaEventElapsedTime(&TiempoSort,  E4, E5);

    cudaEventRecord(E2, 0);
    // Ejecutar el kernel
    calculateFreq<<<k, 1>>>(k, ref_points_dev_val, freq1_dev, freq2_dev);

    cudaEventRecord(E3, 0); cudaEventSynchronize(E3);
    cudaEventElapsedTime(&TiempoKernelFreq,  E2, E3);

    TiempoAllOperations = TiempoKernelDistance + TiempoSort + TiempoKernelFreq;

    cudaMemcpy(freq1_host, freq1_dev, sizeof(unsigned int), cudaMemcpyDeviceToHost);
    cudaMemcpy(freq2_host, freq2_dev, sizeof(unsigned int), cudaMemcpyDeviceToHost);

    cudaFree(ref_points_dev_val);
    cudaFree(freq1_dev);
    cudaFree(freq2_dev);

    int result = -1;
    if(freq1_host[0] > freq2_host[0]) result = 0;
    else result = 1;

    printf ("freq1 is %d.\n", freq1_host[0]);
    printf ("freq2 is %d.\n", freq2_host[0]);

    printf ("The value classified to unknown point"
            " is %d.\n", result);


    printf("Invocació Kernel <<<nBlocks, nKernels>>> (N): <<<%d, %d>>> (%d)\n", nBlocks, nThreads, n);

    printf("Tiempo Kernel calculo distancia (00): %4.6f milseg\n", TiempoKernelDistance);
    printf("Tiempo Kernel calculo freq (00): %4.6f milseg\n", TiempoKernelFreq);
    printf("Tiempo Sort (00): %4.6f milseg\n", TiempoSort);
    printf("Tiempo todas las operaciones (00): %4.6f milseg\n", TiempoAllOperations);

    if (PINNED) printf("Usando Pinned Memory\n");
    else printf("NO usa Pinned Memory\n");

    if (PINNED) {
        cudaFreeHost(ref_points_host_x); cudaFreeHost(ref_points_host_y); cudaFreeHost(ref_points_host_val);cudaFreeHost(result_prediction_host); cudaFreeHost(freq1_host); cudaFreeHost(freq2_host);
    } else {
        free(ref_points_host_x); free(ref_points_host_y); free(ref_points_host_val); free(result_prediction_host); free(freq1_host); free(freq2_host);
    }

    cudaEventRecord(E7, 0); cudaEventSynchronize(E7);
    cudaEventElapsedTime(&TiempoProva,  E6, E7);

    printf("Temps total CUDA: %4.6f milseg\n", TiempoProva);

    return result;
}

void InitKDefecte(int *k) {

    // Parameter to decide group of the testing point
    (*k) = 15;

}

void InitTestPointDefecte(struct Point *p) {

    //Test Point
    p->x = 2.5;
    p->y = 7;

}

void InitDefecte(int *k, struct Point *p) {
    InitKDefecte(k);
    InitTestPointDefecte(p);
}

int main(int argc, char** argv)
{
    srand(time(0));

    //Es declaren les variables
    int n, k;
    struct Point p;

    //S'inicialitza la K, i les coordenades del Testing point
    if (argc == 1)      { InitDefecte(&k, &p); }
    else if (argc == 2) { k = atoi(argv[1]); InitTestPointDefecte(&p); }
    else if (argc == 4) { k = atoi(argv[1]); p.x = atof(argv[2]); p.y = atof(argv[3]);}
    else { printf("Usage: ./exe k TestPointCoordenadaX TestPointCoordenadaY\n"); exit(0); }

    //Es crea l'estructura sobre la qual es vol fer la predicció
    n = 10000; // Number of data points
    Point arr[n];
	
	float val[n];
	float val_cuda[n];

    for(int i = 0; i < n; ++i) {
        arr[i].x = rand() % 100;
        arr[i].y = rand() % 100;
        val[i] = rand() % 2;
	val_cuda[i] = val[i];
    }

    printf("k = %d \n", k);

    printf("The Testing Point values are:");
    printf(" x = %f", p.x);
    printf(" and");
    printf(" y = %f", p.y);
    printf("\n");

    printf("\n");
    printf("Programa Seqüencial -------------------------------------------------- \n");
    printf("\n");

    // Calculate the time taken by the sequential code: classifyAPoint function
    clock_t t;
    t = clock();
    int result = classifyAPoint(arr,val, n, k, p);
    t = clock() - t;
    float time_taken = ((float)t)/(CLOCKS_PER_SEC/1000); // in mseconds

    printf ("The value classified to unknown point"
            " is %d.\n", result);

    printf ("Temps total seqüencial:"
            " %lf milseg.\n", time_taken);

    printf("\n");
    printf("Programa CUDA -------------------------------------------------------- \n");
    printf("\n");

    int result2 = classifyAPointCUDA(arr,val_cuda, n, k, p);
    
	printf ("The value classified to unknown point"
            " is %d.\n", result2);
}

	.file	"tmpxft_00334e60_00000000-6_knn02.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4263:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4263:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z13selectionSortPfS_i
	.type	_Z13selectionSortPfS_i, @function
_Z13selectionSortPfS_i:
.LFB4252:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rcx
	movl	%edx, %r8d
	xorl	%eax, %eax
	leal	-1(%rdx), %ebx
.L3:
	movl	%eax, %r9d
	cmpl	%eax, %ebx
	jle	.L12
	leaq	1(%rax), %r10
	movq	%r10, %rdi
.L4:
	movslq	%r9d, %rdx
	salq	$2, %rdx
	leaq	(%rcx,%rdx), %r11
	movss	(%r11), %xmm0
	cmpl	%edi, %r8d
	jle	.L13
	ucomiss	(%rcx,%rdi,4), %xmm0
	cmova	%edi, %r9d
	incq	%rdi
	jmp	.L4
.L13:
	cvttss2sil	(%rcx,%rax,4), %r9d
	addq	%rsi, %rdx
	cvttss2sil	(%rsi,%rax,4), %edi
	movss	%xmm0, (%rcx,%rax,4)
	movss	(%rdx), %xmm0
	movss	%xmm0, (%rsi,%rax,4)
	movq	%r10, %rax
	cvtsi2ssl	%r9d, %xmm0
	movss	%xmm0, (%r11)
	cvtsi2ssl	%edi, %xmm0
	movss	%xmm0, (%rdx)
	jmp	.L3
.L12:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4252:
	.size	_Z13selectionSortPfS_i, .-_Z13selectionSortPfS_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"freq1 is %d.\n"
.LC3:
	.string	"freq2 is %d.\n"
	.text
	.globl	_Z14classifyAPointP5PointPfiiS_
	.type	_Z14classifyAPointP5PointPfiiS_, @function
_Z14classifyAPointP5PointPfiiS_:
.LFB4253:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%xmm0, %rax
	shrq	$32, %rax
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	movl	%edx, %r15d
	pushq	%r14
	pushq	%r13
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	movl	%ecx, %r13d
	pushq	%r12
	.cfi_offset 12, -48
	movq	%rsi, %r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 3, -56
	movq	%fs:40, %rdx
	movq	%rdx, -56(%rbp)
	xorl	%edx, %edx
	movl	%eax, -72(%rbp)
	movslq	%r15d, %rax
	movq	%rsp, %rcx
	leaq	15(,%rax,4), %rdx
	movd	%xmm0, -68(%rbp)
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L15:
	cmpq	%rcx, %rsp
	je	.L16
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L15
.L16:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L17
	orq	$0, -8(%rsp,%rax)
.L17:
	movq	%rsp, %r14
	xorl	%ebx, %ebx
.L18:
	cmpl	%ebx, %r15d
	jle	.L33
	movss	(%rdi,%rbx,8), %xmm0
	movss	4(%rdi,%rbx,8), %xmm1
	movq	%rdi, -80(%rbp)
	subss	-68(%rbp), %xmm0
	subss	-72(%rbp), %xmm1
	mulss	%xmm0, %xmm0
	mulss	%xmm1, %xmm1
	addss	%xmm1, %xmm0
	call	sqrtf@PLT
	movq	-80(%rbp), %rdi
	movss	%xmm0, (%r14,%rbx,4)
	incq	%rbx
	jmp	.L18
.L33:
	movq	%r14, %rdi
	movl	%r15d, %edx
	movq	%r12, %rsi
	xorl	%ebx, %ebx
	call	_Z13selectionSortPfS_i
	xorl	%r14d, %r14d
	xorl	%eax, %eax
	xorps	%xmm1, %xmm1
	movss	.LC1(%rip), %xmm2
.L20:
	cmpl	%eax, %r13d
	jle	.L34
	movss	(%r12,%rax,4), %xmm0
	ucomiss	%xmm1, %xmm0
	jp	.L21
	jne	.L21
	incl	%r14d
	jmp	.L23
.L21:
	ucomiss	%xmm2, %xmm0
	jp	.L23
	jne	.L23
	incl	%ebx
.L23:
	incq	%rax
	jmp	.L20
.L34:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movl	%ebx, %edx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	xorl	%eax, %eax
	cmpl	%ebx, %r14d
	setle	%al
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4253:
	.size	_Z14classifyAPointP5PointPfiiS_, .-_Z14classifyAPointP5PointPfiiS_
	.globl	_Z13InitHostInputP5PointPfiS_S1_S1_S1_
	.type	_Z13InitHostInputP5PointPfiS_S1_S1_S1_, @function
_Z13InitHostInputP5PointPfiS_S1_S1_S1_:
.LFB4254:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L36:
	cmpl	%eax, %edx
	jle	.L38
	movss	(%rdi,%rax,8), %xmm0
	movss	%xmm0, (%rcx,%rax,4)
	movss	4(%rdi,%rax,8), %xmm0
	movss	%xmm0, (%r8,%rax,4)
	movss	(%rsi,%rax,4), %xmm0
	movss	%xmm0, (%r9,%rax,4)
	incq	%rax
	jmp	.L36
.L38:
	ret
	.cfi_endproc
.LFE4254:
	.size	_Z13InitHostInputP5PointPfiS_S1_S1_S1_, .-_Z13InitHostInputP5PointPfiS_S1_S1_S1_
	.globl	_Z12InitHostFreqPjS_
	.type	_Z12InitHostFreqPjS_, @function
_Z12InitHostFreqPjS_:
.LFB4255:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	movl	%eax, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE4255:
	.size	_Z12InitHostFreqPjS_, .-_Z12InitHostFreqPjS_
	.globl	_Z12InitKDefectePi
	.type	_Z12InitKDefectePi, @function
_Z12InitKDefectePi:
.LFB4257:
	.cfi_startproc
	endbr64
	movl	$15, (%rdi)
	ret
	.cfi_endproc
.LFE4257:
	.size	_Z12InitKDefectePi, .-_Z12InitKDefectePi
	.globl	_Z20InitTestPointDefecteP5Point
	.type	_Z20InitTestPointDefecteP5Point, @function
_Z20InitTestPointDefecteP5Point:
.LFB4258:
	.cfi_startproc
	endbr64
	movabsq	$4674736414286413824, %rax
	movq	%rax, (%rdi)
	ret
	.cfi_endproc
.LFE4258:
	.size	_Z20InitTestPointDefecteP5Point, .-_Z20InitTestPointDefecteP5Point
	.globl	_Z11InitDefectePiP5Point
	.type	_Z11InitDefectePiP5Point, @function
_Z11InitDefectePiP5Point:
.LFB4259:
	.cfi_startproc
	endbr64
	movabsq	$4674736414286413824, %rax
	movl	$15, (%rdi)
	movq	%rax, (%rsi)
	ret
	.cfi_endproc
.LFE4259:
	.size	_Z11InitDefectePiP5Point, .-_Z11InitDefectePiP5Point
	.globl	_Z50__device_stub__Z17calculateDistancei5PointPfS0_S0_iR5PointPfS1_S1_
	.type	_Z50__device_stub__Z17calculateDistancei5PointPfS0_S0_iR5PointPfS1_S1_, @function
_Z50__device_stub__Z17calculateDistancei5PointPfS0_S0_iR5PointPfS1_S1_:
.LFB4285:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rdx, 16(%rsp)
	leaq	32(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movq	%rsi, 104(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movl	$1, 56(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L43
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z17calculateDistancei5PointPfS0_S0_(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L43:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L45
	call	__stack_chk_fail@PLT
.L45:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4285:
	.size	_Z50__device_stub__Z17calculateDistancei5PointPfS0_S0_iR5PointPfS1_S1_, .-_Z50__device_stub__Z17calculateDistancei5PointPfS0_S0_iR5PointPfS1_S1_
	.globl	_Z17calculateDistancei5PointPfS0_S0_
	.type	_Z17calculateDistancei5PointPfS0_S0_, @function
_Z17calculateDistancei5PointPfS0_S0_:
.LFB4286:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%rcx, %r8
	movq	%rdx, %rcx
	movq	%rsi, %rdx
	leaq	8(%rsp), %rax
	movq	%xmm0, 8(%rsp)
	movq	%rax, %rsi
	call	_Z50__device_stub__Z17calculateDistancei5PointPfS0_S0_iR5PointPfS1_S1_
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4286:
	.size	_Z17calculateDistancei5PointPfS0_S0_, .-_Z17calculateDistancei5PointPfS0_S0_
	.globl	_Z39__device_stub__Z13calculateFreqiPfPjS0_iPfPjS0_
	.type	_Z39__device_stub__Z13calculateFreqiPfPjS0_iPfPjS0_, @function
_Z39__device_stub__Z13calculateFreqiPfPjS0_iPfPjS0_:
.LFB4287:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L49
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z13calculateFreqiPfPjS0_(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L49:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L51
	call	__stack_chk_fail@PLT
.L51:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4287:
	.size	_Z39__device_stub__Z13calculateFreqiPfPjS0_iPfPjS0_, .-_Z39__device_stub__Z13calculateFreqiPfPjS0_iPfPjS0_
	.globl	_Z13calculateFreqiPfPjS0_
	.type	_Z13calculateFreqiPfPjS0_, @function
_Z13calculateFreqiPfPjS0_:
.LFB4288:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z13calculateFreqiPfPjS0_iPfPjS0_
	.cfi_endproc
.LFE4288:
	.size	_Z13calculateFreqiPfPjS0_, .-_Z13calculateFreqiPfPjS0_
	.section	.rodata.str1.1
.LC4:
	.string	"nBlocks = %d \n"
.LC5:
	.string	"numBytes = %d \n"
.LC6:
	.string	"The value classified to unknown point is %d.\n"
.LC7:
	.string	"Invocaci\303\263 Kernel <<<nBlocks, nKernels>>> (N): <<<%d, %d>>> (%d)\n"
.LC8:
	.string	"Tiempo Kernel calculo distancia (00): %4.6f milseg\n"
.LC9:
	.string	"Tiempo Kernel calculo freq (00): %4.6f milseg\n"
.LC10:
	.string	"Tiempo Sort (00): %4.6f milseg\n"
.LC11:
	.string	"Tiempo todas las operaciones (00): %4.6f milseg\n"
.LC12:
	.string	"Usando Pinned Memory\n"
.LC13:
	.string	"Temps total CUDA: %4.6f milseg\n"
	.text
	.globl	_Z18classifyAPointCUDAP5PointPfiiS_
	.type	_Z18classifyAPointCUDAP5PointPfiiS_, @function
_Z18classifyAPointCUDAP5PointPfiiS_:
.LFB4256:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%ecx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$232, %rsp
	.cfi_def_cfa_offset 288
	movq	%xmm0, 8(%rsp)
	leaq	24(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 216(%rsp)
	xorl	%eax, %eax
	call	cudaEventCreate@PLT
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	64(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	72(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	80(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	xorl	%eax, %eax
	movl	$1000, %ecx
	xorl	%edx, %edx
	movq	%rax, 88(%rsp)
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movq	%rax, 96(%rsp)
	movq	%rax, 104(%rsp)
	movq	%rax, 112(%rsp)
	movq	%rax, 120(%rsp)
	movq	%rax, 128(%rsp)
	movq	%rax, 136(%rsp)
	movq	%rax, 144(%rsp)
	movq	%rax, 152(%rsp)
	movq	%rax, 160(%rsp)
	movq	%rax, 168(%rsp)
	movq	%rax, 176(%rsp)
	leal	999(%rbp), %eax
	divl	%ecx
	movl	%eax, %ebx
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	imull	$4000, %ebx, %r15d
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	movl	%r15d, %edx
	call	__printf_chk@PLT
	xorl	%edx, %edx
	leaq	120(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaHostAlloc@PLT
	xorl	%edx, %edx
	leaq	128(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaHostAlloc@PLT
	xorl	%edx, %edx
	leaq	136(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaHostAlloc@PLT
	xorl	%edx, %edx
	leaq	144(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaHostAlloc@PLT
	xorl	%edx, %edx
	movl	$4, %esi
	leaq	168(%rsp), %rdi
	call	cudaHostAlloc@PLT
	xorl	%edx, %edx
	movl	$4, %esi
	leaq	176(%rsp), %rdi
	call	cudaHostAlloc@PLT
	movq	120(%rsp), %rcx
	movq	%r13, %rdi
	movl	%ebp, %edx
	movq	136(%rsp), %r9
	movq	128(%rsp), %r8
	movq	%r14, %rsi
	leaq	184(%rsp), %r13
	movq	8(%rsp), %xmm0
	call	_Z13InitHostInputP5PointPfiS_S1_S1_S1_
	xorl	%ecx, %ecx
	leaq	88(%rsp), %rdi
	movq	%r15, %rsi
	movq	168(%rsp), %rdx
	movq	176(%rsp), %rax
	decl	%ebx
	movl	%ecx, (%rdx)
	movl	%ecx, (%rax)
	call	cudaMalloc@PLT
	leaq	96(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	leaq	104(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	leaq	112(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	leaq	152(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	leaq	160(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movq	120(%rsp), %rsi
	movq	88(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	128(%rsp), %rsi
	movq	96(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	136(%rsp), %rsi
	movq	104(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	144(%rsp), %rsi
	movq	112(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$4, %edx
	movq	168(%rsp), %rsi
	movq	152(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$4, %edx
	movq	176(%rsp), %rsi
	movq	160(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$536871037, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%ebx, 192(%rsp)
	salq	$3, %rdx
	movl	$1, %ecx
	movabsq	$4294967297, %rax
	movq	%rax, 196(%rsp)
	movq	192(%rsp), %rdi
	movl	200(%rsp), %esi
	movq	%rdx, 204(%rsp)
	movl	$1, 212(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L55
	movq	8(%rsp), %rax
	movq	112(%rsp), %r8
	movq	%r13, %rsi
	movl	%ebp, %edi
	movq	96(%rsp), %rcx
	movq	88(%rsp), %rdx
	movq	%rax, 184(%rsp)
	call	_Z50__device_stub__Z17calculateDistancei5PointPfS0_S0_iR5PointPfS1_S1_
.L55:
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	leaq	20(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	112(%rsp), %rsi
	movl	$2, %ecx
	movq	%r15, %rdx
	movq	144(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	96(%rsp), %rdi
	call	cudaFree@PLT
	movq	112(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	136(%rsp), %rsi
	movq	144(%rsp), %rdi
	movl	%ebp, %edx
	call	_Z13selectionSortPfS_i
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	64(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rsi
	movq	%r13, %rdi
	call	cudaEventElapsedTime@PLT
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$4294967297, %rdx
	movl	%r12d, 192(%rsp)
	movq	%rdx, 196(%rsp)
	movq	192(%rsp), %rdi
	movl	200(%rsp), %esi
	movq	%rdx, 204(%rsp)
	movl	$1, 212(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L56
	movq	160(%rsp), %rcx
	movq	152(%rsp), %rdx
	movl	%r12d, %edi
	movq	104(%rsp), %rsi
	call	_Z39__device_stub__Z13calculateFreqiPfPjS0_iPfPjS0_
.L56:
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	xorl	%r13d, %r13d
	call	cudaEventRecord@PLT
	movq	48(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	leaq	192(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movss	20(%rsp), %xmm0
	movl	$2, %ecx
	addss	184(%rsp), %xmm0
	addss	192(%rsp), %xmm0
	movq	152(%rsp), %rsi
	movl	$4, %edx
	movq	168(%rsp), %rdi
	movd	%xmm0, %r12d
	call	cudaMemcpy@PLT
	movl	$2, %ecx
	movl	$4, %edx
	movq	160(%rsp), %rsi
	movq	176(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	104(%rsp), %rdi
	call	cudaFree@PLT
	movq	152(%rsp), %rdi
	call	cudaFree@PLT
	movq	160(%rsp), %rdi
	call	cudaFree@PLT
	movq	168(%rsp), %rax
	movl	$2, %edi
	leaq	.LC2(%rip), %rsi
	movl	(%rax), %edx
	movq	176(%rsp), %rax
	cmpl	%edx, (%rax)
	setnb	%r13b
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	176(%rsp), %rax
	movl	$2, %edi
	leaq	.LC3(%rip), %rsi
	movl	(%rax), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%r13d, %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC6(%rip), %rsi
	call	__printf_chk@PLT
	movl	%ebp, %r8d
	movl	$1000, %ecx
	movl	%ebx, %edx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	20(%rsp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	192(%rsp), %xmm0
	leaq	.LC9(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	184(%rsp), %xmm0
	call	__printf_chk@PLT
	movb	$1, %al
	movd	%r12d, %xmm1
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	cvtss2sd	%xmm1, %xmm0
	call	__printf_chk@PLT
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	120(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	128(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	136(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	144(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	168(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	176(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	72(%rsp), %rsi
	movq	80(%rsp), %rdx
	leaq	204(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	204(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	216(%rsp), %rax
	subq	%fs:40, %rax
	je	.L57
	call	__stack_chk_fail@PLT
.L57:
	addq	$232, %rsp
	.cfi_def_cfa_offset 56
	movl	%r13d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4256:
	.size	_Z18classifyAPointCUDAP5PointPfiiS_, .-_Z18classifyAPointCUDAP5PointPfiiS_
	.section	.rodata.str1.1
.LC16:
	.string	"Usage: ./exe k TestPointCoordenadaX TestPointCoordenadaY\n"
.LC17:
	.string	"k = %d \n"
.LC18:
	.string	"The Testing Point values are:"
.LC19:
	.string	" x = %f"
.LC20:
	.string	" and"
.LC21:
	.string	" y = %f"
.LC22:
	.string	"\n"
.LC23:
	.string	"Programa Seq\303\274encial -------------------------------------------------- \n"
.LC25:
	.string	"Temps total seq\303\274encial: %lf milseg.\n"
.LC26:
	.string	"Programa CUDA -------------------------------------------------------- \n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB4260:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	movq	%rsi, %r12
	pushq	%rbx
	.cfi_offset 3, -56
	movl	%edi, %ebx
	xorl	%edi, %edi
	subq	$56, %rsp
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	cmpl	$1, %ebx
	je	.L74
	cmpl	$2, %ebx
	jne	.L61
	movq	8(%r12), %rdi
	call	atoi@PLT
	movss	.LC14(%rip), %xmm1
	movss	.LC15(%rip), %xmm2
	movl	%eax, %ebx
	movss	%xmm1, -76(%rbp)
	movss	%xmm2, -72(%rbp)
	jmp	.L60
.L61:
	cmpl	$4, %ebx
	jne	.L62
	movq	8(%r12), %rdi
	call	atoi@PLT
	movq	16(%r12), %rdi
	movl	%eax, %ebx
	call	atof@PLT
	movq	24(%r12), %rdi
	cvtsd2ss	%xmm0, %xmm3
	movss	%xmm3, -72(%rbp)
	call	atof@PLT
	cvtsd2ss	%xmm0, %xmm4
	movss	%xmm4, -76(%rbp)
	jmp	.L60
.L62:
	movl	$2, %edi
	leaq	.LC16(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L74:
	movss	.LC14(%rip), %xmm5
	movss	.LC15(%rip), %xmm6
	movl	$15, %ebx
	movss	%xmm5, -76(%rbp)
	movss	%xmm6, -72(%rbp)
.L60:
	leaq	-77824(%rsp), %rax
.L63:
	cmpq	%rax, %rsp
	je	.L64
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L63
.L64:
	subq	$2176, %rsp
	orq	$0, 2168(%rsp)
	movq	%rsp, %r13
	leaq	-36864(%rsp), %rax
.L66:
	cmpq	%rax, %rsp
	je	.L67
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L66
.L67:
	subq	$3136, %rsp
	orq	$0, 3128(%rsp)
	movq	%rsp, -88(%rbp)
	leaq	-36864(%rsp), %rax
.L69:
	cmpq	%rax, %rsp
	je	.L70
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L69
.L70:
	subq	$3136, %rsp
	orq	$0, 3128(%rsp)
	xorl	%r14d, %r14d
	movl	$100, %r12d
	movq	%rsp, %r15
.L72:
	call	rand@PLT
	cltd
	idivl	%r12d
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, 0(%r13,%r14,2)
	call	rand@PLT
	cltd
	idivl	%r12d
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, 4(%r13,%r14,2)
	call	rand@PLT
	movl	$2, %esi
	cltd
	idivl	%esi
	movq	-88(%rbp), %rax
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%rax,%r14)
	movss	%xmm0, (%r15,%r14)
	addq	$4, %r14
	cmpq	$40000, %r14
	jne	.L72
	movl	%ebx, %edx
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	-72(%rbp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC20(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC21(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	-76(%rbp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC22(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movss	-72(%rbp), %xmm0
	movq	-88(%rbp), %rsi
	movl	%ebx, %ecx
	movq	%rax, %r12
	movl	-76(%rbp), %eax
	movq	%r13, %rdi
	movd	%xmm0, %edx
	salq	$32, %rax
	orq	%rax, %rdx
	movq	%rdx, %xmm0
	movq	%rdx, -72(%rbp)
	movl	$10000, %edx
	call	_Z14classifyAPointP5PointPfiiS_
	movl	%eax, %r14d
	call	clock@PLT
	movl	%r14d, %edx
	leaq	.LC6(%rip), %r14
	movl	$2, %edi
	subq	%r12, %rax
	movq	%r14, %rsi
	cvtsi2ssq	%rax, %xmm0
	xorl	%eax, %eax
	divss	.LC24(%rip), %xmm0
	movss	%xmm0, -76(%rbp)
	call	__printf_chk@PLT
	movss	-76(%rbp), %xmm0
	leaq	.LC25(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC22(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-72(%rbp), %xmm0
	movq	%r15, %rsi
	movl	%ebx, %ecx
	movl	$10000, %edx
	movq	%r13, %rdi
	call	_Z18classifyAPointCUDAP5PointPfiiS_
	movq	%r14, %rsi
	movl	$2, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L73
	call	__stack_chk_fail@PLT
.L73:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4260:
	.size	main, .-main
	.section	.rodata.str1.1
.LC27:
	.string	"_Z13calculateFreqiPfPjS0_"
.LC28:
	.string	"_Z17calculateDistancei5PointPfS0_S0_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4290:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC27(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z13calculateFreqiPfPjS0_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC28(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z17calculateDistancei5PointPfS0_S0_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE4290:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1065353216
	.align 4
.LC14:
	.long	1088421888
	.align 4
.LC15:
	.long	1075838976
	.align 4
.LC24:
	.long	1148846080
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>

#include <math.h>
#include <iostream>     // std::cout
#include <algorithm>    // std::sort
#include <vector>       // std::vector
#include <time.h>
using namespace std;

#define PINNED 1
#define THREADS 1000

struct Point
{
    float x, y;     // Co-ordinate of point
};

void selectionSort(float *result_prediction_host, float *ref_points_host_val, int n) {
   int i, j, min, temp, temp2;
   for (i = 0; i < n - 1; i++) {
      min = i;
      for (j = i + 1; j < n; j++)
         if (result_prediction_host[j] < result_prediction_host[min])
            min = j;
      temp = result_prediction_host[i];
      temp2 = ref_points_host_val[i];
      result_prediction_host[i] = result_prediction_host[min];
      ref_points_host_val[i] = ref_points_host_val[min];
      result_prediction_host[min] = temp;
      ref_points_host_val[min] = temp2;
   }
}

/**
 * @param arr    refence points
 * @param n      number of reference points
 * @param k      number of points we want to use for the prediction
 * @param p      point we want to predict
 */
int classifyAPoint(Point arr[], float *val, int n, int k, Point p)
{
	float distance[n];
    // Fill distances of all points from p
    for (int i = 0; i < n; i++)
        distance[i] =
            sqrt((arr[i].x - p.x) * (arr[i].x - p.x) +
                 (arr[i].y - p.y) * (arr[i].y - p.y));

    // Sort the Points by distance from p
    selectionSort(distance, val, n);

    // Now consider the first k elements and only
    // two groups
    int freq1 = 0;     // Frequency of group 0
    int freq2 = 0;     // Frequency of group 1
    for (int i = 0; i < k; i++)
    {
        if (val[i] == 0)
            freq1++;
        else if (val[i] == 1)
            freq2++;
    }
	
    printf ("freq1 is %d.\n", freq1);
    printf ("freq2 is %d.\n", freq2);

    return (freq1 > freq2 ? 0 : 1);
}

void InitHostInput(Point arr[], float *val, int n, Point p, float *ref_points_host_x, float *ref_points_host_y, float *ref_points_host_val) {

    for (int i=0; i<n; i++) {
        ref_points_host_x[i] = arr[i].x;
        ref_points_host_y[i] = arr[i].y;
        ref_points_host_val[i] = val[i];
    }

}

void InitHostFreq(unsigned int *freq1_host, unsigned int *freq2_host) {

    freq1_host[0] = 0;
    freq2_host[0] = 0;

}

__global__ void calculateDistance(int n, Point p, float *ref_points_dev_x, float *ref_points_dev_y, float *result_prediction_dev) {

    int i = blockIdx.x * blockDim.x + threadIdx.x;
    // Fill distances of all points from p

        result_prediction_dev[i] =
            sqrt((ref_points_dev_x[i] - p.x) * (ref_points_dev_x[i] - p.x) +
                 (ref_points_dev_y[i] - p.y) * (ref_points_dev_y[i] - p.y));


}

__global__ void calculateFreq(int k, float *ref_points_host_val, unsigned int *freq1_dev, unsigned int *freq2_dev) {

    int i = blockIdx.x * blockDim.x + threadIdx.x;

    if(i < k) {
        if (ref_points_host_val[i] == 0) {
            atomicAdd(&freq1_dev[0], 1);
        }
        else if (ref_points_host_val[i] == 1) {
            atomicAdd(&freq2_dev[0], 1);

        }
    }
}

int classifyAPointCUDA(Point arr[], float *val, int n, int k, Point p)
{
    unsigned int N;
    unsigned int numBytes;
    unsigned int nBlocks, nThreads;

    float TiempoKernelDistance, TiempoSort, TiempoKernelFreq, TiempoAllOperations, TiempoProva;
    hipEvent_t E0, E1, E2, E3, E4, E5, E6, E7;

    hipEventCreate(&E0);
    hipEventCreate(&E1);
    hipEventCreate(&E2);
    hipEventCreate(&E3);
    hipEventCreate(&E4);
    hipEventCreate(&E5);
    hipEventCreate(&E6);
    hipEventCreate(&E7);

    hipEventRecord(E6, 0);

    float *ref_points_dev_x   = NULL;
    float *ref_points_dev_y   = NULL;
    float *ref_points_dev_val   = NULL;
    float *result_prediction_dev  = NULL;

    float *ref_points_host_x   = NULL;
    float *ref_points_host_y = NULL;
    float *ref_points_host_val   = NULL;
    float *result_prediction_host  = NULL;

    unsigned int *freq1_dev = NULL;
    unsigned int *freq2_dev = NULL;
    unsigned int *freq1_host = NULL;
    unsigned int *freq2_host = NULL;


    // numero de Threads
    nThreads = THREADS;

    // numero de Blocks en cada dimension
    nBlocks = (n+nThreads-1)/nThreads;
    printf("nBlocks = %d \n", nBlocks);

    numBytes = nBlocks * nThreads * sizeof(float);
    printf("numBytes = %d \n", numBytes);

    if (PINNED) {
        // Obtiene Memoria [pinned] en el host
        hipHostMalloc((float**)&ref_points_host_x, numBytes, hipHostMallocDefault);
        hipHostMalloc((float**)&ref_points_host_y, numBytes, hipHostMallocDefault);
        hipHostMalloc((float**)&ref_points_host_val, numBytes, hipHostMallocDefault);
        hipHostMalloc((float**)&result_prediction_host, numBytes, hipHostMallocDefault);

        hipHostMalloc((unsigned int**)&freq1_host, sizeof(unsigned int), hipHostMallocDefault);
        hipHostMalloc((unsigned int**)&freq2_host, sizeof(unsigned int), hipHostMallocDefault);

    } else {
        // Obtener Memoria en el host
        ref_points_host_x = (float*) malloc(numBytes);
        ref_points_host_y = (float*) malloc(numBytes);
        ref_points_host_val = (float*) malloc(numBytes);
        result_prediction_host = (float*) malloc(numBytes);

        freq1_host = (unsigned int*) malloc(sizeof(unsigned int));
        freq2_host = (unsigned int*) malloc(sizeof(unsigned int));
    }

    InitHostInput(arr,val, n, p, ref_points_host_x, ref_points_host_y, ref_points_host_val);

    InitHostFreq(freq1_host, freq2_host);

    // Obtener Memoria en el device
    hipMalloc((float**)&ref_points_dev_x, numBytes);
    hipMalloc((float**)&ref_points_dev_y, numBytes);
    hipMalloc((float**)&ref_points_dev_val, numBytes);
    hipMalloc((float**)&result_prediction_dev, numBytes);

    hipMalloc((unsigned int**)&freq1_dev, sizeof(unsigned int));
    hipMalloc((unsigned int**)&freq2_dev, sizeof(unsigned int));


    // Copiar datos desde el host en el device
    hipMemcpy(ref_points_dev_x, ref_points_host_x, numBytes, hipMemcpyHostToDevice);
    hipMemcpy(ref_points_dev_y, ref_points_host_y, numBytes, hipMemcpyHostToDevice);
    hipMemcpy(ref_points_dev_val, ref_points_host_val, numBytes, hipMemcpyHostToDevice);
    hipMemcpy(result_prediction_dev, result_prediction_host,numBytes, hipMemcpyHostToDevice);

    hipMemcpy(freq1_dev, freq1_host, sizeof(unsigned int), hipMemcpyHostToDevice);
    hipMemcpy(freq2_dev, freq2_host, sizeof(unsigned int), hipMemcpyHostToDevice);

    nBlocks = nBlocks-1;


    hipEventRecord(E0, 0);

    // Ejecutar el kernel
    calculateDistance<<<nBlocks, nThreads>>>(n, p, ref_points_dev_x, ref_points_dev_y, result_prediction_dev);

    hipEventRecord(E1, 0); hipEventSynchronize(E1);
    hipEventElapsedTime(&TiempoKernelDistance,  E0, E1);

    // Obtener el resultado desde el host
    hipMemcpy(result_prediction_host, result_prediction_dev, numBytes, hipMemcpyDeviceToHost);

    // Liberar Memoria del device
    hipFree(ref_points_dev_x);
    hipFree(ref_points_dev_y);
    hipFree(result_prediction_dev);

    hipEventRecord(E4, 0);
    
    // Sort the Points by distance from p
    selectionSort(result_prediction_host, ref_points_host_val, n);

    hipEventRecord(E5, 0); hipEventSynchronize(E5);
    hipEventElapsedTime(&TiempoSort,  E4, E5);

    hipEventRecord(E2, 0);
    // Ejecutar el kernel
    calculateFreq<<<k, 1>>>(k, ref_points_dev_val, freq1_dev, freq2_dev);

    hipEventRecord(E3, 0); hipEventSynchronize(E3);
    hipEventElapsedTime(&TiempoKernelFreq,  E2, E3);

    TiempoAllOperations = TiempoKernelDistance + TiempoSort + TiempoKernelFreq;

    hipMemcpy(freq1_host, freq1_dev, sizeof(unsigned int), hipMemcpyDeviceToHost);
    hipMemcpy(freq2_host, freq2_dev, sizeof(unsigned int), hipMemcpyDeviceToHost);

    hipFree(ref_points_dev_val);
    hipFree(freq1_dev);
    hipFree(freq2_dev);

    int result = -1;
    if(freq1_host[0] > freq2_host[0]) result = 0;
    else result = 1;

    printf ("freq1 is %d.\n", freq1_host[0]);
    printf ("freq2 is %d.\n", freq2_host[0]);

    printf ("The value classified to unknown point"
            " is %d.\n", result);


    printf("Invocació Kernel <<<nBlocks, nKernels>>> (N): <<<%d, %d>>> (%d)\n", nBlocks, nThreads, n);

    printf("Tiempo Kernel calculo distancia (00): %4.6f milseg\n", TiempoKernelDistance);
    printf("Tiempo Kernel calculo freq (00): %4.6f milseg\n", TiempoKernelFreq);
    printf("Tiempo Sort (00): %4.6f milseg\n", TiempoSort);
    printf("Tiempo todas las operaciones (00): %4.6f milseg\n", TiempoAllOperations);

    if (PINNED) printf("Usando Pinned Memory\n");
    else printf("NO usa Pinned Memory\n");

    if (PINNED) {
        hipHostFree(ref_points_host_x); hipHostFree(ref_points_host_y); hipHostFree(ref_points_host_val);hipHostFree(result_prediction_host); hipHostFree(freq1_host); hipHostFree(freq2_host);
    } else {
        free(ref_points_host_x); free(ref_points_host_y); free(ref_points_host_val); free(result_prediction_host); free(freq1_host); free(freq2_host);
    }

    hipEventRecord(E7, 0); hipEventSynchronize(E7);
    hipEventElapsedTime(&TiempoProva,  E6, E7);

    printf("Temps total CUDA: %4.6f milseg\n", TiempoProva);

    return result;
}

void InitKDefecte(int *k) {

    // Parameter to decide group of the testing point
    (*k) = 15;

}

void InitTestPointDefecte(struct Point *p) {

    //Test Point
    p->x = 2.5;
    p->y = 7;

}

void InitDefecte(int *k, struct Point *p) {
    InitKDefecte(k);
    InitTestPointDefecte(p);
}

int main(int argc, char** argv)
{
    srand(time(0));

    //Es declaren les variables
    int n, k;
    struct Point p;

    //S'inicialitza la K, i les coordenades del Testing point
    if (argc == 1)      { InitDefecte(&k, &p); }
    else if (argc == 2) { k = atoi(argv[1]); InitTestPointDefecte(&p); }
    else if (argc == 4) { k = atoi(argv[1]); p.x = atof(argv[2]); p.y = atof(argv[3]);}
    else { printf("Usage: ./exe k TestPointCoordenadaX TestPointCoordenadaY\n"); exit(0); }

    //Es crea l'estructura sobre la qual es vol fer la predicció
    n = 10000; // Number of data points
    Point arr[n];
	
	float val[n];
	float val_cuda[n];

    for(int i = 0; i < n; ++i) {
        arr[i].x = rand() % 100;
        arr[i].y = rand() % 100;
        val[i] = rand() % 2;
	val_cuda[i] = val[i];
    }

    printf("k = %d \n", k);

    printf("The Testing Point values are:");
    printf(" x = %f", p.x);
    printf(" and");
    printf(" y = %f", p.y);
    printf("\n");

    printf("\n");
    printf("Programa Seqüencial -------------------------------------------------- \n");
    printf("\n");

    // Calculate the time taken by the sequential code: classifyAPoint function
    clock_t t;
    t = clock();
    int result = classifyAPoint(arr,val, n, k, p);
    t = clock() - t;
    float time_taken = ((float)t)/(CLOCKS_PER_SEC/1000); // in mseconds

    printf ("The value classified to unknown point"
            " is %d.\n", result);

    printf ("Temps total seqüencial:"
            " %lf milseg.\n", time_taken);

    printf("\n");
    printf("Programa CUDA -------------------------------------------------------- \n");
    printf("\n");

    int result2 = classifyAPointCUDA(arr,val_cuda, n, k, p);
    
	printf ("The value classified to unknown point"
            " is %d.\n", result2);
}

	.text
	.file	"knn02.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z13selectionSortPfS_i          # -- Begin function _Z13selectionSortPfS_i
	.type	_Z13selectionSortPfS_i,@function
_Z13selectionSortPfS_i:                 # @_Z13selectionSortPfS_i
	.cfi_startproc
# %bb.0:
                                        # kill: def $edx killed $edx def $rdx
	cmpl	$2, %edx
	jl	.LBB0_8
# %bb.1:                                # %.lr.ph36.preheader
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	leal	-1(%rdx), %eax
	movl	%edx, %ecx
	movl	$1, %edx
	xorl	%r9d, %r9d
.LBB0_2:                                # %.lr.ph.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
	leaq	1(%r9), %r8
	movq	%rdx, %r10
	movl	%r9d, %r11d
.LBB0_3:                                # %.lr.ph
                                        #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	%r11d, %rbx
	movss	(%rdi,%rbx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	(%rdi,%r10,4), %xmm0
	movl	%r10d, %ebx
	ja	.LBB0_5
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB0_3 Depth=2
	movl	%r11d, %ebx
.LBB0_5:                                # %.lr.ph
                                        #   in Loop: Header=BB0_3 Depth=2
	incq	%r10
	movl	%ebx, %r11d
	cmpq	%r10, %rcx
	jne	.LBB0_3
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	movslq	%ebx, %r10
	movss	(%rdi,%r10,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	(%rdi,%r9,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	movss	(%rsi,%r9,4), %xmm2             # xmm2 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdi,%r9,4)
	movss	(%rsi,%r10,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rsi,%r9,4)
	cvttps2dq	%xmm1, %xmm0
	cvtdq2ps	%xmm0, %xmm0
	movss	%xmm0, (%rdi,%r10,4)
	cvttps2dq	%xmm2, %xmm0
	cvtdq2ps	%xmm0, %xmm0
	movss	%xmm0, (%rsi,%r10,4)
	incq	%rdx
	movq	%r8, %r9
	cmpq	%rax, %r8
	jne	.LBB0_2
# %bb.7:
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
.LBB0_8:                                # %._crit_edge37
	retq
.Lfunc_end0:
	.size	_Z13selectionSortPfS_i, .Lfunc_end0-_Z13selectionSortPfS_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z14classifyAPointP5PointPfiiS_
.LCPI1_0:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z14classifyAPointP5PointPfiiS_
	.type	_Z14classifyAPointP5PointPfiiS_,@function
_Z14classifyAPointP5PointPfiiS_:        # @_Z14classifyAPointP5PointPfiiS_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %r14d
	movq	%rsi, %rbx
	movl	%edx, %ecx
	movq	%rsp, %rax
	leaq	15(,%rcx,4), %rsi
	andq	$-16, %rsi
	subq	%rsi, %rax
	movq	%rax, %rsp
	testl	%edx, %edx
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph
	movaps	%xmm0, %xmm1
	shufps	$85, %xmm0, %xmm1               # xmm1 = xmm1[1,1],xmm0[1,1]
	xorl	%esi, %esi
.LBB1_2:                                # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rsi,8), %xmm2            # xmm2 = mem[0],zero,zero,zero
	movss	4(%rdi,%rsi,8), %xmm3           # xmm3 = mem[0],zero,zero,zero
	subss	%xmm0, %xmm2
	mulss	%xmm2, %xmm2
	subss	%xmm1, %xmm3
	mulss	%xmm3, %xmm3
	addss	%xmm2, %xmm3
	xorps	%xmm2, %xmm2
	sqrtss	%xmm3, %xmm2
	movss	%xmm2, (%rax,%rsi,4)
	incq	%rsi
	cmpq	%rsi, %rcx
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_Z13selectionSortPfS_i
	testl	%r14d, %r14d
	jle	.LBB1_4
# %bb.6:                                # %.lr.ph43.preheader
	movl	%r14d, %eax
	xorl	%ecx, %ecx
	xorps	%xmm0, %xmm0
	movss	.LCPI1_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	xorl	%r15d, %r15d
	xorl	%r14d, %r14d
.LBB1_7:                                # %.lr.ph43
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rbx,%rcx,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm2
	jne	.LBB1_9
	jp	.LBB1_9
# %bb.8:                                #   in Loop: Header=BB1_7 Depth=1
	incl	%r14d
	jmp	.LBB1_11
.LBB1_9:                                #   in Loop: Header=BB1_7 Depth=1
	ucomiss	%xmm1, %xmm2
	jne	.LBB1_11
	jp	.LBB1_11
# %bb.10:                               #   in Loop: Header=BB1_7 Depth=1
	incl	%r15d
.LBB1_11:                               #   in Loop: Header=BB1_7 Depth=1
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB1_7
	jmp	.LBB1_5
.LBB1_4:
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB1_5:                                # %._crit_edge44
	movl	$.L.str, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.1, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
	xorl	%eax, %eax
	cmpl	%r15d, %r14d
	setle	%al
	leaq	-24(%rbp), %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end1:
	.size	_Z14classifyAPointP5PointPfiiS_, .Lfunc_end1-_Z14classifyAPointP5PointPfiiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z13InitHostInputP5PointPfiS_S1_S1_S1_ # -- Begin function _Z13InitHostInputP5PointPfiS_S1_S1_S1_
	.type	_Z13InitHostInputP5PointPfiS_S1_S1_S1_,@function
_Z13InitHostInputP5PointPfiS_S1_S1_S1_: # @_Z13InitHostInputP5PointPfiS_S1_S1_S1_
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorl	%edx, %edx
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rdx,8), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rcx,%rdx,4)
	movss	4(%rdi,%rdx,8), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r8,%rdx,4)
	movss	(%rsi,%rdx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r9,%rdx,4)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z13InitHostInputP5PointPfiS_S1_S1_S1_, .Lfunc_end2-_Z13InitHostInputP5PointPfiS_S1_S1_S1_
	.cfi_endproc
                                        # -- End function
	.globl	_Z12InitHostFreqPjS_            # -- Begin function _Z12InitHostFreqPjS_
	.type	_Z12InitHostFreqPjS_,@function
_Z12InitHostFreqPjS_:                   # @_Z12InitHostFreqPjS_
	.cfi_startproc
# %bb.0:
	xorl	%eax, %eax
	movl	%eax, (%rdi)
	movl	%eax, (%rsi)
	retq
.Lfunc_end3:
	.size	_Z12InitHostFreqPjS_, .Lfunc_end3-_Z12InitHostFreqPjS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__calculateDistancei5PointPfS0_S0_ # -- Begin function _Z32__device_stub__calculateDistancei5PointPfS0_S0_
	.type	_Z32__device_stub__calculateDistancei5PointPfS0_S0_,@function
_Z32__device_stub__calculateDistancei5PointPfS0_S0_: # @_Z32__device_stub__calculateDistancei5PointPfS0_S0_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movlps	%xmm0, (%rax)
	leaq	12(%rsp), %r8
	movl	%edi, (%r8)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	96(%rsp), %rbx
	movq	%r8, (%rbx)
	movq	%rax, 8(%rbx)
	movq	%rdi, 16(%rbx)
	movq	%rsi, 24(%rbx)
	movq	%rdx, 32(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z17calculateDistancei5PointPfS0_S0_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z32__device_stub__calculateDistancei5PointPfS0_S0_, .Lfunc_end4-_Z32__device_stub__calculateDistancei5PointPfS0_S0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z28__device_stub__calculateFreqiPfPjS0_ # -- Begin function _Z28__device_stub__calculateFreqiPfPjS0_
	.type	_Z28__device_stub__calculateFreqiPfPjS0_,@function
_Z28__device_stub__calculateFreqiPfPjS0_: # @_Z28__device_stub__calculateFreqiPfPjS0_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	4(%rsp), %rax
	movl	%edi, (%rax)
	leaq	40(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	24(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z13calculateFreqiPfPjS0_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z28__device_stub__calculateFreqiPfPjS0_, .Lfunc_end5-_Z28__device_stub__calculateFreqiPfPjS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z18classifyAPointCUDAP5PointPfiiS_ # -- Begin function _Z18classifyAPointCUDAP5PointPfiiS_
	.type	_Z18classifyAPointCUDAP5PointPfiiS_,@function
_Z18classifyAPointCUDAP5PointPfiiS_:    # @_Z18classifyAPointCUDAP5PointPfiiS_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$216, %rsp
	.cfi_def_cfa_offset 272
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movaps	%xmm0, 192(%rsp)                # 16-byte Spill
	movl	%ecx, 148(%rsp)                 # 4-byte Spill
	movl	%edx, %r14d
	movq	%rsi, %r12
	movq	%rdi, %r13
	leaq	168(%rsp), %rdi
	callq	hipEventCreate
	leaq	136(%rsp), %rdi
	callq	hipEventCreate
	leaq	160(%rsp), %rdi
	callq	hipEventCreate
	leaq	128(%rsp), %rdi
	callq	hipEventCreate
	leaq	152(%rsp), %rdi
	callq	hipEventCreate
	leaq	120(%rsp), %rdi
	callq	hipEventCreate
	leaq	176(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventCreate
	leaq	112(%rsp), %rdi
	callq	hipEventCreate
	movq	(%rbx), %rdi
	xorl	%ebx, %ebx
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%rbx, 104(%rsp)
	movq	%rbx, 96(%rsp)
	movq	%rbx, 88(%rsp)
	movq	%rbx, 48(%rsp)
	leaq	80(%rsp), %rbp
	movq	%rbx, (%rbp)
	leaq	64(%rsp), %rax
	movq	%rbx, (%rax)
	leaq	40(%rsp), %rax
	movq	%rbx, (%rax)
	leaq	32(%rsp), %rax
	movq	%rbx, (%rax)
	movq	%rbx, 24(%rsp)
	movq	%rbx, 16(%rsp)
	leaq	8(%rsp), %rax
	movq	%rbx, (%rax)
	movq	%rsp, %rax
	movq	%rbx, (%rax)
	leal	999(%r14), %eax
	imulq	$274877907, %rax, %r15          # imm = 0x10624DD3
	shrq	$38, %r15
	movl	$.L.str.2, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	%r15, 72(%rsp)                  # 8-byte Spill
	imull	$4000, %r15d, %r15d             # imm = 0xFA0
	movl	$.L.str.3, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	%rbp, %rdi
	movq	%r15, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	64(%rsp), %rdi
	movq	%r15, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	40(%rsp), %rdi
	movq	%r15, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	leaq	32(%rsp), %rdi
	movq	%r15, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	movl	$4, %esi
	leaq	8(%rsp), %rdi
	xorl	%edx, %edx
	callq	hipHostMalloc
	movl	$4, %esi
	movq	%rsp, %rdi
	xorl	%edx, %edx
	callq	hipHostMalloc
	testl	%r14d, %r14d
	jle	.LBB6_3
# %bb.1:                                # %.lr.ph.preheader.i
	movq	80(%rsp), %rax
	movq	64(%rsp), %rcx
	movq	40(%rsp), %rdx
	movl	%r14d, %esi
	xorl	%edi, %edi
.LBB6_2:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r13,%rdi,8), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rax,%rdi,4)
	movss	4(%r13,%rdi,8), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rcx,%rdi,4)
	movss	(%r12,%rdi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdx,%rdi,4)
	incq	%rdi
	cmpq	%rdi, %rsi
	jne	.LBB6_2
.LBB6_3:                                # %_Z13InitHostInputP5PointPfiS_S1_S1_S1_.exit
	movabsq	$4294967296, %r12               # imm = 0x100000000
	movq	8(%rsp), %rax
	movq	(%rsp), %rcx
	movl	%ebx, (%rax)
	movl	%ebx, (%rcx)
	leaq	104(%rsp), %r13
	movq	%r13, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	96(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	88(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	48(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	24(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	movq	(%r13), %rdi
	movq	80(%rsp), %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rdi
	movq	64(%rsp), %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbx), %rdi
	movq	40(%rsp), %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	48(%rsp), %rax
	movq	(%rax), %rdi
	movq	32(%rsp), %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	24(%rsp), %rax
	movq	(%rax), %rdi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	movq	(%rsp), %rsi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	72(%rsp), %rbx                  # 8-byte Reload
	decl	%ebx
	movq	168(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%rbx, %rdi
	btsq	$32, %rdi
	leaq	1000(%r12), %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_5
# %bb.4:
	movq	104(%rsp), %rsi
	movq	96(%rsp), %rdx
	movq	48(%rsp), %rcx
	movl	%r14d, %edi
	movaps	192(%rsp), %xmm0                # 16-byte Reload
	callq	_Z32__device_stub__calculateDistancei5PointPfS0_S0_
.LBB6_5:
	movq	136(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	136(%rsp), %rdi
	callq	hipEventSynchronize
	movq	168(%rsp), %rsi
	movq	136(%rsp), %rdx
	leaq	60(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	32(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	104(%rsp), %rdi
	callq	hipFree
	movq	96(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	152(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	32(%rsp), %rdi
	movq	40(%rsp), %rsi
	movl	%r14d, %edx
	callq	_Z13selectionSortPfS_i
	movq	120(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	120(%rsp), %rdi
	callq	hipEventSynchronize
	movq	152(%rsp), %rsi
	movq	120(%rsp), %rdx
	leaq	56(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	160(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	148(%rsp), %ebp                 # 4-byte Reload
	movl	%ebp, %edi
	orq	%r12, %rdi
	incq	%r12
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_7
# %bb.6:
	movq	88(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rcx
	movl	%ebp, %edi
	callq	_Z28__device_stub__calculateFreqiPfPjS0_
.LBB6_7:
	movq	128(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	128(%rsp), %rdi
	callq	hipEventSynchronize
	movq	160(%rsp), %rsi
	movq	128(%rsp), %rdx
	leaq	188(%rsp), %r15
	movq	%r15, %rdi
	callq	hipEventElapsedTime
	movss	60(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movq	8(%rsp), %rdi
	movq	24(%rsp), %rsi
	addss	56(%rsp), %xmm0
	addss	(%r15), %xmm0
	movss	%xmm0, 72(%rsp)                 # 4-byte Spill
	movl	$4, %edx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	$4, %edx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	88(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rax
	movl	(%rax), %esi
	movq	(%rsp), %rax
	xorl	%ebp, %ebp
	cmpl	(%rax), %esi
	setbe	%bpl
	movl	$.L.str, %edi
	xorl	%eax, %eax
	callq	printf
	movq	(%rsp), %rax
	movl	(%rax), %esi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.4, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.5, %edi
	movl	%ebx, %esi
	movl	$1000, %edx                     # imm = 0x3E8
	movl	%r14d, %ecx
	xorl	%eax, %eax
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	60(%rsp), %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r15), %xmm0
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	56(%rsp), %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	72(%rsp), %xmm0                 # 4-byte Folded Reload
	movl	$.L.str.9, %edi
	movb	$1, %al
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	movq	80(%rsp), %rdi
	callq	hipHostFree
	movq	64(%rsp), %rdi
	callq	hipHostFree
	movq	40(%rsp), %rdi
	callq	hipHostFree
	movq	32(%rsp), %rdi
	callq	hipHostFree
	movq	8(%rsp), %rdi
	callq	hipHostFree
	movq	(%rsp), %rdi
	callq	hipHostFree
	movq	112(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	112(%rsp), %rdi
	callq	hipEventSynchronize
	movq	176(%rsp), %rsi
	movq	112(%rsp), %rdx
	leaq	184(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.11, %edi
	movb	$1, %al
	callq	printf
	movl	%ebp, %eax
	addq	$216, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z18classifyAPointCUDAP5PointPfiiS_, .Lfunc_end6-_Z18classifyAPointCUDAP5PointPfiiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z12InitKDefectePi              # -- Begin function _Z12InitKDefectePi
	.type	_Z12InitKDefectePi,@function
_Z12InitKDefectePi:                     # @_Z12InitKDefectePi
	.cfi_startproc
# %bb.0:
	movl	$15, (%rdi)
	retq
.Lfunc_end7:
	.size	_Z12InitKDefectePi, .Lfunc_end7-_Z12InitKDefectePi
	.cfi_endproc
                                        # -- End function
	.globl	_Z20InitTestPointDefecteP5Point # -- Begin function _Z20InitTestPointDefecteP5Point
	.type	_Z20InitTestPointDefecteP5Point,@function
_Z20InitTestPointDefecteP5Point:        # @_Z20InitTestPointDefecteP5Point
	.cfi_startproc
# %bb.0:
	movabsq	$4674736414286413824, %rax      # imm = 0x40E0000040200000
	movq	%rax, (%rdi)
	retq
.Lfunc_end8:
	.size	_Z20InitTestPointDefecteP5Point, .Lfunc_end8-_Z20InitTestPointDefecteP5Point
	.cfi_endproc
                                        # -- End function
	.globl	_Z11InitDefectePiP5Point        # -- Begin function _Z11InitDefectePiP5Point
	.type	_Z11InitDefectePiP5Point,@function
_Z11InitDefectePiP5Point:               # @_Z11InitDefectePiP5Point
	.cfi_startproc
# %bb.0:
	movl	$15, (%rdi)
	movabsq	$4674736414286413824, %rax      # imm = 0x40E0000040200000
	movq	%rax, (%rsi)
	retq
.Lfunc_end9:
	.size	_Z11InitDefectePiP5Point, .Lfunc_end9-_Z11InitDefectePiP5Point
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI10_0:
	.long	0x40200000                      # float 2.5
	.long	0x40e00000                      # float 7
	.zero	4
	.zero	4
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI10_1:
	.long	0x447a0000                      # float 1000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r14
	movl	%edi, %ebx
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	movaps	.LCPI10_0(%rip), %xmm0          # xmm0 = <2.5E+0,7.0E+0,u,u>
	movaps	%xmm0, -64(%rbp)                # 16-byte Spill
	cmpl	$1, %ebx
	je	.LBB10_1
# %bb.2:
	cmpl	$4, %ebx
	je	.LBB10_6
# %bb.3:
	cmpl	$2, %ebx
	jne	.LBB10_5
# %bb.4:
	movq	8(%r14), %rdi
	callq	atoi
	movl	%eax, %ebx
	jmp	.LBB10_7
.LBB10_6:
	movq	8(%r14), %rdi
	callq	atoi
	movl	%eax, %ebx
	movq	16(%r14), %rdi
	callq	atof
	cvtsd2ss	%xmm0, %xmm0
	movaps	%xmm0, -64(%rbp)                # 16-byte Spill
	movq	24(%r14), %rdi
	callq	atof
	cvtsd2ss	%xmm0, %xmm0
	movaps	-64(%rbp), %xmm1                # 16-byte Reload
	unpcklps	%xmm0, %xmm1                    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
	movaps	%xmm1, -64(%rbp)                # 16-byte Spill
	jmp	.LBB10_7
.LBB10_1:
	movl	$15, %ebx
.LBB10_7:
	movq	%rsp, %r14
	addq	$-80000, %r14                   # imm = 0xFFFEC780
	movq	%r14, %rsp
	movq	%rsp, %r12
	addq	$-40000, %r12                   # imm = 0xFFFF63C0
	movq	%r12, %rsp
	movq	%rsp, %r15
	addq	$-40000, %r15                   # imm = 0xFFFF63C0
	movq	%r15, %rsp
	xorl	%r13d, %r13d
.LBB10_8:                               # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r14,%r13,8)
	callq	rand
	cltq
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, 4(%r14,%r13,8)
	callq	rand
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%eax, %ecx
	andl	$-2, %ecx
	subl	%ecx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r12,%r13,4)
	movss	%xmm0, (%r15,%r13,4)
	incq	%r13
	cmpq	$10000, %r13                    # imm = 0x2710
	jne	.LBB10_8
# %bb.9:
	movl	$.L.str.13, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.14, %edi
	xorl	%eax, %eax
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	-64(%rbp), %xmm0                # 16-byte Folded Reload
	movl	$.L.str.15, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.16, %edi
	xorl	%eax, %eax
	callq	printf
	movaps	-64(%rbp), %xmm0                # 16-byte Reload
	shufps	$85, %xmm0, %xmm0               # xmm0 = xmm0[1,1,1,1]
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.17, %edi
	movb	$1, %al
	callq	printf
	movl	$10, %edi
	callq	putchar@PLT
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$10, %edi
	callq	putchar@PLT
	callq	clock
	movq	%rax, %r13
	movq	%r14, %rdi
	movq	%r12, %rsi
	movl	$10000, %edx                    # imm = 0x2710
	movl	%ebx, %ecx
	movaps	-64(%rbp), %xmm0                # 16-byte Reload
	callq	_Z14classifyAPointP5PointPfiiS_
	movl	%eax, %r12d
	callq	clock
	subq	%r13, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI10_1(%rip), %xmm0
	movss	%xmm0, -68(%rbp)                # 4-byte Spill
	movl	$.L.str.4, %edi
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	-68(%rbp), %xmm0                # 4-byte Folded Reload
	movl	$.L.str.20, %edi
	movb	$1, %al
	callq	printf
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$10, %edi
	callq	putchar@PLT
	movq	%r14, %rdi
	movq	%r15, %rsi
	movl	$10000, %edx                    # imm = 0x2710
	movl	%ebx, %ecx
	movaps	-64(%rbp), %xmm0                # 16-byte Reload
	callq	_Z18classifyAPointCUDAP5PointPfiiS_
	movl	$.L.str.4, %edi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	printf
	xorl	%eax, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.LBB10_5:
	.cfi_def_cfa %rbp, 16
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	xorl	%edi, %edi
	callq	exit
.Lfunc_end10:
	.size	main, .Lfunc_end10-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17calculateDistancei5PointPfS0_S0_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13calculateFreqiPfPjS0_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB12_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"freq1 is %d.\n"
	.size	.L.str, 14

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"freq2 is %d.\n"
	.size	.L.str.1, 14

	.type	_Z17calculateDistancei5PointPfS0_S0_,@object # @_Z17calculateDistancei5PointPfS0_S0_
	.section	.rodata,"a",@progbits
	.globl	_Z17calculateDistancei5PointPfS0_S0_
	.p2align	3, 0x0
_Z17calculateDistancei5PointPfS0_S0_:
	.quad	_Z32__device_stub__calculateDistancei5PointPfS0_S0_
	.size	_Z17calculateDistancei5PointPfS0_S0_, 8

	.type	_Z13calculateFreqiPfPjS0_,@object # @_Z13calculateFreqiPfPjS0_
	.globl	_Z13calculateFreqiPfPjS0_
	.p2align	3, 0x0
_Z13calculateFreqiPfPjS0_:
	.quad	_Z28__device_stub__calculateFreqiPfPjS0_
	.size	_Z13calculateFreqiPfPjS0_, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"nBlocks = %d \n"
	.size	.L.str.2, 15

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"numBytes = %d \n"
	.size	.L.str.3, 16

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"The value classified to unknown point is %d.\n"
	.size	.L.str.4, 46

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Invocaci\303\263 Kernel <<<nBlocks, nKernels>>> (N): <<<%d, %d>>> (%d)\n"
	.size	.L.str.5, 66

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Tiempo Kernel calculo distancia (00): %4.6f milseg\n"
	.size	.L.str.6, 52

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Tiempo Kernel calculo freq (00): %4.6f milseg\n"
	.size	.L.str.7, 47

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Tiempo Sort (00): %4.6f milseg\n"
	.size	.L.str.8, 32

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Tiempo todas las operaciones (00): %4.6f milseg\n"
	.size	.L.str.9, 49

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Temps total CUDA: %4.6f milseg\n"
	.size	.L.str.11, 32

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"k = %d \n"
	.size	.L.str.13, 9

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"The Testing Point values are:"
	.size	.L.str.14, 30

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	" x = %f"
	.size	.L.str.15, 8

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	" and"
	.size	.L.str.16, 5

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	" y = %f"
	.size	.L.str.17, 8

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Temps total seq\303\274encial: %lf milseg.\n"
	.size	.L.str.20, 38

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z17calculateDistancei5PointPfS0_S0_"
	.size	.L__unnamed_1, 37

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z13calculateFreqiPfPjS0_"
	.size	.L__unnamed_2, 26

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Usando Pinned Memory"
	.size	.Lstr, 21

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Usage: ./exe k TestPointCoordenadaX TestPointCoordenadaY"
	.size	.Lstr.1, 57

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Programa Seq\303\274encial -------------------------------------------------- "
	.size	.Lstr.2, 73

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Programa CUDA -------------------------------------------------------- "
	.size	.Lstr.3, 72

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z32__device_stub__calculateDistancei5PointPfS0_S0_
	.addrsig_sym _Z28__device_stub__calculateFreqiPfPjS0_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z17calculateDistancei5PointPfS0_S0_
	.addrsig_sym _Z13calculateFreqiPfPjS0_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z17calculateDistancei5PointPfS0_S0_ ; -- Begin function _Z17calculateDistancei5PointPfS0_S0_
	.globl	_Z17calculateDistancei5PointPfS0_S0_
	.p2align	8
	.type	_Z17calculateDistancei5PointPfS0_S0_,@function
_Z17calculateDistancei5PointPfS0_S0_:   ; @_Z17calculateDistancei5PointPfS0_S0_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b128 s[4:7], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_load_b64 s[2:3], s[0:1], 0x4
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s6, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[4:5], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_dual_subrev_f32 v2, s3, v2 :: v_dual_subrev_f32 v3, s2, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v2, v2, v2
	v_fmac_f32_e32 v2, v3, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_f32_e32 v3, 0x4f800000, v2
	v_cmp_gt_f32_e32 vcc_lo, 0xf800000, v2
	v_cndmask_b32_e32 v2, v2, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_sqrt_f32_e32 v3, v2
	s_waitcnt_depctr 0xfff
	v_add_nc_u32_e32 v4, -1, v3
	v_add_nc_u32_e32 v5, 1, v3
	v_fma_f32 v6, -v4, v3, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v7, -v5, v3, v2
	v_cmp_ge_f32_e64 s2, 0, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_cndmask_b32_e64 v3, v3, v4, s2
	s_load_b64 s[2:3], s[0:1], 0x20
	v_cmp_lt_f32_e64 s0, 0, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v3, v3, v5, s0
	v_mul_f32_e32 v4, 0x37800000, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v3, v3, v4, vcc_lo
	v_cmp_class_f32_e64 vcc_lo, v2, 0x260
	v_cndmask_b32_e32 v2, v3, v2, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17calculateDistancei5PointPfS0_S0_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z17calculateDistancei5PointPfS0_S0_, .Lfunc_end0-_Z17calculateDistancei5PointPfS0_S0_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 316
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z13calculateFreqiPfPjS0_ ; -- Begin function _Z13calculateFreqiPfPjS0_
	.globl	_Z13calculateFreqiPfPjS0_
	.p2align	8
	.type	_Z13calculateFreqiPfPjS0_,@function
_Z13calculateFreqiPfPjS0_:              ; @_Z13calculateFreqiPfPjS0_
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB1_5
; %bb.1:
	s_load_b128 s[4:7], s[0:1], 0x8
	v_ashrrev_i32_e32 v2, 31, v1
	s_mov_b32 s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v2, v[0:1], off
	v_dual_mov_b32 v0, s6 :: v_dual_mov_b32 v1, s7
	s_waitcnt vmcnt(0)
	v_cmp_eq_f32_e64 s2, 0, v2
	v_cmpx_neq_f32_e32 0, v2
	s_cbranch_execz .LBB1_3
; %bb.2:
	s_load_b64 s[0:1], s[0:1], 0x18
	v_cmp_eq_f32_e32 vcc_lo, 1.0, v2
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
	s_and_not1_b32 s0, s2, exec_lo
	s_and_b32 s1, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s2, s0, s1
.LBB1_3:                                ; %Flow
	s_or_b32 exec_lo, exec_lo, s3
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	s_and_b32 exec_lo, exec_lo, s2
	s_cbranch_execz .LBB1_5
; %bb.4:                                ; %.sink.split
	v_mov_b32_e32 v2, 1
	global_atomic_add_u32 v[0:1], v2, off
.LBB1_5:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13calculateFreqiPfPjS0_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 3
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z13calculateFreqiPfPjS0_, .Lfunc_end1-_Z13calculateFreqiPfPjS0_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 224
; NumSgprs: 18
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 3
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           8
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17calculateDistancei5PointPfS0_S0_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17calculateDistancei5PointPfS0_S0_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13calculateFreqiPfPjS0_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13calculateFreqiPfPjS0_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
