// DESCRIPTION HERE
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <chrono>

#define NUM_THREADS 448
#define NUM_CHARS 26
#define SHARED_MEM_SIZE NUM_THREADS * NUM_CHARS

// Calculate how much padding is needed to make the file evenly divided into 448 chunks
size_t calculatePadding(size_t fileSize)
{
	size_t paddingBytes = NUM_THREADS - (fileSize % NUM_THREADS);
	return paddingBytes;
}

// Pad the data so it is evenly divided into 448 chunks
void padData(uint8_t * buf, size_t bytesRead, size_t numPadBytes)
{
    for (size_t i = 0; i < numPadBytes; i++)
    {
        buf[bytesRead + i] = 'a';
    }
}

// Read a file into a byte array
uint8_t * readFile(const char * filename, size_t * outBytesRead, size_t * paddingBytes)
{
	FILE *handle = fopen(filename, "rb");
	fseek(handle, 0, SEEK_END);
	*outBytesRead = ftell(handle);
	*paddingBytes = calculatePadding(*outBytesRead);
	rewind(handle);

	uint8_t * buf = (uint8_t *) malloc((*outBytesRead + *paddingBytes)*sizeof(uint8_t));
	fread(buf, *outBytesRead, 1, handle);
	fclose(handle);

    padData(buf, *outBytesRead, *paddingBytes);

	return buf;
}

// Shift all ascii letters so that 'a' is index 0, 'b' is index 1, etc.
__device__ __constant__ int shiftAmount;
__global__ void shiftLetters(uint8_t *data)
{
    uint32_t threadId = blockIdx.x * blockDim.x + threadIdx.x;
    data[threadId] = data[threadId] - shiftAmount;
}

// Zero out the letter counts
__device__ void zeroLetterCounts(uint32_t * letterCounts)
{
    for (size_t i = 0; i < NUM_CHARS; i++) {
        letterCounts[(threadIdx.x * NUM_CHARS) + i] = 0;
    }
}

// Count the occurence of each letter in *data
__device__ void countLetters(uint8_t *data, uint32_t *letterCounts, uint32_t *threadLetterCounts, size_t chunkSize)
{

    zeroLetterCounts(threadLetterCounts);
    __syncthreads();

    // Tally letters for each thread
    for (size_t i = 0; i < chunkSize; i++)
    {
        threadLetterCounts[(threadIdx.x * NUM_CHARS) + data[(threadIdx.x * chunkSize) + i]]++;
    }

    __syncthreads();

    // Total local thread tallys
    if (threadIdx.x < NUM_CHARS)
    {
        for (size_t i = 0; i < NUM_THREADS; i++)
        {
            letterCounts[threadIdx.x] += threadLetterCounts[threadIdx.x + (i * NUM_CHARS)]; 
        }
    }
}

// Count the occurence of each letter in *data using shared memory
__global__ void countLettersShared(uint8_t *data, uint32_t *letterCounts, size_t chunkSize)
{
    __shared__ uint32_t sharedLetterCounts[SHARED_MEM_SIZE];
    countLetters(data, letterCounts, sharedLetterCounts, chunkSize);
}

// Count the occurence of each letter in *data using global memory
__global__ void countLettersGlobal(uint8_t *data, uint32_t *letterCounts, uint32_t * threadLetterCounts, size_t chunkSize)
{
    countLetters(data, letterCounts, threadLetterCounts, chunkSize);
}

// Remove any padding so that letter counts are accurage
void unpadResult(uint32_t * letterCounts, size_t paddingBytes)
{
    letterCounts[0] -= paddingBytes;
}

// Count the occurence of each letter in *data using shared memory
uint64_t countWithGPUShared(uint8_t * data, size_t dataSize, uint32_t * letterCounts, size_t textChunkSize)
{
    // Declare cuda memory
	uint8_t *gpuData;
    uint32_t *gpuLetterCounts;
	cudaMalloc((void **)&gpuData, dataSize);
	cudaMemcpy(gpuData, data, dataSize, cudaMemcpyHostToDevice);

	cudaMalloc((void **)&gpuLetterCounts, NUM_CHARS * sizeof(uint32_t));
	cudaMemcpy(gpuLetterCounts, letterCounts, NUM_CHARS * sizeof(uint32_t), cudaMemcpyHostToDevice);

    // Run Kernel
    auto start = std::chrono::high_resolution_clock::now();
    shiftLetters<<<textChunkSize, NUM_THREADS>>>(gpuData);
    countLettersShared<<<1, NUM_THREADS>>>(gpuData, gpuLetterCounts, textChunkSize);
    auto stop = std::chrono::high_resolution_clock::now();

	cudaMemcpy(letterCounts, gpuLetterCounts, NUM_CHARS * sizeof(uint32_t), cudaMemcpyDeviceToHost);

	// Free the arrays on the GPU as now we're done with them
	cudaFree(gpuData);
	cudaFree(gpuLetterCounts);

    return std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
}

// Count the occurence of each letter in *data using global memory
uint64_t countWithGPUGlobal(uint8_t * data, size_t dataSize, uint32_t * letterCounts, size_t textChunkSize)
{
    // Declare cuda memory
	uint8_t *gpuData;
    uint32_t *gpuLetterCounts;
    uint32_t *threadLetterCounts;
	cudaMalloc((void **)&gpuData, dataSize);
	cudaMemcpy(gpuData, data, dataSize, cudaMemcpyHostToDevice);

	cudaMalloc((void **)&gpuLetterCounts, NUM_CHARS * sizeof(uint32_t));
	cudaMemcpy(gpuLetterCounts, letterCounts, NUM_CHARS * sizeof(uint32_t), cudaMemcpyHostToDevice);

	cudaMalloc((void **)&threadLetterCounts, SHARED_MEM_SIZE);

    // Run Kernel
    auto start = std::chrono::high_resolution_clock::now();
    shiftLetters<<<textChunkSize, NUM_THREADS>>>(gpuData);
    countLettersGlobal<<<1, NUM_THREADS>>>(gpuData, gpuLetterCounts, threadLetterCounts, textChunkSize);
    auto stop = std::chrono::high_resolution_clock::now();

	cudaMemcpy(letterCounts, gpuLetterCounts, NUM_CHARS * sizeof(uint32_t), cudaMemcpyDeviceToHost);

	/* Free the arrays on the GPU as now we're done with them */
	cudaFree(gpuData);
	cudaFree(gpuLetterCounts);

    return std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
}

// Use the CPU to count the occurrences of each letter in *data
uint64_t countWithCPU(uint8_t * data, size_t dataSize, uint32_t * letterCounts, int ascii_a)
{
    auto start = std::chrono::high_resolution_clock::now();
    for (size_t i = 0; i < dataSize; i++)
    {
        letterCounts[data[i] - ascii_a]++;
    }
    auto stop = std::chrono::high_resolution_clock::now();

    return std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
}

// Display letter counts
void displayResults(uint32_t * letterCounts)
{
    printf("\n\n");
    for (size_t i = 0; i < NUM_CHARS; i++)
    {
        printf("Found %d %c's\n", letterCounts[i], i + 0x61);
    }

    printf("\n\n");
}

// Display and analyze the run times (shared vs. global vs. CPU)
void displayTimingResults(uint64_t gpuSharedDuration, uint64_t gpuGlobalDuration, uint64_t cpuDuration)
{
    printf("Took %dns to run processing on GPU with shared memory\n", gpuSharedDuration);
    printf("Took %dns to run processing on GPU with global memory\n", gpuGlobalDuration);
    printf("Took %dns to run on CPU\n", cpuDuration);

    printf("\n");
    printf("Shared Memory runs %fx faster than global memory\n", ((double)gpuGlobalDuration) / gpuSharedDuration);
    printf("Shared Memory on GPU runs %fx faster than the CPU\n", ((double)cpuDuration) / gpuSharedDuration);
    printf("\n");
}

