// Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3.

#include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

// Macro para wrappear funciones de cuda e interceptar errores
#define CUDA_CHK(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) {
   if (code != cudaSuccess) {
      fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}

void read_file(const char*, int*);
int get_text_length(const char * fname);

// Cifrado: E(x) = (Ax + B) mod M
// Descifrado: D(x) = A^{-1}(x - B) mod M

// A y B son las claves del cifrado. A y M son co-primos.
#define A 15
#define B 27
#define M 256 // Cantidad de caracteres en la tabla ASCII extendida
#define A_MMI_M -17 // A^{-1}. Inverso multiplicativo de A modulo M

// El operador mod no es el mismo que (%) para números negativos, por lo que se provee una función módulo en el código.
__device__ int modulo(int a, int b) {
    int r = a % b;
    r = (r < 0) ? r + b : r;
    return r;
}

// Kernel para el ejercicio 1 y 2. Cada hilo procesa un solo caracter.
__global__ void decrypt_kernel(int *device_message, int length) {
    int index = (blockIdx.x * blockDim.x) + threadIdx.x;
    if(index < length) {
        device_message[index] = modulo(A_MMI_M*(device_message[index] - B), M);
    }
}

// Kernel para el ejercicio 3. Cada hilo procesa char_per_block caracteres.
// Para mantener el coalesced memory access cada cada warp de hilos procesa caracteres secuenciales.
// Es por esto que un hilo modifica caracteres no contiguos (separados por una distancia block_span).
// En lugar de su index sea index*char_per_block y cada hilo modifique char_per_block caracteres contiguos (lo cual no mantendría el coalesced memory access).
__global__ void decrypt_kernel_ej3(int *device_message, int char_per_block, int length) {
    int index = (blockIdx.x*blockDim.x) + threadIdx.x;
    int block_span = blockDim.x*gridDim.x;
    for(int i = 0; i < char_per_block; ++i) {
        if((index + i*block_span) < length) {
            device_message[index + i*block_span] = modulo(A_MMI_M*(device_message[index + i*block_span] - B), M);
        }
    }
}

/*
.  Normalmente se resolvería con un for recorriendo todo el texto usando D(x)
.  Como cada caracter puede ser encriptado y desencriptado de forma independiente podemos utilizar la GPU para desencriptar el texto en paralelo.
.  Para esto debemos lanzar un kernel que realice el desencriptado, asignando un thread por caracter.
*/ 
int main(int argc, char *argv[]) {
    int *host_message;
    int *device_message;
    unsigned int size;

    const char * fname;
    int algorithm;

    if (argc < 3) printf("Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3.\n");
    else
        fname = argv[1];
        algorithm = atoi(argv[2]);

    int length = get_text_length(fname);

    size = length * sizeof(int);

    // Reservo memoria para el mensaje
    host_message = (int *)malloc(size);

    // Leo el archivo de la entrada
    read_file(fname, host_message);

    // Reservo memoria en la GPU
    CUDA_CHK(cudaMalloc((void**)& device_message, size));

    // Copio los datos a la memoria de la GPU
    CUDA_CHK(cudaMemcpy(device_message, host_message, size, cudaMemcpyHostToDevice)); // puntero destino, puntero origen, numero de bytes a copiar, tipo de transferencia

    int block_size = 1024;
    int char_per_block, bloques;

    switch(algorithm) {
        // Ej1: 1 bloque de 1024 threads (No procesa más de 1024 caracteres).
        case 1:
            bloques = 1;
            char_per_block = 1;
            break;
        
        // Ej2: Múltiples bloques, los necesarios para procesar todo el texto.
        case 2:
            bloques = length/block_size + (length % block_size != 0); // Division with ceiling
            char_per_block = 1;
            break;

        // Ej3: 128 bloques. Procesa todo el texto
        //      Si el texto tiene más caracteres de 128*1024 un kernel debe procesar más de un caracter secuencialmente.
        case 3:
            bloques = 128;
            char_per_block = length/(bloques*block_size) + (length % bloques*block_size != 0);
            break;
        default:
            printf("Algoritmo seleccionado invalido.\n");
            printf("Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3.\n");
    }
    
    dim3 tamGrid(bloques); // Grid dimension
    dim3 tamBlock(block_size); // Block dimension

    // Ejecuto el kernel
    if(algorithm == 1 || algorithm == 2) {
        decrypt_kernel<<<tamGrid, tamBlock>>>(device_message, length);
    } else {
        if(algorithm == 3) {
            decrypt_kernel_ej3<<<tamGrid, tamBlock>>>(device_message, char_per_block, length);
        }
    }

    // Copio los datos nuevamente a la memoria de la CPU
    CUDA_CHK(cudaMemcpy(host_message, device_message, size, cudaMemcpyDeviceToHost)); // puntero destino, puntero origen, numero de bytes a copiar, tipo de transferencia

    // Despliego el mensaje
    if(algorithm == 1 || algorithm == 2 || algorithm == 3) {
        for (int i = 0; i < length; i++) {
            printf("%c", (char)host_message[i]);
        }
        printf("\n");
    }
    
    // Libero la memoria en la GPU
    CUDA_CHK(cudaFree(device_message));

    // Libero la memoria en la CPU
    free(host_message);

    return 0;
}

    
int get_text_length(const char * fname) {
    FILE *f = NULL;
    f = fopen(fname, "r"); // read and binary flags

    size_t pos = ftell(f);    
    fseek(f, 0, SEEK_END);    
    size_t length = ftell(f); 
    fseek(f, pos, SEEK_SET);  

    fclose(f);

    return length;
}

