#include <stdio.h>

const int N = 20; 
const int MAX_WORD_SIZE = 1024;

	__global__ 
void hello(char *a, char *b, int *c, int size, int msize) 
{
	int i = 0;
	
	for(i = 0; i < msize; i++){
		if(a[N * threadIdx.x + i] != b[i]){
			c[threadIdx.x] = 0;
			break;
		}
		if(i == msize - 1){
			c[threadIdx.x] = 1;
			break;
		}
	}
}

int main()
{
	char words[MAX_WORD_SIZE][N];
	FILE *fp;
	char *fname = "input_text.txt";
	int c;

	int i = 0;
	int word_count = 0;

	// File Load
	fp = fopen( fname, "r" );
	if( fp == NULL ){
		printf( "%sファイルが開けません¥n", fname );
		return -1;
	}

	while( (c = fgetc( fp )) != EOF ){
		if(c != ',' && c != '.' && c != ' ' && c != '\n' && c != '\t' && c != '\0'){
			//printf("%c", c);
			words[word_count][i] = c;
			i++;
		}
		else{
			if(i != 0){
				//printf("\n");
				words[word_count][i] = '\0';
				word_count++;
				i = 0;
			}
		}
	}

	/*
	printf("Input: \n");
	for(i = 0; i < word_count; i++){
		printf("%s\n", words[i]);
	}
	*/
	char match_word[N] = {"in"};

	int count[word_count];

	char *ad, *bd;
	int *cd;

	const int csize = word_count*N*sizeof(char);
	const int bsize = strlen(match_word)*sizeof(char);
	const int isize = word_count*sizeof(int);

	cudaMalloc( (void**)&ad, csize ); 
	cudaMalloc( (void**)&bd, bsize ); 
	cudaMalloc( (void**)&cd, isize );

	cudaMemcpy( ad, words, csize, cudaMemcpyHostToDevice ); 
	cudaMemcpy( bd, match_word, bsize, cudaMemcpyHostToDevice ); 

	dim3 dimBlock( word_count, 1 );
	dim3 dimGrid( 1, 1 );
	hello<<<dimGrid, dimBlock>>>(ad, bd, cd, word_count, bsize);
	cudaMemcpy( count, cd, isize, cudaMemcpyDeviceToHost ); 
	cudaFree( ad );
	cudaFree( bd );
	cudaFree( cd );

	int ans = 0;

	for(i = 0; i < word_count; i++){
		ans += count[i];
		//printf("%s, %d\n", words[i], count[i]);
	}
	printf("%s: %d\n", match_word, ans);
	
	return EXIT_SUCCESS;
}

	.file	"tmpxft_0038907a_00000000-6_cuda_string_match.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z30__device_stub__Z5helloPcS_PiiiPcS_Piii
	.type	_Z30__device_stub__Z5helloPcS_PiiiPcS_Piii, @function
