//Perlin kernel (Rob Farber)
#include <stdio.h>

extern float gain, xStart, yStart, zOffset, octaves, lacunarity;
#define Z_PLANE 50.f

__constant__ unsigned char c_perm[256];
__shared__ unsigned char s_perm[256]; // shared memory copy of permuation array
unsigned char* d_perm=NULL; // global memory copy of permutation array
// host version of permutation array
const static unsigned char h_perm[] = {151,160,137,91,90,15,
   131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
   190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
   88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
   77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
   102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
   135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
   5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
   223,183,170,213,119,248,152,2,44,154,163, 70,221,153,101,155,167, 43,172,9,
   129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
   251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
   49,192,214, 31,181,199,106,157,184,84,204,176,115,121,50,45,127, 4,150,254,
   138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180
   };

__device__ inline int perm(int i) { return(s_perm[i&0xff]); }
__device__ inline float fade(float t) { return t * t * t * (t * (t * 6.f - 15.f) + 10.f); }
__device__ inline float lerpP(float t, float a, float b) { return a + t * (b - a); }
__device__ inline float grad(int hash, float x, float y, float z) {
  int h = hash & 15;                      // CONVERT LO 4 BITS OF HASH CODE
  float u = h<8 ? x : y,                 // INTO 12 GRADIENT DIRECTIONS.
    v = h<4 ? y : h==12||h==14 ? x : z;
  return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v);
}

__device__ float inoise(float x, float y, float z) {
  int X = ((int)floorf(x)) & 255, // FIND UNIT CUBE THAT
    Y = ((int)floorf(y)) & 255,   // CONTAINS POINT.
    Z = ((int)floorf(z)) & 255;
  x -= floorf(x);               // FIND RELATIVE X,Y,Z
  y -= floorf(y);               // OF POINT IN CUBE.
  z -= floorf(z);
  float u = fade(x),            // COMPUTE FADE CURVES
    v = fade(y),                // FOR EACH OF X,Y,Z.
    w = fade(z);
  int A = perm(X)+Y, AA = perm(A)+Z, AB = perm(A+1)+Z, // HASH COORDINATES OF
    B = perm(X+1)+Y, BA = perm(B)+Z, BB = perm(B+1)+Z; // THE 8 CUBE CORNERS,
  
  return lerpP(w, lerpP(v, lerpP(u, grad(perm(AA), x  , y  , z   ), // AND ADD
				 grad(perm(BA), x-1.f, y  , z   )),   // BLENDED
			lerpP(u, grad(perm(AB), x  , y-1.f, z   ),    // RESULTS
			      grad(perm(BB), x-1.f, y-1.f, z   ))),     // FROM  8
	       lerpP(v, lerpP(u, grad(perm(AA+1), x  , y  , z-1.f ),  // CORNERS
			      grad(perm(BA+1), x-1.f, y  , z-1.f )),    // OF CUBE
		     lerpP(u, grad(perm(AB+1), x  , y-1.f, z-1.f ),
			   grad(perm(BB+1), x-1.f, y-1.f, z-1.f ))));
#ifdef ORIG
  return(perm(X));
#endif
 
}

__device__ float fBm(float x, float y, int octaves,
		     float lacunarity = 2.0f, float gain = 0.5f)
{
  float freq = 1.0f, amp = 0.5f;
  float sum = 0.f;  
  for(int i=0; i<octaves; i++) {
    sum += inoise(x*freq, y*freq, Z_PLANE)*amp;
    freq *= lacunarity;
    amp *= gain;
  }
  return sum;
}


__device__ inline uchar4 colorElevation(float texHeight)
{
  uchar4 pos;

  // color textel (r,g,b,a)
       if (texHeight < -1.000f) pos = make_uchar4(000, 000, 128, 255); //deeps
  else if (texHeight < -.2500f) pos = make_uchar4(000, 000, 255, 255); //shallow
  else if (texHeight < 0.0000f) pos = make_uchar4(000, 128, 255, 255); //shore
  else if (texHeight < 0.0125f) pos = make_uchar4(240, 240, 064, 255); //sand
  else if (texHeight < 0.1250f) pos = make_uchar4(032, 160, 000, 255); //grass
  else if (texHeight < 0.3750f) pos = make_uchar4(224, 224, 000, 255); //dirt
  else if (texHeight < 0.7500f) pos = make_uchar4(128, 128, 128, 255); //rock
  else                          pos = make_uchar4(255, 255, 255, 255); //snow

  return(pos);
}

void checkCUDAError(const char *msg) {
  cudaError_t err = cudaGetLastError();
  if( cudaSuccess != err) {
    fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetErrorString( err) ); 
    exit(EXIT_FAILURE); 
  }
} 

//Simple kernel fills an array with perlin noise
__global__ void k_perlin(float4* pos, uchar4 *colorPos,
			  unsigned int width, unsigned int height, 
			 float2 start, float2 delta, float gain, float zOffset,
			 unsigned char* d_perm, float octaves, float lacunarity)
{
  int idx = blockIdx.x * blockDim.x + threadIdx.x;
  float xCur = start.x + ((float) (idx%width)) * delta.x;
  float yCur = start.y + ((float) (idx/width)) * delta.y;

  if(threadIdx.x < 256)
    // Optimization: this causes bank conflicts
    s_perm[threadIdx.x] = d_perm[threadIdx.x];
  // this synchronization can be important if there are more that 256 threads
  __syncthreads();

  
  // Each thread creates one pixel location in the texture (textel)
  if(idx < width*height) {
    float w = fBm(xCur, yCur, octaves, lacunarity, gain) + zOffset;
    
    colorPos[idx] = colorElevation(w);
    float u = ((float) (idx%width))/(float) width;
    float v = ((float) (idx/width))/(float) height;
    u = u*2.f - 1.f;
    v = v*2.f - 1.f;
    w = (w>0.f)?w:0.f; // don't show region underwater
    pos[idx] = make_float4( u, w, v, 1.0f);
  }
}


