#include <stdio.h>
#include<sys/time.h>
#include<math.h>

#define N 8192
#define nth 1024

__global__ void fast_transpose(size_t* A, size_t* B){
    __shared__ size_t Ablock[nth];
    __shared__ size_t Bblock[nth];

    size_t dimx=blockDim.x;
    size_t dimy=blockDim.y;
    
    //dimx=linear dimension in x of a submatrix block
    size_t th=threadIdx.x+threadIdx.y*dimx;
    size_t thx=threadIdx.x;
    size_t thy=threadIdx.y;

    size_t starty=blockIdx.y*N*dimy;
    size_t startx=blockIdx.x*dimx;
    size_t start= startx+starty;
    //Ablock is different for every block, so I can index it with th
    Ablock[th]= A[start+thx+(thy)*(N)];
    //creation of A completed for each block
    __syncthreads();

    //transpose into B block
    Bblock[dimy*thx + thy] = Ablock[th];

    __syncthreads();


    //put Bblock in B
    start=blockIdx.y*dimy+dimx*N*blockIdx.x; //the x block index of the original matrix becomes y index of transpose, so skip N
    B[ start+thy+(thx)*(N) ]=Bblock[dimy*thx + thy];

}

__global__ void transpose(size_t* A, size_t *B){
  size_t j=blockIdx.x;
  size_t i=threadIdx.x;
  while(i<N){
    B[j+i*N]=A[i+j*N];
    i+=blockDim.x;
  }
  
}

                                        /////////////////////C utilites//////////////////////////////

int transposed(size_t *A, size_t* At){
  size_t i,j;
   for(i=0;i<N;i++){
     for(j=0;j<N;j++){
       if(A[i+j*N]!=At[j+i*N]){return 0;}
     }
   }
   return 1;
}

double seconds()

{

  struct timeval tmp;
  double sec;
  gettimeofday( &tmp, (struct timezone *)0 );
  sec = tmp.tv_sec + ((double)tmp.tv_usec)/1000000.0;
  return sec;

}

                            ////////////////////////////////////main
int main(){
  size_t elements=N*N;
  size_t space=N*N*sizeof(size_t);

  size_t*A=(size_t*)malloc(space);
  size_t*dev_A;
  size_t*B=(size_t*)malloc(space);
  size_t*dev_B;

  size_t i;
  for(i=0;i<elements;i++){
      A[i]=i%N;
  }

  cudaMalloc( (void**)&dev_A, space );
  cudaMalloc( (void**)&dev_B, space );

  cudaMemcpy( dev_A, A, space, cudaMemcpyHostToDevice );

  double tstart=seconds();
  transpose<<< N, nth >>>(dev_A, dev_B); 
  cudaDeviceSynchronize();
  double duration=seconds()-tstart;
  printf("transp time: %lf\n",duration);

  cudaMemcpy( B, dev_B, space, cudaMemcpyDeviceToHost );

  printf("correct? %d\n\n",transposed(A,B));

  size_t block_side= (size_t)sqrt(nth);
  dim3 grid,block;
  if(block_side*block_side==nth){
    grid.x=grid.y=N/block_side;  //number of orizontal blocks=number of vertical blocks
    block.x=block.y=block_side;  //block linear length
  }
  else{
    grid.x=N/32; //ideally, we should have an algorithm that given nth finds (a,b) integers such that nth=a*b and (a,b) closest to each other
    grid.y=N/16; //to be preferred a>b, so that we read more often on x (continous in memory)
    block.x=32;
    block.y=16;
  }
  
  tstart=seconds();
  fast_transpose<<< grid, block >>>(dev_A, dev_B);
  cudaDeviceSynchronize();
  duration=seconds()-tstart;
  printf("fast times: %lf\n",duration);

  cudaMemcpy( B, dev_B, space, cudaMemcpyDeviceToHost );

  /*for(i=0;i<elements;i++){
     if(i%N==0 && i!=0)printf("\n");  
     printf("%d ", A[i]);
  }
  printf("\n");
               
               
  for(i=0;i<elements;i++){
    if(i%N==0 && i!=0)printf("\n");
    
    printf("%d ", B[i]);
    }
  printf("\n"); */

  printf("correct? %d\n\n",transposed(A,B));

  free(A);free(B);
  cudaFree(dev_A);cudaFree(dev_B);
}

	.file	"tmpxft_0025b029_00000000-6_transpose.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
	.globl	_Z10transposedPmS_
	.type	_Z10transposedPmS_, @function
