#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>


void genRandomString(char *str,int length)
{
  for(int i=0;i<length-1;++i)
  {
    str[i] = 'a' + rand()%26;
  }
  str[length-1] = '\0';
}
void genRandomSubString(char *str,int length,int sub_len)
{
  for(int i=0;i<length-1;++i)
  {
    if(i>0 && ((i+1)%sub_len==0)) str[i] = '\0';
    else str[i] = 'a' + rand()%26;
  }
  str[length-1] = '\0';
}

/*__global__ void my_strstr(char *str,char *sub_string,char ** position,int str_len,int sub_len,int num_sub)
{
  int id = threadIdx.x;
  char *sub = &sub_string[id*sub_len];
  char *string = str;
  char *a,*b;
  b = sub;
  printf("in GPU string is %s sub is %s\n",string,b);
  for(;*string != '\0';++string){
    a = string;
    if(*a == *b){
      printf("thread %d find a possible sub %s\n",id,b);
      while(*(++a) == *(++b)){
        printf("thread %d find a more and more possible sub %s\n",id,b);
        if(*(b+1) == '\0'){ 
          printf("thread %d find a sub %s\n",id,b);
          position[id] = string;
          printf("sting match in %s\n",position[id]);
        }
      }
    }
    b = sub;
  }
}*/

char * my_strstr(char *str,char *sub,int str_len,int sub_len)
{
  if(str_len < sub_len) return NULL;
  if(str_len != 0 && sub_len == 0) return NULL;
  if(str_len == 0 && sub_len == 0) return NULL;
  int m, n;
  for(int i=0;i<str_len;++i){
    m = 0;
    n = i;
    if(str[n]==sub[m]){
      while(str[++n] == sub[++m]){
        if(sub[m+1] == '\0') return str+i;
      }
    }
  }
  return NULL;
}



__global__ void my_strstr(char *str,char *sub_string,char ** position,int str_len,int sub_len,int num_sub)
{
  int id = threadIdx.x; 
  //char *sub = &sub_string[id*sub_len];
  char *result = NULL; 
  char sub[24];
  //load sub in register,great improve
  for(int i=0;i<sub_len;++i){
    sub[i] = sub_string[id*sub_len+i];}
  //best case using Shared memory
  extern __shared__ char s_string[];
  //every thread has to fetch how many values from global memory to shared memory
  int each_num = str_len/blockDim.x;
  for(int i=0;i<each_num;++i){
    s_string[i*blockDim.x+id] = str[i*blockDim.x+id];}
  if( ((each_num*blockDim.x+id) < str_len) && (blockDim.x > each_num) )
    s_string[each_num*blockDim.x+id] = str[each_num*blockDim.x+id];

  char *string = s_string;
  char *a,*b;
  //b point to the sub address in register rather than in global memory
  b = sub;
  //result == NULL to judge if we find a match;rather than use goto or break in loop which harm the calculation
  for(int i = 0;(*string != '\0')&&(result == NULL);i++){
    //printf("i am %d\n",id);
    a = string;
    while(*a++ == *b++){
      if(*(b+1) == '\0'){ 
        result = string;
      }
    }
    b = sub;
    ++string;
  }
  //coalesced global memory store, no effect since we only store once 
  position[id] = result;
}




int main()
{
  int LENGTH = 4096, len = 24, num_sub = 100;
  int num_block,num_thread;
  if(num_sub < 512){
    num_block = 1;
    num_thread = num_sub;
  }
  else{
    num_block = num_sub / 512;
    num_thread = 512;
  }
  char haystack[LENGTH];
  char subs[num_sub*len];
  char *position[num_sub];
  char *h_position[num_sub];
  genRandomString(haystack,LENGTH);
  genRandomSubString(subs,len*num_sub,len);

  char *d_string,*d_subs;
  char **d_position;
  cudaMalloc((void**)&d_string,sizeof(char)*LENGTH);
  cudaMalloc((void**)&d_subs,sizeof(char)*num_sub*len);
  cudaMalloc((void***)&d_position,sizeof(char*)*num_sub);
  cudaMemset(d_position,0,sizeof(char*)*num_sub);
  memset(h_position,0,sizeof(char*)*num_sub);
  const size_t smem = sizeof(char)*LENGTH;
  char h_subs[num_sub][len];
  for(int i=0;i<num_sub;++i){
    for(int j=0;j<len;++j){
      h_subs[i][j] = subs[i*len+j];
    }
  }
    
  /*CPU*/

  char *ret;
  struct timeval start,end;
  gettimeofday(&start, NULL );
  for(int i=0;i<num_sub;++i)
  {
    ret = my_strstr(haystack,h_subs[i],LENGTH,len);
    if(ret != NULL){
      printf("find one sub string in %d sub\n",i);
      printf("%s\n",ret);
    }
    position[i] = ret;
  }
  gettimeofday(&end, NULL );
  float timeuse =1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec;
  printf("CPU time=%f\n",timeuse /1000.0);
  
  /*GPU*/

  gettimeofday(&start, NULL );
  for(int i=0;i<50;++i)
  {
    cudaMemcpy(d_string,haystack,sizeof(char)*LENGTH,cudaMemcpyHostToDevice);
    cudaMemcpy(d_subs,subs,sizeof(char)*num_sub*len,cudaMemcpyHostToDevice);
    my_strstr<<<num_block,num_thread,smem>>>(d_string,d_subs,d_position,LENGTH,len,num_sub);
    cudaDeviceSynchronize();
    cudaMemcpy(h_position,d_position,sizeof(char*)*num_sub,cudaMemcpyDeviceToHost);
  }
  gettimeofday(&end, NULL );
  timeuse =1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec;
  printf("GPU time=%f\n",timeuse /1000.0/50);

  /*check*/

  //in small size GPU works well
  /*for(int i=0;i<num_sub;++i){
    if(h_position[i] == position[i]){
      printf("ok in %d sub\n",i);
      if(position[i] != NULL){
        printf("%s\n",position[i]);
      }
    }
    else{
      printf("error !!!!!!");
      if(position[i] != NULL){
        printf("CPU find match %s\n",position[i]);}
      //because h_position[i] point to the address in GPU , causing segment error
      if(h_position[i] != NULL){
        printf("GPU find match %s\n",h_position[i]);}
    }
  }*/

  return(0);
}

	.file	"tmpxft_002621a7_00000000-6_v1_match.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_Z9my_strstrPcS_ii.part.0, @function