int main(int argc, char* argv[])
{
    // Read command line args
	std::string fileName = "all_letter.shakespeare.txt";
	if (argc > 1) {
		fileName = argv[1];
	}

    // Copy from host to constant memory
    const int ascii_a = 0x61;
    cudaMemcpyToSymbol(shiftAmount, &ascii_a, sizeof(uint8_t));

    // Declare some variables
    uint32_t letterCounts[NUM_CHARS];
	size_t bytesRead;
	size_t paddingBytes;
    
    // Read file
	uint8_t * data = readFile(fileName.c_str(), &bytesRead, &paddingBytes);

    // Calculate run-time parameters
	size_t dataSize = bytesRead + paddingBytes;
    size_t textChunkSize = dataSize / NUM_THREADS;
	printf("Bytes read: %d\n", bytesRead);
	printf("Padding bytes: %d\n", paddingBytes);

    uint8_t *pinnedData;
    cudaMallocHost((void**)&pinnedData, dataSize);
    memcpy(pinnedData, data, dataSize);

    // Run letter counter on the CPU
    memset(letterCounts, 0, NUM_CHARS * sizeof(uint32_t));
    uint64_t cpuDuration = countWithCPU(pinnedData, dataSize, letterCounts, ascii_a);

    // Run letter counter on the GPU with global memory
    memset(letterCounts, 0, NUM_CHARS * sizeof(uint32_t));
    uint64_t gpuGlobalDuration = countWithGPUGlobal(pinnedData, dataSize, letterCounts, textChunkSize);

    // Run letter counter on the GPU with shared memory
    memset(letterCounts, 0, NUM_CHARS * sizeof(uint32_t));
    uint64_t gpuSharedDuration = countWithGPUShared(pinnedData, dataSize, letterCounts, textChunkSize);
    unpadResult(letterCounts, paddingBytes);

    // Display letter counts and timing
    displayResults(letterCounts);
    displayTimingResults(gpuSharedDuration, gpuGlobalDuration, cpuDuration);

	return EXIT_SUCCESS;
}

	.file	"tmpxft_00246310_00000000-6_letter_counter.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3750:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3750:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z16calculatePaddingm
	.type	_Z16calculatePaddingm, @function
_Z16calculatePaddingm:
.LFB3734:
	.cfi_startproc
	endbr64
	movl	$448, %ecx
	movq	%rdi, %rax
	xorl	%edx, %edx
	divq	%rcx
	movq	%rcx, %rax
	subq	%rdx, %rax
	ret
	.cfi_endproc
.LFE3734:
	.size	_Z16calculatePaddingm, .-_Z16calculatePaddingm
	.globl	_Z7padDataPhmm
	.type	_Z7padDataPhmm, @function
_Z7padDataPhmm:
.LFB3735:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	addq	%rsi, %rdi
.L4:
	cmpq	%rdx, %rax
	je	.L7
	movb	$97, (%rdi,%rax)
	incq	%rax
	jmp	.L4
.L7:
	ret
	.cfi_endproc
.LFE3735:
	.size	_Z7padDataPhmm, .-_Z7padDataPhmm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"rb"
	.text
	.globl	_Z8readFilePKcPmS1_
	.type	_Z8readFilePKcPmS1_, @function