_Z10transposedPmS_:
.LFB2027:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L3:
	movq	%rax, %rcx
	leaq	(%rdi,%rax,8), %r8
	xorl	%edx, %edx
	salq	$16, %rcx
	addq	%rsi, %rcx
.L5:
	movq	(%rcx,%rdx,8), %r9
	cmpq	%r9, (%r8)
	jne	.L6
	incq	%rdx
	addq	$65536, %r8
	cmpq	$8192, %rdx
	jne	.L5
	incq	%rax
	cmpq	$8192, %rax
	jne	.L3
	movl	$1, %eax
	ret
.L6:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10transposedPmS_, .-_Z10transposedPmS_
	.globl	_Z7secondsv
	.type	_Z7secondsv, @function
_Z7secondsv:
.LFB2028:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	8(%rsp), %xmm1
	cvtsi2sdq	16(%rsp), %xmm0
	divsd	.LC0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z7secondsv, .-_Z7secondsv
	.globl	_Z36__device_stub__Z14fast_transposePmS_PmS_
	.type	_Z36__device_stub__Z14fast_transposePmS_PmS_, @function
_Z36__device_stub__Z14fast_transposePmS_PmS_:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L13
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z14fast_transposePmS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L13:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z36__device_stub__Z14fast_transposePmS_PmS_, .-_Z36__device_stub__Z14fast_transposePmS_PmS_
	.globl	_Z14fast_transposePmS_
	.type	_Z14fast_transposePmS_, @function
_Z14fast_transposePmS_:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z14fast_transposePmS_PmS_
	.cfi_endproc
.LFE2056:
	.size	_Z14fast_transposePmS_, .-_Z14fast_transposePmS_
	.globl	_Z30__device_stub__Z9transposePmS_PmS_
	.type	_Z30__device_stub__Z9transposePmS_PmS_, @function
_Z30__device_stub__Z9transposePmS_PmS_:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z9transposePmS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L18:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z30__device_stub__Z9transposePmS_PmS_, .-_Z30__device_stub__Z9transposePmS_PmS_
	.globl	_Z9transposePmS_
	.type	_Z9transposePmS_, @function
_Z9transposePmS_:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z9transposePmS_PmS_
	.cfi_endproc
.LFE2058:
	.size	_Z9transposePmS_, .-_Z9transposePmS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"transp time: %lf\n"
.LC2:
	.string	"correct? %d\n\n"
.LC3:
	.string	"fast times: %lf\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$536870912, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$536870912, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rax, %rbx
	xorl	%eax, %eax
