#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <cmath>
#include <climits>

#include <fstream>

//const int N = 512;
using namespace::std;

const int BLOCKS = 19000;
const int DIMENSIONS = 16;
const int TESTLINES = 1000;

unsigned short int testLines[TESTLINES*DIMENSIONS];
unsigned short int trainLines[BLOCKS*DIMENSIONS];

string testFilename = "test.txt";
string trainFilename = "train.txt";
string outputFilename = "myout.txt";

void parseLine(string line, int startIndex, unsigned short int* arr) {
  int start=0;
  int numIndex = startIndex;
  for (size_t i = 0; i < line.length(); i++) {
    if (line[i] == ',') {
      arr[numIndex] = stoi(line.substr(start, i-start));
      numIndex++;
      start = i+1;
    }
  }
  arr[numIndex] = stoi(line.substr(start, line.length()-start));
}

void readFile(string filename, unsigned short int* arr){
  ifstream inputFile;
  inputFile.open(filename.c_str());
  int ind = 0;
  string line;
  while (getline(inputFile, line)) {
    parseLine(line, ind*DIMENSIONS, arr);
    ind++;
  }
}

__global__
void calculateDifference(short int *trainLines,unsigned long long int *diffSquare, short int *testLines, short int id){
  __shared__ unsigned int s_diffSquare;
  s_diffSquare = 0;
  __syncthreads();
  short int other = testLines[id*DIMENSIONS + threadIdx.x];
  short int self = trainLines[blockIdx.x*DIMENSIONS + threadIdx.x];

  int result = other - self;

  atomicAdd(&s_diffSquare, result * result);
  __syncthreads();
  if (threadIdx.x % DIMENSIONS == 0) {
    // this will contain min with its index. Since the actual number is on the left side, comparison will be done between
    // the mins. Index will have no effect except the case where two distances are equal which will return the lower index.
    unsigned long long int min = (((unsigned long long int) s_diffSquare) << 32) | blockIdx.x;
    atomicMin(diffSquare, min);
  }
}

void getNearestNeighbors(short int *trainLines, short int *testLines,unsigned short int *result){
    unsigned long long int *d_diffSquare;
    unsigned long long int *diffSquare;
    diffSquare = (unsigned long long int *)malloc(sizeof(unsigned long long int));
    cudaMalloc((void **)&d_diffSquare, sizeof(unsigned long long int));

    unsigned long long int maxLongLong = ULLONG_MAX;

    for (size_t i = 0; i < TESTLINES; i++) {
      cudaMemcpy(d_diffSquare, &maxLongLong, sizeof(unsigned long long int), cudaMemcpyHostToDevice);
      calculateDifference<<<BLOCKS, DIMENSIONS>>>(trainLines, d_diffSquare, testLines, i);

      cudaMemcpy(diffSquare, d_diffSquare, sizeof(unsigned long long int), cudaMemcpyDeviceToHost);

      result[i] = (unsigned int) *diffSquare;
    }


    free(diffSquare);
    cudaFree(d_diffSquare);
}

int main(int argc, char *argv[]) {
  readFile(testFilename, testLines);
  readFile(trainFilename, trainLines);


  short int* d_testLines;
  short int* d_trainLines;

  unsigned short int* output;
  int lineSize = DIMENSIONS * sizeof(short int);
  int trainLinesSize = BLOCKS * lineSize;
  int testLinesSize = TESTLINES * lineSize;

  output = (unsigned short int *)malloc(TESTLINES * sizeof(unsigned short int));
  cudaMalloc((void **)&d_testLines, testLinesSize);
  cudaMalloc((void **)&d_trainLines, trainLinesSize);

  cudaMemcpy(d_testLines, testLines, testLinesSize, cudaMemcpyHostToDevice);
  cudaMemcpy(d_trainLines, trainLines, trainLinesSize, cudaMemcpyHostToDevice);

  getNearestNeighbors(d_trainLines, d_testLines, output);


  ofstream outputFile;
  outputFile.open(outputFilename.c_str());
  for (size_t i = 0; i < TESTLINES; i++) {
    outputFile << output[i] << endl;
  }
  free(output);
  cudaFree(d_testLines); cudaFree(d_trainLines);
  return 1;
}

	.file	"tmpxft_002cb231_00000000-6_bfs.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3773:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3773:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z44__device_stub__Z19calculateDifferencePsPyS_sPsPyS_s
	.type	_Z44__device_stub__Z19calculateDifferencePsPyS_sPsPyS_s, @function