_Z30__device_stub__Z5helloPcS_PiiiPcS_Piii:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%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)
	leaq	4(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z5helloPcS_Piii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L2:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z30__device_stub__Z5helloPcS_PiiiPcS_Piii, .-_Z30__device_stub__Z5helloPcS_PiiiPcS_Piii
	.globl	_Z5helloPcS_Piii
	.type	_Z5helloPcS_Piii, @function
_Z5helloPcS_Piii:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z5helloPcS_PiiiPcS_Piii
	.cfi_endproc
.LFE2053:
	.size	_Z5helloPcS_Piii, .-_Z5helloPcS_Piii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"input_text.txt"
.LC2:
	.string	"%s\343\203\225\343\202\241\343\202\244\343\203\253\343\201\214\351\226\213\343\201\221\343\201\276\343\201\233\343\202\223\302\245n"
.LC3:
	.string	"%s: %d\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	leaq	-20480(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$104, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	leaq	.LC1(%rip), %r15
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	leaq	.LC0(%rip), %rsi
	movq	%r15, %rdi
	movabsq	$-87965225190914, %r13
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	fopen@PLT
	movq	%rax, %r14
	testq	%rax, %rax
	jne	.L9
	movq	%r15, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	orl	$-1, %eax
	jmp	.L8
.L14:
	cmpl	$46, %eax
	jbe	.L31
.L11:
	movslq	%ebx, %rdx
	movslq	%r12d, %rcx
	incl	%r12d
	imulq	$20, %rdx, %rdx
	leaq	-48(%rdx), %rsi
	leaq	(%rsi,%rbp), %rdx
	movb	%al, -20508(%rcx,%rdx)
.L9:
	movq	%r14, %rdi
	call	fgetc@PLT
	cmpl	$-1, %eax
	jne	.L14
	jmp	.L32
.L31:
	btq	%rax, %r13
	jc	.L11
	testl	%r12d, %r12d
	je	.L9
	movslq	%ebx, %rax
	movslq	%r12d, %r12
	incl	%ebx
	imulq	$20, %rax, %rax
	subq	$48, %rax
	addq	%rbp, %rax
	movb	$0, -20508(%r12,%rax)
	xorl	%r12d, %r12d
	jmp	.L9
.L32:
	xorl	%edx, %edx
	movslq	%ebx, %r12
	xorl	%eax, %eax
	movq	$28265, -76(%rbp)
	movl	%edx, -60(%rbp)
	leaq	15(,%r12,4), %rdx
	movq	%rsp, %rcx
	movq	%rax, -68(%rbp)
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L15:
	cmpq	%rcx, %rsp
	je	.L16
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L15
.L16:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L17
	orq	$0, -8(%rsp,%rax)
.L17:
	leaq	-76(%rbp), %r14
	sall	$2, %r12d
	movq	%rsp, %r15
	movq	%r14, %rdi
	movslq	%r12d, %r12
	call	strlen@PLT
	imull	$20, %ebx, %edx
	leaq	-20608(%rbp), %rdi
	movq	%rax, %r13
	movslq	%edx, %rdx
	movq	%rdx, %rsi
	movq	%rdx, -20616(%rbp)
	call	cudaMalloc@PLT
	leaq	-20600(%rbp), %rdi
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	leaq	-20592(%rbp), %rdi
	movq	%r12, %rsi
	call	cudaMalloc@PLT
	movq	-20616(%rbp), %rdx
	movl	$1, %ecx
	movq	-20608(%rbp), %rdi
	leaq	-20556(%rbp), %rsi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movq	%r13, %rdx
	movq	%r14, %rsi
	movq	-20600(%rbp), %rdi
	call	cudaMemcpy@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	%ebx, -20580(%rbp)
	movq	%rdi, -20576(%rbp)
	movl	-20572(%rbp), %ecx
	movq	-20580(%rbp), %rdx
	movq	%rdi, -20568(%rbp)
	movl	$1, -20560(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	movq	-20592(%rbp), %rdx
	movq	-20600(%rbp), %rsi
	movl	%r13d, %r8d
	movl	%ebx, %ecx
	movq	-20608(%rbp), %rdi
	call	_Z30__device_stub__Z5helloPcS_PiiiPcS_Piii
.L18:
	movq	-20592(%rbp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdx
	movq	%r15, %rdi
	call	cudaMemcpy@PLT
	movq	-20608(%rbp), %rdi
	call	cudaFree@PLT
	movq	-20600(%rbp), %rdi
	call	cudaFree@PLT
	movq	-20592(%rbp), %rdi
	call	cudaFree@PLT
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.L19:
	cmpl	%eax, %ebx
	jle	.L33
	addl	(%r15,%rax,4), %ecx
	incq	%rax
	jmp	.L19
.L33:
	movq	%r14, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
.L8:
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC4:
	.string	"_Z5helloPcS_Piii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.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	.LC4(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z5helloPcS_Piii(%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
.LFE2055:
	.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>

const int N = 20; 
const int MAX_WORD_SIZE = 1024;

	__global__ 
void hello(char *a, char *b, int *c, int size, int msize) 
{
	int i = 0;
	
	for(i = 0; i < msize; i++){
		if(a[N * threadIdx.x + i] != b[i]){
			c[threadIdx.x] = 0;
			break;
		}
		if(i == msize - 1){
			c[threadIdx.x] = 1;
			break;
		}
	}
}

int main()
{
	char words[MAX_WORD_SIZE][N];
	FILE *fp;
	char *fname = "input_text.txt";
	int c;

	int i = 0;
	int word_count = 0;

	// File Load
	fp = fopen( fname, "r" );
	if( fp == NULL ){
		printf( "%sファイルが開けません¥n", fname );
		return -1;
	}

	while( (c = fgetc( fp )) != EOF ){
		if(c != ',' && c != '.' && c != ' ' && c != '\n' && c != '\t' && c != '\0'){
			//printf("%c", c);
			words[word_count][i] = c;
			i++;
		}
		else{
			if(i != 0){
				//printf("\n");
				words[word_count][i] = '\0';
				word_count++;
				i = 0;
			}
		}
	}

	/*
	printf("Input: \n");
	for(i = 0; i < word_count; i++){
		printf("%s\n", words[i]);
	}
	*/
	char match_word[N] = {"in"};

	int count[word_count];

	char *ad, *bd;
	int *cd;

	const int csize = word_count*N*sizeof(char);
	const int bsize = strlen(match_word)*sizeof(char);
	const int isize = word_count*sizeof(int);

	hipMalloc( (void**)&ad, csize ); 
	hipMalloc( (void**)&bd, bsize ); 
	hipMalloc( (void**)&cd, isize );

	hipMemcpy( ad, words, csize, hipMemcpyHostToDevice ); 
	hipMemcpy( bd, match_word, bsize, hipMemcpyHostToDevice ); 

	dim3 dimBlock( word_count, 1 );
	dim3 dimGrid( 1, 1 );
	hello<<<dimGrid, dimBlock>>>(ad, bd, cd, word_count, bsize);
	hipMemcpy( count, cd, isize, hipMemcpyDeviceToHost ); 
	hipFree( ad );
	hipFree( bd );
	hipFree( cd );

	int ans = 0;

	for(i = 0; i < word_count; i++){
		ans += count[i];
		//printf("%s, %d\n", words[i], count[i]);
	}
	printf("%s: %d\n", match_word, ans);
	
	return EXIT_SUCCESS;
}

	.text
	.file	"cuda_string_match.hip"
	.globl	_Z20__device_stub__helloPcS_Piii # -- Begin function _Z20__device_stub__helloPcS_Piii
	.type	_Z20__device_stub__helloPcS_Piii,@function
_Z20__device_stub__helloPcS_Piii:       # @_Z20__device_stub__helloPcS_Piii
	.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	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	movq	%rsp, %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%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	$_Z5helloPcS_Piii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	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	_Z20__device_stub__helloPcS_Piii, .Lfunc_end0-_Z20__device_stub__helloPcS_Piii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$20568, %rsp                    # imm = 0x5058
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_2
# %bb.1:                                # %.preheader.outer.preheader
	movq	%rax, %r14
	xorl	%r12d, %r12d
	movabsq	$175930450381826, %r15          # imm = 0xA00200000C02
.LBB1_9:                                # %.preheader.outer
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_3 Depth 2
	movl	%r12d, %eax
	movq	%rax, -96(%rbp)                 # 8-byte Spill
	leaq	(%rax,%rax,4), %rax
	leaq	-20608(,%rax,4), %r13
	addq	%rbp, %r13
	xorl	%eax, %eax
.LBB1_3:                                # %.preheader
                                        #   Parent Loop BB1_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%eax, %ebx
	movq	%r14, %rdi
	callq	fgetc
                                        # kill: def $eax killed $eax def $rax
	leal	1(%rax), %ecx
	cmpl	$47, %ecx
	ja	.LBB1_6
# %bb.4:                                # %.preheader
                                        #   in Loop: Header=BB1_3 Depth=2
	btq	%rcx, %r15
	jae	.LBB1_5
# %bb.7:                                #   in Loop: Header=BB1_3 Depth=2
	movl	$0, %eax
	testl	%ebx, %ebx
	je	.LBB1_3
	jmp	.LBB1_8
.LBB1_5:                                # %.preheader
                                        #   in Loop: Header=BB1_3 Depth=2
	testq	%rcx, %rcx
	je	.LBB1_10
.LBB1_6:                                #   in Loop: Header=BB1_3 Depth=2
	movslq	%ebx, %rcx
	movb	%al, (%rcx,%r13)
	incl	%ebx
	movl	%ebx, %eax
	jmp	.LBB1_3
.LBB1_8:                                #   in Loop: Header=BB1_9 Depth=1
	movslq	%ebx, %rax
	movb	$0, (%rax,%r13)
	incq	%r12
	jmp	.LBB1_9
.LBB1_10:
	movq	%rsp, -88(%rbp)                 # 8-byte Spill
	leaq	-128(%rbp), %rax
	movw	$28265, (%rax)                  # imm = 0x6E69
	xorps	%xmm0, %xmm0
	movups	%xmm0, 2(%rax)
	movw	$0, 18(%rax)
	movq	%rax, %rdi
	movq	%rsp, %r14
	movq	-96(%rbp), %rbx                 # 8-byte Reload
	leaq	15(,%rbx,4), %rax
	andq	$-16, %rax
	subq	%rax, %r14
	movq	%r14, %rsp
	leal	(,%rbx,4), %eax
	movq	%rax, -48(%rbp)                 # 8-byte Spill
	leal	(%rax,%rax,4), %r15d
	callq	strlen
	movq	%rax, %r13
	leaq	-72(%rbp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movq	%r13, -80(%rbp)                 # 8-byte Spill
	movslq	%r13d, %r13
	leaq	-64(%rbp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	movslq	-48(%rbp), %rsi                 # 4-byte Folded Reload
	leaq	-56(%rbp), %rdi
	movq	%rsi, -48(%rbp)                 # 8-byte Spill
	callq	hipMalloc
	leaq	-72(%rbp), %rax
	movq	(%rax), %rdi
	leaq	-20608(%rbp), %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	-64(%rbp), %rax
	movq	(%rax), %rdi
	leaq	-128(%rbp), %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rbx, %rdx
	btsq	$32, %rdx
	movabsq	$4294967296, %rdi               # imm = 0x100000000
	orq	$1, %rdi
	xorl	%r15d, %r15d
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_12
# %bb.11:
	movq	-72(%rbp), %rdi
	movq	-64(%rbp), %rsi
	movq	-56(%rbp), %rdx
	movl	%ebx, %ecx
	movq	-80(%rbp), %r8                  # 8-byte Reload
                                        # kill: def $r8d killed $r8d killed $r8
	callq	_Z20__device_stub__helloPcS_Piii
.LBB1_12:
	movq	-56(%rbp), %rsi
	movq	%r14, %rdi
	movq	-48(%rbp), %rdx                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movq	-72(%rbp), %rdi
	callq	hipFree
	movq	-64(%rbp), %rdi
	callq	hipFree
	movq	-56(%rbp), %rdi
	callq	hipFree
	testq	%rbx, %rbx
	je	.LBB1_15
# %bb.13:                               # %.lr.ph.preheader
	xorl	%r15d, %r15d
.LBB1_14:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	addl	(%r14), %r15d
	addq	$4, %r14
	decq	%r12
	jne	.LBB1_14
.LBB1_15:                               # %._crit_edge
	xorl	%ebx, %ebx
	leaq	-128(%rbp), %rsi
	movl	$.L.str.3, %edi
	movl	%r15d, %edx
	xorl	%eax, %eax
	callq	printf
	movq	-88(%rbp), %rsp                 # 8-byte Reload
	jmp	.LBB1_16
.LBB1_2:
	movl	$.L.str.2, %edi
	movl	$.L.str, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$-1, %ebx
.LBB1_16:
	movl	%ebx, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end1:
	.size	main, .Lfunc_end1-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	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z5helloPcS_Piii, %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_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z5helloPcS_Piii,@object        # @_Z5helloPcS_Piii
	.section	.rodata,"a",@progbits
	.globl	_Z5helloPcS_Piii
	.p2align	3, 0x0
_Z5helloPcS_Piii:
	.quad	_Z20__device_stub__helloPcS_Piii
	.size	_Z5helloPcS_Piii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"input_text.txt"
	.size	.L.str, 15

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%s\343\203\225\343\202\241\343\202\244\343\203\253\343\201\214\351\226\213\343\201\221\343\201\276\343\201\233\343\202\223\302\245n"
	.size	.L.str.2, 36

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"%s: %d\n"
	.size	.L.str.3, 8

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z5helloPcS_Piii"
	.size	.L__unnamed_1, 17

	.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 _Z20__device_stub__helloPcS_Piii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z5helloPcS_Piii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z5helloPcS_Piii        ; -- Begin function _Z5helloPcS_Piii
	.globl	_Z5helloPcS_Piii
	.p2align	8
	.type	_Z5helloPcS_Piii,@function
_Z5helloPcS_Piii:                       ; @_Z5helloPcS_Piii
; %bb.0:
	s_load_b32 s8, s[0:1], 0x1c
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s8, 1
	s_cbranch_scc1 .LBB0_9
; %bb.1:                                ; %.lr.ph
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[2:3], s[0:1], 0x10
	v_mul_u32_u24_e32 v1, 20, v0
	v_mov_b32_e32 v4, 0
	s_mov_b32 s1, exec_lo
	s_waitcnt lgkmcnt(0)
	global_load_u8 v2, v1, s[4:5]
	global_load_u8 v3, v4, s[6:7]
	s_waitcnt vmcnt(0)
	v_cmpx_eq_u16_e64 v2, v3
	s_cbranch_execz .LBB0_8
; %bb.2:                                ; %.lr.ph20.preheader
	v_add_co_u32 v1, s0, s4, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v2, null, s5, 0, s0
	v_mov_b32_e32 v3, 0
	v_add_co_u32 v1, vcc_lo, v1, 1
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	s_add_i32 s8, s8, -1
	s_add_u32 s4, s6, 1
	s_addc_u32 s5, s7, 0
	s_mov_b32 s6, 0
                                        ; implicit-def: $sgpr7
.LBB0_3:                                ; %.lr.ph20
                                        ; =>This Inner Loop Header: Depth=1
	s_or_b32 s7, s7, exec_lo
	s_cmp_lg_u32 s8, 0
	s_cbranch_scc0 .LBB0_5
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	global_load_u8 v4, v[1:2], off
	global_load_u8 v5, v3, s[4:5]
	s_add_u32 s4, s4, 1
	v_add_co_u32 v1, s0, v1, 1
	s_addc_u32 s5, s5, 0
	s_and_not1_b32 s7, s7, exec_lo
	v_add_co_ci_u32_e64 v2, s0, 0, v2, s0
	s_add_i32 s8, s8, -1
	s_mov_b32 s0, 0
	s_waitcnt vmcnt(0)
	v_cmp_ne_u16_e32 vcc_lo, v4, v5
	s_and_b32 s9, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s7, s7, s9
	s_branch .LBB0_6
.LBB0_5:                                ;   in Loop: Header=BB0_3 Depth=1
	s_mov_b32 s0, 1
                                        ; implicit-def: $sgpr4_sgpr5
                                        ; implicit-def: $vgpr1_vgpr2
                                        ; implicit-def: $sgpr8
.LBB0_6:                                ; %Flow
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_mov_b32_e32 v4, s0
	s_and_b32 s9, exec_lo, s7
	s_or_b32 s6, s9, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s6
	s_cbranch_execnz .LBB0_3
; %bb.7:                                ; %Flow38
	s_or_b32 exec_lo, exec_lo, s6
.LBB0_8:                                ; %Flow39
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s1
	v_lshlrev_b32_e32 v0, 2, v0
	global_store_b32 v0, v4, s[2:3]
.LBB0_9:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z5helloPcS_Piii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.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 10
		.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	_Z5helloPcS_Piii, .Lfunc_end0-_Z5helloPcS_Piii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 300
; NumSgprs: 12
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 12
; 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
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 32
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z5helloPcS_Piii
    .private_segment_fixed_size: 0
    .sgpr_count:     12
    .sgpr_spill_count: 0
    .symbol:         _Z5helloPcS_Piii.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
