#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <string.h>
#include <iostream>

#define BLOCOS     1
//#define THREAD

#define CHECK_ERROR(call) do {                                                    \
   if( cudaSuccess != call) {                                                             \
      std::cerr << std::endl << "CUDA ERRO: " <<                             \
         cudaGetErrorString(call) <<  " in file: " << __FILE__                \
         << " in line: " << __LINE__ << std::endl;                               \
         exit(0);                                                                                 \
   } } while (0)

using namespace std;

typedef struct automato {
	char letra;
	automato *prox;
	automato *ant;
	automato *inf;
	int final;
} Automato;

__global__ void pfac(Automato* at, int *matches, char *frase){

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


}

Automato* newAutomato(Automato* ant) {
	Automato *nv = (Automato*) malloc(sizeof(Automato));
	nv->prox = NULL;
	nv->inf = NULL;
	nv->ant = ant;

	return nv;
}

Automato* addAlgarismo(Automato *at, char algm, int first) {
	if (at != NULL && at->letra == algm && first == 1) {
		return at;
	}
	// Caso algarismo novo seja diferente do algarismo da raiz
	else if (at != NULL && at->letra != algm && first == 1) {
		Automato *pt = at->inf;
		Automato *ant = pt;
		while (pt != NULL) {
			if (pt->letra == algm) {
				return pt;
			}
			else {
				if (pt != NULL) {
					ant = pt;
					pt = pt->inf;
				}

			}
		}
		Automato *nv = newAutomato(at);
		nv->letra = algm;
		if (ant != NULL) {
			ant->inf = nv;
			return ant->inf;
		}
		else {
			at->inf = nv;
			return at->inf;
		}

	}

	else if(at != NULL && first == 0)
	{
		Automato *pt = at->prox;
		Automato *ant = NULL;
		while (pt != NULL) {

			if (pt->letra == algm) {
				return pt;
			}
			else
			{
				ant = pt;
				pt = pt->inf;
			}
		}

		Automato *nv = newAutomato(at);
		nv->letra = algm;

		if (ant != NULL) {
			ant->inf = nv;
		}
		else {
			at->prox = nv;
		}

		return nv;
	}
	else
	{
		Automato *nv = newAutomato(NULL);
		nv->letra = algm;
		return nv;
	}
}

void imprimir(Automato *at)
{
	Automato *temp = at;

	while (temp != NULL) {
		printf("%c ", temp->letra);
		imprimir(temp->prox);
		temp = temp->inf;
		printf("\n");
	}

}

/*Automato* mallocGPU(Automato *at)
{
	Automato *temp = at;

	while (temp != NULL) {
		imprimir(temp->prox);
		temp = temp->inf;
	}
}*/

int main (int argc, char **argv)
{
	int GPU = 0;

	Automato *at = newAutomato(NULL);
	at->letra = 'a';
	at->prox = NULL;

	char frase[255] = "ab abg bede ef"; //"abc acd abb agd acc";
	int THREADS = strlen(frase);

	Automato *temp = at;

	int i = 0;
	int first = 1;

	while(frase[i] != '\0')
	{
		if(frase[i] != ' ')
		{
			temp = addAlgarismo(temp, frase[i], first);
			first = 0;
			//printf("Letra: %c\n", temp->letra);
		}
		else
		{
			temp->final = 1;
			temp = at;
			first = 1;
		}
		i++;

	}
	imprimir(at);

	// CPU
	char h_fita[255] = "ab abg bede ef";
	int *h_matches = (int*) malloc(sizeof(int));

	// GPU
	Automato *d_at = NULL;
	char *d_fita = NULL;
	int *d_matches = NULL;

	CHECK_ERROR(cudaSetDevice(GPU));

	*h_matches = 0;

	//Reset na GPU selecionada
	CHECK_ERROR(cudaDeviceReset());

	CHECK_ERROR(cudaMalloc((void**) &d_at, sizeof(Automato*)));
	CHECK_ERROR(cudaMalloc((void**) &d_fita, 255*sizeof(char)));
	CHECK_ERROR(cudaMalloc((void**) &d_matches, sizeof(int)));

	//Copiando CPU --> GPU
	CHECK_ERROR(cudaMemcpy(d_at, at, sizeof(Automato*),  cudaMemcpyHostToDevice));
	CHECK_ERROR(cudaMemcpy(d_fita, h_fita, 255*sizeof(char),  cudaMemcpyHostToDevice));
	CHECK_ERROR(cudaMemcpy(d_matches, h_matches, sizeof(int),  cudaMemcpyHostToDevice));


	pfac <<<BLOCOS, THREADS>>> (d_at, d_matches, d_fita);

	//Copiando GPU --> CPU
	CHECK_ERROR(cudaMemcpy(at, d_at, sizeof(Automato*),  cudaMemcpyDeviceToHost));
	CHECK_ERROR(cudaMemcpy(h_fita, d_fita, 255*sizeof(char),  cudaMemcpyDeviceToHost));
	CHECK_ERROR(cudaMemcpy(h_matches, d_matches, sizeof(int),  cudaMemcpyDeviceToHost));

	// Liberando memória na GPU
	CHECK_ERROR(cudaFree(d_at));
	CHECK_ERROR(cudaFree(d_fita));
	CHECK_ERROR(cudaFree(d_matches));

	// Liberando memória na CPU
	free(at);
	free(h_matches);
	free(h_fita);


   return EXIT_SUCCESS;
}




	.file	"tmpxft_00350239_00000000-6_pfac.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3641:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3641:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11newAutomatoP8automato
	.type	_Z11newAutomatoP8automato, @function