.L24:
	movq	%rax, %rdx
	andl	$8191, %edx
	movq	%rdx, 0(%rbp,%rax,8)
	incq	%rax
	cmpq	$67108864, %rax
	jne	.L24
	leaq	16(%rsp), %rdi
	movl	$536870912, %esi
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movl	$536870912, %esi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$536870912, %edx
	call	cudaMemcpy@PLT
	call	_Z7secondsv
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$524289, %edi
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$13, %rdi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	movsd	%xmm0, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_Z30__device_stub__Z9transposePmS_PmS_
.L25:
	call	cudaDeviceSynchronize@PLT
	leaq	.LC2(%rip), %r12
	call	_Z7secondsv
	subsd	8(%rsp), %xmm0
	leaq	.LC1(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$536870912, %edx
	call	cudaMemcpy@PLT
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	_Z10transposedPmS_
	movq	%r12, %rsi
	movl	$2, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z7secondsv
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$1099511628032, %rdi
	movl	$1, %esi
	movabsq	$137438953504, %rdx
	movl	$1, 40(%rsp)
	movq	%rdi, 32(%rsp)
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	movsd	%xmm0, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_Z36__device_stub__Z14fast_transposePmS_PmS_
.L26:
	call	cudaDeviceSynchronize@PLT
	call	_Z7secondsv
	subsd	8(%rsp), %xmm0
	leaq	.LC3(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$536870912, %edx
	call	cudaMemcpy@PLT
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	_Z10transposedPmS_
	movq	%r12, %rsi
	movl	$2, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$64, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC4:
	.string	"_Z9transposePmS_"
.LC5:
	.string	"_Z14fast_transposePmS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z9transposePmS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC5(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z14fast_transposePmS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2060:
	.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
.LC0:
	.long	0
	.long	1093567616
	.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<sys/time.h>
#include<math.h>

#define N 8192
#define nth 1024

__global__ void fast_transpose(size_t* A, size_t* B){
    __shared__ size_t Ablock[nth];
    __shared__ size_t Bblock[nth];

    size_t dimx=blockDim.x;
    size_t dimy=blockDim.y;
    
    //dimx=linear dimension in x of a submatrix block
    size_t th=threadIdx.x+threadIdx.y*dimx;
    size_t thx=threadIdx.x;
    size_t thy=threadIdx.y;

    size_t starty=blockIdx.y*N*dimy;
    size_t startx=blockIdx.x*dimx;
    size_t start= startx+starty;
    //Ablock is different for every block, so I can index it with th
    Ablock[th]= A[start+thx+(thy)*(N)];
    //creation of A completed for each block
    __syncthreads();

    //transpose into B block
    Bblock[dimy*thx + thy] = Ablock[th];

    __syncthreads();


    //put Bblock in B
    start=blockIdx.y*dimy+dimx*N*blockIdx.x; //the x block index of the original matrix becomes y index of transpose, so skip N
    B[ start+thy+(thx)*(N) ]=Bblock[dimy*thx + thy];

}

__global__ void transpose(size_t* A, size_t *B){
  size_t j=blockIdx.x;
  size_t i=threadIdx.x;
  while(i<N){
    B[j+i*N]=A[i+j*N];
    i+=blockDim.x;
  }
  
}

                                        /////////////////////C utilites//////////////////////////////

int transposed(size_t *A, size_t* At){
  size_t i,j;
   for(i=0;i<N;i++){
     for(j=0;j<N;j++){
       if(A[i+j*N]!=At[j+i*N]){return 0;}
     }
   }
   return 1;
}

double seconds()

{

  struct timeval tmp;
  double sec;
  gettimeofday( &tmp, (struct timezone *)0 );
  sec = tmp.tv_sec + ((double)tmp.tv_usec)/1000000.0;
  return sec;

}

                            ////////////////////////////////////main
int main(){
  size_t elements=N*N;
  size_t space=N*N*sizeof(size_t);

  size_t*A=(size_t*)malloc(space);
  size_t*dev_A;
  size_t*B=(size_t*)malloc(space);
  size_t*dev_B;

  size_t i;
  for(i=0;i<elements;i++){
      A[i]=i%N;
  }

  hipMalloc( (void**)&dev_A, space );
  hipMalloc( (void**)&dev_B, space );

  hipMemcpy( dev_A, A, space, hipMemcpyHostToDevice );

  double tstart=seconds();
  transpose<<< N, nth >>>(dev_A, dev_B); 
  hipDeviceSynchronize();
  double duration=seconds()-tstart;
  printf("transp time: %lf\n",duration);

  hipMemcpy( B, dev_B, space, hipMemcpyDeviceToHost );

  printf("correct? %d\n\n",transposed(A,B));

  size_t block_side= (size_t)sqrt(nth);
  dim3 grid,block;
  if(block_side*block_side==nth){
    grid.x=grid.y=N/block_side;  //number of orizontal blocks=number of vertical blocks
    block.x=block.y=block_side;  //block linear length
  }
  else{
    grid.x=N/32; //ideally, we should have an algorithm that given nth finds (a,b) integers such that nth=a*b and (a,b) closest to each other
    grid.y=N/16; //to be preferred a>b, so that we read more often on x (continous in memory)
    block.x=32;
    block.y=16;
  }
  
  tstart=seconds();
  fast_transpose<<< grid, block >>>(dev_A, dev_B);
  hipDeviceSynchronize();
  duration=seconds()-tstart;
  printf("fast times: %lf\n",duration);

  hipMemcpy( B, dev_B, space, hipMemcpyDeviceToHost );

  /*for(i=0;i<elements;i++){
     if(i%N==0 && i!=0)printf("\n");  
     printf("%d ", A[i]);
  }
  printf("\n");
               
               
  for(i=0;i<elements;i++){
    if(i%N==0 && i!=0)printf("\n");
    
    printf("%d ", B[i]);
    }
  printf("\n"); */

  printf("correct? %d\n\n",transposed(A,B));

  free(A);free(B);
  hipFree(dev_A);hipFree(dev_B);
}

	.text
	.file	"transpose.hip"
	.globl	_Z29__device_stub__fast_transposePmS_ # -- Begin function _Z29__device_stub__fast_transposePmS_
	.type	_Z29__device_stub__fast_transposePmS_,@function
_Z29__device_stub__fast_transposePmS_:  # @_Z29__device_stub__fast_transposePmS_
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z14fast_transposePmS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z29__device_stub__fast_transposePmS_, .Lfunc_end0-_Z29__device_stub__fast_transposePmS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__transposePmS_ # -- Begin function _Z24__device_stub__transposePmS_
	.type	_Z24__device_stub__transposePmS_,@function
_Z24__device_stub__transposePmS_:       # @_Z24__device_stub__transposePmS_
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z9transposePmS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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_end1:
	.size	_Z24__device_stub__transposePmS_, .Lfunc_end1-_Z24__device_stub__transposePmS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z10transposedPmS_              # -- Begin function _Z10transposedPmS_
	.type	_Z10transposedPmS_,@function
_Z10transposedPmS_:                     # @_Z10transposedPmS_
	.cfi_startproc
# %bb.0:
	xorl	%eax, %eax
.LBB2_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
	movq	%rdi, %rcx
	xorl	%edx, %edx
.LBB2_3:                                #   Parent Loop BB2_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rcx), %r8
	cmpq	(%rsi,%rdx,8), %r8
	jne	.LBB2_4
# %bb.2:                                #   in Loop: Header=BB2_3 Depth=2
	incq	%rdx
	addq	$65536, %rcx                    # imm = 0x10000
	cmpq	$8192, %rdx                     # imm = 0x2000
	jne	.LBB2_3
# %bb.5:                                #   in Loop: Header=BB2_1 Depth=1
	incq	%rax
	addq	$65536, %rsi                    # imm = 0x10000
	addq	$8, %rdi
	cmpq	$8192, %rax                     # imm = 0x2000
	jne	.LBB2_1
# %bb.6:
	movl	$1, %eax
	retq
.LBB2_4:
	xorl	%eax, %eax
	retq
.Lfunc_end2:
	.size	_Z10transposedPmS_, .Lfunc_end2-_Z10transposedPmS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7secondsv
.LCPI3_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z7secondsv
	.type	_Z7secondsv,@function
_Z7secondsv:                            # @_Z7secondsv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	(%rbx), %xmm1
	cvtsi2sdq	8(%rbx), %xmm0
	divsd	.LCPI3_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z7secondsv, .Lfunc_end3-_Z7secondsv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$536870912, %edi                # imm = 0x20000000
	callq	malloc
	movq	%rax, %rbx
	movl	$536870912, %edi                # imm = 0x20000000
	callq	malloc
	movq	%rax, %r14
	xorl	%eax, %eax
.LBB4_1:                                # =>This Inner Loop Header: Depth=1
	movl	%eax, %ecx
	andl	$8191, %ecx                     # imm = 0x1FFF
	movq	%rcx, (%rbx,%rax,8)
	incq	%rax
	cmpq	$67108864, %rax                 # imm = 0x4000000
	jne	.LBB4_1
# %bb.2:
	leaq	16(%rsp), %r15
	movl	$536870912, %esi                # imm = 0x20000000
	movq	%r15, %rdi
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$536870912, %esi                # imm = 0x20000000
	callq	hipMalloc
	movq	(%r15), %rdi
	movl	$536870912, %edx                # imm = 0x20000000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	(%r15), %xmm0
	cvtsi2sdq	8(%r15), %xmm1
	divsd	.LCPI4_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movabsq	$4294968320, %rdx               # imm = 0x100000400
	leaq	7168(%rdx), %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_4
# %bb.3:
	movq	16(%rsp), %rdi
	movq	(%rsp), %rsi
	callq	_Z24__device_stub__transposePmS_
.LBB4_4:
	callq	hipDeviceSynchronize
	xorl	%r12d, %r12d
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%r15), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r15), %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	movq	(%rsp), %rsi
	movl	$536870912, %edx                # imm = 0x20000000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%rbx, %rax
	movq	%r14, %rcx
