#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctime>
// Includes CUDA
#include <cuda_runtime.h>

#define LINEWIDTH 20
#define NWORDS 32
#define N_STREAMS 8
#define BLOCK_SIZE 32
#define TITLE_SIZE 1

int length;
int len;
int nwords;
int matches[NWORDS];
char *ctext;
char keywords[NWORDS][LINEWIDTH];
unsigned int  *text;
unsigned int  *words;
float cpuRunTime;

// citation: https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
#define checkCudaErrors(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
   if (code != cudaSuccess) 
   {
      fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}


void intialise(char *input)
{
    nwords = NWORDS;
    printf("-----------\nGoint to read %s\n", input);
    char *line;
	line = (char*) malloc(sizeof(char)*LINEWIDTH);
	memset(matches, 0, sizeof(matches));


	// read in text and keywords for processing
	FILE *fp, *wfile;
	wfile = fopen("./data/keywords.txt","r");
	if (!wfile)
	{	printf("keywords.txt: File not found.\n");	exit(0);}

	int k=0, cnt = nwords;
	size_t read, linelen = LINEWIDTH;
	while((read = getline(&line, &linelen, wfile)) != -1 && cnt--)
	{
		strncpy(keywords[k], line, sizeof(line));
		keywords[k][4] = '\0';
		k++;
	}
	fclose(wfile);


	fp = fopen(input,"r");
	if (!fp)
	{	printf("Unable to open the file.\n");	exit(0);}

	length = 0;
	while (getc(fp) != EOF) length++;
	ctext = (char *)malloc(length+4);

	rewind(fp);

	for (int l=0; l<length; l++) ctext[l] = getc(fp);
	for (int l=length; l<length+4; l++) ctext[l] = ' ';

	fclose(fp);

	printf("Length : %d\n", length );
	// define number of words of text, and set pointers
	len  = length/4;
	text = (unsigned int *) ctext;

	// define words for matching
	words = (unsigned int *)malloc(nwords*sizeof(unsigned int));

	for (int w=0; w<nwords; w++)
	{
		words[w] = ((unsigned int) keywords[w][0])
             + ((unsigned int) keywords[w][1])*(1<<8)
             + ((unsigned int) keywords[w][2])*(1<<16)
             + ((unsigned int) keywords[w][3])*(1<<24);

	}
}

void deinit(){
	free(words);
    free(text);
}

void check_matches(int *temp_matches){
	bool isRight = true;
    for(int i = 0; i<NWORDS; i++) {
		if(matches[i] != temp_matches[i]) {
			isRight = false;
			printf("WRONG OUTPUT:\t %s\t|\t%d\n",  keywords[i], temp_matches[i]);
        }
	}

	if(isRight) {
		printf(" - Correct Answer -\n");
	}
}

void print_matches(int *temp_matches){
    printf("Printing Matches:\n");
	printf("Word\t  |\tNumber of Matches\n===================================\n");
	for (int i = 0; i < nwords; ++i)
		printf("%s\t  |\t%d\n", keywords[i], temp_matches[i]);

}

void matchPattern_CPU(unsigned int *text, unsigned int *words, int *matches, int nwords, int length)
{
	unsigned int word;

	for (int l=0; l<length; l++)
	{
		for (int offset=0; offset<4; offset++)
		{
			if (offset==0)
				word = text[l];
			else
				word = (text[l]>>(8*offset)) + (text[l+1]<<(32-8*offset)); 

			for (int w=0; w<nwords; w++){
				matches[w] += (word==words[w]);
			} 
				
		}
	}
}

void exec_CPU(){
    // CPU execution
	const clock_t begin_time = clock();
	matchPattern_CPU(text, words, matches, nwords, len);
	cpuRunTime = (float)( clock() - begin_time ) /  CLOCKS_PER_SEC;
	printf("CPU exec time: %f s\n\n", cpuRunTime);
}

__global__ void matchPattern_gpu_1(unsigned int *text, unsigned int *words, int *matches, int nwords, int length, int offset_, int which)
{
	int tid = threadIdx.x;
	int idx = offset_ + blockIdx.x * blockDim.x + tid;
	
	// for loading text into the shared memory
	__shared__ unsigned int text_s[NWORDS + 1];
	text_s[tid] = text[idx];
	text_s[NWORDS] = text[offset_ + (blockIdx.x * blockDim.x) + blockDim.x];

	// loads the keyword for this thread
	// each thread in a block is reponsible for one keyword
	unsigned int keyword = words[tid];
	
	__syncthreads();
	
	unsigned int word;
	int sum = 0;
 

		
	#pragma loop unroll
	for(int w = 0; w < NWORDS; w++) {
		#pragma loop unroll
		for (int offset=0; offset<4; offset++)
		{
			word = offset==0 ? text_s[w] : (text_s[w]>>(8*offset)) + (text_s[w+1]<<(32-8*offset)); 
			sum = sum + (word==keyword);
		}
	}

	atomicAdd(&matches[(which*NWORDS)+tid],sum);
}

// citation: https://github.com/NVIDIA-developer-blog/code-samples/blob/master/series/cuda-cpp/overlap-data-transfers/async.cu
void exec_gpu_stream(){

	const int nStreams = N_STREAMS;
	const int streamSize = len / nStreams;
	const int straming_bytes = streamSize * sizeof(unsigned int);

	unsigned int *d_text; unsigned int *d_words; int *d_matches;
	int *h_matches;
	h_matches = (int *)malloc(nwords*sizeof(int)*N_STREAMS);
	memset(h_matches, 0, nwords*sizeof(int)*N_STREAMS);

	cudaStream_t stream[nStreams];
	for (int i = 0; i < nStreams; i++){
		checkCudaErrors( cudaStreamCreate(&stream[i]));
	}

	cudaHostRegister(words,nwords*sizeof(int),0);
	cudaHostRegister(text,strlen(ctext)*sizeof(char),0);
	cudaHostRegister(h_matches,nwords*sizeof(int),0);

	checkCudaErrors(cudaMalloc((void**)&d_words, nwords*sizeof(unsigned int)));
	checkCudaErrors(cudaMalloc((void**)&d_matches, nwords*sizeof(int)*nStreams));
	checkCudaErrors(cudaMalloc((void**)&d_text, sizeof(unsigned int)*len));
		
	cudaEvent_t start, stop;	
	float tiime_ = 0;
	checkCudaErrors( cudaEventCreate(&start) );
	checkCudaErrors( cudaEventCreate(&stop) );

	checkCudaErrors( cudaEventRecord(start,0) );
	checkCudaErrors(cudaMemcpy(d_words, words, nwords*sizeof(unsigned int), cudaMemcpyHostToDevice));
	for (int i = 0; i < nStreams; ++i) 
	{
		int offset = i * streamSize;
		checkCudaErrors(cudaMemcpyAsync(&d_text[offset], &text[offset], straming_bytes, cudaMemcpyHostToDevice, stream[i]));
	}
	
	for (int i = 0; i < nStreams; ++i) 
	{
		int offset = i * streamSize;
		matchPattern_gpu_1<<<ceil(streamSize/(TITLE_SIZE*NWORDS)), NWORDS, 0, stream[i]>>>(d_text, d_words, d_matches, nwords, len, offset, i);
	}

	for (int i = 0; i < nStreams; ++i) 
	{
		int offset = i * streamSize;
		checkCudaErrors(cudaMemcpyAsync(&h_matches[(i*NWORDS)], &d_matches[(i*NWORDS)], NWORDS*sizeof(int), cudaMemcpyDeviceToHost, stream[i]));
	}
	// cudaMemcpy(h_matches, d_matches, nwords*sizeof(int), cudaMemcpyDeviceToHost);
	checkCudaErrors( cudaEventRecord(stop, 0) );
	checkCudaErrors( cudaEventSynchronize(stop) );
	checkCudaErrors( cudaEventElapsedTime(&tiime_, start, stop) );
	  
	printf("Time kernel+memory: %fs\n", tiime_/1000);
	printf("Speedup with memory: %f\n", cpuRunTime/((tiime_)/1000));

	for(int w=0; w < NWORDS; w++)
	{
		for (int i = 1; i < nStreams; ++i)
		{
			h_matches[w] += h_matches[(i*NWORDS) + w];
		}
	}

	check_matches(h_matches);

	// cleanup
	checkCudaErrors( cudaEventDestroy(start) );
	checkCudaErrors( cudaEventDestroy(stop) );

	for (int i = 0; i < nStreams; ++i) {
		checkCudaErrors( cudaStreamDestroy(stream[i]));
	}
	
	cudaHostUnregister(text);
	cudaHostUnregister(words);
	cudaHostUnregister(h_matches);

	cudaFree(d_words);
	cudaFree(d_matches);
	cudaFree(d_text);
	
}
void exec_gpu_simple(){

		// GPU execution
		unsigned int *d_text; unsigned int *d_words; int *d_matches;
		int *h_matches;
		h_matches = (int *)malloc(nwords*sizeof(int));


		checkCudaErrors(cudaMalloc((void**)&d_words, nwords*sizeof(unsigned int)));
		checkCudaErrors(cudaMalloc((void**)&d_matches, nwords*sizeof(int)));
		checkCudaErrors(cudaMalloc((void**)&d_text, sizeof(unsigned int)*len));

		cudaEvent_t start,stop;
		float time_H2D,time_D2H,time_kernel;
		checkCudaErrors(cudaEventCreate(&start));
		checkCudaErrors(cudaEventCreate(&stop));


		// MEMCOPY
		cudaEventRecord(start, 0);
		checkCudaErrors(cudaMemcpy(d_words, words, nwords*sizeof(unsigned int), cudaMemcpyHostToDevice));
		checkCudaErrors(cudaMemcpy(d_text, text, sizeof(unsigned int)*len, cudaMemcpyHostToDevice));
		cudaEventRecord(stop,0);
		cudaEventSynchronize(stop);
		cudaEventElapsedTime(&time_H2D,start,stop);
		printf("HostToDevice memcopy time: %fs\n", time_H2D/1000);

		// RUN KERNEL
		cudaEventRecord(start, 0);
		matchPattern_gpu_1<<< ceil((float)len/(TITLE_SIZE*NWORDS)),NWORDS>>>(d_text, d_words, d_matches, nwords, len, 0, 0);
		cudaEventRecord(stop,0);
		cudaEventSynchronize(stop);
		checkCudaErrors(cudaPeekAtLastError());
		cudaEventElapsedTime(&time_kernel,start,stop);
		printf("Kernel execution time: %fs\n", time_kernel/1000);
		
		cudaEventRecord(start, 0);
		checkCudaErrors(cudaMemcpy(h_matches, d_matches, nwords*sizeof(int), cudaMemcpyDeviceToHost));
		cudaEventRecord(stop,0);
		cudaEventSynchronize(stop);
		cudaEventElapsedTime(&time_D2H,start,stop);
		printf("DeviceToHost memcopy time: %fs\n", time_D2H/1000);

		printf("Total memcopy time: %fs\n", (time_D2H+time_H2D)/1000);
		printf("Total memcopy+kernel time: %fs\n", (time_D2H+time_H2D+time_kernel)/1000);
		
		printf("Speedup without memory: %f\n", cpuRunTime/((time_kernel)/1000));
		printf("Speedup with memory: %f\n", cpuRunTime/((time_D2H + time_H2D + time_kernel)/1000));
		
		check_matches(h_matches);

		cudaEventDestroy(start);
		cudaEventDestroy(stop);

	    free(h_matches);
		cudaFree(d_words);
		cudaFree(d_matches);
		cudaFree(d_text);
}