_Z11newAutomatoP8automato:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movl	$40, %edi
	call	malloc@PLT
	xorl	%edx, %edx
	movq	%rdx, 8(%rax)
	movq	%rdx, 24(%rax)
	movq	%rbx, 16(%rax)
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z11newAutomatoP8automato, .-_Z11newAutomatoP8automato
	.globl	_Z12addAlgarismoP8automatoci
	.type	_Z12addAlgarismoP8automatoci, @function
_Z12addAlgarismoP8automatoci:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	testq	%rdi, %rdi
	je	.L5
	movq	%rdi, %rbx
	movl	%esi, %ecx
	cmpb	%sil, (%rdi)
	jne	.L6
	movq	%rdi, %rax
	cmpl	$1, %edx
	jne	.L8
	jmp	.L4
.L6:
	cmpl	$1, %edx
	jne	.L8
	movq	24(%rdi), %rax
	movq	%rax, %r12
.L9:
	testq	%rax, %rax
	je	.L24
	cmpb	%cl, (%rax)
	je	.L4
	movq	%rax, %r12
	movq	24(%rax), %rax
	jmp	.L9
.L24:
	movq	%rbx, %rdi
	call	_Z11newAutomatoP8automato
	movb	%bpl, (%rax)
	testq	%r12, %r12
	jne	.L22
	movq	%rax, 24(%rbx)
	jmp	.L4
.L8:
	testl	%edx, %edx
	jne	.L5
	movq	8(%rbx), %rax
	xorl	%r12d, %r12d
.L13:
	testq	%rax, %rax
	je	.L25
	cmpb	%cl, (%rax)
	je	.L4
	movq	%rax, %r12
	movq	24(%rax), %rax
	jmp	.L13
.L25:
	movq	%rbx, %rdi
	call	_Z11newAutomatoP8automato
	movb	%bpl, (%rax)
	testq	%r12, %r12
	je	.L15
.L22:
	movq	%rax, 24(%r12)
	jmp	.L4
.L15:
	movq	%rax, 8(%rbx)
	jmp	.L4
.L5:
	xorl	%edi, %edi
	call	_Z11newAutomatoP8automato
	movb	%bpl, (%rax)
.L4:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3636:
	.size	_Z12addAlgarismoP8automatoci, .-_Z12addAlgarismoP8automatoci
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%c "
.LC1:
	.string	"\n"
	.text
	.globl	_Z8imprimirP8automato
	.type	_Z8imprimirP8automato, @function
_Z8imprimirP8automato:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
.L27:
	testq	%rbx, %rbx
	je	.L30
	movsbl	(%rbx), %edx
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rbx), %rdi
	call	_Z8imprimirP8automato
	movl	$2, %edi
	xorl	%eax, %eax
	movq	24(%rbx), %rbx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	jmp	.L27