void read_file(const char * fname, int* input) {
    // printf("leyendo archivo %s\n", fname );

    FILE *f = NULL;
    f = fopen(fname, "r"); // read and binary flags
    if (f == NULL){
        fprintf(stderr, "Error: Could not find %s file \n", fname);
        exit(1);
    }

    // fread(input, 1, N, f);
    int c; 
    while ((c = getc(f)) != EOF) {
        *(input++) = c;
    }

    fclose(f);
}

	.file	"tmpxft_00301716_00000000-6_practico2.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._Z9gpuAssert9cudaErrorPKcib.str1.1,"aMS",@progbits,1
.LC0:
	.string	"GPUassert: %s %s %d\n"
	.section	.text._Z9gpuAssert9cudaErrorPKcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPKcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPKcib
	.type	_Z9gpuAssert9cudaErrorPKcib, @function
_Z9gpuAssert9cudaErrorPKcib:
.LFB2027:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L8
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r9d
	movq	(%rsp), %r8
	leaq	.LC0(%rip), %rdx
	movq	stderr(%rip), %rdi
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	testb	%bpl, %bpl
	je	.L2
	movl	%ebx, %edi
	call	exit@PLT
.L2:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z9gpuAssert9cudaErrorPKcib, .-_Z9gpuAssert9cudaErrorPKcib
	.text
	.globl	_Z6moduloii
	.type	_Z6moduloii, @function
_Z6moduloii:
.LFB2028:
	.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
.LFE2028:
	.size	_Z6moduloii, .-_Z6moduloii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"r"
	.text
	.globl	_Z15get_text_lengthPKc
	.type	_Z15get_text_lengthPKc, @function
