#include <stdio.h>
#include <time.h>
#include "RSA_kernel.cu"
#define BUZZ_SIZE 10002

int p, q, n, t, flag, e[100], d[100], temp[BUZZ_SIZE], j, m[BUZZ_SIZE],
		en[BUZZ_SIZE], mm[BUZZ_SIZE], res[BUZZ_SIZE], i;
char msg[BUZZ_SIZE];
int prime(long int);
void generate_input(int);
void ce();
long int cd(long int);
void encrypt();
void decrypt();
void encrypt_gpu();
void decrypt_gpu();
int numChars;
int threadsPerBlock = 1024;
int blocksPerGrid;
time_t tt;
double time_encrypt_cpu, time_decrypt_cpu;
float time_encrypt_gpu = 0.0;
float time_decrypt_gpu = 0.0;

int main() {

	p = 157;
	q = 373;

	srand((unsigned) time(&tt));/* Intializes random number generator */
	generate_input(10000);

	FILE *f = fopen("input.txt", "r");
	if (f == NULL) {
		perror("Error opening file");
		return (1);
	}
	if (fgets(msg, BUZZ_SIZE, f) != NULL) {
		//printf("String read: %s\n", msg);
		printf("Reading input file...done(");
	}
	fclose(f);

	numChars = strlen(msg) - 1;
	msg[numChars] = '\0';
	printf("numChars: %d)\n\n", numChars);
	blocksPerGrid = (numChars + threadsPerBlock - 1) / threadsPerBlock;

	/*
	 printf("\nENTER MESSAGE\n");
	 fflush(stdin);
	 scanf("%s", msg);
	 numChars = strlen(msg);
	 blocksPerGrid =(numChars + threadsPerBlock - 1) / threadsPerBlock;
	 */

	for (i = 0; msg[i] != '\0'; i++) {
		m[i] = msg[i];
		mm[i] = msg[i] - 96;
	}
	n = p * q;
	t = (p - 1) * (q - 1);
	ce();
	/*
	 printf("\nPOSSIBLE VALUES OF e AND d ARE\n");
	 for (i = 0; i < j - 1; i++)
	 printf("\n%ld\t%ld", e[i], d[i]);
	 */

	encrypt();
	decrypt();
	encrypt_gpu();
	decrypt_gpu();
	printf("GPU encryption speed up: %f\n",
			time_encrypt_cpu / time_encrypt_gpu);
	printf("GPU decryption speed up: %f\n\n",
			time_decrypt_cpu / time_decrypt_gpu);

	return 0;
}

void generate_input(int size) {
	printf("\nGenerating input file... ");
	FILE *fp = fopen("input.txt", "wb");
	if (fp != NULL) {
		for (int k = 0; k < size; k++) {
			int r = rand() % 26;
			fprintf(fp, "%c", r + 97);
		}
		fprintf(fp, "\n");
		fclose(fp);
		printf("done\n");
	}
}

int prime(long int pr) {
	int i;
	j = sqrt(pr);
	for (i = 2; i <= j; i++) {
		if (pr % i == 0)
			return 0;
	}
	return 1;
}

void ce() {
	int k;
	k = 0;
	for (i = 2; i < t; i++) {
		if (t % i == 0)
			continue;
		flag = prime(i);
		if (flag == 1 && i != p && i != q) {
			e[k] = i;
			flag = cd(e[k]);
			if (flag > 0) {
				d[k] = flag;
				k++;
			}
			if (k == 99)
				break;
		}
	}
}

long int cd(long int x) {
	long int k = 1;
	while (1) {
		k = k + t;
		if (k % x == 0)
			return (k / x);
	}
}

void encrypt() {
	double start_encrypt, end_encrypt;
	start_encrypt = clock();
	printf("CPU starts encrypting...\n");
	int pt, ct, key = e[0], k, len;
	printf("\ne=%d\n",key);
	i = 0;
	len = numChars;
	while (i != len) {
		pt = m[i];
		pt = pt - 96;
		k = 1;
		for (j = 0; j < key; j++) {
			k = k * pt;
			k = k % n;
		}
		temp[i] = k;
		ct = k + 96;
		en[i] = ct;
		i++;
	}
	end_encrypt = clock();
	time_encrypt_cpu = (double) (end_encrypt - start_encrypt) / CLOCKS_PER_SEC;
	printf("Encryption time taken by CPU: %f s\n", time_encrypt_cpu);
	/*
	 en[i] = -1;
	 printf("\nCPU ENCRYPTED MESSAGE IS\n");
	 for (i = 0; en[i] != -1; i++)
	 printf("%d ", en[i]);
	 */

	printf("Saving CPU encrypted file... ");
	en[i] = -1;
	FILE *fp = fopen("encrypted_cpu.txt", "wb");
	if (fp != NULL) {
		for (int k = 0; en[k] != -1; k++) {
			fprintf(fp, "%d", en[k]);
		}
		fclose(fp);
		printf("done\n\n");
	}
}

void encrypt_gpu() {
	cudaEvent_t start_encrypt, stop_encrypt;
	int key = e[0];
	//printf("\nkey=%d, n=%d\n",key,n);
	cudaSetDevice(1);
	int *dev_num, *dev_key, *dev_den;
	int *dev_res;
	cudaMalloc((void **) &dev_num, numChars * sizeof(int));
	cudaMalloc((void **) &dev_key, sizeof(int));
	cudaMalloc((void **) &dev_den, sizeof(int));
	cudaMalloc((void **) &dev_res, numChars * sizeof(int));
	cudaMemcpy(dev_num, mm, numChars * sizeof(int), cudaMemcpyHostToDevice);
	cudaMemcpy(dev_key, &key, sizeof(int), cudaMemcpyHostToDevice);
	cudaMemcpy(dev_den, &n, sizeof(int), cudaMemcpyHostToDevice);
	cudaMemcpy(dev_res, res, numChars * sizeof(int), cudaMemcpyHostToDevice);

	cudaEventCreate(&start_encrypt);
	cudaEventCreate(&stop_encrypt);
	cudaEventRecord(start_encrypt);
	printf("GPU starts encrypting...\n");
	rsa<<<blocksPerGrid, threadsPerBlock>>>(dev_num,dev_key,dev_den,dev_res);
	cudaEventRecord(stop_encrypt);
	cudaEventSynchronize(stop_encrypt);
	cudaThreadSynchronize();
	cudaEventElapsedTime(&time_encrypt_gpu, start_encrypt, stop_encrypt);

	cudaMemcpy(res, dev_res, numChars * sizeof(int), cudaMemcpyDeviceToHost);
	cudaFree(dev_num);
	cudaFree(dev_key);
	cudaFree(dev_den);
	cudaFree(dev_res);

	time_encrypt_gpu /= 1000;
	printf("Encryption time taken by GPU: %f s\n", time_encrypt_gpu);

	/*
	 printf("\nGPU ENCRYPTED MESSAGE IS\n");
	 for (i = 0; i < numChars; i++)
	 printf("%d ", res[i]+96);
	 printf("\n");
	 */

	printf("Saving GPU encrypted file... ");
	FILE *fp = fopen("encrypted_gpu.txt", "wb");
	if (fp != NULL) {
		for (i = 0; i < numChars; i++) {
			fprintf(fp, "%d", res[i] + 96);
		}
		fclose(fp);
		printf("done\n\n");
	}
}

void decrypt_gpu() {
	cudaEvent_t start_decrypt, stop_decrypt;
	int key = d[0];
	//printf("\nkey=%d, n=%d\n",key,n);
	cudaSetDevice(1);
	int *dev_num, *dev_key, *dev_den;
	int *dev_res;
	cudaMalloc((void **) &dev_num, numChars * sizeof(int));
	cudaMalloc((void **) &dev_key, sizeof(int));
	cudaMalloc((void **) &dev_den, sizeof(int));
	cudaMalloc((void **) &dev_res, numChars * sizeof(int));
	cudaMemcpy(dev_num, res, numChars * sizeof(int), cudaMemcpyHostToDevice);
	cudaMemcpy(dev_key, &key, sizeof(int), cudaMemcpyHostToDevice);
	cudaMemcpy(dev_den, &n, sizeof(int), cudaMemcpyHostToDevice);
	cudaMemcpy(dev_res, res, numChars * sizeof(int), cudaMemcpyHostToDevice);

	cudaEventCreate(&start_decrypt);
	cudaEventCreate(&stop_decrypt);
	cudaEventRecord(start_decrypt);
	printf("GPU starts decrypting...\n");
	rsa<<<blocksPerGrid, threadsPerBlock>>>(dev_num,dev_key,dev_den,dev_res);
	cudaEventRecord(stop_decrypt);
	cudaEventSynchronize(stop_decrypt);
	cudaThreadSynchronize();
	cudaEventElapsedTime(&time_decrypt_gpu, start_decrypt, stop_decrypt);

	cudaMemcpy(res, dev_res, numChars * sizeof(int), cudaMemcpyDeviceToHost);
	cudaFree(dev_num);
	cudaFree(dev_key);
	cudaFree(dev_den);
	cudaFree(dev_res);

	time_decrypt_gpu /= 1000;
	printf("Decryption time taken by GPU: %f s\n", time_decrypt_gpu);

	/*
	 printf("\nGPU DECRYPTED MESSAGE IS\n");
	 for (i = 0; i < numChars; i++)
	 printf("%d ", res[i]+96);
	 printf("\n");
	 */

	printf("Saving GPU decrypted file... ");
	FILE *fp = fopen("decrypted_gpu.txt", "wb");
	if (fp != NULL) {
		for (i = 0; i < numChars; i++) {
			fprintf(fp, "%c", res[i] + 96);
		}
		fprintf(fp, "\n");
		fclose(fp);
		printf("done\n\n");
	}
}