.LBB4_5:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_7 Depth 2
	movq	%rax, %rdx
	xorl	%esi, %esi
.LBB4_7:                                #   Parent Loop BB4_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rdx), %rdi
	cmpq	(%rcx,%rsi,8), %rdi
	jne	.LBB4_8
# %bb.6:                                #   in Loop: Header=BB4_7 Depth=2
	incq	%rsi
	addq	$65536, %rdx                    # imm = 0x10000
	cmpq	$8192, %rsi                     # imm = 0x2000
	jne	.LBB4_7
# %bb.9:                                #   in Loop: Header=BB4_5 Depth=1
	incq	%r12
	addq	$65536, %rcx                    # imm = 0x10000
	addq	$8, %rax
	cmpq	$8192, %r12                     # imm = 0x2000
	jne	.LBB4_5
# %bb.10:
	movl	$1, %esi
	jmp	.LBB4_11
.LBB4_8:
	xorl	%esi, %esi
.LBB4_11:                               # %.loopexit
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r15), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%r15), %xmm1
	divsd	.LCPI4_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movabsq	$1099511628032, %rdi            # imm = 0x10000000100
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_13
# %bb.12:
	movq	16(%rsp), %rdi
	movq	(%rsp), %rsi
	callq	_Z29__device_stub__fast_transposePmS_