_Z8readFilePKcPmS1_:
.LFB3736:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	leaq	.LC0(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	pushq	%rax
	.cfi_def_cfa_offset 64
	call	fopen@PLT
	xorl	%esi, %esi
	movl	$2, %edx
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	fseek@PLT
	movq	%rbx, %rdi
	call	ftell@PLT
	movl	$448, %ecx
	xorl	%edx, %edx
	movq	%rbx, %rdi
	movq	%rax, 0(%rbp)
	divq	%rcx
	subq	%rdx, %rcx
	movq	%rcx, (%r12)
	call	rewind@PLT
	movq	0(%rbp), %r15
	movq	(%r12), %r14
	addq	%r15, %r14
	movq	%r14, %rdi
	call	malloc@PLT
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%rbx, %r8
	movl	$1, %ecx
	movq	%rax, %rdi
	movq	%rax, %r13
	call	__fread_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	(%r12), %rdx
	movq	0(%rbp), %rsi
	movq	%r13, %rdi
	call	_Z7padDataPhmm
	popq	%rdx
	.cfi_def_cfa_offset 56
	movq	%r13, %rax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.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
	ret
	.cfi_endproc
.LFE3736:
	.size	_Z8readFilePKcPmS1_, .-_Z8readFilePKcPmS1_
	.globl	_Z16zeroLetterCountsPj
	.type	_Z16zeroLetterCountsPj, @function
_Z16zeroLetterCountsPj:
.LFB3737:
	.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
.LFE3737:
	.size	_Z16zeroLetterCountsPj, .-_Z16zeroLetterCountsPj
	.globl	_Z12countLettersPhPjS0_m
	.type	_Z12countLettersPhPjS0_m, @function
_Z12countLettersPhPjS0_m:
.LFB3738:
	.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
.LFE3738:
	.size	_Z12countLettersPhPjS0_m, .-_Z12countLettersPhPjS0_m
	.globl	_Z11unpadResultPjm
	.type	_Z11unpadResultPjm, @function
_Z11unpadResultPjm:
.LFB3739:
	.cfi_startproc
	endbr64
	subl	%esi, (%rdi)
	ret
	.cfi_endproc
.LFE3739:
	.size	_Z11unpadResultPjm, .-_Z11unpadResultPjm
	.globl	_Z12countWithCPUPhmPji
	.type	_Z12countWithCPUPhmPji, @function
_Z12countWithCPUPhmPji:
.LFB3744:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdx, %rbx
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	xorl	%r8d, %r8d
	movq	%rax, %rbp
.L16:
	cmpq	%r12, %r8
	je	.L19
	movzbl	0(%r13,%r8), %edi
	incq	%r8
	subl	%r14d, %edi
	movslq	%edi, %rdi
	incl	(%rbx,%rdi,4)
	jmp	.L16
.L19:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	popq	%rbx
	.cfi_def_cfa_offset 40
	subq	%rbp, %rax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3744:
	.size	_Z12countWithCPUPhmPji, .-_Z12countWithCPUPhmPji
	.section	.rodata.str1.1
.LC1:
	.string	"\n\n"
.LC2:
	.string	"Found %d %c's\n"
	.text
	.globl	_Z14displayResultsPj
	.type	_Z14displayResultsPj, @function
_Z14displayResultsPj:
.LFB3745:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%r12, %rsi
	movq	%rdi, %rbp
	movl	$2, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	$97, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
	call	__printf_chk@PLT
.L21:
	movl	-388(%rbp,%rbx,4), %edx
	movq	%rbx, %rcx
	movq	%r13, %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	incq	%rbx
	call	__printf_chk@PLT
	cmpq	$123, %rbx
	jne	.L21
	popq	%rdx
	.cfi_def_cfa_offset 40
	movq	%r12, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE3745:
	.size	_Z14displayResultsPj, .-_Z14displayResultsPj
	.section	.rodata.str1.1
.LC3:
	.string	"Took %dns to run processing on GPU with shared memory\n"
.LC4:
	.string	"Took %dns to run processing on GPU with global memory\n"
.LC5:
	.string	"Took %dns to run on CPU\n"
.LC6:
	.string	"\n"
.LC7:
	.string	"Shared Memory runs %fx faster than global memory\n"
.LC8:
	.string	"Shared Memory on GPU runs %fx faster than the CPU\n"
	.text
	.globl	_Z20displayTimingResultsmmm
	.type	_Z20displayTimingResultsmmm, @function
_Z20displayTimingResultsmmm:
.LFB3746:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	.LC6(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	leaq	.LC3(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdx, %rbx
	movq	%rdi, %rdx
	movl	$2, %edi
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	call	__printf_chk@PLT
	movq	%rbp, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%rbx, %rdx
	leaq	.LC5(%rip), %rsi
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movq	%r13, %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	testq	%r12, %r12
	js	.L25
	cvtsi2sdq	%r12, %xmm1
	jmp	.L26
.L25:
	movq	%r12, %rax
	andl	$1, %r12d
	shrq	%rax
	orq	%r12, %rax
	cvtsi2sdq	%rax, %xmm1
	addsd	%xmm1, %xmm1
.L26:
	testq	%rbp, %rbp
	js	.L27
	cvtsi2sdq	%rbp, %xmm0
	jmp	.L28
.L27:
	movq	%rbp, %rax
	andl	$1, %ebp
	shrq	%rax
	orq	%rbp, %rax
	cvtsi2sdq	%rax, %xmm0
	addsd	%xmm0, %xmm0
.L28:
	divsd	%xmm1, %xmm0
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movsd	%xmm1, 8(%rsp)
	call	__printf_chk@PLT
	testq	%rbx, %rbx
	movsd	8(%rsp), %xmm1
	js	.L29
	cvtsi2sdq	%rbx, %xmm0
	jmp	.L30
.L29:
	movq	%rbx, %rax
	andl	$1, %ebx
	shrq	%rax
	orq	%rbx, %rax
	cvtsi2sdq	%rax, %xmm0
	addsd	%xmm0, %xmm0
.L30:
	divsd	%xmm1, %xmm0
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 40
	movq	%r13, %rsi
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE3746:
	.size	_Z20displayTimingResultsmmm, .-_Z20displayTimingResultsmmm
	.globl	_Z32__device_stub__Z12shiftLettersPhPh
	.type	_Z32__device_stub__Z12shiftLettersPhPh, @function
_Z32__device_stub__Z12shiftLettersPhPh:
.LFB3772:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z12shiftLettersPh(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L32:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3772:
	.size	_Z32__device_stub__Z12shiftLettersPhPh, .-_Z32__device_stub__Z12shiftLettersPhPh
	.globl	_Z12shiftLettersPh
	.type	_Z12shiftLettersPh, @function
_Z12shiftLettersPh:
.LFB3773:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z12shiftLettersPhPh
	.cfi_endproc
.LFE3773:
	.size	_Z12shiftLettersPh, .-_Z12shiftLettersPh
	.globl	_Z41__device_stub__Z18countLettersSharedPhPjmPhPjm
	.type	_Z41__device_stub__Z18countLettersSharedPhPjmPhPjm, @function
_Z41__device_stub__Z18countLettersSharedPhPjmPhPjm:
.LFB3774:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z18countLettersSharedPhPjm(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L37:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3774:
	.size	_Z41__device_stub__Z18countLettersSharedPhPjmPhPjm, .-_Z41__device_stub__Z18countLettersSharedPhPjmPhPjm
	.globl	_Z18countLettersSharedPhPjm
	.type	_Z18countLettersSharedPhPjm, @function
_Z18countLettersSharedPhPjm:
.LFB3775:
	.cfi_startproc
	endbr64
	jmp	_Z41__device_stub__Z18countLettersSharedPhPjmPhPjm
	.cfi_endproc
.LFE3775:
	.size	_Z18countLettersSharedPhPjm, .-_Z18countLettersSharedPhPjm
	.globl	_Z18countWithGPUSharedPhmPjm
	.type	_Z18countWithGPUSharedPhmPjm, @function
_Z18countWithGPUSharedPhmPjm:
.LFB3740:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rcx, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rdi
	call	cudaMalloc@PLT
	movq	(%rsp), %rdi
	movq	%r12, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	8(%rsp), %rdi
	movl	$104, %esi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$104, %edx
	call	cudaMemcpy@PLT
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	%ebx, 16(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, %r12
	movl	$67108871, %edx
	movabsq	$4294967297, %rax
	movl	$1, %ecx
	movq	%rax, 20(%rsp)
	movl	24(%rsp), %esi
	salq	$6, %rdx
	movq	16(%rsp), %rdi
	movq	%rdx, 28(%rsp)
	movl	$1, 36(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L43
	movq	(%rsp), %rdi
	call	_Z32__device_stub__Z12shiftLettersPhPh
.L43:
	movl	$67108871, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	salq	$6, %rdx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	$1, 36(%rsp)
	movq	%rdx, 28(%rsp)
	movq	%rdi, 16(%rsp)
	movl	$1, 24(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L44
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movq	%rbx, %rdx
	call	_Z41__device_stub__Z18countLettersSharedPhPjmPhPjm
.L44:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	movl	$104, %edx
	movq	%rax, %rbx
	call	cudaMemcpy@PLT
	movq	(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rax
	subq	%r12, %rax
	movq	40(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L45
	call	__stack_chk_fail@PLT
.L45:
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3740:
	.size	_Z18countWithGPUSharedPhmPjm, .-_Z18countWithGPUSharedPhmPjm
	.globl	_Z44__device_stub__Z18countLettersGlobalPhPjS0_mPhPjS0_m
	.type	_Z44__device_stub__Z18countLettersGlobalPhPjS0_mPhPjS0_m, @function
_Z44__device_stub__Z18countLettersGlobalPhPjS0_mPhPjS0_m:
.LFB3776:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z18countLettersGlobalPhPjS0_m(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L47:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L49
	call	__stack_chk_fail@PLT
.L49:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3776:
	.size	_Z44__device_stub__Z18countLettersGlobalPhPjS0_mPhPjS0_m, .-_Z44__device_stub__Z18countLettersGlobalPhPjS0_mPhPjS0_m
	.globl	_Z18countLettersGlobalPhPjS0_m
	.type	_Z18countLettersGlobalPhPjS0_m, @function
_Z18countLettersGlobalPhPjS0_m:
.LFB3777:
	.cfi_startproc
	endbr64
	jmp	_Z44__device_stub__Z18countLettersGlobalPhPjS0_mPhPjS0_m
	.cfi_endproc
.LFE3777:
	.size	_Z18countLettersGlobalPhPjS0_m, .-_Z18countLettersGlobalPhPjS0_m
	.globl	_Z18countWithGPUGlobalPhmPjm
	.type	_Z18countWithGPUGlobalPhmPjm, @function
_Z18countWithGPUGlobalPhmPjm:
.LFB3743:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rcx, %rbx
	subq	$72, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	movq	%r12, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	16(%rsp), %rdi
	movl	$104, %esi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$104, %edx
	call	cudaMemcpy@PLT
	leaq	24(%rsp), %rdi
	movl	$11648, %esi
	call	cudaMalloc@PLT
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movl	%ebx, 32(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, %r12
	movl	$67108871, %edx
	movabsq	$4294967297, %rax
	movl	$1, %ecx
	movq	%rax, 36(%rsp)
	movl	40(%rsp), %esi
	salq	$6, %rdx
	movq	32(%rsp), %rdi
	movq	%rdx, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L53
	movq	8(%rsp), %rdi
	call	_Z32__device_stub__Z12shiftLettersPhPh
.L53:
	movl	$67108871, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	salq	$6, %rdx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	$1, 52(%rsp)
	movq	%rdx, 44(%rsp)
	movq	%rdi, 32(%rsp)
	movl	$1, 40(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L54
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%rbx, %rcx
	movq	8(%rsp), %rdi
	call	_Z44__device_stub__Z18countLettersGlobalPhPjS0_mPhPjS0_m
.L54:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	movl	$104, %edx
	movq	%rax, %rbx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rax
	subq	%r12, %rax
	movq	56(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L55
	call	__stack_chk_fail@PLT
.L55:
	addq	$72, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3743:
	.size	_Z18countWithGPUGlobalPhmPjm, .-_Z18countWithGPUGlobalPhmPjm
	.section	.rodata.str1.1
.LC9:
	.string	"all_letter.shakespeare.txt"
.LC10:
	.string	"Bytes read: %d\n"
.LC11:
	.string	"Padding bytes: %d\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3747:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3747
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%edx, %edx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$200, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	48(%rsp), %r12
	leaq	40(%rsp), %r13
	movq	$26, 40(%rsp)
	leaq	64(%rsp), %rax
	movq	%r13, %rsi
	movq	%r12, %rdi
	movq	%rax, 48(%rsp)
.LEHB0:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT
.LEHE0:
	leaq	26+.LC9(%rip), %rdx
	movq	%rax, 48(%rsp)
	movq	%rax, %rdi
	movq	40(%rsp), %rax
	leaq	-26(%rdx), %rsi
	movq	%rax, 64(%rsp)
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	40(%rsp), %rax
	movq	48(%rsp), %rdx
	decl	%ebp
	movq	%rax, 56(%rsp)
	movb	$0, (%rdx,%rax)
	jg	.L58
.L60:
	leaq	20(%rsp), %rsi
	movl	$1, %r8d
	xorl	%ecx, %ecx
	movl	$1, %edx
	leaq	_ZL11shiftAmount(%rip), %rdi
	movl	$97, 20(%rsp)
.LEHB1:
	call	cudaMemcpyToSymbol@PLT
	jmp	.L68
.L58:
	movq	8(%rbx), %rbx
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	56(%rsp), %rdx
	movq	%rbx, %rcx
	xorl	%esi, %esi
	movq	%rax, %r8
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm@PLT
	jmp	.L60
.L68:
	movq	48(%rsp), %rdi
	leaq	32(%rsp), %rdx
	leaq	24(%rsp), %rsi
	call	_Z8readFilePKcPmS1_
	movq	24(%rsp), %rcx
	movq	32(%rsp), %r15
	movq	%rax, %rbx
	xorl	%edx, %edx
	movl	$448, %esi
	movl	$2, %edi
	leaq	(%rcx,%r15), %rbp
	movq	%rbp, %rax
	divq	%rsi
	movq	%rcx, %rdx
	leaq	.LC10(%rip), %rsi
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r15, %rdx
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rsi
	movq	%r13, %rdi
	call	cudaMallocHost@PLT
	movq	40(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rbp, %rcx
	leaq	80(%rsp), %rbx
	rep movsb
	xorl	%r13d, %r13d
	movl	$26, %ecx
	movq	%rbx, %rdi
	movl	%r13d, %eax
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	rep stosl
	movq	40(%rsp), %rdi
	movl	$97, %ecx
	call	_Z12countWithCPUPhmPji
	movl	$26, %ecx
	movq	%rbx, %rdi
	movq	%rbx, %rdx
	movq	%rax, %r14
	movl	%r13d, %eax
	movq	%rbp, %rsi
	rep stosl
	movq	8(%rsp), %rcx
	movq	40(%rsp), %rdi
	call	_Z18countWithGPUGlobalPhmPjm
	movq	%rax, %r13
	movl	$26, %ecx
	xorl	%eax, %eax
	movq	%rbx, %rdi
	rep stosl
	movq	8(%rsp), %rcx
	movq	40(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	call	_Z18countWithGPUSharedPhmPjm
	movq	%rbx, %rdi
	subl	%r15d, 80(%rsp)
	movq	%rax, %rbp
	call	_Z14displayResultsPj
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%rbp, %rdi
	call	_Z20displayTimingResultsmmm
.LEHE1:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L63
	jmp	.L66
.L64:
	endbr64
	movq	%rax, %rbx
.L61:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L66
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L66:
	call	__stack_chk_fail@PLT
.L63:
	addq	$200, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.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
	ret
	.cfi_endproc
.LFE3747:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3747:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3747-.LLSDACSB3747
.LLSDACSB3747:
	.uleb128 .LEHB0-.LFB3747
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3747
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L64-.LFB3747
	.uleb128 0
	.uleb128 .LEHB2-.LFB3747
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE3747:
	.section	.text.startup
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z18countLettersGlobalPhPjS0_m"
.LC13:
	.string	"_Z18countLettersSharedPhPjm"
.LC14:
	.string	"_Z12shiftLettersPh"
.LC15:
	.string	"shiftAmount"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3779:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z18countLettersGlobalPhPjS0_m(%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	.LC13(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z18countLettersSharedPhPjm(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC14(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12shiftLettersPh(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC15(%rip), %rdx
	movl	$4, %r9d
	leaq	_ZL11shiftAmount(%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
.LFE3779:
	.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
	.local	_ZL11shiftAmount
	.comm	_ZL11shiftAmount,4,4
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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:

// DESCRIPTION HERE

#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <chrono>

#define NUM_THREADS 448
#define NUM_CHARS 26
#define SHARED_MEM_SIZE NUM_THREADS * NUM_CHARS

// Calculate how much padding is needed to make the file evenly divided into 448 chunks
size_t calculatePadding(size_t fileSize)
{
	size_t paddingBytes = NUM_THREADS - (fileSize % NUM_THREADS);
	return paddingBytes;
}

// Pad the data so it is evenly divided into 448 chunks
void padData(uint8_t * buf, size_t bytesRead, size_t numPadBytes)
{
    for (size_t i = 0; i < numPadBytes; i++)
    {
        buf[bytesRead + i] = 'a';
    }
}

// Read a file into a byte array
uint8_t * readFile(const char * filename, size_t * outBytesRead, size_t * paddingBytes)
{
	FILE *handle = fopen(filename, "rb");
	fseek(handle, 0, SEEK_END);
	*outBytesRead = ftell(handle);
	*paddingBytes = calculatePadding(*outBytesRead);
	rewind(handle);

	uint8_t * buf = (uint8_t *) malloc((*outBytesRead + *paddingBytes)*sizeof(uint8_t));
	fread(buf, *outBytesRead, 1, handle);
	fclose(handle);

    padData(buf, *outBytesRead, *paddingBytes);

	return buf;
}

// Shift all ascii letters so that 'a' is index 0, 'b' is index 1, etc.
__device__ __constant__ int shiftAmount;
__global__ void shiftLetters(uint8_t *data)
{
    uint32_t threadId = blockIdx.x * blockDim.x + threadIdx.x;
    data[threadId] = data[threadId] - shiftAmount;
}

// Zero out the letter counts
__device__ void zeroLetterCounts(uint32_t * letterCounts)
{
    for (size_t i = 0; i < NUM_CHARS; i++) {
        letterCounts[(threadIdx.x * NUM_CHARS) + i] = 0;
    }
}

// Count the occurence of each letter in *data
__device__ void countLetters(uint8_t *data, uint32_t *letterCounts, uint32_t *threadLetterCounts, size_t chunkSize)
{

    zeroLetterCounts(threadLetterCounts);
    __syncthreads();

    // Tally letters for each thread
    for (size_t i = 0; i < chunkSize; i++)
    {
        threadLetterCounts[(threadIdx.x * NUM_CHARS) + data[(threadIdx.x * chunkSize) + i]]++;
    }

    __syncthreads();

    // Total local thread tallys
    if (threadIdx.x < NUM_CHARS)
    {
        for (size_t i = 0; i < NUM_THREADS; i++)
        {
            letterCounts[threadIdx.x] += threadLetterCounts[threadIdx.x + (i * NUM_CHARS)]; 
        }
    }
}

// Count the occurence of each letter in *data using shared memory
__global__ void countLettersShared(uint8_t *data, uint32_t *letterCounts, size_t chunkSize)
{
    __shared__ uint32_t sharedLetterCounts[SHARED_MEM_SIZE];
    countLetters(data, letterCounts, sharedLetterCounts, chunkSize);
}

// Count the occurence of each letter in *data using global memory
__global__ void countLettersGlobal(uint8_t *data, uint32_t *letterCounts, uint32_t * threadLetterCounts, size_t chunkSize)
{
    countLetters(data, letterCounts, threadLetterCounts, chunkSize);
}

// Remove any padding so that letter counts are accurage
void unpadResult(uint32_t * letterCounts, size_t paddingBytes)
{
    letterCounts[0] -= paddingBytes;
}

// Count the occurence of each letter in *data using shared memory
uint64_t countWithGPUShared(uint8_t * data, size_t dataSize, uint32_t * letterCounts, size_t textChunkSize)
{
    // Declare cuda memory
	uint8_t *gpuData;
    uint32_t *gpuLetterCounts;
	hipMalloc((void **)&gpuData, dataSize);
	hipMemcpy(gpuData, data, dataSize, hipMemcpyHostToDevice);

	hipMalloc((void **)&gpuLetterCounts, NUM_CHARS * sizeof(uint32_t));
	hipMemcpy(gpuLetterCounts, letterCounts, NUM_CHARS * sizeof(uint32_t), hipMemcpyHostToDevice);

    // Run Kernel
    auto start = std::chrono::high_resolution_clock::now();
    shiftLetters<<<textChunkSize, NUM_THREADS>>>(gpuData);
    countLettersShared<<<1, NUM_THREADS>>>(gpuData, gpuLetterCounts, textChunkSize);
    auto stop = std::chrono::high_resolution_clock::now();

	hipMemcpy(letterCounts, gpuLetterCounts, NUM_CHARS * sizeof(uint32_t), hipMemcpyDeviceToHost);

	// Free the arrays on the GPU as now we're done with them
	hipFree(gpuData);
	hipFree(gpuLetterCounts);

    return std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
}

// Count the occurence of each letter in *data using global memory
uint64_t countWithGPUGlobal(uint8_t * data, size_t dataSize, uint32_t * letterCounts, size_t textChunkSize)
{
    // Declare cuda memory
	uint8_t *gpuData;
    uint32_t *gpuLetterCounts;
    uint32_t *threadLetterCounts;
	hipMalloc((void **)&gpuData, dataSize);
	hipMemcpy(gpuData, data, dataSize, hipMemcpyHostToDevice);

	hipMalloc((void **)&gpuLetterCounts, NUM_CHARS * sizeof(uint32_t));
	hipMemcpy(gpuLetterCounts, letterCounts, NUM_CHARS * sizeof(uint32_t), hipMemcpyHostToDevice);

	hipMalloc((void **)&threadLetterCounts, SHARED_MEM_SIZE);

    // Run Kernel
    auto start = std::chrono::high_resolution_clock::now();
    shiftLetters<<<textChunkSize, NUM_THREADS>>>(gpuData);
    countLettersGlobal<<<1, NUM_THREADS>>>(gpuData, gpuLetterCounts, threadLetterCounts, textChunkSize);
    auto stop = std::chrono::high_resolution_clock::now();

	hipMemcpy(letterCounts, gpuLetterCounts, NUM_CHARS * sizeof(uint32_t), hipMemcpyDeviceToHost);

	/* Free the arrays on the GPU as now we're done with them */
	hipFree(gpuData);
	hipFree(gpuLetterCounts);

    return std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
}

// Use the CPU to count the occurrences of each letter in *data
uint64_t countWithCPU(uint8_t * data, size_t dataSize, uint32_t * letterCounts, int ascii_a)
{
    auto start = std::chrono::high_resolution_clock::now();
    for (size_t i = 0; i < dataSize; i++)
    {
        letterCounts[data[i] - ascii_a]++;
    }
    auto stop = std::chrono::high_resolution_clock::now();

    return std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
}

// Display letter counts
void displayResults(uint32_t * letterCounts)
{
    printf("\n\n");
    for (size_t i = 0; i < NUM_CHARS; i++)
    {
        printf("Found %d %c's\n", letterCounts[i], i + 0x61);
    }

    printf("\n\n");
}

// Display and analyze the run times (shared vs. global vs. CPU)
void displayTimingResults(uint64_t gpuSharedDuration, uint64_t gpuGlobalDuration, uint64_t cpuDuration)
{
    printf("Took %dns to run processing on GPU with shared memory\n", gpuSharedDuration);
    printf("Took %dns to run processing on GPU with global memory\n", gpuGlobalDuration);
    printf("Took %dns to run on CPU\n", cpuDuration);

    printf("\n");
    printf("Shared Memory runs %fx faster than global memory\n", ((double)gpuGlobalDuration) / gpuSharedDuration);
    printf("Shared Memory on GPU runs %fx faster than the CPU\n", ((double)cpuDuration) / gpuSharedDuration);
    printf("\n");
}

int main(int argc, char* argv[])
{
    // Read command line args
	std::string fileName = "all_letter.shakespeare.txt";
	if (argc > 1) {
		fileName = argv[1];
	}

    // Copy from host to constant memory
    const int ascii_a = 0x61;
    hipMemcpyToSymbol(HIP_SYMBOL(shiftAmount), &ascii_a, sizeof(uint8_t));

    // Declare some variables
    uint32_t letterCounts[NUM_CHARS];
	size_t bytesRead;
	size_t paddingBytes;
    
    // Read file
	uint8_t * data = readFile(fileName.c_str(), &bytesRead, &paddingBytes);

    // Calculate run-time parameters
	size_t dataSize = bytesRead + paddingBytes;
    size_t textChunkSize = dataSize / NUM_THREADS;
	printf("Bytes read: %d\n", bytesRead);
	printf("Padding bytes: %d\n", paddingBytes);

    uint8_t *pinnedData;
    hipHostMalloc((void**)&pinnedData, dataSize, hipHostMallocDefault);
    memcpy(pinnedData, data, dataSize);

    // Run letter counter on the CPU
    memset(letterCounts, 0, NUM_CHARS * sizeof(uint32_t));
    uint64_t cpuDuration = countWithCPU(pinnedData, dataSize, letterCounts, ascii_a);

    // Run letter counter on the GPU with global memory
    memset(letterCounts, 0, NUM_CHARS * sizeof(uint32_t));
    uint64_t gpuGlobalDuration = countWithGPUGlobal(pinnedData, dataSize, letterCounts, textChunkSize);

    // Run letter counter on the GPU with shared memory
    memset(letterCounts, 0, NUM_CHARS * sizeof(uint32_t));
    uint64_t gpuSharedDuration = countWithGPUShared(pinnedData, dataSize, letterCounts, textChunkSize);
    unpadResult(letterCounts, paddingBytes);

    // Display letter counts and timing
    displayResults(letterCounts);
    displayTimingResults(gpuSharedDuration, gpuGlobalDuration, cpuDuration);

	return EXIT_SUCCESS;
}

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

                                        # End of file scope inline assembly
	.globl	_Z16calculatePaddingm           # -- Begin function _Z16calculatePaddingm
	.type	_Z16calculatePaddingm,@function
_Z16calculatePaddingm:                  # @_Z16calculatePaddingm
	.cfi_startproc
# %bb.0:
	movq	%rdi, %rax
	shrq	$6, %rax
	movabsq	$2635249153387078803, %rcx      # imm = 0x2492492492492493
	mulq	%rcx
	imulq	$448, %rdx, %rax                # imm = 0x1C0
	subq	%rdi, %rax
	addq	$448, %rax                      # imm = 0x1C0
	retq
.Lfunc_end0:
	.size	_Z16calculatePaddingm, .Lfunc_end0-_Z16calculatePaddingm
	.cfi_endproc
                                        # -- End function
	.globl	_Z7padDataPhmm                  # -- Begin function _Z7padDataPhmm
	.type	_Z7padDataPhmm,@function
_Z7padDataPhmm:                         # @_Z7padDataPhmm
	.cfi_startproc
# %bb.0:
	testq	%rdx, %rdx
	je	.LBB1_1
# %bb.2:                                # %.lr.ph.preheader
	addq	%rsi, %rdi
	movl	$97, %esi
	jmp	memset@PLT                      # TAILCALL
.LBB1_1:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z7padDataPhmm, .Lfunc_end1-_Z7padDataPhmm
	.cfi_endproc
                                        # -- End function
	.globl	_Z8readFilePKcPmS1_             # -- Begin function _Z8readFilePKcPmS1_
	.type	_Z8readFilePKcPmS1_,@function
_Z8readFilePKcPmS1_:                    # @_Z8readFilePKcPmS1_
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rsi, %rbx
	movl	$.L.str, %esi
	callq	fopen
	movq	%rax, %r15
	movq	%rax, %rdi
	xorl	%esi, %esi
	movl	$2, %edx
	callq	fseek
	movq	%r15, %rdi
	callq	ftell
	movq	%rax, %rcx
	movq	%rax, (%rbx)
	shrq	$6, %rax
	movabsq	$2635249153387078803, %rdx      # imm = 0x2492492492492493
	mulq	%rdx
	imulq	$448, %rdx, %rax                # imm = 0x1C0
	subq	%rcx, %rax
	addq	$448, %rax                      # imm = 0x1C0
	movq	%rax, (%r14)
	movq	%r15, %rdi
	callq	rewind
	movq	(%rbx), %r13
	movq	(%r14), %rdi
	addq	%r13, %rdi
	callq	malloc
	movq	%rax, %r12
	movl	$1, %edx
	movq	%rax, %rdi
	movq	%r13, %rsi
	movq	%r15, %rcx
	callq	fread
	movq	%r15, %rdi
	callq	fclose
	movq	(%r14), %rdx
	testq	%rdx, %rdx
	je	.LBB2_2
# %bb.1:                                # %.lr.ph.preheader.i
	movq	(%rbx), %rdi
	addq	%r12, %rdi
	movl	$97, %esi
	callq	memset@PLT
.LBB2_2:                                # %_Z7padDataPhmm.exit
	movq	%r12, %rax
	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_end2:
	.size	_Z8readFilePKcPmS1_, .Lfunc_end2-_Z8readFilePKcPmS1_
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__shiftLettersPh # -- Begin function _Z27__device_stub__shiftLettersPh
	.type	_Z27__device_stub__shiftLettersPh,@function
_Z27__device_stub__shiftLettersPh:      # @_Z27__device_stub__shiftLettersPh
	.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	$64, %rsp
	.cfi_def_cfa_offset 112
	.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)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z12shiftLettersPh, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z27__device_stub__shiftLettersPh, .Lfunc_end3-_Z27__device_stub__shiftLettersPh
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__countLettersSharedPhPjm # -- Begin function _Z33__device_stub__countLettersSharedPhPjm
	.type	_Z33__device_stub__countLettersSharedPhPjm,@function
_Z33__device_stub__countLettersSharedPhPjm: # @_Z33__device_stub__countLettersSharedPhPjm
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z18countLettersSharedPhPjm, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z33__device_stub__countLettersSharedPhPjm, .Lfunc_end4-_Z33__device_stub__countLettersSharedPhPjm
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__countLettersGlobalPhPjS0_m # -- Begin function _Z33__device_stub__countLettersGlobalPhPjS0_m
	.type	_Z33__device_stub__countLettersGlobalPhPjS0_m,@function
_Z33__device_stub__countLettersGlobalPhPjS0_m: # @_Z33__device_stub__countLettersGlobalPhPjS0_m
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z18countLettersGlobalPhPjS0_m, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z33__device_stub__countLettersGlobalPhPjS0_m, .Lfunc_end5-_Z33__device_stub__countLettersGlobalPhPjS0_m
	.cfi_endproc
                                        # -- End function
	.globl	_Z11unpadResultPjm              # -- Begin function _Z11unpadResultPjm
	.type	_Z11unpadResultPjm,@function
_Z11unpadResultPjm:                     # @_Z11unpadResultPjm
	.cfi_startproc
# %bb.0:
	subl	%esi, (%rdi)
	retq
.Lfunc_end6:
	.size	_Z11unpadResultPjm, .Lfunc_end6-_Z11unpadResultPjm
	.cfi_endproc
                                        # -- End function
	.globl	_Z18countWithGPUSharedPhmPjm    # -- Begin function _Z18countWithGPUSharedPhmPjm
	.type	_Z18countWithGPUSharedPhmPjm,@function
_Z18countWithGPUSharedPhmPjm:           # @_Z18countWithGPUSharedPhmPjm
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, %r14
	movq	%rdx, %rbx
	movq	%rsi, %r15
	movq	%rdi, %r13
	movabsq	$4294967744, %r12               # imm = 0x1000001C0
	leaq	16(%rsp), %rbp
	movq	%rbp, %rdi
	callq	hipMalloc
	movq	(%rbp), %rdi
	movq	%r13, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	8(%rsp), %r15
	movl	$104, %esi
	movq	%r15, %rdi
	callq	hipMalloc
	movq	(%r15), %rdi
	movl	$104, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r15
	movl	%r14d, %eax
	leaq	(%rax,%r12), %rdi
	addq	$-448, %rdi                     # imm = 0xFE40
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_2
# %bb.1:
	movq	16(%rsp), %rdi
	callq	_Z27__device_stub__shiftLettersPh
.LBB7_2:
	leaq	-447(%r12), %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_4
# %bb.3:
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	%r14, %rdx
	callq	_Z33__device_stub__countLettersSharedPhPjm
.LBB7_4:
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r14
	movq	8(%rsp), %rsi
	movl	$104, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	subq	%r15, %r14
	movq	%r14, %rax
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	_Z18countWithGPUSharedPhmPjm, .Lfunc_end7-_Z18countWithGPUSharedPhmPjm
	.cfi_endproc
                                        # -- End function
	.globl	_Z18countWithGPUGlobalPhmPjm    # -- Begin function _Z18countWithGPUGlobalPhmPjm
	.type	_Z18countWithGPUGlobalPhmPjm,@function
_Z18countWithGPUGlobalPhmPjm:           # @_Z18countWithGPUGlobalPhmPjm
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, %r14
	movq	%rdx, %rbx
	movq	%rsi, %r15
	movq	%rdi, %r13
	movabsq	$4294967744, %r12               # imm = 0x1000001C0
	leaq	8(%rsp), %rbp
	movq	%rbp, %rdi
	callq	hipMalloc
	movq	(%rbp), %rdi
	movq	%r13, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rsp, %r15
	movl	$104, %esi
	movq	%r15, %rdi
	callq	hipMalloc
	movq	(%r15), %rdi
	movl	$104, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rdi
	movl	$11648, %esi                    # imm = 0x2D80
	callq	hipMalloc
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r15
	movl	%r14d, %eax
	leaq	(%rax,%r12), %rdi
	addq	$-448, %rdi                     # imm = 0xFE40
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_2
# %bb.1:
	movq	8(%rsp), %rdi
	callq	_Z27__device_stub__shiftLettersPh
.LBB8_2:
	leaq	-447(%r12), %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB8_4
# %bb.3:
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	%r14, %rcx
	callq	_Z33__device_stub__countLettersGlobalPhPjS0_m
.LBB8_4:
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r14
	movq	(%rsp), %rsi
	movl	$104, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	subq	%r15, %r14
	movq	%r14, %rax
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z18countWithGPUGlobalPhmPjm, .Lfunc_end8-_Z18countWithGPUGlobalPhmPjm
	.cfi_endproc
                                        # -- End function
	.globl	_Z12countWithCPUPhmPji          # -- Begin function _Z12countWithCPUPhmPji
	.type	_Z12countWithCPUPhmPji,@function
_Z12countWithCPUPhmPji:                 # @_Z12countWithCPUPhmPji
	.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, %ebp
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %r12
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %rbx
	testq	%r15, %r15
	je	.LBB9_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
	movslq	%ebp, %rcx
.LBB9_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movzbl	(%r12,%rax), %edx
	subq	%rcx, %rdx
	incl	(%r14,%rdx,4)
	incq	%rax
	cmpq	%rax, %r15
	jne	.LBB9_2
.LBB9_3:                                # %._crit_edge
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%rbx, %rax
	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
	retq
.Lfunc_end9:
	.size	_Z12countWithCPUPhmPji, .Lfunc_end9-_Z12countWithCPUPhmPji
	.cfi_endproc
                                        # -- End function
	.globl	_Z14displayResultsPj            # -- Begin function _Z14displayResultsPj
	.type	_Z14displayResultsPj,@function
_Z14displayResultsPj:                   # @_Z14displayResultsPj
	.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
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$97, %r14d
.LBB10_1:                               # =>This Inner Loop Header: Depth=1
	movl	-388(%rbx,%r14,4), %esi
	movl	$.L.str.2, %edi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	printf
	incq	%r14
	cmpq	$123, %r14
	jne	.LBB10_1
# %bb.2:
	movl	$.Lstr.1, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end10:
	.size	_Z14displayResultsPj, .Lfunc_end10-_Z14displayResultsPj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z20displayTimingResultsmmm
.LCPI11_0:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI11_1:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.text
	.globl	_Z20displayTimingResultsmmm
	.type	_Z20displayTimingResultsmmm,@function
_Z20displayTimingResultsmmm:            # @_Z20displayTimingResultsmmm
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %rbx
	movq	%rsi, %r15
	movq	%rdi, %r14
	movl	$.L.str.3, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.4, %edi
	movq	%r15, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.5, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$10, %edi
	callq	putchar@PLT
	movq	%r15, %xmm1
	movdqa	.LCPI11_0(%rip), %xmm2          # xmm2 = [1127219200,1160773632,0,0]
	punpckldq	%xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
	movapd	.LCPI11_1(%rip), %xmm3          # xmm3 = [4.503599627370496E+15,1.9342813113834067E+25]
	subpd	%xmm3, %xmm1
	movapd	%xmm1, %xmm0
	unpckhpd	%xmm1, %xmm0                    # xmm0 = xmm0[1],xmm1[1]
	addsd	%xmm1, %xmm0
	movq	%r14, %xmm1
	punpckldq	%xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
	subpd	%xmm3, %xmm1
	movapd	%xmm1, %xmm2
	unpckhpd	%xmm1, %xmm2                    # xmm2 = xmm2[1],xmm1[1]
	addsd	%xmm1, %xmm2
	movapd	%xmm2, (%rsp)                   # 16-byte Spill
	divsd	%xmm2, %xmm0
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	movq	%rbx, %xmm1
	punpckldq	.LCPI11_0(%rip), %xmm1  # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
	subpd	.LCPI11_1(%rip), %xmm1
	movapd	%xmm1, %xmm0
	unpckhpd	%xmm1, %xmm0                    # xmm0 = xmm0[1],xmm1[1]
	addsd	%xmm1, %xmm0
	divsd	(%rsp), %xmm0                   # 16-byte Folded Reload
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	movl	$10, %edi
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end11:
	.size	_Z20displayTimingResultsmmm, .Lfunc_end11-_Z20displayTimingResultsmmm
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.exit
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	leaq	24(%rsp), %rax
	movq	%rax, -16(%rax)
	leaq	8(%rsp), %rdi
	movl	$.L.str.9, %esi
	movl	$.L.str.9+26, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	cmpl	$2, %ebp
	jl	.LBB12_2
# %bb.1:
	movq	8(%rbx), %rbx
	leaq	8(%rsp), %r14
	movq	8(%r14), %r15
	movq	%rbx, %rdi
	callq	strlen
.Ltmp0:
	movq	%r14, %rdi
	xorl	%esi, %esi
	movq	%r15, %rdx
	movq	%rbx, %rcx
	movq	%rax, %r8
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm
.Ltmp1:
.LBB12_2:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc.exit
	leaq	44(%rsp), %rsi
	movl	$97, (%rsi)
.Ltmp3:
	movl	$shiftAmount, %edi
	movl	$1, %edx
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
.Ltmp4:
# %bb.3:                                # %_Z17hipMemcpyToSymbolIiE10hipError_tRKT_PKvmm13hipMemcpyKind.exit
	movq	8(%rsp), %rdi
	leaq	56(%rsp), %rbx
	leaq	48(%rsp), %r14
	movq	%rbx, %rsi
	movq	%r14, %rdx
	callq	_Z8readFilePKcPmS1_
	movq	%rax, %r12
	movq	(%rbx), %rsi
	movq	(%r14), %rbx
	leaq	(%rbx,%rsi), %r14
	movq	%r14, %rax
	shrq	$6, %rax
	movabsq	$2635249153387078803, %rcx      # imm = 0x2492492492492493
	mulq	%rcx
	movq	%rdx, %r15
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.11, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
.Ltmp6:
	movq	%rsp, %rdi
	movq	%r14, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
.Ltmp7:
# %bb.4:
	movq	(%rsp), %rdi
	movq	%r12, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
	xorps	%xmm0, %xmm0
	leaq	64(%rsp), %r13
	movaps	%xmm0, (%r13)
	movaps	%xmm0, 16(%r13)
	movaps	%xmm0, 32(%r13)
	movaps	%xmm0, 48(%r13)
	movaps	%xmm0, 64(%r13)
	movaps	%xmm0, 80(%r13)
	xorl	%ebp, %ebp
	movq	%rbp, 96(%r13)
	movq	(%rsp), %rdi
	movq	%r14, %rsi
	movq	%r13, %rdx
	movl	$97, %ecx
	callq	_Z12countWithCPUPhmPji
	movq	%rax, %r12
	xorps	%xmm0, %xmm0
	movaps	%xmm0, (%r13)
	movaps	%xmm0, 16(%r13)
	movaps	%xmm0, 32(%r13)
	movaps	%xmm0, 48(%r13)
	movaps	%xmm0, 64(%r13)
	movaps	%xmm0, 80(%r13)
	movq	%rbp, 96(%r13)
	movq	(%rsp), %rdi
.Ltmp9:
	movq	%r14, %rsi
	movq	%r13, %rdx
	movq	%r15, %rcx
	callq	_Z18countWithGPUGlobalPhmPjm
.Ltmp10:
# %bb.5:
	movq	%rax, %r13
	leaq	64(%rsp), %rdx
	xorps	%xmm0, %xmm0
	movaps	%xmm0, 80(%rdx)
	movaps	%xmm0, 64(%rdx)
	movaps	%xmm0, 48(%rdx)
	movaps	%xmm0, 32(%rdx)
	movaps	%xmm0, 16(%rdx)
	movaps	%xmm0, (%rdx)
	movq	$0, 96(%rdx)
	movq	(%rsp), %rdi
.Ltmp12:
	movq	%r14, %rsi
	movq	%r15, %rcx
	callq	_Z18countWithGPUSharedPhmPjm
.Ltmp13:
# %bb.6:
	movq	%rax, %r14
	leaq	64(%rsp), %rdi
	subl	%ebx, (%rdi)
	callq	_Z14displayResultsPj
	movq	%r14, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	callq	_Z20displayTimingResultsmmm
	movq	8(%rsp), %rdi
	leaq	24(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB12_8
# %bb.7:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
	callq	_ZdlPv
.LBB12_8:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
	xorl	%eax, %eax
	addq	$168, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB12_16:
	.cfi_def_cfa_offset 224
.Ltmp2:
	jmp	.LBB12_13
.LBB12_12:
.Ltmp14:
	jmp	.LBB12_13
.LBB12_11:
.Ltmp11:
	jmp	.LBB12_13
.LBB12_10:
.Ltmp8:
	jmp	.LBB12_13
.LBB12_9:
.Ltmp5:
.LBB12_13:
	movq	%rax, %rbx
	movq	8(%rsp), %rdi
	leaq	24(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB12_15
# %bb.14:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i30
	callq	_ZdlPv
.LBB12_15:                              # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit32
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end12:
	.size	main, .Lfunc_end12-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table12:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp7-.Lfunc_begin0           # >> Call Site 5 <<
	.uleb128 .Ltmp9-.Ltmp7                  #   Call between .Ltmp7 and .Ltmp9
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 6 <<
	.uleb128 .Ltmp10-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp10
	.uleb128 .Ltmp11-.Lfunc_begin0          #     jumps to .Ltmp11
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp12-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp13-.Ltmp12                #   Call between .Ltmp12 and .Ltmp13
	.uleb128 .Ltmp14-.Lfunc_begin0          #     jumps to .Ltmp14
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp13-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Lfunc_end12-.Ltmp13           #   Call between .Ltmp13 and .Lfunc_end12
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.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
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbx
	subq	%rsi, %r14
	movq	%r14, (%rsp)
	cmpq	$15, %r14
	jbe	.LBB13_1
# %bb.2:
	movq	%rsp, %r12
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm
	movq	%rax, (%rbx)
	movq	(%r12), %rcx
	movq	%rcx, 16(%rbx)
	jmp	.LBB13_3
.LBB13_1:                               # %._crit_edge
	movq	(%rbx), %rax
.LBB13_3:
	testq	%r14, %r14
	je	.LBB13_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB13_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB13_7
.LBB13_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB13_7:                               # %_ZZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tagEN6_GuardD2Ev.exit
	movq	(%rsp), %rax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rcx
	movb	$0, (%rcx,%rax)
	addq	$8, %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_end13:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag, .Lfunc_end13-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_endproc
                                        # -- End function
	.text
	.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	.LBB14_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB14_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12shiftLettersPh, %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	$_Z18countLettersSharedPhPjm, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18countLettersGlobalPhPjS0_m, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$1, (%rsp)
	movl	$shiftAmount, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movl	$4, %r9d
	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_end14:
	.size	__hip_module_ctor, .Lfunc_end14-__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	.LBB15_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
.LBB15_2:
	retq
.Lfunc_end15:
	.size	__hip_module_dtor, .Lfunc_end15-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"rb"
	.size	.L.str, 3

	.type	shiftAmount,@object             # @shiftAmount
	.local	shiftAmount
	.comm	shiftAmount,4,4
	.type	_Z12shiftLettersPh,@object      # @_Z12shiftLettersPh
	.section	.rodata,"a",@progbits
	.globl	_Z12shiftLettersPh
	.p2align	3, 0x0
_Z12shiftLettersPh:
	.quad	_Z27__device_stub__shiftLettersPh
	.size	_Z12shiftLettersPh, 8

	.type	_Z18countLettersSharedPhPjm,@object # @_Z18countLettersSharedPhPjm
	.globl	_Z18countLettersSharedPhPjm
	.p2align	3, 0x0
_Z18countLettersSharedPhPjm:
	.quad	_Z33__device_stub__countLettersSharedPhPjm
	.size	_Z18countLettersSharedPhPjm, 8

	.type	_Z18countLettersGlobalPhPjS0_m,@object # @_Z18countLettersGlobalPhPjS0_m
	.globl	_Z18countLettersGlobalPhPjS0_m
	.p2align	3, 0x0
_Z18countLettersGlobalPhPjS0_m:
	.quad	_Z33__device_stub__countLettersGlobalPhPjS0_m
	.size	_Z18countLettersGlobalPhPjS0_m, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"Found %d %c's\n"
	.size	.L.str.2, 15

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Took %dns to run processing on GPU with shared memory\n"
	.size	.L.str.3, 55

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Took %dns to run processing on GPU with global memory\n"
	.size	.L.str.4, 55

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Took %dns to run on CPU\n"
	.size	.L.str.5, 25

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Shared Memory runs %fx faster than global memory\n"
	.size	.L.str.7, 50

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Shared Memory on GPU runs %fx faster than the CPU\n"
	.size	.L.str.8, 51

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"all_letter.shakespeare.txt"
	.size	.L.str.9, 27

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Bytes read: %d\n"
	.size	.L.str.10, 16

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Padding bytes: %d\n"
	.size	.L.str.11, 19

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12shiftLettersPh"
	.size	.L__unnamed_1, 19

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z18countLettersSharedPhPjm"
	.size	.L__unnamed_2, 28

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z18countLettersGlobalPhPjS0_m"
	.size	.L__unnamed_3, 31

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"shiftAmount"
	.size	.L__unnamed_4, 12

	.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

	.type	.Lstr.1,@object                 # @str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr.1:
	.asciz	"\n"
	.size	.Lstr.1, 2

	.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 _Z27__device_stub__shiftLettersPh
	.addrsig_sym _Z33__device_stub__countLettersSharedPhPjm
	.addrsig_sym _Z33__device_stub__countLettersGlobalPhPjS0_m
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym shiftAmount
	.addrsig_sym _Z12shiftLettersPh
	.addrsig_sym _Z18countLettersSharedPhPjm
	.addrsig_sym _Z18countLettersGlobalPhPjS0_m
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12shiftLettersPh      ; -- Begin function _Z12shiftLettersPh
	.globl	_Z12shiftLettersPh
	.p2align	8
	.type	_Z12shiftLettersPh,@function
_Z12shiftLettersPh:                     ; @_Z12shiftLettersPh
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x14
	s_load_b64 s[0:1], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, shiftAmount@rel32@lo+4
	s_addc_u32 s3, s3, shiftAmount@rel32@hi+12
	s_load_b32 s2, s[2:3], 0x0
	global_load_u8 v0, v1, s[0:1]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_sub_nc_u16 v0, v0, s2
	global_store_b8 v1, v0, s[0:1]
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12shiftLettersPh
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 264
		.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 3
		.amdhsa_next_free_sgpr 16
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z12shiftLettersPh, .Lfunc_end0-_Z12shiftLettersPh
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 112
; NumSgprs: 16
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 3
; 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
	.protected	_Z18countLettersSharedPhPjm ; -- Begin function _Z18countLettersSharedPhPjm
	.globl	_Z18countLettersSharedPhPjm
	.p2align	8
	.type	_Z18countLettersSharedPhPjm,@function
_Z18countLettersSharedPhPjm:            ; @_Z18countLettersSharedPhPjm
; %bb.0:
	v_mul_u32_u24_e32 v1, 26, v0
	s_mov_b64 s[2:3], 26
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v3, 2, v1
	v_dual_mov_b32 v1, 0 :: v_dual_mov_b32 v2, v3
.LBB1_1:                                ; =>This Inner Loop Header: Depth=1
	ds_store_b32 v2, v1
	v_add_nc_u32_e32 v2, 4, v2
	s_add_u32 s2, s2, -1
	s_addc_u32 s3, s3, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u64 s[2:3], 0
	s_cbranch_scc1 .LBB1_1
; %bb.2:                                ; %_Z16zeroLetterCountsPj.exit.i
	s_clause 0x1
	s_load_b64 s[4:5], s[0:1], 0x10
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cmp_eq_u64 s[4:5], 0
	s_cbranch_scc1 .LBB1_5
; %bb.3:                                ; %.lr.ph.i
	v_mad_u64_u32 v[1:2], null, v0, s4, s[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[4:5], null, v0, s5, v[2:3]
	v_mov_b32_e32 v2, v4
.LBB1_4:                                ; =>This Inner Loop Header: Depth=1
	global_load_u8 v4, v[1:2], off
	v_add_co_u32 v1, vcc_lo, v1, 1
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	s_add_u32 s4, s4, -1
	s_addc_u32 s5, s5, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u64 s[4:5], 0
	s_waitcnt vmcnt(0)
	v_lshl_add_u32 v4, v4, 2, v3
	ds_load_b32 v5, v4
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v5, 1, v5
	ds_store_b32 v4, v5
	s_cbranch_scc0 .LBB1_4
.LBB1_5:                                ; %._crit_edge.i
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_mov_b32 s0, exec_lo
	v_cmpx_gt_u32_e32 26, v0
	s_cbranch_execz .LBB1_9
; %bb.6:                                ; %.preheader.i
	v_lshlrev_b32_e32 v1, 2, v0
	v_mad_i32_i24 v3, 0xffffff9c, v0, v3
	s_mov_b64 s[0:1], 0x1c0
	global_load_b32 v2, v1, s[2:3]
	v_add_co_u32 v0, s2, s2, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v1, null, s3, 0, s2
.LBB1_7:                                ; =>This Inner Loop Header: Depth=1
	ds_load_b32 v4, v3
	v_add_nc_u32_e32 v3, 0x68, v3
	s_add_u32 s0, s0, -1
	s_addc_u32 s1, s1, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u64 s[0:1], 0
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_nc_u32_e32 v2, v4, v2
	s_cbranch_scc1 .LBB1_7
; %bb.8:                                ; %_Z12countLettersPhPjS0_m.exit.loopexit
	global_store_b32 v[0:1], v2, off
.LBB1_9:                                ; %_Z12countLettersPhPjS0_m.exit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18countLettersSharedPhPjm
		.amdhsa_group_segment_fixed_size 46592
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 6
		.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	_Z18countLettersSharedPhPjm, .Lfunc_end1-_Z18countLettersSharedPhPjm
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 344
; NumSgprs: 8
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 46592 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 8
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z18countLettersGlobalPhPjS0_m ; -- Begin function _Z18countLettersGlobalPhPjS0_m
	.globl	_Z18countLettersGlobalPhPjS0_m
	.p2align	8
	.type	_Z18countLettersGlobalPhPjS0_m,@function
_Z18countLettersGlobalPhPjS0_m:         ; @_Z18countLettersGlobalPhPjS0_m
; %bb.0:
	s_load_b256 s[0:7], s[0:1], 0x0
	v_mul_u32_u24_e32 v1, 26, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_dual_mov_b32 v1, 0 :: v_dual_lshlrev_b32 v2, 2, v1
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v3, s8, s4, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v4, null, s5, 0, s8
	s_mov_b64 s[8:9], 0
.LBB2_1:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	v_add_co_u32 v5, vcc_lo, v3, s8
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e32 v6, vcc_lo, s9, v4, vcc_lo
	s_add_u32 s8, s8, 4
	s_addc_u32 s9, s9, 0
	s_cmp_lg_u64 s[8:9], 0x68
	global_store_b32 v[5:6], v1, off
	s_cbranch_scc1 .LBB2_1
; %bb.2:                                ; %_Z16zeroLetterCountsPj.exit.i
	s_cmp_eq_u64 s[6:7], 0
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB2_5
; %bb.3:                                ; %.lr.ph.i
	v_mad_u64_u32 v[1:2], null, v0, s6, s[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[5:6], null, v0, s7, v[2:3]
	v_mov_b32_e32 v2, v5
.LBB2_4:                                ; =>This Inner Loop Header: Depth=1
	global_load_u8 v5, v[1:2], off
	s_add_u32 s6, s6, -1
	s_addc_u32 s7, s7, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_cmp_eq_u64 s[6:7], 0
	s_waitcnt vmcnt(0)
	v_lshlrev_b32_e32 v5, 2, v5
	v_add_co_u32 v5, vcc_lo, v3, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, 0, v4, vcc_lo
	v_add_co_u32 v1, vcc_lo, v1, 1
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	global_load_b32 v7, v[5:6], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v7, 1, v7
	global_store_b32 v[5:6], v7, off
	s_cbranch_scc0 .LBB2_4
.LBB2_5:                                ; %._crit_edge.i
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_mov_b32 s0, exec_lo
	v_cmpx_gt_u32_e32 26, v0
	s_cbranch_execz .LBB2_8
; %bb.6:                                ; %.preheader.i
	v_lshlrev_b32_e32 v0, 2, v0
	global_load_b32 v2, v0, s[2:3]
	v_add_co_u32 v3, s0, s4, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v4, null, s5, 0, s0
	v_add_co_u32 v0, s0, s2, v0
	v_add_co_ci_u32_e64 v1, null, s3, 0, s0
	s_mov_b64 s[0:1], 0
.LBB2_7:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_add_co_u32 v5, vcc_lo, v3, s0
	v_add_co_ci_u32_e32 v6, vcc_lo, s1, v4, vcc_lo
	s_add_u32 s0, s0, 0x68
	s_addc_u32 s1, s1, 0
	s_cmp_lg_u64 s[0:1], 0xb600
	global_load_b32 v5, v[5:6], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v2, v5, v2
	global_store_b32 v[0:1], v2, off
	s_cbranch_scc1 .LBB2_7
.LBB2_8:                                ; %_Z12countLettersPhPjS0_m.exit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18countLettersGlobalPhPjS0_m
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 32
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 10
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z18countLettersGlobalPhPjS0_m, .Lfunc_end2-_Z18countLettersGlobalPhPjS0_m
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 388
; NumSgprs: 12
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 12
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 1
; 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	shiftAmount             ; @shiftAmount
	.type	shiftAmount,@object
	.section	.bss,"aw",@nobits
	.globl	shiftAmount
	.p2align	2, 0x0
shiftAmount:
	.long	0                               ; 0x0
	.size	shiftAmount, 4

	.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 shiftAmount
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         12
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         20
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         22
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         24
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         26
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         28
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         30
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         48
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         72
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 264
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12shiftLettersPh
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z12shiftLettersPh.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .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:           8
        .value_kind:     by_value
    .group_segment_fixed_size: 46592
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18countLettersSharedPhPjm
    .private_segment_fixed_size: 0
    .sgpr_count:     8
    .sgpr_spill_count: 0
    .symbol:         _Z18countLettersSharedPhPjm.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           8
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 32
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18countLettersGlobalPhPjS0_m
    .private_segment_fixed_size: 0
    .sgpr_count:     12
    .sgpr_spill_count: 0
    .symbol:         _Z18countLettersGlobalPhPjS0_m.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