void decrypt() {
	double start_decrypt, end_decrypt;
	start_decrypt = clock();
	printf("CPU starts decrypting...\n");
	long int pt, ct, key = d[0], k;
	printf("\nd=%d\n",key);
	i = 0;
	while (en[i] != -1) {
		ct = temp[i];
		k = 1;
		for (j = 0; j < key; j++) {
			k = k * ct;
			k = k % n;
		}
		pt = k + 96;
		m[i] = pt;
		i++;
	}
	end_decrypt = clock();
	time_decrypt_cpu = (double) (end_decrypt - start_decrypt) / CLOCKS_PER_SEC;
	printf("Decryption time taken by CPU: %f s\n", time_decrypt_cpu);

	/*
	 m[i] = -1;
	 printf("\nCPU DECRYPTED MESSAGE IS\n");
	 for (i = 0; m[i] != -1; i++)
	 printf("%d ", m[i]);
	 printf("\n");
	 */

	printf("Saving CPU decrypted file... ");
	m[i] = -1;
	FILE *fp = fopen("decrypted_cpu.txt", "wb");
	if (fp != NULL) {
		for (int k = 0; m[k] != -1; k++) {
			fprintf(fp, "%c", m[k]);
		}
		fprintf(fp, "\n");
		fclose(fp);
		printf("done\n\n");
	}
}

	.file	"tmpxft_0026b12d_00000000-6_RSA.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2040:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2040:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z3modiii
	.type	_Z3modiii, @function
_Z3modiii:
.LFB2027:
	.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
.LFE2027:
	.size	_Z3modiii, .-_Z3modiii
	.globl	_Z13mod_optimizediii
	.type	_Z13mod_optimizediii, @function
_Z13mod_optimizediii:
.LFB2183:
	.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
.LFE2183:
	.size	_Z13mod_optimizediii, .-_Z13mod_optimizediii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"\nGenerating input file... "
.LC1:
	.string	"wb"
.LC2:
	.string	"input.txt"
.LC3:
	.string	"%c"
.LC4:
	.string	"\n"
.LC5:
	.string	"done\n"
	.text
	.globl	_Z14generate_inputi
	.type	_Z14generate_inputi, @function
_Z14generate_inputi:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%edi, %ebp
	movl	$2, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rcx
	.cfi_def_cfa_offset 48
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	call	fopen@PLT
	testq	%rax, %rax
	je	.L16
	movq	%rax, %rbx
	xorl	%r12d, %r12d
	leaq	.LC3(%rip), %r13
.L7:
	cmpl	%ebp, %r12d
	jge	.L17
	call	rand@PLT
	movl	$26, %ecx
	movq	%rbx, %rdi
	incl	%r12d
	cltd
	movl	$2, %esi
	idivl	%ecx
	xorl	%eax, %eax
	leal	97(%rdx), %ecx
	movq	%r13, %rdx
	call	__fprintf_chk@PLT
	jmp	.L7
.L17:
	leaq	.LC4(%rip), %rdx
	movl	$2, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	popq	%rdx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	leaq	.LC5(%rip), %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
.L16:
	.cfi_restore_state
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z14generate_inputi, .-_Z14generate_inputi
	.globl	_Z5primel
	.type	_Z5primel, @function
_Z5primel:
.LFB2031:
	.cfi_startproc
	endbr64
	cvtsi2sdq	%rdi, %xmm0
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	sqrt@PLT
	movl	$2, %ecx
	cvttsd2sil	%xmm0, %esi
	movl	%esi, j(%rip)
.L19:
	cmpl	%ecx, %esi
	jl	.L24
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	incq	%rcx
	testq	%rdx, %rdx
	jne	.L19
	xorl	%eax, %eax
	jmp	.L18
.L24:
	movl	$1, %eax
.L18:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z5primel, .-_Z5primel
	.globl	_Z2cdl
	.type	_Z2cdl, @function
_Z2cdl:
.LFB2033:
	.cfi_startproc
	endbr64
	movslq	t(%rip), %rsi
	movl	$1, %ecx
.L26:
	addq	%rsi, %rcx
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	testq	%rdx, %rdx
	jne	.L26
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z2cdl, .-_Z2cdl
	.globl	_Z2cev
	.type	_Z2cev, @function