_Z9my_strstrPcS_ii.part.0:
.LFB2175:
	.cfi_startproc
	xorl	%eax, %eax
.L3:
	cmpl	%eax, %edx
	jle	.L11
	movb	(%rsi), %cl
	cmpb	%cl, (%rdi,%rax)
	jne	.L4
	leaq	1(%rsi), %rcx
	movq	%rax, %r8
.L5:
	movb	(%rcx), %r10b
	movq	%rcx, %r9
	cmpb	%r10b, 1(%rdi,%r8)
	jne	.L4
	incq	%r8
	incq	%rcx
	cmpb	$0, 1(%r9)
	jne	.L5
	addq	%rdi, %rax
	ret
.L4:
	incq	%rax
	jmp	.L3
.L11:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE2175:
	.size	_Z9my_strstrPcS_ii.part.0, .-_Z9my_strstrPcS_ii.part.0
	.globl	_Z15genRandomStringPci
	.type	_Z15genRandomStringPci, @function
_Z15genRandomStringPci:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movslq	%esi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 48
	leal	-1(%rbx), %r13d
.L13:
	cmpl	%r12d, %r13d
	jle	.L16
	call	rand@PLT
	movl	$26, %ecx
	cltd
	idivl	%ecx
	addl	$97, %edx
	movb	%dl, 0(%rbp,%r12)
	incq	%r12
	jmp	.L13
.L16:
	movb	$0, -1(%rbp,%rbx)
	popq	%rax
	.cfi_def_cfa_offset 40
	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
.LFE2027:
	.size	_Z15genRandomStringPci, .-_Z15genRandomStringPci
	.globl	_Z18genRandomSubStringPcii
	.type	_Z18genRandomSubStringPcii, @function
_Z18genRandomSubStringPcii:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movslq	%esi, %rbx
	leal	-1(%rbx), %r14d
.L18:
	cmpl	%ebp, %r14d
	jle	.L28
	leal	1(%rbp), %eax
	testq	%rbp, %rbp
	je	.L19
	cltd
	idivl	%r13d
	xorl	%eax, %eax
	testl	%edx, %edx
	je	.L20
.L19:
	call	rand@PLT
	movl	$26, %ecx
	cltd
	idivl	%ecx
	leal	97(%rdx), %eax
.L20:
	movb	%al, (%r12,%rbp)
	incq	%rbp
	jmp	.L18
