//#include "utils.cuh"
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <sys/time.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define BLOCKSIZE 1


struct MatrixStorage {
    int *row_ptr;
    int row_size;

    int *col_ind;
    int col_size;

    double *values;
    int val_size;
};

__host__ int* allocateArray(int size);
__host__ double* allocateDoubleArray(int size);

__host__ void initializeDoubleArray(double* arr, int size, double initalizer);
__host__ void initializeArray(int* arr, int size, int initalizer);
//void allocateMatrixStorage(struct MatrixStorage* matrixOut, int rows,int values);
__host__ void allocateMatrixStorage(int** row_ptr, int **col_ind,double **values, int row_size, int col_size, int val_size);
__host__  void initializeMatrixStorage(int **row_ptr, int **col_ind,double **values, int row_size, int col_size, int val_size);
__host__ void readMatrix(int **row_ptr, int **col_ind,double **values,
            int &row_size, int &col_size, int &val_size, char *filename);
__host__ void accumulateCounts(int* arr,int size,int val);
__host__ void printArray(int* arr, int size);
__host__ void printDoubleArray(double* arr, int size);
__host__ void matrix_vector_multip(int *row_ptr, int *col_ind, 
            double *values, int rows,int columns, double **x );

__host__ int* allocateArray(int size){
    int *arr;
    arr = (int *)malloc(sizeof(int) * size);
    return arr;
}
  
__host__ double* allocateDoubleArray(int size){
    double *arr;
    arr = (double *)malloc(sizeof(double) * size);
    return arr;
}

__host__ void initializeArray(int* arr, int size, int initalizer){
    int i;
    for (i = 0; i < size; i++){
        arr[i] = initalizer;
    }
}
__host__ void initializeDoubleArray(double* arr, int size, double initalizer){
    int i;
    for (i = 0; i < size; i++){
        arr[i] = initalizer;
    }
}

__host__ void allocateMatrixStorage(int** row_ptr, int **col_ind,double **values, int row_size,int col_size,int val_size){
    *row_ptr =  allocateArray(row_size);
    *col_ind =  allocateArray(val_size);
    *values =  allocateDoubleArray(val_size);
}

__host__ void initializeMatrixStorage(int** row_ptr, int **col_ind,double **values, int row_size,int col_size,int val_size){ 
    initializeArray(*row_ptr, row_size, 0);
    initializeArray(*col_ind, val_size, val_size);
    initializeDoubleArray(*values, val_size, (double) val_size);
}

__host__  void readMatrix(int **row_ptr, int **col_ind,double **values,
            int &row_size, int &col_size, int &val_size, char *filename){
   
    FILE * fileToRead;
    int  i;
    int row_index,col_index;
    double val;

    
    fileToRead = fopen(filename,"r");             //opens the file

    if (fileToRead == NULL){
         printf("file cant be found\n");
         return ;
    }else{
    
        fscanf(fileToRead,"%d %d %d", &(row_size), &(col_size), &(val_size));
        allocateMatrixStorage( row_ptr, col_ind, values, row_size,col_size,val_size);
        initializeMatrixStorage(row_ptr, col_ind, values,row_size,col_size, val_size);

        for (i = 0; i < val_size; i++)
        {   
            fscanf(fileToRead,"%d %d %lg", &row_index, &col_index, &val);
            //if (row_index == 5)
            //printf("%d,%d\n", row_ptr[row_index-1],row_index);
            (*row_ptr)[row_index-1] =  (*row_ptr)[row_index-1] + 1;	
            (*values)[i] = val;
            (*col_ind)[i] = col_index -1;
        } 
        //printf("\n");
    }
    fclose(fileToRead);
}

__host__ void accumulateCounts(int* arr,int size,int val){
    int i;
   
    if (arr[size-1] == 0){
        arr[size-1] = val;
    }
    else{
         arr[size-1] = val - arr[size-1];
    }
    
    for (i = size-2; i >=0; i--){
        if (arr[i] == 0)
            arr[i] = arr[i+1];
        else {
            arr[i] = arr[i+1] - arr[i];
        }
    }
}

__host__ void printArray(int* arr, int size){
     
    int i;
    for (i = 0; i < size; i++){
        printf("%d\n", arr[i]);
    }
    printf("\n");
}

__host__ void printDoubleArray(double* arr, int size){
    int i;
    for (i = 0; i < size; i++){
        printf("%lf\n", arr[i]);
    }
    printf("\n");
}

__host__ void matrix_vector_multip(int *row_ptr, int *col_ind, 
            double *values, int rows,int columns, double **x ){
    int i,j;
    double val = 0.0;
    
    double *newArr = allocateDoubleArray(rows);
    initializeDoubleArray(newArr,rows,0.0);
    
    double *tmpX = *x;

    for (i = 0; i < rows-1; i++){
        if (row_ptr[i] != row_ptr[i+1]){
            for (j = row_ptr[i]; j < row_ptr[i+1];j++){
                val = val + tmpX[col_ind[j]]*values[j];
            }
            newArr[i] = val;
        } else {
            newArr[i] = 0.0;
        }
        val = 0.0;
    }
    
    //printArray(col_ind,columns);
    i = rows -1;
    if (row_ptr[i] < rows){
        for (j = row_ptr[i]; j < columns;j++){
            
            val = val + tmpX[col_ind[j]]*values[j];
        }
        newArr[i] = val;
        
    }else {
        newArr[i] = 0.0;
    }
    val = 0.0;
    
    *x = newArr;
    newArr = NULL;
    free(tmpX);
}
__global__ void initializeDoubleArrayDev(double* arr, int size, double initalizer){
    int i;
    for (i = 0; i < size; i++){
        arr[i] = initalizer;
    }
}

__global__ void matrix_vector_multip_dev(int *row_ptr, int *col_ind, 
            double *values, int *rowsArr,int *columnsArr, double *x, double *newArr,int *single_block_size ){
    int block_size = single_block_size[0];
    int x_tid = blockIdx.x*blockDim.x + threadIdx.x;
    int y_tid = blockIdx.y*blockDim.y + threadIdx.y;
    int thread_index = x_tid + gridDim.x*block_size*y_tid;       
    

    int j;
    int rows = rowsArr[0];
    int columns = columnsArr[0];
    double val = 0.0;
    int ofset = rows * thread_index; 

    if (thread_index < rows){
        newArr[thread_index] = 0.0;
    }
    if (thread_index < rows -1 ){
        if (row_ptr[thread_index] != row_ptr[thread_index+1]){
            for (j = row_ptr[thread_index]; j < row_ptr[thread_index+1];j++){
                    val = val + x[col_ind[j]] *values[j];
            }
            newArr[thread_index] += val;
        }else {
            newArr[thread_index] += 0.0;
        }
    } else {
        if (thread_index == rows -1 && row_ptr[thread_index] < rows){
            for (j = row_ptr[thread_index]; j < columns;j++){
                val = val + x[col_ind[j]] *values[ofset + j];
            }
            newArr[thread_index] += val;
        }else {
            newArr[thread_index] += 0.0;
        }
    }

   
   __syncthreads();
    
}


