#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
// Step 1: Query Device for maximum block sizes and thread sizes
// (not really sure what we care about)
// Step 2: Take in user input to specify data dimensions
// Step 3: Check to make sure user inputs match with specified program device queries

int TOTAL_GLOBAL_MEM, REGS_PER_BLOCK, WARP_SIZE, MAX_THREADS_PER_BLOCK, *MAX_THREADS_DIM;

__global__
void vec_mult_add(const unsigned int * A, const unsigned int * B, const unsigned int c, unsigned int * D, int num_elements)
{
    /*int i = blockDim.x * blockIdx.x + threadIdx.x;

    if (i < numElements)
    {
        C[i] = A[i] + B[i];
    }*/

    int id = blockDim.x * blockIdx.x + threadIdx.x;
    if (id < num_elements) {
	D[id] = c*A[id] + B[id];
    } 
} 
// Device Query Information:
void getHardwareConstraints() {

//=============================Gets number of cuda devices===========================================
    int deviceCount = 0;
    cudaError_t error_id = cudaGetDeviceCount(&deviceCount);

    if (error_id != cudaSuccess)
    {
        printf("cudaGetDeviceCount returned %d\n-> %s\n", (int)error_id, cudaGetErrorString(error_id));
        printf("Result = FAIL\n");
        exit(EXIT_FAILURE);
    }

    // This function call returns 0 if there are no CUDA capable devices.
    if (deviceCount == 0)
    {
        printf("There are no available device(s) that support CUDA\n");
    }
    else
    {
        printf("Detected %d CUDA Capable device(s)\n", deviceCount);
    }
//=============================Gets number of cuda devices===========================================
    
    // for each device found, store this device in some type of object
    int device;

    for (device = 0; device < deviceCount; device++) {
	
	// Sets the context of the device so that we know which device we are working with if there
	// are multiple	
	cudaSetDevice(device);
        cudaDeviceProp deviceProp;

	// gets the "properties" struct that stores the properties of a device
	// from this property struct, we can query the limitations of this device
        cudaGetDeviceProperties(&deviceProp, device);

	printf("\nDevice: %d \"%s\"\n===========================================\n", device, deviceProp.name);
	
	TOTAL_GLOBAL_MEM = deviceProp.totalGlobalMem;
	REGS_PER_BLOCK = deviceProp.regsPerBlock;
	WARP_SIZE = deviceProp.warpSize;
	MAX_THREADS_PER_BLOCK = deviceProp.maxThreadsPerBlock;
	MAX_THREADS_DIM = deviceProp.maxThreadsDim; 
	printf("The %s has:\n\t-%zu total bytes of global memory\n\t-%d registers per block\n\t-%d threads per warp\n\t-A maximum of %d threads per block\n\t-And a maximum thread dimension of %d x %d x %d\n", deviceProp.name, TOTAL_GLOBAL_MEM, REGS_PER_BLOCK, WARP_SIZE, MAX_THREADS_PER_BLOCK, MAX_THREADS_DIM[0], MAX_THREADS_DIM[1], MAX_THREADS_DIM[2]); 
	// What I think we care about:
	// 1. totalGlobalMem
	// 2. regsPerBlock
	// 3. warpSize (i.e. numThreadsPerBlock (is this equal to regsPerBlock??)
	// 4. maxThreadsperBlock
	// 5. maxThreadsDim[3]
    }

}

void printVector(unsigned int * A, int numElements) {
    printf("\n[");
    for(int i = 0; i < numElements; i++){
        printf("\n   %d",A[i]);
    }
    printf("\n]\n");
}

void checkOutput(unsigned int * A, int numElements) {
    bool incorrect = false;
    for(int i = 0; i < numElements; i++) {
	if(A[i] != (2*i + i)) {
	    incorrect = true;
	    printf("\nIncorrect value of %d at index %d... should be %d\n", A[i], i, (2*i + i));   
	}
    } 
    if(!incorrect) {
    	printf("\nOutput is Correct!\n");
    }
}
void elementWiseMult_Add() {

}