_Z15get_text_lengthPKc:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC1(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	fopen@PLT
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	ftell@PLT
	movl	$2, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	movq	%rax, %r12
	call	fseek@PLT
	movq	%rbx, %rdi
	call	ftell@PLT
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%edx, %edx
	movq	%rax, %rbp
	call	fseek@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	movl	%ebp, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z15get_text_lengthPKc, .-_Z15get_text_lengthPKc
	.section	.rodata.str1.1
.LC2:
	.string	"Error: Could not find %s file \n"
	.text
	.globl	_Z9read_filePKcPi
	.type	_Z9read_filePKcPi, @function
_Z9read_filePKcPi:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	leaq	.LC1(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	fopen@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	jne	.L17
	movq	stderr(%rip), %rdi
	movq	%r12, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L17:
	movq	%rbx, %rdi
	call	getc@PLT
	cmpl	$-1, %eax
	je	.L22
	addq	$4, %rbp
	movl	%eax, -4(%rbp)
	jmp	.L17
.L22:
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z9read_filePKcPi, .-_Z9read_filePKcPi
	.globl	_Z35__device_stub__Z14decrypt_kernelPiiPii
	.type	_Z35__device_stub__Z14decrypt_kernelPiiPii, @function
_Z35__device_stub__Z14decrypt_kernelPiiPii:
.LFB2056:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z14decrypt_kernelPii(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L23:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z35__device_stub__Z14decrypt_kernelPiiPii, .-_Z35__device_stub__Z14decrypt_kernelPiiPii
	.globl	_Z14decrypt_kernelPii
	.type	_Z14decrypt_kernelPii, @function
_Z14decrypt_kernelPii:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z14decrypt_kernelPiiPii
	.cfi_endproc
.LFE2057:
	.size	_Z14decrypt_kernelPii, .-_Z14decrypt_kernelPii
	.globl	_Z40__device_stub__Z18decrypt_kernel_ej3PiiiPiii
	.type	_Z40__device_stub__Z18decrypt_kernel_ej3PiiiPiii, @function
_Z40__device_stub__Z18decrypt_kernel_ej3PiiiPiii:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z18decrypt_kernel_ej3Piii(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	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 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L28:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z40__device_stub__Z18decrypt_kernel_ej3PiiiPiii, .-_Z40__device_stub__Z18decrypt_kernel_ej3PiiiPiii
	.globl	_Z18decrypt_kernel_ej3Piii
	.type	_Z18decrypt_kernel_ej3Piii, @function
_Z18decrypt_kernel_ej3Piii:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z18decrypt_kernel_ej3PiiiPiii
	.cfi_endproc
.LFE2059:
	.size	_Z18decrypt_kernel_ej3Piii, .-_Z18decrypt_kernel_ej3Piii
	.section	.rodata.str1.1
.LC3:
	.string	"Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3.\n"
.LC4:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/gouvina-fing/fing-gpgpu2020/master/practico2/practico2.cu"
.LC5:
	.string	"Algoritmo seleccionado invalido.\n"
.LC6:
	.string	"%c"
.LC7:
	.string	"\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	jg	.L34
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L35
.L34:
	movq	8(%rsi), %r14
.L35:
	movq	16(%rbx), %rdi
	call	atoi@PLT
	movq	%r14, %rdi
	movl	%eax, %r15d
	call	_Z15get_text_lengthPKc
	movl	%eax, %ebx
	leal	0(,%rbx,4), %eax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	leaq	.LC4(%rip), %r14
	movq	%rax, %rsi
	movq	%rax, %rbp
	call	_Z9read_filePKcPi
	movq	8(%rsp), %rsi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$87, %edx
	movq	%r14, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$90, %edx
	movq	%r14, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	cmpl	$2, %r15d
	je	.L36
	cmpl	$3, %r15d
	je	.L37
	cmpl	$1, %r15d
	je	.L48
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L38
.L36:
	xorl	%r13d, %r13d
	movl	%ebx, %eax
	testl	$1023, %ebx
	movl	$1024, %ecx
	setne	%r13b
	cltd
	idivl	%ecx
	addl	%eax, %r13d
	jmp	.L52
.L37:
	xorl	%r12d, %r12d
	movl	%ebx, %eax
	testb	$127, %bl
	movl	$131072, %ecx
	setne	%r12b
	cltd
	movl	$128, %r13d
	idivl	%ecx
	addl	%eax, %r12d
	jmp	.L38
.L48:
	movl	$1, %r13d
.L52:
	movl	$1, %r12d
.L38:
	movl	%r13d, 32(%rsp)
	movl	$4194305, %edx
	leal	-1(%r15), %r13d
	movabsq	$4294967297, %rax
	movq	%rax, 36(%rsp)
	salq	$10, %rdx
	cmpl	$1, %r13d
	ja	.L40
	movq	32(%rsp), %rdi
	movl	40(%rsp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L42
	movq	24(%rsp), %rdi
	movl	%ebx, %esi
	call	_Z35__device_stub__Z14decrypt_kernelPiiPii
	jmp	.L42
.L40:
	cmpl	$3, %r15d
	jne	.L42
	movq	32(%rsp), %rdi
	movl	40(%rsp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L42
	movq	24(%rsp), %rdi
	movl	%ebx, %edx
	movl	%r12d, %esi
	call	_Z40__device_stub__Z18decrypt_kernel_ej3PiiiPiii
.L42:
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$132, %edx
	movq	%r14, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	cmpl	$2, %r13d
	ja	.L45
	xorl	%r12d, %r12d
	leaq	.LC6(%rip), %r13
.L44:
	cmpl	%r12d, %ebx
	jle	.L53
	movsbl	0(%rbp,%r12,4), %edx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%r12
	call	__printf_chk@PLT
	jmp	.L44
.L53:
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L45:
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	$1, %ecx
	movl	$143, %edx
	movq	%r14, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	%rbp, %rdi
	call	free@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L47
	call	__stack_chk_fail@PLT
.L47:
	addq	$72, %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
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC8:
	.string	"_Z18decrypt_kernel_ej3Piii"
.LC9:
	.string	"_Z14decrypt_kernelPii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2061:
	.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	.LC8(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z18decrypt_kernel_ej3Piii(%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	.LC9(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z14decrypt_kernelPii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2061:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

// Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3.

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


// Macro para wrappear funciones de cuda e interceptar errores
#define CUDA_CHK(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true) {
   if (code != hipSuccess) {
      fprintf(stderr,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}

void read_file(const char*, int*);
int get_text_length(const char * fname);

// Cifrado: E(x) = (Ax + B) mod M
// Descifrado: D(x) = A^{-1}(x - B) mod M

// A y B son las claves del cifrado. A y M son co-primos.
#define A 15
#define B 27
#define M 256 // Cantidad de caracteres en la tabla ASCII extendida
#define A_MMI_M -17 // A^{-1}. Inverso multiplicativo de A modulo M

// El operador mod no es el mismo que (%) para números negativos, por lo que se provee una función módulo en el código.
__device__ int modulo(int a, int b) {
    int r = a % b;
    r = (r < 0) ? r + b : r;
    return r;
}

// Kernel para el ejercicio 1 y 2. Cada hilo procesa un solo caracter.
__global__ void decrypt_kernel(int *device_message, int length) {
    int index = (blockIdx.x * blockDim.x) + threadIdx.x;
    if(index < length) {
        device_message[index] = modulo(A_MMI_M*(device_message[index] - B), M);
    }
}

// Kernel para el ejercicio 3. Cada hilo procesa char_per_block caracteres.
// Para mantener el coalesced memory access cada cada warp de hilos procesa caracteres secuenciales.
// Es por esto que un hilo modifica caracteres no contiguos (separados por una distancia block_span).
// En lugar de su index sea index*char_per_block y cada hilo modifique char_per_block caracteres contiguos (lo cual no mantendría el coalesced memory access).
__global__ void decrypt_kernel_ej3(int *device_message, int char_per_block, int length) {
    int index = (blockIdx.x*blockDim.x) + threadIdx.x;
    int block_span = blockDim.x*gridDim.x;
    for(int i = 0; i < char_per_block; ++i) {
        if((index + i*block_span) < length) {
            device_message[index + i*block_span] = modulo(A_MMI_M*(device_message[index + i*block_span] - B), M);
        }
    }
}

/*
.  Normalmente se resolvería con un for recorriendo todo el texto usando D(x)
.  Como cada caracter puede ser encriptado y desencriptado de forma independiente podemos utilizar la GPU para desencriptar el texto en paralelo.
.  Para esto debemos lanzar un kernel que realice el desencriptado, asignando un thread por caracter.
*/ 
int main(int argc, char *argv[]) {
    int *host_message;
    int *device_message;
    unsigned int size;

    const char * fname;
    int algorithm;

    if (argc < 3) printf("Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3.\n");
    else
        fname = argv[1];
        algorithm = atoi(argv[2]);

    int length = get_text_length(fname);

    size = length * sizeof(int);

    // Reservo memoria para el mensaje
    host_message = (int *)malloc(size);

    // Leo el archivo de la entrada
    read_file(fname, host_message);

    // Reservo memoria en la GPU
    CUDA_CHK(hipMalloc((void**)& device_message, size));

    // Copio los datos a la memoria de la GPU
    CUDA_CHK(hipMemcpy(device_message, host_message, size, hipMemcpyHostToDevice)); // puntero destino, puntero origen, numero de bytes a copiar, tipo de transferencia

    int block_size = 1024;
    int char_per_block, bloques;

    switch(algorithm) {
        // Ej1: 1 bloque de 1024 threads (No procesa más de 1024 caracteres).
        case 1:
            bloques = 1;
            char_per_block = 1;
            break;
        
        // Ej2: Múltiples bloques, los necesarios para procesar todo el texto.
        case 2:
            bloques = length/block_size + (length % block_size != 0); // Division with ceiling
            char_per_block = 1;
            break;

        // Ej3: 128 bloques. Procesa todo el texto
        //      Si el texto tiene más caracteres de 128*1024 un kernel debe procesar más de un caracter secuencialmente.
        case 3:
            bloques = 128;
            char_per_block = length/(bloques*block_size) + (length % bloques*block_size != 0);
            break;
        default:
            printf("Algoritmo seleccionado invalido.\n");
            printf("Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3.\n");
    }
    
    dim3 tamGrid(bloques); // Grid dimension
    dim3 tamBlock(block_size); // Block dimension

    // Ejecuto el kernel
    if(algorithm == 1 || algorithm == 2) {
        decrypt_kernel<<<tamGrid, tamBlock>>>(device_message, length);
    } else {
        if(algorithm == 3) {
            decrypt_kernel_ej3<<<tamGrid, tamBlock>>>(device_message, char_per_block, length);
        }
    }

    // Copio los datos nuevamente a la memoria de la CPU
    CUDA_CHK(hipMemcpy(host_message, device_message, size, hipMemcpyDeviceToHost)); // puntero destino, puntero origen, numero de bytes a copiar, tipo de transferencia

    // Despliego el mensaje
    if(algorithm == 1 || algorithm == 2 || algorithm == 3) {
        for (int i = 0; i < length; i++) {
            printf("%c", (char)host_message[i]);
        }
        printf("\n");
    }
    
    // Libero la memoria en la GPU
    CUDA_CHK(hipFree(device_message));

    // Libero la memoria en la CPU
    free(host_message);

    return 0;
}

    
int get_text_length(const char * fname) {
    FILE *f = NULL;
    f = fopen(fname, "r"); // read and binary flags

    size_t pos = ftell(f);    
    fseek(f, 0, SEEK_END);    
    size_t length = ftell(f); 
    fseek(f, pos, SEEK_SET);  

    fclose(f);

    return length;
}

void read_file(const char * fname, int* input) {
    // printf("leyendo archivo %s\n", fname );

    FILE *f = NULL;
    f = fopen(fname, "r"); // read and binary flags
    if (f == NULL){
        fprintf(stderr, "Error: Could not find %s file \n", fname);
        exit(1);
    }

    // fread(input, 1, N, f);
    int c; 
    while ((c = getc(f)) != EOF) {
        *(input++) = c;
    }

    fclose(f);
}

	.text
	.file	"practico2.hip"
	.globl	_Z29__device_stub__decrypt_kernelPii # -- Begin function _Z29__device_stub__decrypt_kernelPii
	.type	_Z29__device_stub__decrypt_kernelPii,@function
_Z29__device_stub__decrypt_kernelPii:   # @_Z29__device_stub__decrypt_kernelPii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%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	$_Z14decrypt_kernelPii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z29__device_stub__decrypt_kernelPii, .Lfunc_end0-_Z29__device_stub__decrypt_kernelPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__decrypt_kernel_ej3Piii # -- Begin function _Z33__device_stub__decrypt_kernel_ej3Piii
	.type	_Z33__device_stub__decrypt_kernel_ej3Piii,@function
_Z33__device_stub__decrypt_kernel_ej3Piii: # @_Z33__device_stub__decrypt_kernel_ej3Piii
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%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	$_Z18decrypt_kernel_ej3Piii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z33__device_stub__decrypt_kernel_ej3Piii, .Lfunc_end1-_Z33__device_stub__decrypt_kernel_ej3Piii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	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
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	cmpl	$2, %edi
	jg	.LBB2_2
# %bb.1:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
                                        # implicit-def: $r12
	jmp	.LBB2_3
.LBB2_2:
	movq	8(%rbx), %r12
.LBB2_3:
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	%r12, %rdi
	callq	_Z15get_text_lengthPKc
	movl	%eax, %r14d
	leal	(,%r14,4), %r15d
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r12, %rdi
	movq	%rax, %rsi
	callq	_Z9read_filePKcPi
	leaq	8(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_4
# %bb.6:                                # %_Z9gpuAssert10hipError_tPKcib.exit
	movq	8(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_7
# %bb.8:                                # %_Z9gpuAssert10hipError_tPKcib.exit68
	movabsq	$4294968320, %rdx               # imm = 0x100000400
	cmpl	$1, %ebp
	je	.LBB2_9
# %bb.10:                               # %_Z9gpuAssert10hipError_tPKcib.exit68
	cmpl	$3, %ebp
	jne	.LBB2_11
# %bb.15:
	leaq	-896(%rdx), %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_17
# %bb.16:
	leal	131071(%r14), %esi
	testl	%r14d, %r14d
	cmovnsl	%r14d, %esi
	sarl	$17, %esi
	movl	%r14d, %eax
	andl	$127, %eax
	cmpl	$1, %eax
	sbbl	$-1, %esi
	movq	8(%rsp), %rdi
	movl	%r14d, %edx
	callq	_Z33__device_stub__decrypt_kernel_ej3Piii
	jmp	.LBB2_17
.LBB2_9:
	leaq	-1023(%rdx), %rdi
	jmp	.LBB2_13
.LBB2_11:                               # %_Z9gpuAssert10hipError_tPKcib.exit68
	cmpl	$2, %ebp
	jne	.LBB2_26
# %bb.12:
	movl	$1023, %eax                     # imm = 0x3FF
	leal	(%r14,%rax), %ecx
	testl	%r14d, %r14d
	cmovnsl	%r14d, %ecx
	sarl	$10, %ecx
	andl	%r14d, %eax
	cmpl	$1, %eax
	sbbl	$-1, %ecx
	leaq	(%rdx,%rcx), %rdi
	addq	$-1024, %rdi                    # imm = 0xFC00
.LBB2_13:
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_17
# %bb.14:
	movq	8(%rsp), %rdi
	movl	%r14d, %esi
	callq	_Z29__device_stub__decrypt_kernelPii
.LBB2_17:
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_23
# %bb.18:                               # %_Z9gpuAssert10hipError_tPKcib.exit70.preheader
	testl	%r14d, %r14d
	jle	.LBB2_21
# %bb.19:                               # %_Z9gpuAssert10hipError_tPKcib.exit70.preheader87
	movl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB2_20:                               # %_Z9gpuAssert10hipError_tPKcib.exit70
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%rbx,%r15,4), %edi
	callq	putchar@PLT
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB2_20
.LBB2_21:                               # %_Z9gpuAssert10hipError_tPKcib.exit70._crit_edge
	movl	$10, %edi
	callq	putchar@PLT
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_22
# %bb.25:                               # %_Z9gpuAssert10hipError_tPKcib.exit72
	movq	%rbx, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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
.LBB2_4:
	.cfi_def_cfa_offset 64
	movl	%eax, %r12d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.1, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$87, %r8d
	jmp	.LBB2_5
.LBB2_7:
	movl	%eax, %r12d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.1, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$90, %r8d
.LBB2_5:
	xorl	%eax, %eax
	callq	fprintf
	movl	%r12d, %edi
	callq	exit
.LBB2_23:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.1, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$132, %r8d
	jmp	.LBB2_24
.LBB2_22:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.1, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$143, %r8d
.LBB2_24:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, %edi
	callq	exit
.LBB2_26:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z15get_text_lengthPKc          # -- Begin function _Z15get_text_lengthPKc
	.type	_Z15get_text_lengthPKc,@function
_Z15get_text_lengthPKc:                 # @_Z15get_text_lengthPKc
	.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
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$.L.str.5, %esi
	callq	fopen
	movq	%rax, %rbx
	movq	%rax, %rdi
	callq	ftell
	movq	%rax, %r14
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movl	$2, %edx
	callq	fseek
	movq	%rbx, %rdi
	callq	ftell
	movq	%rax, %r15
	movq	%rbx, %rdi
	movq	%r14, %rsi
	xorl	%edx, %edx
	callq	fseek
	movq	%rbx, %rdi
	callq	fclose
	movl	%r15d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z15get_text_lengthPKc, .Lfunc_end3-_Z15get_text_lengthPKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z9read_filePKcPi               # -- Begin function _Z9read_filePKcPi
	.type	_Z9read_filePKcPi,@function
_Z9read_filePKcPi:                      # @_Z9read_filePKcPi
	.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
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r15
	movl	$.L.str.5, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB4_5
# %bb.1:                                # %.preheader
	movq	%rax, %r14
.LBB4_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	callq	getc
	cmpl	$-1, %eax
	je	.LBB4_4
# %bb.2:                                # %.lr.ph
                                        #   in Loop: Header=BB4_3 Depth=1
	movl	%eax, (%rbx)
	addq	$4, %rbx
	jmp	.LBB4_3
.LBB4_4:                                # %._crit_edge
	movq	%r14, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.LBB4_5:
	.cfi_def_cfa_offset 32
	movq	stderr(%rip), %rdi
	movl	$.L.str.6, %esi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end4:
	.size	_Z9read_filePKcPi, .Lfunc_end4-_Z9read_filePKcPi
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14decrypt_kernelPii, %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	$_Z18decrypt_kernel_ej3Piii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB6_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z14decrypt_kernelPii,@object   # @_Z14decrypt_kernelPii
	.section	.rodata,"a",@progbits
	.globl	_Z14decrypt_kernelPii
	.p2align	3, 0x0
_Z14decrypt_kernelPii:
	.quad	_Z29__device_stub__decrypt_kernelPii
	.size	_Z14decrypt_kernelPii, 8

	.type	_Z18decrypt_kernel_ej3Piii,@object # @_Z18decrypt_kernel_ej3Piii
	.globl	_Z18decrypt_kernel_ej3Piii
	.p2align	3, 0x0
_Z18decrypt_kernel_ej3Piii:
	.quad	_Z33__device_stub__decrypt_kernel_ej3Piii
	.size	_Z18decrypt_kernel_ej3Piii, 8

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/gouvina-fing/fing-gpgpu2020/master/practico2/practico2.hip"
	.size	.L.str.1, 121

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Error: Could not find %s file \n"
	.size	.L.str.6, 32

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"GPUassert: %s %s %d\n"
	.size	.L.str.7, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14decrypt_kernelPii"
	.size	.L__unnamed_1, 22

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z18decrypt_kernel_ej3Piii"
	.size	.L__unnamed_2, 27

	.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	"Algoritmo seleccionado invalido."
	.size	.Lstr.1, 33

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3."
	.size	.Lstr.2, 90

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z29__device_stub__decrypt_kernelPii
	.addrsig_sym _Z33__device_stub__decrypt_kernel_ej3Piii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z14decrypt_kernelPii
	.addrsig_sym _Z18decrypt_kernel_ej3Piii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14decrypt_kernelPii   ; -- Begin function _Z14decrypt_kernelPii
	.globl	_Z14decrypt_kernelPii
	.p2align	8
	.type	_Z14decrypt_kernelPii,@function
_Z14decrypt_kernelPii:                  ; @_Z14decrypt_kernelPii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_movk_i32 s0, 0xef
	global_load_b32 v4, v[0:1], off
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[2:3], null, v4, s0, 0xcb
	v_and_b32_e32 v2, 0xff, v2
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14decrypt_kernelPii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 5
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z14decrypt_kernelPii, .Lfunc_end0-_Z14decrypt_kernelPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 160
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 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	_Z18decrypt_kernel_ej3Piii ; -- Begin function _Z18decrypt_kernel_ej3Piii
	.globl	_Z18decrypt_kernel_ej3Piii
	.p2align	8
	.type	_Z18decrypt_kernel_ej3Piii,@function
_Z18decrypt_kernel_ej3Piii:             ; @_Z18decrypt_kernel_ej3Piii
; %bb.0:
	s_load_b64 s[2:3], s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB1_5
; %bb.1:                                ; %.lr.ph.preheader
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b32 s5, s[0:1], 0x10
	s_load_b64 s[0:1], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	s_mul_i32 s4, s5, s4
	s_movk_i32 s5, 0xef
.LBB1_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s6, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB1_4
; %bb.3:                                ;   in Loop: Header=BB1_2 Depth=1
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s0, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	global_load_b32 v0, v[2:3], off
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[4:5], null, v0, s5, 0xcb
	v_and_b32_e32 v0, 0xff, v4
	global_store_b32 v[2:3], v0, off
.LBB1_4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s6
	v_add_nc_u32_e32 v1, s4, v1
	s_add_i32 s2, s2, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s2, 0
	s_cbranch_scc0 .LBB1_2
.LBB1_5:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18decrypt_kernel_ej3Piii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z18decrypt_kernel_ej3Piii, .Lfunc_end1-_Z18decrypt_kernel_ej3Piii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 208
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14decrypt_kernelPii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14decrypt_kernelPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18decrypt_kernel_ej3Piii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18decrypt_kernel_ej3Piii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