_Z44__device_stub__Z19calculateDifferencePsPyS_sPsPyS_s:
.LFB3795:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movw	%cx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%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)
	leaq	4(%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	.L2
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z19calculateDifferencePsPyS_s(%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
.L2:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3795:
	.size	_Z44__device_stub__Z19calculateDifferencePsPyS_sPsPyS_s, .-_Z44__device_stub__Z19calculateDifferencePsPyS_sPsPyS_s
	.globl	_Z19calculateDifferencePsPyS_s
	.type	_Z19calculateDifferencePsPyS_s, @function
_Z19calculateDifferencePsPyS_s:
.LFB3796:
	.cfi_startproc
	endbr64
	movswl	%cx, %ecx
	jmp	_Z44__device_stub__Z19calculateDifferencePsPyS_sPsPyS_s
	.cfi_endproc
.LFE3796:
	.size	_Z19calculateDifferencePsPyS_s, .-_Z19calculateDifferencePsPyS_s
	.globl	_Z19getNearestNeighborsPsS_Pt
	.type	_Z19getNearestNeighborsPsS_Pt, @function
_Z19getNearestNeighborsPsS_Pt:
.LFB3769:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movabsq	$4294967312, %r15
	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
	movl	$8, %edi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movq	%rsp, %rdi
	movl	$8, %esi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movq	$-1, 8(%rsp)
.L10:
	movq	(%rsp), %rdi
	leaq	8(%rsp), %rsi
	movl	$1, %ecx
	movl	$8, %edx
	call	cudaMemcpy@PLT
	movl	$536873287, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$3, %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L9
	movq	(%rsp), %rsi
	movl	%ebp, %ecx
	movq	%r14, %rdx
	movq	%r13, %rdi
	call	_Z44__device_stub__Z19calculateDifferencePsPyS_sPsPyS_s
.L9:
	movq	(%rsp), %rsi
	movl	$2, %ecx
	movl	$8, %edx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	movq	(%rbx), %rax
	movw	%ax, (%r12,%rbp,2)
	incq	%rbp
	cmpq	$1000, %rbp
	jne	.L10
	movq	%rbx, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	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
.LFE3769:
	.size	_Z19getNearestNeighborsPsS_Pt, .-_Z19getNearestNeighborsPsS_Pt
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z19calculateDifferencePsPyS_s"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3798:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC0(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z19calculateDifferencePsPyS_s(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	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	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3798:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev,"axG",@progbits,_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD5Ev,comdat
	.align 2
	.weak	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.type	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev, @function
_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev:
.LFB3877:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	__errno_location@PLT
	cmpl	$0, (%rax)
	jne	.L16
	movl	(%rbx), %edx
	movl	%edx, (%rax)
.L16:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3877:
	.size	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev, .-_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.weak	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	.set	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev,_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.section	.text._ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_,"axG",@progbits,_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_,comdat
	.weak	_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_
	.type	_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_, @function
_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_:
.LFB3872:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3872
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdx, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	%r8d, 12(%rsp)
	leaq	28(%rsp), %r13
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	__errno_location@PLT
	movl	12(%rsp), %edx
	leaq	32(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%rax, %rbp
	movl	(%rax), %eax
	movl	%eax, 28(%rsp)
	xorl	%eax, %eax
	movl	%eax, 0(%rbp)
.LEHB0:
	call	*%r15
	movq	32(%rsp), %rdx
	cmpq	%rbx, %rdx
	jne	.L20
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	movq	%r14, %rdi
	call	_ZSt24__throw_invalid_argumentPKc@PLT
.L20:
	cmpl	$34, 0(%rbp)
	je	.L22
	movl	$2147483648, %ecx
	movl	$4294967295, %esi
	addq	%rax, %rcx
	cmpq	%rcx, %rsi
	jnb	.L23
.L22:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	movq	%r14, %rdi
	call	_ZSt20__throw_out_of_rangePKc@PLT
.LEHE0:
.L23:
	testq	%r12, %r12
	je	.L25
	subq	%rbx, %rdx
	movq	%rdx, (%r12)
.L25:
	movq	%r13, %rdi
	movl	%eax, 12(%rsp)
	call	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	movl	12(%rsp), %eax
	movq	40(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	jmp	.L33
.L29:
	endbr64
	movq	%rax, %rbx
.L26:
	movq	%r13, %rdi
	call	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	movq	%rbx, %rdi
.LEHB1:
	call	_Unwind_Resume@PLT
.LEHE1:
.L33:
	call	__stack_chk_fail@PLT
.L28:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	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
.LFE3872:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table._ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_,"aG",@progbits,_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_,comdat
.LLSDA3872:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3872-.LLSDACSB3872
.LLSDACSB3872:
	.uleb128 .LEHB0-.LFB3872
	.uleb128 .LEHE0-.LEHB0
	.uleb128 .L29-.LFB3872
	.uleb128 0
	.uleb128 .LEHB1-.LFB3872
	.uleb128 .LEHE1-.LEHB1
	.uleb128 0
	.uleb128 0
.LLSDACSE3872:
	.section	.text._ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_,"axG",@progbits,_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_,comdat
	.size	_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_, .-_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_
	.section	.rodata.str1.1
.LC1:
	.string	"stoi"
	.text
	.globl	_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt
	.type	_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt, @function
_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt:
.LFB3766:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3766
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
.L37:
	movq	8(%rbp), %rcx
	movslq	%eax, %rdx
	cmpq	%rcx, %r12
	jnb	.L51
	movq	0(%rbp), %rcx
	cmpb	$44, (%rcx,%r12)
	jne	.L38
	leaq	8(%rsp), %r14
	movq	%r12, %rcx
	movq	%rbp, %rsi
	subq	%rdx, %rcx
	movq	%r14, %rdi
.LEHB2:
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm@PLT
.LEHE2:
	movq	8(%rsp), %rdx
	xorl	%ecx, %ecx
	movq	%r15, %rsi
	movq	__isoc23_strtol@GOTPCREL(%rip), %rdi
	movl	$10, %r8d
.LEHB3:
	call	_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_
.LEHE3:
	movl	%eax, %edx
	movslq	%ebx, %rax
	movq	%r14, %rdi
	incl	%ebx
	movw	%dx, 0(%r13,%rax,2)
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	leal	1(%r12), %eax
.L38:
	incq	%r12
	jmp	.L37
.L51:
	leaq	8(%rsp), %r12
	subq	%rdx, %rcx
	movq	%rbp, %rsi
	movq	%r12, %rdi
.LEHB4:
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm@PLT
.LEHE4:
	movq	8(%rsp), %rdx
	movq	__isoc23_strtol@GOTPCREL(%rip), %rdi
	xorl	%ecx, %ecx
	movl	$10, %r8d
	leaq	.LC1(%rip), %rsi
.LEHB5:
	call	_ZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_
.LEHE5:
	movslq	%ebx, %rbx
	movq	%r12, %rdi
	movw	%ax, 0(%r13,%rbx,2)
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	jmp	.L47
.L45:
	endbr64
	movq	%rax, %rbx
.L40:
	movq	%r14, %rdi
	jmp	.L50
.L46:
	endbr64
	movq	%rax, %rbx
.L42:
	movq	%r12, %rdi
.L50:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L47
	movq	%rbx, %rdi
.LEHB6:
	call	_Unwind_Resume@PLT
.LEHE6:
.L47:
	call	__stack_chk_fail@PLT
.L44:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	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
.LFE3766:
	.section	.gcc_except_table,"a",@progbits
.LLSDA3766:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3766-.LLSDACSB3766
.LLSDACSB3766:
	.uleb128 .LEHB2-.LFB3766
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB3-.LFB3766
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L45-.LFB3766
	.uleb128 0
	.uleb128 .LEHB4-.LFB3766
	.uleb128 .LEHE4-.LEHB4
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB5-.LFB3766
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L46-.LFB3766
	.uleb128 0
	.uleb128 .LEHB6-.LFB3766
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
.LLSDACSE3766:
	.text
	.size	_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt, .-_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt
	.section	.rodata._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.str1.1,"aMS",@progbits,1
.LC2:
	.string	"basic_string: construction from null is not valid"
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IS3_EEPKcRKS3_,comdat
	.align 2
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_:
.LFB4115:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	jne	.L53
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L58
	leaq	.LC2(%rip), %rdi
	call	_ZSt19__throw_logic_errorPKc@PLT
.L53:
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	movq	%rsi, %rbp
	call	strlen@PLT
	movq	%rax, (%rsp)
	leaq	0(%rbp,%rax), %r12
	cmpq	$15, %rax
	jbe	.L55
	movq	%rsp, %rsi
	xorl	%edx, %edx
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT
	movq	%rax, (%rbx)
	movq	(%rsp), %rax
	movq	%rax, 16(%rbx)
.L55:
	movq	(%rbx), %rdi
	movq	%r12, %rdx
	movq	%rbp, %rsi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	(%rsp), %rax
	movq	(%rbx), %rdx
	movq	%rax, 8(%rbx)
	movb	$0, (%rdx,%rax)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L56
.L58:
	call	__stack_chk_fail@PLT
.L56:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4115:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	.set	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.text
	.globl	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
	.type	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt, @function
_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt:
.LFB3767:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3767
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdi, %rbx
	subq	$592, %rsp
	.cfi_def_cfa_offset 640
	movq	%fs:40, %rax
	movq	%rax, 584(%rsp)
	xorl	%eax, %eax
	leaq	64(%rsp), %rbp
	movq	%rbp, %rdi
.LEHB7:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE7:
	movq	(%rbx), %rsi
	movl	$8, %edx
	movq	%rbp, %rdi
.LEHB8:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
.LEHE8:
	leaq	16(%rsp), %rax
	movb	$0, 16(%rsp)
	xorl	%ebx, %ebx
	movq	%rsp, %r12
	movq	%rax, (%rsp)
	xorl	%eax, %eax
	movq	%rax, 8(%rsp)
.L60:
	movq	%r12, %rsi
	movq	%rbp, %rdi
.LEHB9:
	call	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L72
	leaq	32(%rsp), %r13
	movq	%r12, %rsi
	movq	%r13, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1ERKS4_@PLT
.LEHE9:
	movq	%r14, %rdx
	movl	%ebx, %esi
	movq	%r13, %rdi
.LEHB10:
	call	_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt
.LEHE10:
	movq	%r13, %rdi
	addl	$16, %ebx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L60
.L72:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%rbp, %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	584(%rsp), %rax
	subq	%fs:40, %rax
	je	.L66
	jmp	.L70
.L68:
	endbr64
	movq	%rax, %rbx
.L62:
	movq	%r13, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L63
.L69:
	endbr64
	movq	%rax, %rbx
.L63:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L64
.L67:
	endbr64
	movq	%rax, %rbx
.L64:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	584(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L70
	movq	%rbx, %rdi
.LEHB11:
	call	_Unwind_Resume@PLT
.LEHE11:
.L70:
	call	__stack_chk_fail@PLT
.L66:
	addq	$592, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3767:
	.section	.gcc_except_table
.LLSDA3767:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3767-.LLSDACSB3767
.LLSDACSB3767:
	.uleb128 .LEHB7-.LFB3767
	.uleb128 .LEHE7-.LEHB7
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB8-.LFB3767
	.uleb128 .LEHE8-.LEHB8
	.uleb128 .L67-.LFB3767
	.uleb128 0
	.uleb128 .LEHB9-.LFB3767
	.uleb128 .LEHE9-.LEHB9
	.uleb128 .L69-.LFB3767
	.uleb128 0
	.uleb128 .LEHB10-.LFB3767
	.uleb128 .LEHE10-.LEHB10
	.uleb128 .L68-.LFB3767
	.uleb128 0
	.uleb128 .LEHB11-.LFB3767
	.uleb128 .LEHE11-.LEHB11
	.uleb128 0
	.uleb128 0
.LLSDACSE3767:
	.text
	.size	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt, .-_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3770:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3770
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	_Z12testFilenameB5cxx11(%rip), %rsi
	leaq	testLines(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$552, %rsp
	.cfi_def_cfa_offset 592
	movq	%fs:40, %rax
	movq	%rax, 536(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rbx
	movq	%rbx, %rdi
.LEHB12:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1ERKS4_@PLT
.LEHE12:
	movq	%r13, %rsi
	movq	%rbx, %rdi
.LEHB13:
	call	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
.LEHE13:
	movq	%rbx, %rdi
	leaq	trainLines(%rip), %r12
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	leaq	_Z13trainFilenameB5cxx11(%rip), %rsi
	movq	%rbx, %rdi
.LEHB14:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1ERKS4_@PLT
.LEHE14:
	movq	%r12, %rsi
	movq	%rbx, %rdi
.LEHB15:
	call	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
.LEHE15:
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movl	$2000, %edi
	call	malloc@PLT
	leaq	8(%rsp), %rdi
	movl	$32000, %esi
	movq	%rax, %rbp
.LEHB16:
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movl	$608000, %esi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rsi
	movl	$32000, %edx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$608000, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdi
	movq	%rbp, %rdx
	call	_Z19getNearestNeighborsPsS_Pt
	movq	%rbx, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE16:
	movq	_Z14outputFilenameB5cxx11(%rip), %rsi
	movl	$16, %edx
	movq	%rbx, %rdi
.LEHB17:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	xorl	%r12d, %r12d
.L74:
	movzwl	0(%rbp,%r12,2), %esi
	movq	%rbx, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	incq	%r12
	cmpq	$1000, %r12
	jne	.L74
	movq	%rbp, %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
.LEHE17:
	movq	%rbx, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	je	.L81
	jmp	.L86
.L82:
	endbr64
	jmp	.L90
.L83:
	endbr64
.L90:
	movq	%rax, %rbp
.L77:
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L89
.L84:
	endbr64
	movq	%rax, %rbp
.L79:
	movq	%rbx, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
.L89:
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L86
	movq	%rbp, %rdi
.LEHB18:
	call	_Unwind_Resume@PLT
.LEHE18:
.L86:
	call	__stack_chk_fail@PLT
.L81:
	addq	$552, %rsp
	.cfi_def_cfa_offset 40
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3770:
	.section	.gcc_except_table
.LLSDA3770:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3770-.LLSDACSB3770
.LLSDACSB3770:
	.uleb128 .LEHB12-.LFB3770
	.uleb128 .LEHE12-.LEHB12
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB13-.LFB3770
	.uleb128 .LEHE13-.LEHB13
	.uleb128 .L82-.LFB3770
	.uleb128 0
	.uleb128 .LEHB14-.LFB3770
	.uleb128 .LEHE14-.LEHB14
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB15-.LFB3770
	.uleb128 .LEHE15-.LEHB15
	.uleb128 .L83-.LFB3770
	.uleb128 0
	.uleb128 .LEHB16-.LFB3770
	.uleb128 .LEHE16-.LEHB16
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB17-.LFB3770
	.uleb128 .LEHE17-.LEHB17
	.uleb128 .L84-.LFB3770
	.uleb128 0
	.uleb128 .LEHB18-.LFB3770
	.uleb128 .LEHE18-.LEHB18
	.uleb128 0
	.uleb128 0
.LLSDACSE3770:
	.section	.text.startup
	.size	main, .-main
	.section	.rodata.str1.1
.LC3:
	.string	"test.txt"
.LC4:
	.string	"train.txt"
.LC5:
	.string	"myout.txt"
	.section	.text.startup
	.type	_GLOBAL__sub_I_testLines, @function
_GLOBAL__sub_I_testLines:
.LFB4508:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	_Z12testFilenameB5cxx11(%rip), %r12
	leaq	.LC3(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	__dso_handle(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	7(%rsp), %rbp
	movq	%rbp, %rdx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	movq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@GOTPCREL(%rip), %rdi
	movq	%r12, %rsi
	movq	%rbx, %rdx
	leaq	_Z13trainFilenameB5cxx11(%rip), %r12
	call	__cxa_atexit@PLT
	movq	%rbp, %rdx
	leaq	.LC4(%rip), %rsi
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	movq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@GOTPCREL(%rip), %rdi
	movq	%rbx, %rdx
	movq	%r12, %rsi
	call	__cxa_atexit@PLT
	movq	%rbp, %rdx
	leaq	_Z14outputFilenameB5cxx11(%rip), %rbp
	leaq	.LC5(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L92
	call	__stack_chk_fail@PLT
.L92:
	movq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@GOTPCREL(%rip), %rdi
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__cxa_atexit@PLT
	.cfi_endproc
.LFE4508:
	.size	_GLOBAL__sub_I_testLines, .-_GLOBAL__sub_I_testLines
	.section	.init_array
	.align 8
	.quad	_GLOBAL__sub_I_testLines
	.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
	.globl	_Z14outputFilenameB5cxx11
	.bss
	.align 32
	.type	_Z14outputFilenameB5cxx11, @object
	.size	_Z14outputFilenameB5cxx11, 32
_Z14outputFilenameB5cxx11:
	.zero	32
	.globl	_Z13trainFilenameB5cxx11
	.align 32
	.type	_Z13trainFilenameB5cxx11, @object
	.size	_Z13trainFilenameB5cxx11, 32
_Z13trainFilenameB5cxx11:
	.zero	32
	.globl	_Z12testFilenameB5cxx11
	.align 32
	.type	_Z12testFilenameB5cxx11, @object
	.size	_Z12testFilenameB5cxx11, 32
_Z12testFilenameB5cxx11:
	.zero	32
	.globl	trainLines
	.align 32
	.type	trainLines, @object
	.size	trainLines, 608000
trainLines:
	.zero	608000
	.globl	testLines
	.align 32
	.type	testLines, @object
	.size	testLines, 32000
testLines:
	.zero	32000
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.hidden	__dso_handle
	.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 <string>
#include <iostream>
#include <cmath>
#include <climits>

#include <fstream>

//const int N = 512;
using namespace::std;

const int BLOCKS = 19000;
const int DIMENSIONS = 16;
const int TESTLINES = 1000;

unsigned short int testLines[TESTLINES*DIMENSIONS];
unsigned short int trainLines[BLOCKS*DIMENSIONS];

string testFilename = "test.txt";
string trainFilename = "train.txt";
string outputFilename = "myout.txt";

void parseLine(string line, int startIndex, unsigned short int* arr) {
  int start=0;
  int numIndex = startIndex;
  for (size_t i = 0; i < line.length(); i++) {
    if (line[i] == ',') {
      arr[numIndex] = stoi(line.substr(start, i-start));
      numIndex++;
      start = i+1;
    }
  }
  arr[numIndex] = stoi(line.substr(start, line.length()-start));
}

void readFile(string filename, unsigned short int* arr){
  ifstream inputFile;
  inputFile.open(filename.c_str());
  int ind = 0;
  string line;
  while (getline(inputFile, line)) {
    parseLine(line, ind*DIMENSIONS, arr);
    ind++;
  }
}

__global__
void calculateDifference(short int *trainLines,unsigned long long int *diffSquare, short int *testLines, short int id){
  __shared__ unsigned int s_diffSquare;
  s_diffSquare = 0;
  __syncthreads();
  short int other = testLines[id*DIMENSIONS + threadIdx.x];
  short int self = trainLines[blockIdx.x*DIMENSIONS + threadIdx.x];

  int result = other - self;

  atomicAdd(&s_diffSquare, result * result);
  __syncthreads();
  if (threadIdx.x % DIMENSIONS == 0) {
    // this will contain min with its index. Since the actual number is on the left side, comparison will be done between
    // the mins. Index will have no effect except the case where two distances are equal which will return the lower index.
    unsigned long long int min = (((unsigned long long int) s_diffSquare) << 32) | blockIdx.x;
    atomicMin(diffSquare, min);
  }
}

void getNearestNeighbors(short int *trainLines, short int *testLines,unsigned short int *result){
    unsigned long long int *d_diffSquare;
    unsigned long long int *diffSquare;
    diffSquare = (unsigned long long int *)malloc(sizeof(unsigned long long int));
    hipMalloc((void **)&d_diffSquare, sizeof(unsigned long long int));

    unsigned long long int maxLongLong = ULLONG_MAX;

    for (size_t i = 0; i < TESTLINES; i++) {
      hipMemcpy(d_diffSquare, &maxLongLong, sizeof(unsigned long long int), hipMemcpyHostToDevice);
      calculateDifference<<<BLOCKS, DIMENSIONS>>>(trainLines, d_diffSquare, testLines, i);

      hipMemcpy(diffSquare, d_diffSquare, sizeof(unsigned long long int), hipMemcpyDeviceToHost);

      result[i] = (unsigned int) *diffSquare;
    }


    free(diffSquare);
    hipFree(d_diffSquare);
}

int main(int argc, char *argv[]) {
  readFile(testFilename, testLines);
  readFile(trainFilename, trainLines);


  short int* d_testLines;
  short int* d_trainLines;

  unsigned short int* output;
  int lineSize = DIMENSIONS * sizeof(short int);
  int trainLinesSize = BLOCKS * lineSize;
  int testLinesSize = TESTLINES * lineSize;

  output = (unsigned short int *)malloc(TESTLINES * sizeof(unsigned short int));
  hipMalloc((void **)&d_testLines, testLinesSize);
  hipMalloc((void **)&d_trainLines, trainLinesSize);

  hipMemcpy(d_testLines, testLines, testLinesSize, hipMemcpyHostToDevice);
  hipMemcpy(d_trainLines, trainLines, trainLinesSize, hipMemcpyHostToDevice);

  getNearestNeighbors(d_trainLines, d_testLines, output);


  ofstream outputFile;
  outputFile.open(outputFilename.c_str());
  for (size_t i = 0; i < TESTLINES; i++) {
    outputFile << output[i] << endl;
  }
  free(output);
  hipFree(d_testLines); hipFree(d_trainLines);
  return 1;
}

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

                                        # End of file scope inline assembly
	.globl	_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt # -- Begin function _Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt
	.type	_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt,@function
_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt: # @_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, 8(%rsp)                   # 8-byte Spill
	movl	%esi, %ebp
	movq	%rdi, %r14
	movq	8(%rdi), %rcx
	xorl	%edx, %edx
	testq	%rcx, %rcx
	je	.LBB0_1
# %bb.18:                               # %.lr.ph
	xorl	%r12d, %r12d
.LBB0_19:                               # =>This Inner Loop Header: Depth=1
	movq	(%r14), %rax
	cmpb	$44, (%rax,%r12)
	jne	.LBB0_38
# %bb.20:                               #   in Loop: Header=BB0_19 Depth=1
	movslq	%edx, %rdx
	movq	%r12, %rcx
	subq	%rdx, %rcx
	leaq	24(%rsp), %rdi
	movq	%r14, %rsi
	callq	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm
	movq	24(%rsp), %r15
	callq	__errno_location
	movq	%rax, %r13
	movl	(%rax), %ebx
	movl	$0, (%rax)
	movq	%r15, %rdi
	leaq	16(%rsp), %rsi
	movl	$10, %edx
	callq	__isoc23_strtol
	cmpq	%r15, 16(%rsp)
	je	.LBB0_21
# %bb.29:                               #   in Loop: Header=BB0_19 Depth=1
	leaq	-2147483648(%rax), %rcx
	movabsq	$-4294967296, %rdx              # imm = 0xFFFFFFFF00000000
	cmpq	%rdx, %rcx
	jb	.LBB0_31
# %bb.30:                               #   in Loop: Header=BB0_19 Depth=1
	movl	(%r13), %ecx
	cmpl	$34, %ecx
	je	.LBB0_31
# %bb.33:                               #   in Loop: Header=BB0_19 Depth=1
	testl	%ecx, %ecx
	jne	.LBB0_35
# %bb.34:                               #   in Loop: Header=BB0_19 Depth=1
	movl	%ebx, (%r13)
.LBB0_35:                               #   in Loop: Header=BB0_19 Depth=1
	movslq	%ebp, %rcx
	movq	8(%rsp), %rdx                   # 8-byte Reload
	movw	%ax, (%rdx,%rcx,2)
	movq	24(%rsp), %rdi
	leaq	40(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB0_37
# %bb.36:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
                                        #   in Loop: Header=BB0_19 Depth=1
	callq	_ZdlPv
.LBB0_37:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        #   in Loop: Header=BB0_19 Depth=1
	incl	%ebp
	leal	1(%r12), %edx
	movq	8(%r14), %rcx
.LBB0_38:                               #   in Loop: Header=BB0_19 Depth=1
	incq	%r12
	cmpq	%rcx, %r12
	jb	.LBB0_19
# %bb.2:                                # %._crit_edge.loopexit
	movslq	%edx, %rdx
	jmp	.LBB0_3
.LBB0_1:
	xorl	%ecx, %ecx
.LBB0_3:                                # %._crit_edge
	subq	%rdx, %rcx
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm
	movq	(%r15), %r15
	callq	__errno_location
	movq	%rax, %r14
	movl	(%rax), %r13d
	movl	$0, (%rax)
	leaq	16(%rsp), %r12
	movq	%r15, %rdi
	movq	%r12, %rsi
	movl	$10, %edx
	callq	__isoc23_strtol
	cmpq	%r15, (%r12)
	je	.LBB0_4
# %bb.9:
	leaq	-2147483648(%rax), %rcx
	movabsq	$-4294967296, %rdx              # imm = 0xFFFFFFFF00000000
	cmpq	%rdx, %rcx
	jb	.LBB0_11
# %bb.10:
	movl	(%r14), %ecx
	cmpl	$34, %ecx
	je	.LBB0_11
# %bb.13:
	testl	%ecx, %ecx
	jne	.LBB0_15
# %bb.14:
	movl	%r13d, (%r14)
.LBB0_15:
	movslq	%ebp, %rcx
	movq	8(%rsp), %rdx                   # 8-byte Reload
	movw	%ax, (%rdx,%rcx,2)
	leaq	40(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB0_17
# %bb.16:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i31
	callq	_ZdlPv
.LBB0_17:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit33
	addq	$56, %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
.LBB0_21:
	.cfi_def_cfa_offset 112
.Ltmp2:
	movl	$.L.str.5, %edi
	callq	_ZSt24__throw_invalid_argumentPKc
.Ltmp3:
# %bb.22:
.LBB0_31:                               # %.critedge.i.i23
.Ltmp0:
	movl	$.L.str.5, %edi
	callq	_ZSt20__throw_out_of_rangePKc
.Ltmp1:
# %bb.32:
.LBB0_4:
.Ltmp7:
	movl	$.L.str.5, %edi
	callq	_ZSt24__throw_invalid_argumentPKc
.Ltmp8:
# %bb.5:
.LBB0_11:                               # %.critedge.i.i
.Ltmp5:
	movl	$.L.str.5, %edi
	callq	_ZSt20__throw_out_of_rangePKc
.Ltmp6:
# %bb.12:
.LBB0_6:
.Ltmp9:
	movq	%rax, %r15
	cmpl	$0, (%r14)
	jne	.LBB0_8
# %bb.7:
	movl	%r13d, (%r14)
.LBB0_8:                                # %_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev.exit.i.i
	leaq	40(%rsp), %rax
	movq	-16(%rax), %rdi
	jmp	.LBB0_26
.LBB0_23:
.Ltmp4:
	movq	%rax, %r15
	cmpl	$0, (%r13)
	jne	.LBB0_25
# %bb.24:
	movl	%ebx, (%r13)
.LBB0_25:                               # %_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev.exit.i.i24
	movq	24(%rsp), %rdi
	leaq	40(%rsp), %rax
.LBB0_26:                               # %_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev.exit.i.i24
	cmpq	%rax, %rdi
	je	.LBB0_28
# %bb.27:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i28
	callq	_ZdlPv
.LBB0_28:
	movq	%r15, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end0:
	.size	_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt, .Lfunc_end0-_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table0:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp2-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp2-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp2                  #   Call between .Ltmp2 and .Ltmp1
	.uleb128 .Ltmp4-.Lfunc_begin0           #     jumps to .Ltmp4
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp7-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp6-.Ltmp7                  #   Call between .Ltmp7 and .Ltmp6
	.uleb128 .Ltmp9-.Lfunc_begin0           #     jumps to .Ltmp9
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Lfunc_end0-.Ltmp6             #   Call between .Ltmp6 and .Lfunc_end0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt # -- Begin function _Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
	.type	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt,@function
_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt: # @_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %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	$584, %rsp                      # imm = 0x248
	.cfi_def_cfa_offset 640
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movq	%rdi, %r15
	leaq	64(%rsp), %r14
	movq	%r14, %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
	movq	(%r15), %rsi
.Ltmp10:
	movq	%r14, %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp11:
# %bb.1:
	leaq	16(%rsp), %rax
	movq	%rax, -16(%rax)
	movq	$0, -8(%rax)
	movb	$0, (%rax)
	xorl	%ebp, %ebp
	leaq	48(%rsp), %r13
	movq	%rsp, %r15
	leaq	32(%rsp), %r12
.LBB1_2:                                # =>This Inner Loop Header: Depth=1
	movq	64(%rsp), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp13:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp14:
# %bb.3:                                # %.noexc
                                        #   in Loop: Header=BB1_2 Depth=1
.Ltmp15:
	movsbl	%al, %edx
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_
.Ltmp16:
# %bb.4:                                #   in Loop: Header=BB1_2 Depth=1
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB1_13
# %bb.5:                                #   in Loop: Header=BB1_2 Depth=1
	movq	%r13, 32(%rsp)
	movq	(%rsp), %rsi
	movq	8(%rsp), %rdx
	addq	%rsi, %rdx
.Ltmp17:
	movq	%r12, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag
.Ltmp18:
# %bb.6:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_.exit
                                        #   in Loop: Header=BB1_2 Depth=1
.Ltmp20:
	movq	%r12, %rdi
	movl	%ebp, %esi
	movq	%rbx, %rdx
	callq	_Z9parseLineNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPt
.Ltmp21:
# %bb.7:                                #   in Loop: Header=BB1_2 Depth=1
	movq	32(%rsp), %rdi
	cmpq	%r13, %rdi
	je	.LBB1_9
# %bb.8:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
                                        #   in Loop: Header=BB1_2 Depth=1
	callq	_ZdlPv
.LBB1_9:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        #   in Loop: Header=BB1_2 Depth=1
	addl	$16, %ebp
	jmp	.LBB1_2
.LBB1_13:
	movq	(%rsp), %rdi
	leaq	16(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB1_15
# %bb.14:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i14
	callq	_ZdlPv
.LBB1_15:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit16
	leaq	64(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	addq	$584, %rsp                      # imm = 0x248
	.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
.LBB1_10:
	.cfi_def_cfa_offset 640
.Ltmp12:
	movq	%rax, %rbx
	jmp	.LBB1_19
.LBB1_11:
.Ltmp22:
	movq	%rax, %rbx
	movq	32(%rsp), %rdi
	cmpq	%r13, %rdi
	je	.LBB1_17
# %bb.12:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i11
	callq	_ZdlPv
	jmp	.LBB1_17
.LBB1_16:
.Ltmp19:
	movq	%rax, %rbx
.LBB1_17:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit13
	movq	(%rsp), %rdi
	leaq	16(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB1_19
# %bb.18:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i17
	callq	_ZdlPv
.LBB1_19:
	leaq	64(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt, .Lfunc_end1-_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Lfunc_begin1-.Lfunc_begin1    # >> Call Site 1 <<
	.uleb128 .Ltmp10-.Lfunc_begin1          #   Call between .Lfunc_begin1 and .Ltmp10
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin1          # >> Call Site 2 <<
	.uleb128 .Ltmp11-.Ltmp10                #   Call between .Ltmp10 and .Ltmp11
	.uleb128 .Ltmp12-.Lfunc_begin1          #     jumps to .Ltmp12
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp13-.Lfunc_begin1          # >> Call Site 3 <<
	.uleb128 .Ltmp18-.Ltmp13                #   Call between .Ltmp13 and .Ltmp18
	.uleb128 .Ltmp19-.Lfunc_begin1          #     jumps to .Ltmp19
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp20-.Lfunc_begin1          # >> Call Site 4 <<
	.uleb128 .Ltmp21-.Ltmp20                #   Call between .Ltmp20 and .Ltmp21
	.uleb128 .Ltmp22-.Lfunc_begin1          #     jumps to .Ltmp22
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp21-.Lfunc_begin1          # >> Call Site 5 <<
	.uleb128 .Lfunc_end1-.Ltmp21            #   Call between .Ltmp21 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end1:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z34__device_stub__calculateDifferencePsPyS_s # -- Begin function _Z34__device_stub__calculateDifferencePsPyS_s
	.type	_Z34__device_stub__calculateDifferencePsPyS_s,@function
_Z34__device_stub__calculateDifferencePsPyS_s: # @_Z34__device_stub__calculateDifferencePsPyS_s
	.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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	6(%rsp), %rdx
	movw	%cx, (%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	$_Z19calculateDifferencePsPyS_s, %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_end2:
	.size	_Z34__device_stub__calculateDifferencePsPyS_s, .Lfunc_end2-_Z34__device_stub__calculateDifferencePsPyS_s
	.cfi_endproc
                                        # -- End function
	.globl	_Z19getNearestNeighborsPsS_Pt   # -- Begin function _Z19getNearestNeighborsPsS_Pt
	.type	_Z19getNearestNeighborsPsS_Pt,@function
_Z19getNearestNeighborsPsS_Pt:          # @_Z19getNearestNeighborsPsS_Pt
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %rbx
	movq	%rsi, 24(%rsp)                  # 8-byte Spill
	movq	%rdi, 16(%rsp)                  # 8-byte Spill
	movabsq	$4294967312, %r12               # imm = 0x100000010
	movl	$8, %edi
	callq	malloc
	movq	%rax, %r13
	leaq	8(%rsp), %rdi
	movl	$8, %esi
	callq	hipMalloc
	leaq	32(%rsp), %rbp
	movq	$-1, (%rbp)
	xorl	%r15d, %r15d
	leaq	18984(%r12), %r14
.LBB3_1:                                # =>This Inner Loop Header: Depth=1
	movq	8(%rsp), %rdi
	movl	$8, %edx
	movq	%rbp, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_3
# %bb.2:                                #   in Loop: Header=BB3_1 Depth=1
	movq	8(%rsp), %rsi
	movswl	%r15w, %ecx
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movq	24(%rsp), %rdx                  # 8-byte Reload
	callq	_Z34__device_stub__calculateDifferencePsPyS_s
.LBB3_3:                                #   in Loop: Header=BB3_1 Depth=1
	movq	8(%rsp), %rsi
	movl	$8, %edx
	movq	%r13, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movzwl	(%r13), %eax
	movw	%ax, (%rbx,%r15,2)
	incq	%r15
	cmpq	$1000, %r15                     # imm = 0x3E8
	jne	.LBB3_1
# %bb.4:
	movq	%r13, %rdi
	callq	free
	movq	8(%rsp), %rdi
	callq	hipFree
	addq	$40, %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_end3:
	.size	_Z19getNearestNeighborsPsS_Pt, .Lfunc_end3-_Z19getNearestNeighborsPsS_Pt
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin2:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception2
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$600, %rsp                      # imm = 0x258
	.cfi_def_cfa_offset 640
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	72(%rsp), %r14
	movq	%r14, -16(%r14)
	movq	_Z12testFilenameB5cxx11(%rip), %rsi
	movq	_Z12testFilenameB5cxx11+8(%rip), %rdx
	addq	%rsi, %rdx
	leaq	56(%rsp), %rbx
	movq	%rbx, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag
.Ltmp23:
	movl	$testLines, %esi
	movq	%rbx, %rdi
	callq	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
.Ltmp24:
# %bb.1:
	movq	56(%rsp), %rdi
	cmpq	%r14, %rdi
	je	.LBB4_3
# %bb.2:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
	callq	_ZdlPv
.LBB4_3:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
	leaq	40(%rsp), %r14
	movq	%r14, -16(%r14)
	movq	_Z13trainFilenameB5cxx11(%rip), %rsi
	movq	_Z13trainFilenameB5cxx11+8(%rip), %rdx
	addq	%rsi, %rdx
	leaq	24(%rsp), %rbx
	movq	%rbx, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag
.Ltmp26:
	movl	$trainLines, %esi
	movq	%rbx, %rdi
	callq	_Z8readFileNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPt
.Ltmp27:
# %bb.4:
	movq	24(%rsp), %rdi
	cmpq	%r14, %rdi
	je	.LBB4_6
# %bb.5:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i19
	callq	_ZdlPv
.LBB4_6:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit21
	movl	$2000, %edi                     # imm = 0x7D0
	callq	malloc
	movq	%rax, %rbx
	leaq	16(%rsp), %r14
	movl	$32000, %esi                    # imm = 0x7D00
	movq	%r14, %rdi
	callq	hipMalloc
	leaq	8(%rsp), %r15
	movl	$608000, %esi                   # imm = 0x94700
	movq	%r15, %rdi
	callq	hipMalloc
	movq	(%r14), %rdi
	movl	$testLines, %esi
	movl	$32000, %edx                    # imm = 0x7D00
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r15), %rdi
	movl	$trainLines, %esi
	movl	$608000, %edx                   # imm = 0x94700
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r15), %rdi
	movq	(%r14), %rsi
	movq	%rbx, %rdx
	callq	_Z19getNearestNeighborsPsS_Pt
	leaq	88(%rsp), %r14
	movq	%r14, %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
	movq	_Z14outputFilenameB5cxx11(%rip), %rsi
.Ltmp29:
	movq	%r14, %rdi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp30:
# %bb.7:                                # %.preheader.preheader
	xorl	%r12d, %r12d
	leaq	88(%rsp), %r14
.LBB4_8:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movzwl	(%rbx,%r12,2), %esi
.Ltmp31:
	movq	%r14, %rdi
	callq	_ZNSo9_M_insertImEERSoT_
.Ltmp32:
# %bb.9:                                # %_ZNSolsEt.exit
                                        #   in Loop: Header=BB4_8 Depth=1
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
.Ltmp33:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp34:
# %bb.10:                               # %.noexc
                                        #   in Loop: Header=BB4_8 Depth=1
.Ltmp35:
	movsbl	%al, %esi
	movq	%r15, %rdi
	callq	_ZNSo3putEc
.Ltmp36:
# %bb.11:                               # %.noexc28
                                        #   in Loop: Header=BB4_8 Depth=1
.Ltmp37:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp38:
# %bb.12:                               # %_ZNSolsEPFRSoS_E.exit
                                        #   in Loop: Header=BB4_8 Depth=1
	incq	%r12
	cmpq	$1000, %r12                     # imm = 0x3E8
	jne	.LBB4_8
# %bb.13:
	movq	%rbx, %rdi
	callq	free
	movq	16(%rsp), %rdi
.Ltmp40:
	callq	hipFree
.Ltmp41:
# %bb.14:
	movq	8(%rsp), %rdi
.Ltmp42:
	callq	hipFree
.Ltmp43:
# %bb.15:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	96(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 88(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	336(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	movl	$1, %eax
	addq	$600, %rsp                      # imm = 0x258
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB4_19:
	.cfi_def_cfa_offset 640
.Ltmp28:
	movq	%rax, %rbx
	movq	24(%rsp), %rdi
	jmp	.LBB4_17
.LBB4_16:
.Ltmp25:
	movq	%rax, %rbx
	movq	56(%rsp), %rdi
.LBB4_17:
	cmpq	%r14, %rdi
	je	.LBB4_23
# %bb.18:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i22
	callq	_ZdlPv
	jmp	.LBB4_23
.LBB4_21:
.Ltmp44:
	jmp	.LBB4_22
.LBB4_20:
.Ltmp39:
.LBB4_22:
	movq	%rax, %rbx
	leaq	88(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
.LBB4_23:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit24
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table4:
.Lexception2:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end2-.Lcst_begin2
.Lcst_begin2:
	.uleb128 .Lfunc_begin2-.Lfunc_begin2    # >> Call Site 1 <<
	.uleb128 .Ltmp23-.Lfunc_begin2          #   Call between .Lfunc_begin2 and .Ltmp23
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp23-.Lfunc_begin2          # >> Call Site 2 <<
	.uleb128 .Ltmp24-.Ltmp23                #   Call between .Ltmp23 and .Ltmp24
	.uleb128 .Ltmp25-.Lfunc_begin2          #     jumps to .Ltmp25
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp24-.Lfunc_begin2          # >> Call Site 3 <<
	.uleb128 .Ltmp26-.Ltmp24                #   Call between .Ltmp24 and .Ltmp26
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp26-.Lfunc_begin2          # >> Call Site 4 <<
	.uleb128 .Ltmp27-.Ltmp26                #   Call between .Ltmp26 and .Ltmp27
	.uleb128 .Ltmp28-.Lfunc_begin2          #     jumps to .Ltmp28
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp27-.Lfunc_begin2          # >> Call Site 5 <<
	.uleb128 .Ltmp29-.Ltmp27                #   Call between .Ltmp27 and .Ltmp29
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp29-.Lfunc_begin2          # >> Call Site 6 <<
	.uleb128 .Ltmp30-.Ltmp29                #   Call between .Ltmp29 and .Ltmp30
	.uleb128 .Ltmp44-.Lfunc_begin2          #     jumps to .Ltmp44
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp31-.Lfunc_begin2          # >> Call Site 7 <<
	.uleb128 .Ltmp38-.Ltmp31                #   Call between .Ltmp31 and .Ltmp38
	.uleb128 .Ltmp39-.Lfunc_begin2          #     jumps to .Ltmp39
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp40-.Lfunc_begin2          # >> Call Site 8 <<
	.uleb128 .Ltmp43-.Ltmp40                #   Call between .Ltmp40 and .Ltmp43
	.uleb128 .Ltmp44-.Lfunc_begin2          #     jumps to .Ltmp44
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp43-.Lfunc_begin2          # >> Call Site 9 <<
	.uleb128 .Lfunc_end4-.Ltmp43            #   Call between .Ltmp43 and .Lfunc_end4
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end2:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbx
	subq	%rsi, %r14
	movq	%r14, (%rsp)
	cmpq	$15, %r14
	jbe	.LBB5_1
# %bb.2:
	movq	%rsp, %r12
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm
	movq	%rax, (%rbx)
	movq	(%r12), %rcx
	movq	%rcx, 16(%rbx)
	jmp	.LBB5_3
.LBB5_1:                                # %._crit_edge
	movq	(%rbx), %rax
.LBB5_3:
	testq	%r14, %r14
	je	.LBB5_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB5_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB5_7
.LBB5_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB5_7:                                # %_ZZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tagEN6_GuardD2Ev.exit
	movq	(%rsp), %rax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rcx
	movb	$0, (%rcx,%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag, .Lfunc_end5-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag
	.cfi_endproc
                                        # -- End function
	.section	.text.startup,"ax",@progbits
	.type	_GLOBAL__sub_I_bfs.hip,@function # -- Begin function _GLOBAL__sub_I_bfs.hip
_GLOBAL__sub_I_bfs.hip:                 # @_GLOBAL__sub_I_bfs.hip
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	$_Z12testFilenameB5cxx11+16, _Z12testFilenameB5cxx11(%rip)
	movabsq	$8392585648475956596, %rax      # imm = 0x7478742E74736574
	movq	%rax, _Z12testFilenameB5cxx11+16(%rip)
	movq	$8, _Z12testFilenameB5cxx11+8(%rip)
	movb	$0, _Z12testFilenameB5cxx11+24(%rip)
	movl	$_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev, %edi
	movl	$_Z12testFilenameB5cxx11, %esi
	movl	$__dso_handle, %edx
	callq	__cxa_atexit
	movq	$_Z13trainFilenameB5cxx11+16, _Z13trainFilenameB5cxx11(%rip)
	movabsq	$8679613433599062644, %rax      # imm = 0x78742E6E69617274
	movq	%rax, _Z13trainFilenameB5cxx11+16(%rip)
	movw	$116, %bx
	movw	%bx, _Z13trainFilenameB5cxx11+24(%rip)
	movl	$9, %r14d
	movq	%r14, _Z13trainFilenameB5cxx11+8(%rip)
	movl	$_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev, %edi
	movl	$_Z13trainFilenameB5cxx11, %esi
	movl	$__dso_handle, %edx
	callq	__cxa_atexit
	movq	$_Z14outputFilenameB5cxx11+16, _Z14outputFilenameB5cxx11(%rip)
	movabsq	$8679613459571112301, %rax      # imm = 0x78742E74756F796D
	movq	%rax, _Z14outputFilenameB5cxx11+16(%rip)
	movw	%bx, _Z14outputFilenameB5cxx11+24(%rip)
	movq	%r14, _Z14outputFilenameB5cxx11+8(%rip)
	movl	$_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev, %edi
	movl	$_Z14outputFilenameB5cxx11, %esi
	movl	$__dso_handle, %edx
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__cxa_atexit                    # TAILCALL
.Lfunc_end6:
	.size	_GLOBAL__sub_I_bfs.hip, .Lfunc_end6-_GLOBAL__sub_I_bfs.hip
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z19calculateDifferencePsPyS_s, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	testLines,@object               # @testLines
	.bss
	.globl	testLines
	.p2align	4, 0x0
testLines:
	.zero	32000
	.size	testLines, 32000

	.type	trainLines,@object              # @trainLines
	.globl	trainLines
	.p2align	4, 0x0
trainLines:
	.zero	608000
	.size	trainLines, 608000

	.type	_Z12testFilenameB5cxx11,@object # @_Z12testFilenameB5cxx11
	.globl	_Z12testFilenameB5cxx11
	.p2align	3, 0x0
_Z12testFilenameB5cxx11:
	.zero	32
	.size	_Z12testFilenameB5cxx11, 32

	.hidden	__dso_handle
	.type	_Z13trainFilenameB5cxx11,@object # @_Z13trainFilenameB5cxx11
	.globl	_Z13trainFilenameB5cxx11
	.p2align	3, 0x0
_Z13trainFilenameB5cxx11:
	.zero	32
	.size	_Z13trainFilenameB5cxx11, 32

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"train.txt"
	.size	.L.str.2, 10

	.type	_Z14outputFilenameB5cxx11,@object # @_Z14outputFilenameB5cxx11
	.bss
	.globl	_Z14outputFilenameB5cxx11
	.p2align	3, 0x0
_Z14outputFilenameB5cxx11:
	.zero	32
	.size	_Z14outputFilenameB5cxx11, 32

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"myout.txt"
	.size	.L.str.4, 10

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

	.type	.L.str.5,@object                # @.str.5
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.5:
	.asciz	"stoi"
	.size	.L.str.5, 5

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z19calculateDifferencePsPyS_s"
	.size	.L__unnamed_1, 31

	.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	_GLOBAL__sub_I_bfs.hip
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.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 __gxx_personality_v0
	.addrsig_sym _Z34__device_stub__calculateDifferencePsPyS_s
	.addrsig_sym _GLOBAL__sub_I_bfs.hip
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym testLines
	.addrsig_sym trainLines
	.addrsig_sym _Z12testFilenameB5cxx11
	.addrsig_sym __dso_handle
	.addrsig_sym _Z13trainFilenameB5cxx11
	.addrsig_sym _Z14outputFilenameB5cxx11
	.addrsig_sym _Z19calculateDifferencePsPyS_s
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z19calculateDifferencePsPyS_s ; -- Begin function _Z19calculateDifferencePsPyS_s
	.globl	_Z19calculateDifferencePsPyS_s
	.p2align	8
	.type	_Z19calculateDifferencePsPyS_s,@function
_Z19calculateDifferencePsPyS_s:         ; @_Z19calculateDifferencePsPyS_s
; %bb.0:
	s_clause 0x2
	s_load_b32 s5, s[0:1], 0x18
	s_load_b64 s[6:7], s[0:1], 0x10
	s_load_b128 s[0:3], s[0:1], 0x0
	v_mov_b32_e32 v2, 0
	s_mov_b32 s4, exec_lo
	ds_store_b32 v2, v2
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_sext_i32_i16 s5, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshl_add_u32 v1, s5, 4, v0
	v_lshlrev_b64 v[3:4], 1, v[1:2]
	v_lshl_add_u32 v1, s15, 4, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[1:2], 1, v[1:2]
	v_add_co_u32 v3, vcc_lo, s6, v3
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v4, vcc_lo, s7, v4, vcc_lo
	v_add_co_u32 v1, vcc_lo, s0, v1
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	s_mov_b32 s0, 0
	global_load_i16 v3, v[3:4], off
	global_load_i16 v1, v[1:2], off
	s_waitcnt vmcnt(0)
	v_sub_nc_u32_e32 v1, v3, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_i32_i24_e32 v1, v1, v1
.LBB0_1:                                ; %ComputeLoop
                                        ; =>This Inner Loop Header: Depth=1
	s_ctz_i32_b32 s1, s4
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_readlane_b32 s5, v1, s1
	s_lshl_b32 s1, 1, s1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_and_not1_b32 s4, s4, s1
	s_add_i32 s0, s0, s5
	s_cmp_lg_u32 s4, 0
	s_cbranch_scc1 .LBB0_1
; %bb.2:                                ; %ComputeEnd
	v_mbcnt_lo_u32_b32 v1, exec_lo, 0
	s_mov_b32 s1, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v1
	s_xor_b32 s1, exec_lo, s1
	s_cbranch_execz .LBB0_4
; %bb.3:
	v_dual_mov_b32 v1, 0 :: v_dual_mov_b32 v2, s0
	ds_add_u32 v1, v2
.LBB0_4:
	s_or_b32 exec_lo, exec_lo, s1
	v_and_b32_e32 v0, 15, v0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_7
; %bb.5:
	v_mbcnt_lo_u32_b32 v0, exec_lo, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_7
; %bb.6:
	v_mov_b32_e32 v2, 0
	v_mov_b32_e32 v0, s15
	ds_load_b32 v1, v2
	s_waitcnt lgkmcnt(0)
	global_atomic_min_u64 v2, v[0:1], s[2:3]
.LBB0_7:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z19calculateDifferencePsPyS_s
		.amdhsa_group_segment_fixed_size 4
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 28
		.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 5
		.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	_Z19calculateDifferencePsPyS_s, .Lfunc_end0-_Z19calculateDifferencePsPyS_s
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 356
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 4 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; 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:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           2
        .value_kind:     by_value
    .group_segment_fixed_size: 4
    .kernarg_segment_align: 8
    .kernarg_segment_size: 28
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z19calculateDifferencePsPyS_s
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z19calculateDifferencePsPyS_s.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