int main(int argc, const char **argv)
{

	intialise("./data/small.txt");
    exec_CPU();
	exec_gpu_stream();

	intialise("./data/medium.txt");
    exec_CPU();
	exec_gpu_stream();

    intialise("./data/large.txt");
    exec_CPU();
	exec_gpu_stream();

	deinit();
	
}

	.file	"tmpxft_002bc392_00000000-6_pattern_streams.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2039:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2039:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._Z9gpuAssert9cudaErrorPKcib.str1.1,"aMS",@progbits,1
.LC0:
	.string	"GPUassert: %s %s %d\n"
	.section	.text._Z9gpuAssert9cudaErrorPKcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPKcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPKcib
	.type	_Z9gpuAssert9cudaErrorPKcib, @function
_Z9gpuAssert9cudaErrorPKcib:
.LFB2027:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L8
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r9d
	movq	(%rsp), %r8
	leaq	.LC0(%rip), %rdx
	movq	stderr(%rip), %rdi
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	testb	%bpl, %bpl
	je	.L2
	movl	%ebx, %edi
	call	exit@PLT
.L2:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z9gpuAssert9cudaErrorPKcib, .-_Z9gpuAssert9cudaErrorPKcib
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"-----------\nGoint to read %s\n"
.LC2:
	.string	"r"
.LC3:
	.string	"./data/keywords.txt"
.LC4:
	.string	"keywords.txt: File not found.\n"
.LC5:
	.string	"Unable to open the file.\n"
.LC6:
	.string	"Length : %d\n"
	.text
	.globl	_Z9intialisePc
	.type	_Z9intialisePc, @function
_Z9intialisePc:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %rdx
	leaq	.LC1(%rip), %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	movl	$2, %edi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movl	$32, nwords(%rip)
	call	__printf_chk@PLT
	movl	$20, %edi
	call	malloc@PLT
	leaq	matches(%rip), %rdx
	movl	$32, %ecx
	movq	%r14, %rsi
	movq	%rax, 24(%rsp)
	movq	%rdx, %rdi
	xorl	%eax, %eax
	rep stosl
	leaq	.LC3(%rip), %rdi
	call	fopen@PLT
	leaq	.LC4(%rip), %rsi
	testq	%rax, %rax
	je	.L34
	leaq	keywords(%rip), %rbx
	movl	nwords(%rip), %r13d
	movq	%rax, %rbp
	leaq	32(%rsp), %r15
	movq	$20, 32(%rsp)
	movq	%rbx, %r12