.L30:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3637:
	.size	_Z8imprimirP8automato, .-_Z8imprimirP8automato
	.globl	_Z35__device_stub__Z4pfacP8automatoPiPcP8automatoPiPc
	.type	_Z35__device_stub__Z4pfacP8automatoPiPcP8automatoPiPc, @function
_Z35__device_stub__Z4pfacP8automatoPiPcP8automatoPiPc:
.LFB3663:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z4pfacP8automatoPiPc(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L31:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L33
	call	__stack_chk_fail@PLT
.L33:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3663:
	.size	_Z35__device_stub__Z4pfacP8automatoPiPcP8automatoPiPc, .-_Z35__device_stub__Z4pfacP8automatoPiPcP8automatoPiPc
	.globl	_Z4pfacP8automatoPiPc
	.type	_Z4pfacP8automatoPiPc, @function
_Z4pfacP8automatoPiPc:
.LFB3664:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z4pfacP8automatoPiPcP8automatoPiPc
	.cfi_endproc
.LFE3664:
	.size	_Z4pfacP8automatoPiPc, .-_Z4pfacP8automatoPiPc
	.section	.rodata.str1.1
.LC2:
	.string	"CUDA ERRO: "
.LC3:
	.string	" in file: "
.LC4:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/juliobarbieri/pf-aho-corasick/master/pfac.cu"
.LC5:
	.string	" in line: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3638:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%edi, %edi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$584, %rsp
	.cfi_def_cfa_offset 624
	movq	%fs:40, %rax
	movq	%rax, 568(%rsp)
	xorl	%eax, %eax
	leaq	58(%rsp), %r12
	call	_Z11newAutomatoP8automato
	xorl	%ecx, %ecx
	leaq	74(%rsp), %rdi
	movabsq	$112584521245797, %rdx
	movq	%rcx, 8(%rax)
	movq	%rax, %rbx
	movl	$239, %ecx
	movb	$97, (%rax)
	movabsq	$7070765087205646945, %rax
	movq	%rax, 58(%rsp)
	xorl	%eax, %eax
	rep stosb
	movq	%r12, %rdi
	movq	%rdx, 66(%rsp)
	call	strlen@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	movq	%rax, %r13
.L37:
	movb	(%r12), %bpl
	testb	%bpl, %bpl
	je	.L59
	cmpb	$32, %bpl
	je	.L38
	movsbl	%bpl, %esi
	call	_Z12addAlgarismoP8automatoci
	xorl	%edx, %edx
	movq	%rax, %rdi
	jmp	.L39
.L38:
	movl	$1, 32(%rdi)
	movl	$1, %edx
	movq	%rbx, %rdi
.L39:
	incq	%r12
	jmp	.L37
.L59:
	movq	%rbx, %rdi
	call	_Z8imprimirP8automato
	leaq	329(%rsp), %rdi
	movl	$239, %ecx
	movabsq	$7070765087205646945, %rax
	movq	%rax, 313(%rsp)
	movl	%ebp, %eax
	movabsq	$112584521245797, %rdx
	rep stosb
	movl	$4, %edi
	movq	%rdx, 321(%rsp)
	call	malloc@PLT
	xorl	%edx, %edx
	xorl	%edi, %edi
	movq	%rdx, 8(%rsp)
	movq	%rax, %rbp
	movq	%rdx, 16(%rsp)
	movq	%rdx, 24(%rsp)
	call	cudaSetDevice@PLT
	testl	%eax, %eax
	je	.L41
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	xorl	%edi, %edi
	movq	%rax, %rbx
	call	cudaSetDevice@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$181, %esi
	movq	%rax, %rdi
	jmp	.L58
.L41:
	xorl	%eax, %eax
	movl	%eax, 0(%rbp)
	call	cudaDeviceReset@PLT
	testl	%eax, %eax
	je	.L42
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rbx
	call	cudaDeviceReset@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$186, %esi
	movq	%rax, %rdi
.L58:
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L42:
	leaq	8(%rsp), %r12
	movl	$8, %esi
	movq	%r12, %rdi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L43
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$8, %esi
	movq	%r12, %rdi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$188, %esi
	movq	%rax, %rdi
	jmp	.L58
.L43:
	leaq	16(%rsp), %r12
	movl	$255, %esi
	movq	%r12, %rdi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L44
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$255, %esi
	movq	%r12, %rdi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$189, %esi
	movq	%rax, %rdi
	jmp	.L58
.L44:
	leaq	24(%rsp), %r12
	movl	$4, %esi
	movq	%r12, %rdi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L45
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$4, %esi
	movq	%r12, %rdi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$190, %esi
	movq	%rax, %rdi
	jmp	.L58
.L45:
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$8, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L46
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$8, %edx
	movq	%rax, %rbp
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$193, %esi
	movq	%rax, %rdi
	jmp	.L58
.L46:
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movl	$255, %edx
	leaq	313(%rsp), %r12
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L47
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$255, %edx
	movq	%rax, %rbx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$194, %esi
	movq	%rax, %rdi
	jmp	.L58
.L47:
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movl	$4, %edx
	movq	%rbp, %rsi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L48
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$4, %edx
	movq	%rax, %rbx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$195, %esi
	movq	%rax, %rdi
	jmp	.L58
.L48:
	movl	%r13d, 44(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movq	%rdi, 48(%rsp)
	movl	52(%rsp), %ecx
	movq	44(%rsp), %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L49
	movq	16(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdi
	call	_Z35__device_stub__Z4pfacP8automatoPiPcP8automatoPiPc
.L49:
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movl	$8, %edx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L50
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$8, %edx
	movq	%rax, %rbp
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$201, %esi
	movq	%rax, %rdi
	jmp	.L58
.L50:
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movl	$255, %edx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L51
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	movl	$255, %edx
	movq	%rax, %rbx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$202, %esi
	movq	%rax, %rdi
	jmp	.L58
.L51:
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movl	$4, %edx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L52
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	movl	$4, %edx
	movq	%rax, %rbx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$203, %esi
	movq	%rax, %rdi
	jmp	.L58
.L52:
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	testl	%eax, %eax
	je	.L53
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, %rbx
	call	cudaFree@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$206, %esi
	movq	%rax, %rdi
	jmp	.L58
.L53:
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	testl	%eax, %eax
	je	.L54
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	16(%rsp), %rdi
	movq	%rax, %rbx
	call	cudaFree@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$207, %esi
	movq	%rax, %rdi
	jmp	.L58
.L54:
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	testl	%eax, %eax
	je	.L55
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	24(%rsp), %rdi
	movq	%rax, %rbx
	call	cudaFree@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$208, %esi
	movq	%rax, %rdi
	jmp	.L58
.L55:
	movq	%rbx, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	568(%rsp), %rax
	subq	%fs:40, %rax
	je	.L56
	call	__stack_chk_fail@PLT
.L56:
	addq	$584, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3638:
	.size	main, .-main
	.section	.rodata.str1.1
.LC6:
	.string	"_Z4pfacP8automatoPiPc"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3666:
	.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	.LC6(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z4pfacP8automatoPiPc(%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
.LFE3666:
	.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
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <string.h>
#include <iostream>

#define BLOCOS     1
//#define THREAD

#define CHECK_ERROR(call) do {                                                    \
   if( hipSuccess != call) {                                                             \
      std::cerr << std::endl << "CUDA ERRO: " <<                             \
         hipGetErrorString(call) <<  " in file: " << __FILE__                \
         << " in line: " << __LINE__ << std::endl;                               \
         exit(0);                                                                                 \
   } } while (0)

using namespace std;

typedef struct automato {
	char letra;
	automato *prox;
	automato *ant;
	automato *inf;
	int final;
} Automato;

__global__ void pfac(Automato* at, int *matches, char *frase){

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


}

Automato* newAutomato(Automato* ant) {
	Automato *nv = (Automato*) malloc(sizeof(Automato));
	nv->prox = NULL;
	nv->inf = NULL;
	nv->ant = ant;

	return nv;
}

Automato* addAlgarismo(Automato *at, char algm, int first) {
	if (at != NULL && at->letra == algm && first == 1) {
		return at;
	}
	// Caso algarismo novo seja diferente do algarismo da raiz
	else if (at != NULL && at->letra != algm && first == 1) {
		Automato *pt = at->inf;
		Automato *ant = pt;
		while (pt != NULL) {
			if (pt->letra == algm) {
				return pt;
			}
			else {
				if (pt != NULL) {
					ant = pt;
					pt = pt->inf;
				}

			}
		}
		Automato *nv = newAutomato(at);
		nv->letra = algm;
		if (ant != NULL) {
			ant->inf = nv;
			return ant->inf;
		}
		else {
			at->inf = nv;
			return at->inf;
		}

	}

	else if(at != NULL && first == 0)
	{
		Automato *pt = at->prox;
		Automato *ant = NULL;
		while (pt != NULL) {

			if (pt->letra == algm) {
				return pt;
			}
			else
			{
				ant = pt;
				pt = pt->inf;
			}
		}

		Automato *nv = newAutomato(at);
		nv->letra = algm;

		if (ant != NULL) {
			ant->inf = nv;
		}
		else {
			at->prox = nv;
		}

		return nv;
	}
	else
	{
		Automato *nv = newAutomato(NULL);
		nv->letra = algm;
		return nv;
	}
}

void imprimir(Automato *at)
{
	Automato *temp = at;

	while (temp != NULL) {
		printf("%c ", temp->letra);
		imprimir(temp->prox);
		temp = temp->inf;
		printf("\n");
	}

}

/*Automato* mallocGPU(Automato *at)
{
	Automato *temp = at;

	while (temp != NULL) {
		imprimir(temp->prox);
		temp = temp->inf;
	}
}*/

int main (int argc, char **argv)
{
	int GPU = 0;

	Automato *at = newAutomato(NULL);
	at->letra = 'a';
	at->prox = NULL;

	char frase[255] = "ab abg bede ef"; //"abc acd abb agd acc";
	int THREADS = strlen(frase);

	Automato *temp = at;

	int i = 0;
	int first = 1;

	while(frase[i] != '\0')
	{
		if(frase[i] != ' ')
		{
			temp = addAlgarismo(temp, frase[i], first);
			first = 0;
			//printf("Letra: %c\n", temp->letra);
		}
		else
		{
			temp->final = 1;
			temp = at;
			first = 1;
		}
		i++;

	}
	imprimir(at);

	// CPU
	char h_fita[255] = "ab abg bede ef";
	int *h_matches = (int*) malloc(sizeof(int));

	// GPU
	Automato *d_at = NULL;
	char *d_fita = NULL;
	int *d_matches = NULL;

	CHECK_ERROR(hipSetDevice(GPU));

	*h_matches = 0;

	//Reset na GPU selecionada
	CHECK_ERROR(hipDeviceReset());

	CHECK_ERROR(hipMalloc((void**) &d_at, sizeof(Automato*)));
	CHECK_ERROR(hipMalloc((void**) &d_fita, 255*sizeof(char)));
	CHECK_ERROR(hipMalloc((void**) &d_matches, sizeof(int)));

	//Copiando CPU --> GPU
	CHECK_ERROR(hipMemcpy(d_at, at, sizeof(Automato*),  hipMemcpyHostToDevice));
	CHECK_ERROR(hipMemcpy(d_fita, h_fita, 255*sizeof(char),  hipMemcpyHostToDevice));
	CHECK_ERROR(hipMemcpy(d_matches, h_matches, sizeof(int),  hipMemcpyHostToDevice));


	pfac <<<BLOCOS, THREADS>>> (d_at, d_matches, d_fita);

	//Copiando GPU --> CPU
	CHECK_ERROR(hipMemcpy(at, d_at, sizeof(Automato*),  hipMemcpyDeviceToHost));
	CHECK_ERROR(hipMemcpy(h_fita, d_fita, 255*sizeof(char),  hipMemcpyDeviceToHost));
	CHECK_ERROR(hipMemcpy(h_matches, d_matches, sizeof(int),  hipMemcpyDeviceToHost));

	// Liberando memória na GPU
	CHECK_ERROR(hipFree(d_at));
	CHECK_ERROR(hipFree(d_fita));
	CHECK_ERROR(hipFree(d_matches));

	// Liberando memória na CPU
	free(at);
	free(h_matches);
	free(h_fita);


   return EXIT_SUCCESS;
}




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

                                        # End of file scope inline assembly
	.globl	_Z19__device_stub__pfacP8automatoPiPc # -- Begin function _Z19__device_stub__pfacP8automatoPiPc
	.type	_Z19__device_stub__pfacP8automatoPiPc,@function
_Z19__device_stub__pfacP8automatoPiPc:  # @_Z19__device_stub__pfacP8automatoPiPc
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z4pfacP8automatoPiPc, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z19__device_stub__pfacP8automatoPiPc, .Lfunc_end0-_Z19__device_stub__pfacP8automatoPiPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z11newAutomatoP8automato       # -- Begin function _Z11newAutomatoP8automato
	.type	_Z11newAutomatoP8automato,@function
_Z11newAutomatoP8automato:              # @_Z11newAutomatoP8automato
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movl	$40, %edi
	callq	malloc
	xorl	%ecx, %ecx
	movq	%rcx, 8(%rax)
	movq	%rcx, 24(%rax)
	movq	%rbx, 16(%rax)
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z11newAutomatoP8automato, .Lfunc_end1-_Z11newAutomatoP8automato
	.cfi_endproc
                                        # -- End function
	.globl	_Z12addAlgarismoP8automatoci    # -- Begin function _Z12addAlgarismoP8automatoci
	.type	_Z12addAlgarismoP8automatoci,@function
_Z12addAlgarismoP8automatoci:           # @_Z12addAlgarismoP8automatoci
	.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
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	testq	%rdi, %rdi
	je	.LBB2_21
# %bb.1:
	movq	%rdi, %rbx
	movb	(%rdi), %al
	cmpl	$1, %edx
	jne	.LBB2_4
# %bb.2:
	cmpb	%bpl, %al
	jne	.LBB2_4
# %bb.3:
	movq	%rbx, %rax
	jmp	.LBB2_22
.LBB2_4:
	cmpl	$1, %edx
	jne	.LBB2_13
# %bb.5:
	cmpb	%bpl, %al
	je	.LBB2_13
# %bb.6:
	movq	24(%rbx), %rax
	testq	%rax, %rax
	je	.LBB2_7
.LBB2_8:                                # %.lr.ph79
                                        # =>This Inner Loop Header: Depth=1
	movq	%rax, %r14
	cmpb	%bpl, (%rax)
	je	.LBB2_17
# %bb.9:                                #   in Loop: Header=BB2_8 Depth=1
	movq	24(%r14), %rax
	testq	%rax, %rax
	jne	.LBB2_8
	jmp	.LBB2_10
.LBB2_13:                               # %.critedge
	testl	%edx, %edx
	je	.LBB2_14
.LBB2_21:                               # %.critedge.thread
	movl	$40, %edi
	callq	malloc
	xorps	%xmm0, %xmm0
	movups	%xmm0, 8(%rax)
	movq	$0, 24(%rax)
	movb	%bpl, (%rax)
.LBB2_22:                               # %.loopexit
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_14:
	.cfi_def_cfa_offset 32
	movq	8(%rbx), %rax
	testq	%rax, %rax
	je	.LBB2_15
.LBB2_16:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%rax, %r14
	cmpb	%bpl, (%rax)
	je	.LBB2_17
# %bb.18:                               #   in Loop: Header=BB2_16 Depth=1
	movq	24(%r14), %rax
	testq	%rax, %rax
	jne	.LBB2_16
	jmp	.LBB2_19
.LBB2_17:
	movq	%r14, %rax
	jmp	.LBB2_22
.LBB2_7:
	xorl	%r14d, %r14d
.LBB2_10:                               # %._crit_edge80
	movl	$40, %edi
	callq	malloc
	xorl	%ecx, %ecx
	movq	%rcx, 8(%rax)
	movq	%rcx, 24(%rax)
	movq	%rbx, 16(%rax)
	movb	%bpl, (%rax)
	testq	%r14, %r14
	jne	.LBB2_11
# %bb.12:
	movq	%rax, 24(%rbx)
	jmp	.LBB2_22
.LBB2_15:
	xorl	%r14d, %r14d
.LBB2_19:                               # %._crit_edge
	movl	$40, %edi
	callq	malloc
	xorl	%ecx, %ecx
	movq	%rcx, 8(%rax)
	movq	%rcx, 24(%rax)
	movq	%rbx, 16(%rax)
	movb	%bpl, (%rax)
	testq	%r14, %r14
	je	.LBB2_20
.LBB2_11:
	movq	%rax, 24(%r14)
	jmp	.LBB2_22
.LBB2_20:
	movq	%rax, 8(%rbx)
	jmp	.LBB2_22
.Lfunc_end2:
	.size	_Z12addAlgarismoP8automatoci, .Lfunc_end2-_Z12addAlgarismoP8automatoci
	.cfi_endproc
                                        # -- End function
	.globl	_Z8imprimirP8automato           # -- Begin function _Z8imprimirP8automato
	.type	_Z8imprimirP8automato,@function
_Z8imprimirP8automato:                  # @_Z8imprimirP8automato
	.cfi_startproc
# %bb.0:
	testq	%rdi, %rdi
	je	.LBB3_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%rbx), %esi
	movl	$.L.str, %edi
	xorl	%eax, %eax
	callq	printf
	movq	8(%rbx), %rdi
	callq	_Z8imprimirP8automato
	movq	24(%rbx), %rbx
	movl	$10, %edi
	callq	putchar@PLT
	testq	%rbx, %rbx
	jne	.LBB3_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
.LBB3_4:                                # %._crit_edge
	retq
.Lfunc_end3:
	.size	_Z8imprimirP8automato, .Lfunc_end3-_Z8imprimirP8automato
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$296, %rsp                      # imm = 0x128
	.cfi_def_cfa_offset 320
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	$40, %edi
	callq	malloc
	movq	%rax, %rbx
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rax)
	movb	$97, (%rax)
	movq	$0, 8(%rax)
	movl	$1, %edx
	movb	$97, %cl
	movq	$-14, %r14
.LBB4_1:                                # =>This Inner Loop Header: Depth=1
	cmpb	$32, %cl
	jne	.LBB4_2
# %bb.3:                                #   in Loop: Header=BB4_1 Depth=1
	movl	$1, 32(%rax)
	movl	$1, %edx
	movq	%rbx, %rax
	jmp	.LBB4_4
.LBB4_2:                                #   in Loop: Header=BB4_1 Depth=1
	movsbl	%cl, %esi
	movq	%rax, %rdi
	callq	_Z12addAlgarismoP8automatoci
	xorl	%edx, %edx
.LBB4_4:                                #   in Loop: Header=BB4_1 Depth=1
	movb	.L__const.main.h_fita+15(%r14), %cl
	incq	%r14
	jne	.LBB4_1
# %bb.5:
	movq	%rbx, %rdi
	callq	_Z8imprimirP8automato
	leaq	32(%rsp), %rdi
	movl	$.L__const.main.h_fita, %esi
	movl	$255, %edx
	callq	memcpy@PLT
	movl	$4, %edi
	callq	malloc
	movq	%rax, %r14
	xorl	%eax, %eax
	movq	%rax, 24(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 8(%rsp)
	xorl	%edi, %edi
	callq	hipSetDevice
	testl	%eax, %eax
	jne	.LBB4_6
# %bb.7:
	movl	$0, (%r14)
	callq	hipDeviceReset
	testl	%eax, %eax
	jne	.LBB4_8
# %bb.10:
	leaq	24(%rsp), %rdi
	movl	$8, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_11
# %bb.12:
	leaq	16(%rsp), %rdi
	movl	$255, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_13
# %bb.14:
	leaq	8(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_15
# %bb.16:
	movq	24(%rsp), %rdi
	movl	$8, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_17
# %bb.18:
	movq	16(%rsp), %rdi
	leaq	32(%rsp), %rsi
	movl	$255, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_19
# %bb.20:
	movq	8(%rsp), %rdi
	movl	$4, %edx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_21
# %bb.22:
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	leaq	13(%rdi), %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_24
# %bb.23:
	movq	24(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdx
	callq	_Z19__device_stub__pfacP8automatoPiPc
.LBB4_24:
	movq	24(%rsp), %rsi
	movl	$8, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_25
# %bb.26:
	movq	16(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movl	$255, %edx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_27
# %bb.28:
	movq	8(%rsp), %rsi
	movl	$4, %edx
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_29
# %bb.30:
	movq	24(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB4_31
# %bb.32:
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB4_33
# %bb.34:
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB4_35
# %bb.36:
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	leaq	32(%rsp), %rdi
	callq	free
	xorl	%eax, %eax
	addq	$296, %rsp                      # imm = 0x128
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB4_6:
	.cfi_def_cfa_offset 320
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	xorl	%edi, %edi
	callq	hipSetDevice
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$183, %esi
	jmp	.LBB4_9
.LBB4_8:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	callq	hipDeviceReset
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$188, %esi
	jmp	.LBB4_9
.LBB4_11:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	leaq	24(%rsp), %rdi
	movl	$8, %esi
	callq	hipMalloc
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$190, %esi
	jmp	.LBB4_9
.LBB4_13:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	leaq	16(%rsp), %rdi
	movl	$255, %esi
	callq	hipMalloc
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$191, %esi
	jmp	.LBB4_9
.LBB4_15:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	leaq	8(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$192, %esi
	jmp	.LBB4_9
.LBB4_17:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %r14
	movq	24(%rsp), %rdi
	movl	$8, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$195, %esi
	jmp	.LBB4_9
.LBB4_19:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movq	16(%rsp), %rdi
	leaq	32(%rsp), %rsi
	movl	$255, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$196, %esi
	jmp	.LBB4_9
.LBB4_21:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movq	8(%rsp), %rdi
	movl	$4, %edx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$197, %esi
	jmp	.LBB4_9
.LBB4_25:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %r14
	movq	24(%rsp), %rsi
	movl	$8, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$203, %esi
	jmp	.LBB4_9
.LBB4_27:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movq	16(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movl	$255, %edx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$204, %esi
	jmp	.LBB4_9
.LBB4_29:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movq	8(%rsp), %rsi
	movl	$4, %edx
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$205, %esi
	jmp	.LBB4_9
.LBB4_31:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movq	24(%rsp), %rdi
	callq	hipFree
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$208, %esi
	jmp	.LBB4_9
.LBB4_33:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movq	16(%rsp), %rdi
	callq	hipFree
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$209, %esi
	jmp	.LBB4_9
.LBB4_35:
	movl	$_ZSt4cerr, %edi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rbx
	movq	8(%rsp), %rdi
	callq	hipFree
	movl	%eax, %edi
	callq	hipGetErrorString
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movl	$210, %esi
.LBB4_9:
	callq	_ZNSolsEi
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	xorl	%edi, %edi
	callq	exit
.Lfunc_end4:
	.size	main, .Lfunc_end4-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	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z4pfacP8automatoPiPc, %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_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z4pfacP8automatoPiPc,@object   # @_Z4pfacP8automatoPiPc
	.section	.rodata,"a",@progbits
	.globl	_Z4pfacP8automatoPiPc
	.p2align	3, 0x0
_Z4pfacP8automatoPiPc:
	.quad	_Z19__device_stub__pfacP8automatoPiPc
	.size	_Z4pfacP8automatoPiPc, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%c "
	.size	.L.str, 4

	.type	.L__const.main.h_fita,@object   # @__const.main.h_fita
	.section	.rodata,"a",@progbits
	.p2align	4, 0x0
.L__const.main.h_fita:
	.asciz	"ab abg bede ef\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
	.size	.L__const.main.h_fita, 255

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"CUDA ERRO: "
	.size	.L.str.2, 12

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	" in file: "
	.size	.L.str.3, 11

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/juliobarbieri/pf-aho-corasick/master/pfac.hip"
	.size	.L.str.4, 108

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	" in line: "
	.size	.L.str.5, 11

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z4pfacP8automatoPiPc"
	.size	.L__unnamed_1, 22

	.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

	.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 _Z19__device_stub__pfacP8automatoPiPc
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z4pfacP8automatoPiPc
	.addrsig_sym _ZSt4cerr
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z4pfacP8automatoPiPc   ; -- Begin function _Z4pfacP8automatoPiPc
	.globl	_Z4pfacP8automatoPiPc
	.p2align	8
	.type	_Z4pfacP8automatoPiPc,@function
_Z4pfacP8automatoPiPc:                  ; @_Z4pfacP8automatoPiPc
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z4pfacP8automatoPiPc
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.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 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.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	_Z4pfacP8automatoPiPc, .Lfunc_end0-_Z4pfacP8automatoPiPc
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; 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
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z4pfacP8automatoPiPc
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z4pfacP8automatoPiPc.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