_Z2cev:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$2, %edi
	leaq	e(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 32
.L29:
	movl	t(%rip), %eax
	movl	%edi, i(%rip)
	cmpl	%eax, %edi
	jge	.L28
	cltd
	idivl	%edi
	testl	%edx, %edx
	je	.L32
	movslq	%edi, %rdi
	call	_Z5primel
	movl	%eax, flag(%rip)
	decl	%eax
	jne	.L32
	movslq	i(%rip), %rdi
	cmpl	p(%rip), %edi
	je	.L32
	cmpl	q(%rip), %edi
	je	.L32
	movslq	%ebx, %r8
	movl	%edi, 0(%rbp,%r8,4)
	call	_Z2cdl
	movl	%eax, flag(%rip)
	testl	%eax, %eax
	jle	.L31
	leaq	d(%rip), %rdx
	incl	%ebx
	movl	%eax, (%rdx,%r8,4)
.L31:
	cmpl	$99, %ebx
	je	.L28
.L32:
	movl	i(%rip), %eax
	leal	1(%rax), %edi
	jmp	.L29
.L28:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z2cev, .-_Z2cev
	.section	.rodata.str1.1
.LC6:
	.string	"CPU starts encrypting...\n"
.LC7:
	.string	"\ne=%d\n"
.LC9:
	.string	"Encryption time taken by CPU: %f s\n"
.LC10:
	.string	"Saving CPU encrypted file... "
.LC11:
	.string	"encrypted_cpu.txt"
.LC12:
	.string	"%d"
.LC13:
	.string	"done\n\n"
	.text
	.globl	_Z7encryptv
	.type	_Z7encryptv, @function
_Z7encryptv:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	en(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	temp(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	call	clock@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	cvtsi2sdq	%rax, %xmm1
	xorl	%eax, %eax
	movsd	%xmm1, 8(%rsp)
	call	__printf_chk@PLT
	movl	e(%rip), %ebx
	xorl	%eax, %eax
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	movl	%ebx, %edx
	call	__printf_chk@PLT
	xorl	%r10d, %r10d
	xorl	%esi, %esi
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	testl	%ebx, %ebx
	movl	%r10d, i(%rip)
	movl	numChars(%rip), %r9d
	movl	n(%rip), %r10d
	movl	j(%rip), %eax
	cmovns	%ebx, %esi
	leaq	m(%rip), %r11
.L40:
	cmpl	%ecx, %r9d
	je	.L52
	movl	(%r11,%rcx,4), %eax
	xorl	%edi, %edi
	movl	$1, %edx
	leal	-96(%rax), %r8d
.L41:
	cmpl	%edi, %ebx
	jle	.L53
	movl	%edx, %eax
	incl	%edi
	imull	%r8d, %eax
	cltd
	idivl	%r10d
	jmp	.L41
.L53:
	movl	%edx, 0(%rbp,%rcx,4)
	addl	$96, %edx
	movl	%esi, %eax
	movl	%edx, (%r12,%rcx,4)
	incq	%rcx
	movb	$1, %dl
	jmp	.L40
.L52:
	testb	%dl, %dl
	je	.L44
	movl	%r9d, i(%rip)
	movl	%eax, j(%rip)
.L44:
	call	clock@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	leaq	en(%rip), %rbx
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	subsd	8(%rsp), %xmm0
	divsd	.LC8(%rip), %xmm0
	movsd	%xmm0, time_encrypt_cpu(%rip)
	leaq	.LC12(%rip), %r12
	call	__printf_chk@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	i(%rip), %rax
	leaq	.LC1(%rip), %rsi
	leaq	.LC11(%rip), %rdi
	movl	$-1, (%rbx,%rax,4)
	call	fopen@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L54
.L46:
	movl	(%rbx), %ecx
	addq	$4, %rbx
	cmpl	$-1, %ecx
	je	.L55
	movq	%r12, %rdx
	movl	$2, %esi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L46
.L55:
	movq	%rbp, %rdi
	call	fclose@PLT
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	leaq	.LC13(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
.L54:
	.cfi_restore_state
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z7encryptv, .-_Z7encryptv
	.section	.rodata.str1.1
.LC14:
	.string	"CPU starts decrypting...\n"
.LC15:
	.string	"\nd=%d\n"
.LC16:
	.string	"Decryption time taken by CPU: %f s\n"
.LC17:
	.string	"Saving CPU decrypted file... "
.LC18:
	.string	"decrypted_cpu.txt"
	.text
	.globl	_Z7decryptv
	.type	_Z7decryptv, @function
_Z7decryptv:
.LFB2037:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	call	clock@PLT
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	cvtsi2sdq	%rax, %xmm1
	xorl	%eax, %eax
	movsd	%xmm1, 8(%rsp)
	call	__printf_chk@PLT
	movslq	d(%rip), %rdx
	xorl	%eax, %eax
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	movq	%rdx, %rbx
	call	__printf_chk@PLT
	xorl	%r10d, %r10d
	xorl	%esi, %esi
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	testl	%ebx, %ebx
	movslq	n(%rip), %r8
	movl	j(%rip), %eax
	cmovns	%ebx, %esi
	movl	%r10d, i(%rip)
	leaq	en(%rip), %r9
	leaq	temp(%rip), %r10
	leaq	m(%rip), %r11
.L57:
	cmpl	$-1, (%r9,%rcx,4)
	je	.L69
	movslq	(%r10,%rcx,4), %rbp
	xorl	%edi, %edi
	movl	$1, %edx
.L58:
	cmpl	%edi, %ebx
	jle	.L70
	movq	%rdx, %rax
	incl	%edi
	imulq	%rbp, %rax
	cqto
	idivq	%r8
	jmp	.L58
.L70:
	addq	$96, %rdx
	movl	%esi, %eax
	movl	%edx, (%r11,%rcx,4)
	incq	%rcx
	movb	$1, %dl
	jmp	.L57
.L69:
	testb	%dl, %dl
	je	.L61
	movl	%ecx, i(%rip)
	movl	%eax, j(%rip)
.L61:
	call	clock@PLT
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	leaq	m(%rip), %rbp
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	subsd	8(%rsp), %xmm0
	divsd	.LC8(%rip), %xmm0
	movsd	%xmm0, time_decrypt_cpu(%rip)
	leaq	.LC3(%rip), %r12
	call	__printf_chk@PLT
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	i(%rip), %rax
	leaq	.LC1(%rip), %rsi
	leaq	.LC18(%rip), %rdi
	movl	$-1, 0(%rbp,%rax,4)
	call	fopen@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.L71
.L63:
	movl	0(%rbp), %ecx
	addq	$4, %rbp
	cmpl	$-1, %ecx
	je	.L72
	movq	%r12, %rdx
	movl	$2, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L63
.L72:
	movl	$2, %esi
	movq	%rbx, %rdi
	leaq	.LC4(%rip), %rdx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	leaq	.LC13(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
.L71:
	.cfi_restore_state
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2037:
	.size	_Z7decryptv, .-_Z7decryptv
	.globl	_Z28__device_stub__Z3rsaPiS_S_S_PiS_S_S_
	.type	_Z28__device_stub__Z3rsaPiS_S_S_PiS_S_S_, @function
_Z28__device_stub__Z3rsaPiS_S_S_PiS_S_S_:
.LFB2062:
	.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	.L73
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z3rsaPiS_S_S_(%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
.L73:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L75
	call	__stack_chk_fail@PLT
.L75:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2062:
	.size	_Z28__device_stub__Z3rsaPiS_S_S_PiS_S_S_, .-_Z28__device_stub__Z3rsaPiS_S_S_PiS_S_S_
	.globl	_Z3rsaPiS_S_S_
	.type	_Z3rsaPiS_S_S_, @function
_Z3rsaPiS_S_S_:
.LFB2063:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z3rsaPiS_S_S_PiS_S_S_
	.cfi_endproc
.LFE2063:
	.size	_Z3rsaPiS_S_S_, .-_Z3rsaPiS_S_S_
	.section	.rodata.str1.1
.LC19:
	.string	"GPU starts encrypting...\n"
.LC21:
	.string	"Encryption time taken by GPU: %f s\n"
.LC22:
	.string	"Saving GPU encrypted file... "
.LC23:
	.string	"encrypted_gpu.txt"
	.text
	.globl	_Z11encrypt_gpuv
	.type	_Z11encrypt_gpuv, @function
_Z11encrypt_gpuv:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$1, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	res(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$96, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	movl	e(%rip), %eax
	movl	%eax, 12(%rsp)
	call	cudaSetDevice@PLT
	movslq	numChars(%rip), %rsi
	leaq	32(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movslq	numChars(%rip), %rsi
	leaq	56(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movq	32(%rsp), %rdi
	movslq	numChars(%rip), %rdx
	movl	$1, %ecx
	leaq	mm(%rip), %rsi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	leaq	12(%rsp), %rsi
	movl	$1, %ecx
	movl	$4, %edx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movl	$4, %edx
	leaq	n(%rip), %rsi
	call	cudaMemcpy@PLT
	movslq	numChars(%rip), %rdx
	movq	56(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	leaq	16(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	24(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	threadsPerBlock(%rip), %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	blocksPerGrid(%rip), %edx
	movl	%eax, 76(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 80(%rsp)
	movl	84(%rsp), %ecx
	movl	%edx, 64(%rsp)
	movq	76(%rsp), %rdx
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L79
	movq	56(%rsp), %rcx
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
	call	_Z28__device_stub__Z3rsaPiS_S_S_PiS_S_S_
.L79:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	leaq	.LC12(%rip), %r12
	call	cudaEventRecord@PLT
	movq	24(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	call	cudaThreadSynchronize@PLT
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	leaq	time_encrypt_gpu(%rip), %rdi
	call	cudaEventElapsedTime@PLT
	movslq	numChars(%rip), %rdx
	movq	56(%rsp), %rsi
	movq	%rbp, %rdi
	movl	$2, %ecx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	leaq	.LC21(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	movss	time_encrypt_gpu(%rip), %xmm0
	divss	.LC20(%rip), %xmm0
	movss	%xmm0, time_encrypt_gpu(%rip)
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	leaq	.LC23(%rip), %rdi
	call	fopen@PLT
	xorl	%edx, %edx
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.L78
.L80:
	cmpl	%edx, numChars(%rip)
	movl	%edx, i(%rip)
	jle	.L87
	movslq	%edx, %rdx
	movl	$2, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	movl	0(%rbp,%rdx,4), %ecx
	movq	%r12, %rdx
	addl	$96, %ecx
	call	__fprintf_chk@PLT
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	jmp	.L80
.L87:
	movq	%rbx, %rdi
	call	fclose@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L78:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L83
	call	__stack_chk_fail@PLT
.L83:
	addq	$96, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	_Z11encrypt_gpuv, .-_Z11encrypt_gpuv
	.section	.rodata.str1.1
.LC24:
	.string	"GPU starts decrypting...\n"
.LC25:
	.string	"Decryption time taken by GPU: %f s\n"
.LC26:
	.string	"Saving GPU decrypted file... "
.LC27:
	.string	"decrypted_gpu.txt"
	.text
	.globl	_Z11decrypt_gpuv
	.type	_Z11decrypt_gpuv, @function
_Z11decrypt_gpuv:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$1, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	res(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$96, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	movl	d(%rip), %eax
	movl	%eax, 12(%rsp)
	call	cudaSetDevice@PLT
	movslq	numChars(%rip), %rsi
	leaq	32(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movslq	numChars(%rip), %rsi
	leaq	56(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movslq	numChars(%rip), %rdx
	movq	32(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	leaq	12(%rsp), %rsi
	movl	$1, %ecx
	movl	$4, %edx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movl	$4, %edx
	leaq	n(%rip), %rsi
	call	cudaMemcpy@PLT
	movslq	numChars(%rip), %rdx
	movq	56(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	leaq	16(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	24(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	leaq	.LC24(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	threadsPerBlock(%rip), %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	blocksPerGrid(%rip), %edx
	movl	%eax, 76(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 80(%rsp)
	movl	84(%rsp), %ecx
	movl	%edx, 64(%rsp)
	movq	76(%rsp), %rdx
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L89
	movq	56(%rsp), %rcx
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
	call	_Z28__device_stub__Z3rsaPiS_S_S_PiS_S_S_
.L89:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	leaq	.LC3(%rip), %r12
	call	cudaEventRecord@PLT
	movq	24(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	call	cudaThreadSynchronize@PLT
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	leaq	time_decrypt_gpu(%rip), %rdi
	call	cudaEventElapsedTime@PLT
	movslq	numChars(%rip), %rdx
	movq	56(%rsp), %rsi
	movq	%rbp, %rdi
	movl	$2, %ecx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	leaq	.LC25(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	movss	time_decrypt_gpu(%rip), %xmm0
	divss	.LC20(%rip), %xmm0
	movss	%xmm0, time_decrypt_gpu(%rip)
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	leaq	.LC27(%rip), %rdi
	call	fopen@PLT
	movq	%rax, %rbx
	xorl	%eax, %eax
	testq	%rbx, %rbx
	je	.L88
.L90:
	cmpl	%eax, numChars(%rip)
	movl	%eax, i(%rip)
	jle	.L97
	cltq
	movq	%r12, %rdx
	movl	$2, %esi
	movq	%rbx, %rdi
	movl	0(%rbp,%rax,4), %ecx
	xorl	%eax, %eax
	addl	$96, %ecx
	call	__fprintf_chk@PLT
	movl	i(%rip), %eax
	incl	%eax
	jmp	.L90
.L97:
	movl	$2, %esi
	leaq	.LC4(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L88:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L93
	call	__stack_chk_fail@PLT
.L93:
	addq	$96, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z11decrypt_gpuv, .-_Z11decrypt_gpuv
	.section	.rodata.str1.1
.LC28:
	.string	"r"
.LC29:
	.string	"Error opening file"
.LC30:
	.string	"Reading input file...done("
.LC31:
	.string	"numChars: %d)\n\n"
.LC32:
	.string	"GPU encryption speed up: %f\n"
.LC33:
	.string	"GPU decryption speed up: %f\n\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	tt(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rsi
	.cfi_def_cfa_offset 32
	movl	$157, p(%rip)
	movl	$373, q(%rip)
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	movl	$10000, %edi
	call	_Z14generate_inputi
	leaq	.LC28(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L99
	leaq	.LC29(%rip), %rdi
	call	perror@PLT
	movl	$1, %eax
	jmp	.L98
.L99:
	movq	%rax, %rcx
	movl	$10002, %edx
	movl	$10002, %esi
	movq	%rax, %rbp
	leaq	msg(%rip), %rbx
	movq	%rbx, %rdi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	je	.L101
	leaq	.LC30(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L101:
	movq	%rbp, %rdi
	call	fclose@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	leaq	.LC31(%rip), %rsi
	movl	$2, %edi
	leal	-1(%rax), %edx
	movslq	%edx, %rax
	movl	%edx, numChars(%rip)
	movb	$0, (%rbx,%rax)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	threadsPerBlock(%rip), %ecx
	movl	numChars(%rip), %eax
	leaq	m(%rip), %rsi
	leaq	mm(%rip), %rdi
	addl	%ecx, %eax
	decl	%eax
	cltd
	idivl	%ecx
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	movl	%ecx, i(%rip)
	xorl	%ecx, %ecx
	movl	%eax, blocksPerGrid(%rip)
.L102:
	movsbl	(%rbx,%rdx), %eax
	testb	%al, %al
	je	.L112
	movl	%eax, (%rsi,%rdx,4)
	subl	$96, %eax
	movb	$1, %cl
	movl	%eax, (%rdi,%rdx,4)
	incq	%rdx
	jmp	.L102
.L112:
	testb	%cl, %cl
	je	.L104
	movl	%edx, i(%rip)
.L104:
	movl	p(%rip), %eax
	movl	q(%rip), %edx
	movl	%eax, %ecx
	decl	%eax
	imull	%edx, %ecx
	decl	%edx
	imull	%edx, %eax
	movl	%ecx, n(%rip)
	movl	%eax, t(%rip)
	call	_Z2cev
	call	_Z7encryptv
	call	_Z7decryptv
	call	_Z11encrypt_gpuv
	call	_Z11decrypt_gpuv
	movsd	time_encrypt_cpu(%rip), %xmm0
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	time_encrypt_gpu(%rip), %xmm1
	leaq	.LC32(%rip), %rsi
	divsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	movsd	time_decrypt_cpu(%rip), %xmm0
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	time_decrypt_gpu(%rip), %xmm1
	leaq	.LC33(%rip), %rsi
	divsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	xorl	%eax, %eax
.L98:
	popq	%rdx
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC34:
	.string	"_Z3rsaPiS_S_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2065:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC34(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z3rsaPiS_S_S_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2065:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	time_decrypt_gpu
	.bss
	.align 4
	.type	time_decrypt_gpu, @object
	.size	time_decrypt_gpu, 4
time_decrypt_gpu:
	.zero	4
	.globl	time_encrypt_gpu
	.align 4
	.type	time_encrypt_gpu, @object
	.size	time_encrypt_gpu, 4
time_encrypt_gpu:
	.zero	4
	.globl	time_decrypt_cpu
	.align 8
	.type	time_decrypt_cpu, @object
	.size	time_decrypt_cpu, 8
time_decrypt_cpu:
	.zero	8
	.globl	time_encrypt_cpu
	.align 8
	.type	time_encrypt_cpu, @object
	.size	time_encrypt_cpu, 8
time_encrypt_cpu:
	.zero	8
	.globl	tt
	.align 8
	.type	tt, @object
	.size	tt, 8
tt:
	.zero	8
	.globl	blocksPerGrid
	.align 4
	.type	blocksPerGrid, @object
	.size	blocksPerGrid, 4
blocksPerGrid:
	.zero	4
	.globl	threadsPerBlock
	.data
	.align 4
	.type	threadsPerBlock, @object
	.size	threadsPerBlock, 4
threadsPerBlock:
	.long	1024
	.globl	numChars
	.bss
	.align 4
	.type	numChars, @object
	.size	numChars, 4
numChars:
	.zero	4
	.globl	msg
	.align 32
	.type	msg, @object
	.size	msg, 10002
msg:
	.zero	10002
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	res
	.align 32
	.type	res, @object
	.size	res, 40008
res:
	.zero	40008
	.globl	mm
	.align 32
	.type	mm, @object
	.size	mm, 40008
mm:
	.zero	40008
	.globl	en
	.align 32
	.type	en, @object
	.size	en, 40008
en:
	.zero	40008
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 40008
m:
	.zero	40008
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	temp
	.align 32
	.type	temp, @object
	.size	temp, 40008
temp:
	.zero	40008
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.globl	e
	.align 32
	.type	e, @object
	.size	e, 400
e:
	.zero	400
	.globl	flag
	.align 4
	.type	flag, @object
	.size	flag, 4
flag:
	.zero	4
	.globl	t
	.align 4
	.type	t, @object
	.size	t, 4
t:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	q
	.align 4
	.type	q, @object
	.size	q, 4
q:
	.zero	4
	.globl	p
	.align 4
	.type	p, @object
	.size	p, 4
p:
	.zero	4
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC8:
	.long	0
	.long	1093567616
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC20:
	.long	1148846080
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <time.h>
#include "RSA_kernel.cu"
#define BUZZ_SIZE 10002

int p, q, n, t, flag, e[100], d[100], temp[BUZZ_SIZE], j, m[BUZZ_SIZE],
		en[BUZZ_SIZE], mm[BUZZ_SIZE], res[BUZZ_SIZE], i;
char msg[BUZZ_SIZE];
int prime(long int);
void generate_input(int);
void ce();
long int cd(long int);
void encrypt();
void decrypt();
void encrypt_gpu();
void decrypt_gpu();
int numChars;
int threadsPerBlock = 1024;
int blocksPerGrid;
time_t tt;
double time_encrypt_cpu, time_decrypt_cpu;
float time_encrypt_gpu = 0.0;
float time_decrypt_gpu = 0.0;

int main() {

	p = 157;
	q = 373;

	srand((unsigned) time(&tt));/* Intializes random number generator */
	generate_input(10000);

	FILE *f = fopen("input.txt", "r");
	if (f == NULL) {
		perror("Error opening file");
		return (1);
	}
	if (fgets(msg, BUZZ_SIZE, f) != NULL) {
		//printf("String read: %s\n", msg);
		printf("Reading input file...done(");
	}
	fclose(f);

	numChars = strlen(msg) - 1;
	msg[numChars] = '\0';
	printf("numChars: %d)\n\n", numChars);
	blocksPerGrid = (numChars + threadsPerBlock - 1) / threadsPerBlock;

	/*
	 printf("\nENTER MESSAGE\n");
	 fflush(stdin);
	 scanf("%s", msg);
	 numChars = strlen(msg);
	 blocksPerGrid =(numChars + threadsPerBlock - 1) / threadsPerBlock;
	 */

	for (i = 0; msg[i] != '\0'; i++) {
		m[i] = msg[i];
		mm[i] = msg[i] - 96;
	}
	n = p * q;
	t = (p - 1) * (q - 1);
	ce();
	/*
	 printf("\nPOSSIBLE VALUES OF e AND d ARE\n");
	 for (i = 0; i < j - 1; i++)
	 printf("\n%ld\t%ld", e[i], d[i]);
	 */

	encrypt();
	decrypt();
	encrypt_gpu();
	decrypt_gpu();
	printf("GPU encryption speed up: %f\n",
			time_encrypt_cpu / time_encrypt_gpu);
	printf("GPU decryption speed up: %f\n\n",
			time_decrypt_cpu / time_decrypt_gpu);

	return 0;
}

void generate_input(int size) {
	printf("\nGenerating input file... ");
	FILE *fp = fopen("input.txt", "wb");
	if (fp != NULL) {
		for (int k = 0; k < size; k++) {
			int r = rand() % 26;
			fprintf(fp, "%c", r + 97);
		}
		fprintf(fp, "\n");
		fclose(fp);
		printf("done\n");
	}
}

int prime(long int pr) {
	int i;
	j = sqrt(pr);
	for (i = 2; i <= j; i++) {
		if (pr % i == 0)
			return 0;
	}
	return 1;
}

void ce() {
	int k;
	k = 0;
	for (i = 2; i < t; i++) {
		if (t % i == 0)
			continue;
		flag = prime(i);
		if (flag == 1 && i != p && i != q) {
			e[k] = i;
			flag = cd(e[k]);
			if (flag > 0) {
				d[k] = flag;
				k++;
			}
			if (k == 99)
				break;
		}
	}
}

long int cd(long int x) {
	long int k = 1;
	while (1) {
		k = k + t;
		if (k % x == 0)
			return (k / x);
	}
}

void encrypt() {
	double start_encrypt, end_encrypt;
	start_encrypt = clock();
	printf("CPU starts encrypting...\n");
	int pt, ct, key = e[0], k, len;
	printf("\ne=%d\n",key);
	i = 0;
	len = numChars;
	while (i != len) {
		pt = m[i];
		pt = pt - 96;
		k = 1;
		for (j = 0; j < key; j++) {
			k = k * pt;
			k = k % n;
		}
		temp[i] = k;
		ct = k + 96;
		en[i] = ct;
		i++;
	}
	end_encrypt = clock();
	time_encrypt_cpu = (double) (end_encrypt - start_encrypt) / CLOCKS_PER_SEC;
	printf("Encryption time taken by CPU: %f s\n", time_encrypt_cpu);
	/*
	 en[i] = -1;
	 printf("\nCPU ENCRYPTED MESSAGE IS\n");
	 for (i = 0; en[i] != -1; i++)
	 printf("%d ", en[i]);
	 */

	printf("Saving CPU encrypted file... ");
	en[i] = -1;
	FILE *fp = fopen("encrypted_cpu.txt", "wb");
	if (fp != NULL) {
		for (int k = 0; en[k] != -1; k++) {
			fprintf(fp, "%d", en[k]);
		}
		fclose(fp);
		printf("done\n\n");
	}
}

void encrypt_gpu() {
	hipEvent_t start_encrypt, stop_encrypt;
	int key = e[0];
	//printf("\nkey=%d, n=%d\n",key,n);
	hipSetDevice(1);
	int *dev_num, *dev_key, *dev_den;
	int *dev_res;
	hipMalloc((void **) &dev_num, numChars * sizeof(int));
	hipMalloc((void **) &dev_key, sizeof(int));
	hipMalloc((void **) &dev_den, sizeof(int));
	hipMalloc((void **) &dev_res, numChars * sizeof(int));
	hipMemcpy(dev_num, mm, numChars * sizeof(int), hipMemcpyHostToDevice);
	hipMemcpy(dev_key, &key, sizeof(int), hipMemcpyHostToDevice);
	hipMemcpy(dev_den, &n, sizeof(int), hipMemcpyHostToDevice);
	hipMemcpy(dev_res, res, numChars * sizeof(int), hipMemcpyHostToDevice);

	hipEventCreate(&start_encrypt);
	hipEventCreate(&stop_encrypt);
	hipEventRecord(start_encrypt);
	printf("GPU starts encrypting...\n");
	rsa<<<blocksPerGrid, threadsPerBlock>>>(dev_num,dev_key,dev_den,dev_res);
	hipEventRecord(stop_encrypt);
	hipEventSynchronize(stop_encrypt);
	hipDeviceSynchronize();
	hipEventElapsedTime(&time_encrypt_gpu, start_encrypt, stop_encrypt);

	hipMemcpy(res, dev_res, numChars * sizeof(int), hipMemcpyDeviceToHost);
	hipFree(dev_num);
	hipFree(dev_key);
	hipFree(dev_den);
	hipFree(dev_res);

	time_encrypt_gpu /= 1000;
	printf("Encryption time taken by GPU: %f s\n", time_encrypt_gpu);

	/*
	 printf("\nGPU ENCRYPTED MESSAGE IS\n");
	 for (i = 0; i < numChars; i++)
	 printf("%d ", res[i]+96);
	 printf("\n");
	 */

	printf("Saving GPU encrypted file... ");
	FILE *fp = fopen("encrypted_gpu.txt", "wb");
	if (fp != NULL) {
		for (i = 0; i < numChars; i++) {
			fprintf(fp, "%d", res[i] + 96);
		}
		fclose(fp);
		printf("done\n\n");
	}
}

void decrypt_gpu() {
	hipEvent_t start_decrypt, stop_decrypt;
	int key = d[0];
	//printf("\nkey=%d, n=%d\n",key,n);
	hipSetDevice(1);
	int *dev_num, *dev_key, *dev_den;
	int *dev_res;
	hipMalloc((void **) &dev_num, numChars * sizeof(int));
	hipMalloc((void **) &dev_key, sizeof(int));
	hipMalloc((void **) &dev_den, sizeof(int));
	hipMalloc((void **) &dev_res, numChars * sizeof(int));
	hipMemcpy(dev_num, res, numChars * sizeof(int), hipMemcpyHostToDevice);
	hipMemcpy(dev_key, &key, sizeof(int), hipMemcpyHostToDevice);
	hipMemcpy(dev_den, &n, sizeof(int), hipMemcpyHostToDevice);
	hipMemcpy(dev_res, res, numChars * sizeof(int), hipMemcpyHostToDevice);

	hipEventCreate(&start_decrypt);
	hipEventCreate(&stop_decrypt);
	hipEventRecord(start_decrypt);
	printf("GPU starts decrypting...\n");
	rsa<<<blocksPerGrid, threadsPerBlock>>>(dev_num,dev_key,dev_den,dev_res);
	hipEventRecord(stop_decrypt);
	hipEventSynchronize(stop_decrypt);
	hipDeviceSynchronize();
	hipEventElapsedTime(&time_decrypt_gpu, start_decrypt, stop_decrypt);

	hipMemcpy(res, dev_res, numChars * sizeof(int), hipMemcpyDeviceToHost);
	hipFree(dev_num);
	hipFree(dev_key);
	hipFree(dev_den);
	hipFree(dev_res);

	time_decrypt_gpu /= 1000;
	printf("Decryption time taken by GPU: %f s\n", time_decrypt_gpu);

	/*
	 printf("\nGPU DECRYPTED MESSAGE IS\n");
	 for (i = 0; i < numChars; i++)
	 printf("%d ", res[i]+96);
	 printf("\n");
	 */

	printf("Saving GPU decrypted file... ");
	FILE *fp = fopen("decrypted_gpu.txt", "wb");
	if (fp != NULL) {
		for (i = 0; i < numChars; i++) {
			fprintf(fp, "%c", res[i] + 96);
		}
		fprintf(fp, "\n");
		fclose(fp);
		printf("done\n\n");
	}
}

void decrypt() {
	double start_decrypt, end_decrypt;
	start_decrypt = clock();
	printf("CPU starts decrypting...\n");
	long int pt, ct, key = d[0], k;
	printf("\nd=%d\n",key);
	i = 0;
	while (en[i] != -1) {
		ct = temp[i];
		k = 1;
		for (j = 0; j < key; j++) {
			k = k * ct;
			k = k % n;
		}
		pt = k + 96;
		m[i] = pt;
		i++;
	}
	end_decrypt = clock();
	time_decrypt_cpu = (double) (end_decrypt - start_decrypt) / CLOCKS_PER_SEC;
	printf("Decryption time taken by CPU: %f s\n", time_decrypt_cpu);

	/*
	 m[i] = -1;
	 printf("\nCPU DECRYPTED MESSAGE IS\n");
	 for (i = 0; m[i] != -1; i++)
	 printf("%d ", m[i]);
	 printf("\n");
	 */

	printf("Saving CPU decrypted file... ");
	m[i] = -1;
	FILE *fp = fopen("decrypted_cpu.txt", "wb");
	if (fp != NULL) {
		for (int k = 0; m[k] != -1; k++) {
			fprintf(fp, "%c", m[k]);
		}
		fprintf(fp, "\n");
		fclose(fp);
		printf("done\n\n");
	}
}

	.text
	.file	"RSA.hip"
	.globl	_Z18__device_stub__rsaPiS_S_S_  # -- Begin function _Z18__device_stub__rsaPiS_S_S_
	.type	_Z18__device_stub__rsaPiS_S_S_,@function
_Z18__device_stub__rsaPiS_S_S_:         # @_Z18__device_stub__rsaPiS_S_S_
	.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	$_Z3rsaPiS_S_S_, %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_end0:
	.size	_Z18__device_stub__rsaPiS_S_S_, .Lfunc_end0-_Z18__device_stub__rsaPiS_S_S_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	$157, p(%rip)
	movl	$373, q(%rip)                   # imm = 0x175
	movl	$tt, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	movl	$10000, %edi                    # imm = 0x2710
	callq	_Z14generate_inputi
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_1
# %bb.2:
	movq	%rax, %rbx
	movl	$msg, %edi
	movl	$10002, %esi                    # imm = 0x2712
	movq	%rax, %rdx
	callq	fgets
	testq	%rax, %rax
	je	.LBB1_4
# %bb.3:
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
.LBB1_4:
	movq	%rbx, %rdi
	callq	fclose
	movl	$msg, %edi
	callq	strlen
	decl	%eax
	movl	%eax, numChars(%rip)
	movslq	%eax, %rsi
	movb	$0, msg(%rsi)
	xorl	%ebx, %ebx
	movl	$.L.str.4, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
	movl	numChars(%rip), %eax
	movl	threadsPerBlock(%rip), %ecx
	addl	%ecx, %eax
	decl	%eax
	cltd
	idivl	%ecx
	movl	%eax, blocksPerGrid(%rip)
	movb	msg(%rip), %cl
	movl	$0, %eax
	testb	%cl, %cl
	je	.LBB1_7
# %bb.5:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB1_6:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsbl	%cl, %ecx
	movl	%ecx, m(,%rax,4)
	addl	$-96, %ecx
	movl	%ecx, mm(,%rax,4)
	movb	msg+1(%rax), %cl
	incq	%rax
	testb	%cl, %cl
	jne	.LBB1_6
.LBB1_7:                                # %._crit_edge
	movl	%eax, i(%rip)
	movl	p(%rip), %eax
	movl	q(%rip), %ecx
	movl	%ecx, %edx
	imull	%eax, %edx
	movl	%edx, n(%rip)
	decl	%eax
	decl	%ecx
	imull	%eax, %ecx
	movl	%ecx, t(%rip)
	callq	_Z2cev
	callq	_Z7encryptv
	callq	_Z7decryptv
	callq	_Z11encrypt_gpuv
	callq	_Z11decrypt_gpuv
	movsd	time_encrypt_cpu(%rip), %xmm0   # xmm0 = mem[0],zero
	cvtss2sd	time_encrypt_gpu(%rip), %xmm1
	divsd	%xmm1, %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	movsd	time_decrypt_cpu(%rip), %xmm0   # xmm0 = mem[0],zero
	xorps	%xmm1, %xmm1
	cvtss2sd	time_decrypt_gpu(%rip), %xmm1
	divsd	%xmm1, %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
.LBB1_8:
	movl	%ebx, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB1_1:
	.cfi_def_cfa_offset 16
	movl	$.L.str.2, %edi
	callq	perror
	movl	$1, %ebx
	jmp	.LBB1_8
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z14generate_inputi             # -- Begin function _Z14generate_inputi
	.type	_Z14generate_inputi,@function
_Z14generate_inputi:                    # @_Z14generate_inputi
	.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
	movl	%edi, %ebx
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str, %edi
	movl	$.L.str.8, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB2_4
# %bb.1:                                # %.preheader
	movq	%rax, %r14
	testl	%ebx, %ebx
	jle	.LBB2_3
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1321528399, %rax, %rcx         # imm = 0x4EC4EC4F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$35, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,4), %edx
	leal	(%rdx,%rdx,4), %edx
	addl	%ecx, %edx
	negl	%edx
	leal	(%rax,%rdx), %edi
	addl	$97, %edi
	movq	%r14, %rsi
	callq	fputc@PLT
	decl	%ebx
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	movl	$10, %edi
	movq	%r14, %rsi
	callq	fputc@PLT
	movq	%r14, %rdi
	callq	fclose
	movl	$.Lstr, %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
.LBB2_4:
	.cfi_def_cfa_offset 32
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z14generate_inputi, .Lfunc_end2-_Z14generate_inputi
	.cfi_endproc
                                        # -- End function
	.globl	_Z2cev                          # -- Begin function _Z2cev
	.type	_Z2cev,@function
_Z2cev:                                 # @_Z2cev
	.cfi_startproc
# %bb.0:
	movl	$2, i(%rip)
	movl	t(%rip), %ecx
	cmpl	$3, %ecx
	jl	.LBB3_20
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbp
	.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 %rbp, -16
	movl	$2, %ebp
	xorl	%ebx, %ebx
	xorpd	%xmm1, %xmm1
.LBB3_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_9 Depth 2
                                        #     Child Loop BB3_14 Depth 2
	movl	%ecx, %eax
	cltd
	idivl	%ebp
	testl	%edx, %edx
	je	.LBB3_18
# %bb.3:                                #   in Loop: Header=BB3_2 Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2sd	%ebp, %xmm0
	ucomisd	%xmm1, %xmm0
	jb	.LBB3_5
# %bb.4:                                #   in Loop: Header=BB3_2 Depth=1
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB3_6
.LBB3_5:                                # %call.sqrt
                                        #   in Loop: Header=BB3_2 Depth=1
	callq	sqrt
	xorpd	%xmm1, %xmm1
.LBB3_6:                                # %.split
                                        #   in Loop: Header=BB3_2 Depth=1
	cvttsd2si	%xmm0, %esi
	movl	%esi, j(%rip)
	cmpl	$2, %esi
	jl	.LBB3_11
# %bb.7:                                # %.lr.ph.preheader.i
                                        #   in Loop: Header=BB3_2 Depth=1
	movslq	%ebp, %rcx
	incl	%esi
	movl	$2, %edi
.LBB3_9:                                # %.lr.ph.i
                                        #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	testq	%rdx, %rdx
	je	.LBB3_10
# %bb.8:                                #   in Loop: Header=BB3_9 Depth=2
	incq	%rdi
	cmpq	%rdi, %rsi
	jne	.LBB3_9
.LBB3_11:                               # %.loopexit
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	$1, flag(%rip)
	movl	i(%rip), %ebp
	movl	t(%rip), %ecx
	cmpl	p(%rip), %ebp
	je	.LBB3_18
# %bb.12:                               # %.loopexit
                                        #   in Loop: Header=BB3_2 Depth=1
	cmpl	q(%rip), %ebp
	je	.LBB3_18
# %bb.13:                               #   in Loop: Header=BB3_2 Depth=1
	movslq	%ebp, %r8
	movslq	%ecx, %r9
	movslq	%ebx, %rdi
	movl	%ebp, e(,%rdi,4)
	leaq	1(%r9), %rsi
.LBB3_14:                               #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%rsi, %rax
	cqto
	idivq	%r8
	addq	%r9, %rsi
	testq	%rdx, %rdx
	jne	.LBB3_14
# %bb.15:                               # %_Z2cdl.exit
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	%eax, flag(%rip)
	testl	%eax, %eax
	jle	.LBB3_17
# %bb.16:                               #   in Loop: Header=BB3_2 Depth=1
	movl	%eax, d(,%rdi,4)
	incl	%edi
	movl	%edi, %ebx
.LBB3_17:                               #   in Loop: Header=BB3_2 Depth=1
	cmpl	$99, %ebx
	jne	.LBB3_18
	jmp	.LBB3_19
.LBB3_10:                               # %_Z5primel.exit
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	$0, flag(%rip)
	movl	i(%rip), %ebp
	movl	t(%rip), %ecx
.LBB3_18:                               #   in Loop: Header=BB3_2 Depth=1
	incl	%ebp
	movl	%ebp, i(%rip)
	cmpl	%ecx, %ebp
	jl	.LBB3_2
.LBB3_19:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %rbp
.LBB3_20:                               # %._crit_edge
	retq
.Lfunc_end3:
	.size	_Z2cev, .Lfunc_end3-_Z2cev
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7encryptv
.LCPI4_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z7encryptv
	.type	_Z7encryptv,@function
_Z7encryptv:                            # @_Z7encryptv
	.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
	callq	clock
	cvtsi2sd	%rax, %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	e(%rip), %ebx
	movl	$.L.str.13, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$0, i(%rip)
	movl	numChars(%rip), %ecx
	testq	%rcx, %rcx
	je	.LBB4_8
# %bb.1:                                # %.lr.ph30
	movl	n(%rip), %esi
	xorl	%edi, %edi
.LBB4_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_5 Depth 2
	testl	%ebx, %ebx
	jle	.LBB4_3
# %bb.4:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	m(,%rdi,4), %r8d
	addl	$-96, %r8d
	movl	$1, %edx
	movl	%ebx, %r9d
.LBB4_5:                                # %.lr.ph
                                        #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	imull	%r8d, %edx
	movl	%edx, %eax
	cltd
	idivl	%esi
	decl	%r9d
	jne	.LBB4_5
	jmp	.LBB4_6
.LBB4_3:                                #   in Loop: Header=BB4_2 Depth=1
	movl	$1, %edx
.LBB4_6:                                # %._crit_edge
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	%edx, temp(,%rdi,4)
	addl	$96, %edx
	movl	%edx, en(,%rdi,4)
	incq	%rdi
	cmpq	%rcx, %rdi
	jne	.LBB4_2
# %bb.7:                                # %._crit_edge31
	xorl	%eax, %eax
	testl	%ebx, %ebx
	cmovgl	%ebx, %eax
	movl	%eax, j(%rip)
	movl	%ecx, i(%rip)
.LBB4_8:
	callq	clock
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	subsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	divsd	.LCPI4_0(%rip), %xmm0
	movsd	%xmm0, time_encrypt_cpu(%rip)
	movl	$.L.str.14, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.15, %edi
	xorl	%eax, %eax
	callq	printf
	movslq	i(%rip), %rax
	movl	$-1, en(,%rax,4)
	movl	$.L.str.16, %edi
	movl	$.L.str.8, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB4_13
# %bb.9:                                # %.preheader
	movq	%rax, %rbx
	movl	en(%rip), %edx
	cmpl	$-1, %edx
	je	.LBB4_12
# %bb.10:                               # %.lr.ph34.preheader
	movl	$en+4, %r14d
.LBB4_11:                               # %.lr.ph34
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.17, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	fprintf
	movl	(%r14), %edx
	addq	$4, %r14
	cmpl	$-1, %edx
	jne	.LBB4_11
.LBB4_12:                               # %._crit_edge35
	movq	%rbx, %rdi
	callq	fclose
	movl	$.Lstr.8, %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
.LBB4_13:
	.cfi_def_cfa_offset 32
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z7encryptv, .Lfunc_end4-_Z7encryptv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7decryptv
.LCPI5_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z7decryptv
	.type	_Z7decryptv,@function
_Z7decryptv:                            # @_Z7decryptv
	.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
	callq	clock
	cvtsi2sd	%rax, %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	d(%rip), %ebx
	movslq	%ebx, %rsi
	xorl	%r14d, %r14d
	movl	$.L.str.28, %edi
	xorl	%eax, %eax
	callq	printf
	cmpl	$-1, en(%rip)
	je	.LBB5_8
# %bb.1:                                # %.lr.ph29
	movslq	n(%rip), %rcx
	xorl	%esi, %esi
.LBB5_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_5 Depth 2
	testl	%ebx, %ebx
	jle	.LBB5_3
# %bb.4:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB5_2 Depth=1
	movslq	temp(,%rsi,4), %rdi
	movl	$1, %edx
	movl	%ebx, %r8d
.LBB5_5:                                # %.lr.ph
                                        #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	imulq	%rdi, %rdx
	movq	%rdx, %rax
	cqto
	idivq	%rcx
	decl	%r8d
	jne	.LBB5_5
	jmp	.LBB5_6
.LBB5_3:                                #   in Loop: Header=BB5_2 Depth=1
	movl	$1, %edx
.LBB5_6:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	addl	$96, %edx
	movl	%edx, m(,%rsi,4)
	leaq	1(%rsi), %r14
	cmpl	$-1, en+4(,%rsi,4)
	movq	%r14, %rsi
	jne	.LBB5_2
# %bb.7:                                # %._crit_edge30
	xorl	%eax, %eax
	testl	%ebx, %ebx
	cmovgl	%ebx, %eax
	movl	%eax, j(%rip)
.LBB5_8:
	movl	%r14d, i(%rip)
	callq	clock
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	subsd	(%rsp), %xmm0                   # 8-byte Folded Reload
	divsd	.LCPI5_0(%rip), %xmm0
	movsd	%xmm0, time_decrypt_cpu(%rip)
	movl	$.L.str.29, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.30, %edi
	xorl	%eax, %eax
	callq	printf
	movslq	i(%rip), %rax
	movl	$-1, m(,%rax,4)
	movl	$.L.str.31, %edi
	movl	$.L.str.8, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB5_13
# %bb.9:                                # %.preheader
	movq	%rax, %rbx
	movl	m(%rip), %edi
	cmpl	$-1, %edi
	je	.LBB5_12
# %bb.10:                               # %.lr.ph34.preheader
	movl	$m+4, %r14d
.LBB5_11:                               # %.lr.ph34
                                        # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rsi
	callq	fputc@PLT
	movl	(%r14), %edi
	addq	$4, %r14
	cmpl	$-1, %edi
	jne	.LBB5_11
.LBB5_12:                               # %._crit_edge35
	movl	$10, %edi
	movq	%rbx, %rsi
	callq	fputc@PLT
	movq	%rbx, %rdi
	callq	fclose
	movl	$.Lstr.8, %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
.LBB5_13:
	.cfi_def_cfa_offset 32
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z7decryptv, .Lfunc_end5-_Z7decryptv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z11encrypt_gpuv
.LCPI6_0:
	.long	0x447a0000                      # float 1000
	.text
	.globl	_Z11encrypt_gpuv
	.type	_Z11encrypt_gpuv,@function
_Z11encrypt_gpuv:                       # @_Z11encrypt_gpuv
	.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
	movl	e(%rip), %eax
	leaq	60(%rsp), %rbx
	movl	%eax, (%rbx)
	movl	$1, %edi
	callq	hipSetDevice
	movslq	numChars(%rip), %rsi
	shlq	$2, %rsi
	leaq	40(%rsp), %r13
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	32(%rsp), %r12
	movl	$4, %esi
	movq	%r12, %rdi
	callq	hipMalloc
	leaq	24(%rsp), %r14
	movl	$4, %esi
	movq	%r14, %rdi
	callq	hipMalloc
	movslq	numChars(%rip), %rsi
	shlq	$2, %rsi
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	callq	hipMalloc
	movq	(%r13), %rdi
	movslq	numChars(%rip), %rdx
	shlq	$2, %rdx
	movl	$mm, %esi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	movl	$4, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r14), %rdi
	movl	$n, %esi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r15), %rdi
	movslq	numChars(%rip), %rdx
	shlq	$2, %rdx
	movl	$res, %esi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	48(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	movq	(%rbx), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	blocksPerGrid(%rip), %edi
	movl	threadsPerBlock(%rip), %edx
	btsq	$32, %rdi
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_2
# %bb.1:
	movq	40(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	8(%rsp), %rcx
	callq	_Z18__device_stub__rsaPiS_S_S_
.LBB6_2:
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	callq	hipDeviceSynchronize
	movq	48(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	$time_encrypt_gpu, %edi
	callq	hipEventElapsedTime
	movq	8(%rsp), %rsi
	movslq	numChars(%rip), %rdx
	shlq	$2, %rdx
	movl	$res, %edi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movss	time_encrypt_gpu(%rip), %xmm0   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI6_0(%rip), %xmm0
	movss	%xmm0, time_encrypt_gpu(%rip)
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.20, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.21, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.22, %edi
	movl	$.L.str.8, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB6_7
# %bb.3:                                # %.preheader
	movq	%rax, %rbx
	movl	$0, i(%rip)
	cmpl	$0, numChars(%rip)
	jle	.LBB6_6
# %bb.4:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB6_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	cltq
	movl	res(,%rax,4), %edx
	addl	$96, %edx
	movl	$.L.str.17, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	fprintf
	movl	i(%rip), %eax
	incl	%eax
	movl	%eax, i(%rip)
	cmpl	numChars(%rip), %eax
	jl	.LBB6_5
.LBB6_6:                                # %._crit_edge
	movq	%rbx, %rdi
	callq	fclose
	movl	$.Lstr.8, %edi
	callq	puts@PLT
.LBB6_7:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	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_end6:
	.size	_Z11encrypt_gpuv, .Lfunc_end6-_Z11encrypt_gpuv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z11decrypt_gpuv
.LCPI7_0:
	.long	0x447a0000                      # float 1000
	.text
	.globl	_Z11decrypt_gpuv
	.type	_Z11decrypt_gpuv,@function
_Z11decrypt_gpuv:                       # @_Z11decrypt_gpuv
	.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
	movl	d(%rip), %eax
	leaq	60(%rsp), %rbx
	movl	%eax, (%rbx)
	movl	$1, %edi
	callq	hipSetDevice
	movslq	numChars(%rip), %rsi
	shlq	$2, %rsi
	leaq	40(%rsp), %r13
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	32(%rsp), %r12
	movl	$4, %esi
	movq	%r12, %rdi
	callq	hipMalloc
	leaq	24(%rsp), %r14
	movl	$4, %esi
	movq	%r14, %rdi
	callq	hipMalloc
	movslq	numChars(%rip), %rsi
	shlq	$2, %rsi
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	callq	hipMalloc
	movq	(%r13), %rdi
	movslq	numChars(%rip), %rdx
	shlq	$2, %rdx
	movl	$res, %esi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	movl	$4, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r14), %rdi
	movl	$n, %esi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r15), %rdi
	movslq	numChars(%rip), %rdx
	shlq	$2, %rdx
	movl	$res, %esi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	48(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	movq	(%rbx), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	$.Lstr.7, %edi
	callq	puts@PLT
	movl	blocksPerGrid(%rip), %edi
	movl	threadsPerBlock(%rip), %edx
	btsq	$32, %rdi
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_2
# %bb.1:
	movq	40(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	8(%rsp), %rcx
	callq	_Z18__device_stub__rsaPiS_S_S_
.LBB7_2:
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	callq	hipDeviceSynchronize
	movq	48(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	$time_decrypt_gpu, %edi
	callq	hipEventElapsedTime
	movq	8(%rsp), %rsi
	movslq	numChars(%rip), %rdx
	shlq	$2, %rdx
	movl	$res, %edi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movss	time_decrypt_gpu(%rip), %xmm0   # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI7_0(%rip), %xmm0
	movss	%xmm0, time_decrypt_gpu(%rip)
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.24, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.25, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.26, %edi
	movl	$.L.str.8, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB7_7
# %bb.3:                                # %.preheader
	movq	%rax, %rbx
	movl	$0, i(%rip)
	cmpl	$0, numChars(%rip)
	jle	.LBB7_6
# %bb.4:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB7_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	cltq
	movl	res(,%rax,4), %edi
	addl	$96, %edi
	movq	%rbx, %rsi
	callq	fputc@PLT
	movl	i(%rip), %eax
	incl	%eax
	movl	%eax, i(%rip)
	cmpl	numChars(%rip), %eax
	jl	.LBB7_5
.LBB7_6:                                # %._crit_edge
	movl	$10, %edi
	movq	%rbx, %rsi
	callq	fputc@PLT
	movq	%rbx, %rdi
	callq	fclose
	movl	$.Lstr.8, %edi
	callq	puts@PLT
.LBB7_7:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	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_end7:
	.size	_Z11decrypt_gpuv, .Lfunc_end7-_Z11decrypt_gpuv
	.cfi_endproc
                                        # -- End function
	.globl	_Z5primel                       # -- Begin function _Z5primel
	.type	_Z5primel,@function
_Z5primel:                              # @_Z5primel
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	cvtsi2sd	%rdi, %xmm0
	xorpd	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	jb	.LBB8_2
# %bb.1:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB8_3
.LBB8_2:                                # %call.sqrt
	callq	sqrt
.LBB8_3:                                # %.split
	cvttsd2si	%xmm0, %esi
	movl	%esi, j(%rip)
	movl	$1, %ecx
	cmpl	$2, %esi
	jl	.LBB8_8
# %bb.4:                                # %.lr.ph.preheader
	incl	%esi
	movl	$2, %edi
.LBB8_6:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rax
	cqto
	idivq	%rdi
	testq	%rdx, %rdx
	je	.LBB8_7
# %bb.5:                                #   in Loop: Header=BB8_6 Depth=1
	incq	%rdi
	cmpq	%rdi, %rsi
	jne	.LBB8_6
	jmp	.LBB8_8
.LBB8_7:
	xorl	%ecx, %ecx
.LBB8_8:                                # %._crit_edge
	movl	%ecx, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z5primel, .Lfunc_end8-_Z5primel
	.cfi_endproc
                                        # -- End function
	.globl	_Z2cdl                          # -- Begin function _Z2cdl
	.type	_Z2cdl,@function
_Z2cdl:                                 # @_Z2cdl
	.cfi_startproc
# %bb.0:
	movslq	t(%rip), %rsi
	leaq	1(%rsi), %rcx
.LBB9_1:                                # =>This Inner Loop Header: Depth=1
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	addq	%rsi, %rcx
	testq	%rdx, %rdx
	jne	.LBB9_1
# %bb.2:
	retq
.Lfunc_end9:
	.size	_Z2cdl, .Lfunc_end9-_Z2cdl
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z3rsaPiS_S_S_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z3rsaPiS_S_S_,@object          # @_Z3rsaPiS_S_S_
	.section	.rodata,"a",@progbits
	.globl	_Z3rsaPiS_S_S_
	.p2align	3, 0x0
_Z3rsaPiS_S_S_:
	.quad	_Z18__device_stub__rsaPiS_S_S_
	.size	_Z3rsaPiS_S_S_, 8

	.type	p,@object                       # @p
	.bss
	.globl	p
	.p2align	2, 0x0
p:
	.long	0                               # 0x0
	.size	p, 4

	.type	q,@object                       # @q
	.globl	q
	.p2align	2, 0x0
q:
	.long	0                               # 0x0
	.size	q, 4

	.type	n,@object                       # @n
	.globl	n
	.p2align	2, 0x0
n:
	.long	0                               # 0x0
	.size	n, 4

	.type	t,@object                       # @t
	.globl	t
	.p2align	2, 0x0
t:
	.long	0                               # 0x0
	.size	t, 4

	.type	flag,@object                    # @flag
	.globl	flag
	.p2align	2, 0x0
flag:
	.long	0                               # 0x0
	.size	flag, 4

	.type	e,@object                       # @e
	.globl	e
	.p2align	4, 0x0
e:
	.zero	400
	.size	e, 400

	.type	d,@object                       # @d
	.globl	d
	.p2align	4, 0x0
d:
	.zero	400
	.size	d, 400

	.type	temp,@object                    # @temp
	.globl	temp
	.p2align	4, 0x0
temp:
	.zero	40008
	.size	temp, 40008

	.type	j,@object                       # @j
	.globl	j
	.p2align	2, 0x0
j:
	.long	0                               # 0x0
	.size	j, 4

	.type	m,@object                       # @m
	.globl	m
	.p2align	4, 0x0
m:
	.zero	40008
	.size	m, 40008

	.type	en,@object                      # @en
	.globl	en
	.p2align	4, 0x0
en:
	.zero	40008
	.size	en, 40008

	.type	mm,@object                      # @mm
	.globl	mm
	.p2align	4, 0x0
mm:
	.zero	40008
	.size	mm, 40008

	.type	res,@object                     # @res
	.globl	res
	.p2align	4, 0x0
res:
	.zero	40008
	.size	res, 40008

	.type	i,@object                       # @i
	.globl	i
	.p2align	2, 0x0
i:
	.long	0                               # 0x0
	.size	i, 4

	.type	msg,@object                     # @msg
	.globl	msg
	.p2align	4, 0x0
msg:
	.zero	10002
	.size	msg, 10002

	.type	numChars,@object                # @numChars
	.globl	numChars
	.p2align	2, 0x0
numChars:
	.long	0                               # 0x0
	.size	numChars, 4

	.type	threadsPerBlock,@object         # @threadsPerBlock
	.data
	.globl	threadsPerBlock
	.p2align	2, 0x0
threadsPerBlock:
	.long	1024                            # 0x400
	.size	threadsPerBlock, 4

	.type	blocksPerGrid,@object           # @blocksPerGrid
	.bss
	.globl	blocksPerGrid
	.p2align	2, 0x0
blocksPerGrid:
	.long	0                               # 0x0
	.size	blocksPerGrid, 4

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

	.type	time_encrypt_cpu,@object        # @time_encrypt_cpu
	.globl	time_encrypt_cpu
	.p2align	3, 0x0
time_encrypt_cpu:
	.quad	0x0000000000000000              # double 0
	.size	time_encrypt_cpu, 8

	.type	time_decrypt_cpu,@object        # @time_decrypt_cpu
	.globl	time_decrypt_cpu
	.p2align	3, 0x0
time_decrypt_cpu:
	.quad	0x0000000000000000              # double 0
	.size	time_decrypt_cpu, 8

	.type	time_encrypt_gpu,@object        # @time_encrypt_gpu
	.globl	time_encrypt_gpu
	.p2align	2, 0x0
time_encrypt_gpu:
	.long	0x00000000                      # float 0
	.size	time_encrypt_gpu, 4

	.type	time_decrypt_gpu,@object        # @time_decrypt_gpu
	.globl	time_decrypt_gpu
	.p2align	2, 0x0
time_decrypt_gpu:
	.long	0x00000000                      # float 0
	.size	time_decrypt_gpu, 4

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"input.txt"
	.size	.L.str, 10

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Error opening file"
	.size	.L.str.2, 19

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Reading input file...done("
	.size	.L.str.3, 27

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"numChars: %d)\n\n"
	.size	.L.str.4, 16

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"GPU encryption speed up: %f\n"
	.size	.L.str.5, 29

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"GPU decryption speed up: %f\n\n"
	.size	.L.str.6, 30

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"\nGenerating input file... "
	.size	.L.str.7, 27

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"wb"
	.size	.L.str.8, 3

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"\ne=%d\n"
	.size	.L.str.13, 7

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Encryption time taken by CPU: %f s\n"
	.size	.L.str.14, 36

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Saving CPU encrypted file... "
	.size	.L.str.15, 30

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"encrypted_cpu.txt"
	.size	.L.str.16, 18

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"%d"
	.size	.L.str.17, 3

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Encryption time taken by GPU: %f s\n"
	.size	.L.str.20, 36

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"Saving GPU encrypted file... "
	.size	.L.str.21, 30

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"encrypted_gpu.txt"
	.size	.L.str.22, 18

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"Decryption time taken by GPU: %f s\n"
	.size	.L.str.24, 36

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"Saving GPU decrypted file... "
	.size	.L.str.25, 30

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"decrypted_gpu.txt"
	.size	.L.str.26, 18

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"\nd=%d\n"
	.size	.L.str.28, 7

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"Decryption time taken by CPU: %f s\n"
	.size	.L.str.29, 36

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"Saving CPU decrypted file... "
	.size	.L.str.30, 30

	.type	.L.str.31,@object               # @.str.31
.L.str.31:
	.asciz	"decrypted_cpu.txt"
	.size	.L.str.31, 18

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z3rsaPiS_S_S_"
	.size	.L__unnamed_1, 15

	.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,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"done"
	.size	.Lstr, 5

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"CPU starts encrypting..."
	.size	.Lstr.1, 25

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"CPU starts decrypting..."
	.size	.Lstr.3, 25

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"GPU starts encrypting..."
	.size	.Lstr.5, 25

	.type	.Lstr.7,@object                 # @str.7
.Lstr.7:
	.asciz	"GPU starts decrypting..."
	.size	.Lstr.7, 25

	.type	.Lstr.8,@object                 # @str.8
.Lstr.8:
	.asciz	"done\n"
	.size	.Lstr.8, 6

	.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 _Z18__device_stub__rsaPiS_S_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z3rsaPiS_S_S_
	.addrsig_sym n
	.addrsig_sym mm
	.addrsig_sym res
	.addrsig_sym msg
	.addrsig_sym tt
	.addrsig_sym time_encrypt_gpu
	.addrsig_sym time_decrypt_gpu
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z3rsaPiS_S_S_          ; -- Begin function _Z3rsaPiS_S_S_
	.globl	_Z3rsaPiS_S_S_
	.p2align	8
	.type	_Z3rsaPiS_S_S_,@function
_Z3rsaPiS_S_S_:                         ; @_Z3rsaPiS_S_S_
; %bb.0:
	s_clause 0x1
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b32 s0, s[0:1], 0x2c
	s_waitcnt lgkmcnt(0)
	s_load_b32 s6, s[6:7], 0x0
	s_and_b32 s0, s0, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s0, v[0:1]
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s6, 1
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph.i
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	s_load_b32 s4, s[8:9], 0x0
	global_load_b32 v4, v[2:3], off
	v_mov_b32_e32 v2, 1
	v_mov_b32_e32 v3, 0
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s5, s4, 31
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v5, 31, v4
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_add_u32 s2, s4, s5
	s_mov_b32 s0, s5
	s_mov_b32 s1, s5
	s_addc_u32 s3, s5, s5
	v_mul_lo_u32 v3, v3, v4
	s_xor_b64 s[2:3], s[2:3], s[0:1]
	v_mul_lo_u32 v8, v2, v5
	v_mad_u64_u32 v[6:7], null, v2, v4, 0
	v_cvt_f32_u32_e32 v2, s2
	v_cvt_f32_u32_e32 v9, s3
	s_sub_u32 s0, 0, s2
	s_subb_u32 s1, 0, s3
	s_add_i32 s6, s6, -1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_fmac_f32_e32 v2, 0x4f800000, v9
	v_add3_u32 v3, v7, v8, v3
	s_cmp_lg_u32 s6, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v2, v2
	v_ashrrev_i32_e32 v10, 31, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_u32 v6, vcc_lo, v6, v10
	v_add_co_ci_u32_e32 v3, vcc_lo, v3, v10, vcc_lo
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v2, 0x5f7ffffc, v2
	v_xor_b32_e32 v12, v6, v10
	v_xor_b32_e32 v11, v3, v10
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v3, 0x2f800000, v2
	v_trunc_f32_e32 v3, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fmac_f32_e32 v2, 0xcf800000, v3
	v_cvt_u32_f32_e32 v3, v3
	v_cvt_u32_f32_e32 v2, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v6, s0, v3
	v_mul_hi_u32 v7, s0, v2
	v_mul_lo_u32 v9, s1, v2
	v_mul_lo_u32 v8, s0, v2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v6, v7, v6
	v_mul_hi_u32 v7, v2, v8
	v_mul_hi_u32 v13, v3, v8
	v_mul_lo_u32 v8, v3, v8
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v6, v6, v9
	v_mul_lo_u32 v9, v2, v6
	v_mul_hi_u32 v14, v2, v6
	v_mul_hi_u32 v15, v3, v6
	v_mul_lo_u32 v6, v3, v6
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v7, vcc_lo, v7, v9
	v_add_co_ci_u32_e32 v9, vcc_lo, 0, v14, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v7, vcc_lo, v7, v8
	v_add_co_ci_u32_e32 v7, vcc_lo, v9, v13, vcc_lo
	v_add_co_ci_u32_e32 v8, vcc_lo, 0, v15, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, v7, v6
	v_add_co_ci_u32_e32 v7, vcc_lo, 0, v8, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, v2, v6
	v_add_co_ci_u32_e32 v3, vcc_lo, v3, v7, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_hi_u32 v7, s0, v2
	v_mul_lo_u32 v8, s1, v2
	v_mul_lo_u32 v9, s0, v3
	v_mul_lo_u32 v6, s0, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v7, v7, v9
	v_mul_hi_u32 v13, v3, v6
	v_mul_lo_u32 v14, v3, v6
	v_mul_hi_u32 v6, v2, v6
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v7, v7, v8
	v_mul_lo_u32 v8, v2, v7
	v_mul_hi_u32 v9, v2, v7
	v_mul_hi_u32 v15, v3, v7
	v_mul_lo_u32 v7, v3, v7
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v6, vcc_lo, v6, v8
	v_add_co_ci_u32_e32 v8, vcc_lo, 0, v9, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, v6, v14
	v_add_co_ci_u32_e32 v6, vcc_lo, v8, v13, vcc_lo
	v_add_co_ci_u32_e32 v8, vcc_lo, 0, v15, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, v6, v7
	v_add_co_ci_u32_e32 v7, vcc_lo, 0, v8, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, v2, v6
	v_add_co_ci_u32_e32 v13, vcc_lo, v3, v7, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_hi_u32 v14, v12, v6
	v_mad_u64_u32 v[2:3], null, v11, v6, 0
	v_mad_u64_u32 v[6:7], null, v12, v13, 0
	v_mad_u64_u32 v[8:9], null, v11, v13, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v6, vcc_lo, v14, v6
	v_add_co_ci_u32_e32 v7, vcc_lo, 0, v7, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, v6, v2
	v_add_co_ci_u32_e32 v2, vcc_lo, v7, v3, vcc_lo
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v9, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, v2, v8
	v_add_co_ci_u32_e32 v7, vcc_lo, 0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_lo_u32 v8, s3, v6
	v_mad_u64_u32 v[2:3], null, s2, v6, 0
	v_mul_lo_u32 v6, s2, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_co_u32 v2, vcc_lo, v12, v2
	v_add3_u32 v3, v3, v6, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v6, v11, v3
	v_subrev_co_ci_u32_e64 v6, s0, s3, v6, vcc_lo
	v_sub_co_ci_u32_e32 v3, vcc_lo, v11, v3, vcc_lo
	v_cmp_le_u32_e32 vcc_lo, s2, v2
	v_sub_co_u32 v7, s0, v2, s2
	v_cndmask_b32_e64 v8, 0, -1, vcc_lo
	v_subrev_co_ci_u32_e64 v9, vcc_lo, 0, v6, s0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_le_u32_e32 vcc_lo, s2, v7
	v_cmp_eq_u32_e64 s1, s3, v9
	v_cndmask_b32_e64 v11, 0, -1, vcc_lo
	v_subrev_co_ci_u32_e64 v6, vcc_lo, s3, v6, s0
	v_cmp_le_u32_e64 s0, s3, v3
	v_sub_co_u32 v12, vcc_lo, v7, s2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_subrev_co_ci_u32_e32 v6, vcc_lo, 0, v6, vcc_lo
	v_cndmask_b32_e64 v13, 0, -1, s0
	v_cmp_le_u32_e64 s0, s3, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v14, 0, -1, s0
	v_cmp_eq_u32_e64 s0, s3, v3
	v_cndmask_b32_e64 v11, v14, v11, s1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v8, v13, v8, s0
	v_cmp_ne_u32_e32 vcc_lo, 0, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_ne_u32_e64 s0, 0, v8
	v_dual_cndmask_b32 v7, v7, v12 :: v_dual_cndmask_b32 v6, v9, v6
	v_cndmask_b32_e64 v2, v2, v7, s0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v3, v3, v6, s0
	v_xor_b32_e32 v2, v2, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_xor_b32_e32 v3, v3, v10
	v_sub_co_u32 v2, vcc_lo, v2, v10
	s_delay_alu instid0(VALU_DEP_2)
	v_sub_co_ci_u32_e32 v3, vcc_lo, v3, v10, vcc_lo
	s_cbranch_scc1 .LBB0_2
	s_branch .LBB0_4
.LBB0_3:
	v_mov_b32_e32 v2, 1
.LBB0_4:                                ; %_Z3modiii.exit
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s10, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s11, v1, vcc_lo
	global_atomic_swap_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z3rsaPiS_S_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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 16
		.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	_Z3rsaPiS_S_S_, .Lfunc_end0-_Z3rsaPiS_S_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1076
; NumSgprs: 18
; NumVgprs: 16
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 16
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z3rsaPiS_S_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z3rsaPiS_S_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     16
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