.L15:
	leaq	24(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r15, %rsi
	call	getline@PLT
	incq	%rax
	je	.L14
	testl	%r13d, %r13d
	je	.L14
	movq	24(%rsp), %rsi
	movq	%r12, %rdi
	movl	$8, %edx
	decl	%r13d
	leaq	640(%rbx), %rcx
	subq	%r12, %rcx
	addq	$20, %r12
	call	__strncpy_chk@PLT
	movb	$0, -16(%r12)
	jmp	.L15
.L14:
	movq	%rbp, %rdi
	call	fclose@PLT
	movq	8(%rsp), %rdi
	movq	%r14, %rsi
	call	fopen@PLT
	xorl	%edi, %edi
	movq	%rax, %rbp
	testq	%rax, %rax
	jne	.L16
	leaq	.LC5(%rip), %rsi
.L34:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L16:
	movl	%edi, length(%rip)
	movq	%rbp, %rdi
	call	getc@PLT
	movl	length(%rip), %edi
	incl	%eax
	je	.L35
	incl	%edi
	jmp	.L16
.L35:
	addl	$4, %edi
	xorl	%r12d, %r12d
	movslq	%edi, %rdi
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, ctext(%rip)
	call	rewind@PLT
.L18:
	movl	length(%rip), %eax
	cmpl	%r12d, %eax
	jle	.L36
	movq	%rbp, %rdi
	call	getc@PLT
	movq	ctext(%rip), %rdx
	movb	%al, (%rdx,%r12)
	incq	%r12
	jmp	.L18
.L36:
	movslq	%eax, %rcx
.L20:
	movl	length(%rip), %esi
	leal	3(%rsi), %edx
	cmpl	%eax, %edx
	jl	.L37
	movq	ctext(%rip), %rdx
	incl	%eax
	movb	$32, (%rdx,%rcx)
	incq	%rcx
	jmp	.L20
.L37:
	movq	%rbp, %rdi
	call	fclose@PLT
	movl	length(%rip), %edx
	leaq	.LC6(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	length(%rip), %eax
	movl	$4, %ecx
	movslq	nwords(%rip), %rdi
	cltd
	movq	%rdi, %rbp
	salq	$2, %rdi
	idivl	%ecx
	movl	%eax, len(%rip)
	movq	ctext(%rip), %rax
	movq	%rax, text(%rip)
	call	malloc@PLT
	xorl	%ecx, %ecx
	movq	%rax, words(%rip)
.L22:
	cmpl	%ecx, %ebp
	jle	.L38
	movsbl	3(%rbx), %edx
	movsbl	2(%rbx), %esi
	addq	$20, %rbx
	sall	$8, %edx
	addl	%esi, %edx
	movsbl	-19(%rbx), %esi
	sall	$8, %edx
	addl	%esi, %edx
	movsbl	-20(%rbx), %esi
	sall	$8, %edx
	addl	%esi, %edx
	movl	%edx, (%rax,%rcx,4)
	incq	%rcx
	jmp	.L22
.L38:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	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
.LFE2028:
	.size	_Z9intialisePc, .-_Z9intialisePc
	.globl	_Z6deinitv
	.type	_Z6deinitv, @function
_Z6deinitv:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	words(%rip), %rdi
	call	free@PLT
	movq	text(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z6deinitv, .-_Z6deinitv
	.section	.rodata.str1.1
.LC7:
	.string	"WRONG OUTPUT:\t %s\t|\t%d\n"
.LC8:
	.string	" - Correct Answer -\n"
	.text
	.globl	_Z13check_matchesPi
	.type	_Z13check_matchesPi, @function
_Z13check_matchesPi:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movb	$1, %al
	leaq	matches(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
.L43:
	movl	0(%rbp,%rbx), %ecx
	cmpl	%ecx, (%r12,%rbx)
	je	.L42
	leaq	keywords(%rip), %rax
	leaq	(%rbx,%rbx,4), %rdx
	movl	$2, %edi
	addq	%rax, %rdx
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
.L42:
	addq	$4, %rbx
	cmpq	$128, %rbx
	jne	.L43
	testb	%al, %al
	je	.L41
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	$2, %edi
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
.L41:
	.cfi_restore_state
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z13check_matchesPi, .-_Z13check_matchesPi
	.section	.rodata.str1.1
.LC9:
	.string	"Printing Matches:\n"
.LC10:
	.string	"Word\t  |\tNumber of Matches\n===================================\n"
.LC11:
	.string	"%s\t  |\t%d\n"
	.text
	.globl	_Z13print_matchesPi
	.type	_Z13print_matchesPi, @function
_Z13print_matchesPi:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC9(%rip), %rsi
	xorl	%eax, %eax
	leaq	keywords(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	movl	$2, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	call	__printf_chk@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L48:
	cmpl	%ebx, nwords(%rip)
	jle	.L51
	imulq	$20, %rbx, %rdx
	movl	0(%rbp,%rbx,4), %ecx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC11(%rip), %rsi
	incq	%rbx
	addq	%r12, %rdx
	call	__printf_chk@PLT
	jmp	.L48
.L51:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z13print_matchesPi, .-_Z13print_matchesPi
	.globl	_Z16matchPattern_CPUPjS_Piii
	.type	_Z16matchPattern_CPUPjS_Piii, @function
_Z16matchPattern_CPUPjS_Piii:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r10
	movl	%ecx, %r11d
	movq	%rdx, %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	xorl	%eax, %eax
	movl	$32, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
.L53:
	cmpl	%eax, %r8d
	jle	.L60
	movl	(%rdi,%rax,4), %edx
	xorl	%r9d, %r9d
	xorl	%ebx, %ebx
.L57:
	xorl	%ecx, %ecx
.L54:
	cmpl	%ecx, %r11d
	jle	.L61
	xorl	%r12d, %r12d
	cmpl	%edx, (%r10,%rcx,4)
	sete	%r12b
	addl	%r12d, (%rsi,%rcx,4)
	incq	%rcx
	jmp	.L54
.L61:
	incl	%ebx
	addl	$8, %r9d
	cmpl	$4, %ebx
	je	.L56
	movl	4(%rdi,%rax,4), %edx
	movl	%ebp, %ecx
	movl	(%rdi,%rax,4), %r12d
	subl	%r9d, %ecx
	sall	%cl, %edx
	movl	%r9d, %ecx
	shrl	%cl, %r12d
	addl	%r12d, %edx
	jmp	.L57
.L56:
	incq	%rax
	jmp	.L53
.L60:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z16matchPattern_CPUPjS_Piii, .-_Z16matchPattern_CPUPjS_Piii
	.section	.rodata.str1.1
.LC13:
	.string	"CPU exec time: %f s\n\n"
	.text
	.globl	_Z8exec_CPUv
	.type	_Z8exec_CPUv, @function
_Z8exec_CPUv:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	call	clock@PLT
	movq	words(%rip), %rsi
	movq	text(%rip), %rdi
	leaq	matches(%rip), %rdx
	movl	len(%rip), %r8d
	movl	nwords(%rip), %ecx
	movq	%rax, %rbx
	call	_Z16matchPattern_CPUPjS_Piii
	call	clock@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	subq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 8
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC12(%rip), %xmm0
	movss	%xmm0, cpuRunTime(%rip)
	cvtss2sd	%xmm0, %xmm0
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2033:
	.size	_Z8exec_CPUv, .-_Z8exec_CPUv
	.globl	_Z46__device_stub__Z18matchPattern_gpu_1PjS_PiiiiiPjS_Piiiii
	.type	_Z46__device_stub__Z18matchPattern_gpu_1PjS_PiiiiiPjS_Piiiii, @function
_Z46__device_stub__Z18matchPattern_gpu_1PjS_PiiiiiPjS_Piiiii:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	56(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L64
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z18matchPattern_gpu_1PjS_Piiiii(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L64:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L66
	call	__stack_chk_fail@PLT
.L66:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z46__device_stub__Z18matchPattern_gpu_1PjS_PiiiiiPjS_Piiiii, .-_Z46__device_stub__Z18matchPattern_gpu_1PjS_PiiiiiPjS_Piiiii
	.globl	_Z18matchPattern_gpu_1PjS_Piiiii
	.type	_Z18matchPattern_gpu_1PjS_Piiiii, @function
_Z18matchPattern_gpu_1PjS_Piiiii:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z46__device_stub__Z18matchPattern_gpu_1PjS_PiiiiiPjS_Piiiii
	.cfi_endproc
.LFE2062:
	.size	_Z18matchPattern_gpu_1PjS_Piiiii, .-_Z18matchPattern_gpu_1PjS_Piiiii
	.section	.rodata.str1.1
.LC14:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/sedflix/cuda_pattern_matching/master/pattern_streams.cu"
.LC16:
	.string	"HostToDevice memcopy time: %fs\n"
.LC18:
	.string	"Kernel execution time: %fs\n"
.LC19:
	.string	"DeviceToHost memcopy time: %fs\n"
.LC20:
	.string	"Total memcopy time: %fs\n"
.LC21:
	.string	"Total memcopy+kernel time: %fs\n"
.LC22:
	.string	"Speedup without memory: %f\n"
.LC23:
	.string	"Speedup with memory: %f\n"
	.text
	.globl	_Z15exec_gpu_simplev
	.type	_Z15exec_gpu_simplev, @function
_Z15exec_gpu_simplev:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movabsq	$4294967328, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$80, %rsp
	.cfi_def_cfa_offset 112
	movslq	nwords(%rip), %rbx
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	salq	$2, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	16(%rsp), %rdi
	leaq	.LC14(%rip), %rbx
	movq	%rax, %rbp
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$278, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movslq	nwords(%rip), %rsi
	leaq	24(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$279, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movslq	len(%rip), %rsi
	leaq	8(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$280, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$1, %ecx
	movl	$284, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$1, %ecx
	movl	$285, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movslq	nwords(%rip), %rdx
	movq	words(%rip), %rsi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$290, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movslq	len(%rip), %rdx
	movq	text(%rip), %rsi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$291, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	4(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	4(%rsp), %xmm0
	divss	.LC15(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	cvtsi2ssl	len(%rip), %xmm0
	mulss	.LC17(%rip), %xmm0
	movq	%r12, 60(%rsp)
	movl	$1, 68(%rsp)
	call	ceilf@PLT
	xorl	%r9d, %r9d
	movq	%r12, %rdx
	xorl	%r8d, %r8d
	cvttss2siq	%xmm0, %rax
	movl	$1, %ecx
	movl	%eax, 48(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L70
	pushq	%rax
	.cfi_def_cfa_offset 120
	movl	nwords(%rip), %ecx
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 128
	movl	len(%rip), %r8d
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z46__device_stub__Z18matchPattern_gpu_1PjS_PiiiiiPjS_Piiiii
	popq	%rdx
	.cfi_def_cfa_offset 120
	popq	%rcx
	.cfi_def_cfa_offset 112
.L70:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	call	cudaPeekAtLastError@PLT
	movl	$1, %ecx
	movl	$302, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	60(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	60(%rsp), %xmm0
	divss	.LC15(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movslq	nwords(%rip), %rdx
	movq	24(%rsp), %rsi
	movq	%rbp, %rdi
	movl	$2, %ecx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$307, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	48(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	48(%rsp), %xmm0
	divss	.LC15(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	leaq	.LC20(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	48(%rsp), %xmm0
	addss	4(%rsp), %xmm0
	divss	.LC15(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	leaq	.LC21(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	48(%rsp), %xmm0
	addss	4(%rsp), %xmm0
	addss	60(%rsp), %xmm0
	divss	.LC15(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movss	cpuRunTime(%rip), %xmm0
	movss	60(%rsp), %xmm1
	movb	$1, %al
	divss	.LC15(%rip), %xmm1
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	movss	cpuRunTime(%rip), %xmm0
	movss	48(%rsp), %xmm1
	leaq	.LC23(%rip), %rsi
	addss	4(%rsp), %xmm1
	addss	60(%rsp), %xmm1
	divss	.LC15(%rip), %xmm1
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	_Z13check_matchesPi
	movq	32(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	40(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L71
	call	__stack_chk_fail@PLT
.L71:
	addq	$80, %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
.LFE2035:
	.size	_Z15exec_gpu_simplev, .-_Z15exec_gpu_simplev
	.section	.rodata.str1.1
.LC25:
	.string	"Time kernel+memory: %fs\n"
	.text
	.globl	_Z15exec_gpu_streamv
	.type	_Z15exec_gpu_streamv, @function
_Z15exec_gpu_streamv:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$8, %ecx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	movslq	nwords(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	movl	len(%rip), %eax
	leaq	88(%rsp), %r13
	leaq	152(%rsp), %rbp
	salq	$5, %r12
	movq	%r12, %rdi
	cltd
	movl	%eax, 4(%rsp)
	idivl	%ecx
	movl	%eax, %r14d
	leal	0(,%rax,4), %r15d
	call	malloc@PLT
	movq	%r12, %rcx
	movq	%r12, %rdx
	xorl	%esi, %esi
	movq	%rax, %rdi
	movq	%rax, %rbx
	movq	%r13, %r12
	call	__memset_chk@PLT
.L74:
	movq	%r13, %rdi
	addq	$8, %r13
	call	cudaStreamCreate@PLT
	movl	$1, %ecx
	movl	$200, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	cmpq	%rbp, %r13
	jne	.L74
	movslq	nwords(%rip), %rsi
	xorl	%edx, %edx
	movslq	%r14d, %r13
	xorl	%ebp, %ebp
	movq	words(%rip), %rdi
	movslq	%r15d, %r15
	salq	$2, %rsi
	call	cudaHostRegister@PLT
	movq	ctext(%rip), %rdi
	call	strlen@PLT
	movq	text(%rip), %rdi
	xorl	%edx, %edx
	movq	%rax, %rsi
	call	cudaHostRegister@PLT
	movslq	nwords(%rip), %rsi
	xorl	%edx, %edx
	movq	%rbx, %rdi
	salq	$2, %rsi
	call	cudaHostRegister@PLT
	movslq	nwords(%rip), %rsi
	leaq	32(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$207, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movslq	nwords(%rip), %rsi
	leaq	40(%rsp), %rdi
	salq	$5, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$208, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movslq	len(%rip), %rsi
	leaq	24(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$209, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	48(%rsp), %rdi
	movl	$0x00000000, 20(%rsp)
	call	cudaEventCreate@PLT
	movl	$1, %ecx
	movl	$213, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$1, %ecx
	movl	$214, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$1, %ecx
	movl	$216, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movslq	nwords(%rip), %rdx
	movq	words(%rip), %rsi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$217, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	0(,%r13,4), %rax
	xorl	%r13d, %r13d
	movq	%rax, 8(%rsp)
.L75:
	movq	text(%rip), %rsi
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%r15, %rdx
	movq	(%r12,%rbp,8), %r8
	incq	%rbp
	addq	%r13, %rsi
	addq	%r13, %rdi
	call	cudaMemcpyAsync@PLT
	movl	$1, %ecx
	movl	$221, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	8(%rsp), %rax
	addq	%rax, %r13
	cmpq	$8, %rbp
	jne	.L75
	movl	4(%rsp), %eax
	movl	$256, %ecx
	xorl	%r13d, %r13d
	xorl	%ebp, %ebp
	movabsq	$4294967328, %r15
	cltd
	idivl	%ecx
	movl	%eax, 4(%rsp)
.L77:
	movl	4(%rsp), %eax
	movq	(%r12,%rbp,8), %r9
	xorl	%r8d, %r8d
	movq	%r15, %rdx
	movl	$1, %ecx
	movq	%r15, 76(%rsp)
	movl	%eax, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	movl	$1, 84(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L76
	pushq	%rax
	.cfi_def_cfa_offset 232
	movl	nwords(%rip), %ecx
	movl	%r13d, %r9d
	pushq	%rbp
	.cfi_def_cfa_offset 240
	movl	len(%rip), %r8d
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z46__device_stub__Z18matchPattern_gpu_1PjS_PiiiiiPjS_Piiiii
	popq	%rdx
	.cfi_def_cfa_offset 232
	popq	%rcx
	.cfi_def_cfa_offset 224
.L76:
	incq	%rbp
	addl	%r14d, %r13d
	cmpq	$8, %rbp
	jne	.L77
	xorl	%r13d, %r13d
.L78:
	movq	40(%rsp), %rsi
	movq	%r13, %rdi
	movq	(%r12,%r13,8), %r8
	incq	%r13
	salq	$7, %rdi
	movl	$2, %ecx
	movl	$128, %edx
	movq	%rbx, %rbp
	addq	%rdi, %rsi
	addq	%rbx, %rdi
	call	cudaMemcpyAsync@PLT
	movl	$1, %ecx
	movl	$233, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	cmpq	$8, %r13
	jne	.L78
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$1, %ecx
	movl	$236, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	$1, %ecx
	movl	$237, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	leaq	20(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movl	$1, %ecx
	movl	$238, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	.LC25(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	20(%rsp), %xmm0
	divss	.LC15(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movss	cpuRunTime(%rip), %xmm0
	movss	20(%rsp), %xmm1
	movb	$1, %al
	divss	.LC15(%rip), %xmm1
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	xorl	%ecx, %ecx
.L79:
	movq	%rbp, %rdx
	movl	$1, %eax
.L80:
	incl	%eax
	movl	128(%rdx), %esi
	subq	$-128, %rdx
	addl	%esi, 0(%rbp)
	cmpl	$8, %eax
	jne	.L80
	incl	%ecx
	addq	$4, %rbp
	cmpl	$32, %ecx
	jne	.L79
	movq	%rbx, %rdi
	xorl	%ebp, %ebp
	call	_Z13check_matchesPi
	movq	48(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	$1, %ecx
	movl	$254, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	56(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	$1, %ecx
	movl	$255, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
.L82:
	movq	(%r12,%rbp,8), %rdi
	incq	%rbp
	call	cudaStreamDestroy@PLT
	movl	$1, %ecx
	movl	$258, %edx
	leaq	.LC14(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	cmpq	$8, %rbp
	jne	.L82
	movq	text(%rip), %rdi
	call	cudaHostUnregister@PLT
	movq	words(%rip), %rdi
	call	cudaHostUnregister@PLT
	movq	%rbx, %rdi
	call	cudaHostUnregister@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L83
	call	__stack_chk_fail@PLT
.L83:
	addq	$168, %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
.LFE2034:
	.size	_Z15exec_gpu_streamv, .-_Z15exec_gpu_streamv
	.section	.rodata.str1.1
.LC26:
	.string	"./data/small.txt"
.LC27:
	.string	"./data/medium.txt"
.LC28:
	.string	"./data/large.txt"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC26(%rip), %rdi
	call	_Z9intialisePc
	call	_Z8exec_CPUv
	call	_Z15exec_gpu_streamv
	leaq	.LC27(%rip), %rdi
	call	_Z9intialisePc
	call	_Z8exec_CPUv
	call	_Z15exec_gpu_streamv
	leaq	.LC28(%rip), %rdi
	call	_Z9intialisePc
	call	_Z8exec_CPUv
	call	_Z15exec_gpu_streamv
	call	_Z6deinitv
	xorl	%eax, %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	main, .-main
	.section	.rodata.str1.1
.LC29:
	.string	"_Z18matchPattern_gpu_1PjS_Piiiii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.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	.LC29(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z18matchPattern_gpu_1PjS_Piiiii(%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
.LFE2064:
	.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
	.globl	cpuRunTime
	.bss
	.align 4
	.type	cpuRunTime, @object
	.size	cpuRunTime, 4
cpuRunTime:
	.zero	4
	.globl	words
	.align 8
	.type	words, @object
	.size	words, 8
words:
	.zero	8
	.globl	text
	.align 8
	.type	text, @object
	.size	text, 8
text:
	.zero	8
	.globl	keywords
	.align 32
	.type	keywords, @object
	.size	keywords, 640
keywords:
	.zero	640
	.globl	ctext
	.align 8
	.type	ctext, @object
	.size	ctext, 8
ctext:
	.zero	8
	.globl	matches
	.align 32
	.type	matches, @object
	.size	matches, 128
matches:
	.zero	128
	.globl	nwords
	.align 4
	.type	nwords, @object
	.size	nwords, 4
nwords:
	.zero	4
	.globl	len
	.align 4
	.type	len, @object
	.size	len, 4
len:
	.zero	4
	.globl	length
	.align 4
	.type	length, @object
	.size	length, 4
length:
	.zero	4
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC12:
	.long	1232348160
	.align 4
.LC15:
	.long	1148846080
	.align 4
.LC17:
	.long	1023410176
	.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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctime>
// Includes CUDA
#include <hip/hip_runtime.h>

#define LINEWIDTH 20
#define NWORDS 32
#define N_STREAMS 8
#define BLOCK_SIZE 32
#define TITLE_SIZE 1

int length;
int len;
int nwords;
int matches[NWORDS];
char *ctext;
char keywords[NWORDS][LINEWIDTH];
unsigned int  *text;
unsigned int  *words;
float cpuRunTime;

// citation: https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
#define checkCudaErrors(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true)
{
   if (code != hipSuccess) 
   {
      fprintf(stderr,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}


void intialise(char *input)
{
    nwords = NWORDS;
    printf("-----------\nGoint to read %s\n", input);
    char *line;
	line = (char*) malloc(sizeof(char)*LINEWIDTH);
	memset(matches, 0, sizeof(matches));


	// read in text and keywords for processing
	FILE *fp, *wfile;
	wfile = fopen("./data/keywords.txt","r");
	if (!wfile)
	{	printf("keywords.txt: File not found.\n");	exit(0);}

	int k=0, cnt = nwords;
	size_t read, linelen = LINEWIDTH;
	while((read = getline(&line, &linelen, wfile)) != -1 && cnt--)
	{
		strncpy(keywords[k], line, sizeof(line));
		keywords[k][4] = '\0';
		k++;
	}
	fclose(wfile);


	fp = fopen(input,"r");
	if (!fp)
	{	printf("Unable to open the file.\n");	exit(0);}

	length = 0;
	while (getc(fp) != EOF) length++;
	ctext = (char *)malloc(length+4);

	rewind(fp);

	for (int l=0; l<length; l++) ctext[l] = getc(fp);
	for (int l=length; l<length+4; l++) ctext[l] = ' ';

	fclose(fp);

	printf("Length : %d\n", length );
	// define number of words of text, and set pointers
	len  = length/4;
	text = (unsigned int *) ctext;

	// define words for matching
	words = (unsigned int *)malloc(nwords*sizeof(unsigned int));

	for (int w=0; w<nwords; w++)
	{
		words[w] = ((unsigned int) keywords[w][0])
             + ((unsigned int) keywords[w][1])*(1<<8)
             + ((unsigned int) keywords[w][2])*(1<<16)
             + ((unsigned int) keywords[w][3])*(1<<24);

	}
}

void deinit(){
	free(words);
    free(text);
}

void check_matches(int *temp_matches){
	bool isRight = true;
    for(int i = 0; i<NWORDS; i++) {
		if(matches[i] != temp_matches[i]) {
			isRight = false;
			printf("WRONG OUTPUT:\t %s\t|\t%d\n",  keywords[i], temp_matches[i]);
        }
	}

	if(isRight) {
		printf(" - Correct Answer -\n");
	}
}

void print_matches(int *temp_matches){
    printf("Printing Matches:\n");
	printf("Word\t  |\tNumber of Matches\n===================================\n");
	for (int i = 0; i < nwords; ++i)
		printf("%s\t  |\t%d\n", keywords[i], temp_matches[i]);

}

void matchPattern_CPU(unsigned int *text, unsigned int *words, int *matches, int nwords, int length)
{
	unsigned int word;

	for (int l=0; l<length; l++)
	{
		for (int offset=0; offset<4; offset++)
		{
			if (offset==0)
				word = text[l];
			else
				word = (text[l]>>(8*offset)) + (text[l+1]<<(32-8*offset)); 

			for (int w=0; w<nwords; w++){
				matches[w] += (word==words[w]);
			} 
				
		}
	}
}

void exec_CPU(){
    // CPU execution
	const clock_t begin_time = clock();
	matchPattern_CPU(text, words, matches, nwords, len);
	cpuRunTime = (float)( clock() - begin_time ) /  CLOCKS_PER_SEC;
	printf("CPU exec time: %f s\n\n", cpuRunTime);
}

__global__ void matchPattern_gpu_1(unsigned int *text, unsigned int *words, int *matches, int nwords, int length, int offset_, int which)
{
	int tid = threadIdx.x;
	int idx = offset_ + blockIdx.x * blockDim.x + tid;
	
	// for loading text into the shared memory
	__shared__ unsigned int text_s[NWORDS + 1];
	text_s[tid] = text[idx];
	text_s[NWORDS] = text[offset_ + (blockIdx.x * blockDim.x) + blockDim.x];

	// loads the keyword for this thread
	// each thread in a block is reponsible for one keyword
	unsigned int keyword = words[tid];
	
	__syncthreads();
	
	unsigned int word;
	int sum = 0;
 

		
	#pragma loop unroll
	for(int w = 0; w < NWORDS; w++) {
		#pragma loop unroll
		for (int offset=0; offset<4; offset++)
		{
			word = offset==0 ? text_s[w] : (text_s[w]>>(8*offset)) + (text_s[w+1]<<(32-8*offset)); 
			sum = sum + (word==keyword);
		}
	}

	atomicAdd(&matches[(which*NWORDS)+tid],sum);
}

// citation: https://github.com/NVIDIA-developer-blog/code-samples/blob/master/series/cuda-cpp/overlap-data-transfers/async.cu
void exec_gpu_stream(){

	const int nStreams = N_STREAMS;
	const int streamSize = len / nStreams;
	const int straming_bytes = streamSize * sizeof(unsigned int);

	unsigned int *d_text; unsigned int *d_words; int *d_matches;
	int *h_matches;
	h_matches = (int *)malloc(nwords*sizeof(int)*N_STREAMS);
	memset(h_matches, 0, nwords*sizeof(int)*N_STREAMS);

	hipStream_t stream[nStreams];
	for (int i = 0; i < nStreams; i++){
		checkCudaErrors( hipStreamCreate(&stream[i]));
	}

	hipHostRegister(words,nwords*sizeof(int),0);
	hipHostRegister(text,strlen(ctext)*sizeof(char),0);
	hipHostRegister(h_matches,nwords*sizeof(int),0);

	checkCudaErrors(hipMalloc((void**)&d_words, nwords*sizeof(unsigned int)));
	checkCudaErrors(hipMalloc((void**)&d_matches, nwords*sizeof(int)*nStreams));
	checkCudaErrors(hipMalloc((void**)&d_text, sizeof(unsigned int)*len));
		
	hipEvent_t start, stop;	
	float tiime_ = 0;
	checkCudaErrors( hipEventCreate(&start) );
	checkCudaErrors( hipEventCreate(&stop) );

	checkCudaErrors( hipEventRecord(start,0) );
	checkCudaErrors(hipMemcpy(d_words, words, nwords*sizeof(unsigned int), hipMemcpyHostToDevice));
	for (int i = 0; i < nStreams; ++i) 
	{
		int offset = i * streamSize;
		checkCudaErrors(hipMemcpyAsync(&d_text[offset], &text[offset], straming_bytes, hipMemcpyHostToDevice, stream[i]));
	}
	
	for (int i = 0; i < nStreams; ++i) 
	{
		int offset = i * streamSize;
		matchPattern_gpu_1<<<ceil(streamSize/(TITLE_SIZE*NWORDS)), NWORDS, 0, stream[i]>>>(d_text, d_words, d_matches, nwords, len, offset, i);
	}

	for (int i = 0; i < nStreams; ++i) 
	{
		int offset = i * streamSize;
		checkCudaErrors(hipMemcpyAsync(&h_matches[(i*NWORDS)], &d_matches[(i*NWORDS)], NWORDS*sizeof(int), hipMemcpyDeviceToHost, stream[i]));
	}
	// cudaMemcpy(h_matches, d_matches, nwords*sizeof(int), cudaMemcpyDeviceToHost);
	checkCudaErrors( hipEventRecord(stop, 0) );
	checkCudaErrors( hipEventSynchronize(stop) );
	checkCudaErrors( hipEventElapsedTime(&tiime_, start, stop) );
	  
	printf("Time kernel+memory: %fs\n", tiime_/1000);
	printf("Speedup with memory: %f\n", cpuRunTime/((tiime_)/1000));

	for(int w=0; w < NWORDS; w++)
	{
		for (int i = 1; i < nStreams; ++i)
		{
			h_matches[w] += h_matches[(i*NWORDS) + w];
		}
	}

	check_matches(h_matches);

	// cleanup
	checkCudaErrors( hipEventDestroy(start) );
	checkCudaErrors( hipEventDestroy(stop) );

	for (int i = 0; i < nStreams; ++i) {
		checkCudaErrors( hipStreamDestroy(stream[i]));
	}
	
	hipHostUnregister(text);
	hipHostUnregister(words);
	hipHostUnregister(h_matches);

	hipFree(d_words);
	hipFree(d_matches);
	hipFree(d_text);
	
}
void exec_gpu_simple(){

		// GPU execution
		unsigned int *d_text; unsigned int *d_words; int *d_matches;
		int *h_matches;
		h_matches = (int *)malloc(nwords*sizeof(int));


		checkCudaErrors(hipMalloc((void**)&d_words, nwords*sizeof(unsigned int)));
		checkCudaErrors(hipMalloc((void**)&d_matches, nwords*sizeof(int)));
		checkCudaErrors(hipMalloc((void**)&d_text, sizeof(unsigned int)*len));

		hipEvent_t start,stop;
		float time_H2D,time_D2H,time_kernel;
		checkCudaErrors(hipEventCreate(&start));
		checkCudaErrors(hipEventCreate(&stop));


		// MEMCOPY
		hipEventRecord(start, 0);
		checkCudaErrors(hipMemcpy(d_words, words, nwords*sizeof(unsigned int), hipMemcpyHostToDevice));
		checkCudaErrors(hipMemcpy(d_text, text, sizeof(unsigned int)*len, hipMemcpyHostToDevice));
		hipEventRecord(stop,0);
		hipEventSynchronize(stop);
		hipEventElapsedTime(&time_H2D,start,stop);
		printf("HostToDevice memcopy time: %fs\n", time_H2D/1000);

		// RUN KERNEL
		hipEventRecord(start, 0);
		matchPattern_gpu_1<<< ceil((float)len/(TITLE_SIZE*NWORDS)),NWORDS>>>(d_text, d_words, d_matches, nwords, len, 0, 0);
		hipEventRecord(stop,0);
		hipEventSynchronize(stop);
		checkCudaErrors(hipPeekAtLastError());
		hipEventElapsedTime(&time_kernel,start,stop);
		printf("Kernel execution time: %fs\n", time_kernel/1000);
		
		hipEventRecord(start, 0);
		checkCudaErrors(hipMemcpy(h_matches, d_matches, nwords*sizeof(int), hipMemcpyDeviceToHost));
		hipEventRecord(stop,0);
		hipEventSynchronize(stop);
		hipEventElapsedTime(&time_D2H,start,stop);
		printf("DeviceToHost memcopy time: %fs\n", time_D2H/1000);

		printf("Total memcopy time: %fs\n", (time_D2H+time_H2D)/1000);
		printf("Total memcopy+kernel time: %fs\n", (time_D2H+time_H2D+time_kernel)/1000);
		
		printf("Speedup without memory: %f\n", cpuRunTime/((time_kernel)/1000));
		printf("Speedup with memory: %f\n", cpuRunTime/((time_D2H + time_H2D + time_kernel)/1000));
		
		check_matches(h_matches);

		hipEventDestroy(start);
		hipEventDestroy(stop);

	    free(h_matches);
		hipFree(d_words);
		hipFree(d_matches);
		hipFree(d_text);
}

int main(int argc, const char **argv)
{

	intialise("./data/small.txt");
    exec_CPU();
	exec_gpu_stream();

	intialise("./data/medium.txt");
    exec_CPU();
	exec_gpu_stream();

    intialise("./data/large.txt");
    exec_CPU();
	exec_gpu_stream();

	deinit();
	
}

	.text
	.file	"pattern_streams.hip"
	.globl	_Z9intialisePc                  # -- Begin function _Z9intialisePc
	.type	_Z9intialisePc,@function
_Z9intialisePc:                         # @_Z9intialisePc
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.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	%rdi, %rbx
	movl	$32, nwords(%rip)
	movl	$.L.str, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$20, %edi
	callq	malloc
	movq	%rax, 8(%rsp)
	xorps	%xmm0, %xmm0
	movaps	%xmm0, matches(%rip)
	movaps	%xmm0, matches+16(%rip)
	movaps	%xmm0, matches+32(%rip)
	movaps	%xmm0, matches+48(%rip)
	movaps	%xmm0, matches+64(%rip)
	movaps	%xmm0, matches+80(%rip)
	movaps	%xmm0, matches+96(%rip)
	movaps	%xmm0, matches+112(%rip)
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB0_1
# %bb.3:
	movq	%rax, %r14
	movl	nwords(%rip), %ebp
	leaq	16(%rsp), %rsi
	movq	$20, (%rsi)
	leaq	8(%rsp), %rdi
	movq	%rax, %rdx
	callq	getline
	cmpq	$-1, %rax
	je	.LBB0_8
# %bb.4:
	testl	%ebp, %ebp
	je	.LBB0_8
# %bb.5:                                # %.lr.ph.preheader
	decl	%ebp
	movl	$keywords, %r15d
	leaq	8(%rsp), %r12
	leaq	16(%rsp), %r13
.LBB0_6:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	8(%rsp), %rsi
	movl	$8, %edx
	movq	%r15, %rdi
	callq	strncpy
	movb	$0, 4(%r15)
	movq	%r12, %rdi
	movq	%r13, %rsi
	movq	%r14, %rdx
	callq	getline
	subl	$1, %ebp
	setb	%cl
	cmpq	$-1, %rax
	je	.LBB0_8
# %bb.7:                                # %.lr.ph
                                        #   in Loop: Header=BB0_6 Depth=1
	addq	$20, %r15
	testb	%cl, %cl
	je	.LBB0_6
.LBB0_8:                                # %.critedge
	movq	%r14, %rdi
	callq	fclose
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB0_21
# %bb.9:                                # %.preheader38
	movq	%rax, %rbx
	movl	$0, length(%rip)
.LBB0_11:                               # %.lr.ph45
                                        # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	callq	getc
	cmpl	$-1, %eax
	je	.LBB0_12
# %bb.10:                               # %.lr.ph45
                                        #   in Loop: Header=BB0_11 Depth=1
	incl	length(%rip)
	jmp	.LBB0_11
.LBB0_12:                               # %._crit_edge
	movslq	length(%rip), %rdi
	addq	$4, %rdi
	callq	malloc
	movq	%rax, ctext(%rip)
	movq	%rbx, %rdi
	callq	rewind
	movl	length(%rip), %eax
	testl	%eax, %eax
	jle	.LBB0_15
# %bb.13:                               # %.lr.ph48.preheader
	xorl	%r14d, %r14d
.LBB0_14:                               # %.lr.ph48
                                        # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	callq	getc
	movq	ctext(%rip), %rcx
	movb	%al, (%rcx,%r14)
	incq	%r14
	movslq	length(%rip), %rax
	cmpq	%rax, %r14
	jl	.LBB0_14
.LBB0_15:                               # %.lr.ph50.preheader
	cltq
	decq	%rax
.LBB0_16:                               # %.lr.ph50
                                        # =>This Inner Loop Header: Depth=1
	movq	ctext(%rip), %rcx
	movb	$32, 1(%rcx,%rax)
	movslq	length(%rip), %rcx
	addq	$3, %rcx
	incq	%rax
	cmpq	%rcx, %rax
	jl	.LBB0_16
# %bb.17:                               # %._crit_edge51
	movq	%rbx, %rdi
	callq	fclose
	movl	length(%rip), %esi
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	movl	length(%rip), %eax
	leal	3(%rax), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	sarl	$2, %ecx
	movl	%ecx, len(%rip)
	movq	ctext(%rip), %rax
	movq	%rax, text(%rip)
	movslq	nwords(%rip), %rbx
	leaq	(,%rbx,4), %rdi
	callq	malloc
	movq	%rax, words(%rip)
	testq	%rbx, %rbx
	jle	.LBB0_20
# %bb.18:                               # %.lr.ph54.preheader
	movl	%ebx, %ecx
	shlq	$2, %rcx
	xorl	%edx, %edx
.LBB0_19:                               # %.lr.ph54
                                        # =>This Inner Loop Header: Depth=1
	movsbl	keywords(%rdx,%rdx,4), %esi
	movsbl	keywords+1(%rdx,%rdx,4), %edi
	shll	$8, %edi
	addl	%esi, %edi
	movsbl	keywords+2(%rdx,%rdx,4), %esi
	shll	$16, %esi
	movzbl	keywords+3(%rdx,%rdx,4), %r8d
	shll	$24, %r8d
	addl	%esi, %r8d
	addl	%edi, %r8d
	movl	%r8d, (%rax,%rdx)
	addq	$4, %rdx
	cmpq	%rdx, %rcx
	jne	.LBB0_19
.LBB0_20:                               # %._crit_edge55
	addq	$24, %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_1:
	.cfi_def_cfa_offset 80
	movl	$.Lstr, %edi
	jmp	.LBB0_2
.LBB0_21:
	movl	$.Lstr.1, %edi
.LBB0_2:
	callq	puts@PLT
	xorl	%edi, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z9intialisePc, .Lfunc_end0-_Z9intialisePc
	.cfi_endproc
                                        # -- End function
	.globl	_Z6deinitv                      # -- Begin function _Z6deinitv
	.type	_Z6deinitv,@function
_Z6deinitv:                             # @_Z6deinitv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	words(%rip), %rdi
	callq	free
	movq	text(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end1:
	.size	_Z6deinitv, .Lfunc_end1-_Z6deinitv
	.cfi_endproc
                                        # -- End function
	.globl	_Z13check_matchesPi             # -- Begin function _Z13check_matchesPi
	.type	_Z13check_matchesPi,@function
_Z13check_matchesPi:                    # @_Z13check_matchesPi
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, %rbx
	movb	$1, %bpl
	movl	$keywords, %r14d
	xorl	%r15d, %r15d
.LBB2_1:                                # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r15), %edx
	cmpl	%edx, matches(%r15)
	je	.LBB2_3
# %bb.2:                                #   in Loop: Header=BB2_1 Depth=1
	xorl	%ebp, %ebp
	movl	$.L.str.6, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
.LBB2_3:                                #   in Loop: Header=BB2_1 Depth=1
	addq	$20, %r14
	addq	$4, %r15
	cmpq	$128, %r15
	jne	.LBB2_1
# %bb.4:
	testb	$1, %bpl
	jne	.LBB2_6
# %bb.5:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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
.LBB2_6:
	.cfi_def_cfa_offset 48
	movl	$.Lstr.2, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end2:
	.size	_Z13check_matchesPi, .Lfunc_end2-_Z13check_matchesPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z13print_matchesPi             # -- Begin function _Z13print_matchesPi
	.type	_Z13print_matchesPi,@function
_Z13print_matchesPi:                    # @_Z13print_matchesPi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	cmpl	$0, nwords(%rip)
	jle	.LBB3_3
# %bb.1:                                # %.lr.ph.preheader
	movl	$keywords, %r14d
	xorl	%r15d, %r15d
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r15,4), %edx
	movl	$.L.str.10, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	movslq	nwords(%rip), %rax
	addq	$20, %r14
	cmpq	%rax, %r15
	jl	.LBB3_2
.LBB3_3:                                # %._crit_edge
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z13print_matchesPi, .Lfunc_end3-_Z13print_matchesPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z16matchPattern_CPUPjS_Piii    # -- Begin function _Z16matchPattern_CPUPjS_Piii
	.type	_Z16matchPattern_CPUPjS_Piii,@function
_Z16matchPattern_CPUPjS_Piii:           # @_Z16matchPattern_CPUPjS_Piii
	.cfi_startproc
# %bb.0:
	testl	%r8d, %r8d
	jle	.LBB4_11
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %eax
	movl	%r8d, %r8d
	movl	%ecx, %r9d
	xorl	%r10d, %r10d
.LBB4_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_3 Depth 2
                                        #       Child Loop BB4_7 Depth 3
	xorl	%r11d, %r11d
.LBB4_3:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_7 Depth 3
	movl	(%rdi,%r10,4), %ebx
	testl	%r11d, %r11d
	je	.LBB4_5
# %bb.4:                                #   in Loop: Header=BB4_3 Depth=2
	leal	(,%r11,8), %ecx
	shrl	%cl, %ebx
	movl	4(%rdi,%r10,4), %ebp
	negb	%cl
                                        # kill: def $cl killed $cl killed $ecx
	shll	%cl, %ebp
	addl	%ebp, %ebx
.LBB4_5:                                #   in Loop: Header=BB4_3 Depth=2
	testl	%eax, %eax
	jle	.LBB4_8
# %bb.6:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB4_3 Depth=2
	xorl	%ecx, %ecx
.LBB4_7:                                # %.lr.ph
                                        #   Parent Loop BB4_2 Depth=1
                                        #     Parent Loop BB4_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	xorl	%ebp, %ebp
	cmpl	(%rsi,%rcx,4), %ebx
	sete	%bpl
	addl	%ebp, (%rdx,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %r9
	jne	.LBB4_7
.LBB4_8:                                # %._crit_edge
                                        #   in Loop: Header=BB4_3 Depth=2
	incl	%r11d
	cmpl	$4, %r11d
	jne	.LBB4_3
# %bb.9:                                #   in Loop: Header=BB4_2 Depth=1
	incq	%r10
	cmpq	%r8, %r10
	jne	.LBB4_2
# %bb.10:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %rbp
.LBB4_11:                               # %._crit_edge27
	retq
.Lfunc_end4:
	.size	_Z16matchPattern_CPUPjS_Piii, .Lfunc_end4-_Z16matchPattern_CPUPjS_Piii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z8exec_CPUv
.LCPI5_0:
	.long	0x49742400                      # float 1.0E+6
	.text
	.globl	_Z8exec_CPUv
	.type	_Z8exec_CPUv,@function
_Z8exec_CPUv:                           # @_Z8exec_CPUv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	callq	clock
	movq	%rax, %rbx
	movq	text(%rip), %rdi
	movq	words(%rip), %rsi
	movl	nwords(%rip), %ecx
	movl	len(%rip), %r8d
	movl	$matches, %edx
	callq	_Z16matchPattern_CPUPjS_Piii
	callq	clock
	subq	%rbx, %rax
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI5_0(%rip), %xmm0
	movss	%xmm0, cpuRunTime(%rip)
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.11, %edi
	movb	$1, %al
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	printf                          # TAILCALL
.Lfunc_end5:
	.size	_Z8exec_CPUv, .Lfunc_end5-_Z8exec_CPUv
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__matchPattern_gpu_1PjS_Piiiii # -- Begin function _Z33__device_stub__matchPattern_gpu_1PjS_Piiiii
	.type	_Z33__device_stub__matchPattern_gpu_1PjS_Piiiii,@function
_Z33__device_stub__matchPattern_gpu_1PjS_Piiiii: # @_Z33__device_stub__matchPattern_gpu_1PjS_Piiiii
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	20(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	16(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z18matchPattern_gpu_1PjS_Piiiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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_end6:
	.size	_Z33__device_stub__matchPattern_gpu_1PjS_Piiiii, .Lfunc_end6-_Z33__device_stub__matchPattern_gpu_1PjS_Piiiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z15exec_gpu_streamv
.LCPI7_0:
	.long	0x447a0000                      # float 1000
	.text
	.globl	_Z15exec_gpu_streamv
	.type	_Z15exec_gpu_streamv,@function
_Z15exec_gpu_streamv:                   # @_Z15exec_gpu_streamv
	.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	$152, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	len(%rip), %r13d
	leal	7(%r13), %r12d
	testl	%r13d, %r13d
	cmovnsl	%r13d, %r12d
	sarl	$3, %r12d
	leal	(,%r12,4), %r15d
	movslq	nwords(%rip), %rsi
	shlq	$5, %rsi
	movl	$1, %edi
	callq	calloc@PLT
	movq	%rax, %rbx
	xorl	%r14d, %r14d
.LBB7_1:                                # %_Z9gpuAssert10hipError_tPKcib.exit64
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%rsp,%r14), %rdi
	addq	$80, %rdi
	callq	hipStreamCreate
	testl	%eax, %eax
	jne	.LBB7_21
# %bb.2:                                #   in Loop: Header=BB7_1 Depth=1
	addq	$8, %r14
	cmpq	$64, %r14
	jne	.LBB7_1
# %bb.3:
	movq	words(%rip), %rdi
	movslq	nwords(%rip), %rsi
	shlq	$2, %rsi
	xorl	%edx, %edx
	callq	hipHostRegister
	movq	text(%rip), %r14
	movq	ctext(%rip), %rdi
	callq	strlen
	movq	%r14, %rdi
	movq	%rax, %rsi
	xorl	%edx, %edx
	callq	hipHostRegister
	movslq	nwords(%rip), %rsi
	shlq	$2, %rsi
	movq	%rbx, %rdi
	xorl	%edx, %edx
	callq	hipHostRegister
	movslq	nwords(%rip), %rsi
	shlq	$2, %rsi
	leaq	48(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_4
# %bb.6:                                # %_Z9gpuAssert10hipError_tPKcib.exit
	movslq	nwords(%rip), %rsi
	shlq	$5, %rsi
	leaq	40(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_7
# %bb.8:                                # %_Z9gpuAssert10hipError_tPKcib.exit52
	movslq	len(%rip), %rsi
	shlq	$2, %rsi
	leaq	56(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB7_9
# %bb.10:                               # %_Z9gpuAssert10hipError_tPKcib.exit54
	movl	$0, 20(%rsp)
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB7_11
# %bb.12:                               # %_Z9gpuAssert10hipError_tPKcib.exit56
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB7_13
# %bb.14:                               # %_Z9gpuAssert10hipError_tPKcib.exit58
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB7_15
# %bb.16:                               # %_Z9gpuAssert10hipError_tPKcib.exit60
	movq	%r13, 72(%rsp)                  # 8-byte Spill
	movq	48(%rsp), %rdi
	movq	words(%rip), %rsi
	movslq	nwords(%rip), %rdx
	shlq	$2, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB7_20
# %bb.17:                               # %_Z9gpuAssert10hipError_tPKcib.exit62.preheader
	movslq	%r15d, %r14
	movq	%r12, 64(%rsp)                  # 8-byte Spill
	movslq	%r12d, %r15
	shlq	$2, %r15
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB7_18:                               # %_Z9gpuAssert10hipError_tPKcib.exit66
                                        # =>This Inner Loop Header: Depth=1
	movq	56(%rsp), %rdi
	addq	%r12, %rdi
	movq	text(%rip), %rsi
	addq	%r12, %rsi
	movq	80(%rsp,%r13,8), %r8
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpyAsync
	testl	%eax, %eax
	jne	.LBB7_19
# %bb.22:                               # %_Z9gpuAssert10hipError_tPKcib.exit62
                                        #   in Loop: Header=BB7_18 Depth=1
	incq	%r13
	addq	%r15, %r12
	cmpq	$8, %r13
	jne	.LBB7_18
# %bb.23:                               # %.preheader85
	movabsq	$4294967296, %r14               # imm = 0x100000000
	movq	72(%rsp), %rax                  # 8-byte Reload
	leal	255(%rax), %r15d
	testl	%eax, %eax
	cmovnsl	%eax, %r15d
	sarl	$8, %r15d
	btsq	$32, %r15
	xorl	%r12d, %r12d
	addq	$32, %r14
	xorl	%ebp, %ebp
	movq	64(%rsp), %r13                  # 8-byte Reload
.LBB7_24:                               # =>This Inner Loop Header: Depth=1
	movq	80(%rsp,%rbp,8), %r9
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_26
# %bb.25:                               #   in Loop: Header=BB7_24 Depth=1
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdx
	movl	nwords(%rip), %ecx
	movl	len(%rip), %r8d
	movl	%ebp, (%rsp)
	movl	%r12d, %r9d
	callq	_Z33__device_stub__matchPattern_gpu_1PjS_Piiiii
.LBB7_26:                               #   in Loop: Header=BB7_24 Depth=1
	incq	%rbp
	addl	%r13d, %r12d
	cmpq	$8, %rbp
	jne	.LBB7_24
# %bb.27:                               # %_Z9gpuAssert10hipError_tPKcib.exit74.preheader
	leaq	80(%rsp), %r14
	xorl	%r15d, %r15d
.LBB7_28:                               # %_Z9gpuAssert10hipError_tPKcib.exit74
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%rbx,%r15), %rdi
	movq	40(%rsp), %rsi
	addq	%r15, %rsi
	movq	(%r14), %r8
	movl	$128, %edx
	movl	$2, %ecx
	callq	hipMemcpyAsync
	testl	%eax, %eax
	jne	.LBB7_36
# %bb.29:                               #   in Loop: Header=BB7_28 Depth=1
	subq	$-128, %r15
	addq	$8, %r14
	cmpq	$1024, %r15                     # imm = 0x400
	jne	.LBB7_28
# %bb.30:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%eax, %eax
	jne	.LBB7_31
# %bb.32:                               # %_Z9gpuAssert10hipError_tPKcib.exit68
	movq	24(%rsp), %rdi
	callq	hipEventSynchronize
	testl	%eax, %eax
	jne	.LBB7_33
# %bb.34:                               # %_Z9gpuAssert10hipError_tPKcib.exit70
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdx
	leaq	20(%rsp), %rdi
	callq	hipEventElapsedTime
	testl	%eax, %eax
	jne	.LBB7_35
# %bb.37:                               # %_Z9gpuAssert10hipError_tPKcib.exit72
	movss	20(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI7_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.13, %edi
	movb	$1, %al
	callq	printf
	movss	cpuRunTime(%rip), %xmm0         # xmm0 = mem[0],zero,zero,zero
	movss	20(%rsp), %xmm1                 # xmm1 = mem[0],zero,zero,zero
	divss	.LCPI7_0(%rip), %xmm1
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.14, %edi
	movb	$1, %al
	callq	printf
	movq	%rbx, %rax
	subq	$-128, %rax
	xorl	%ecx, %ecx
.LBB7_38:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_39 Depth 2
	movl	(%rbx,%rcx,4), %edx
	xorl	%esi, %esi
.LBB7_39:                               #   Parent Loop BB7_38 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addl	(%rax,%rsi), %edx
	subq	$-128, %rsi
	cmpq	$896, %rsi                      # imm = 0x380
	jne	.LBB7_39
# %bb.40:                               #   in Loop: Header=BB7_38 Depth=1
	movl	%edx, (%rbx,%rcx,4)
	incq	%rcx
	addq	$4, %rax
	cmpq	$32, %rcx
	jne	.LBB7_38
# %bb.41:
	movq	%rbx, %rdi
	callq	_Z13check_matchesPi
	movq	32(%rsp), %rdi
	callq	hipEventDestroy
	testl	%eax, %eax
	jne	.LBB7_42
# %bb.43:                               # %_Z9gpuAssert10hipError_tPKcib.exit76
	movq	24(%rsp), %rdi
	callq	hipEventDestroy
	testl	%eax, %eax
	jne	.LBB7_45
# %bb.44:                               # %_Z9gpuAssert10hipError_tPKcib.exit80.preheader
	xorl	%r14d, %r14d
.LBB7_47:                               # %_Z9gpuAssert10hipError_tPKcib.exit80
                                        # =>This Inner Loop Header: Depth=1
	movq	80(%rsp,%r14,8), %rdi
	callq	hipStreamDestroy
	testl	%eax, %eax
	jne	.LBB7_48
# %bb.46:                               # %_Z9gpuAssert10hipError_tPKcib.exit78
                                        #   in Loop: Header=BB7_47 Depth=1
	incq	%r14
	cmpq	$8, %r14
	jne	.LBB7_47
# %bb.49:
	movq	text(%rip), %rdi
	callq	hipHostUnregister
	movq	words(%rip), %rdi
	callq	hipHostUnregister
	movq	%rbx, %rdi
	callq	hipHostUnregister
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	56(%rsp), %rdi
	callq	hipFree
	addq	$152, %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
.LBB7_21:
	.cfi_def_cfa_offset 208
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$200, %r8d
	jmp	.LBB7_5
.LBB7_19:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$221, %r8d
	jmp	.LBB7_5
.LBB7_36:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$233, %r8d
	jmp	.LBB7_5
.LBB7_48:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$258, %r8d                      # imm = 0x102
.LBB7_5:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, %edi
	callq	exit
.LBB7_4:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$207, %r8d
	jmp	.LBB7_5
.LBB7_7:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$208, %r8d
	jmp	.LBB7_5
.LBB7_9:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$209, %r8d
	jmp	.LBB7_5
.LBB7_11:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$213, %r8d
	jmp	.LBB7_5
.LBB7_13:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$214, %r8d
	jmp	.LBB7_5
.LBB7_15:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$216, %r8d
	jmp	.LBB7_5
.LBB7_20:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$217, %r8d
	jmp	.LBB7_5
.LBB7_31:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$236, %r8d
	jmp	.LBB7_5
.LBB7_33:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$237, %r8d
	jmp	.LBB7_5
.LBB7_35:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$238, %r8d
	jmp	.LBB7_5
.LBB7_42:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$254, %r8d
	jmp	.LBB7_5
.LBB7_45:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$255, %r8d
	jmp	.LBB7_5
.Lfunc_end7:
	.size	_Z15exec_gpu_streamv, .Lfunc_end7-_Z15exec_gpu_streamv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z15exec_gpu_simplev
.LCPI8_0:
	.long	0x447a0000                      # float 1000
.LCPI8_1:
	.long	0x3d000000                      # float 0.03125
	.text
	.globl	_Z15exec_gpu_simplev
	.type	_Z15exec_gpu_simplev,@function
_Z15exec_gpu_simplev:                   # @_Z15exec_gpu_simplev
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movslq	nwords(%rip), %r14
	shlq	$2, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, %rbx
	leaq	40(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB8_1
# %bb.3:                                # %_Z9gpuAssert10hipError_tPKcib.exit
	movslq	nwords(%rip), %rsi
	shlq	$2, %rsi
	leaq	32(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB8_4
# %bb.5:                                # %_Z9gpuAssert10hipError_tPKcib.exit6
	movslq	len(%rip), %rsi
	shlq	$2, %rsi
	leaq	48(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB8_6
# %bb.7:                                # %_Z9gpuAssert10hipError_tPKcib.exit8
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB8_8
# %bb.9:                                # %_Z9gpuAssert10hipError_tPKcib.exit10
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	testl	%eax, %eax
	jne	.LBB8_10
# %bb.11:                               # %_Z9gpuAssert10hipError_tPKcib.exit12
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	40(%rsp), %rdi
	movq	words(%rip), %rsi
	movslq	nwords(%rip), %rdx
	shlq	$2, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB8_12
# %bb.13:                               # %_Z9gpuAssert10hipError_tPKcib.exit14
	movq	48(%rsp), %rdi
	movq	text(%rip), %rsi
	movslq	len(%rip), %rdx
	shlq	$2, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB8_14
# %bb.15:                               # %_Z9gpuAssert10hipError_tPKcib.exit16
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	28(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI8_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.15, %edi
	movb	$1, %al
	callq	printf
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	xorps	%xmm0, %xmm0
	cvtsi2ssl	len(%rip), %xmm0
	mulss	.LCPI8_1(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %rax
	movl	%eax, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_17
# %bb.16:
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	movl	nwords(%rip), %ecx
	movl	len(%rip), %r8d
	movl	$0, (%rsp)
	xorl	%r9d, %r9d
	callq	_Z33__device_stub__matchPattern_gpu_1PjS_Piiiii
.LBB8_17:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	callq	hipPeekAtLastError
	testl	%eax, %eax
	jne	.LBB8_18
# %bb.19:                               # %_Z9gpuAssert10hipError_tPKcib.exit18
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	24(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI8_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.16, %edi
	movb	$1, %al
	callq	printf
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	32(%rsp), %rsi
	movslq	nwords(%rip), %rdx
	shlq	$2, %rdx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB8_20
# %bb.21:                               # %_Z9gpuAssert10hipError_tPKcib.exit20
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	60(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI8_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.17, %edi
	movb	$1, %al
	callq	printf
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	addss	28(%rsp), %xmm0
	divss	.LCPI8_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.18, %edi
	movb	$1, %al
	callq	printf
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	addss	28(%rsp), %xmm0
	addss	24(%rsp), %xmm0
	divss	.LCPI8_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.19, %edi
	movb	$1, %al
	callq	printf
	movss	cpuRunTime(%rip), %xmm0         # xmm0 = mem[0],zero,zero,zero
	movss	24(%rsp), %xmm1                 # xmm1 = mem[0],zero,zero,zero
	divss	.LCPI8_0(%rip), %xmm1
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.20, %edi
	movb	$1, %al
	callq	printf
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	addss	28(%rsp), %xmm0
	addss	24(%rsp), %xmm0
	movss	cpuRunTime(%rip), %xmm1         # xmm1 = mem[0],zero,zero,zero
	divss	.LCPI8_0(%rip), %xmm0
	divss	%xmm0, %xmm1
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	movl	$.L.str.14, %edi
	movb	$1, %al
	callq	printf
	movq	%rbx, %rdi
	callq	_Z13check_matchesPi
	movq	16(%rsp), %rdi
	callq	hipEventDestroy
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	movq	%rbx, %rdi
	callq	free
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	addq	$64, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB8_1:
	.cfi_def_cfa_offset 96
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$278, %r8d                      # imm = 0x116
	jmp	.LBB8_2
.LBB8_4:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$279, %r8d                      # imm = 0x117
	jmp	.LBB8_2
.LBB8_6:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$280, %r8d                      # imm = 0x118
	jmp	.LBB8_2
.LBB8_8:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$284, %r8d                      # imm = 0x11C
	jmp	.LBB8_2
.LBB8_10:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$285, %r8d                      # imm = 0x11D
	jmp	.LBB8_2
.LBB8_12:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$290, %r8d                      # imm = 0x122
	jmp	.LBB8_2
.LBB8_14:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$291, %r8d                      # imm = 0x123
	jmp	.LBB8_2
.LBB8_18:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$302, %r8d                      # imm = 0x12E
	jmp	.LBB8_2
.LBB8_20:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.24, %esi
	movl	$.L.str.12, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$307, %r8d                      # imm = 0x133
.LBB8_2:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, %edi
	callq	exit
.Lfunc_end8:
	.size	_Z15exec_gpu_simplev, .Lfunc_end8-_Z15exec_gpu_simplev
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$.L.str.21, %edi
	callq	_Z9intialisePc
	callq	_Z8exec_CPUv
	callq	_Z15exec_gpu_streamv
	movl	$.L.str.22, %edi
	callq	_Z9intialisePc
	callq	_Z8exec_CPUv
	callq	_Z15exec_gpu_streamv
	movl	$.L.str.23, %edi
	callq	_Z9intialisePc
	callq	_Z8exec_CPUv
	callq	_Z15exec_gpu_streamv
	movq	words(%rip), %rdi
	callq	free
	movq	text(%rip), %rdi
	callq	free
	xorl	%eax, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	main, .Lfunc_end9-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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18matchPattern_gpu_1PjS_Piiiii, %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_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	length,@object                  # @length
	.bss
	.globl	length
	.p2align	2, 0x0
length:
	.long	0                               # 0x0
	.size	length, 4

	.type	len,@object                     # @len
	.globl	len
	.p2align	2, 0x0
len:
	.long	0                               # 0x0
	.size	len, 4

	.type	nwords,@object                  # @nwords
	.globl	nwords
	.p2align	2, 0x0
nwords:
	.long	0                               # 0x0
	.size	nwords, 4

	.type	matches,@object                 # @matches
	.globl	matches
	.p2align	4, 0x0
matches:
	.zero	128
	.size	matches, 128

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

	.type	keywords,@object                # @keywords
	.globl	keywords
	.p2align	4, 0x0
keywords:
	.zero	640
	.size	keywords, 640

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

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

	.type	cpuRunTime,@object              # @cpuRunTime
	.globl	cpuRunTime
	.p2align	2, 0x0
cpuRunTime:
	.long	0x00000000                      # float 0
	.size	cpuRunTime, 4

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"-----------\nGoint to read %s\n"
	.size	.L.str, 30

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"./data/keywords.txt"
	.size	.L.str.1, 20

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"r"
	.size	.L.str.2, 2

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Length : %d\n"
	.size	.L.str.5, 13

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"WRONG OUTPUT:\t %s\t|\t%d\n"
	.size	.L.str.6, 24

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"%s\t  |\t%d\n"
	.size	.L.str.10, 11

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"CPU exec time: %f s\n\n"
	.size	.L.str.11, 22

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

	.type	.L.str.12,@object               # @.str.12
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.12:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/sedflix/cuda_pattern_matching/master/pattern_streams.hip"
	.size	.L.str.12, 119

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Time kernel+memory: %fs\n"
	.size	.L.str.13, 25

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Speedup with memory: %f\n"
	.size	.L.str.14, 25

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"HostToDevice memcopy time: %fs\n"
	.size	.L.str.15, 32

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Kernel execution time: %fs\n"
	.size	.L.str.16, 28

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"DeviceToHost memcopy time: %fs\n"
	.size	.L.str.17, 32

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Total memcopy time: %fs\n"
	.size	.L.str.18, 25

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"Total memcopy+kernel time: %fs\n"
	.size	.L.str.19, 32

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Speedup without memory: %f\n"
	.size	.L.str.20, 28

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"./data/small.txt"
	.size	.L.str.21, 17

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"./data/medium.txt"
	.size	.L.str.22, 18

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"./data/large.txt"
	.size	.L.str.23, 17

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"GPUassert: %s %s %d\n"
	.size	.L.str.24, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z18matchPattern_gpu_1PjS_Piiiii"
	.size	.L__unnamed_1, 33

	.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	"keywords.txt: File not found."
	.size	.Lstr, 30

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Unable to open the file."
	.size	.Lstr.1, 25

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	" - Correct Answer -"
	.size	.Lstr.2, 20

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Printing Matches:"
	.size	.Lstr.3, 18

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Word\t  |\tNumber of Matches\n==================================="
	.size	.Lstr.4, 63

	.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 _Z33__device_stub__matchPattern_gpu_1PjS_Piiiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym matches
	.addrsig_sym keywords
	.addrsig_sym _Z18matchPattern_gpu_1PjS_Piiiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z18matchPattern_gpu_1PjS_Piiiii ; -- Begin function _Z18matchPattern_gpu_1PjS_Piiiii
	.globl	_Z18matchPattern_gpu_1PjS_Piiiii
	.p2align	8
	.type	_Z18matchPattern_gpu_1PjS_Piiiii,@function
_Z18matchPattern_gpu_1PjS_Piiiii:       ; @_Z18matchPattern_gpu_1PjS_Piiiii
; %bb.0:
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x34
	s_load_b64 s[2:3], s[0:1], 0x20
	s_load_b128 s[8:11], s[0:1], 0x0
	v_lshlrev_b32_e32 v3, 2, v0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s5, s15, s4
	s_add_i32 s2, s5, s2
	s_mov_b32 s5, 0
	v_add_nc_u32_e32 v1, s2, v0
	s_add_i32 s4, s2, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[6:7], s[4:5], 2
	s_add_u32 s6, s8, s6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	s_addc_u32 s7, s9, s7
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, s8, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s9, v2, vcc_lo
	global_load_b32 v4, v[1:2], off
	global_load_b32 v2, v3, s[10:11]
	s_load_b32 s2, s[6:7], 0x0
	v_mov_b32_e32 v1, 0
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v5, s2
	s_waitcnt vmcnt(1)
	ds_store_b32 v3, v4
	ds_store_b32 v1, v5 offset:128
	s_waitcnt vmcnt(0) lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_1:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_2 Depth 2
	s_lshl_b32 s2, s5, 2
	s_mov_b32 s4, 0
	v_mov_b32_e32 v3, s2
	s_mov_b32 s6, 32
	ds_load_b32 v3, v3
.LBB0_2:                                ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v4, v3
	s_cmp_eq_u32 s6, 32
	s_cbranch_scc1 .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=2
	v_mov_b32_e32 v4, s2
	v_lshrrev_b32_e32 v5, s4, v3
	ds_load_b32 v4, v4 offset:4
	s_waitcnt lgkmcnt(0)
	v_lshlrev_b32_e32 v4, s6, v4
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v4, v4, v5
.LBB0_4:                                ;   in Loop: Header=BB0_2 Depth=2
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_eq_u32_e32 vcc_lo, v4, v2
	s_add_i32 s6, s6, -8
	s_add_i32 s4, s4, 8
	s_cmp_eq_u32 s6, 0
	v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
	s_cbranch_scc0 .LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_1 Depth=1
	s_add_i32 s5, s5, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s5, 32
	s_cbranch_scc0 .LBB0_1
; %bb.6:
	v_lshl_add_u32 v2, s3, 5, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	global_atomic_add_u32 v[2:3], v1, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18matchPattern_gpu_1PjS_Piiiii
		.amdhsa_group_segment_fixed_size 132
		.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 6
		.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	_Z18matchPattern_gpu_1PjS_Piiiii, .Lfunc_end0-_Z18matchPattern_gpu_1PjS_Piiiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 372
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 132 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; 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:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .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: 132
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18matchPattern_gpu_1PjS_Piiiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18matchPattern_gpu_1PjS_Piiiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