.LBB4_13:
	callq	hipDeviceSynchronize
	xorl	%r12d, %r12d
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%r15), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%r15), %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movq	(%rsp), %rsi
	movl	$536870912, %edx                # imm = 0x20000000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%rbx, %rax
	movq	%r14, %rcx
.LBB4_14:                               # %.preheader.i41
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_16 Depth 2
	movq	%rax, %rdx
	xorl	%esi, %esi
.LBB4_16:                               #   Parent Loop BB4_14 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rdx), %rdi
	cmpq	(%rcx,%rsi,8), %rdi
	jne	.LBB4_17
# %bb.15:                               #   in Loop: Header=BB4_16 Depth=2
	incq	%rsi
	addq	$65536, %rdx                    # imm = 0x10000
	cmpq	$8192, %rsi                     # imm = 0x2000
	jne	.LBB4_16
# %bb.18:                               #   in Loop: Header=BB4_14 Depth=1
	incq	%r12
	addq	$65536, %rcx                    # imm = 0x10000
	addq	$8, %rax
	cmpq	$8192, %r12                     # imm = 0x2000
	jne	.LBB4_14
# %bb.19:
	movl	$1, %esi
	jmp	.LBB4_20
.LBB4_17:
	xorl	%esi, %esi
.LBB4_20:                               # %_Z10transposedPmS_.exit52
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14fast_transposePmS_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9transposePmS_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.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	_Z14fast_transposePmS_,@object  # @_Z14fast_transposePmS_
	.section	.rodata,"a",@progbits
	.globl	_Z14fast_transposePmS_
	.p2align	3, 0x0
_Z14fast_transposePmS_:
	.quad	_Z29__device_stub__fast_transposePmS_
	.size	_Z14fast_transposePmS_, 8

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"transp time: %lf\n"
	.size	.L.str, 18

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"correct? %d\n\n"
	.size	.L.str.1, 14

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"fast times: %lf\n"
	.size	.L.str.2, 17

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

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z9transposePmS_"
	.size	.L__unnamed_2, 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 _Z29__device_stub__fast_transposePmS_
	.addrsig_sym _Z24__device_stub__transposePmS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z14fast_transposePmS_
	.addrsig_sym _Z9transposePmS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14fast_transposePmS_  ; -- Begin function _Z14fast_transposePmS_
	.globl	_Z14fast_transposePmS_
	.p2align	8
	.type	_Z14fast_transposePmS_,@function