int main(int argc, char* argv[]) {
    
    int numThreads;
    int blockSize;
    numThreads = atoi(argv[1]);
    blockSize = atoi(argv[2]);
    
    getHardwareConstraints();    
    /*std::cout << "This program will take two arrays of integers from 0-1023, multiply them the first array by a constant of 2, and add the first array to the second array\n";
    std::cout << "You must first specify a number of threads you would like to use for this operation: ";
    std::cin >> numThreads;
    std::cout << "\nAnd a block size: ";
    std::cin >> blockSize;*/
    printf("numThreads: %d and blockSize: %d\n", numThreads, blockSize);
    // keep track of errors from cuda operations
    cudaError_t err = cudaSuccess;

// this will be taken from cmd
    int numElements = 1024;

    size_t size = numElements * sizeof(int);
    // Allocate the host input vector A
    unsigned int *h_A = (unsigned int *)malloc(size);

    // Allocate the host input vector B
    unsigned int *h_B = (unsigned int *)malloc(size);

    // Allocate the host output vector C
    unsigned int *h_D = (unsigned int *)malloc(size);
    
    //srand(time(NULL));
    int c = 2;
    
    // initialize host input vectors
    for(int i = 0; i < numElements; i++){
	h_A[i] = i;
	h_B[i] = i;
    }
    // DEBUG
    //printf("%d * \n", c);
    //printVector(h_A, numElements);
    //printf(" + \n");
    //printVector(h_B, numElements);

    // Allocate device input vector
    // Allocate the device input vector A
    unsigned int *d_A = NULL;
    err = cudaMalloc((void **)&d_A, size);
    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to allocate device vector A (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }
    
    // Allocate device input vector B
    unsigned int *d_B = NULL;
    err = cudaMalloc((void **)&d_B, size);
    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to allocate device vector B (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Allocate device output vector D
    // Allocate device input vector B
    unsigned int *d_D = NULL;
    err = cudaMalloc((void **)&d_D, size);
    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to allocate device vector D (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Copy the host input vectors A and B in host memory to the device input vectors in
    // device memory
    //printf("Copy input data from the host memory to the CUDA device\n");
    err = cudaMemcpy(d_A, h_A, size, cudaMemcpyHostToDevice);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to copy vector A from host to device (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    //printf("Copy input data from the host memory to the CUDA device\n");
    err = cudaMemcpy(d_B, h_B, size, cudaMemcpyHostToDevice);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to copy vector B from host to device (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // calculate appropriate thread size 
    // Launch the Vector Add CUDA Kernel
    int threadsPerBlock = blockSize;
    int blocksPerGrid = numThreads / threadsPerBlock;    
//int blocksPerGrid =(numElements + threadsPerBlock - 1) / threadsPerBlock;
    //printf("CUDA kernel launch with %d blocks of %d threads\n", blocksPerGrid, threadsPerBlock);
    vec_mult_add<<<blocksPerGrid, threadsPerBlock>>>(d_A, d_B, c, d_D, numElements);
    err = cudaGetLastError();

    if(err != cudaSuccess) {
	fprintf(stderr, "Failed to execute kernel (error code %s)!\n", cudaGetErrorString(err));
	exit(EXIT_FAILURE);
    }

    err = cudaMemcpy(h_D, d_D, size, cudaMemcpyDeviceToHost);
    
    if(err != cudaSuccess) {
	fprintf(stderr, "Failed to copy kernel back to host (error code %s)!\n", cudaGetErrorString(err));
    	exit(EXIT_FAILURE);
    }
    checkOutput(h_D, numElements);
    //printf(" = \n");
    //printVector(h_D, numElements);
    err = cudaFree(d_A);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to free device vector A (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    err = cudaFree(d_B);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to free device vector B (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    err = cudaFree(d_D);

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to free device vector C (error code %s)!\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Free host memory
    free(h_A);
    free(h_B);
    free(h_D);

    // Reset the device and exit
    // cudaDeviceReset causes the driver to clean up all state. While
    // not mandatory in normal operation, it is good practice.  It is also
    // needed to ensure correct operation when the application is being
    // profiled. Calling cudaDeviceReset causes all profile data to be
    // flushed before the application exits
    err = cudaDeviceReset();

    if (err != cudaSuccess)
    {
        fprintf(stderr, "Failed to deinitialize the device! error=%s\n", cudaGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    printf("Done\n");
   
    //printf("Here are random numbers %d %d\n", (rand() % 11), (rand() % 11));
    
    return(EXIT_SUCCESS);
}

	.file	"tmpxft_003b7ac3_00000000-6_dynamicDataSize.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3642:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3642:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"cudaGetDeviceCount returned %d\n-> %s\n"
.LC1:
	.string	"Result = FAIL\n"
.LC2:
	.string	"There are no available device(s) that support CUDA\n"
.LC3:
	.string	"Detected %d CUDA Capable device(s)\n"
.LC4:
	.string	"\nDevice: %d \"%s\"\n===========================================\n"
.LC5:
	.string	"The %s has:\n\t-%zu total bytes of global memory\n\t-%d registers per block\n\t-%d threads per warp\n\t-A maximum of %d threads per block\n\t-And a maximum thread dimension of %d x %d x %d\n"
	.text
	.globl	_Z22getHardwareConstraintsv
	.type	_Z22getHardwareConstraintsv, @function
_Z22getHardwareConstraintsv:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$1056, %rsp
	.cfi_def_cfa_offset 1088
	movq	%fs:40, %rax
	movq	%rax, 1048(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdi
	xorl	%eax, %eax
	movl	%eax, 12(%rsp)
	call	cudaGetDeviceCount@PLT
	testl	%eax, %eax
	je	.L3
	movl	%eax, %edi
	movl	%eax, %ebx
	call	cudaGetErrorString@PLT
	movl	%ebx, %edx
	movl	$2, %edi
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L3:
	movl	12(%rsp), %edx
	testl	%edx, %edx
	jne	.L4
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L6:
	xorl	%ebx, %ebx
	leaq	.LC4(%rip), %r12
	jmp	.L5
.L4:
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L6
.L5:
	cmpl	%ebx, 12(%rsp)
	jle	.L11
	leaq	16(%rsp), %rbp
	movl	%ebx, %edi
	call	cudaSetDevice@PLT
	movl	%ebx, %esi
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movl	%ebx, %edx
	movq	%rbp, %rcx
	movq	%r12, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%ebx
	call	__printf_chk@PLT
	leaq	340(%rsp), %rdx
	movq	304(%rsp), %rax
	movl	320(%rsp), %r8d
	movq	%rdx, MAX_THREADS_DIM(%rip)
	movl	348(%rsp), %edx
	movl	$2, %edi
	leaq	.LC5(%rip), %rsi
	movl	324(%rsp), %r9d
	movl	%eax, TOTAL_GLOBAL_MEM(%rip)
	movl	%eax, %ecx
	movl	336(%rsp), %eax
	pushq	%rdx
	.cfi_def_cfa_offset 1096
	movl	352(%rsp), %edx
	movl	%r8d, REGS_PER_BLOCK(%rip)
	movl	%eax, MAX_THREADS_PER_BLOCK(%rip)
	pushq	%rdx
	.cfi_def_cfa_offset 1104
	movl	356(%rsp), %edx
	movl	%r9d, WARP_SIZE(%rip)
	pushq	%rdx
	.cfi_def_cfa_offset 1112
	movq	%rbp, %rdx
	pushq	%rax
	.cfi_def_cfa_offset 1120
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 1088
	jmp	.L5
.L11:
	movq	1048(%rsp), %rax
	subq	%fs:40, %rax
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	addq	$1056, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z22getHardwareConstraintsv, .-_Z22getHardwareConstraintsv
	.section	.rodata.str1.1
.LC6:
	.string	"\n["
.LC7:
	.string	"\n   %d"
.LC8:
	.string	"\n]\n"
	.text
	.globl	_Z11printVectorPji
	.type	_Z11printVectorPji, @function
_Z11printVectorPji:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	.LC7(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	movl	$2, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%esi, %ebp
	leaq	.LC6(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
	call	__printf_chk@PLT
.L13:
	cmpl	%ebx, %ebp
	jle	.L16
	movl	(%r12,%rbx,4), %edx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L13
.L16:
	popq	%rdx
	.cfi_def_cfa_offset 40
	leaq	.LC8(%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
.LFE3636:
	.size	_Z11printVectorPji, .-_Z11printVectorPji
	.section	.rodata.str1.1
.LC9:
	.string	"\nIncorrect value of %d at index %d... should be %d\n"
.LC10:
	.string	"\nOutput is Correct!\n"
	.text
	.globl	_Z11checkOutputPji
	.type	_Z11checkOutputPji, @function
_Z11checkOutputPji:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	.LC9(%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
.L18:
	movl	%ebx, %ecx
	cmpl	%ebx, %ebp
	jle	.L23
	movl	(%r12,%rbx,4), %edx
	leal	(%rbx,%rbx,2), %r8d
	cmpl	%r8d, %edx
	je	.L19
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movb	$1, %al
.L19:
	incq	%rbx
	jmp	.L18
.L23:
	testb	%al, %al
	jne	.L17
	popq	%rdx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	leaq	.LC10(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
.L17:
	.cfi_restore_state
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3637:
	.size	_Z11checkOutputPji, .-_Z11checkOutputPji
	.globl	_Z19elementWiseMult_Addv
	.type	_Z19elementWiseMult_Addv, @function
_Z19elementWiseMult_Addv:
.LFB3638:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE3638:
	.size	_Z19elementWiseMult_Addv, .-_Z19elementWiseMult_Addv
	.globl	_Z40__device_stub__Z12vec_mult_addPKjS0_jPjiPKjS0_jPji
	.type	_Z40__device_stub__Z12vec_mult_addPKjS0_jPjiPKjS0_jPji, @function
_Z40__device_stub__Z12vec_mult_addPKjS0_jPjiPKjS0_jPji:
.LFB3664:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movq	%rsp, %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z12vec_mult_addPKjS0_jPji(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	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 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L25:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3664:
	.size	_Z40__device_stub__Z12vec_mult_addPKjS0_jPjiPKjS0_jPji, .-_Z40__device_stub__Z12vec_mult_addPKjS0_jPjiPKjS0_jPji
	.globl	_Z12vec_mult_addPKjS0_jPji
	.type	_Z12vec_mult_addPKjS0_jPji, @function
_Z12vec_mult_addPKjS0_jPji:
.LFB3665:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z12vec_mult_addPKjS0_jPjiPKjS0_jPji
	.cfi_endproc
.LFE3665:
	.size	_Z12vec_mult_addPKjS0_jPji, .-_Z12vec_mult_addPKjS0_jPji
	.section	.rodata.str1.1
.LC11:
	.string	"numThreads: %d and blockSize: %d\n"
.LC12:
	.string	"Failed to allocate device vector A (error code %s)!\n"
.LC13:
	.string	"Failed to allocate device vector B (error code %s)!\n"
.LC14:
	.string	"Failed to allocate device vector D (error code %s)!\n"
.LC15:
	.string	"Failed to copy vector A from host to device (error code %s)!\n"
.LC16:
	.string	"Failed to copy vector B from host to device (error code %s)!\n"
.LC17:
	.string	"Failed to execute kernel (error code %s)!\n"
.LC18:
	.string	"Failed to copy kernel back to host (error code %s)!\n"
.LC19:
	.string	"Failed to free device vector A (error code %s)!\n"
.LC20:
	.string	"Failed to free device vector B (error code %s)!\n"
.LC21:
	.string	"Failed to free device vector C (error code %s)!\n"
.LC22:
	.string	"Failed to deinitialize the device! error=%s\n"
.LC23:
	.string	"Done\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3639:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	8(%rsi), %rdi
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	atoi@PLT
	movq	16(%rbp), %rdi
	movl	%eax, %ebx
	call	atoi@PLT
	movl	%eax, %ebp
	call	_Z22getHardwareConstraintsv
	movl	%ebp, %ecx
	movl	%ebx, %edx
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$4096, %edi
	call	malloc@PLT
	movl	$4096, %edi
	movq	%rax, %r14
	call	malloc@PLT
	movl	$4096, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movq	%rax, %r12
	xorl	%eax, %eax
.L31:
	movl	%eax, (%r14,%rax,4)
	movl	%eax, 0(%r13,%rax,4)
	incq	%rax
	cmpq	$1024, %rax
	jne	.L31
	xorl	%ecx, %ecx
	leaq	8(%rsp), %rdi
	movl	$4096, %esi
	movq	%rcx, 8(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L32
	call	cudaGetErrorString@PLT
	leaq	.LC12(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L32:
	xorl	%edx, %edx
	leaq	16(%rsp), %rdi
	movl	$4096, %esi
	movq	%rdx, 16(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L33
	call	cudaGetErrorString@PLT
	leaq	.LC13(%rip), %rdx
	movq	%rax, %rcx
.L47:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L33:
	xorl	%eax, %eax
	leaq	24(%rsp), %rdi
	movl	$4096, %esi
	movq	%rax, 24(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L34
	call	cudaGetErrorString@PLT
	leaq	.LC14(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L34:
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$4096, %edx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L35
	call	cudaGetErrorString@PLT
	leaq	.LC15(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L35:
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movl	$4096, %edx
	movq	%r13, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L36
	call	cudaGetErrorString@PLT
	leaq	.LC16(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L36:
	movl	%ebx, %eax
	movl	%ebp, 44(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rcx
	cltd
	idivl	%ebp
	movq	%rcx, 36(%rsp)
	movl	40(%rsp), %esi
	movq	%rcx, 48(%rsp)
	movl	52(%rsp), %ecx
	movq	44(%rsp), %rdx
	movl	%eax, 32(%rsp)
	movq	32(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	movq	24(%rsp), %rcx
	movq	16(%rsp), %rsi
	movl	$2, %edx
	movl	$1024, %r8d
	movq	8(%rsp), %rdi
	call	_Z40__device_stub__Z12vec_mult_addPKjS0_jPjiPKjS0_jPji
.L37:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L38
	call	cudaGetErrorString@PLT
	leaq	.LC17(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L38:
	movq	24(%rsp), %rsi
	movq	%r12, %rdi
	movl	$2, %ecx
	movl	$4096, %edx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L39
	call	cudaGetErrorString@PLT
	leaq	.LC18(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L39:
	movl	$1024, %esi
	movq	%r12, %rdi
	call	_Z11checkOutputPji
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L40
	call	cudaGetErrorString@PLT
	leaq	.LC19(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L40:
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L41
	call	cudaGetErrorString@PLT
	leaq	.LC20(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L41:
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L42
	call	cudaGetErrorString@PLT
	leaq	.LC21(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L42:
	movq	%r14, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L43
	call	cudaGetErrorString@PLT
	leaq	.LC22(%rip), %rdx
	movq	%rax, %rcx
	jmp	.L47
.L43:
	xorl	%eax, %eax
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3639:
	.size	main, .-main
	.section	.rodata.str1.1
.LC24:
	.string	"_Z12vec_mult_addPKjS0_jPji"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3667:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC24(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z12vec_mult_addPKjS0_jPji(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3667:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	MAX_THREADS_DIM
	.bss
	.align 8
	.type	MAX_THREADS_DIM, @object
	.size	MAX_THREADS_DIM, 8
MAX_THREADS_DIM:
	.zero	8
	.globl	MAX_THREADS_PER_BLOCK
	.align 4
	.type	MAX_THREADS_PER_BLOCK, @object
	.size	MAX_THREADS_PER_BLOCK, 4
MAX_THREADS_PER_BLOCK:
	.zero	4
	.globl	WARP_SIZE
	.align 4
	.type	WARP_SIZE, @object
	.size	WARP_SIZE, 4
WARP_SIZE:
	.zero	4
	.globl	REGS_PER_BLOCK
	.align 4
	.type	REGS_PER_BLOCK, @object
	.size	REGS_PER_BLOCK, 4
REGS_PER_BLOCK:
	.zero	4
	.globl	TOTAL_GLOBAL_MEM
	.align 4
	.type	TOTAL_GLOBAL_MEM, @object
	.size	TOTAL_GLOBAL_MEM, 4
TOTAL_GLOBAL_MEM:
	.zero	4
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
// Step 1: Query Device for maximum block sizes and thread sizes
// (not really sure what we care about)
// Step 2: Take in user input to specify data dimensions
// Step 3: Check to make sure user inputs match with specified program device queries

int TOTAL_GLOBAL_MEM, REGS_PER_BLOCK, WARP_SIZE, MAX_THREADS_PER_BLOCK, *MAX_THREADS_DIM;

__global__
void vec_mult_add(const unsigned int * A, const unsigned int * B, const unsigned int c, unsigned int * D, int num_elements)
{
    /*int i = blockDim.x * blockIdx.x + threadIdx.x;

    if (i < numElements)
    {
        C[i] = A[i] + B[i];
    }*/

    int id = blockDim.x * blockIdx.x + threadIdx.x;
    if (id < num_elements) {
	D[id] = c*A[id] + B[id];
    } 
} 
// Device Query Information:
void getHardwareConstraints() {

//=============================Gets number of cuda devices===========================================
    int deviceCount = 0;
    hipError_t error_id = hipGetDeviceCount(&deviceCount);

    if (error_id != hipSuccess)
    {
        printf("hipGetDeviceCount returned %d\n-> %s\n", (int)error_id, hipGetErrorString(error_id));
        printf("Result = FAIL\n");
        exit(EXIT_FAILURE);
    }

    // This function call returns 0 if there are no CUDA capable devices.
    if (deviceCount == 0)
    {
        printf("There are no available device(s) that support CUDA\n");
    }
    else
    {
        printf("Detected %d CUDA Capable device(s)\n", deviceCount);
    }
//=============================Gets number of cuda devices===========================================
    
    // for each device found, store this device in some type of object
    int device;

    for (device = 0; device < deviceCount; device++) {
	
	// Sets the context of the device so that we know which device we are working with if there
	// are multiple	
	hipSetDevice(device);
        hipDeviceProp_t deviceProp;

	// gets the "properties" struct that stores the properties of a device
	// from this property struct, we can query the limitations of this device
        hipGetDeviceProperties(&deviceProp, device);

	printf("\nDevice: %d \"%s\"\n===========================================\n", device, deviceProp.name);
	
	TOTAL_GLOBAL_MEM = deviceProp.totalGlobalMem;
	REGS_PER_BLOCK = deviceProp.regsPerBlock;
	WARP_SIZE = deviceProp.warpSize;
	MAX_THREADS_PER_BLOCK = deviceProp.maxThreadsPerBlock;
	MAX_THREADS_DIM = deviceProp.maxThreadsDim; 
	printf("The %s has:\n\t-%zu total bytes of global memory\n\t-%d registers per block\n\t-%d threads per warp\n\t-A maximum of %d threads per block\n\t-And a maximum thread dimension of %d x %d x %d\n", deviceProp.name, TOTAL_GLOBAL_MEM, REGS_PER_BLOCK, WARP_SIZE, MAX_THREADS_PER_BLOCK, MAX_THREADS_DIM[0], MAX_THREADS_DIM[1], MAX_THREADS_DIM[2]); 
	// What I think we care about:
	// 1. totalGlobalMem
	// 2. regsPerBlock
	// 3. warpSize (i.e. numThreadsPerBlock (is this equal to regsPerBlock??)
	// 4. maxThreadsperBlock
	// 5. maxThreadsDim[3]
    }

}

void printVector(unsigned int * A, int numElements) {
    printf("\n[");
    for(int i = 0; i < numElements; i++){
        printf("\n   %d",A[i]);
    }
    printf("\n]\n");
}

void checkOutput(unsigned int * A, int numElements) {
    bool incorrect = false;
    for(int i = 0; i < numElements; i++) {
	if(A[i] != (2*i + i)) {
	    incorrect = true;
	    printf("\nIncorrect value of %d at index %d... should be %d\n", A[i], i, (2*i + i));   
	}
    } 
    if(!incorrect) {
    	printf("\nOutput is Correct!\n");
    }
}
void elementWiseMult_Add() {

}

int main(int argc, char* argv[]) {
    
    int numThreads;
    int blockSize;
    numThreads = atoi(argv[1]);
    blockSize = atoi(argv[2]);
    
    getHardwareConstraints();    
    /*std::cout << "This program will take two arrays of integers from 0-1023, multiply them the first array by a constant of 2, and add the first array to the second array\n";
    std::cout << "You must first specify a number of threads you would like to use for this operation: ";
    std::cin >> numThreads;
    std::cout << "\nAnd a block size: ";
    std::cin >> blockSize;*/
    printf("numThreads: %d and blockSize: %d\n", numThreads, blockSize);
    // keep track of errors from cuda operations
    hipError_t err = hipSuccess;

// this will be taken from cmd
    int numElements = 1024;

    size_t size = numElements * sizeof(int);
    // Allocate the host input vector A
    unsigned int *h_A = (unsigned int *)malloc(size);

    // Allocate the host input vector B
    unsigned int *h_B = (unsigned int *)malloc(size);

    // Allocate the host output vector C
    unsigned int *h_D = (unsigned int *)malloc(size);
    
    //srand(time(NULL));
    int c = 2;
    
    // initialize host input vectors
    for(int i = 0; i < numElements; i++){
	h_A[i] = i;
	h_B[i] = i;
    }
    // DEBUG
    //printf("%d * \n", c);
    //printVector(h_A, numElements);
    //printf(" + \n");
    //printVector(h_B, numElements);

    // Allocate device input vector
    // Allocate the device input vector A
    unsigned int *d_A = NULL;
    err = hipMalloc((void **)&d_A, size);
    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to allocate device vector A (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }
    
    // Allocate device input vector B
    unsigned int *d_B = NULL;
    err = hipMalloc((void **)&d_B, size);
    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to allocate device vector B (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Allocate device output vector D
    // Allocate device input vector B
    unsigned int *d_D = NULL;
    err = hipMalloc((void **)&d_D, size);
    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to allocate device vector D (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Copy the host input vectors A and B in host memory to the device input vectors in
    // device memory
    //printf("Copy input data from the host memory to the CUDA device\n");
    err = hipMemcpy(d_A, h_A, size, hipMemcpyHostToDevice);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to copy vector A from host to device (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    //printf("Copy input data from the host memory to the CUDA device\n");
    err = hipMemcpy(d_B, h_B, size, hipMemcpyHostToDevice);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to copy vector B from host to device (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // calculate appropriate thread size 
    // Launch the Vector Add CUDA Kernel
    int threadsPerBlock = blockSize;
    int blocksPerGrid = numThreads / threadsPerBlock;    
//int blocksPerGrid =(numElements + threadsPerBlock - 1) / threadsPerBlock;
    //printf("CUDA kernel launch with %d blocks of %d threads\n", blocksPerGrid, threadsPerBlock);
    vec_mult_add<<<blocksPerGrid, threadsPerBlock>>>(d_A, d_B, c, d_D, numElements);
    err = hipGetLastError();

    if(err != hipSuccess) {
	fprintf(stderr, "Failed to execute kernel (error code %s)!\n", hipGetErrorString(err));
	exit(EXIT_FAILURE);
    }

    err = hipMemcpy(h_D, d_D, size, hipMemcpyDeviceToHost);
    
    if(err != hipSuccess) {
	fprintf(stderr, "Failed to copy kernel back to host (error code %s)!\n", hipGetErrorString(err));
    	exit(EXIT_FAILURE);
    }
    checkOutput(h_D, numElements);
    //printf(" = \n");
    //printVector(h_D, numElements);
    err = hipFree(d_A);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to free device vector A (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    err = hipFree(d_B);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to free device vector B (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    err = hipFree(d_D);

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to free device vector C (error code %s)!\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    // Free host memory
    free(h_A);
    free(h_B);
    free(h_D);

    // Reset the device and exit
    // cudaDeviceReset causes the driver to clean up all state. While
    // not mandatory in normal operation, it is good practice.  It is also
    // needed to ensure correct operation when the application is being
    // profiled. Calling cudaDeviceReset causes all profile data to be
    // flushed before the application exits
    err = hipDeviceReset();

    if (err != hipSuccess)
    {
        fprintf(stderr, "Failed to deinitialize the device! error=%s\n", hipGetErrorString(err));
        exit(EXIT_FAILURE);
    }

    printf("Done\n");
   
    //printf("Here are random numbers %d %d\n", (rand() % 11), (rand() % 11));
    
    return(EXIT_SUCCESS);
}

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

                                        # End of file scope inline assembly
	.globl	_Z27__device_stub__vec_mult_addPKjS0_jPji # -- Begin function _Z27__device_stub__vec_mult_addPKjS0_jPji
	.type	_Z27__device_stub__vec_mult_addPKjS0_jPji,@function
_Z27__device_stub__vec_mult_addPKjS0_jPji: # @_Z27__device_stub__vec_mult_addPKjS0_jPji
	.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	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	4(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	24(%rsp), %rdx
	movq	%rcx, (%rdx)
	movq	%rsp, %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z12vec_mult_addPKjS0_jPji, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z27__device_stub__vec_mult_addPKjS0_jPji, .Lfunc_end0-_Z27__device_stub__vec_mult_addPKjS0_jPji
	.cfi_endproc
                                        # -- End function
	.globl	_Z22getHardwareConstraintsv     # -- Begin function _Z22getHardwareConstraintsv
	.type	_Z22getHardwareConstraintsv,@function
_Z22getHardwareConstraintsv:            # @_Z22getHardwareConstraintsv
	.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	%rbx
	.cfi_def_cfa_offset 40
	subq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 1520
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	4(%rsp), %rdi
	movl	$0, (%rdi)
	callq	hipGetDeviceCount
	testl	%eax, %eax
	jne	.LBB1_8
# %bb.1:
	movl	4(%rsp), %esi
	testl	%esi, %esi
	je	.LBB1_2
# %bb.3:
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB1_4
.LBB1_2:
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB1_4:
	cmpl	$0, 4(%rsp)
	jle	.LBB1_7
# %bb.5:                                # %.lr.ph
	leaq	332(%rsp), %r14
	leaq	8(%rsp), %rbx
	xorl	%ebp, %ebp
.LBB1_6:                                # =>This Inner Loop Header: Depth=1
	movl	%ebp, %edi
	callq	hipSetDevice
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$.L.str.4, %edi
	movl	%ebp, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	296(%rsp), %edx
	movl	312(%rsp), %ecx
	movl	%edx, TOTAL_GLOBAL_MEM(%rip)
	movl	%ecx, REGS_PER_BLOCK(%rip)
	movl	316(%rsp), %r8d
	movl	%r8d, WARP_SIZE(%rip)
	movl	328(%rsp), %r9d
	movl	%r9d, MAX_THREADS_PER_BLOCK(%rip)
	movq	%r14, MAX_THREADS_DIM(%rip)
	movl	332(%rsp), %r10d
	movl	336(%rsp), %r11d
	movl	340(%rsp), %r15d
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movl	$.L.str.5, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	callq	printf
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	incl	%ebp
	cmpl	4(%rsp), %ebp
	jl	.LBB1_6
.LBB1_7:                                # %._crit_edge
	addq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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
.LBB1_8:
	.cfi_def_cfa_offset 1520
	movl	%eax, %ebx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movl	%ebx, %esi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z22getHardwareConstraintsv, .Lfunc_end1-_Z22getHardwareConstraintsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z11printVectorPji              # -- Begin function _Z11printVectorPji
	.type	_Z11printVectorPji,@function
_Z11printVectorPji:                     # @_Z11printVectorPji
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	testl	%ebp, %ebp
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r15,4), %esi
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	movl	$.Lstr.2, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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_end2:
	.size	_Z11printVectorPji, .Lfunc_end2-_Z11printVectorPji
	.cfi_endproc
                                        # -- End function
	.globl	_Z11checkOutputPji              # -- Begin function _Z11checkOutputPji
	.type	_Z11checkOutputPji,@function
_Z11checkOutputPji:                     # @_Z11checkOutputPji
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB3_7
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.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 %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, %rbx
	movl	%esi, %eax
	leaq	(%rax,%rax,2), %r15
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	xorl	%ebp, %ebp
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx), %esi
	cmpq	%rsi, %r14
	je	.LBB3_4
# %bb.3:                                #   in Loop: Header=BB3_2 Depth=1
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	movl	%ebp, %edx
	movl	%r14d, %ecx
	xorl	%eax, %eax
	callq	printf
	movb	$1, %al
.LBB3_4:                                #   in Loop: Header=BB3_2 Depth=1
	incl	%ebp
	addq	$4, %rbx
	addq	$3, %r14
	cmpq	%r14, %r15
	jne	.LBB3_2
# %bb.5:                                # %._crit_edge
	testb	$1, %al
	leaq	8(%rsp), %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
	jne	.LBB3_6
.LBB3_7:                                # %._crit_edge.thread
	movl	$.Lstr.3, %edi
	jmp	puts@PLT                        # TAILCALL
.LBB3_6:
	retq
.Lfunc_end3:
	.size	_Z11checkOutputPji, .Lfunc_end3-_Z11checkOutputPji
	.cfi_endproc
                                        # -- End function
	.globl	_Z19elementWiseMult_Addv        # -- Begin function _Z19elementWiseMult_Addv
	.type	_Z19elementWiseMult_Addv,@function
_Z19elementWiseMult_Addv:               # @_Z19elementWiseMult_Addv
	.cfi_startproc
# %bb.0:
	retq
.Lfunc_end4:
	.size	_Z19elementWiseMult_Addv, .Lfunc_end4-_Z19elementWiseMult_Addv
	.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	$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	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r12d
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	callq	_Z22getHardwareConstraintsv
	xorl	%r13d, %r13d
	movl	$.L.str.11, %edi
	movl	%r12d, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$4096, %edi                     # imm = 0x1000
	callq	malloc
	movq	%rax, %rbx
	movl	$4096, %edi                     # imm = 0x1000
	callq	malloc
	movq	%rax, %r14
	movl	$4096, %edi                     # imm = 0x1000
	callq	malloc
	movq	%rax, %r15
.LBB5_1:                                # =>This Inner Loop Header: Depth=1
	movl	%r13d, (%rbx,%r13,4)
	movl	%r13d, (%r14,%r13,4)
	incq	%r13
	cmpq	$1024, %r13                     # imm = 0x400
	jne	.LBB5_1
# %bb.2:
	leaq	16(%rsp), %rdi
	movq	$0, (%rdi)
	movl	$4096, %esi                     # imm = 0x1000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_3
# %bb.5:
	leaq	8(%rsp), %rdi
	movq	$0, (%rdi)
	movl	$4096, %esi                     # imm = 0x1000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_6
# %bb.7:
	movq	%rsp, %rdi
	movq	$0, (%rdi)
	movl	$4096, %esi                     # imm = 0x1000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_8
# %bb.9:
	movq	16(%rsp), %rdi
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_10
# %bb.11:
	movq	8(%rsp), %rdi
	movl	$4096, %edx                     # imm = 0x1000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_12
# %bb.13:
	movl	%r12d, %eax
	cltd
	idivl	%ebp
                                        # kill: def $eax killed $eax def $rax
	btsq	$32, %rax
	movl	%ebp, %edx
	btsq	$32, %rdx
	movq	%rax, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_15
# %bb.14:
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rcx
	movl	$2, %edx
	movl	$1024, %r8d                     # imm = 0x400
	callq	_Z27__device_stub__vec_mult_addPKjS0_jPji
.LBB5_15:
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB5_16
# %bb.17:
	movq	(%rsp), %rsi
	movl	$4096, %edx                     # imm = 0x1000
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_18
# %bb.19:
	movq	%r15, %rdi
	movl	$1024, %esi                     # imm = 0x400
	callq	_Z11checkOutputPji
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_20
# %bb.21:
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_22
# %bb.23:
	movq	(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_24
# %bb.25:
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	callq	hipDeviceReset
	testl	%eax, %eax
	jne	.LBB5_26
# %bb.27:
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	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
.LBB5_3:
	.cfi_def_cfa_offset 80
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.12, %esi
	jmp	.LBB5_4
.LBB5_6:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	jmp	.LBB5_4
.LBB5_8:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.14, %esi
	jmp	.LBB5_4
.LBB5_10:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.15, %esi
	jmp	.LBB5_4
.LBB5_12:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.16, %esi
	jmp	.LBB5_4
.LBB5_16:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.17, %esi
	jmp	.LBB5_4
.LBB5_18:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.18, %esi
	jmp	.LBB5_4
.LBB5_20:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.19, %esi
	jmp	.LBB5_4
.LBB5_22:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.20, %esi
	jmp	.LBB5_4
.LBB5_24:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.21, %esi
	jmp	.LBB5_4
.LBB5_26:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.22, %esi
.LBB5_4:
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end5:
	.size	main, .Lfunc_end5-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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12vec_mult_addPKjS0_jPji, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	TOTAL_GLOBAL_MEM,@object        # @TOTAL_GLOBAL_MEM
	.bss
	.globl	TOTAL_GLOBAL_MEM
	.p2align	2, 0x0
TOTAL_GLOBAL_MEM:
	.long	0                               # 0x0
	.size	TOTAL_GLOBAL_MEM, 4

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

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

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

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

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"hipGetDeviceCount returned %d\n-> %s\n"
	.size	.L.str, 37

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Detected %d CUDA Capable device(s)\n"
	.size	.L.str.3, 36

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

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"The %s has:\n\t-%zu total bytes of global memory\n\t-%d registers per block\n\t-%d threads per warp\n\t-A maximum of %d threads per block\n\t-And a maximum thread dimension of %d x %d x %d\n"
	.size	.L.str.5, 180

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"\n["
	.size	.L.str.6, 3

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

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"\nIncorrect value of %d at index %d... should be %d\n"
	.size	.L.str.9, 52

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"numThreads: %d and blockSize: %d\n"
	.size	.L.str.11, 34

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Failed to allocate device vector A (error code %s)!\n"
	.size	.L.str.12, 53

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Failed to allocate device vector B (error code %s)!\n"
	.size	.L.str.13, 53

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Failed to allocate device vector D (error code %s)!\n"
	.size	.L.str.14, 53

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Failed to copy vector A from host to device (error code %s)!\n"
	.size	.L.str.15, 62

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Failed to copy vector B from host to device (error code %s)!\n"
	.size	.L.str.16, 62

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Failed to execute kernel (error code %s)!\n"
	.size	.L.str.17, 43

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Failed to copy kernel back to host (error code %s)!\n"
	.size	.L.str.18, 53

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"Failed to free device vector A (error code %s)!\n"
	.size	.L.str.19, 49

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Failed to free device vector B (error code %s)!\n"
	.size	.L.str.20, 49

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"Failed to free device vector C (error code %s)!\n"
	.size	.L.str.21, 49

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"Failed to deinitialize the device! error=%s\n"
	.size	.L.str.22, 45

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12vec_mult_addPKjS0_jPji"
	.size	.L__unnamed_1, 27

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"There are no available device(s) that support CUDA"
	.size	.Lstr, 51

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Result = FAIL"
	.size	.Lstr.1, 14

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"\n]"
	.size	.Lstr.2, 3

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\nOutput is Correct!"
	.size	.Lstr.3, 20

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Done"
	.size	.Lstr.4, 5

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12vec_mult_addPKjS0_jPji ; -- Begin function _Z12vec_mult_addPKjS0_jPji
	.globl	_Z12vec_mult_addPKjS0_jPji
	.p2align	8
	.type	_Z12vec_mult_addPKjS0_jPji,@function
_Z12vec_mult_addPKjS0_jPji:             ; @_Z12vec_mult_addPKjS0_jPji
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b32 s3, s[0:1], 0x20
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b32 s2, s[0:1], 0x10
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b64 s[0:1], s[0:1], 0x18
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	global_load_b32 v6, v[2:3], off
	global_load_b32 v2, v[4:5], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[3:4], null, v6, s2, v[2:3]
	global_store_b32 v[0:1], v3, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12vec_mult_addPKjS0_jPji
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 7
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z12vec_mult_addPKjS0_jPji, .Lfunc_end0-_Z12vec_mult_addPKjS0_jPji
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 196
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