.L28:
	movb	$0, -1(%r12,%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z18genRandomSubStringPcii, .-_Z18genRandomSubStringPcii
	.globl	_Z9my_strstrPcS_ii
	.type	_Z9my_strstrPcS_ii, @function
_Z9my_strstrPcS_ii:
.LFB2029:
	.cfi_startproc
	endbr64
	cmpl	%ecx, %edx
	jl	.L29
	testl	%edx, %edx
	je	.L35
	testl	%ecx, %ecx
	je	.L29
.L35:
	orl	%edx, %ecx
	je	.L29
	jmp	_Z9my_strstrPcS_ii.part.0
.L29:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z9my_strstrPcS_ii, .-_Z9my_strstrPcS_ii
	.globl	_Z36__device_stub__Z9my_strstrPcS_PS_iiiPcS_PS_iii
	.type	_Z36__device_stub__Z9my_strstrPcS_PS_iiiPcS_PS_iii, @function
_Z36__device_stub__Z9my_strstrPcS_PS_iiiPcS_PS_iii:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	64(%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, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L40
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z9my_strstrPcS_PS_iii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L40:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z36__device_stub__Z9my_strstrPcS_PS_iiiPcS_PS_iii, .-_Z36__device_stub__Z9my_strstrPcS_PS_iiiPcS_PS_iii
	.globl	_Z9my_strstrPcS_PS_iii
	.type	_Z9my_strstrPcS_PS_iii, @function
_Z9my_strstrPcS_PS_iii:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z9my_strstrPcS_PS_iiiPcS_PS_iii
	.cfi_endproc
.LFE2056:
	.size	_Z9my_strstrPcS_PS_iii, .-_Z9my_strstrPcS_PS_iii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"find one sub string in %d sub\n"
.LC1:
	.string	"%s\n"
.LC3:
	.string	"CPU time=%f\n"
.LC5:
	.string	"GPU time=%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.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
	subq	$136, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	leaq	-4096(%rsp), %rax
.L46:
	cmpq	%rax, %rsp
	je	.L47
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L46
.L47:
	movq	%rsp, -152(%rbp)
.L49:
	movq	-152(%rbp), %rax
	cmpq	%rax, %rsp
	je	.L50
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L49
.L50:
	subq	$2400, %rsp
	orq	$0, 2392(%rsp)
	movq	%rsp, -160(%rbp)
.L52:
	movq	-160(%rbp), %rax
	cmpq	%rax, %rsp
	je	.L53
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L52
.L53:
	subq	$800, %rsp
	orq	$0, 792(%rsp)
	movq	%rsp, %r13
	movq	%rsp, %rax
.L55:
	cmpq	%rax, %rsp
	je	.L56
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L55
.L56:
	subq	$800, %rsp
	orq	$0, 792(%rsp)
	movl	$4096, %esi
	movq	-152(%rbp), %rdi
	movq	%rsp, -168(%rbp)
	call	_Z15genRandomStringPci
	movl	$24, %edx
	movl	$2400, %esi
	movq	-160(%rbp), %rdi
	call	_Z18genRandomSubStringPcii
	leaq	-136(%rbp), %rdi
	movl	$4096, %esi
	call	cudaMalloc@PLT
	leaq	-128(%rbp), %rdi
	movl	$2400, %esi
	call	cudaMalloc@PLT
	leaq	-120(%rbp), %rdi
	movl	$800, %esi
	call	cudaMalloc@PLT
	movq	-120(%rbp), %rdi
	movl	$800, %edx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movq	-168(%rbp), %rdi
	xorl	%eax, %eax
	movl	$200, %ecx
	rep stosl
	movq	%rsp, %rax
.L58:
	cmpq	%rax, %rsp
	je	.L59
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L58
.L59:
	subq	$2400, %rsp
	orq	$0, 2392(%rsp)
	movl	$600, %ecx
	xorl	%r12d, %r12d
	leaq	.LC0(%rip), %r15
	movq	-160(%rbp), %rsi
	movq	%rsp, %rdi
	leaq	-88(%rbp), %rax
	movq	%rsp, %r14
	rep movsl
	xorl	%esi, %esi
	movq	%rax, %rdi
	movq	%rax, -176(%rbp)
	call	gettimeofday@PLT
.L62:
	imulq	$24, %r12, %rsi
	movq	-152(%rbp), %rdi
	movl	$4096, %edx
	addq	%r14, %rsi
	call	_Z9my_strstrPcS_ii.part.0
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.L61
	movl	%r12d, %edx
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
.L61:
	movq	%rbx, 0(%r13,%r12,8)
	incq	%r12
	cmpq	$100, %r12
	jne	.L62
	leaq	-72(%rbp), %r13
	xorl	%esi, %esi
	movl	$50, %ebx
	movabsq	$4294967396, %r12
	movq	%r13, %rdi
	call	gettimeofday@PLT
	movq	-72(%rbp), %rax
	subq	-88(%rbp), %rax
	leaq	.LC3(%rip), %rsi
	imulq	$1000000, %rax, %rax
	addq	-64(%rbp), %rax
	subq	-80(%rbp), %rax
	movl	$2, %edi
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	cvtss2sd	%xmm0, %xmm0
	divsd	.LC2(%rip), %xmm0
	call	__printf_chk@PLT
	xorl	%esi, %esi
	movq	-176(%rbp), %rdi
	call	gettimeofday@PLT
.L64:
	movq	-152(%rbp), %rsi
	movl	$1, %ecx
	movl	$4096, %edx
	movq	-136(%rbp), %rdi
	call	cudaMemcpy@PLT
	movq	-160(%rbp), %rsi
	movq	-128(%rbp), %rdi
	movl	$1, %ecx
	movl	$2400, %edx
	call	cudaMemcpy@PLT
	xorl	%r9d, %r9d
	movq	%r12, %rdx
	movl	$1, %ecx
	movl	$4096, %r8d
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L63
	movq	-120(%rbp), %rdx
	movq	-128(%rbp), %rsi
	movl	$100, %r9d
	movl	$24, %r8d
	movq	-136(%rbp), %rdi
	movl	$4096, %ecx
	call	_Z36__device_stub__Z9my_strstrPcS_PS_iiiPcS_PS_iii
.L63:
	call	cudaDeviceSynchronize@PLT
	movq	-120(%rbp), %rsi
	movl	$2, %ecx
	movq	-168(%rbp), %rdi
	movl	$800, %edx
	call	cudaMemcpy@PLT
	decl	%ebx
	jne	.L64
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	gettimeofday@PLT
	movq	-72(%rbp), %rax
	subq	-88(%rbp), %rax
	leaq	.LC5(%rip), %rsi
	imulq	$1000000, %rax, %rax
	addq	-64(%rbp), %rax
	subq	-80(%rbp), %rax
	movl	$2, %edi
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	cvtss2sd	%xmm0, %xmm0
	divsd	.LC2(%rip), %xmm0
	divsd	.LC4(%rip), %xmm0
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L65
	call	__stack_chk_fail@PLT
.L65:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC6:
	.string	"_Z9my_strstrPcS_PS_iii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2058:
	.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	_Z9my_strstrPcS_PS_iii(%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
.LFE2058:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC2:
	.long	0
	.long	1083129856
	.align 8
.LC4:
	.long	0
	.long	1078525952
	.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 <string.h>
#include <stdlib.h>
#include <sys/time.h>


void genRandomString(char *str,int length)
{
  for(int i=0;i<length-1;++i)
  {
    str[i] = 'a' + rand()%26;
  }
  str[length-1] = '\0';
}
void genRandomSubString(char *str,int length,int sub_len)
{
  for(int i=0;i<length-1;++i)
  {
    if(i>0 && ((i+1)%sub_len==0)) str[i] = '\0';
    else str[i] = 'a' + rand()%26;
  }
  str[length-1] = '\0';
}

/*__global__ void my_strstr(char *str,char *sub_string,char ** position,int str_len,int sub_len,int num_sub)
{
  int id = threadIdx.x;
  char *sub = &sub_string[id*sub_len];
  char *string = str;
  char *a,*b;
  b = sub;
  printf("in GPU string is %s sub is %s\n",string,b);
  for(;*string != '\0';++string){
    a = string;
    if(*a == *b){
      printf("thread %d find a possible sub %s\n",id,b);
      while(*(++a) == *(++b)){
        printf("thread %d find a more and more possible sub %s\n",id,b);
        if(*(b+1) == '\0'){ 
          printf("thread %d find a sub %s\n",id,b);
          position[id] = string;
          printf("sting match in %s\n",position[id]);
        }
      }
    }
    b = sub;
  }
}*/

char * my_strstr(char *str,char *sub,int str_len,int sub_len)
{
  if(str_len < sub_len) return NULL;
  if(str_len != 0 && sub_len == 0) return NULL;
  if(str_len == 0 && sub_len == 0) return NULL;
  int m, n;
  for(int i=0;i<str_len;++i){
    m = 0;
    n = i;
    if(str[n]==sub[m]){
      while(str[++n] == sub[++m]){
        if(sub[m+1] == '\0') return str+i;
      }
    }
  }
  return NULL;
}



__global__ void my_strstr(char *str,char *sub_string,char ** position,int str_len,int sub_len,int num_sub)
{
  int id = threadIdx.x; 
  //char *sub = &sub_string[id*sub_len];
  char *result = NULL; 
  char sub[24];
  //load sub in register,great improve
  for(int i=0;i<sub_len;++i){
    sub[i] = sub_string[id*sub_len+i];}
  //best case using Shared memory
  extern __shared__ char s_string[];
  //every thread has to fetch how many values from global memory to shared memory
  int each_num = str_len/blockDim.x;
  for(int i=0;i<each_num;++i){
    s_string[i*blockDim.x+id] = str[i*blockDim.x+id];}
  if( ((each_num*blockDim.x+id) < str_len) && (blockDim.x > each_num) )
    s_string[each_num*blockDim.x+id] = str[each_num*blockDim.x+id];

  char *string = s_string;
  char *a,*b;
  //b point to the sub address in register rather than in global memory
  b = sub;
  //result == NULL to judge if we find a match;rather than use goto or break in loop which harm the calculation
  for(int i = 0;(*string != '\0')&&(result == NULL);i++){
    //printf("i am %d\n",id);
    a = string;
    while(*a++ == *b++){
      if(*(b+1) == '\0'){ 
        result = string;
      }
    }
    b = sub;
    ++string;
  }
  //coalesced global memory store, no effect since we only store once 
  position[id] = result;
}




int main()
{
  int LENGTH = 4096, len = 24, num_sub = 100;
  int num_block,num_thread;
  if(num_sub < 512){
    num_block = 1;
    num_thread = num_sub;
  }
  else{
    num_block = num_sub / 512;
    num_thread = 512;
  }
  char haystack[LENGTH];
  char subs[num_sub*len];
  char *position[num_sub];
  char *h_position[num_sub];
  genRandomString(haystack,LENGTH);
  genRandomSubString(subs,len*num_sub,len);

  char *d_string,*d_subs;
  char **d_position;
  hipMalloc((void**)&d_string,sizeof(char)*LENGTH);
  hipMalloc((void**)&d_subs,sizeof(char)*num_sub*len);
  hipMalloc((void***)&d_position,sizeof(char*)*num_sub);
  hipMemset(d_position,0,sizeof(char*)*num_sub);
  memset(h_position,0,sizeof(char*)*num_sub);
  const size_t smem = sizeof(char)*LENGTH;
  char h_subs[num_sub][len];
  for(int i=0;i<num_sub;++i){
    for(int j=0;j<len;++j){
      h_subs[i][j] = subs[i*len+j];
    }
  }
    
  /*CPU*/

  char *ret;
  struct timeval start,end;
  gettimeofday(&start, NULL );
  for(int i=0;i<num_sub;++i)
  {
    ret = my_strstr(haystack,h_subs[i],LENGTH,len);
    if(ret != NULL){
      printf("find one sub string in %d sub\n",i);
      printf("%s\n",ret);
    }
    position[i] = ret;
  }
  gettimeofday(&end, NULL );
  float timeuse =1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec;
  printf("CPU time=%f\n",timeuse /1000.0);
  
  /*GPU*/

  gettimeofday(&start, NULL );
  for(int i=0;i<50;++i)
  {
    hipMemcpy(d_string,haystack,sizeof(char)*LENGTH,hipMemcpyHostToDevice);
    hipMemcpy(d_subs,subs,sizeof(char)*num_sub*len,hipMemcpyHostToDevice);
    my_strstr<<<num_block,num_thread,smem>>>(d_string,d_subs,d_position,LENGTH,len,num_sub);
    hipDeviceSynchronize();
    hipMemcpy(h_position,d_position,sizeof(char*)*num_sub,hipMemcpyDeviceToHost);
  }
  gettimeofday(&end, NULL );
  timeuse =1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec;
  printf("GPU time=%f\n",timeuse /1000.0/50);

  /*check*/

  //in small size GPU works well
  /*for(int i=0;i<num_sub;++i){
    if(h_position[i] == position[i]){
      printf("ok in %d sub\n",i);
      if(position[i] != NULL){
        printf("%s\n",position[i]);
      }
    }
    else{
      printf("error !!!!!!");
      if(position[i] != NULL){
        printf("CPU find match %s\n",position[i]);}
      //because h_position[i] point to the address in GPU , causing segment error
      if(h_position[i] != NULL){
        printf("GPU find match %s\n",h_position[i]);}
    }
  }*/

  return(0);
}

	.text
	.file	"v1_match.hip"
	.globl	_Z15genRandomStringPci          # -- Begin function _Z15genRandomStringPci
	.type	_Z15genRandomStringPci,@function
_Z15genRandomStringPci:                 # @_Z15genRandomStringPci
	.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
                                        # kill: def $esi killed $esi def $rsi
	movq	%rdi, %rbx
	leal	-1(%rsi), %ebp
	cmpl	$2, %esi
	jl	.LBB0_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1321528399, %rax, %rcx         # imm = 0x4EC4EC4F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$35, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,4), %edx
	leal	(%rdx,%rdx,4), %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	addb	$97, %al
	movb	%al, (%rbx,%r15)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	movslq	%ebp, %rax
	movb	$0, (%rbx,%rax)
	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
.Lfunc_end0:
	.size	_Z15genRandomStringPci, .Lfunc_end0-_Z15genRandomStringPci
	.cfi_endproc
                                        # -- End function
	.globl	_Z18genRandomSubStringPcii      # -- Begin function _Z18genRandomSubStringPcii
	.type	_Z18genRandomSubStringPcii,@function
_Z18genRandomSubStringPcii:             # @_Z18genRandomSubStringPcii
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
                                        # kill: def $esi killed $esi def $rsi
	movq	%rdi, %rbx
	leal	-1(%rsi), %r15d
	cmpl	$2, %esi
	jl	.LBB1_8
# %bb.1:                                # %.lr.ph.preheader
	movl	%edx, %ebp
	movl	%r15d, %r12d
	xorl	%r13d, %r13d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	testq	%r13, %r13
	je	.LBB1_3
# %bb.5:                                #   in Loop: Header=BB1_2 Depth=1
	leaq	1(%r13), %r14
	movl	%r14d, %eax
	cltd
	idivl	%ebp
	testl	%edx, %edx
	jne	.LBB1_4
# %bb.6:                                #   in Loop: Header=BB1_2 Depth=1
	xorl	%eax, %eax
	jmp	.LBB1_7
.LBB1_3:                                #   in Loop: Header=BB1_2 Depth=1
	movl	$1, %r14d
.LBB1_4:                                # %.lr.ph._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	callq	rand
	cltq
	imulq	$1321528399, %rax, %rcx         # imm = 0x4EC4EC4F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	shrq	$35, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,4), %edx
	leal	(%rdx,%rdx,4), %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	addb	$97, %al
.LBB1_7:                                #   in Loop: Header=BB1_2 Depth=1
	movb	%al, (%rbx,%r13)
	movq	%r14, %r13
	cmpq	%r12, %r14
	jne	.LBB1_2
.LBB1_8:                                # %._crit_edge
	movslq	%r15d, %rax
	movb	$0, (%rbx,%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z18genRandomSubStringPcii, .Lfunc_end1-_Z18genRandomSubStringPcii
	.cfi_endproc
                                        # -- End function
	.globl	_Z9my_strstrPcS_ii              # -- Begin function _Z9my_strstrPcS_ii
	.type	_Z9my_strstrPcS_ii,@function
_Z9my_strstrPcS_ii:                     # @_Z9my_strstrPcS_ii
	.cfi_startproc
# %bb.0:
	cmpl	%ecx, %edx
	jge	.LBB2_3
# %bb.1:
	xorl	%eax, %eax
.LBB2_2:                                # %.loopexit35
	retq
.LBB2_3:
	testl	%edx, %edx
	setne	%r8b
	testl	%ecx, %ecx
	sete	%r9b
	xorl	%eax, %eax
	testl	%edx, %edx
	jle	.LBB2_2
# %bb.4:
	andb	%r9b, %r8b
	jne	.LBB2_2
# %bb.5:
	orl	%edx, %ecx
	je	.LBB2_2
# %bb.6:                                # %.lr.ph
	movb	(%rsi), %cl
	movl	%edx, %edx
	xorl	%eax, %eax
	movq	%rdi, %r9
	xorl	%r8d, %r8d
.LBB2_7:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_9 Depth 2
	cmpb	%cl, (%rdi,%r8)
	jne	.LBB2_12
# %bb.8:                                # %.preheader.preheader
                                        #   in Loop: Header=BB2_7 Depth=1
	movl	$1, %r10d
.LBB2_9:                                # %.preheader
                                        #   Parent Loop BB2_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movb	(%r9,%r10), %r11b
	cmpb	(%rsi,%r10), %r11b
	jne	.LBB2_12
# %bb.10:                               #   in Loop: Header=BB2_9 Depth=2
	cmpb	$0, 1(%rsi,%r10)
	leaq	1(%r10), %r10
	jne	.LBB2_9
	jmp	.LBB2_11
.LBB2_12:                               # %.loopexit
                                        #   in Loop: Header=BB2_7 Depth=1
	incq	%r8
	incq	%r9
	cmpq	%rdx, %r8
	jne	.LBB2_7
	jmp	.LBB2_2
.LBB2_11:                               # %.loopexit35.loopexit
	addq	%r8, %rdi
	movq	%rdi, %rax
	retq
.Lfunc_end2:
	.size	_Z9my_strstrPcS_ii, .Lfunc_end2-_Z9my_strstrPcS_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__my_strstrPcS_PS_iii # -- Begin function _Z24__device_stub__my_strstrPcS_PS_iii
	.type	_Z24__device_stub__my_strstrPcS_PS_iii,@function
_Z24__device_stub__my_strstrPcS_PS_iii: # @_Z24__device_stub__my_strstrPcS_PS_iii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	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	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	$_Z9my_strstrPcS_PS_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z24__device_stub__my_strstrPcS_PS_iii, .Lfunc_end3-_Z24__device_stub__my_strstrPcS_PS_iii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x408f400000000000              # double 1000
.LCPI4_1:
	.quad	0x4049000000000000              # double 50
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$7352, %rsp                     # imm = 0x1CB8
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	xorl	%ebx, %ebx
.LBB4_1:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1321528399, %rax, %rcx         # imm = 0x4EC4EC4F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$35, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,4), %edx
	leal	(%rdx,%rdx,4), %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	addb	$97, %al
	movb	%al, -7392(%rbp,%rbx)
	incq	%rbx
	cmpq	$4095, %rbx                     # imm = 0xFFF
	jne	.LBB4_1
# %bb.2:                                # %_Z15genRandomStringPci.exit
	movb	$0, -3297(%rbp)
	xorl	%ebx, %ebx
.LBB4_3:                                # %.lr.ph.i68
                                        # =>This Inner Loop Header: Depth=1
	testq	%rbx, %rbx
	je	.LBB4_4
# %bb.6:                                #   in Loop: Header=BB4_3 Depth=1
	leaq	1(%rbx), %r14
	imull	$-1431655765, %r14d, %eax       # imm = 0xAAAAAAAB
	addl	$715827880, %eax                # imm = 0x2AAAAAA8
	rorl	$3, %eax
	cmpl	$178956971, %eax                # imm = 0xAAAAAAB
	jae	.LBB4_5
# %bb.7:                                #   in Loop: Header=BB4_3 Depth=1
	xorl	%eax, %eax
	jmp	.LBB4_8
.LBB4_4:                                #   in Loop: Header=BB4_3 Depth=1
	movl	$1, %r14d
.LBB4_5:                                # %.lr.ph._crit_edge.i
                                        #   in Loop: Header=BB4_3 Depth=1
	callq	rand
	cltq
	imulq	$1321528399, %rax, %rcx         # imm = 0x4EC4EC4F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	shrq	$35, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,4), %edx
	leal	(%rdx,%rdx,4), %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	addb	$97, %al
.LBB4_8:                                #   in Loop: Header=BB4_3 Depth=1
	movb	%al, -3296(%rbp,%rbx)
	movq	%r14, %rbx
	cmpq	$2399, %r14                     # imm = 0x95F
	jne	.LBB4_3
# %bb.9:                                # %_Z18genRandomSubStringPcii.exit
	movb	$0, -897(%rbp)
	leaq	-64(%rbp), %rdi
	movl	$4096, %esi                     # imm = 0x1000
	callq	hipMalloc
	leaq	-56(%rbp), %rdi
	movl	$2400, %esi                     # imm = 0x960
	callq	hipMalloc
	leaq	-48(%rbp), %rbx
	movl	$800, %esi                      # imm = 0x320
	movq	%rbx, %rdi
	callq	hipMalloc
	movq	(%rbx), %rdi
	xorl	%ebx, %ebx
	movl	$800, %edx                      # imm = 0x320
	xorl	%esi, %esi
	callq	hipMemset
	leaq	-896(%rbp), %rdi
	movl	$800, %edx                      # imm = 0x320
	xorl	%esi, %esi
	callq	memset@PLT
	movq	%rsp, %r15
	addq	$-2400, %r15                    # imm = 0xF6A0
	movq	%r15, %rsp
.LBB4_10:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	-3280(%rbp,%rbx), %rax
	movq	%rax, 16(%r15,%rbx)
	movups	-3296(%rbp,%rbx), %xmm0
	movups	%xmm0, (%r15,%rbx)
	addq	$24, %rbx
	cmpq	$2400, %rbx                     # imm = 0x960
	jne	.LBB4_10
# %bb.11:
	leaq	-80(%rbp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	leaq	1(%r15), %r12
	leaq	-7392(%rbp), %r13
	xorl	%ebx, %ebx
.LBB4_12:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_13 Depth 2
                                        #       Child Loop BB4_15 Depth 3
	leaq	(%rbx,%rbx,2), %rax
	movb	(%r15,%rax,8), %al
	movq	%r13, %rdx
	xorl	%ecx, %ecx
.LBB4_13:                               #   Parent Loop BB4_12 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_15 Depth 3
	cmpb	%al, -7392(%rbp,%rcx)
	jne	.LBB4_24
# %bb.14:                               # %.preheader.i.preheader
                                        #   in Loop: Header=BB4_13 Depth=2
	movl	$1, %esi
.LBB4_15:                               # %.preheader.i
                                        #   Parent Loop BB4_12 Depth=1
                                        #     Parent Loop BB4_13 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movb	(%rdx,%rsi), %dil
	cmpb	-1(%r12,%rsi), %dil
	jne	.LBB4_24
# %bb.16:                               #   in Loop: Header=BB4_15 Depth=3
	cmpb	$0, (%r12,%rsi)
	leaq	1(%rsi), %rsi
	jne	.LBB4_15
	jmp	.LBB4_17
.LBB4_24:                               # %.loopexit.i
                                        #   in Loop: Header=BB4_13 Depth=2
	incq	%rcx
	incq	%rdx
	cmpq	$4096, %rcx                     # imm = 0x1000
	jne	.LBB4_13
	jmp	.LBB4_18
.LBB4_17:                               # %_Z9my_strstrPcS_ii.exit
                                        #   in Loop: Header=BB4_12 Depth=1
	leaq	(%rcx,%rbp), %r14
	addq	$-7392, %r14                    # imm = 0xE320
	movl	$.L.str, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movq	%r14, %rdi
	callq	puts@PLT
.LBB4_18:                               # %_Z9my_strstrPcS_ii.exit.thread
                                        #   in Loop: Header=BB4_12 Depth=1
	incq	%rbx
	addq	$24, %r12
	cmpq	$100, %rbx
	jne	.LBB4_12
# %bb.19:
	movabsq	$4294967297, %r12               # imm = 0x100000001
	leaq	-96(%rbp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r14), %rax
	leaq	-80(%rbp), %r15
	subq	(%r15), %rax
	imulq	$1000000, %rax, %rax            # imm = 0xF4240
	addq	8(%r14), %rax
	subq	8(%r15), %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	$50, %ebx
	leaq	-3296(%rbp), %r15
	movq	%r12, %r14
	addq	$99, %r12
	leaq	-896(%rbp), %r13
.LBB4_20:                               # =>This Inner Loop Header: Depth=1
	movq	-64(%rbp), %rdi
	movl	$4096, %edx                     # imm = 0x1000
	leaq	-7392(%rbp), %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	-56(%rbp), %rdi
	movl	$2400, %edx                     # imm = 0x960
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$4096, %r8d                     # imm = 0x1000
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_22
# %bb.21:                               #   in Loop: Header=BB4_20 Depth=1
	movq	-64(%rbp), %rdi
	movq	-56(%rbp), %rsi
	movq	-48(%rbp), %rdx
	movl	$4096, %ecx                     # imm = 0x1000
	movl	$24, %r8d
	movl	$100, %r9d
	callq	_Z24__device_stub__my_strstrPcS_PS_iii
.LBB4_22:                               #   in Loop: Header=BB4_20 Depth=1
	callq	hipDeviceSynchronize
	movq	-48(%rbp), %rsi
	movl	$800, %edx                      # imm = 0x320
	movq	%r13, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	decl	%ebx
	jne	.LBB4_20
# %bb.23:
	leaq	-96(%rbp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%rbx), %rax
	subq	-80(%rbp), %rax
	imulq	$1000000, %rax, %rax            # imm = 0xF4240
	addq	8(%rbx), %rax
	subq	-72(%rbp), %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	cvtss2sd	%xmm0, %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
	divsd	.LCPI4_1(%rip), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	xorl	%eax, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.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	$_Z9my_strstrPcS_PS_iii, %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	_Z9my_strstrPcS_PS_iii,@object  # @_Z9my_strstrPcS_PS_iii
	.section	.rodata,"a",@progbits
	.globl	_Z9my_strstrPcS_PS_iii
	.p2align	3, 0x0
_Z9my_strstrPcS_PS_iii:
	.quad	_Z24__device_stub__my_strstrPcS_PS_iii
	.size	_Z9my_strstrPcS_PS_iii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"find one sub string in %d sub\n"
	.size	.L.str, 31

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"CPU time=%f\n"
	.size	.L.str.2, 13

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"GPU time=%f\n"
	.size	.L.str.3, 13

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9my_strstrPcS_PS_iii"
	.size	.L__unnamed_1, 23

	.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 _Z24__device_stub__my_strstrPcS_PS_iii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z9my_strstrPcS_PS_iii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9my_strstrPcS_PS_iii  ; -- Begin function _Z9my_strstrPcS_PS_iii
	.globl	_Z9my_strstrPcS_PS_iii
	.p2align	8
	.type	_Z9my_strstrPcS_PS_iii,@function
_Z9my_strstrPcS_PS_iii:                 ; @_Z9my_strstrPcS_PS_iii
; %bb.0:
	s_load_b256 s[4:11], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s11, 1
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph
	v_mul_lo_u32 v1, v0, s11
	v_mov_b32_e32 v3, 16
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v1, s2, s6, v1
	v_add_co_ci_u32_e64 v2, null, s7, 0, s2
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_u8 v4, v[1:2], off
	v_add_co_u32 v1, vcc_lo, v1, 1
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	s_add_i32 s11, s11, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s11, 0
	s_waitcnt vmcnt(0)
	scratch_store_b8 v3, v4, off
	v_add_nc_u32_e32 v3, 1, v3
	s_cbranch_scc0 .LBB0_2
.LBB0_3:                                ; %._crit_edge
	s_load_b32 s0, s[0:1], 0x34
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s0, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f32_u32_e32 v1, s0
	s_sub_i32 s2, 0, s0
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_readfirstlane_b32 s1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s2, s2, s1
	s_mul_hi_u32 s2, s1, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s1, s1, s2
	s_mul_hi_u32 s1, s10, s1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_mul_i32 s2, s1, s0
	s_add_i32 s3, s1, 1
	s_sub_i32 s2, s10, s2
	s_sub_i32 s6, s2, s0
	s_cmp_ge_u32 s2, s0
	s_cselect_b32 s1, s3, s1
	s_cselect_b32 s2, s6, s2
	s_add_i32 s3, s1, 1
	s_cmp_ge_u32 s2, s0
	s_mov_b32 s2, 0
	s_cselect_b32 s1, s3, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lt_i32 s1, 1
	s_cbranch_scc1 .LBB0_6
; %bb.4:                                ; %.lr.ph52.preheader
	v_mov_b32_e32 v1, v0
.LBB0_5:                                ; %.lr.ph52
                                        ; =>This Inner Loop Header: Depth=1
	global_load_u8 v2, v1, s[4:5]
	v_add_nc_u32_e32 v3, 0, v1
	v_add_nc_u32_e32 v1, s0, v1
	s_add_i32 s2, s2, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_ge_i32 s2, s1
	s_waitcnt vmcnt(0)
	ds_store_b8 v3, v2
	s_cbranch_scc0 .LBB0_5
.LBB0_6:                                ; %._crit_edge53
	v_mad_u64_u32 v[1:2], null, s1, s0, v[0:1]
	s_cmp_lt_u32 s1, s0
	s_cselect_b32 s0, -1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_u32_e32 vcc_lo, s10, v1
	s_and_b32 s1, s0, vcc_lo
	s_and_saveexec_b32 s0, s1
	s_cbranch_execz .LBB0_8
; %bb.7:
	global_load_u8 v2, v1, s[4:5]
	v_add_nc_u32_e32 v1, 0, v1
	s_waitcnt vmcnt(0)
	ds_store_b8 v1, v2
.LBB0_8:
	s_or_b32 exec_lo, exec_lo, s0
	v_mov_b32_e32 v1, 0
	s_mov_b32 s2, 0
	ds_load_u8 v4, v1
	s_waitcnt lgkmcnt(0)
	v_cmp_eq_u16_e32 vcc_lo, 0, v4
	s_cbranch_vccnz .LBB0_16
; %bb.9:                                ; %.preheader.lr.ph
	scratch_load_u8 v1, off, off offset:16
	s_mov_b32 s3, 0
	s_mov_b64 s[0:1], src_shared_base
	s_waitcnt vmcnt(0)
	v_and_b32_e32 v3, 0xff, v1
.LBB0_10:                               ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_12 Depth 2
	v_dual_mov_b32 v1, 0 :: v_dual_and_b32 v4, 0xff, v4
	v_mov_b32_e32 v2, 0
	s_mov_b32 s4, exec_lo
	s_delay_alu instid0(VALU_DEP_2)
	v_cmpx_eq_u16_e64 v4, v3
	s_cbranch_execz .LBB0_14
; %bb.11:                               ; %.lr.ph57.preheader
                                        ;   in Loop: Header=BB0_10 Depth=1
	v_mov_b32_e32 v1, 0
	v_mov_b32_e32 v2, 0
	s_cmp_lg_u32 s2, -1
	s_mov_b32 s5, 0
	s_cselect_b32 s6, s1, 0
	s_cselect_b32 s7, s2, 0
	s_mov_b32 s10, 0
.LBB0_12:                               ; %.lr.ph57
                                        ;   Parent Loop BB0_10 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_add_nc_u32_e64 v4, s10, 16
	s_add_i32 s0, s2, s10
	s_add_i32 s10, s10, 1
	v_dual_mov_b32 v6, s0 :: v_dual_add_nc_u32 v5, 2, v4
	v_add_nc_u32_e32 v4, 1, v4
	s_clause 0x1
	scratch_load_u8 v5, v5, off
	scratch_load_u8 v4, v4, off
	ds_load_u8 v6, v6 offset:1
	s_waitcnt vmcnt(1)
	v_cmp_eq_u16_e32 vcc_lo, 0, v5
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cmp_ne_u16_e64 s0, v6, v4
	v_cndmask_b32_e64 v2, v2, s6, vcc_lo
	v_cndmask_b32_e64 v1, v1, s7, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s5, s0, s5
	s_and_not1_b32 exec_lo, exec_lo, s5
	s_cbranch_execnz .LBB0_12
; %bb.13:                               ; %Flow
                                        ;   in Loop: Header=BB0_10 Depth=1
	s_or_b32 exec_lo, exec_lo, s5
.LBB0_14:                               ; %Flow91
                                        ;   in Loop: Header=BB0_10 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s4
	v_mov_b32_e32 v4, s2
	v_cmp_ne_u64_e32 vcc_lo, 0, v[1:2]
	s_add_i32 s2, s2, 1
	ds_load_u8 v4, v4 offset:1
	s_waitcnt lgkmcnt(0)
	v_cmp_eq_u16_e64 s0, 0, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s0, s0, vcc_lo
	s_and_b32 s0, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s3, s0, s3
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB0_10
; %bb.15:                               ; %Flow92
	s_or_b32 exec_lo, exec_lo, s3
	s_branch .LBB0_17
.LBB0_16:
	v_mov_b32_e32 v1, 0
	v_mov_b32_e32 v2, 0
.LBB0_17:                               ; %._crit_edge60
	v_lshlrev_b32_e32 v0, 3, v0
	global_store_b64 v0, v[1:2], s[8:9]
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9my_strstrPcS_PS_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 48
		.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 1
		.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 7
		.amdhsa_next_free_sgpr 12
		.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	_Z9my_strstrPcS_PS_iii, .Lfunc_end0-_Z9my_strstrPcS_PS_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 696
; NumSgprs: 14
; NumVgprs: 7
; ScratchSize: 48
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 14
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 1
; 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 s_string
	.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:         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
      - .offset:         160
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9my_strstrPcS_PS_iii
    .private_segment_fixed_size: 48
    .sgpr_count:     14
    .sgpr_spill_count: 0
    .symbol:         _Z9my_strstrPcS_PS_iii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