uchar4 *eColor=NULL;
// Wrapper for the __global__ call that sets up the kernel call
extern "C" void launch_kernel(float4 *pos, uchar4* posColor,
			      unsigned int image_width, unsigned int image_height,
			      float time)
{
  int nThreads=256; // must be equal or larger than 256! (see s_perm)
  int totalThreads = image_height * image_width;
  int nBlocks = totalThreads/nThreads; 
  nBlocks += ((totalThreads%nThreads)>0)?1:0;
  
  float xExtent = 10.f;
  float yExtent = 10.f;
  float xDelta = xExtent/(float)image_width;
  float yDelta = yExtent/(float)image_height;
  
  if(!d_perm) { // for convenience allocate and copy d_perm here
    cudaMalloc((void**) &d_perm,sizeof(h_perm));
    cudaMemcpy(d_perm,h_perm,sizeof(h_perm),cudaMemcpyHostToDevice);
    checkCUDAError("d_perm malloc or copy failed!");
  }

  k_perlin<<< nBlocks, nThreads>>>(pos, posColor, image_width, image_height,
				   make_float2(xStart, yStart),
				   make_float2(xDelta, yDelta),
				   gain, zOffset, d_perm,
				   octaves, lacunarity);
  
  // make certain the kernel has completed 
  cudaThreadSynchronize();
  checkCUDAError("kernel failed!");
}


	.file	"tmpxft_002fa48f_00000000-6_kernelVBO.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2038:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2038:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z6inoisefff
	.type	_Z6inoisefff, @function
_Z6inoisefff:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z6inoisefff, .-_Z6inoisefff
	.globl	_Z3fBmffiff
	.type	_Z3fBmffiff, @function
_Z3fBmffiff:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z3fBmffiff, .-_Z3fBmffiff
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Cuda error: %s: %s.\n"
	.text
	.globl	_Z14checkCUDAErrorPKc
	.type	_Z14checkCUDAErrorPKc, @function
_Z14checkCUDAErrorPKc:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	cudaGetLastError@PLT
	testl	%eax, %eax
	je	.L6
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	%rbx, %rcx
	leaq	.LC0(%rip), %rdx
	movq	%rax, %r8
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L6:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z14checkCUDAErrorPKc, .-_Z14checkCUDAErrorPKc
	.globl	_Z59__device_stub__Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhffP6float4P6uchar4jjR6float2S4_ffPhff
	.type	_Z59__device_stub__Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhffP6float4P6uchar4jjR6float2S4_ffPhff, @function