_Z14fast_transposePmS_:                 ; @_Z14fast_transposePmS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b128 s[0:3], s[0:1], 0x0
	v_and_b32_e32 v2, 0x3ff, v0
	s_lshl_b32 s6, s15, 13
	v_bfe_u32 v3, v0, 10, 10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b32_e32 v0, 3, v2
	v_lshlrev_b32_e32 v1, 16, v3
	s_waitcnt lgkmcnt(0)
	s_and_b32 s10, s4, 0xffff
	s_lshr_b32 s11, s4, 16
	s_mul_hi_u32 s5, s10, s14
	s_mul_i32 s4, s10, s14
	s_mul_hi_u32 s7, s11, s6
	s_lshl_b64 s[8:9], s[4:5], 3
	s_mul_i32 s6, s11, s6
	s_add_u32 s8, s0, s8
	s_addc_u32 s9, s1, s9
	s_lshl_b64 s[0:1], s[6:7], 3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_add_u32 s0, s8, s0
	s_addc_u32 s1, s9, s1
	v_add_co_u32 v0, s0, s0, v0
	v_add_co_ci_u32_e64 v4, null, s1, 0, s0
	s_mul_hi_u32 s1, s11, s15
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, v0, v1
	v_add_co_ci_u32_e32 v1, vcc_lo, 0, v4, vcc_lo
	v_mul_u32_u24_e32 v4, s10, v3
	s_mul_i32 s0, s11, s15
	global_load_b64 v[0:1], v[0:1], off
	s_lshl_b64 s[0:1], s[0:1], 3
	v_add_lshl_u32 v4, v4, v2, 3
	s_add_u32 s2, s2, s0
	s_addc_u32 s3, s3, s1
	s_lshl_b64 s[0:1], s[4:5], 16
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s0, s2, s0
	s_addc_u32 s1, s3, s1
	s_waitcnt vmcnt(0)
	ds_store_b64 v4, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_b64 v[0:1], v4
	v_mul_u32_u24_e32 v4, s11, v2
	v_lshlrev_b32_e32 v2, 16, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_lshl_u32 v4, v4, v3, 3
	v_lshlrev_b32_e32 v3, 3, v3
	v_add_co_u32 v3, s0, s0, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_u32 v2, vcc_lo, v3, v2
	s_waitcnt lgkmcnt(0)
	ds_store_b64 v4, v[0:1] offset:8192
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_b64 v[0:1], v4 offset:8192
	v_add_co_ci_u32_e64 v4, null, s1, 0, s0
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v4, vcc_lo
	s_waitcnt lgkmcnt(0)
	global_store_b64 v[2:3], v[0:1], off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14fast_transposePmS_
		.amdhsa_group_segment_fixed_size 16384
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 5
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z14fast_transposePmS_, .Lfunc_end0-_Z14fast_transposePmS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 356
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 16384 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z9transposePmS_        ; -- Begin function _Z9transposePmS_
	.globl	_Z9transposePmS_
	.p2align	8
	.type	_Z9transposePmS_,@function
_Z9transposePmS_:                       ; @_Z9transposePmS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s10, s[0:1], 0x1c
	s_load_b128 s[4:7], s[0:1], 0x0
	s_mov_b32 s2, s15
	s_mov_b32 s3, 0
	v_dual_mov_b32 v1, 0 :: v_dual_lshlrev_b32 v2, 3, v0
	s_lshl_b64 s[8:9], s[2:3], 16
	v_lshlrev_b32_e32 v4, 16, v0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s1, s10, 0xffff
	s_add_u32 s0, s4, s8
	s_addc_u32 s5, s5, s9
	s_lshl_b64 s[8:9], s[2:3], 3
	v_add_co_u32 v2, s0, s0, v2
	s_lshl_b32 s4, s1, 3
	v_add_co_ci_u32_e64 v3, null, s5, 0, s0
	s_add_u32 s0, s6, s8
	s_addc_u32 s2, s7, s9
	v_add_co_u32 v4, s0, s0, v4
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v5, null, s2, 0, s0
	s_lshl_b32 s2, s10, 16
.LBB1_1:                                ; =>This Inner Loop Header: Depth=1
	global_load_b64 v[6:7], v[2:3], off
	v_add_co_u32 v0, vcc_lo, v0, s1
	v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
	v_add_co_u32 v2, vcc_lo, v2, s4
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_cmp_lt_u64_e32 vcc_lo, 0x1fff, v[0:1]
	s_or_b32 s3, vcc_lo, s3
	s_waitcnt vmcnt(0)
	global_store_b64 v[4:5], v[6:7], off
	v_add_co_u32 v4, s0, v4, s2
	v_add_co_ci_u32_e64 v5, s0, 0, v5, s0
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB1_1
; %bb.2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9transposePmS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 8
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z9transposePmS_, .Lfunc_end1-_Z9transposePmS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 216
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; 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
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 16384
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14fast_transposePmS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14fast_transposePmS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9transposePmS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9transposePmS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