int main(int argc, char** argv){

    int noThreads,number_of_iter,print_what;
    char *filename;

    if (argc < 5){
        printf("Please enter the all the following arguments:\n");
        printf("1. The number of threads used to compute Matrix-vector product\n");
        printf("2. The number of repetitions \n");
        printf("3. An argument to print on stdout \n");
        printf("4. Test-file name\n");
        exit(1);
    }else {
        noThreads = atoi(argv[1]);
        number_of_iter = atoi(argv[2]);
        print_what =  atoi(argv[3]);
        filename = argv[4];
    } 

    int *d_rowptr, *d_col_ind;
    double *d_values;
    int *d_rows, *d_columns;
    int *row_ptr, *col_ind, *single_block_size;
    double *values;
    int row_size, col_size, val_size;

    double * man_x, *man_x_result;
    double * d_man_x, *d_man_x_result;
 
    readMatrix(&row_ptr,&col_ind,&values,row_size,col_size,val_size ,filename);
    accumulateCounts(row_ptr,row_size,val_size);
    
    
    cudaMalloc((void**)&d_rowptr, sizeof(int) * row_size);
    cudaMalloc((void**)&d_col_ind, sizeof(int) * val_size);
    cudaMalloc((void**)&d_values, sizeof(double) * val_size);
    cudaMalloc((void**)&d_rows, sizeof(int));
    cudaMalloc((void**)&d_columns, sizeof(int));
    cudaMalloc((void**)&single_block_size, sizeof(int));
   
    cudaMalloc((void**)&man_x, sizeof(double) * row_size);
    cudaMalloc((void**)&man_x_result, sizeof(double) * row_size);
    cudaMalloc((void**)&d_man_x, sizeof(double) * row_size);
    cudaMalloc((void**)&d_man_x_result, sizeof(double) * row_size);


    man_x = allocateDoubleArray(row_size);
    man_x_result = allocateDoubleArray(row_size);
    initializeDoubleArray(man_x,row_size,1.0);
 
   
    cudaMemcpy(d_rowptr, row_ptr, sizeof(int) * row_size, cudaMemcpyHostToDevice);
    cudaMemcpy(d_col_ind, col_ind, sizeof(int) * val_size, cudaMemcpyHostToDevice);
    cudaMemcpy(d_values, values, sizeof(double) * val_size, cudaMemcpyHostToDevice);
    cudaMemcpy(d_rows, &row_size, sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(d_columns, &col_size, sizeof(int), cudaMemcpyHostToDevice);
    
    int block_size = BLOCKSIZE;
    int a_block_can_hold =block_size*block_size;
    int blocks_in_a_grid;
    if (row_size % a_block_can_hold != 0){
        blocks_in_a_grid=row_size/a_block_can_hold+1;
    }else {
        blocks_in_a_grid=(row_size/a_block_can_hold+1)-1;
    }
    
    int grids = noThreads /(blocks_in_a_grid*a_block_can_hold);

    if (noThreads%(blocks_in_a_grid*a_block_can_hold)>0){
        grids++;
    }

    dim3 dimBlock(block_size,block_size);
    dim3 dimGrid(grids,blocks_in_a_grid);

    double *pt;
    cudaMemcpy(single_block_size , &block_size, sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(d_man_x, man_x, sizeof(double) * row_size, cudaMemcpyHostToDevice);
    
    struct timeval t1, t2;

    gettimeofday(&t1, 0);
    for(int iter=0; iter<number_of_iter; iter++) {
        matrix_vector_multip_dev<<<dimGrid,dimBlock>>>(d_rowptr, d_col_ind,d_values, d_rows,d_columns, d_man_x,d_man_x_result,single_block_size );
        cudaDeviceSynchronize(); 
        pt = d_man_x;
        d_man_x = d_man_x_result;
        d_man_x_result = pt;
    }
    gettimeofday(&t2, 0);

    double time = (1000000.0*(t2.tv_sec-t1.tv_sec) + t2.tv_usec-t1.tv_usec)/1000.0;

    //printf("Time to generate:  %3.11f ms \n", time);
  
    cudaMemcpy(man_x, d_man_x, sizeof(double) * row_size, cudaMemcpyDeviceToHost);

    
    if (print_what == 1){
        printDoubleArray(values,val_size);
        printArray(col_ind,val_size);
        printArray(row_ptr,row_size);
    }
    if (print_what == 2){
        printDoubleArray(man_x,row_size);
    }
    
    return 0;
}
	.file	"tmpxft_003aa48f_00000000-6_cuda_parallel.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2041:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2041:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z13allocateArrayi
	.type	_Z13allocateArrayi, @function
_Z13allocateArrayi:
.LFB2027:
	.cfi_startproc
	endbr64
	movslq	%edi, %rdi
	salq	$2, %rdi
	jmp	malloc@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z13allocateArrayi, .-_Z13allocateArrayi
	.globl	_Z19allocateDoubleArrayi
	.type	_Z19allocateDoubleArrayi, @function
_Z19allocateDoubleArrayi:
.LFB2028:
	.cfi_startproc
	endbr64
	movslq	%edi, %rdi
	salq	$3, %rdi
	jmp	malloc@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z19allocateDoubleArrayi, .-_Z19allocateDoubleArrayi
	.globl	_Z15initializeArrayPiii
	.type	_Z15initializeArrayPiii, @function
_Z15initializeArrayPiii:
.LFB2029:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L5:
	cmpl	%eax, %esi
	jle	.L8
	movl	%edx, (%rdi,%rax,4)
	incq	%rax
	jmp	.L5
.L8:
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z15initializeArrayPiii, .-_Z15initializeArrayPiii
	.globl	_Z21initializeDoubleArrayPdid
	.type	_Z21initializeDoubleArrayPdid, @function
_Z21initializeDoubleArrayPdid:
.LFB2030:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L10:
	cmpl	%eax, %esi
	jle	.L12
	movsd	%xmm0, (%rdi,%rax,8)
	incq	%rax
	jmp	.L10
.L12:
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z21initializeDoubleArrayPdid, .-_Z21initializeDoubleArrayPdid
	.globl	_Z21allocateMatrixStoragePPiS0_PPdiii
	.type	_Z21allocateMatrixStoragePPiS0_PPdiii, @function
_Z21allocateMatrixStoragePPiS0_PPdiii:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdi, %r13
	movl	%ecx, %edi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%r9d, %ebx
	pushq	%rax
	.cfi_def_cfa_offset 48
	call	_Z13allocateArrayi
	movl	%ebx, %edi
	movq	%rax, 0(%r13)
	call	_Z13allocateArrayi
	movl	%ebx, %edi
	movq	%rax, (%r12)
	call	_Z19allocateDoubleArrayi
	movq	%rax, 0(%rbp)
	popq	%rdx
	.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
.LFE2031:
	.size	_Z21allocateMatrixStoragePPiS0_PPdiii, .-_Z21allocateMatrixStoragePPiS0_PPdiii
	.globl	_Z23initializeMatrixStoragePPiS0_PPdiii
	.type	_Z23initializeMatrixStoragePPiS0_PPdiii, @function
_Z23initializeMatrixStoragePPiS0_PPdiii:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rdi
	movq	%rsi, %r10
	movq	%rdx, %r8
	movl	%ecx, %esi
	xorl	%edx, %edx
	call	_Z15initializeArrayPiii
	movq	(%r10), %rdi
	movl	%r9d, %edx
	movl	%r9d, %esi
	call	_Z15initializeArrayPiii
	cvtsi2sdl	%r9d, %xmm0
	movq	(%r8), %rdi
	jmp	_Z21initializeDoubleArrayPdid
	.cfi_endproc
.LFE2032:
	.size	_Z23initializeMatrixStoragePPiS0_PPdiii, .-_Z23initializeMatrixStoragePPiS0_PPdiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"file cant be found\n"
.LC2:
	.string	"%d %d %d"
.LC3:
	.string	"%d %d %lg"
	.text
	.globl	_Z10readMatrixPPiS0_PPdRiS3_S3_Pc
	.type	_Z10readMatrixPPiS0_PPdRiS3_S3_Pc, @function
_Z10readMatrixPPiS0_PPdRiS3_S3_Pc:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%r8, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rcx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	leaq	.LC0(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r9, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movq	112(%rsp), %rdi
	call	fopen@PLT
	movq	%rax, 8(%rsp)
	testq	%rax, %rax
	jne	.L17
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	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
	jmp	__printf_chk@PLT
.L17:
	.cfi_restore_state
	movq	8(%rsp), %rdi
	movq	%r15, %rcx
	movq	%r14, %rdx
	movq	%rbx, %r8
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movl	(%r15), %r8d
	movl	(%r14), %ecx
	movq	%r13, %rdx
	movl	(%rbx), %r9d
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	_Z21allocateMatrixStoragePPiS0_PPdiii
	movl	(%r15), %r8d
	movl	(%r14), %ecx
	movq	%r13, %rdx
	movl	(%rbx), %r9d
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%r15d, %r15d
	leaq	.LC3(%rip), %r14
	call	_Z23initializeMatrixStoragePPiS0_PPdiii
.L19:
	cmpl	%r15d, (%rbx)
	jle	.L24
	movq	8(%rsp), %rdi
	leaq	24(%rsp), %rdx
	movq	%r14, %rsi
	xorl	%eax, %eax
	leaq	28(%rsp), %rcx
	leaq	32(%rsp), %r8
	call	__isoc23_fscanf@PLT
	movq	0(%rbp), %rax
	movslq	24(%rsp), %rdx
	movsd	32(%rsp), %xmm0
	incl	-4(%rax,%rdx,4)
	movq	0(%r13), %rax
	movq	(%r12), %rdx
	movsd	%xmm0, (%rax,%r15,8)
	movl	28(%rsp), %eax
	decl	%eax
	movl	%eax, (%rdx,%r15,4)
	incq	%r15
	jmp	.L19
.L24:
	movq	8(%rsp), %rdi
	call	fclose@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
.L23:
	call	__stack_chk_fail@PLT
.L21:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	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
.LFE2033:
	.size	_Z10readMatrixPPiS0_PPdRiS3_S3_Pc, .-_Z10readMatrixPPiS0_PPdRiS3_S3_Pc
	.globl	_Z16accumulateCountsPiii
	.type	_Z16accumulateCountsPiii, @function
_Z16accumulateCountsPiii:
.LFB2034:
	.cfi_startproc
	endbr64
	movslq	%esi, %rax
	subl	$2, %esi
	leaq	-4(%rdi,%rax,4), %rax
	movslq	%esi, %rsi
	subl	(%rax), %edx
	movl	%edx, (%rax)
.L26:
	testl	%esi, %esi
	js	.L28
	movl	4(%rdi,%rsi,4), %eax
	subl	(%rdi,%rsi,4), %eax
	movl	%eax, (%rdi,%rsi,4)
	decq	%rsi
	jmp	.L26
.L28:
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z16accumulateCountsPiii, .-_Z16accumulateCountsPiii
	.section	.rodata.str1.1
.LC4:
	.string	"%d\n"
.LC5:
	.string	"\n"
	.text
	.globl	_Z10printArrayPii
	.type	_Z10printArrayPii, @function
_Z10printArrayPii:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC4(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
.L30:
	cmpl	%ebx, %ebp
	jle	.L33
	movl	(%r12,%rbx,4), %edx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L30
.L33:
	popq	%rdx
	.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
	.cfi_endproc
.LFE2035:
	.size	_Z10printArrayPii, .-_Z10printArrayPii
	.section	.rodata.str1.1
.LC6:
	.string	"%lf\n"
	.text
	.globl	_Z16printDoubleArrayPdi
	.type	_Z16printDoubleArrayPdi, @function
_Z16printDoubleArrayPdi:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC6(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
.L35:
	cmpl	%ebx, %ebp
	jle	.L38
	movsd	(%r12,%rbx,8), %xmm0
	movq	%r13, %rsi
	movl	$2, %edi
	movb	$1, %al
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L35
.L38:
	popq	%rdx
	.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
	.cfi_endproc
.LFE2036:
	.size	_Z16printDoubleArrayPdi, .-_Z16printDoubleArrayPdi
	.globl	_Z20matrix_vector_multipPiS_PdiiPS0_
	.type	_Z20matrix_vector_multipPiS_PdiiPS0_, @function
_Z20matrix_vector_multipPiS_PdiiPS0_:
.LFB2037:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%r9, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	movl	%ecx, %edi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r8d, %ebx
	pushq	%r10
	.cfi_def_cfa_offset 64
	call	_Z19allocateDoubleArrayi
	movl	%ebp, %esi
	xorps	%xmm0, %xmm0
	xorl	%ecx, %ecx
	movq	%rax, %rdi
	movq	%rax, %rdx
	call	_Z21initializeDoubleArrayPdid
	movq	(%r15), %rdi
	leal	-1(%rbp), %esi
.L40:
	cmpl	%ecx, %esi
	jle	.L51
	movslq	(%r14,%rcx,4), %rax
	movl	4(%r14,%rcx,4), %r8d
	xorps	%xmm0, %xmm0
	cmpl	%r8d, %eax
	je	.L41
.L42:
	cmpl	%eax, %r8d
	jle	.L41
	movslq	(%r12,%rax,4), %r9
	movsd	(%rdi,%r9,8), %xmm1
	mulsd	0(%r13,%rax,8), %xmm1
	incq	%rax
	addsd	%xmm1, %xmm0
	jmp	.L42
.L41:
	movsd	%xmm0, (%rdx,%rcx,8)
	incq	%rcx
	jmp	.L40
.L51:
	movslq	%esi, %rcx
	xorps	%xmm0, %xmm0
	movslq	(%r14,%rcx,4), %rax
	leaq	(%rdx,%rcx,8), %rcx
	cmpl	%ebp, %eax
	jge	.L45
.L46:
	cmpl	%eax, %ebx
	jle	.L45
	movslq	(%r12,%rax,4), %rsi
	movsd	(%rdi,%rsi,8), %xmm1
	mulsd	0(%r13,%rax,8), %xmm1
	incq	%rax
	addsd	%xmm1, %xmm0
	jmp	.L46
.L45:
	movq	%rdx, (%r15)
	movsd	%xmm0, (%rcx)
	popq	%rax
	.cfi_def_cfa_offset 56
	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
	jmp	free@PLT
	.cfi_endproc
.LFE2037:
	.size	_Z20matrix_vector_multipPiS_PdiiPS0_, .-_Z20matrix_vector_multipPiS_PdiiPS0_
	.globl	_Z46__device_stub__Z24initializeDoubleArrayDevPdidPdid
	.type	_Z46__device_stub__Z24initializeDoubleArrayDevPdidPdid, @function
_Z46__device_stub__Z24initializeDoubleArrayDevPdidPdid:
.LFB2063:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	32(%rsp), %rdx
	movl	%esi, 20(%rsp)
	leaq	48(%rsp), %rdi
	leaq	60(%rsp), %rsi
	movsd	%xmm0, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L52
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z24initializeDoubleArrayDevPdid(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L52:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2063:
	.size	_Z46__device_stub__Z24initializeDoubleArrayDevPdidPdid, .-_Z46__device_stub__Z24initializeDoubleArrayDevPdidPdid
	.globl	_Z24initializeDoubleArrayDevPdid
	.type	_Z24initializeDoubleArrayDevPdid, @function
_Z24initializeDoubleArrayDevPdid:
.LFB2064:
	.cfi_startproc
	endbr64
	jmp	_Z46__device_stub__Z24initializeDoubleArrayDevPdidPdid
	.cfi_endproc
.LFE2064:
	.size	_Z24initializeDoubleArrayDevPdid, .-_Z24initializeDoubleArrayDevPdid
	.globl	_Z60__device_stub__Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_PiS_PdS_S_S0_S0_S_
	.type	_Z60__device_stub__Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_PiS_PdS_S_S0_S0_S_, @function
_Z60__device_stub__Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_PiS_PdS_S_S0_S0_S_:
.LFB2065:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	224(%rsp), %rax
	movq	%rdi, 56(%rsp)
	leaq	88(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	100(%rsp), %rsi
	movq	%rax, 8(%rsp)
	movq	232(%rsp), %rax
	movq	%rdx, 40(%rsp)
	leaq	72(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	80(%rsp), %rcx
	movq	%r8, 24(%rsp)
	movq	%r9, 16(%rsp)
	movq	%rax, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 96(%rsp)
	movq	%rax, 136(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 184(%rsp)
	movq	%rsp, %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L57
	pushq	80(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_(%rip), %rdi
	pushq	80(%rsp)
	.cfi_def_cfa_offset 240
	movq	116(%rsp), %rcx
	movl	124(%rsp), %r8d
	movq	104(%rsp), %rsi
	movl	112(%rsp), %edx
	leaq	152(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L57:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L59
	call	__stack_chk_fail@PLT
.L59:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2065:
	.size	_Z60__device_stub__Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_PiS_PdS_S_S0_S0_S_, .-_Z60__device_stub__Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_PiS_PdS_S_S0_S0_S_
	.globl	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	.type	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_, @function
_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_:
.LFB2066:
	.cfi_startproc
	endbr64
	jmp	_Z60__device_stub__Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_PiS_PdS_S_S0_S0_S_
	.cfi_endproc
.LFE2066:
	.size	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_, .-_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	.section	.rodata.str1.1
.LC8:
	.string	"Please enter the all the following arguments:\n"
.LC9:
	.string	"1. The number of threads used to compute Matrix-vector product\n"
.LC10:
	.string	"2. The number of repetitions \n"
.LC11:
	.string	"3. An argument to print on stdout \n"
.LC12:
	.string	"4. Test-file name\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2038:
	.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
	subq	$216, %rsp
	.cfi_def_cfa_offset 272
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	cmpl	$4, %edi
	jg	.L63
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %edi
	leaq	.LC12(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L63:
	movq	8(%rsi), %rdi
	movq	%rsi, %r13
	leaq	24(%rsp), %r15
	call	atoi@PLT
	movq	16(%r13), %rdi
	movl	%eax, %ebx
	call	atoi@PLT
	movq	24(%r13), %rdi
	movl	%eax, %r12d
	call	atoi@PLT
	leaq	28(%rsp), %r8
	leaq	104(%rsp), %rdx
	leaq	88(%rsp), %rsi
	leaq	80(%rsp), %rdi
	pushq	%rcx
	.cfi_def_cfa_offset 280
	movq	%r15, %rcx
	pushq	32(%r13)
	.cfi_def_cfa_offset 288
	movl	%eax, %ebp
	leaq	48(%rsp), %r9
	movq	%r8, 24(%rsp)
	call	_Z10readMatrixPPiS0_PPdRiS3_S3_Pc
	movq	96(%rsp), %rax
	movl	48(%rsp), %edx
	movl	40(%rsp), %esi
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
	call	_Z16accumulateCountsPiii
	popq	%rsi
	.cfi_def_cfa_offset 280
	popq	%rdi
	.cfi_def_cfa_offset 272
	movslq	24(%rsp), %rsi
	leaq	40(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movslq	32(%rsp), %rsi
	leaq	48(%rsp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movslq	32(%rsp), %rsi
	leaq	56(%rsp), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	leaq	72(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	leaq	96(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movslq	24(%rsp), %rsi
	leaq	112(%rsp), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	24(%rsp), %rsi
	leaq	120(%rsp), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	24(%rsp), %rsi
	leaq	128(%rsp), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	24(%rsp), %rsi
	leaq	136(%rsp), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movl	24(%rsp), %r13d
	movl	%r13d, %edi
	call	_Z19allocateDoubleArrayi
	movl	%r13d, %edi
	movq	%rax, %r14
	movq	%rax, 112(%rsp)
	call	_Z19allocateDoubleArrayi
	movl	%r13d, %esi
	movq	%r14, %rdi
	movslq	%r13d, %rdx
	movq	%rax, 120(%rsp)
	salq	$2, %rdx
	movl	$1, %ecx
	movsd	.LC13(%rip), %xmm0
	call	_Z21initializeDoubleArrayPdid
	movq	(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	88(%rsp), %r13
	movslq	32(%rsp), %rdx
	movl	$1, %ecx
	movq	48(%rsp), %rdi
	salq	$2, %rdx
	movq	%r13, %rsi
	call	cudaMemcpy@PLT
	movq	104(%rsp), %r14
	movslq	32(%rsp), %rdx
	movl	$1, %ecx
	movq	56(%rsp), %rdi
	salq	$3, %rdx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movq	%r15, %rsi
	movl	$4, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movl	$4, %edx
	call	cudaMemcpy@PLT
	movl	%ebx, %eax
	movl	24(%rsp), %ecx
	movl	$1, 36(%rsp)
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jle	.L64
	incl	%eax
.L64:
	movq	96(%rsp), %rdi
	leaq	36(%rsp), %rsi
	movl	%ecx, 160(%rsp)
	movabsq	$4294967297, %rbx
	movl	$1, %ecx
	movl	$4, %edx
	movq	%rbx, 144(%rsp)
	xorl	%ebx, %ebx
	movl	$1, 152(%rsp)
	movl	%eax, 156(%rsp)
	movl	$1, 164(%rsp)
	call	cudaMemcpy@PLT
	movslq	24(%rsp), %rdx
	movq	112(%rsp), %rsi
	movl	$1, %ecx
	movq	128(%rsp), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	leaq	168(%rsp), %rdi
	xorl	%esi, %esi
	call	gettimeofday@PLT
.L65:
	cmpl	%r12d, %ebx
	jge	.L72
	movl	152(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	144(%rsp), %rdx
	movq	156(%rsp), %rdi
	movl	164(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L66
	pushq	96(%rsp)
	.cfi_def_cfa_offset 280
	pushq	144(%rsp)
	.cfi_def_cfa_offset 288
	movq	144(%rsp), %r9
	movq	88(%rsp), %r8
	movq	80(%rsp), %rcx
	movq	72(%rsp), %rdx
	movq	64(%rsp), %rsi
	movq	56(%rsp), %rdi
	call	_Z60__device_stub__Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_PiS_PdS_S_S0_S0_S_
	popq	%rax
	.cfi_def_cfa_offset 280
	popq	%rdx
	.cfi_def_cfa_offset 272
.L66:
	call	cudaDeviceSynchronize@PLT
	movq	128(%rsp), %rax
	movq	136(%rsp), %rdx
	incl	%ebx
	movq	%rdx, 128(%rsp)
	movq	%rax, 136(%rsp)
	jmp	.L65
.L72:
	xorl	%esi, %esi
	leaq	184(%rsp), %rdi
	call	gettimeofday@PLT
	movslq	24(%rsp), %rdx
	movq	112(%rsp), %rdi
	movl	$2, %ecx
	movq	128(%rsp), %rsi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	cmpl	$1, %ebp
	jne	.L68
	movl	32(%rsp), %esi
	movq	%r14, %rdi
	call	_Z16printDoubleArrayPdi
	movl	32(%rsp), %esi
	movq	%r13, %rdi
	call	_Z10printArrayPii
	movl	24(%rsp), %esi
	movq	(%rsp), %rdi
	call	_Z10printArrayPii
	jmp	.L69
.L68:
	cmpl	$2, %ebp
	jne	.L69
	movl	24(%rsp), %esi
	movq	112(%rsp), %rdi
	call	_Z16printDoubleArrayPdi
.L69:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L70
	call	__stack_chk_fail@PLT
.L70:
	addq	$216, %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
.LFE2038:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_"
.LC15:
	.string	"_Z24initializeDoubleArrayDevPdid"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2068:
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_(%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	.LC15(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z24initializeDoubleArrayDevPdid(%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
.LFE2068:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC13:
	.long	0
	.long	1072693248
	.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 "utils.cuh"
#include <stdio.h>
#include <stdlib.h>
#include <hip/hip_runtime.h>

#include <sys/time.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define BLOCKSIZE 1


struct MatrixStorage {
    int *row_ptr;
    int row_size;

    int *col_ind;
    int col_size;

    double *values;
    int val_size;
};

__host__ int* allocateArray(int size);
__host__ double* allocateDoubleArray(int size);

__host__ void initializeDoubleArray(double* arr, int size, double initalizer);
__host__ void initializeArray(int* arr, int size, int initalizer);
//void allocateMatrixStorage(struct MatrixStorage* matrixOut, int rows,int values);
__host__ void allocateMatrixStorage(int** row_ptr, int **col_ind,double **values, int row_size, int col_size, int val_size);
__host__  void initializeMatrixStorage(int **row_ptr, int **col_ind,double **values, int row_size, int col_size, int val_size);
__host__ void readMatrix(int **row_ptr, int **col_ind,double **values,
            int &row_size, int &col_size, int &val_size, char *filename);
__host__ void accumulateCounts(int* arr,int size,int val);
__host__ void printArray(int* arr, int size);
__host__ void printDoubleArray(double* arr, int size);
__host__ void matrix_vector_multip(int *row_ptr, int *col_ind, 
            double *values, int rows,int columns, double **x );

__host__ int* allocateArray(int size){
    int *arr;
    arr = (int *)malloc(sizeof(int) * size);
    return arr;
}
  
__host__ double* allocateDoubleArray(int size){
    double *arr;
    arr = (double *)malloc(sizeof(double) * size);
    return arr;
}

__host__ void initializeArray(int* arr, int size, int initalizer){
    int i;
    for (i = 0; i < size; i++){
        arr[i] = initalizer;
    }
}
__host__ void initializeDoubleArray(double* arr, int size, double initalizer){
    int i;
    for (i = 0; i < size; i++){
        arr[i] = initalizer;
    }
}

__host__ void allocateMatrixStorage(int** row_ptr, int **col_ind,double **values, int row_size,int col_size,int val_size){
    *row_ptr =  allocateArray(row_size);
    *col_ind =  allocateArray(val_size);
    *values =  allocateDoubleArray(val_size);
}

__host__ void initializeMatrixStorage(int** row_ptr, int **col_ind,double **values, int row_size,int col_size,int val_size){ 
    initializeArray(*row_ptr, row_size, 0);
    initializeArray(*col_ind, val_size, val_size);
    initializeDoubleArray(*values, val_size, (double) val_size);
}

__host__  void readMatrix(int **row_ptr, int **col_ind,double **values,
            int &row_size, int &col_size, int &val_size, char *filename){
   
    FILE * fileToRead;
    int  i;
    int row_index,col_index;
    double val;

    
    fileToRead = fopen(filename,"r");             //opens the file

    if (fileToRead == NULL){
         printf("file cant be found\n");
         return ;
    }else{
    
        fscanf(fileToRead,"%d %d %d", &(row_size), &(col_size), &(val_size));
        allocateMatrixStorage( row_ptr, col_ind, values, row_size,col_size,val_size);
        initializeMatrixStorage(row_ptr, col_ind, values,row_size,col_size, val_size);

        for (i = 0; i < val_size; i++)
        {   
            fscanf(fileToRead,"%d %d %lg", &row_index, &col_index, &val);
            //if (row_index == 5)
            //printf("%d,%d\n", row_ptr[row_index-1],row_index);
            (*row_ptr)[row_index-1] =  (*row_ptr)[row_index-1] + 1;	
            (*values)[i] = val;
            (*col_ind)[i] = col_index -1;
        } 
        //printf("\n");
    }
    fclose(fileToRead);
}

__host__ void accumulateCounts(int* arr,int size,int val){
    int i;
   
    if (arr[size-1] == 0){
        arr[size-1] = val;
    }
    else{
         arr[size-1] = val - arr[size-1];
    }
    
    for (i = size-2; i >=0; i--){
        if (arr[i] == 0)
            arr[i] = arr[i+1];
        else {
            arr[i] = arr[i+1] - arr[i];
        }
    }
}

__host__ void printArray(int* arr, int size){
     
    int i;
    for (i = 0; i < size; i++){
        printf("%d\n", arr[i]);
    }
    printf("\n");
}

__host__ void printDoubleArray(double* arr, int size){
    int i;
    for (i = 0; i < size; i++){
        printf("%lf\n", arr[i]);
    }
    printf("\n");
}

__host__ void matrix_vector_multip(int *row_ptr, int *col_ind, 
            double *values, int rows,int columns, double **x ){
    int i,j;
    double val = 0.0;
    
    double *newArr = allocateDoubleArray(rows);
    initializeDoubleArray(newArr,rows,0.0);
    
    double *tmpX = *x;

    for (i = 0; i < rows-1; i++){
        if (row_ptr[i] != row_ptr[i+1]){
            for (j = row_ptr[i]; j < row_ptr[i+1];j++){
                val = val + tmpX[col_ind[j]]*values[j];
            }
            newArr[i] = val;
        } else {
            newArr[i] = 0.0;
        }
        val = 0.0;
    }
    
    //printArray(col_ind,columns);
    i = rows -1;
    if (row_ptr[i] < rows){
        for (j = row_ptr[i]; j < columns;j++){
            
            val = val + tmpX[col_ind[j]]*values[j];
        }
        newArr[i] = val;
        
    }else {
        newArr[i] = 0.0;
    }
    val = 0.0;
    
    *x = newArr;
    newArr = NULL;
    free(tmpX);
}
__global__ void initializeDoubleArrayDev(double* arr, int size, double initalizer){
    int i;
    for (i = 0; i < size; i++){
        arr[i] = initalizer;
    }
}

__global__ void matrix_vector_multip_dev(int *row_ptr, int *col_ind, 
            double *values, int *rowsArr,int *columnsArr, double *x, double *newArr,int *single_block_size ){
    int block_size = single_block_size[0];
    int x_tid = blockIdx.x*blockDim.x + threadIdx.x;
    int y_tid = blockIdx.y*blockDim.y + threadIdx.y;
    int thread_index = x_tid + gridDim.x*block_size*y_tid;       
    

    int j;
    int rows = rowsArr[0];
    int columns = columnsArr[0];
    double val = 0.0;
    int ofset = rows * thread_index; 

    if (thread_index < rows){
        newArr[thread_index] = 0.0;
    }
    if (thread_index < rows -1 ){
        if (row_ptr[thread_index] != row_ptr[thread_index+1]){
            for (j = row_ptr[thread_index]; j < row_ptr[thread_index+1];j++){
                    val = val + x[col_ind[j]] *values[j];
            }
            newArr[thread_index] += val;
        }else {
            newArr[thread_index] += 0.0;
        }
    } else {
        if (thread_index == rows -1 && row_ptr[thread_index] < rows){
            for (j = row_ptr[thread_index]; j < columns;j++){
                val = val + x[col_ind[j]] *values[ofset + j];
            }
            newArr[thread_index] += val;
        }else {
            newArr[thread_index] += 0.0;
        }
    }

   
   __syncthreads();
    
}


int main(int argc, char** argv){

    int noThreads,number_of_iter,print_what;
    char *filename;

    if (argc < 5){
        printf("Please enter the all the following arguments:\n");
        printf("1. The number of threads used to compute Matrix-vector product\n");
        printf("2. The number of repetitions \n");
        printf("3. An argument to print on stdout \n");
        printf("4. Test-file name\n");
        exit(1);
    }else {
        noThreads = atoi(argv[1]);
        number_of_iter = atoi(argv[2]);
        print_what =  atoi(argv[3]);
        filename = argv[4];
    } 

    int *d_rowptr, *d_col_ind;
    double *d_values;
    int *d_rows, *d_columns;
    int *row_ptr, *col_ind, *single_block_size;
    double *values;
    int row_size, col_size, val_size;

    double * man_x, *man_x_result;
    double * d_man_x, *d_man_x_result;
 
    readMatrix(&row_ptr,&col_ind,&values,row_size,col_size,val_size ,filename);
    accumulateCounts(row_ptr,row_size,val_size);
    
    
    hipMalloc((void**)&d_rowptr, sizeof(int) * row_size);
    hipMalloc((void**)&d_col_ind, sizeof(int) * val_size);
    hipMalloc((void**)&d_values, sizeof(double) * val_size);
    hipMalloc((void**)&d_rows, sizeof(int));
    hipMalloc((void**)&d_columns, sizeof(int));
    hipMalloc((void**)&single_block_size, sizeof(int));
   
    hipMalloc((void**)&man_x, sizeof(double) * row_size);
    hipMalloc((void**)&man_x_result, sizeof(double) * row_size);
    hipMalloc((void**)&d_man_x, sizeof(double) * row_size);
    hipMalloc((void**)&d_man_x_result, sizeof(double) * row_size);


    man_x = allocateDoubleArray(row_size);
    man_x_result = allocateDoubleArray(row_size);
    initializeDoubleArray(man_x,row_size,1.0);
 
   
    hipMemcpy(d_rowptr, row_ptr, sizeof(int) * row_size, hipMemcpyHostToDevice);
    hipMemcpy(d_col_ind, col_ind, sizeof(int) * val_size, hipMemcpyHostToDevice);
    hipMemcpy(d_values, values, sizeof(double) * val_size, hipMemcpyHostToDevice);
    hipMemcpy(d_rows, &row_size, sizeof(int), hipMemcpyHostToDevice);
    hipMemcpy(d_columns, &col_size, sizeof(int), hipMemcpyHostToDevice);
    
    int block_size = BLOCKSIZE;
    int a_block_can_hold =block_size*block_size;
    int blocks_in_a_grid;
    if (row_size % a_block_can_hold != 0){
        blocks_in_a_grid=row_size/a_block_can_hold+1;
    }else {
        blocks_in_a_grid=(row_size/a_block_can_hold+1)-1;
    }
    
    int grids = noThreads /(blocks_in_a_grid*a_block_can_hold);

    if (noThreads%(blocks_in_a_grid*a_block_can_hold)>0){
        grids++;
    }

    dim3 dimBlock(block_size,block_size);
    dim3 dimGrid(grids,blocks_in_a_grid);

    double *pt;
    hipMemcpy(single_block_size , &block_size, sizeof(int), hipMemcpyHostToDevice);
    hipMemcpy(d_man_x, man_x, sizeof(double) * row_size, hipMemcpyHostToDevice);
    
    struct timeval t1, t2;

    gettimeofday(&t1, 0);
    for(int iter=0; iter<number_of_iter; iter++) {
        matrix_vector_multip_dev<<<dimGrid,dimBlock>>>(d_rowptr, d_col_ind,d_values, d_rows,d_columns, d_man_x,d_man_x_result,single_block_size );
        hipDeviceSynchronize(); 
        pt = d_man_x;
        d_man_x = d_man_x_result;
        d_man_x_result = pt;
    }
    gettimeofday(&t2, 0);

    double time = (1000000.0*(t2.tv_sec-t1.tv_sec) + t2.tv_usec-t1.tv_usec)/1000.0;

    //printf("Time to generate:  %3.11f ms \n", time);
  
    hipMemcpy(man_x, d_man_x, sizeof(double) * row_size, hipMemcpyDeviceToHost);

    
    if (print_what == 1){
        printDoubleArray(values,val_size);
        printArray(col_ind,val_size);
        printArray(row_ptr,row_size);
    }
    if (print_what == 2){
        printDoubleArray(man_x,row_size);
    }
    
    return 0;
}
	.text
	.file	"cuda_parallel.hip"
	.globl	_Z13allocateArrayi              # -- Begin function _Z13allocateArrayi
	.type	_Z13allocateArrayi,@function
_Z13allocateArrayi:                     # @_Z13allocateArrayi
	.cfi_startproc
# %bb.0:
	movslq	%edi, %rdi
	shlq	$2, %rdi
	jmp	malloc                          # TAILCALL
.Lfunc_end0:
	.size	_Z13allocateArrayi, .Lfunc_end0-_Z13allocateArrayi
	.cfi_endproc
                                        # -- End function
	.globl	_Z19allocateDoubleArrayi        # -- Begin function _Z19allocateDoubleArrayi
	.type	_Z19allocateDoubleArrayi,@function
_Z19allocateDoubleArrayi:               # @_Z19allocateDoubleArrayi
	.cfi_startproc
# %bb.0:
	movslq	%edi, %rdi
	shlq	$3, %rdi
	jmp	malloc                          # TAILCALL
.Lfunc_end1:
	.size	_Z19allocateDoubleArrayi, .Lfunc_end1-_Z19allocateDoubleArrayi
	.cfi_endproc
                                        # -- End function
	.globl	_Z15initializeArrayPiii         # -- Begin function _Z15initializeArrayPiii
	.type	_Z15initializeArrayPiii,@function
_Z15initializeArrayPiii:                # @_Z15initializeArrayPiii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%edx, (%rdi,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z15initializeArrayPiii, .Lfunc_end2-_Z15initializeArrayPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z21initializeDoubleArrayPdid   # -- Begin function _Z21initializeDoubleArrayPdid
	.type	_Z21initializeDoubleArrayPdid,@function
_Z21initializeDoubleArrayPdid:          # @_Z21initializeDoubleArrayPdid
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB3_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, (%rdi,%rcx,8)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB3_2
.LBB3_3:                                # %._crit_edge
	retq
.Lfunc_end3:
	.size	_Z21initializeDoubleArrayPdid, .Lfunc_end3-_Z21initializeDoubleArrayPdid
	.cfi_endproc
                                        # -- End function
	.globl	_Z21allocateMatrixStoragePPiS0_PPdiii # -- Begin function _Z21allocateMatrixStoragePPiS0_PPdiii
	.type	_Z21allocateMatrixStoragePPiS0_PPdiii,@function
_Z21allocateMatrixStoragePPiS0_PPdiii:  # @_Z21allocateMatrixStoragePPiS0_PPdiii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%r9d, %ebx
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %r12
	movslq	%ecx, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, (%r12)
	movslq	%ebx, %rbx
	leaq	(,%rbx,4), %rdi
	callq	malloc
	movq	%rax, (%r15)
	shlq	$3, %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, (%r14)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z21allocateMatrixStoragePPiS0_PPdiii, .Lfunc_end4-_Z21allocateMatrixStoragePPiS0_PPdiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z23initializeMatrixStoragePPiS0_PPdiii # -- Begin function _Z23initializeMatrixStoragePPiS0_PPdiii
	.type	_Z23initializeMatrixStoragePPiS0_PPdiii,@function
_Z23initializeMatrixStoragePPiS0_PPdiii: # @_Z23initializeMatrixStoragePPiS0_PPdiii
	.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	%r9d, %ebx
	movq	%rdx, %r14
	movq	%rsi, %r15
	testl	%ecx, %ecx
	jle	.LBB5_2
# %bb.1:                                # %.lr.ph.preheader.i
	movq	(%rdi), %rdi
	movl	%ecx, %edx
	shlq	$2, %rdx
	xorl	%esi, %esi
	callq	memset@PLT
.LBB5_2:                                # %_Z15initializeArrayPiii.exit
	testl	%ebx, %ebx
	jle	.LBB5_7
# %bb.3:                                # %.lr.ph.preheader.i7
	movq	(%r15), %rcx
	movl	%ebx, %eax
	xorl	%edx, %edx
.LBB5_4:                                # %.lr.ph.i9
                                        # =>This Inner Loop Header: Depth=1
	movl	%ebx, (%rcx,%rdx,4)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB5_4
# %bb.5:                                # %_Z15initializeArrayPiii.exit13
	movq	(%r14), %rcx
	cvtsi2sd	%ebx, %xmm0
	xorl	%edx, %edx
.LBB5_6:                                # %.lr.ph.i16
                                        # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, (%rcx,%rdx,8)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB5_6
.LBB5_7:                                # %_Z21initializeDoubleArrayPdid.exit
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z23initializeMatrixStoragePPiS0_PPdiii, .Lfunc_end5-_Z23initializeMatrixStoragePPiS0_PPdiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10readMatrixPPiS0_PPdRiS3_S3_Pc # -- Begin function _Z10readMatrixPPiS0_PPdRiS3_S3_Pc
	.type	_Z10readMatrixPPiS0_PPdRiS3_S3_Pc,@function
_Z10readMatrixPPiS0_PPdRiS3_S3_Pc:      # @_Z10readMatrixPPiS0_PPdRiS3_S3_Pc
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r9, %rbx
	movq	%r8, %r14
	movq	%rcx, %rbp
	movq	%rdx, %r15
	movq	%rsi, %r12
	movq	%rdi, %r13
	movq	80(%rsp), %rdi
	movl	$.L.str, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB6_12
# %bb.1:
	movl	$.L.str.2, %esi
	movq	%rax, (%rsp)                    # 8-byte Spill
	movq	%rax, %rdi
	movq	%rbp, %rdx
	movq	%r14, %rcx
	movq	%rbx, %r8
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movl	(%rbp), %ecx
	movl	(%rbx), %r9d
	movq	%r13, %rdi
	movq	%r12, %rsi
	movq	%r15, %rdx
	callq	_Z21allocateMatrixStoragePPiS0_PPdiii
	movl	(%rbp), %edx
	movl	(%rbx), %r14d
	testl	%edx, %edx
	jle	.LBB6_3
# %bb.2:                                # %.lr.ph.preheader.i.i
	movq	(%r13), %rdi
	shlq	$2, %rdx
	xorl	%esi, %esi
	callq	memset@PLT
.LBB6_3:                                # %_Z15initializeArrayPiii.exit.i
	testl	%r14d, %r14d
	movq	(%rsp), %rdi                    # 8-byte Reload
	jle	.LBB6_8
# %bb.4:                                # %.lr.ph.preheader.i7.i
	movq	(%r12), %rax
	xorl	%ecx, %ecx
.LBB6_5:                                # %.lr.ph.i9.i
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, (%rax,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %r14
	jne	.LBB6_5
# %bb.6:                                # %_Z15initializeArrayPiii.exit13.i
	movq	(%r15), %rax
	cvtsi2sd	%r14d, %xmm0
	xorl	%ecx, %ecx
.LBB6_7:                                # %.lr.ph.i16.i
                                        # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, (%rax,%rcx,8)
	incq	%rcx
	cmpq	%rcx, %r14
	jne	.LBB6_7
.LBB6_8:                                # %_Z23initializeMatrixStoragePPiS0_PPdiii.exit
	cmpl	$0, (%rbx)
	jle	.LBB6_11
# %bb.9:                                # %.lr.ph.preheader
	movq	%r12, %rbp
	leaq	16(%rsp), %r14
	xorl	%r12d, %r12d
.LBB6_10:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.3, %esi
	movq	(%rsp), %rdi                    # 8-byte Reload
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rcx
	movq	%r14, %r8
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movq	(%rsp), %rdi                    # 8-byte Reload
	movq	(%r13), %rax
	movslq	12(%rsp), %rcx
	incl	-4(%rax,%rcx,4)
	movsd	16(%rsp), %xmm0                 # xmm0 = mem[0],zero
	movq	(%r15), %rax
	movsd	%xmm0, (%rax,%r12,8)
	movl	8(%rsp), %eax
	decl	%eax
	movq	(%rbp), %rcx
	movl	%eax, (%rcx,%r12,4)
	incq	%r12
	movslq	(%rbx), %rax
	cmpq	%rax, %r12
	jl	.LBB6_10
.LBB6_11:                               # %._crit_edge
	callq	fclose
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB6_12:
	.cfi_def_cfa_offset 80
	movl	$.Lstr, %edi
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end6:
	.size	_Z10readMatrixPPiS0_PPdRiS3_S3_Pc, .Lfunc_end6-_Z10readMatrixPPiS0_PPdRiS3_S3_Pc
	.cfi_endproc
                                        # -- End function
	.globl	_Z16accumulateCountsPiii        # -- Begin function _Z16accumulateCountsPiii
	.type	_Z16accumulateCountsPiii,@function
_Z16accumulateCountsPiii:               # @_Z16accumulateCountsPiii
	.cfi_startproc
# %bb.0:
                                        # kill: def $esi killed $esi def $rsi
	movslq	%esi, %rax
	subl	-4(%rdi,%rax,4), %edx
	movl	%edx, -4(%rdi,%rax,4)
	cmpl	$2, %eax
	jl	.LBB7_3
# %bb.1:                                # %.lr.ph.preheader
	addl	$-2, %esi
	movl	4(%rdi,%rsi,4), %eax
	incq	%rsi
.LBB7_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	subl	-4(%rdi,%rsi,4), %eax
	movl	%eax, -4(%rdi,%rsi,4)
	decq	%rsi
	jg	.LBB7_2
.LBB7_3:                                # %._crit_edge
	retq
.Lfunc_end7:
	.size	_Z16accumulateCountsPiii, .Lfunc_end7-_Z16accumulateCountsPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10printArrayPii               # -- Begin function _Z10printArrayPii
	.type	_Z10printArrayPii,@function
_Z10printArrayPii:                      # @_Z10printArrayPii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB8_4
# %bb.1:                                # %.lr.ph.preheader
	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	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB8_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r15,4), %esi
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB8_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB8_4:                                # %._crit_edge
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end8:
	.size	_Z10printArrayPii, .Lfunc_end8-_Z10printArrayPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z16printDoubleArrayPdi         # -- Begin function _Z16printDoubleArrayPdi
	.type	_Z16printDoubleArrayPdi,@function
_Z16printDoubleArrayPdi:                # @_Z16printDoubleArrayPdi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB9_4
# %bb.1:                                # %.lr.ph.preheader
	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	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB9_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rbx,%r15,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB9_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB9_4:                                # %._crit_edge
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end9:
	.size	_Z16printDoubleArrayPdi, .Lfunc_end9-_Z16printDoubleArrayPdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z20matrix_vector_multipPiS_PdiiPS0_ # -- Begin function _Z20matrix_vector_multipPiS_PdiiPS0_
	.type	_Z20matrix_vector_multipPiS_PdiiPS0_,@function
_Z20matrix_vector_multipPiS_PdiiPS0_:   # @_Z20matrix_vector_multipPiS_PdiiPS0_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r9, 16(%rsp)                   # 8-byte Spill
	movl	%r8d, 12(%rsp)                  # 4-byte Spill
	movl	%ecx, %r13d
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbp
	movslq	%ecx, %rbx
	leaq	(,%rbx,8), %rdi
	callq	malloc
	movq	%rax, %r12
	testl	%ebx, %ebx
	jle	.LBB10_1
# %bb.2:                                # %_Z21initializeDoubleArrayPdid.exit
	movl	%r13d, %edx
	shlq	$3, %rdx
	xorl	%ebx, %ebx
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	16(%rsp), %r10                  # 8-byte Reload
	movq	(%r10), %rdi
	cmpl	$1, %r13d
	je	.LBB10_8
# %bb.3:                                # %.lr.ph60.preheader
	leal	-1(%r13), %ebx
	movl	%ebx, %eax
	movl	(%rbp), %r8d
	xorl	%ecx, %ecx
.LBB10_4:                               # %.lr.ph60
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_6 Depth 2
	movl	4(%rbp,%rcx,4), %edx
	xorpd	%xmm0, %xmm0
	cmpl	%edx, %r8d
	jge	.LBB10_7
# %bb.5:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB10_4 Depth=1
	movslq	%edx, %rsi
	movslq	%r8d, %r8
.LBB10_6:                               # %.lr.ph
                                        #   Parent Loop BB10_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	(%r15,%r8,4), %r9
	movsd	(%rdi,%r9,8), %xmm1             # xmm1 = mem[0],zero
	mulsd	(%r14,%r8,8), %xmm1
	addsd	%xmm1, %xmm0
	incq	%r8
	cmpq	%r8, %rsi
	jne	.LBB10_6
.LBB10_7:                               # %._crit_edge
                                        #   in Loop: Header=BB10_4 Depth=1
	movsd	%xmm0, (%r12,%rcx,8)
	incq	%rcx
	movl	%edx, %r8d
	cmpq	%rax, %rcx
	jne	.LBB10_4
	jmp	.LBB10_8
.LBB10_1:                               # %_Z21initializeDoubleArrayPdid.exit.thread
	movq	16(%rsp), %r10                  # 8-byte Reload
	movq	(%r10), %rdi
	leal	-1(%r13), %ebx
.LBB10_8:                               # %._crit_edge61
	movslq	%ebx, %rax
	movl	(%rbp,%rax,4), %ecx
	xorpd	%xmm0, %xmm0
	cmpl	%r13d, %ecx
	jge	.LBB10_12
# %bb.9:                                # %._crit_edge61
	movl	12(%rsp), %edx                  # 4-byte Reload
	cmpl	%edx, %ecx
	jge	.LBB10_12
# %bb.10:                               # %.lr.ph65.preheader
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
.LBB10_11:                              # %.lr.ph65
                                        # =>This Inner Loop Header: Depth=1
	movslq	(%r15,%rcx,4), %rsi
	movsd	(%rdi,%rsi,8), %xmm1            # xmm1 = mem[0],zero
	mulsd	(%r14,%rcx,8), %xmm1
	addsd	%xmm1, %xmm0
	incq	%rcx
	cmpq	%rcx, %rdx
	jne	.LBB10_11
.LBB10_12:                              # %._crit_edge66
	movsd	%xmm0, (%r12,%rax,8)
	movq	%r12, (%r10)
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end10:
	.size	_Z20matrix_vector_multipPiS_PdiiPS0_, .Lfunc_end10-_Z20matrix_vector_multipPiS_PdiiPS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z39__device_stub__initializeDoubleArrayDevPdid # -- Begin function _Z39__device_stub__initializeDoubleArrayDevPdid
	.type	_Z39__device_stub__initializeDoubleArrayDevPdid,@function
_Z39__device_stub__initializeDoubleArrayDevPdid: # @_Z39__device_stub__initializeDoubleArrayDevPdid
	.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	12(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	32(%rsp), %rdx
	movsd	%xmm0, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rdx, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z24initializeDoubleArrayDevPdid, %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_end11:
	.size	_Z39__device_stub__initializeDoubleArrayDevPdid, .Lfunc_end11-_Z39__device_stub__initializeDoubleArrayDevPdid
	.cfi_endproc
                                        # -- End function
	.globl	_Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_S_ # -- Begin function _Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	.type	_Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_S_,@function
_Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_S_: # @_Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	216(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%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	$_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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_end12:
	.size	_Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_S_, .Lfunc_end12-_Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	.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	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$184, %rsp
	.cfi_def_cfa_offset 240
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$4, %edi
	jle	.LBB13_16
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, 40(%rsp)                  # 4-byte Spill
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	leaq	152(%rsp), %r14
	leaq	128(%rsp), %rsi
	leaq	120(%rsp), %rdx
	leaq	12(%rsp), %r15
	leaq	52(%rsp), %r8
	leaq	16(%rsp), %r12
	movq	%r14, %rdi
	movq	%r15, %rcx
	movq	%r12, %r9
	pushq	32(%rbx)
	.cfi_adjust_cfa_offset 8
	callq	_Z10readMatrixPPiS0_PPdRiS3_S3_Pc
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movq	(%r14), %r14
	movslq	(%r15), %rax
	movl	(%r12), %ecx
	subl	-4(%r14,%rax,4), %ecx
	movl	%ecx, -4(%r14,%rax,4)
	cmpq	$2, %rax
	jl	.LBB13_4
# %bb.2:                                # %.lr.ph.preheader.i
	addl	$-2, %eax
	movl	4(%r14,%rax,4), %ecx
.LBB13_3:                               # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	subl	(%r14,%rax,4), %ecx
	movl	%ecx, (%r14,%rax,4)
	addq	$-1, %rax
	jb	.LBB13_3
.LBB13_4:                               # %_Z16accumulateCountsPiii.exit
	movslq	4(%rsp), %rsi
	shlq	$2, %rsi
	leaq	88(%rsp), %rdi
	callq	hipMalloc
	movslq	8(%rsp), %rsi
	shlq	$2, %rsi
	leaq	80(%rsp), %rdi
	callq	hipMalloc
	movslq	8(%rsp), %rsi
	shlq	$3, %rsi
	leaq	72(%rsp), %rdi
	callq	hipMalloc
	leaq	64(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	leaq	56(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	leaq	48(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	movslq	4(%rsp), %rsi
	shlq	$3, %rsi
	leaq	24(%rsp), %rdi
	callq	hipMalloc
	movslq	4(%rsp), %rsi
	shlq	$3, %rsi
	leaq	136(%rsp), %r13
	movq	%r13, %rdi
	callq	hipMalloc
	movslq	4(%rsp), %rsi
	shlq	$3, %rsi
	leaq	16(%rsp), %rdi
	callq	hipMalloc
	movslq	4(%rsp), %rsi
	shlq	$3, %rsi
	leaq	32(%rsp), %rdi
	callq	hipMalloc
	movslq	4(%rsp), %rbx
	leaq	(,%rbx,8), %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r15
	leaq	24(%rsp), %rax
	movq	%r15, (%rax)
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, (%r13)
	testq	%rbx, %rbx
	jle	.LBB13_7
# %bb.5:                                # %.lr.ph.preheader.i35
	movl	%ebx, %eax
	xorl	%ecx, %ecx
	movabsq	$4607182418800017408, %rdx      # imm = 0x3FF0000000000000
.LBB13_6:                               # %.lr.ph.i36
                                        # =>This Inner Loop Header: Depth=1
	movq	%rdx, (%r15,%rcx,8)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB13_6
.LBB13_7:                               # %_Z21initializeDoubleArrayPdid.exit
	movq	88(%rsp), %rdi
	shlq	$2, %rbx
	movq	%r14, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	80(%rsp), %rdi
	movq	120(%rsp), %rsi
	movslq	8(%rsp), %rdx
	shlq	$2, %rdx
	movq	%rsi, 104(%rsp)                 # 8-byte Spill
	movl	$1, %ecx
	callq	hipMemcpy
	movq	72(%rsp), %rdi
	movq	112(%rsp), %rsi
	movslq	8(%rsp), %rdx
	shlq	$3, %rdx
	movq	%rsi, 96(%rsp)                  # 8-byte Spill
	movl	$1, %ecx
	callq	hipMemcpy
	movq	64(%rsp), %rdi
	leaq	4(%rsp), %r12
	movl	$4, %edx
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	56(%rsp), %rdi
	leaq	44(%rsp), %rsi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	132(%rsp), %rsi
	movl	$1, (%rsi)
	movl	(%r12), %ebx
	movl	12(%rsp), %eax                  # 4-byte Reload
	cltd
	idivl	%ebx
	movl	%eax, %r15d
	xorl	%r13d, %r13d
	testl	%edx, %edx
	setg	12(%rsp)                        # 1-byte Folded Spill
	movq	48(%rsp), %rdi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rdi
	movq	24(%rsp), %rsi
	movslq	(%r12), %rdx
	shlq	$3, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	168(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	testl	%ebp, %ebp
	jle	.LBB13_12
# %bb.8:
	movb	12(%rsp), %al                   # 1-byte Reload
	movb	%al, %r13b
	addl	%r13d, %r15d
	shlq	$32, %rbx
	orq	%r15, %rbx
	movabsq	$4294967297, %r15               # imm = 0x100000001
.LBB13_9:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB13_11
# %bb.10:                               #   in Loop: Header=BB13_9 Depth=1
	movq	88(%rsp), %rdi
	movq	80(%rsp), %rsi
	movq	72(%rsp), %rdx
	movq	64(%rsp), %rcx
	movq	56(%rsp), %r8
	movq	16(%rsp), %r9
	pushq	48(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	40(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB13_11:                              #   in Loop: Header=BB13_9 Depth=1
	callq	hipDeviceSynchronize
	movq	16(%rsp), %rax
	movq	32(%rsp), %rcx
	movq	%rcx, 16(%rsp)
	movq	%rax, 32(%rsp)
	decl	%ebp
	jne	.LBB13_9
.LBB13_12:                              # %._crit_edge
	leaq	152(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movslq	4(%rsp), %rdx
	shlq	$3, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	40(%rsp), %eax                  # 4-byte Reload
	cmpl	$1, %eax
	je	.LBB13_17
# %bb.13:                               # %._crit_edge
	cmpl	$2, %eax
	jne	.LBB13_15
# %bb.14:
	movq	24(%rsp), %rdi
	movl	4(%rsp), %esi
	callq	_Z16printDoubleArrayPdi
	jmp	.LBB13_15
.LBB13_17:
	movl	8(%rsp), %esi
	movq	96(%rsp), %rdi                  # 8-byte Reload
	callq	_Z16printDoubleArrayPdi
	movl	8(%rsp), %esi
	movq	104(%rsp), %rdi                 # 8-byte Reload
	callq	_Z10printArrayPii
	movl	4(%rsp), %esi
	movq	%r14, %rdi
	callq	_Z10printArrayPii
.LBB13_15:
	xorl	%eax, %eax
	addq	$184, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB13_16:
	.cfi_def_cfa_offset 240
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end13:
	.size	main, .Lfunc_end13-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB14_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB14_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z24initializeDoubleArrayDevPdid, %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	$_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_, %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_end14:
	.size	__hip_module_ctor, .Lfunc_end14-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB15_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB15_2:
	retq
.Lfunc_end15:
	.size	__hip_module_dtor, .Lfunc_end15-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"r"
	.size	.L.str, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%d %d %d"
	.size	.L.str.2, 9

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

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%lf\n"
	.size	.L.str.6, 5

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

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

	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z24initializeDoubleArrayDevPdid"
	.size	.L__unnamed_1, 33

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_"
	.size	.L__unnamed_2, 47

	.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	"file cant be found"
	.size	.Lstr, 19

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Please enter the all the following arguments:"
	.size	.Lstr.1, 46

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"1. The number of threads used to compute Matrix-vector product"
	.size	.Lstr.2, 63

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"2. The number of repetitions "
	.size	.Lstr.3, 30

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"3. An argument to print on stdout "
	.size	.Lstr.4, 35

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"4. Test-file name"
	.size	.Lstr.5, 18

	.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 _Z39__device_stub__initializeDoubleArrayDevPdid
	.addrsig_sym _Z39__device_stub__matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z24initializeDoubleArrayDevPdid
	.addrsig_sym _Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z24initializeDoubleArrayDevPdid ; -- Begin function _Z24initializeDoubleArrayDevPdid
	.globl	_Z24initializeDoubleArrayDevPdid
	.p2align	8
	.type	_Z24initializeDoubleArrayDevPdid,@function
_Z24initializeDoubleArrayDevPdid:       ; @_Z24initializeDoubleArrayDevPdid
; %bb.0:
	s_load_b32 s2, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	s_clause 0x1
	s_load_b64 s[4:5], s[0:1], 0x10
	s_load_b64 s[0:1], s[0:1], 0x0
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v0, s4 :: v_dual_mov_b32 v1, s5
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_add_i32 s2, s2, -1
	global_store_b64 v2, v[0:1], s[0:1]
	s_add_u32 s0, s0, 8
	s_addc_u32 s1, s1, 0
	s_cmp_lg_u32 s2, 0
	s_cbranch_scc1 .LBB0_2
.LBB0_3:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z24initializeDoubleArrayDevPdid
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 3
		.amdhsa_next_free_sgpr 6
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z24initializeDoubleArrayDevPdid, .Lfunc_end0-_Z24initializeDoubleArrayDevPdid
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 96
; NumSgprs: 6
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 6
; NumVGPRsForWavesPerEU: 3
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_ ; -- Begin function _Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	.globl	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
	.p2align	8
	.type	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_,@function
_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_: ; @_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
; %bb.0:
	s_clause 0x2
	s_load_b512 s[16:31], s[0:1], 0x0
	s_load_b32 s3, s[0:1], 0x4c
	s_load_b32 s0, s[0:1], 0x40
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_load_b32 s1, s[30:31], 0x0
	s_lshr_b32 s2, s3, 16
	s_load_b32 s4, s[22:23], 0x0
	v_mad_u64_u32 v[2:3], null, s15, s2, v[1:2]
	s_load_b32 s2, s[24:25], 0x0
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s0, s0, s1
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mul_lo_u32 v1, s0, v2
	s_and_b32 s0, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_mul_i32 s14, s14, s0
	s_mov_b32 s0, exec_lo
	v_add3_u32 v2, s14, v0, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_cmpx_gt_i32_e64 s4, v2
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 3, v[2:3]
	v_mov_b32_e32 v4, 0
	v_mov_b32_e32 v5, v4
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, s28, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s29, v1, vcc_lo
	global_store_b64 v[0:1], v[4:5], off
.LBB1_2:
	s_or_b32 exec_lo, exec_lo, s0
	s_add_i32 s0, s4, -1
	s_mov_b32 s6, -1
                                        ; implicit-def: $vgpr5_vgpr6
                                        ; implicit-def: $vgpr0_vgpr1
                                        ; implicit-def: $vgpr9_vgpr10
	s_mov_b32 s1, exec_lo
	v_cmpx_le_i32_e64 s0, v2
	s_xor_b32 s3, exec_lo, s1
	s_cbranch_execz .LBB1_14
; %bb.3:
	v_cmp_eq_u32_e32 vcc_lo, s0, v2
	s_mov_b32 s5, 0
                                        ; implicit-def: $vgpr4
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB1_5
; %bb.4:
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_mov_b32 s5, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s16, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s17, v1, vcc_lo
	global_load_b32 v4, v[0:1], off
	s_waitcnt vmcnt(0)
	v_cmp_le_i32_e32 vcc_lo, s4, v4
	s_or_not1_b32 s6, vcc_lo, exec_lo
.LBB1_5:                                ; %Flow125
	s_or_b32 exec_lo, exec_lo, s0
	v_lshlrev_b64 v[7:8], 3, v[2:3]
                                        ; implicit-def: $vgpr5_vgpr6
                                        ; implicit-def: $vgpr0_vgpr1
                                        ; implicit-def: $sgpr0_sgpr1
	s_and_saveexec_b32 s7, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s6, exec_lo, s7
	s_cbranch_execz .LBB1_7
; %bb.6:                                ; %._crit_edge81
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v5, vcc_lo, s28, v7
	v_add_co_ci_u32_e32 v6, vcc_lo, s29, v8, vcc_lo
	s_mov_b64 s[0:1], 0
	s_and_not1_b32 s5, s5, exec_lo
	global_load_b64 v[0:1], v[5:6], off
.LBB1_7:                                ; %Flow126
	s_or_b32 exec_lo, exec_lo, s6
	v_dual_mov_b32 v10, s1 :: v_dual_mov_b32 v9, s0
	s_and_saveexec_b32 s1, s5
	s_cbranch_execz .LBB1_13
; %bb.8:                                ; %.preheader72
	s_waitcnt vmcnt(0)
	v_mov_b32_e32 v0, 0
	v_mov_b32_e32 v1, 0
	s_mov_b32 s5, exec_lo
	v_cmpx_gt_i32_e64 s2, v4
	s_cbranch_execz .LBB1_12
; %bb.9:                                ; %.lr.ph.preheader
	v_mad_u64_u32 v[0:1], null, v2, s4, v[4:5]
	v_ashrrev_i32_e32 v5, 31, v4
	s_mov_b32 s4, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[5:6], 2, v[4:5]
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[2:3], 3, v[0:1]
	v_mov_b32_e32 v0, 0
	v_mov_b32_e32 v1, 0
	v_add_co_u32 v2, vcc_lo, s20, v2
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v3, vcc_lo, s21, v3, vcc_lo
	v_add_co_u32 v5, vcc_lo, s18, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s19, v6, vcc_lo
.LBB1_10:                               ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v9, v[5:6], off
	v_add_nc_u32_e32 v4, 1, v4
	v_add_co_u32 v5, s0, v5, 4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v6, s0, 0, v6, s0
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v10, 31, v9
	v_lshlrev_b64 v[9:10], 3, v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v9, vcc_lo, s26, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, s27, v10, vcc_lo
	global_load_b64 v[11:12], v[2:3], off
	global_load_b64 v[9:10], v[9:10], off
	v_add_co_u32 v2, vcc_lo, v2, 8
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	v_cmp_le_i32_e32 vcc_lo, s2, v4
	s_or_b32 s4, vcc_lo, s4
	s_waitcnt vmcnt(0)
	v_fma_f64 v[0:1], v[9:10], v[11:12], v[0:1]
	s_and_not1_b32 exec_lo, exec_lo, s4
	s_cbranch_execnz .LBB1_10
; %bb.11:                               ; %Flow
	s_or_b32 exec_lo, exec_lo, s4
.LBB1_12:                               ; %Flow124
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s5
	v_add_co_u32 v5, vcc_lo, s28, v7
	v_add_co_ci_u32_e32 v6, vcc_lo, s29, v8, vcc_lo
	global_load_b64 v[9:10], v[5:6], off
.LBB1_13:                               ; %Flow127
	s_or_b32 exec_lo, exec_lo, s1
                                        ; implicit-def: $vgpr2
.LBB1_14:                               ; %Flow132
	s_and_not1_saveexec_b32 s1, s3
	s_cbranch_execz .LBB1_24
; %bb.15:
	s_waitcnt vmcnt(0)
	v_lshlrev_b64 v[0:1], 2, v[2:3]
                                        ; implicit-def: $vgpr5_vgpr6
                                        ; implicit-def: $vgpr9_vgpr10
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s16, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s17, v1, vcc_lo
	global_load_b64 v[7:8], v[0:1], off
                                        ; implicit-def: $vgpr0_vgpr1
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e64 v7, v8
	s_xor_b32 s2, exec_lo, s0
	s_cbranch_execz .LBB1_21
; %bb.16:                               ; %.preheader
	v_mov_b32_e32 v0, 0
	v_mov_b32_e32 v1, 0
	s_mov_b32 s3, exec_lo
	v_cmpx_lt_i32_e64 v7, v8
	s_cbranch_execz .LBB1_20
; %bb.17:                               ; %.lr.ph77.preheader
	v_ashrrev_i32_e32 v5, 31, v7
	v_mov_b32_e32 v4, v7
	v_mov_b32_e32 v0, 0
	v_mov_b32_e32 v1, 0
	s_mov_b32 s4, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[9:10], 2, v[4:5]
	v_lshlrev_b64 v[11:12], 3, v[4:5]
	v_add_co_u32 v4, vcc_lo, s18, v9
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v5, vcc_lo, s19, v10, vcc_lo
	v_add_co_u32 v9, vcc_lo, s20, v11
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v10, vcc_lo, s21, v12, vcc_lo
.LBB1_18:                               ; %.lr.ph77
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v11, v[4:5], off
	v_add_nc_u32_e32 v7, 1, v7
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v12, 31, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[11:12], 3, v[11:12]
	v_add_co_u32 v11, vcc_lo, s26, v11
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v12, vcc_lo, s27, v12, vcc_lo
	v_add_co_u32 v4, vcc_lo, v4, 4
	global_load_b64 v[13:14], v[9:10], off
	global_load_b64 v[11:12], v[11:12], off
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	v_cmp_ge_i32_e32 vcc_lo, v7, v8
	v_add_co_u32 v9, s0, v9, 8
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v10, s0, 0, v10, s0
	s_or_b32 s4, vcc_lo, s4
	s_waitcnt vmcnt(0)
	v_fma_f64 v[0:1], v[11:12], v[13:14], v[0:1]
	s_and_not1_b32 exec_lo, exec_lo, s4
	s_cbranch_execnz .LBB1_18
; %bb.19:                               ; %Flow128
	s_or_b32 exec_lo, exec_lo, s4
.LBB1_20:                               ; %Flow129
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s3
	v_lshlrev_b64 v[2:3], 3, v[2:3]
	v_add_co_u32 v5, vcc_lo, s28, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v6, vcc_lo, s29, v3, vcc_lo
                                        ; implicit-def: $vgpr2_vgpr3
	global_load_b64 v[9:10], v[5:6], off
.LBB1_21:                               ; %Flow130
	s_and_not1_saveexec_b32 s0, s2
	s_cbranch_execz .LBB1_23
; %bb.22:
	v_lshlrev_b64 v[0:1], 3, v[2:3]
	s_waitcnt vmcnt(0)
	v_mov_b32_e32 v9, 0
	v_mov_b32_e32 v10, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v5, vcc_lo, s28, v0
	v_add_co_ci_u32_e32 v6, vcc_lo, s29, v1, vcc_lo
	global_load_b64 v[0:1], v[5:6], off
.LBB1_23:                               ; %Flow131
	s_or_b32 exec_lo, exec_lo, s0
.LBB1_24:
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s1
	s_waitcnt vmcnt(0)
	v_add_f64 v[0:1], v[0:1], v[9:10]
	global_store_b64 v[5:6], v[0:1], off
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 15
		.amdhsa_next_free_sgpr 32
		.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	_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_, .Lfunc_end1-_Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1072
; NumSgprs: 34
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 4
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 34
; NumVGPRsForWavesPerEU: 15
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.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:           8
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z24initializeDoubleArrayDevPdid
    .private_segment_fixed_size: 0
    .sgpr_count:     6
    .sgpr_spill_count: 0
    .symbol:         _Z24initializeDoubleArrayDevPdid.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         48
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         56
        .size:           8
        .value_kind:     global_buffer
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     34
    .sgpr_spill_count: 0
    .symbol:         _Z24matrix_vector_multip_devPiS_PdS_S_S0_S0_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