_Z59__device_stub__Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhffP6float4P6uchar4jjR6float2S4_ffPhff:
.LFB2060:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	224(%rsp), %rax
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movl	%edx, 28(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 24(%rsp)
	leaq	56(%rsp), %rcx
	movq	%rax, 8(%rsp)
	movss	%xmm0, 20(%rsp)
	movss	%xmm1, 16(%rsp)
	movss	%xmm2, 4(%rsp)
	movss	%xmm3, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movq	%r8, 144(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 184(%rsp)
	movq	%rsp, %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%r9, 152(%rsp)
	movq	%rax, 64(%rsp)
	movl	$1, 72(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L10
	pushq	56(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhff(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 240
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L10:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z59__device_stub__Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhffP6float4P6uchar4jjR6float2S4_ffPhff, .-_Z59__device_stub__Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhffP6float4P6uchar4jjR6float2S4_ffPhff
	.globl	_Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhff
	.type	_Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhff, @function
_Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhff:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$32, %rsp
	.cfi_def_cfa_offset 40
	movq	%xmm0, 16(%rsp)
	movaps	%xmm2, %xmm0
	movaps	%xmm4, %xmm2
	movq	%xmm1, 8(%rsp)
	movaps	%xmm3, %xmm1
	movaps	%xmm5, %xmm3
	pushq	%r8
	.cfi_def_cfa_offset 48
	leaq	16(%rsp), %r9
	leaq	24(%rsp), %r8
	call	_Z59__device_stub__Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhffP6float4P6uchar4jjR6float2S4_ffPhff
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhff, .-_Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhff
	.section	.rodata.str1.1
.LC1:
	.string	"d_perm malloc or copy failed!"
.LC3:
	.string	"kernel failed!"
	.text
	.globl	launch_kernel
	.type	launch_kernel, @function
launch_kernel:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	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
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edx, %ebx
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	movl	%ecx, %eax
	movl	$256, %ecx
	imull	%edx, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	setg	%r14b
	addl	%eax, %r14d
	cmpq	$0, d_perm(%rip)
	jne	.L17
	movl	$256, %esi
	leaq	d_perm(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movq	d_perm(%rip), %rdi
	movl	$256, %edx
	leaq	_ZL6h_perm(%rip), %rsi
	call	cudaMemcpy@PLT
	leaq	.LC1(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
.L17:
	movl	%r14d, 16(%rsp)
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	salq	$8, %rdx
	movl	$1, %ecx
	movq	%rax, 20(%rsp)
	movq	16(%rsp), %rdi
	movl	24(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	movss	xStart(%rip), %xmm0
	movl	%ebx, %eax
	movl	%ebp, %ecx
	movl	%ebx, %edx
	cvtsi2ssq	%rax, %xmm2
	movl	%ebp, %eax
	movss	lacunarity(%rip), %xmm3
	movq	%r13, %rsi
	movss	%xmm0, (%rsp)
	movss	yStart(%rip), %xmm0
	movq	%r12, %rdi
	movss	%xmm0, 4(%rsp)
	movss	.LC2(%rip), %xmm0
	movaps	%xmm0, %xmm1
	divss	%xmm2, %xmm1
	movss	octaves(%rip), %xmm2
	movss	%xmm1, 8(%rsp)
	cvtsi2ssq	%rax, %xmm1
	divss	%xmm1, %xmm0
	movss	zOffset(%rip), %xmm1
	movss	%xmm0, 12(%rsp)
	movss	gain(%rip), %xmm0
	pushq	%rax
	.cfi_def_cfa_offset 104
	pushq	d_perm(%rip)
	.cfi_def_cfa_offset 112
	leaq	24(%rsp), %r9
	leaq	16(%rsp), %r8
	call	_Z59__device_stub__Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhffP6float4P6uchar4jjR6float2S4_ffPhff
	popq	%rdx
	.cfi_def_cfa_offset 104
	popq	%rcx
	.cfi_def_cfa_offset 96
.L18:
	call	cudaThreadSynchronize@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	leaq	.LC3(%rip), %rdi
	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
	jmp	_Z14checkCUDAErrorPKc
	.cfi_endproc
.LFE2035:
	.size	launch_kernel, .-launch_kernel
	.section	.rodata.str1.1
.LC4:
	.string	"_Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhff"
.LC5:
	.string	"c_perm"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2063:
	.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	_Z8k_perlinP6float4P6uchar4jj6float2S3_ffPhff(%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	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC5(%rip), %rdx
	movl	$256, %r9d
	leaq	_ZL6c_perm(%rip), %rsi
	pushq	$1
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.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
.LFE2063:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	eColor
	.bss
	.align 8
	.type	eColor, @object
	.size	eColor, 8
eColor:
	.zero	8
	.section	.rodata
	.align 32
	.type	_ZL6h_perm, @object
	.size	_ZL6h_perm, 256
_ZL6h_perm:
	.string	"\227\240\211[Z\017\203\r\311_`5\302\351\007\341\214$g\036E\216\bc%\360\025\n\027\276\006\224\367x\352K"
	.ascii	"\032\305>^\374\333\313u#\013 9\261!X\355\2258W\256\024}\210\253"
	.ascii	"\250D\257J\245G\206\2130\033\246M\222\236\347So\345z<\323\205"
	.ascii	"\346\334i\\)7.\365(\364f\2176A\031?\241\001\330PI\321L\204\273"
	.ascii	"\320Y\022\251\310\304\207\202t\274\237V\244dm\306\255\272\003"
	.ascii	"@4\331\342\372|{\005\312&\223v~\377RU\324\317\316;\343/\020:"
	.ascii	"\021\266\275\034*\337\267\252\325w\370\230\002,\232\243F\335"
	.ascii	"\231e\233\247+\254\t\201\026'\375\023blnOq\340\350\262\271ph"
	.ascii	"\332\366a\344\373\"\362\301\356\322\220\f\277\263\242\361Q3\221"
	.ascii	"\353\371\016\357k1\300\326\037\265\307j\235\270T\314\260sy2-"
	.ascii	"\177\004\226\376\212\354\315]\336rC\035\030H\363\215\200\303"
	.ascii	"NB\327=\234\264"
	.globl	d_perm
	.bss
	.align 8
	.type	d_perm, @object
	.size	d_perm, 8
d_perm:
	.zero	8
	.local	_ZL6c_perm
	.comm	_ZL6c_perm,256,32
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	1092616192
	.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:

//Perlin kernel (Rob Farber)

#include <hip/hip_runtime.h>
#include <stdio.h>

extern float gain, xStart, yStart, zOffset, octaves, lacunarity;
#define Z_PLANE 50.f

__constant__ unsigned char c_perm[256];
__shared__ unsigned char s_perm[256]; // shared memory copy of permuation array
unsigned char* d_perm=NULL; // global memory copy of permutation array
// host version of permutation array
const static unsigned char h_perm[] = {151,160,137,91,90,15,
   131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
   190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
   88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
   77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
   102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
   135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
   5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
   223,183,170,213,119,248,152,2,44,154,163, 70,221,153,101,155,167, 43,172,9,
   129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
   251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
   49,192,214, 31,181,199,106,157,184,84,204,176,115,121,50,45,127, 4,150,254,
   138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180
   };

__device__ inline int perm(int i) { return(s_perm[i&0xff]); }
__device__ inline float fade(float t) { return t * t * t * (t * (t * 6.f - 15.f) + 10.f); }
__device__ inline float lerpP(float t, float a, float b) { return a + t * (b - a); }
__device__ inline float grad(int hash, float x, float y, float z) {
  int h = hash & 15;                      // CONVERT LO 4 BITS OF HASH CODE
  float u = h<8 ? x : y,                 // INTO 12 GRADIENT DIRECTIONS.
    v = h<4 ? y : h==12||h==14 ? x : z;
  return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v);
}

__device__ float inoise(float x, float y, float z) {
  int X = ((int)floorf(x)) & 255, // FIND UNIT CUBE THAT
    Y = ((int)floorf(y)) & 255,   // CONTAINS POINT.
    Z = ((int)floorf(z)) & 255;
  x -= floorf(x);               // FIND RELATIVE X,Y,Z
  y -= floorf(y);               // OF POINT IN CUBE.
  z -= floorf(z);
  float u = fade(x),            // COMPUTE FADE CURVES
    v = fade(y),                // FOR EACH OF X,Y,Z.
    w = fade(z);
  int A = perm(X)+Y, AA = perm(A)+Z, AB = perm(A+1)+Z, // HASH COORDINATES OF
    B = perm(X+1)+Y, BA = perm(B)+Z, BB = perm(B+1)+Z; // THE 8 CUBE CORNERS,
  
  return lerpP(w, lerpP(v, lerpP(u, grad(perm(AA), x  , y  , z   ), // AND ADD
				 grad(perm(BA), x-1.f, y  , z   )),   // BLENDED
			lerpP(u, grad(perm(AB), x  , y-1.f, z   ),    // RESULTS
			      grad(perm(BB), x-1.f, y-1.f, z   ))),     // FROM  8
	       lerpP(v, lerpP(u, grad(perm(AA+1), x  , y  , z-1.f ),  // CORNERS
			      grad(perm(BA+1), x-1.f, y  , z-1.f )),    // OF CUBE
		     lerpP(u, grad(perm(AB+1), x  , y-1.f, z-1.f ),
			   grad(perm(BB+1), x-1.f, y-1.f, z-1.f ))));
#ifdef ORIG
  return(perm(X));
#endif
 
}

__device__ float fBm(float x, float y, int octaves,
		     float lacunarity = 2.0f, float gain = 0.5f)
{
  float freq = 1.0f, amp = 0.5f;
  float sum = 0.f;  
  for(int i=0; i<octaves; i++) {
    sum += inoise(x*freq, y*freq, Z_PLANE)*amp;
    freq *= lacunarity;
    amp *= gain;
  }
  return sum;
}


__device__ inline uchar4 colorElevation(float texHeight)
{
  uchar4 pos;

  // color textel (r,g,b,a)
       if (texHeight < -1.000f) pos = make_uchar4(000, 000, 128, 255); //deeps
  else if (texHeight < -.2500f) pos = make_uchar4(000, 000, 255, 255); //shallow
  else if (texHeight < 0.0000f) pos = make_uchar4(000, 128, 255, 255); //shore
  else if (texHeight < 0.0125f) pos = make_uchar4(240, 240, 064, 255); //sand
  else if (texHeight < 0.1250f) pos = make_uchar4(032, 160, 000, 255); //grass
  else if (texHeight < 0.3750f) pos = make_uchar4(224, 224, 000, 255); //dirt
  else if (texHeight < 0.7500f) pos = make_uchar4(128, 128, 128, 255); //rock
  else                          pos = make_uchar4(255, 255, 255, 255); //snow

  return(pos);
}

void checkCUDAError(const char *msg) {
  hipError_t err = hipGetLastError();
  if( hipSuccess != err) {
    fprintf(stderr, "Cuda error: %s: %s.\n", msg, hipGetErrorString( err) ); 
    exit(EXIT_FAILURE); 
  }
} 

//Simple kernel fills an array with perlin noise
__global__ void k_perlin(float4* pos, uchar4 *colorPos,
			  unsigned int width, unsigned int height, 
			 float2 start, float2 delta, float gain, float zOffset,
			 unsigned char* d_perm, float octaves, float lacunarity)
{
  int idx = blockIdx.x * blockDim.x + threadIdx.x;
  float xCur = start.x + ((float) (idx%width)) * delta.x;
  float yCur = start.y + ((float) (idx/width)) * delta.y;

  if(threadIdx.x < 256)
    // Optimization: this causes bank conflicts
    s_perm[threadIdx.x] = d_perm[threadIdx.x];
  // this synchronization can be important if there are more that 256 threads
  __syncthreads();

  
  // Each thread creates one pixel location in the texture (textel)
  if(idx < width*height) {
    float w = fBm(xCur, yCur, octaves, lacunarity, gain) + zOffset;
    
    colorPos[idx] = colorElevation(w);
    float u = ((float) (idx%width))/(float) width;
    float v = ((float) (idx/width))/(float) height;
    u = u*2.f - 1.f;
    v = v*2.f - 1.f;
    w = (w>0.f)?w:0.f; // don't show region underwater
    pos[idx] = make_float4( u, w, v, 1.0f);
  }
}


uchar4 *eColor=NULL;
// Wrapper for the __global__ call that sets up the kernel call
extern "C" void launch_kernel(float4 *pos, uchar4* posColor,
			      unsigned int image_width, unsigned int image_height,
			      float time)
{
  int nThreads=256; // must be equal or larger than 256! (see s_perm)
  int totalThreads = image_height * image_width;
  int nBlocks = totalThreads/nThreads; 
  nBlocks += ((totalThreads%nThreads)>0)?1:0;
  
  float xExtent = 10.f;
  float yExtent = 10.f;
  float xDelta = xExtent/(float)image_width;
  float yDelta = yExtent/(float)image_height;
  
  if(!d_perm) { // for convenience allocate and copy d_perm here
    hipMalloc((void**) &d_perm,sizeof(h_perm));
    hipMemcpy(d_perm,h_perm,sizeof(h_perm),hipMemcpyHostToDevice);
    checkCUDAError("d_perm malloc or copy failed!");
  }

  k_perlin<<< nBlocks, nThreads>>>(pos, posColor, image_width, image_height,
				   make_float2(xStart, yStart),
				   make_float2(xDelta, yDelta),
				   gain, zOffset, d_perm,
				   octaves, lacunarity);
  
  // make certain the kernel has completed 
  hipDeviceSynchronize();
  checkCUDAError("kernel failed!");
}


	.text
	.file	"kernelVBO.hip"
	.globl	_Z14checkCUDAErrorPKc           # -- Begin function _Z14checkCUDAErrorPKc
	.type	_Z14checkCUDAErrorPKc,@function
_Z14checkCUDAErrorPKc:                  # @_Z14checkCUDAErrorPKc
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %rbx
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB0_2
# %bb.1:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB0_2:
	.cfi_def_cfa_offset 32
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movq	%r14, %rdi
	movq	%rbx, %rdx
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z14checkCUDAErrorPKc, .Lfunc_end0-_Z14checkCUDAErrorPKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff # -- Begin function _Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
	.type	_Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff,@function
_Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff: # @_Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
	.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	$208, %rsp
	.cfi_def_cfa_offset 256
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	72(%rsp), %rax
	movsd	%xmm0, (%rax)
	leaq	64(%rsp), %r9
	movsd	%xmm1, (%r9)
	leaq	56(%rsp), %r10
	movq	%rdi, (%r10)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	20(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	16(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	12(%rsp), %rcx
	movss	%xmm2, (%rcx)
	leaq	8(%rsp), %r11
	movss	%xmm3, (%r11)
	leaq	40(%rsp), %r14
	movq	%r8, (%r14)
	leaq	4(%rsp), %r8
	movss	%xmm4, (%r8)
	movq	%rsp, %r15
	movss	%xmm5, (%r15)
	leaq	112(%rsp), %rbx
	movq	%r10, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rax, 32(%rbx)
	movq	%r9, 40(%rbx)
	movq	%rcx, 48(%rbx)
	movq	%r11, 56(%rbx)
	movq	%r14, 64(%rbx)
	movq	%r8, 72(%rbx)
	movq	%r15, 80(%rbx)
	leaq	96(%rsp), %r14
	leaq	80(%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	$_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$224, %rsp
	.cfi_adjust_cfa_offset -224
	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	_Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff, .Lfunc_end1-_Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function launch_kernel
.LCPI2_0:
	.long	0x41200000                      # float 10
	.text
	.globl	launch_kernel
	.type	launch_kernel,@function
launch_kernel:                          # @launch_kernel
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebx
	movl	%edx, %ebp
	movq	%rsi, %r14
	movl	%ecx, %eax
	imull	%edx, %eax
	leal	255(%rax), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	movq	%rdi, %r15
	sarl	$8, %ecx
	xorl	%r12d, %r12d
	testl	$-2147483393, %eax              # imm = 0x800000FF
	setg	%r12b
	addl	%ecx, %r12d
	cmpq	$0, d_perm(%rip)
	jne	.LBB2_2
# %bb.1:
	movl	$d_perm, %edi
	movl	$256, %esi                      # imm = 0x100
	callq	hipMalloc
	movq	d_perm(%rip), %rdi
	movl	$_ZL6h_perm, %esi
	movl	$256, %edx                      # imm = 0x100
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.1, %edi
	callq	_Z14checkCUDAErrorPKc
.LBB2_2:
	movl	%r12d, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$256, %rdx                      # imm = 0x100
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_4
# %bb.3:
	movl	%ebp, %eax
	movl	%ebx, %ecx
	cvtsi2ss	%rax, %xmm0
	movss	.LCPI2_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	cvtsi2ss	%rcx, %xmm3
	movaps	%xmm2, %xmm1
	divss	%xmm0, %xmm1
	divss	%xmm3, %xmm2
	unpcklps	%xmm2, %xmm1                    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
	movss	yStart(%rip), %xmm2             # xmm2 = mem[0],zero,zero,zero
	movss	xStart(%rip), %xmm0             # xmm0 = mem[0],zero,zero,zero
	unpcklps	%xmm2, %xmm0                    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
	movss	gain(%rip), %xmm2               # xmm2 = mem[0],zero,zero,zero
	movss	zOffset(%rip), %xmm3            # xmm3 = mem[0],zero,zero,zero
	movq	d_perm(%rip), %r8
	movss	octaves(%rip), %xmm4            # xmm4 = mem[0],zero,zero,zero
	movss	lacunarity(%rip), %xmm5         # xmm5 = mem[0],zero,zero,zero
	movq	%r15, %rdi
	movq	%r14, %rsi
	movl	%ebp, %edx
	movl	%ebx, %ecx
	callq	_Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
.LBB2_4:
	callq	hipDeviceSynchronize
	movl	$.L.str.2, %edi
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z14checkCUDAErrorPKc           # TAILCALL
.Lfunc_end2:
	.size	launch_kernel, .Lfunc_end2-launch_kernel
	.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	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$1, (%rsp)
	movl	$c_perm, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movl	$256, %r9d                      # imm = 0x100
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	c_perm,@object                  # @c_perm
	.local	c_perm
	.comm	c_perm,256,16
	.type	d_perm,@object                  # @d_perm
	.bss
	.globl	d_perm
	.p2align	3, 0x0
d_perm:
	.quad	0
	.size	d_perm, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Cuda error: %s: %s.\n"
	.size	.L.str, 21

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

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

	.type	_ZL6h_perm,@object              # @_ZL6h_perm
	.section	.rodata,"a",@progbits
	.p2align	4, 0x0
_ZL6h_perm:
	.ascii	"\227\240\211[Z\017\203\r\311_`5\302\351\007\341\214$g\036E\216\bc%\360\025\n\027\276\006\224\367x\352K\000\032\305>^\374\333\313u#\013 9\261!X\355\2258W\256\024}\210\253\250D\257J\245G\206\2130\033\246M\222\236\347So\345z<\323\205\346\334i\\)7.\365(\364f\2176A\031?\241\001\330PI\321L\204\273\320Y\022\251\310\304\207\202t\274\237V\244dm\306\255\272\003@4\331\342\372|{\005\312&\223v~\377RU\324\317\316;\343/\020:\021\266\275\034*\337\267\252\325w\370\230\002,\232\243F\335\231e\233\247+\254\t\201\026'\375\023blnOq\340\350\262\271ph\332\366a\344\373\"\362\301\356\322\220\f\277\263\242\361Q3\221\353\371\016\357k1\300\326\037\265\307j\235\270T\314\260sy2-\177\004\226\376\212\354\315]\336rC\035\030H\363\215\200\303NB\327=\234\264"
	.size	_ZL6h_perm, 256

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"d_perm malloc or copy failed!"
	.size	.L.str.1, 30

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"kernel failed!"
	.size	.L.str.2, 15

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff"
	.size	.L__unnamed_1, 67

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"c_perm"
	.size	.L__unnamed_2, 7

	.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 _Z23__device_stub__k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym c_perm
	.addrsig_sym d_perm
	.addrsig_sym _Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
	.addrsig_sym _ZL6h_perm
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff ; -- Begin function _Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
	.globl	_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
	.p2align	8
	.type	_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff,@function
_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff: ; @_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
; %bb.0:
	s_clause 0x1
	s_load_b256 s[16:23], s[0:1], 0x10
	s_load_b32 s2, s[0:1], 0x4c
	s_mov_b32 s3, exec_lo
	v_cmpx_gt_u32_e32 0x100, v0
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b64 s[4:5], s[0:1], 0x30
	s_waitcnt lgkmcnt(0)
	global_load_u8 v1, v0, s[4:5]
	s_waitcnt vmcnt(0)
	ds_store_b8 v0, v1
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s3
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, 0xffff, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mul_i32 s2, s17, s16
	s_barrier
	buffer_gl0_inv
	v_cmp_gt_u32_e32 vcc_lo, s2, v1
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_20
; %bb.3:
	v_cvt_f32_u32_e32 v0, s16
	s_sub_i32 s2, 0, s16
	s_load_b64 s[12:13], s[0:1], 0x38
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v2, v0
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v2, 0x4f7ffffe, v2
	v_cvt_u32_f32_e32 v2, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v3, s2, v2
	v_mul_hi_u32 v3, v2, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v2, v2, v3
	v_mul_hi_u32 v2, v1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v3, v2, s16
	v_add_nc_u32_e32 v4, 1, v2
	v_sub_nc_u32_e32 v3, v1, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_subrev_nc_u32_e32 v5, s16, v3
	v_cmp_le_u32_e32 vcc_lo, s16, v3
	v_dual_cndmask_b32 v3, v3, v5 :: v_dual_cndmask_b32 v2, v2, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_le_u32_e32 vcc_lo, s16, v3
	v_add_nc_u32_e32 v4, 1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v4, v2, v4, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_cvt_i32_f32_e32 v2, s12
	v_mul_lo_u32 v3, v4, s16
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_cmp_gt_i32_e32 vcc_lo, 1, v2
	v_cvt_f32_u32_e32 v4, v4
	v_sub_nc_u32_e32 v3, v1, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_u32_e32 v3, v3
	s_cbranch_vccnz .LBB0_6
; %bb.4:                                ; %.lr.ph.i.preheader
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f32 v6, s20, v3, s18
	v_fma_f32 v7, s21, v4, s19
	v_dual_mov_b32 v8, 0.5 :: v_dual_mov_b32 v9, 1.0
	v_mov_b32_e32 v5, 0
	s_mov_b32 s14, 0x40c00000
.LBB0_5:                                ; %.lr.ph.i
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mul_f32 v11, v7, v9 :: v_dual_add_nc_u32 v2, -1, v2
	v_floor_f32_e32 v11, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_cvt_i32_f32_e32 v13, v11
	v_fma_f32 v11, v7, v9, -v11
	v_mul_f32_e32 v10, v6, v9
	v_dual_add_f32 v20, -1.0, v11 :: v_dual_and_b32 v13, 0xff, v13
	v_mul_f32_e32 v17, v11, v11
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_floor_f32_e32 v10, v10
	v_dual_fmaak_f32 v18, s14, v11, 0xc1700000 :: v_dual_mul_f32 v17, v11, v17
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cvt_i32_f32_e32 v12, v10
	v_fma_f32 v10, v6, v9, -v10
	v_dual_mul_f32 v9, s13, v9 :: v_dual_and_b32 v14, 0xff, v12
	s_delay_alu instid0(VALU_DEP_2)
	v_mul_f32_e32 v15, v10, v10
	v_fmaak_f32 v16, s14, v10, 0xc1700000
	v_dual_add_f32 v19, -1.0, v10 :: v_dual_add_nc_u32 v12, 1, v12
	ds_load_u8 v14, v14
	v_mul_f32_e32 v15, v10, v15
	v_fmaak_f32 v16, v10, v16, 0x41200000
	v_and_b32_e32 v12, 0xff, v12
	ds_load_u8 v12, v12
	s_waitcnt lgkmcnt(1)
	v_dual_mul_f32 v15, v15, v16 :: v_dual_add_nc_u32 v14, v13, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v16, 1, v14
	v_and_b32_e32 v14, 0xff, v14
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v12, v13, v12
	v_and_b32_e32 v13, 0xff, v16
	ds_load_u8 v14, v14
	v_and_b32_e32 v16, 0xff, v12
	v_add_nc_u32_e32 v12, 1, v12
	ds_load_u8 v13, v13
	ds_load_u8 v16, v16
	v_fmaak_f32 v18, v11, v18, 0x41200000
	v_and_b32_e32 v12, 0xff, v12
	ds_load_u8 v12, v12
	s_waitcnt lgkmcnt(3)
	v_add_nc_u32_e32 v21, 50, v14
	v_add_nc_u32_e32 v14, 51, v14
	s_delay_alu instid0(VALU_DEP_2)
	v_and_b32_e32 v21, 0xff, v21
	s_waitcnt lgkmcnt(1)
	v_add_nc_u32_e32 v23, 50, v16
	v_add_nc_u32_e32 v22, 50, v13
	v_add_nc_u32_e32 v16, 51, v16
	ds_load_u8 v21, v21
	v_and_b32_e32 v23, 0xff, v23
	v_and_b32_e32 v22, 0xff, v22
	v_and_b32_e32 v16, 0xff, v16
	ds_load_u8 v23, v23
	s_waitcnt lgkmcnt(2)
	v_add_nc_u32_e32 v24, 50, v12
	v_add_nc_u32_e32 v12, 51, v12
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_and_b32_e32 v24, 0xff, v24
	v_and_b32_e32 v12, 0xff, v12
	s_waitcnt lgkmcnt(1)
	v_and_b32_e32 v25, 13, v21
	v_and_b32_e32 v26, 15, v21
	v_and_b32_e32 v27, 1, v21
	v_and_b32_e32 v21, 2, v21
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_cmp_eq_u32_e32 vcc_lo, 12, v25
	v_cmp_gt_u32_e64 s2, 4, v26
	s_waitcnt lgkmcnt(0)
	v_and_b32_e32 v29, 13, v23
	v_cmp_eq_u32_e64 s5, 0, v21
	v_dual_cndmask_b32 v25, 0, v10 :: v_dual_and_b32 v30, 1, v23
	v_cmp_gt_u32_e32 vcc_lo, 8, v26
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_cndmask_b32_e64 v25, v25, v11, s2
	v_cndmask_b32_e32 v28, v11, v10, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, 0, v27
	v_cndmask_b32_e64 v21, -v25, v25, s5
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v26, -v28, v28, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, 12, v29
	v_add_f32_e32 v21, v26, v21
	v_and_b32_e32 v27, 15, v23
	v_and_b32_e32 v23, 2, v23
	v_cndmask_b32_e32 v28, 0, v19, vcc_lo
	v_and_b32_e32 v14, 0xff, v14
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_cmp_gt_u32_e32 vcc_lo, 4, v27
	v_cmp_gt_u32_e64 s2, 8, v27
	v_cmp_eq_u32_e64 s12, 0, v23
	v_cndmask_b32_e32 v25, v28, v11, vcc_lo
	v_cndmask_b32_e64 v27, v11, v19, s2
	v_cmp_eq_u32_e64 s2, 0, v30
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v23, -v25, v25, s12
	v_cndmask_b32_e64 v27, -v27, v27, s2
	v_add_nc_u32_e32 v13, 51, v13
	s_delay_alu instid0(VALU_DEP_1)
	v_and_b32_e32 v13, 0xff, v13
	ds_load_u8 v22, v22
	ds_load_u8 v24, v24
	ds_load_u8 v14, v14
	ds_load_u8 v16, v16
	ds_load_u8 v13, v13
	ds_load_u8 v12, v12
	s_waitcnt lgkmcnt(5)
	v_and_b32_e32 v31, 15, v22
	v_and_b32_e32 v32, 13, v22
	v_and_b32_e32 v33, 1, v22
	s_waitcnt lgkmcnt(3)
	v_and_b32_e32 v34, 15, v14
	v_and_b32_e32 v35, 13, v14
	v_cmp_gt_u32_e64 s4, 8, v31
	v_cmp_eq_u32_e64 s3, 12, v32
	v_and_b32_e32 v32, 13, v24
	s_waitcnt lgkmcnt(2)
	v_and_b32_e32 v38, 13, v16
	s_waitcnt lgkmcnt(1)
	v_and_b32_e32 v41, 13, v13
	v_cndmask_b32_e64 v30, v20, v10, s4
	v_cndmask_b32_e64 v29, 0, v10, s3
	v_cmp_gt_u32_e64 s3, 4, v31
	v_cmp_eq_u32_e64 s4, 0, v33
	v_and_b32_e32 v31, 15, v24
	s_waitcnt lgkmcnt(0)
	v_and_b32_e32 v44, 13, v12
	v_and_b32_e32 v22, 2, v22
	v_and_b32_e32 v33, 1, v24
	v_and_b32_e32 v36, 1, v14
	v_and_b32_e32 v37, 15, v16
	v_and_b32_e32 v40, 15, v13
	v_and_b32_e32 v43, 15, v12
	v_cndmask_b32_e64 v28, v29, v20, s3
	v_cndmask_b32_e64 v29, -v30, v30, s4
	v_cmp_eq_u32_e64 s2, 12, v32
	v_cmp_gt_u32_e64 s3, 8, v31
	v_cmp_eq_u32_e64 s4, 12, v35
	v_cmp_gt_u32_e64 s5, 8, v34
	v_cmp_eq_u32_e64 s6, 12, v38
	v_cmp_eq_u32_e64 s8, 12, v41
	v_cmp_eq_u32_e64 s10, 12, v44
	v_and_b32_e32 v24, 2, v24
	v_and_b32_e32 v14, 2, v14
	v_and_b32_e32 v39, 1, v16
	v_and_b32_e32 v16, 2, v16
	v_and_b32_e32 v42, 1, v13
	v_and_b32_e32 v13, 2, v13
	v_and_b32_e32 v45, 1, v12
	v_and_b32_e32 v12, 2, v12
	v_cmp_eq_u32_e32 vcc_lo, 0, v22
	v_cndmask_b32_e64 v22, 0, v19, s2
	v_cmp_gt_u32_e64 s2, 4, v31
	v_cndmask_b32_e64 v30, v20, v19, s3
	v_cmp_eq_u32_e64 s3, 0, v33
	v_cndmask_b32_e64 v31, -1.0, v10, s4
	v_cmp_gt_u32_e64 s4, 4, v34
	v_cndmask_b32_e64 v32, v11, v10, s5
	v_cmp_eq_u32_e64 s5, 0, v36
	v_cndmask_b32_e64 v33, -1.0, v19, s6
	v_cmp_gt_u32_e64 s6, 4, v37
	v_cmp_gt_u32_e64 s7, 8, v37
	v_cndmask_b32_e64 v35, -1.0, v10, s8
	v_cmp_gt_u32_e64 s8, 4, v40
	v_cmp_gt_u32_e64 s9, 8, v40
	v_cndmask_b32_e64 v36, -1.0, v19, s10
	v_cmp_gt_u32_e64 s10, 4, v43
	v_cmp_gt_u32_e64 s11, 8, v43
	v_cndmask_b32_e64 v34, v11, v19, s7
	v_cmp_eq_u32_e64 s7, 0, v39
	v_cndmask_b32_e64 v10, v20, v10, s9
	v_cmp_eq_u32_e64 s9, 0, v42
	v_cndmask_b32_e64 v19, v20, v19, s11
	v_cmp_eq_u32_e64 s11, 0, v45
	v_cndmask_b32_e64 v25, -v28, v28, vcc_lo
	v_cndmask_b32_e64 v22, v22, v20, s2
	v_cndmask_b32_e64 v26, -v30, v30, s3
	v_cndmask_b32_e64 v28, v31, v11, s4
	v_cndmask_b32_e64 v30, -v32, v32, s5
	v_cmp_eq_u32_e32 vcc_lo, 0, v14
	v_cndmask_b32_e64 v11, v33, v11, s6
	v_cmp_eq_u32_e64 s2, 0, v16
	v_cndmask_b32_e64 v16, v35, v20, s8
	v_cmp_eq_u32_e64 s3, 0, v13
	v_cndmask_b32_e64 v13, v36, v20, s10
	v_cmp_eq_u32_e64 s4, 0, v12
	v_cmp_eq_u32_e64 s5, 0, v24
	v_cndmask_b32_e64 v14, -v34, v34, s7
	v_cndmask_b32_e64 v10, -v10, v10, s9
	v_cndmask_b32_e64 v19, -v19, v19, s11
	v_add_f32_e32 v12, v27, v23
	v_cndmask_b32_e64 v22, -v22, v22, s5
	v_cndmask_b32_e64 v23, -v28, v28, vcc_lo
	v_cndmask_b32_e64 v11, -v11, v11, s2
	v_cndmask_b32_e64 v16, -v16, v16, s3
	v_cndmask_b32_e64 v13, -v13, v13, s4
	v_add_f32_e32 v20, v29, v25
	v_add_f32_e32 v22, v26, v22
	v_add_f32_e32 v23, v30, v23
	v_add_f32_e32 v11, v14, v11
	v_dual_add_f32 v10, v10, v16 :: v_dual_add_f32 v13, v19, v13
	v_sub_f32_e32 v12, v12, v21
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_dual_sub_f32 v14, v22, v20 :: v_dual_sub_f32 v11, v11, v23
	v_cmp_ne_u32_e32 vcc_lo, 0, v2
	v_sub_f32_e32 v13, v13, v10
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_fmac_f32_e32 v21, v15, v12
	v_fmac_f32_e32 v20, v15, v14
	v_fmac_f32_e32 v23, v15, v11
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_dual_mul_f32 v11, v17, v18 :: v_dual_fmac_f32 v10, v15, v13
	s_and_b32 vcc_lo, exec_lo, vcc_lo
	v_sub_f32_e32 v12, v20, v21
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_sub_f32 v10, v10, v23 :: v_dual_fmac_f32 v21, v11, v12
	v_fmac_f32_e32 v23, v11, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v10, v23, v21
	v_fmac_f32_e32 v21, 0, v10
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_fmac_f32 v5, v8, v21 :: v_dual_mul_f32 v8, s22, v8
	s_cbranch_vccnz .LBB0_5
	s_branch .LBB0_7
.LBB0_6:
	v_mov_b32_e32 v5, 0
.LBB0_7:                                ; %_Z3fBmffiff.exit
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_dual_add_f32 v6, s23, v5 :: v_dual_mov_b32 v5, 0xff800000
	s_mov_b32 s2, exec_lo
	v_cmpx_ngt_f32_e32 -1.0, v6
	s_cbranch_execz .LBB0_19
; %bb.8:
	v_mov_b32_e32 v5, 0xffff0000
	s_mov_b32 s3, exec_lo
	v_cmpx_ngt_f32_e32 0xbe800000, v6
	s_cbranch_execz .LBB0_18
; %bb.9:
	v_mov_b32_e32 v5, 0xffff8000
	s_mov_b32 s4, exec_lo
	v_cmpx_ngt_f32_e32 0, v6
	s_cbranch_execz .LBB0_17
; %bb.10:
	v_mov_b32_e32 v5, 0xff34f0f0
	s_mov_b32 s5, exec_lo
	v_cmpx_ngt_f32_e32 0x3c4ccccd, v6
	s_cbranch_execz .LBB0_16
; %bb.11:
	v_mov_b32_e32 v5, 0xff00a01a
	s_mov_b32 s6, exec_lo
	v_cmpx_ngt_f32_e32 0x3e000000, v6
	s_cbranch_execz .LBB0_15
; %bb.12:
	v_mov_b32_e32 v5, 0xff00e0e0
	s_mov_b32 s7, exec_lo
	v_cmpx_ngt_f32_e32 0x3ec00000, v6
; %bb.13:
	v_cmp_gt_f32_e32 vcc_lo, 0x3f400000, v6
	v_cndmask_b32_e64 v5, -1, 0xff808080, vcc_lo
; %bb.14:                               ; %Flow
	s_or_b32 exec_lo, exec_lo, s7
.LBB0_15:                               ; %Flow68
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s6
.LBB0_16:                               ; %Flow69
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s5
.LBB0_17:                               ; %Flow70
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s4
.LBB0_18:                               ; %Flow71
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s3
.LBB0_19:                               ; %_Z14colorElevationf.exit
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	s_or_b32 exec_lo, exec_lo, s2
	v_cvt_f32_u32_e32 v12, s17
	v_div_scale_f32 v10, null, v0, v0, v3
	v_div_scale_f32 v15, vcc_lo, v3, v0, v3
	v_div_scale_f32 v11, null, v12, v12, v4
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_rcp_f32_e32 v13, v10
	v_div_scale_f32 v16, s2, v4, v12, v4
	v_rcp_f32_e32 v14, v11
	s_load_b128 s[4:7], s[0:1], 0x0
	s_waitcnt_depctr 0xfff
	v_fma_f32 v2, -v10, v13, 1.0
	v_fma_f32 v7, -v11, v14, 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_fmac_f32_e32 v13, v2, v13
	v_ashrrev_i32_e32 v2, 31, v1
	v_fmac_f32_e32 v14, v7, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mul_f32 v17, v15, v13 :: v_dual_mul_f32 v18, v16, v14
	v_fma_f32 v7, -v10, v17, v15
	v_max_f32_e32 v6, v6, v6
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f32 v8, -v11, v18, v16
	v_fmac_f32_e32 v17, v7, v13
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_max_f32_e32 v7, 0, v6
	v_fmac_f32_e32 v18, v8, v14
	v_lshlrev_b64 v[8:9], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_fma_f32 v6, -v10, v17, v15
	v_lshlrev_b64 v[1:2], 4, v[1:2]
	v_fma_f32 v10, -v11, v18, v16
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_fmas_f32 v6, v6, v13, v17
	s_mov_b32 vcc_lo, s2
	v_div_fmas_f32 v13, v10, v14, v18
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v10, vcc_lo, s6, v8
	v_div_fixup_f32 v3, v6, v0, v3
	v_add_co_ci_u32_e32 v11, vcc_lo, s7, v9, vcc_lo
	v_mov_b32_e32 v9, 1.0
	v_div_fixup_f32 v4, v13, v12, v4
	v_add_co_u32 v0, vcc_lo, s4, v1
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v2, vcc_lo
	v_fma_f32 v6, v3, 2.0, -1.0
	s_delay_alu instid0(VALU_DEP_4)
	v_fma_f32 v8, v4, 2.0, -1.0
	global_store_b32 v[10:11], v5, off
	global_store_b128 v[0:1], v[6:9], off
.LBB0_20:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
		.amdhsa_group_segment_fixed_size 256
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.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 46
		.amdhsa_next_free_sgpr 24
		.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	_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff, .Lfunc_end0-_Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2212
; NumSgprs: 26
; NumVgprs: 46
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 256 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 5
; NumSGPRsForWavesPerEU: 26
; NumVGPRsForWavesPerEU: 46
; 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
	.protected	c_perm                  ; @c_perm
	.type	c_perm,@object
	.section	.bss,"aw",@nobits
	.globl	c_perm
	.p2align	4, 0x0
c_perm:
	.zero	256
	.size	c_perm, 256

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.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:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           8
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         44
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         48
        .size:           8
        .value_kind:     global_buffer
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .offset:         60
        .size:           4
        .value_kind:     by_value
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 256
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff
    .private_segment_fixed_size: 0
    .sgpr_count:     26
    .sgpr_spill_count: 0
    .symbol:         _Z8k_perlinP15HIP_vector_typeIfLj4EEPS_IhLj4EEjjS_IfLj2EES4_ffPhff.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     46
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
