#include <cmath>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cassert>
#include <chrono>
#include <random>
#include <string>
#include <ctime>
#include <algorithm>
#include <fcntl.h>
#include <unistd.h>

//constants
#define TRAINING_SET_SIZE 60000
#define TEST_SET_SIZE 10000
#define COLS 28
#define ROWS 28
#define IMG_MAGIC_NUM 0x00000803
#define LABEL_MAGIC_NUM 0x00000801
#define NUM_LABELS 60000
#define NUM_NEURONS 1024
#define EPOCH_SIZE 100
#define BATCH_SIZE 100

//All the integers in the files are stored in the MSB first (high endian) format
void toLittleEndian(int &num){
    num = (0xFF&(num >> 24))      |
          (0xFF00&(num >> 8))     |
          (0xFF0000&(num << 8))   |
          (0xFF000000&(num << 24));
}

void read_images(const std::string &file_name, float*** (&imgs)){
    int fd;
    fd = open(file_name.c_str(), O_RDONLY);
    assert(fd >= 0);

    int rv, magic_num, num_imgs, num_cols, num_rows;

    rv = read(fd, &magic_num, 4);
    assert(rv == 4);
    //change endianess
    toLittleEndian(magic_num);
    assert(magic_num == 0x803);

    rv = read(fd, &num_imgs, 4);
    assert(rv == 4);
    //change endianess
    toLittleEndian(num_imgs);

    rv = read(fd, &num_rows, 4);
    assert(rv == 4);
    //change endianness
    toLittleEndian(num_rows);

    rv = read(fd, &num_cols, 4);
    assert(rv == 4);
    //change endianness
    toLittleEndian(num_cols);

    imgs = new float**[num_imgs]();
    for(int i = 0; i < num_imgs; i++){
        imgs[i] = new float*[num_rows]();

        //read whole image at once to minimize IO since that takes time
        unsigned char tmp_img[num_rows][num_cols];
        rv = read(fd, tmp_img, num_rows*num_cols);
        assert(rv == num_rows*num_cols);

        for(int r = 0; r < num_rows; r++){
            imgs[i][r] = new float[num_cols]();
            for(int c = 0; c < num_cols; c++){
                imgs[i][r][c] = double(tmp_img[r][c])/127.5 - 1;
            }
        }

    }
    rv = close(fd);
    assert(rv == 0);
}

void read_labels(const std::string &file_name, unsigned char* (&labels)){
    int fd;
    fd = open(file_name.c_str(), O_RDONLY);
    assert(fd >= 0);

    int magic_num, num_labels;

    int rv = read(fd, &magic_num, 4);
    assert(rv == 4);
    //change endianess
    toLittleEndian(magic_num);

    rv = read(fd, &num_labels, 4);
    assert(rv == 4);
    //change endianess
    toLittleEndian(num_labels);

    labels = new unsigned char[num_labels]();
    rv = read(fd, labels, num_labels);
    for(int i = 0; i < num_labels; i++){
        //all labels are 0-9
        //assert(labels[i] >= 0 && labels[i] <= 9);
    }
    rv = close(fd);
    assert(rv == 0);

}

void generateWeights(float*** (&ilw), float*** (&ild), float** (&fclw), float** (&fcld)){

    //unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    unsigned seed = 8493;
    std::default_random_engine generator(seed);
    std::normal_distribution<float> distribution;

    ilw = new float**[NUM_NEURONS]();
    ild = new float**[NUM_NEURONS]();
    fclw = new float*[(int) NUM_NEURONS/EPOCH_SIZE]();
    fcld = new float*[(int) NUM_NEURONS/EPOCH_SIZE]();

    for(int n = 0; n < NUM_NEURONS; n++){
        ilw[n] = new float*[ROWS]();
        ild[n] = new float*[ROWS]();
        for(int r = 0; r < ROWS; r++){
            ilw[n][r] = new float[COLS]();
            ild[n][r] = new float[COLS]();
            for(int c = 0; c < COLS; c++){
                //normal_distribution represents unbownded distribution, divide by sqrt(N)
                ilw[n][r][c] = distribution(generator) / sqrt(NUM_NEURONS);
                //std::cout << distribution(generator) / sqrt(NUM_NEURONS) << std::endl;
                //initially weights are 0
                ild[n][r][c] = 0;
            }
        }
    }

    for(int i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
        fclw[i] = new float[NUM_NEURONS]();
        fcld[i] = new float[NUM_NEURONS]();
        for (int n = 0; n < NUM_NEURONS; n++){
            fclw[i][n] = distribution(generator) / sqrt((int) NUM_NEURONS/EPOCH_SIZE);
            fcld[i][n] = 0;
        }
    }
}

//based on softmax from prof. Chiu's examples
float* softmax(float *in){
    // Use identity softmax(x) == softmax(x - C)
    const auto C = *std::max_element(in, in+((int) NUM_NEURONS/EPOCH_SIZE));
    //std::cout << "Max element: " << C << std::endl;
    //same length as in
    float* out = new float[(int) NUM_NEURONS/EPOCH_SIZE];
    float sum = 0;
    for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
        //std::cout << in[i] - C << std::endl;
        out[i] = std::exp(in[i] - C);
        //assert(out[i] != 0);
        sum += out[i];
    }
    /*
    for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
        out[i] = out[i]/sum;
    }
    */
    // for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
    //     assert(out[i] != 0);
    //     std::cout << "GOOD" << std::endl;
    // }
    std::transform(out, out + ((int) NUM_NEURONS/EPOCH_SIZE), out, [sum](float e) {return e/sum;});

    // for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
    //     assert(out[i] != 0);
    //     if(out[i] != 0){
    //         std::cout << out[i] << std::endl;
    //     }
    // }

    return out;

}

float* softmax_ds(float* out, float* us){
    float* sm_ds = new float[(int) NUM_NEURONS/EPOCH_SIZE]();
    for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
        for(size_t j = 0; j < (int) NUM_NEURONS/EPOCH_SIZE; j++){
            if( i == j) {
                sm_ds[i] += (out[j]*(1 - out[i])) * us[j];
            } else {
                sm_ds[i] += (-out[i]*out[j])*us[j];
            }
        }
    }
    return sm_ds;
}

__global__ void update_dense_weights(float *w1, float *ds1){
    //current thread and node num
    int tid = blockIdx.x * blockDim.x + threadIdx.x;

    w1[tid] -= (BATCH_SIZE/1000)*ds1[tid];
    ds1[tid] = 0;

}

int main(int argc, char** argv){
    if(argc != 3){
        std::cerr << "Wrong number of inputs. Usage: ./parallelNN <images> <labels>" << std::endl;
        exit(1);
    }

    //read training
    static float ***training_images;
    static unsigned char *training_labels;
    read_images(std::string(argv[1]), training_images);
    read_labels(std::string(argv[2]), training_labels);

    float ***input_layer_w, ***input_layer_ds;
    float **fully_connected_layer_w, **fully_connected_layer_ds;

    //std::cout << input_layer_w[0][0][0] << std::endl;

    generateWeights(input_layer_w, input_layer_ds, fully_connected_layer_w, fully_connected_layer_ds);

    //First fully connected layer
    float *first_layer = new float[NUM_NEURONS]();
    float *first_layer_ds = new float[NUM_NEURONS]();

    //Second fully connected layer
    float *second_layer = new float[(int)NUM_NEURONS/EPOCH_SIZE]();
    float *second_layer_ds = new float[NUM_NEURONS]();

    //Softmax layer
    float *soft_max_layer = new float[(int)NUM_NEURONS/EPOCH_SIZE]();
    float *soft_max_layer_ds = new float[(int)NUM_NEURONS/EPOCH_SIZE]();

    //Cross-entropy layer
    float* cross_ent_layer = new float[(int)NUM_NEURONS/EPOCH_SIZE]();

    //CUDA
    float *dense_layer_w1, *dense_layer_ds1, *dense_layer_w2, *dense_layer_ds2;
    //place them in contiguoys memory
    float *hidden_layer_w1 = new float[NUM_NEURONS*ROWS*COLS]();
    float *hidden_layer_ds1 = new float[NUM_NEURONS*ROWS*COLS]();
    float *hidden_layer_w2 = new float[NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE)]();
    float *hidden_layer_ds2 = new float[NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE)]();

    cudaMalloc(&dense_layer_w1, NUM_NEURONS*ROWS*COLS*(sizeof(float)));
    cudaMalloc(&dense_layer_ds1, NUM_NEURONS*ROWS*COLS*(sizeof(float)));
    cudaMalloc(&dense_layer_w2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)));
    cudaMalloc(&dense_layer_ds2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)));

    //to generate random number for dropout
    std::srand(std::time(0));

    for(int e = 0; e < EPOCH_SIZE; e++){
        //rounds
        for(int j = 0; j < EPOCH_SIZE; j++){

            //FORWARD

            //initialize values
            int correct = 0, total = 0;

            //loop through images in batch
            for(int i = 0; i < BATCH_SIZE; i++){
                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    cross_ent_layer[k] = 0;
                }
                //current label and img displaced by i (the images already processed)
                int current_label = (int) training_labels[EPOCH_SIZE*j + i];
                float** current_image = training_images[EPOCH_SIZE*j + i];

                for(int n = 0; n < NUM_NEURONS; n++){
                    float temp_result = 0;
                    //dropout rate of 0.4%
                    if(std::rand() % 1000 < 4){
                        first_layer[n] = 0;
                    } else{
                        for(int r = 0; r < ROWS; r++){
                            for(int c = 0; c < COLS; c++){
                                //calculate results of the first layer
                                temp_result += input_layer_w[n][r][c] * current_image[r][c];
                            }
                        }
                        //ReLU
                        if(temp_result < 0){
                            first_layer[n] = 0;
                        } else{
                            first_layer[n] = temp_result;
                        }
                    }
                }
                //std::cout << "1" << std::endl;
                //std::cout << input_layer_w[0][0][0] << std::endl;

                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    for(int n = 0; n < NUM_NEURONS; n++){
                        //second_layer weights are too large/small
                        second_layer[k] += fully_connected_layer_w[k][n] * first_layer[n];
                    }
                }

                soft_max_layer = softmax(second_layer);
                if(std::distance(soft_max_layer, std::max_element(soft_max_layer, soft_max_layer+(int) NUM_NEURONS/EPOCH_SIZE)) == current_label){
                    correct++;
                }
                total++;

                cross_ent_layer[current_label] = -1 / soft_max_layer[current_label];

                //BACK-PROPAGATION

                soft_max_layer_ds = softmax_ds(soft_max_layer, cross_ent_layer);

                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    for(int n = 0; n < NUM_NEURONS; n++){
                        second_layer_ds[n] = 0;
                    }
                    for(int n = 0; n < NUM_NEURONS; n++){
                        fully_connected_layer_ds[k][n] += ((first_layer[n] * soft_max_layer_ds[k]) / BATCH_SIZE);
                        second_layer_ds[n] += fully_connected_layer_w[k][n] * soft_max_layer_ds[k];
                    }
                }

                for(int n = 0; n < NUM_NEURONS; n++){
                    for(int r = 0; r < ROWS; r++){
                        for(int c = 0; c < COLS; c++){
                            input_layer_ds[n][r][c] +=  (current_image[r][c] * second_layer_ds[n])/BATCH_SIZE;
                        }
                    }
                }

                //UPDATE WEIGHTS
                //copy to contiguous array to copy to CUDA mem
                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    for(int n = 0; n < NUM_NEURONS; n++){
                        hidden_layer_w2[k*NUM_NEURONS + n] = fully_connected_layer_w[k][n] ;
                        hidden_layer_ds2[k*NUM_NEURONS + n] = fully_connected_layer_ds[k][n];
                    }
                }
                cudaMemcpy(dense_layer_w2, hidden_layer_w2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), cudaMemcpyHostToDevice);
                cudaMemcpy(dense_layer_ds2, hidden_layer_ds2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), cudaMemcpyHostToDevice);

                update_dense_weights<<<(int)NUM_NEURONS/EPOCH_SIZE, NUM_NEURONS>>>(dense_layer_w2, dense_layer_ds2);

                //copy back
                cudaMemcpy(hidden_layer_w2, dense_layer_w2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), cudaMemcpyHostToDevice);
                cudaMemcpy(hidden_layer_ds2, dense_layer_ds2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), cudaMemcpyHostToDevice);


                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    for(int n = 0; n < NUM_NEURONS; n++){
                        fully_connected_layer_w[k][n] = hidden_layer_w2[k*NUM_NEURONS + n];
                        fully_connected_layer_ds[k][n] = hidden_layer_ds2[k*NUM_NEURONS + n];
                    }
                }

                /*----------------------*/

                for(int n = 0; n < NUM_NEURONS; n++){
                    for(int r = 0; r < ROWS; r++){
                        for(int c = 0; c < COLS; c++){
                            hidden_layer_w1[n*ROWS*COLS + r*ROWS + c] =  input_layer_w[n][r][c];
                            //std::cout << input_layer_ds[n][r][c] << std::endl;
                            //std::cout << input_layer_w[n][r][c] << std::endl;
                            hidden_layer_ds1[n*ROWS*COLS + r*ROWS + c] = input_layer_ds[n][r][c];
                        }
                    }
                }
                cudaMemcpy(dense_layer_w1, hidden_layer_w1,  NUM_NEURONS*ROWS*COLS*(sizeof(float)), cudaMemcpyHostToDevice);
                cudaMemcpy(dense_layer_ds1, hidden_layer_ds1, NUM_NEURONS*ROWS*COLS*(sizeof(float)), cudaMemcpyHostToDevice);

                update_dense_weights<<<ROWS*COLS, NUM_NEURONS>>>(dense_layer_w1, dense_layer_ds1);

                //copy back
                cudaMemcpy(hidden_layer_w1, dense_layer_w1, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), cudaMemcpyHostToDevice);
                cudaMemcpy(hidden_layer_ds1, dense_layer_ds1, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), cudaMemcpyHostToDevice);


                for(int n = 0; n < NUM_NEURONS; n++){
                    for(int r = 0; r < ROWS; r++){
                        for(int c = 0; c < COLS; c++){
                            input_layer_w[n][r][c] = hidden_layer_w1[n*ROWS*COLS + r*ROWS + c];
                            //std::cout << input_layer_ds[n][r][c] << std::endl;
                            //std::cout << input_layer_w[n][r][c] << std::endl;
                            input_layer_ds[n][r][c] = hidden_layer_ds1[n*ROWS*COLS + r*ROWS + c];
                        }
                    }
                }
            }
            if(j % 100 == 0){
                //std::cout << input_layer_w[0][0][0] << std::endl;
                printf("Epoch %d: Round %d: accuracy=%f\n", e, j, correct/total);
            }

        }
    }

    return 0;

}























//

	.file	"tmpxft_0039c18c_00000000-6_parallelNN.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB5194:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE5194:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z14toLittleEndianRi
	.type	_Z14toLittleEndianRi, @function
_Z14toLittleEndianRi:
.LFB5183:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	bswap	%eax
	movl	%eax, (%rdi)
	ret
	.cfi_endproc
.LFE5183:
	.size	_Z14toLittleEndianRi, .-_Z14toLittleEndianRi
	.globl	_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf
	.type	_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf, @function
_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf:
.LFB5184:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	movq	%rsi, %r12
	xorl	%esi, %esi
	pushq	%rbx
	.cfi_offset 3, -56
	leaq	-72(%rbp), %rbx
	subq	$72, %rsp
	movq	(%rdi), %rdi
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__open_2@PLT
	movq	%rbx, %rsi
	movl	$4, %ecx
	movl	$4, %edx
	movl	%eax, %edi
	movl	%eax, -84(%rbp)
	call	__read_chk@PLT
	movq	%rbx, %rdi
	leaq	-68(%rbp), %rbx
	movl	$4, %ecx
	call	_Z14toLittleEndianRi
	movl	-84(%rbp), %edi
	movq	%rbx, %rsi
	movl	$4, %edx
	call	__read_chk@PLT
	movq	%rbx, %rdi
	leaq	-60(%rbp), %rbx
	movl	$4, %ecx
	call	_Z14toLittleEndianRi
	movl	-84(%rbp), %edi
	movq	%rbx, %rsi
	movl	$4, %edx
	call	__read_chk@PLT
	movq	%rbx, %rdi
	leaq	-64(%rbp), %rbx
	movl	$4, %ecx
	call	_Z14toLittleEndianRi
	movl	-84(%rbp), %edi
	movq	%rbx, %rsi
	movl	$4, %edx
	call	__read_chk@PLT
	movq	%rbx, %rdi
	call	_Z14toLittleEndianRi
	movslq	-68(%rbp), %rbx
	movabsq	$1152921504606846975, %rax
	cmpq	%rbx, %rax
	jb	.L4
	leaq	0(,%rbx,8), %rdi
	call	_Znam@PLT
	xorl	%edx, %edx
	jmp	.L5
.L4:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L26
	call	__cxa_throw_bad_array_new_length@PLT
.L5:
	cmpq	%rdx, %rbx
	je	.L28
	xorl	%esi, %esi
	movq	%rsi, (%rax,%rdx,8)
	incq	%rdx
	jmp	.L5
.L28:
	movq	%rax, (%r12)
	xorl	%ebx, %ebx
.L8:
	cmpl	%ebx, -68(%rbp)
	jle	.L29
	movslq	-60(%rbp), %r13
	movq	%rsp, -96(%rbp)
	movabsq	$1152921504606846975, %rax
	cmpq	%r13, %rax
	jb	.L4
	leaq	0(,%r13,8), %rdi
	call	_Znam@PLT
	xorl	%edx, %edx
.L9:
	cmpq	%rdx, %r13
	je	.L30
	xorl	%ecx, %ecx
	movq	%rcx, (%rax,%rdx,8)
	incq	%rdx
	jmp	.L9
.L30:
	movq	(%r12), %rdx
	movslq	-64(%rbp), %r13
	movq	%rsp, %rsi
	leaq	0(,%rbx,8), %r14
	movq	%rax, (%rdx,%rbx,8)
	movslq	-60(%rbp), %rdx
	imulq	%r13, %rdx
	leaq	15(%rdx), %rcx
	movq	%rcx, %rax
	andq	$-4096, %rcx
	andq	$-16, %rax
	subq	%rcx, %rsi
.L11:
	cmpq	%rsi, %rsp
	je	.L12
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L11
.L12:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L13
	orq	$0, -8(%rsp,%rax)
.L13:
	movl	-84(%rbp), %edi
	movq	%rdx, %rcx
	movq	%rsp, %rsi
	xorl	%r15d, %r15d
	call	__read_chk@PLT
	movq	%rsp, %rcx
.L14:
	cmpl	%r15d, -60(%rbp)
	jle	.L31
	movslq	-64(%rbp), %r8
	movq	%rcx, -112(%rbp)
	movabsq	$2305843009213693950, %rax
	cmpq	%r8, %rax
	jb	.L4
	leaq	0(,%r8,4), %rdi
	movq	%r8, -104(%rbp)
	call	_Znam@PLT
	movq	-104(%rbp), %r8
	movq	-112(%rbp), %rcx
	movq	%rax, %rsi
	xorl	%eax, %eax
.L15:
	cmpq	%rax, %r8
	je	.L32
	movl	$0x00000000, (%rsi,%rax,4)
	incq	%rax
	jmp	.L15
.L32:
	movq	(%r12), %rax
	movl	-64(%rbp), %edi
	movsd	.LC1(%rip), %xmm1
	movsd	.LC2(%rip), %xmm2
	movq	(%rax,%r14), %rax
	movq	%rsi, (%rax,%r15,8)
	xorl	%eax, %eax
.L17:
	cmpl	%eax, %edi
	jle	.L33
	movzbl	(%rcx,%rax), %r8d
	cvtsi2sdl	%r8d, %xmm0
	divsd	%xmm1, %xmm0
	subsd	%xmm2, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rsi,%rax,4)
	incq	%rax
	jmp	.L17
.L33:
	incq	%r15
	addq	%r13, %rcx
	jmp	.L14
.L31:
	incq	%rbx
	movq	-96(%rbp), %rsp
	jmp	.L8
.L29:
	movl	-84(%rbp), %edi
	call	close@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L21
.L26:
	call	__stack_chk_fail@PLT
.L21:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE5184:
	.size	_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf, .-_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf
	.globl	_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh
	.type	_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh, @function
_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh:
.LFB5185:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r12
	xorl	%esi, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	(%rdi), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbp
	call	__open_2@PLT
	movq	%rbp, %rsi
	movl	$4, %ecx
	movl	$4, %edx
	movl	%eax, %edi
	movl	%eax, %ebx
	call	__read_chk@PLT
	movq	%rbp, %rdi
	leaq	4(%rsp), %rbp
	movl	$4, %edx
	call	_Z14toLittleEndianRi
	movq	%rbp, %rsi
	movl	$4, %ecx
	movl	%ebx, %edi
	call	__read_chk@PLT
	movq	%rbp, %rdi
	call	_Z14toLittleEndianRi
	movslq	4(%rsp), %rbp
	movq	%rbp, %rdi
	call	_Znam@PLT
	movq	%rax, %rsi
	movq	%rax, %rdx
	movq	%rbp, %rax
.L35:
	decq	%rax
	js	.L39
	movb	$0, (%rdx)
	incq	%rdx
	jmp	.L35
.L39:
	movq	%rsi, (%r12)
	movslq	4(%rsp), %rdx
	movl	%ebx, %edi
	movq	%rbp, %rcx
	call	__read_chk@PLT
	movl	%ebx, %edi
	call	close@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5185:
	.size	_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh, .-_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh
	.globl	_Z7softmaxPf
	.type	_Z7softmaxPf, @function
_Z7softmaxPf:
.LFB5188:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	40(%rdi), %rcx
	movq	%rdi, %rdx
	movq	%rdi, %rax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
.L41:
	movss	(%rdx), %xmm3
	addq	$4, %rax
	movss	%xmm3, 8(%rsp)
	cmpq	%rax, %rcx
	je	.L50
	movss	(%rax), %xmm0
	ucomiss	8(%rsp), %xmm0
	cmova	%rax, %rdx
	jmp	.L41
.L50:
	movl	$40, %edi
	xorl	%r12d, %r12d
	call	_Znam@PLT
	xorps	%xmm1, %xmm1
	movq	%rax, %rbx
.L44:
	movss	0(%rbp,%r12,4), %xmm0
	subss	8(%rsp), %xmm0
	movss	%xmm1, 12(%rsp)
	call	expf@PLT
	movss	12(%rsp), %xmm1
	movss	%xmm0, (%rbx,%r12,4)
	incq	%r12
	addss	%xmm0, %xmm1
	cmpq	$10, %r12
	jne	.L44
	xorl	%eax, %eax
.L45:
	movss	(%rbx,%rax), %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, (%rbx,%rax)
	addq	$4, %rax
	cmpq	$40, %rax
	jne	.L45
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5188:
	.size	_Z7softmaxPf, .-_Z7softmaxPf
	.globl	_Z10softmax_dsPfS_
	.type	_Z10softmax_dsPfS_, @function
_Z10softmax_dsPfS_:
.LFB5190:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	movl	$40, %edi
	pushq	%rcx
	.cfi_def_cfa_offset 32
	call	_Znam@PLT
	movl	$10, %ecx
	xorl	%edx, %edx
	movss	.LC3(%rip), %xmm5
	movq	%rax, %rsi
	xorl	%eax, %eax
	movss	.LC4(%rip), %xmm4
	movq	%rsi, %rdi
	rep stosl
.L52:
	movss	(%rbx,%rdx,4), %xmm2
	movss	(%rsi,%rdx,4), %xmm0
	xorl	%eax, %eax
	movaps	%xmm2, %xmm3
	xorps	%xmm4, %xmm3
.L55:
	cmpq	%rax, %rdx
	jne	.L53
	movaps	%xmm5, %xmm1
	subss	%xmm2, %xmm1
	mulss	(%rbx,%rdx,4), %xmm1
	mulss	0(%rbp,%rdx,4), %xmm1
	jmp	.L59
.L53:
	movss	(%rbx,%rax,4), %xmm1
	mulss	%xmm3, %xmm1
	mulss	0(%rbp,%rax,4), %xmm1
.L59:
	incq	%rax
	addss	%xmm1, %xmm0
	cmpq	$10, %rax
	jne	.L55
	movss	%xmm0, (%rsi,%rdx,4)
	incq	%rdx
	cmpq	$10, %rdx
	jne	.L52
	popq	%rdx
	.cfi_def_cfa_offset 24
	movq	%rsi, %rax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5190:
	.size	_Z10softmax_dsPfS_, .-_Z10softmax_dsPfS_
	.globl	_Z42__device_stub__Z20update_dense_weightsPfS_PfS_
	.type	_Z42__device_stub__Z20update_dense_weightsPfS_PfS_, @function
_Z42__device_stub__Z20update_dense_weightsPfS_PfS_:
.LFB5216:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L60
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z20update_dense_weightsPfS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L60:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L62
	call	__stack_chk_fail@PLT
.L62:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5216:
	.size	_Z42__device_stub__Z20update_dense_weightsPfS_PfS_, .-_Z42__device_stub__Z20update_dense_weightsPfS_PfS_
	.globl	_Z20update_dense_weightsPfS_
	.type	_Z20update_dense_weightsPfS_, @function
_Z20update_dense_weightsPfS_:
.LFB5217:
	.cfi_startproc
	endbr64
	jmp	_Z42__device_stub__Z20update_dense_weightsPfS_PfS_
	.cfi_endproc
.LFE5217:
	.size	_Z20update_dense_weightsPfS_, .-_Z20update_dense_weightsPfS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC5:
	.string	"_Z20update_dense_weightsPfS_"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB5219:
	.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	.LC5(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z20update_dense_weightsPfS_(%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
.LFE5219:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.str1.1,"aMS",@progbits,1
.LC6:
	.string	"basic_string: construction from null is not valid"
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IS3_EEPKcRKS3_,comdat
	.align 2
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_:
.LFB5564:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	jne	.L68
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L73
	leaq	.LC6(%rip), %rdi
	call	_ZSt19__throw_logic_errorPKc@PLT
.L68:
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	movq	%rsi, %rbp
	call	strlen@PLT
	movq	%rax, (%rsp)
	leaq	0(%rbp,%rax), %r12
	cmpq	$15, %rax
	jbe	.L70
	movq	%rsp, %rsi
	xorl	%edx, %edx
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT
	movq	%rax, (%rbx)
	movq	(%rsp), %rax
	movq	%rax, 16(%rbx)
.L70:
	movq	(%rbx), %rdi
	movq	%r12, %rdx
	movq	%rbp, %rsi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	(%rsp), %rax
	movq	(%rbx), %rdx
	movq	%rax, 8(%rbx)
	movb	$0, (%rdx,%rax)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L71
.L73:
	call	__stack_chk_fail@PLT
.L71:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5564:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	.set	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.section	.text._ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_,"axG",@progbits,_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_,comdat
	.weak	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	.type	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_, @function
_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_:
.LFB5943:
	.cfi_startproc
	endbr64
	imulq	$16807, (%rdi), %rax
	movl	$2147483647, %ecx
	xorl	%edx, %edx
	divq	%rcx
	movq	%rdx, (%rdi)
	decq	%rdx
	js	.L75
	cvtsi2ssq	%rdx, %xmm0
	jmp	.L76
.L75:
	movq	%rdx, %rax
	andl	$1, %edx
	shrq	%rax
	orq	%rdx, %rax
	cvtsi2ssq	%rax, %xmm0
	addss	%xmm0, %xmm0
.L76:
	xorps	%xmm1, %xmm1
	addss	%xmm1, %xmm0
	mulss	.LC8(%rip), %xmm0
	comiss	.LC3(%rip), %xmm0
	jb	.L74
	movss	.LC7(%rip), %xmm0
.L74:
	ret
	.cfi_endproc
.LFE5943:
	.size	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_, .-_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	.text
	.align 2
	.type	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE.isra.0, @function
_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE.isra.0:
.LFB5993:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	cmpb	$0, 12(%rdi)
	movss	%xmm0, 16(%rsp)
	movss	%xmm1, 20(%rsp)
	je	.L84
	movb	$0, 12(%rdi)
	movss	8(%rdi), %xmm1
	jmp	.L81
.L88:
	xorps	%xmm0, %xmm0
	ucomiss	%xmm0, %xmm2
	jp	.L83
	jne	.L83
.L84:
	movq	%rbp, %rdi
	call	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	movq	%rbp, %rdi
	addss	%xmm0, %xmm0
	subss	.LC3(%rip), %xmm0
	movss	%xmm0, 12(%rsp)
	call	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	movss	12(%rsp), %xmm2
	addss	%xmm0, %xmm0
	mulss	%xmm2, %xmm2
	movaps	%xmm0, %xmm1
	subss	.LC3(%rip), %xmm1
	movaps	%xmm1, %xmm0
	mulss	%xmm1, %xmm0
	addss	%xmm0, %xmm2
	comiss	.LC3(%rip), %xmm2
	ja	.L84
	jmp	.L88
.L83:
	movaps	%xmm2, %xmm0
	movss	%xmm1, 28(%rsp)
	movss	%xmm2, 24(%rsp)
	call	logf@PLT
	mulss	.LC9(%rip), %xmm0
	movss	24(%rsp), %xmm2
	divss	%xmm2, %xmm0
	call	sqrtf@PLT
	movss	12(%rsp), %xmm2
	movss	28(%rsp), %xmm1
	movb	$1, 12(%rbx)
	mulss	%xmm0, %xmm2
	mulss	%xmm0, %xmm1
	movss	%xmm2, 8(%rbx)
.L81:
	mulss	20(%rsp), %xmm1
	movss	16(%rsp), %xmm0
	addq	$40, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	addss	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE5993:
	.size	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE.isra.0, .-_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE.isra.0
	.globl	_Z15generateWeightsRPPPfS2_RS0_S3_
	.type	_Z15generateWeightsRPPPfS2_RS0_S3_, @function
_Z15generateWeightsRPPPfS2_RS0_S3_:
.LFB5186:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rcx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	movl	$8192, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	movl	$127, %eax
	movl	$0x00000000, 48(%rsp)
	salq	$55, %rax
	movb	$0, 52(%rsp)
	movq	$8493, 32(%rsp)
	movq	%rax, 40(%rsp)
	call	_Znam@PLT
	movl	$2048, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	movl	%ebx, %eax
	rep stosl
	movq	%rdx, 0(%rbp)
	movl	$8192, %edi
	call	_Znam@PLT
	movl	$2048, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	movl	%ebx, %eax
	rep stosl
	movq	%rdx, (%r14)
	movl	$80, %edi
	call	_Znam@PLT
	movl	$20, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	movl	%ebx, %eax
	rep stosl
	movq	%rdx, 0(%r13)
	movl	$80, %edi
	call	_Znam@PLT
	movl	$20, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	movl	%ebx, %eax
	xorl	%ebx, %ebx
	rep stosl
	movq	%rdx, (%r15)
.L92:
	movl	$224, %edi
	xorl	%r12d, %r12d
	call	_Znam@PLT
	movl	$56, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	xorl	%eax, %eax
	rep stosl
	movq	0(%rbp), %rax
	movl	$224, %edi
	movq	%rdx, (%rax,%rbx)
	call	_Znam@PLT
	movl	$56, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	xorl	%eax, %eax
	rep stosl
	movq	(%r14), %rax
	movq	%rdx, (%rax,%rbx)
.L91:
	movl	$112, %edi
	call	_Znam@PLT
	movl	$28, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	xorl	%eax, %eax
	rep stosl
	movq	0(%rbp), %rax
	movl	$112, %edi
	movq	(%rax,%rbx), %rax
	movq	%rdx, (%rax,%r12)
	call	_Znam@PLT
	movl	$28, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	xorl	%eax, %eax
	rep stosl
	movq	(%r14), %rax
	movq	(%rax,%rbx), %rax
	movq	%rdx, (%rax,%r12)
	xorl	%eax, %eax
.L90:
	movq	%rax, 24(%rsp)
	leaq	32(%rsp), %rax
	movss	.LC3(%rip), %xmm1
	xorps	%xmm0, %xmm0
	movq	%rax, (%rsp)
	leaq	40(%rsp), %rax
	movq	(%rsp), %rsi
	movq	%rax, %rdi
	movq	%rdx, 16(%rsp)
	movq	%rax, 8(%rsp)
	call	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE.isra.0
	movq	0(%rbp), %rcx
	movq	24(%rsp), %rax
	mulss	.LC10(%rip), %xmm0
	movq	16(%rsp), %rdx
	movq	(%rcx,%rbx), %rcx
	movq	(%rcx,%r12), %rcx
	movss	%xmm0, (%rcx,%rax)
	movl	$0x00000000, (%rdx,%rax)
	addq	$4, %rax
	cmpq	$112, %rax
	jne	.L90
	addq	$8, %r12
	cmpq	$224, %r12
	jne	.L91
	addq	$8, %rbx
	cmpq	$8192, %rbx
	jne	.L92
	xorl	%ebx, %ebx
.L94:
	movl	$4096, %edi
	xorl	%ebp, %ebp
	call	_Znam@PLT
	movl	$1024, %ecx
	movq	%rax, %rdx
	movq	%rax, %rdi
	movl	%ebp, %eax
	rep stosl
	movq	0(%r13), %rax
	movl	$4096, %edi
	movq	%rdx, (%rax,%rbx)
	call	_Znam@PLT
	movl	$1024, %ecx
	movq	%rax, %r12
	movq	%rax, %rdi
	movl	%ebp, %eax
	xorl	%ebp, %ebp
	rep stosl
	movq	(%r15), %rax
	movq	%r12, (%rax,%rbx)
.L93:
	movss	.LC3(%rip), %xmm1
	movq	(%rsp), %rsi
	xorps	%xmm0, %xmm0
	movq	8(%rsp), %rdi
	call	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE.isra.0
	movq	0(%r13), %rax
	cvtss2sd	%xmm0, %xmm0
	divsd	.LC11(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	(%rax,%rbx), %rax
	movss	%xmm0, (%rax,%rbp)
	movl	$0x00000000, (%r12,%rbp)
	addq	$4, %rbp
	cmpq	$4096, %rbp
	jne	.L93
	addq	$8, %rbx
	cmpq	$80, %rbx
	jne	.L94
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L95
	call	__stack_chk_fail@PLT
.L95:
	addq	$72, %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
.LFE5186:
	.size	_Z15generateWeightsRPPPfS2_RS0_S3_, .-_Z15generateWeightsRPPPfS2_RS0_S3_
	.section	.rodata.str1.1
.LC12:
	.string	"Wrong number of inputs. Usage: ./parallelNN <images> <labels>"
.LC15:
	.string	"Epoch %d: Round %d: accuracy=%f\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB5191:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA5191
	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	$232, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 216(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	je	.L103
	leaq	.LC12(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
.LEHB0:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$1, %edi
	call	exit@PLT
.L103:
	leaq	184(%rsp), %rbx
	movq	%rsi, %rbp
	leaq	172(%rsp), %r12
	movq	8(%rsi), %rsi
	movq	%rbx, %rdi
	movq	%r12, %rdx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE0:
	leaq	_ZZ4mainE15training_images(%rip), %rsi
	movq	%rbx, %rdi
.LEHB1:
	call	_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf
.LEHE1:
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	16(%rbp), %rsi
	movq	%rbx, %rdi
	movq	%r12, %rdx
.LEHB2:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE2:
	leaq	_ZZ4mainE15training_labels(%rip), %rsi
	movq	%rbx, %rdi
.LEHB3:
	call	_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh
.LEHE3:
	movq	%rbx, %rdi
	xorl	%ebp, %ebp
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	leaq	112(%rsp), %rdx
	leaq	104(%rsp), %rsi
	leaq	120(%rsp), %rcx
	leaq	96(%rsp), %rdi
.LEHB4:
	call	_Z15generateWeightsRPPPfS2_RS0_S3_
	movl	$4096, %edi
	call	_Znam@PLT
	movl	$1024, %ecx
	movq	%rax, %rdi
	movq	%rax, %rbx
	movl	%ebp, %eax
	rep stosl
	movl	$40, %edi
	call	_Znam@PLT
	movl	$10, %ecx
	movq	%rax, 40(%rsp)
	movq	%rax, %rdi
	movl	%ebp, %eax
	rep stosl
	movl	$4096, %edi
	call	_Znam@PLT
	movl	$40, %edi
	movq	%rax, %r15
	call	_Znam@PLT
	movl	$3211264, %edi
	movq	%rax, 48(%rsp)
	call	_Znam@PLT
	movl	$802816, %ecx
	movq	%rax, 8(%rsp)
	movq	%rax, %rdi
	movl	%ebp, %eax
	rep stosl
	movl	$3211264, %edi
	call	_Znam@PLT
	movl	$802816, %ecx
	movq	%rax, 16(%rsp)
	movq	%rax, %rdi
	movl	%ebp, %eax
	rep stosl
	movl	$40960, %edi
	call	_Znam@PLT
	movl	$10240, %ecx
	movq	%rax, 24(%rsp)
	movq	%rax, %rdi
	movl	%ebp, %eax
	rep stosl
	movl	$40960, %edi
	call	_Znam@PLT
	movl	$10240, %ecx
	movl	$3211264, %esi
	movq	%rax, 32(%rsp)
	movq	%rax, %rdi
	movl	%ebp, %eax
	rep stosl
	leaq	128(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	136(%rsp), %rdi
	movl	$3211264, %esi
	call	cudaMalloc@PLT
	leaq	144(%rsp), %rdi
	movl	$40960, %esi
	call	cudaMalloc@PLT
	movl	$40960, %esi
	leaq	152(%rsp), %rdi
	call	cudaMalloc@PLT
	xorl	%edi, %edi
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	xorl	%edx, %edx
	movl	%edx, 60(%rsp)
.L104:
	xorl	%ebp, %ebp
.L147:
	imulq	$100, %rbp, %rax
	movq	%rax, 64(%rsp)
	xorl	%eax, %eax
	movl	%eax, 80(%rsp)
	movl	%eax, 84(%rsp)
.L145:
	movq	48(%rsp), %rdi
	xorl	%eax, %eax
	movl	$10, %ecx
	xorl	%r14d, %r14d
	movq	64(%rsp), %rsi
	movl	$1000, %r12d
	rep stosl
	movq	_ZZ4mainE15training_labels(%rip), %rax
	movzbl	(%rax,%rsi), %r13d
	movq	_ZZ4mainE15training_images(%rip), %rax
	movq	(%rax,%rsi,8), %rax
	movq	%rax, 88(%rsp)
.L109:
	call	rand@PLT
	movq	96(%rsp), %rsi
	xorps	%xmm0, %xmm0
	cltd
	idivl	%r12d
	movq	%rsi, 72(%rsp)
	cmpl	$3, %edx
	jle	.L105
	movq	(%rsi,%r14,8), %rdi
	xorl	%edx, %edx
.L106:
	movq	88(%rsp), %rax
	movq	(%rdi,%rdx), %rsi
	movq	(%rax,%rdx), %rcx
	xorl	%eax, %eax
.L107:
	movss	(%rsi,%rax), %xmm1
	mulss	(%rcx,%rax), %xmm1
	addq	$4, %rax
	addss	%xmm1, %xmm0
	cmpq	$112, %rax
	jne	.L107
	addq	$8, %rdx
	cmpq	$224, %rdx
	jne	.L106
	xorps	%xmm1, %xmm1
	comiss	%xmm0, %xmm1
	jbe	.L105
	movaps	%xmm1, %xmm0
.L105:
	movss	%xmm0, (%rbx,%r14,4)
	incq	%r14
	cmpq	$1024, %r14
	jne	.L109
	movq	112(%rsp), %r12
	xorl	%eax, %eax
.L110:
	movq	40(%rsp), %rcx
	xorl	%edx, %edx
	movss	(%rcx,%rax,4), %xmm0
	movq	(%r12,%rax,8), %rcx
.L111:
	movss	(%rcx,%rdx), %xmm1
	mulss	(%rbx,%rdx), %xmm1
	addq	$4, %rdx
	addss	%xmm1, %xmm0
	cmpq	$4096, %rdx
	jne	.L111
	movq	40(%rsp), %rsi
	movss	%xmm0, (%rsi,%rax,4)
	incq	%rax
	cmpq	$10, %rax
	jne	.L110
	movq	40(%rsp), %rdi
	call	_Z7softmaxPf
	movq	%rax, %rdi
	leaq	40(%rax), %rcx
	movq	%rax, %rdx
.L113:
	addq	$4, %rdx
	cmpq	%rdx, %rcx
	je	.L173
	movss	(%rdx), %xmm0
	comiss	(%rax), %xmm0
	jbe	.L113
	movq	%rdx, %rax
	jmp	.L113
.L173:
	subq	%rdi, %rax
	sarq	$2, %rax
	cmpq	%rax, %r13
	jne	.L116
	incl	84(%rsp)
.L116:
	movq	48(%rsp), %rax
	movss	.LC13(%rip), %xmm0
	divss	(%rdi,%r13,4), %xmm0
	incl	80(%rsp)
	movq	%rax, %rsi
	movss	%xmm0, (%rax,%r13,4)
	call	_Z10softmax_dsPfS_
	movq	120(%rsp), %r14
	movss	.LC14(%rip), %xmm1
	xorl	%esi, %esi
	movq	%rax, %r8
	xorl	%eax, %eax
.L117:
	movl	$1024, %ecx
	movq	%r15, %rdi
	xorl	%edx, %edx
	rep stosl
	movq	(%r14,%rsi,8), %rcx
	movq	(%r12,%rsi,8), %rdi
.L118:
	movss	(%rbx,%rdx), %xmm0
	mulss	(%r8,%rsi,4), %xmm0
	divss	%xmm1, %xmm0
	addss	(%rcx,%rdx), %xmm0
	movss	%xmm0, (%rcx,%rdx)
	movss	(%rdi,%rdx), %xmm0
	mulss	(%r8,%rsi,4), %xmm0
	addss	(%r15,%rdx), %xmm0
	movss	%xmm0, (%r15,%rdx)
	addq	$4, %rdx
	cmpq	$4096, %rdx
	jne	.L118
	incq	%rsi
	cmpq	$10, %rsi
	jne	.L117
	movq	104(%rsp), %r13
	xorl	%ecx, %ecx
.L122:
	movq	0(%r13,%rcx,8), %rdi
	movss	(%r15,%rcx,4), %xmm2
	xorl	%edx, %edx
.L124:
	movq	88(%rsp), %rax
	movq	(%rdi,%rdx), %rsi
	movq	(%rax,%rdx), %r8
	xorl	%eax, %eax
.L120:
	movss	(%r8,%rax), %xmm0
	mulss	%xmm2, %xmm0
	divss	%xmm1, %xmm0
	addss	(%rsi,%rax), %xmm0
	movss	%xmm0, (%rsi,%rax)
	addq	$4, %rax
	cmpq	$112, %rax
	jne	.L120
	addq	$8, %rdx
	cmpq	$224, %rdx
	jne	.L124
	incq	%rcx
	cmpq	$1024, %rcx
	jne	.L122
	xorl	%eax, %eax
.L123:
	movq	%rax, %rcx
	movq	(%r12,%rax), %rdi
	movq	(%r14,%rax), %rsi
	xorl	%edx, %edx
	salq	$9, %rcx
.L125:
	movss	(%rdi,%rdx), %xmm0
	movq	24(%rsp), %r10
	movq	32(%rsp), %r11
	movss	%xmm0, (%r10,%rcx)
	movss	(%rsi,%rdx), %xmm0
	addq	$4, %rdx
	movss	%xmm0, (%r11,%rcx)
	addq	$4, %rcx
	cmpq	$4096, %rdx
	jne	.L125
	addq	$8, %rax
	cmpq	$80, %rax
	jne	.L123
	movq	24(%rsp), %rsi
	movl	$1, %ecx
	movl	$40960, %edx
	movq	144(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rsi
	movl	$1, %ecx
	movq	152(%rsp), %rdi
	movl	$40960, %edx
	call	cudaMemcpy@PLT
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$2147483653, %edi
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	addq	%rdi, %rdi
	movq	%rdx, 172(%rsp)
	movl	$1, 180(%rsp)
	movq	%rdi, 160(%rsp)
	movl	$1, 168(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L127
	movq	152(%rsp), %rsi
	movq	144(%rsp), %rdi
	call	_Z42__device_stub__Z20update_dense_weightsPfS_PfS_
.L127:
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movl	$40960, %edx
	movq	144(%rsp), %rsi
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movq	152(%rsp), %rsi
	movl	$40960, %edx
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L128:
	movq	%rax, %rcx
	movq	(%r12,%rax), %rdi
	movq	(%r14,%rax), %rsi
	xorl	%edx, %edx
	salq	$9, %rcx
.L129:
	movq	24(%rsp), %r9
	movq	32(%rsp), %r10
	movss	(%r9,%rcx), %xmm0
	movss	%xmm0, (%rdi,%rdx)
	movss	(%r10,%rcx), %xmm0
	addq	$4, %rcx
	movss	%xmm0, (%rsi,%rdx)
	addq	$4, %rdx
	cmpq	$4096, %rdx
	jne	.L129
	addq	$8, %rax
	cmpq	$80, %rax
	jne	.L128
	xorl	%edx, %edx
.L130:
	movq	72(%rsp), %rax
	imulq	$392, %rdx, %rsi
	movq	0(%r13,%rdx), %rdi
	xorl	%ecx, %ecx
	movq	(%rax,%rdx), %r8
.L134:
	movq	8(%rsp), %r9
	movq	16(%rsp), %r14
	xorl	%eax, %eax
	movq	(%r8,%rcx), %r12
	movq	(%rdi,%rcx), %r11
	leaq	(%rsi,%r9), %r10
	leaq	(%r14,%rsi), %r9
.L131:
	movss	(%r12,%rax), %xmm0
	movss	%xmm0, (%r10,%rax)
	movss	(%r11,%rax), %xmm0
	movss	%xmm0, (%r9,%rax)
	addq	$4, %rax
	cmpq	$112, %rax
	jne	.L131
	addq	$8, %rcx
	addq	$112, %rsi
	cmpq	$224, %rcx
	jne	.L134
	addq	$8, %rdx
	cmpq	$8192, %rdx
	jne	.L130
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movl	$3211264, %edx
	movq	128(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	136(%rsp), %rdi
	movl	$3211264, %edx
	call	cudaMemcpy@PLT
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$268435505, %edi
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$4, %rdi
	movq	%rdx, 172(%rsp)
	movl	$1, 180(%rsp)
	movq	%rdi, 160(%rsp)
	movl	$1, 168(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L135
	movq	136(%rsp), %rsi
	movq	128(%rsp), %rdi
	call	_Z42__device_stub__Z20update_dense_weightsPfS_PfS_
.L135:
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$40960, %edx
	movq	128(%rsp), %rsi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movl	$40960, %edx
	movq	136(%rsp), %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	xorl	%edx, %edx
.L136:
	movq	72(%rsp), %rax
	imulq	$392, %rdx, %rsi
	movq	0(%r13,%rdx), %rdi
	xorl	%ecx, %ecx
	movq	(%rax,%rdx), %r8
.L140:
	movq	8(%rsp), %r10
	movq	16(%rsp), %r9
	xorl	%eax, %eax
	movq	(%r8,%rcx), %r12
	movq	(%rdi,%rcx), %r11
	addq	%rsi, %r10
	addq	%rsi, %r9
.L137:
	movss	(%r10,%rax), %xmm0
	movss	%xmm0, (%r12,%rax)
	movss	(%r9,%rax), %xmm0
	movss	%xmm0, (%r11,%rax)
	addq	$4, %rax
	cmpq	$112, %rax
	jne	.L137
	addq	$8, %rcx
	addq	$112, %rsi
	cmpq	$224, %rcx
	jne	.L140
	addq	$8, %rdx
	cmpq	$8192, %rdx
	jne	.L136
	incq	64(%rsp)
	cmpl	$100, 80(%rsp)
	jne	.L145
	testq	%rbp, %rbp
	jne	.L142
	movl	84(%rsp), %eax
	xorl	%ecx, %ecx
	movl	$2, %edi
	movl	$1, %ebp
	leaq	.LC15(%rip), %rsi
	cltd
	idivl	80(%rsp)
	movl	60(%rsp), %edx
	movl	%eax, %r8d
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L147
.L142:
	incq	%rbp
	cmpq	$100, %rbp
	jne	.L147
	incl	60(%rsp)
	cmpl	$100, 60(%rsp)
	jne	.L104
	movq	216(%rsp), %rax
	subq	%fs:40, %rax
	je	.L152
	jmp	.L169
.L157:
	endbr64
	jmp	.L172
.L158:
	endbr64
.L172:
	movq	%rax, %rbp
.L150:
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	216(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L169
	movq	%rbp, %rdi
	call	_Unwind_Resume@PLT
.LEHE4:
.L169:
	call	__stack_chk_fail@PLT
.L152:
	addq	$232, %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
.LFE5191:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA5191:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE5191-.LLSDACSB5191
.LLSDACSB5191:
	.uleb128 .LEHB0-.LFB5191
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB5191
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L157-.LFB5191
	.uleb128 0
	.uleb128 .LEHB2-.LFB5191
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB3-.LFB5191
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L158-.LFB5191
	.uleb128 0
	.uleb128 .LEHB4-.LFB5191
	.uleb128 .LEHE4-.LEHB4
	.uleb128 0
	.uleb128 0
.LLSDACSE5191:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZZ4mainE15training_labels
	.comm	_ZZ4mainE15training_labels,8,8
	.local	_ZZ4mainE15training_images
	.comm	_ZZ4mainE15training_images,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1080025088
	.align 8
.LC2:
	.long	0
	.long	1072693248
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC3:
	.long	1065353216
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC4:
	.long	-2147483648
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst4
	.align 4
.LC7:
	.long	1065353215
	.align 4
.LC8:
	.long	805306368
	.align 4
.LC9:
	.long	-1073741824
	.align 4
.LC10:
	.long	1023410176
	.section	.rodata.cst8
	.align 8
.LC11:
	.long	987388755
	.long	1074351192
	.section	.rodata.cst4
	.align 4
.LC13:
	.long	-1082130432
	.align 4
.LC14:
	.long	1120403456
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cassert>
#include <chrono>
#include <random>
#include <string>
#include <ctime>
#include <algorithm>
#include <fcntl.h>
#include <unistd.h>

//constants
#define TRAINING_SET_SIZE 60000
#define TEST_SET_SIZE 10000
#define COLS 28
#define ROWS 28
#define IMG_MAGIC_NUM 0x00000803
#define LABEL_MAGIC_NUM 0x00000801
#define NUM_LABELS 60000
#define NUM_NEURONS 1024
#define EPOCH_SIZE 100
#define BATCH_SIZE 100

//All the integers in the files are stored in the MSB first (high endian) format
void toLittleEndian(int &num){
    num = (0xFF&(num >> 24))      |
          (0xFF00&(num >> 8))     |
          (0xFF0000&(num << 8))   |
          (0xFF000000&(num << 24));
}

void read_images(const std::string &file_name, float*** (&imgs)){
    int fd;
    fd = open(file_name.c_str(), O_RDONLY);
    assert(fd >= 0);

    int rv, magic_num, num_imgs, num_cols, num_rows;

    rv = read(fd, &magic_num, 4);
    assert(rv == 4);
    //change endianess
    toLittleEndian(magic_num);
    assert(magic_num == 0x803);

    rv = read(fd, &num_imgs, 4);
    assert(rv == 4);
    //change endianess
    toLittleEndian(num_imgs);

    rv = read(fd, &num_rows, 4);
    assert(rv == 4);
    //change endianness
    toLittleEndian(num_rows);

    rv = read(fd, &num_cols, 4);
    assert(rv == 4);
    //change endianness
    toLittleEndian(num_cols);

    imgs = new float**[num_imgs]();
    for(int i = 0; i < num_imgs; i++){
        imgs[i] = new float*[num_rows]();

        //read whole image at once to minimize IO since that takes time
        unsigned char tmp_img[num_rows][num_cols];
        rv = read(fd, tmp_img, num_rows*num_cols);
        assert(rv == num_rows*num_cols);

        for(int r = 0; r < num_rows; r++){
            imgs[i][r] = new float[num_cols]();
            for(int c = 0; c < num_cols; c++){
                imgs[i][r][c] = double(tmp_img[r][c])/127.5 - 1;
            }
        }

    }
    rv = close(fd);
    assert(rv == 0);
}

void read_labels(const std::string &file_name, unsigned char* (&labels)){
    int fd;
    fd = open(file_name.c_str(), O_RDONLY);
    assert(fd >= 0);

    int magic_num, num_labels;

    int rv = read(fd, &magic_num, 4);
    assert(rv == 4);
    //change endianess
    toLittleEndian(magic_num);

    rv = read(fd, &num_labels, 4);
    assert(rv == 4);
    //change endianess
    toLittleEndian(num_labels);

    labels = new unsigned char[num_labels]();
    rv = read(fd, labels, num_labels);
    for(int i = 0; i < num_labels; i++){
        //all labels are 0-9
        //assert(labels[i] >= 0 && labels[i] <= 9);
    }
    rv = close(fd);
    assert(rv == 0);

}

void generateWeights(float*** (&ilw), float*** (&ild), float** (&fclw), float** (&fcld)){

    //unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    unsigned seed = 8493;
    std::default_random_engine generator(seed);
    std::normal_distribution<float> distribution;

    ilw = new float**[NUM_NEURONS]();
    ild = new float**[NUM_NEURONS]();
    fclw = new float*[(int) NUM_NEURONS/EPOCH_SIZE]();
    fcld = new float*[(int) NUM_NEURONS/EPOCH_SIZE]();

    for(int n = 0; n < NUM_NEURONS; n++){
        ilw[n] = new float*[ROWS]();
        ild[n] = new float*[ROWS]();
        for(int r = 0; r < ROWS; r++){
            ilw[n][r] = new float[COLS]();
            ild[n][r] = new float[COLS]();
            for(int c = 0; c < COLS; c++){
                //normal_distribution represents unbownded distribution, divide by sqrt(N)
                ilw[n][r][c] = distribution(generator) / sqrt(NUM_NEURONS);
                //std::cout << distribution(generator) / sqrt(NUM_NEURONS) << std::endl;
                //initially weights are 0
                ild[n][r][c] = 0;
            }
        }
    }

    for(int i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
        fclw[i] = new float[NUM_NEURONS]();
        fcld[i] = new float[NUM_NEURONS]();
        for (int n = 0; n < NUM_NEURONS; n++){
            fclw[i][n] = distribution(generator) / sqrt((int) NUM_NEURONS/EPOCH_SIZE);
            fcld[i][n] = 0;
        }
    }
}

//based on softmax from prof. Chiu's examples
float* softmax(float *in){
    // Use identity softmax(x) == softmax(x - C)
    const auto C = *std::max_element(in, in+((int) NUM_NEURONS/EPOCH_SIZE));
    //std::cout << "Max element: " << C << std::endl;
    //same length as in
    float* out = new float[(int) NUM_NEURONS/EPOCH_SIZE];
    float sum = 0;
    for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
        //std::cout << in[i] - C << std::endl;
        out[i] = std::exp(in[i] - C);
        //assert(out[i] != 0);
        sum += out[i];
    }
    /*
    for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
        out[i] = out[i]/sum;
    }
    */
    // for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
    //     assert(out[i] != 0);
    //     std::cout << "GOOD" << std::endl;
    // }
    std::transform(out, out + ((int) NUM_NEURONS/EPOCH_SIZE), out, [sum](float e) {return e/sum;});

    // for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
    //     assert(out[i] != 0);
    //     if(out[i] != 0){
    //         std::cout << out[i] << std::endl;
    //     }
    // }

    return out;

}

float* softmax_ds(float* out, float* us){
    float* sm_ds = new float[(int) NUM_NEURONS/EPOCH_SIZE]();
    for(size_t i = 0; i < (int) NUM_NEURONS/EPOCH_SIZE; i++){
        for(size_t j = 0; j < (int) NUM_NEURONS/EPOCH_SIZE; j++){
            if( i == j) {
                sm_ds[i] += (out[j]*(1 - out[i])) * us[j];
            } else {
                sm_ds[i] += (-out[i]*out[j])*us[j];
            }
        }
    }
    return sm_ds;
}

__global__ void update_dense_weights(float *w1, float *ds1){
    //current thread and node num
    int tid = blockIdx.x * blockDim.x + threadIdx.x;

    w1[tid] -= (BATCH_SIZE/1000)*ds1[tid];
    ds1[tid] = 0;

}

int main(int argc, char** argv){
    if(argc != 3){
        std::cerr << "Wrong number of inputs. Usage: ./parallelNN <images> <labels>" << std::endl;
        exit(1);
    }

    //read training
    static float ***training_images;
    static unsigned char *training_labels;
    read_images(std::string(argv[1]), training_images);
    read_labels(std::string(argv[2]), training_labels);

    float ***input_layer_w, ***input_layer_ds;
    float **fully_connected_layer_w, **fully_connected_layer_ds;

    //std::cout << input_layer_w[0][0][0] << std::endl;

    generateWeights(input_layer_w, input_layer_ds, fully_connected_layer_w, fully_connected_layer_ds);

    //First fully connected layer
    float *first_layer = new float[NUM_NEURONS]();
    float *first_layer_ds = new float[NUM_NEURONS]();

    //Second fully connected layer
    float *second_layer = new float[(int)NUM_NEURONS/EPOCH_SIZE]();
    float *second_layer_ds = new float[NUM_NEURONS]();

    //Softmax layer
    float *soft_max_layer = new float[(int)NUM_NEURONS/EPOCH_SIZE]();
    float *soft_max_layer_ds = new float[(int)NUM_NEURONS/EPOCH_SIZE]();

    //Cross-entropy layer
    float* cross_ent_layer = new float[(int)NUM_NEURONS/EPOCH_SIZE]();

    //CUDA
    float *dense_layer_w1, *dense_layer_ds1, *dense_layer_w2, *dense_layer_ds2;
    //place them in contiguoys memory
    float *hidden_layer_w1 = new float[NUM_NEURONS*ROWS*COLS]();
    float *hidden_layer_ds1 = new float[NUM_NEURONS*ROWS*COLS]();
    float *hidden_layer_w2 = new float[NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE)]();
    float *hidden_layer_ds2 = new float[NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE)]();

    hipMalloc(&dense_layer_w1, NUM_NEURONS*ROWS*COLS*(sizeof(float)));
    hipMalloc(&dense_layer_ds1, NUM_NEURONS*ROWS*COLS*(sizeof(float)));
    hipMalloc(&dense_layer_w2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)));
    hipMalloc(&dense_layer_ds2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)));

    //to generate random number for dropout
    std::srand(std::time(0));

    for(int e = 0; e < EPOCH_SIZE; e++){
        //rounds
        for(int j = 0; j < EPOCH_SIZE; j++){

            //FORWARD

            //initialize values
            int correct = 0, total = 0;

            //loop through images in batch
            for(int i = 0; i < BATCH_SIZE; i++){
                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    cross_ent_layer[k] = 0;
                }
                //current label and img displaced by i (the images already processed)
                int current_label = (int) training_labels[EPOCH_SIZE*j + i];
                float** current_image = training_images[EPOCH_SIZE*j + i];

                for(int n = 0; n < NUM_NEURONS; n++){
                    float temp_result = 0;
                    //dropout rate of 0.4%
                    if(std::rand() % 1000 < 4){
                        first_layer[n] = 0;
                    } else{
                        for(int r = 0; r < ROWS; r++){
                            for(int c = 0; c < COLS; c++){
                                //calculate results of the first layer
                                temp_result += input_layer_w[n][r][c] * current_image[r][c];
                            }
                        }
                        //ReLU
                        if(temp_result < 0){
                            first_layer[n] = 0;
                        } else{
                            first_layer[n] = temp_result;
                        }
                    }
                }
                //std::cout << "1" << std::endl;
                //std::cout << input_layer_w[0][0][0] << std::endl;

                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    for(int n = 0; n < NUM_NEURONS; n++){
                        //second_layer weights are too large/small
                        second_layer[k] += fully_connected_layer_w[k][n] * first_layer[n];
                    }
                }

                soft_max_layer = softmax(second_layer);
                if(std::distance(soft_max_layer, std::max_element(soft_max_layer, soft_max_layer+(int) NUM_NEURONS/EPOCH_SIZE)) == current_label){
                    correct++;
                }
                total++;

                cross_ent_layer[current_label] = -1 / soft_max_layer[current_label];

                //BACK-PROPAGATION

                soft_max_layer_ds = softmax_ds(soft_max_layer, cross_ent_layer);

                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    for(int n = 0; n < NUM_NEURONS; n++){
                        second_layer_ds[n] = 0;
                    }
                    for(int n = 0; n < NUM_NEURONS; n++){
                        fully_connected_layer_ds[k][n] += ((first_layer[n] * soft_max_layer_ds[k]) / BATCH_SIZE);
                        second_layer_ds[n] += fully_connected_layer_w[k][n] * soft_max_layer_ds[k];
                    }
                }

                for(int n = 0; n < NUM_NEURONS; n++){
                    for(int r = 0; r < ROWS; r++){
                        for(int c = 0; c < COLS; c++){
                            input_layer_ds[n][r][c] +=  (current_image[r][c] * second_layer_ds[n])/BATCH_SIZE;
                        }
                    }
                }

                //UPDATE WEIGHTS
                //copy to contiguous array to copy to CUDA mem
                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    for(int n = 0; n < NUM_NEURONS; n++){
                        hidden_layer_w2[k*NUM_NEURONS + n] = fully_connected_layer_w[k][n] ;
                        hidden_layer_ds2[k*NUM_NEURONS + n] = fully_connected_layer_ds[k][n];
                    }
                }
                hipMemcpy(dense_layer_w2, hidden_layer_w2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), hipMemcpyHostToDevice);
                hipMemcpy(dense_layer_ds2, hidden_layer_ds2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), hipMemcpyHostToDevice);

                update_dense_weights<<<(int)NUM_NEURONS/EPOCH_SIZE, NUM_NEURONS>>>(dense_layer_w2, dense_layer_ds2);

                //copy back
                hipMemcpy(hidden_layer_w2, dense_layer_w2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), hipMemcpyHostToDevice);
                hipMemcpy(hidden_layer_ds2, dense_layer_ds2, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), hipMemcpyHostToDevice);


                for(int k = 0; k < (int) NUM_NEURONS/EPOCH_SIZE; k++){
                    for(int n = 0; n < NUM_NEURONS; n++){
                        fully_connected_layer_w[k][n] = hidden_layer_w2[k*NUM_NEURONS + n];
                        fully_connected_layer_ds[k][n] = hidden_layer_ds2[k*NUM_NEURONS + n];
                    }
                }

                /*----------------------*/

                for(int n = 0; n < NUM_NEURONS; n++){
                    for(int r = 0; r < ROWS; r++){
                        for(int c = 0; c < COLS; c++){
                            hidden_layer_w1[n*ROWS*COLS + r*ROWS + c] =  input_layer_w[n][r][c];
                            //std::cout << input_layer_ds[n][r][c] << std::endl;
                            //std::cout << input_layer_w[n][r][c] << std::endl;
                            hidden_layer_ds1[n*ROWS*COLS + r*ROWS + c] = input_layer_ds[n][r][c];
                        }
                    }
                }
                hipMemcpy(dense_layer_w1, hidden_layer_w1,  NUM_NEURONS*ROWS*COLS*(sizeof(float)), hipMemcpyHostToDevice);
                hipMemcpy(dense_layer_ds1, hidden_layer_ds1, NUM_NEURONS*ROWS*COLS*(sizeof(float)), hipMemcpyHostToDevice);

                update_dense_weights<<<ROWS*COLS, NUM_NEURONS>>>(dense_layer_w1, dense_layer_ds1);

                //copy back
                hipMemcpy(hidden_layer_w1, dense_layer_w1, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), hipMemcpyHostToDevice);
                hipMemcpy(hidden_layer_ds1, dense_layer_ds1, NUM_NEURONS* ((int)NUM_NEURONS/EPOCH_SIZE) *(sizeof(float)), hipMemcpyHostToDevice);


                for(int n = 0; n < NUM_NEURONS; n++){
                    for(int r = 0; r < ROWS; r++){
                        for(int c = 0; c < COLS; c++){
                            input_layer_w[n][r][c] = hidden_layer_w1[n*ROWS*COLS + r*ROWS + c];
                            //std::cout << input_layer_ds[n][r][c] << std::endl;
                            //std::cout << input_layer_w[n][r][c] << std::endl;
                            input_layer_ds[n][r][c] = hidden_layer_ds1[n*ROWS*COLS + r*ROWS + c];
                        }
                    }
                }
            }
            if(j % 100 == 0){
                //std::cout << input_layer_w[0][0][0] << std::endl;
                printf("Epoch %d: Round %d: accuracy=%f\n", e, j, correct/total);
            }

        }
    }

    return 0;

}























//

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

                                        # End of file scope inline assembly
	.globl	_Z14toLittleEndianRi            # -- Begin function _Z14toLittleEndianRi
	.type	_Z14toLittleEndianRi,@function
_Z14toLittleEndianRi:                   # @_Z14toLittleEndianRi
	.cfi_startproc
# %bb.0:
	movl	(%rdi), %eax
	bswapl	%eax
	movl	%eax, (%rdi)
	retq
.Lfunc_end0:
	.size	_Z14toLittleEndianRi, .Lfunc_end0-_Z14toLittleEndianRi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf
.LCPI1_0:
	.quad	0x405fe00000000000              # double 127.5
.LCPI1_1:
	.quad	0xbff0000000000000              # double -1
	.text
	.globl	_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf
	.type	_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf,@function
_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf: # @_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, -64(%rbp)                 # 8-byte Spill
	movq	(%rdi), %rdi
	xorl	%esi, %esi
	xorl	%eax, %eax
	callq	open
	movl	%eax, %r15d
	leaq	-136(%rbp), %rsi
	movl	$4, %edx
	movl	%eax, %edi
	callq	read
	leaq	-132(%rbp), %r14
	movl	$4, %edx
	movl	%r15d, %edi
	movq	%r14, %rsi
	callq	read
	movl	(%r14), %ebx
	bswapl	%ebx
	leaq	-124(%rbp), %r14
	movl	$4, %edx
	movl	%r15d, %edi
	movq	%r14, %rsi
	callq	read
	movl	(%r14), %eax
	movq	%rax, -56(%rbp)                 # 8-byte Spill
	leaq	-128(%rbp), %r14
	movl	$4, %edx
	movl	%r15d, -44(%rbp)                # 4-byte Spill
	movl	%r15d, %edi
	movq	%r14, %rsi
	callq	read
	movl	(%r14), %r15d
	movslq	%ebx, %r13
	leaq	(,%r13,8), %r14
	testl	%r13d, %r13d
	movq	$-1, %rax
	cmovsq	%rax, %r14
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, %r12
	movq	%rax, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
	movq	-64(%rbp), %rax                 # 8-byte Reload
	movq	%r12, (%rax)
	testl	%r13d, %r13d
	jle	.LBB1_9
# %bb.1:                                # %.lr.ph34
	movq	-56(%rbp), %rcx                 # 8-byte Reload
	bswapl	%ecx
	movslq	%ecx, %rax
	leaq	(,%rax,8), %rdx
	testl	%eax, %eax
	movq	$-1, %rsi
	cmovsq	%rsi, %rdx
	movq	%rdx, -96(%rbp)                 # 8-byte Spill
	bswapl	%r15d
	movq	%r15, %rdx
	movq	%rcx, -56(%rbp)                 # 8-byte Spill
	imulq	%rcx, %rdx
	imull	%r15d, %eax
	cltq
	movq	%rax, -80(%rbp)                 # 8-byte Spill
	movslq	%r15d, %rax
	leaq	(,%rax,4), %rcx
	testl	%eax, %eax
	cmovsq	%rsi, %rcx
	movq	%rcx, -112(%rbp)                # 8-byte Spill
	movl	%ebx, %eax
	movq	%rax, -72(%rbp)                 # 8-byte Spill
	xorl	%ebx, %ebx
	addq	$15, %rdx
	andq	$-16, %rdx
	movq	%rdx, -88(%rbp)                 # 8-byte Spill
.LBB1_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
                                        #       Child Loop BB1_6 Depth 3
	movq	-96(%rbp), %r12                 # 8-byte Reload
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, %r14
	movq	%rax, %rdi
	xorl	%esi, %esi
	movq	%r12, %rdx
	callq	memset@PLT
	movq	%rsp, -104(%rbp)                # 8-byte Spill
	movq	-64(%rbp), %rax                 # 8-byte Reload
	movq	(%rax), %rax
	movq	%r14, (%rax,%rbx,8)
	movq	%rsp, %r14
	subq	-88(%rbp), %r14                 # 8-byte Folded Reload
	movq	%r14, %rsp
	movl	-44(%rbp), %edi                 # 4-byte Reload
	movq	%r14, %rsi
	movq	-80(%rbp), %rdx                 # 8-byte Reload
	callq	read
	cmpl	$0, -56(%rbp)                   # 4-byte Folded Reload
	jle	.LBB1_8
# %bb.3:                                # %.lr.ph30.preheader
                                        #   in Loop: Header=BB1_2 Depth=1
	xorl	%r13d, %r13d
	movq	%rbx, -120(%rbp)                # 8-byte Spill
.LBB1_4:                                # %.lr.ph30
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_6 Depth 3
	movq	-112(%rbp), %rbx                # 8-byte Reload
	movq	%rbx, %rdi
	callq	_Znam
	movq	%rax, %r12
	movq	%rax, %rdi
	xorl	%esi, %esi
	movq	%rbx, %rdx
	movq	-120(%rbp), %rbx                # 8-byte Reload
	callq	memset@PLT
	movq	-64(%rbp), %rax                 # 8-byte Reload
	movq	(%rax), %rax
	movq	(%rax,%rbx,8), %rax
	movq	%r12, (%rax,%r13,8)
	testl	%r15d, %r15d
	movsd	.LCPI1_0(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	.LCPI1_1(%rip), %xmm2           # xmm2 = mem[0],zero
	jle	.LBB1_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB1_4 Depth=2
	movq	-64(%rbp), %rax                 # 8-byte Reload
	movq	(%rax), %rax
	movq	(%rax,%rbx,8), %rax
	movq	(%rax,%r13,8), %rax
	xorl	%ecx, %ecx
.LBB1_6:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movzbl	(%r14,%rcx), %edx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%edx, %xmm0
	divsd	%xmm1, %xmm0
	addsd	%xmm2, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %r15
	jne	.LBB1_6
.LBB1_7:                                # %._crit_edge
                                        #   in Loop: Header=BB1_4 Depth=2
	incq	%r13
	addq	%r15, %r14
	cmpq	-56(%rbp), %r13                 # 8-byte Folded Reload
	jne	.LBB1_4
.LBB1_8:                                # %._crit_edge31
                                        #   in Loop: Header=BB1_2 Depth=1
	movq	-104(%rbp), %rsp                # 8-byte Reload
	incq	%rbx
	cmpq	-72(%rbp), %rbx                 # 8-byte Folded Reload
	jne	.LBB1_2
.LBB1_9:                                # %._crit_edge35
	movl	-44(%rbp), %edi                 # 4-byte Reload
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	jmp	close                           # TAILCALL
.Lfunc_end1:
	.size	_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf, .Lfunc_end1-_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf
	.cfi_endproc
                                        # -- End function
	.globl	_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh # -- Begin function _Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh
	.type	_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh,@function
_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh: # @_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh
	.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
	movq	%rsi, %rbx
	movq	(%rdi), %rdi
	xorl	%esi, %esi
	xorl	%eax, %eax
	callq	open
	movl	%eax, %ebp
	leaq	4(%rsp), %rsi
	movl	$4, %edx
	movl	%eax, %edi
	callq	read
	movq	%rsp, %r14
	movl	$4, %edx
	movl	%ebp, %edi
	movq	%r14, %rsi
	callq	read
	movl	(%r14), %eax
	bswapl	%eax
	movslq	%eax, %r14
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, %r15
	movq	%rax, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	memset@PLT
	movq	%r15, (%rbx)
	movl	%ebp, %edi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	read
	movl	%ebp, %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	close                           # TAILCALL
.Lfunc_end2:
	.size	_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh, .Lfunc_end2-_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z15generateWeightsRPPPfS2_RS0_S3_
.LCPI3_0:
	.long	0x3d000000                      # float 0.03125
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI3_1:
	.quad	0x40094c583ada5b53              # double 3.1622776601683795
	.text
	.globl	_Z15generateWeightsRPPPfS2_RS0_S3_
	.type	_Z15generateWeightsRPPPfS2_RS0_S3_,@function
_Z15generateWeightsRPPPfS2_RS0_S3_:     # @_Z15generateWeightsRPPPfS2_RS0_S3_
	.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	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, %rbx
	movq	%rdx, %r12
	movq	%rsi, %r15
	movq	%rdi, %r13
	leaq	24(%rsp), %rax
	movq	$8493, (%rax)                   # imm = 0x212D
	movabsq	$4575657221408423936, %rax      # imm = 0x3F80000000000000
	leaq	40(%rsp), %rcx
	movq	%rax, (%rcx)
	movl	$0, 8(%rcx)
	movb	$0, 12(%rcx)
	movl	$8192, %edi                     # imm = 0x2000
	callq	_Znam
	movq	%rax, %rbp
	xorl	%r14d, %r14d
	movl	$8192, %edx                     # imm = 0x2000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	%rbp, (%r13)
	movl	$8192, %edi                     # imm = 0x2000
	callq	_Znam
	movq	%rax, %rbp
	movl	$8192, %edx                     # imm = 0x2000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	%rbp, (%r15)
	movl	$80, %edi
	callq	_Znam
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movups	%xmm0, 16(%rax)
	movups	%xmm0, 32(%rax)
	movups	%xmm0, 48(%rax)
	movups	%xmm0, 64(%rax)
	movq	%r12, (%rsp)                    # 8-byte Spill
	movq	%rax, (%r12)
	movl	$80, %edi
	callq	_Znam
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movups	%xmm0, 16(%rax)
	movups	%xmm0, 32(%rax)
	movups	%xmm0, 48(%rax)
	movups	%xmm0, 64(%rax)
	movq	%rbx, 32(%rsp)                  # 8-byte Spill
	movq	%rax, (%rbx)
	movq	(%r13), %rbx
	movq	%r13, 8(%rsp)                   # 8-byte Spill
	movq	%r15, 16(%rsp)                  # 8-byte Spill
	movq	8(%rsp), %rbp                   # 8-byte Reload
.LBB3_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_2 Depth 2
                                        #       Child Loop BB3_3 Depth 3
	movl	$224, %edi
	callq	_Znam
	movq	%rax, %r12
	movl	$224, %edx
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	%r12, (%rbx,%r14,8)
	movl	$224, %edi
	callq	_Znam
	movq	%rax, %rbx
	movl	$224, %edx
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	(%r15), %rax
	movq	%rbx, (%rax,%r14,8)
	movq	(%r13), %rbx
	xorl	%r13d, %r13d
.LBB3_2:                                #   Parent Loop BB3_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_3 Depth 3
	movl	$112, %edi
	callq	_Znam
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movups	%xmm0, 16(%rax)
	movups	%xmm0, 32(%rax)
	movups	%xmm0, 48(%rax)
	movups	%xmm0, 64(%rax)
	movups	%xmm0, 80(%rax)
	movups	%xmm0, 96(%rax)
	movq	(%rbx,%r14,8), %rcx
	movq	%rax, (%rcx,%r13,8)
	movl	$112, %edi
	callq	_Znam
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movups	%xmm0, 16(%rax)
	movups	%xmm0, 32(%rax)
	movups	%xmm0, 48(%rax)
	movups	%xmm0, 64(%rax)
	movups	%xmm0, 80(%rax)
	movups	%xmm0, 96(%rax)
	movq	(%r15), %rcx
	movq	(%rcx,%r14,8), %rcx
	movq	%rax, (%rcx,%r13,8)
	xorl	%r12d, %r12d
	leaq	40(%rsp), %r15
.LBB3_3:                                #   Parent Loop BB3_1 Depth=1
                                        #     Parent Loop BB3_2 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movq	%r15, %rdi
	leaq	24(%rsp), %rsi
	movq	%r15, %rdx
	callq	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE
	mulss	.LCPI3_0(%rip), %xmm0
	movq	(%rbp), %rbx
	movq	(%rbx,%r14,8), %rax
	movq	(%rax,%r13,8), %rax
	movss	%xmm0, (%rax,%r12,4)
	movq	16(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rax
	movq	(%rax,%r14,8), %rax
	movq	(%rax,%r13,8), %rax
	movl	$0, (%rax,%r12,4)
	incq	%r12
	cmpq	$28, %r12
	jne	.LBB3_3
# %bb.4:                                #   in Loop: Header=BB3_2 Depth=2
	incq	%r13
	cmpq	$28, %r13
	movq	16(%rsp), %r15                  # 8-byte Reload
	jne	.LBB3_2
# %bb.5:                                #   in Loop: Header=BB3_1 Depth=1
	incq	%r14
	cmpq	$1024, %r14                     # imm = 0x400
	movq	8(%rsp), %r13                   # 8-byte Reload
	jne	.LBB3_1
# %bb.6:                                # %.preheader.preheader
	movq	(%rsp), %rax                    # 8-byte Reload
	movq	(%rax), %rbx
	xorl	%r14d, %r14d
	leaq	40(%rsp), %r12
	movq	32(%rsp), %rbp                  # 8-byte Reload
	movq	(%rsp), %r15                    # 8-byte Reload
.LBB3_7:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_8 Depth 2
	movl	$4096, %edi                     # imm = 0x1000
	callq	_Znam
	movq	%rax, %r13
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	%r13, (%rbx,%r14,8)
	movl	$4096, %edi                     # imm = 0x1000
	callq	_Znam
	movq	%rax, %r13
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	(%rbp), %rax
	movq	%r13, (%rax,%r14,8)
	xorl	%r13d, %r13d
.LBB3_8:                                #   Parent Loop BB3_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r12, %rdi
	leaq	24(%rsp), %rsi
	movq	%r12, %rdx
	callq	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE
	cvtss2sd	%xmm0, %xmm0
	divsd	.LCPI3_1(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	(%r15), %rbx
	movq	(%rbx,%r14,8), %rax
	movss	%xmm0, (%rax,%r13,4)
	movq	(%rbp), %rax
	movq	(%rax,%r14,8), %rax
	movl	$0, (%rax,%r13,4)
	incq	%r13
	cmpq	$1024, %r13                     # imm = 0x400
	jne	.LBB3_8
# %bb.9:                                #   in Loop: Header=BB3_7 Depth=1
	incq	%r14
	cmpq	$10, %r14
	jne	.LBB3_7
# %bb.10:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z15generateWeightsRPPPfS2_RS0_S3_, .Lfunc_end3-_Z15generateWeightsRPPPfS2_RS0_S3_
	.cfi_endproc
                                        # -- End function
	.globl	_Z7softmaxPf                    # -- Begin function _Z7softmaxPf
	.type	_Z7softmaxPf,@function
_Z7softmaxPf:                           # @_Z7softmaxPf
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movss	(%rdi), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movl	$4, %eax
	movq	%rdi, %rcx
.LBB4_1:                                # %.lr.ph.i.i
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rbx,%rax), %xmm1              # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	leaq	(%rbx,%rax), %rdx
	cmovaq	%rdx, %rcx
	maxss	%xmm0, %xmm1
	addq	$4, %rax
	movaps	%xmm1, %xmm0
	cmpq	$40, %rax
	jne	.LBB4_1
# %bb.2:                                # %_ZSt11max_elementIPfET_S1_S1_.exit
	movss	(%rcx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 8(%rsp)                  # 4-byte Spill
	movl	$40, %edi
	callq	_Znam
	movq	%rax, %r14
	xorps	%xmm1, %xmm1
	xorl	%r15d, %r15d
.LBB4_3:                                # =>This Inner Loop Header: Depth=1
	movss	%xmm1, 12(%rsp)                 # 4-byte Spill
	movss	(%rbx,%r15,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	subss	8(%rsp), %xmm0                  # 4-byte Folded Reload
	callq	expf
	movss	12(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	movss	%xmm0, (%r14,%r15,4)
	addss	%xmm0, %xmm1
	incq	%r15
	cmpq	$10, %r15
	jne	.LBB4_3
# %bb.4:                                # %.lr.ph.i.preheader
	xorl	%eax, %eax
.LBB4_5:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r14,%rax), %xmm0              # xmm0 = mem[0],zero,zero,zero
	divss	%xmm1, %xmm0
	movss	%xmm0, (%r14,%rax)
	addq	$4, %rax
	cmpq	$40, %rax
	jne	.LBB4_5
# %bb.6:                                # %_ZSt9transformIPfS0_Z7softmaxS0_EUlfE_ET0_T_S3_S2_T1_.exit
	movq	%r14, %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z7softmaxPf, .Lfunc_end4-_Z7softmaxPf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z10softmax_dsPfS_
.LCPI5_0:
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI5_1:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z10softmax_dsPfS_
	.type	_Z10softmax_dsPfS_,@function
_Z10softmax_dsPfS_:                     # @_Z10softmax_dsPfS_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$40, %edi
	callq	_Znam
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movups	%xmm0, 16(%rax)
	movq	$0, 32(%rax)
	xorl	%ecx, %ecx
	movaps	.LCPI5_0(%rip), %xmm0           # xmm0 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
.LBB5_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_2 Depth 2
	movss	(%rax,%rcx,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	movss	(%r14,%rcx,4), %xmm4            # xmm4 = mem[0],zero,zero,zero
	movaps	%xmm1, %xmm3
	subss	%xmm4, %xmm3
	mulss	%xmm4, %xmm3
	xorps	%xmm0, %xmm4
	xorl	%edx, %edx
.LBB5_2:                                #   Parent Loop BB5_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpq	%rdx, %rcx
	jne	.LBB5_6
# %bb.3:                                #   in Loop: Header=BB5_2 Depth=2
	movss	(%rbx,%rcx,4), %xmm5            # xmm5 = mem[0],zero,zero,zero
	movaps	%xmm3, %xmm6
	jmp	.LBB5_7
.LBB5_6:                                #   in Loop: Header=BB5_2 Depth=2
	movss	(%r14,%rdx,4), %xmm5            # xmm5 = mem[0],zero,zero,zero
	mulss	%xmm4, %xmm5
	movss	(%rbx,%rdx,4), %xmm6            # xmm6 = mem[0],zero,zero,zero
.LBB5_7:                                #   in Loop: Header=BB5_2 Depth=2
	mulss	%xmm5, %xmm6
	addss	%xmm6, %xmm2
	incq	%rdx
	cmpq	$10, %rdx
	jne	.LBB5_2
# %bb.4:                                #   in Loop: Header=BB5_1 Depth=1
	movss	%xmm2, (%rax,%rcx,4)
	incq	%rcx
	cmpq	$10, %rcx
	jne	.LBB5_1
# %bb.5:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z10softmax_dsPfS_, .Lfunc_end5-_Z10softmax_dsPfS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z35__device_stub__update_dense_weightsPfS_ # -- Begin function _Z35__device_stub__update_dense_weightsPfS_
	.type	_Z35__device_stub__update_dense_weightsPfS_,@function
_Z35__device_stub__update_dense_weightsPfS_: # @_Z35__device_stub__update_dense_weightsPfS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%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	$_Z20update_dense_weightsPfS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z35__device_stub__update_dense_weightsPfS_, .Lfunc_end6-_Z35__device_stub__update_dense_weightsPfS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI7_0:
	.long	0xbf800000                      # float -1
.LCPI7_1:
	.long	0x42c80000                      # float 100
.LCPI7_2:
	.long	0x00000000                      # float 0
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$200, %rsp
	.cfi_def_cfa_offset 256
	.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	$3, %edi
	jne	.LBB7_75
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rsi
.Ltmp0:
	leaq	112(%rsp), %rdi
	leaq	104(%rsp), %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
.Ltmp1:
# %bb.2:
.Ltmp3:
	leaq	112(%rsp), %rdi
	movl	$_ZZ4mainE15training_images, %esi
	callq	_Z11read_imagesRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPPPf
.Ltmp4:
# %bb.3:
	leaq	128(%rsp), %r14
	movq	-16(%r14), %rdi
	cmpq	%r14, %rdi
	je	.LBB7_5
# %bb.4:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
	callq	_ZdlPv
.LBB7_5:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
	movq	16(%rbx), %rsi
.Ltmp6:
	leaq	112(%rsp), %rdi
	leaq	104(%rsp), %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
.Ltmp7:
# %bb.6:
.Ltmp9:
	leaq	112(%rsp), %rdi
	movl	$_ZZ4mainE15training_labels, %esi
	callq	_Z11read_labelsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPh
.Ltmp10:
# %bb.7:
	movq	112(%rsp), %rdi
	cmpq	%r14, %rdi
	je	.LBB7_9
# %bb.8:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i223
	callq	_ZdlPv
.LBB7_9:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit225
	leaq	112(%rsp), %rdi
	leaq	104(%rsp), %r15
	leaq	192(%rsp), %rdx
	leaq	184(%rsp), %rcx
	movq	%r15, %rsi
	callq	_Z15generateWeightsRPPPfS2_RS0_S3_
	movl	$4096, %edi                     # imm = 0x1000
	callq	_Znam
	movq	%rax, %r14
	xorl	%ebx, %ebx
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$40, %edi
	callq	_Znam
	movq	%rax, %r13
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movups	%xmm0, 16(%rax)
	movq	%rbx, 32(%rax)
	movl	$4096, %edi                     # imm = 0x1000
	callq	_Znam
	movq	%rax, %r12
	movl	$4096, %edx                     # imm = 0x1000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$40, %edi
	callq	_Znam
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movups	%xmm0, 16(%rax)
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	%rbx, 32(%rax)
	movl	$3211264, %edi                  # imm = 0x310000
	callq	_Znam
	movl	$3211264, %edx                  # imm = 0x310000
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$3211264, %edi                  # imm = 0x310000
	callq	_Znam
	movl	$3211264, %edx                  # imm = 0x310000
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$40960, %edi                    # imm = 0xA000
	callq	_Znam
	movl	$40960, %edx                    # imm = 0xA000
	movq	%rax, 152(%rsp)                 # 8-byte Spill
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$40960, %edi                    # imm = 0xA000
	callq	_Znam
	movq	%rax, %rbp
	movl	$40960, %edx                    # imm = 0xA000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	leaq	56(%rsp), %rdi
	movl	$3211264, %esi                  # imm = 0x310000
	callq	hipMalloc
	leaq	48(%rsp), %rdi
	movl	$3211264, %esi                  # imm = 0x310000
	callq	hipMalloc
	leaq	40(%rsp), %rdi
	movl	$40960, %esi                    # imm = 0xA000
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movl	$40960, %esi                    # imm = 0xA000
	callq	hipMalloc
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	leaq	112(%rsp), %rax
	movq	(%rax), %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	leaq	192(%rsp), %rax
	movq	(%rax), %rbx
	leaq	184(%rsp), %rax
	movq	(%rax), %rax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movq	(%r15), %rax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movl	$0, (%rsp)                      # 4-byte Folded Spill
	movq	%r13, 160(%rsp)                 # 8-byte Spill
	movq	%rbp, 64(%rsp)                  # 8-byte Spill
.LBB7_10:                               # %.preheader261
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_11 Depth 2
                                        #       Child Loop BB7_12 Depth 3
                                        #         Child Loop BB7_13 Depth 4
                                        #           Child Loop BB7_15 Depth 5
                                        #             Child Loop BB7_16 Depth 6
                                        #         Child Loop BB7_32 Depth 4
                                        #           Child Loop BB7_33 Depth 5
                                        #         Child Loop BB7_36 Depth 4
                                        #         Child Loop BB7_38 Depth 4
                                        #           Child Loop BB7_39 Depth 5
                                        #         Child Loop BB7_42 Depth 4
                                        #           Child Loop BB7_43 Depth 5
                                        #             Child Loop BB7_44 Depth 6
                                        #         Child Loop BB7_48 Depth 4
                                        #           Child Loop BB7_49 Depth 5
                                        #         Child Loop BB7_54 Depth 4
                                        #           Child Loop BB7_55 Depth 5
                                        #         Child Loop BB7_58 Depth 4
                                        #           Child Loop BB7_59 Depth 5
                                        #             Child Loop BB7_60 Depth 6
                                        #         Child Loop BB7_66 Depth 4
                                        #           Child Loop BB7_67 Depth 5
                                        #             Child Loop BB7_68 Depth 6
	xorl	%r15d, %r15d
.LBB7_11:                               # %.preheader260
                                        #   Parent Loop BB7_10 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB7_12 Depth 3
                                        #         Child Loop BB7_13 Depth 4
                                        #           Child Loop BB7_15 Depth 5
                                        #             Child Loop BB7_16 Depth 6
                                        #         Child Loop BB7_32 Depth 4
                                        #           Child Loop BB7_33 Depth 5
                                        #         Child Loop BB7_36 Depth 4
                                        #         Child Loop BB7_38 Depth 4
                                        #           Child Loop BB7_39 Depth 5
                                        #         Child Loop BB7_42 Depth 4
                                        #           Child Loop BB7_43 Depth 5
                                        #             Child Loop BB7_44 Depth 6
                                        #         Child Loop BB7_48 Depth 4
                                        #           Child Loop BB7_49 Depth 5
                                        #         Child Loop BB7_54 Depth 4
                                        #           Child Loop BB7_55 Depth 5
                                        #         Child Loop BB7_58 Depth 4
                                        #           Child Loop BB7_59 Depth 5
                                        #             Child Loop BB7_60 Depth 6
                                        #         Child Loop BB7_66 Depth 4
                                        #           Child Loop BB7_67 Depth 5
                                        #             Child Loop BB7_68 Depth 6
	movq	%r15, 144(%rsp)                 # 8-byte Spill
	imulq	$100, %r15, %rax
	movq	%rax, 168(%rsp)                 # 8-byte Spill
	xorl	%edx, %edx
	movl	$0, 4(%rsp)                     # 4-byte Folded Spill
.LBB7_12:                               # %.preheader259
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB7_13 Depth 4
                                        #           Child Loop BB7_15 Depth 5
                                        #             Child Loop BB7_16 Depth 6
                                        #         Child Loop BB7_32 Depth 4
                                        #           Child Loop BB7_33 Depth 5
                                        #         Child Loop BB7_36 Depth 4
                                        #         Child Loop BB7_38 Depth 4
                                        #           Child Loop BB7_39 Depth 5
                                        #         Child Loop BB7_42 Depth 4
                                        #           Child Loop BB7_43 Depth 5
                                        #             Child Loop BB7_44 Depth 6
                                        #         Child Loop BB7_48 Depth 4
                                        #           Child Loop BB7_49 Depth 5
                                        #         Child Loop BB7_54 Depth 4
                                        #           Child Loop BB7_55 Depth 5
                                        #         Child Loop BB7_58 Depth 4
                                        #           Child Loop BB7_59 Depth 5
                                        #             Child Loop BB7_60 Depth 6
                                        #         Child Loop BB7_66 Depth 4
                                        #           Child Loop BB7_67 Depth 5
                                        #             Child Loop BB7_68 Depth 6
	xorps	%xmm0, %xmm0
	movq	88(%rsp), %rax                  # 8-byte Reload
	movups	%xmm0, 16(%rax)
	movups	%xmm0, (%rax)
	movq	$0, 32(%rax)
	movq	_ZZ4mainE15training_labels(%rip), %rax
	movq	168(%rsp), %rcx                 # 8-byte Reload
	movq	%rdx, 96(%rsp)                  # 8-byte Spill
	addq	%rdx, %rcx
	movzbl	(%rax,%rcx), %eax
	movq	%rax, 176(%rsp)                 # 8-byte Spill
	movq	_ZZ4mainE15training_images(%rip), %rax
	movq	(%rax,%rcx,8), %r15
	xorl	%ebp, %ebp
.LBB7_13:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB7_15 Depth 5
                                        #             Child Loop BB7_16 Depth 6
	callq	rand
	cltq
	imulq	$274877907, %rax, %rcx          # imm = 0x10624DD3
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$38, %rcx
	addl	%edx, %ecx
	imull	$1000, %ecx, %ecx               # imm = 0x3E8
	subl	%ecx, %eax
	cmpl	$4, %eax
	jl	.LBB7_19
# %bb.14:                               # %.preheader254
                                        #   in Loop: Header=BB7_13 Depth=4
	movq	16(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%rbp,8), %rax
	xorps	%xmm0, %xmm0
	xorl	%ecx, %ecx
.LBB7_15:                               # %.preheader245
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_13 Depth=4
                                        # =>        This Loop Header: Depth=5
                                        #             Child Loop BB7_16 Depth 6
	movq	(%rax,%rcx,8), %rdx
	movq	(%r15,%rcx,8), %rsi
	xorl	%edi, %edi
.LBB7_16:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_13 Depth=4
                                        #           Parent Loop BB7_15 Depth=5
                                        # =>          This Inner Loop Header: Depth=6
	movss	(%rdx,%rdi,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%rsi,%rdi,4), %xmm1
	addss	%xmm1, %xmm0
	incq	%rdi
	cmpq	$28, %rdi
	jne	.LBB7_16
# %bb.17:                               #   in Loop: Header=BB7_15 Depth=5
	incq	%rcx
	cmpq	$28, %rcx
	jne	.LBB7_15
# %bb.18:                               #   in Loop: Header=BB7_13 Depth=4
	xorps	%xmm1, %xmm1
	ucomiss	%xmm0, %xmm1
	jbe	.LBB7_29
.LBB7_19:                               #   in Loop: Header=BB7_13 Depth=4
	movl	$0, (%r14,%rbp,4)
	jmp	.LBB7_30
.LBB7_29:                               #   in Loop: Header=BB7_13 Depth=4
	movss	%xmm0, (%r14,%rbp,4)
.LBB7_30:                               #   in Loop: Header=BB7_13 Depth=4
	incq	%rbp
	cmpq	$1024, %rbp                     # imm = 0x400
	jne	.LBB7_13
# %bb.31:                               # %.preheader253.preheader
                                        #   in Loop: Header=BB7_12 Depth=3
	xorl	%eax, %eax
.LBB7_32:                               # %.preheader253
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB7_33 Depth 5
	movq	(%rbx,%rax,8), %rcx
	movss	(%r13,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	xorl	%edx, %edx
.LBB7_33:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_32 Depth=4
                                        # =>        This Inner Loop Header: Depth=5
	movss	(%rcx,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r14,%rdx,4), %xmm1
	addss	%xmm1, %xmm0
	incq	%rdx
	cmpq	$1024, %rdx                     # imm = 0x400
	jne	.LBB7_33
# %bb.34:                               #   in Loop: Header=BB7_32 Depth=4
	movss	%xmm0, (%r13,%rax,4)
	incq	%rax
	cmpq	$10, %rax
	jne	.LBB7_32
# %bb.35:                               #   in Loop: Header=BB7_12 Depth=3
	movq	%r13, %rdi
	callq	_Z7softmaxPf
	movss	(%rax), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movl	$4, %edx
	movq	%rax, %rcx
.LBB7_36:                               # %.lr.ph.i.i
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movss	(%rax,%rdx), %xmm1              # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	leaq	(%rax,%rdx), %rsi
	cmovaq	%rsi, %rcx
	maxss	%xmm0, %xmm1
	addq	$4, %rdx
	movaps	%xmm1, %xmm0
	cmpq	$40, %rdx
	jne	.LBB7_36
# %bb.37:                               # %_ZSt11max_elementIPfET_S1_S1_.exit
                                        #   in Loop: Header=BB7_12 Depth=3
	subq	%rax, %rcx
	sarq	$2, %rcx
	xorl	%edx, %edx
	movq	176(%rsp), %rdi                 # 8-byte Reload
	cmpq	%rdi, %rcx
	sete	%dl
	addl	%edx, 4(%rsp)                   # 4-byte Folded Spill
	movss	.LCPI7_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	divss	(%rax,%rdi,4), %xmm0
	movq	88(%rsp), %rsi                  # 8-byte Reload
	movss	%xmm0, (%rsi,%rdi,4)
	movq	%rax, %rdi
	callq	_Z10softmax_dsPfS_
	movq	%rax, %rbp
	xorl	%r13d, %r13d
.LBB7_38:                               # %.preheader252
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB7_39 Depth 5
	movl	$4096, %edx                     # imm = 0x1000
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movss	(%rbp,%r13,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	8(%rsp), %rax                   # 8-byte Reload
	movq	(%rax,%r13,8), %rax
	movq	(%rbx,%r13,8), %rcx
	xorl	%edx, %edx
	movss	.LCPI7_1(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
.LBB7_39:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_38 Depth=4
                                        # =>        This Inner Loop Header: Depth=5
	movss	(%r14,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	divss	%xmm2, %xmm1
	addss	(%rax,%rdx,4), %xmm1
	movss	%xmm1, (%rax,%rdx,4)
	movss	(%rcx,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	addss	(%r12,%rdx,4), %xmm1
	movss	%xmm1, (%r12,%rdx,4)
	incq	%rdx
	cmpq	$1024, %rdx                     # imm = 0x400
	jne	.LBB7_39
# %bb.40:                               #   in Loop: Header=BB7_38 Depth=4
	incq	%r13
	cmpq	$10, %r13
	jne	.LBB7_38
# %bb.41:                               # %.preheader250.preheader
                                        #   in Loop: Header=BB7_12 Depth=3
	xorl	%eax, %eax
	movq	152(%rsp), %r13                 # 8-byte Reload
	movq	64(%rsp), %r10                  # 8-byte Reload
	movq	8(%rsp), %r11                   # 8-byte Reload
	movss	.LCPI7_1(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
.LBB7_42:                               # %.preheader250
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB7_43 Depth 5
                                        #             Child Loop BB7_44 Depth 6
	movss	(%r12,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	24(%rsp), %rcx                  # 8-byte Reload
	movq	(%rcx,%rax,8), %rcx
	xorl	%edx, %edx
.LBB7_43:                               # %.preheader244
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_42 Depth=4
                                        # =>        This Loop Header: Depth=5
                                        #             Child Loop BB7_44 Depth 6
	movq	(%r15,%rdx,8), %r9
	movq	(%rcx,%rdx,8), %rdi
	xorl	%r8d, %r8d
.LBB7_44:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_42 Depth=4
                                        #           Parent Loop BB7_43 Depth=5
                                        # =>          This Inner Loop Header: Depth=6
	movss	(%r9,%r8,4), %xmm1              # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	divss	%xmm2, %xmm1
	addss	(%rdi,%r8,4), %xmm1
	movss	%xmm1, (%rdi,%r8,4)
	incq	%r8
	cmpq	$28, %r8
	jne	.LBB7_44
# %bb.45:                               #   in Loop: Header=BB7_43 Depth=5
	incq	%rdx
	cmpq	$28, %rdx
	jne	.LBB7_43
# %bb.46:                               #   in Loop: Header=BB7_42 Depth=4
	incq	%rax
	cmpq	$1024, %rax                     # imm = 0x400
	jne	.LBB7_42
# %bb.47:                               # %.preheader249.preheader
                                        #   in Loop: Header=BB7_12 Depth=3
	movq	%r13, %rax
	movq	%r10, %rcx
	xorl	%edx, %edx
	movl	$4096, %r15d                    # imm = 0x1000
.LBB7_48:                               # %.preheader249
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB7_49 Depth 5
	movq	(%rbx,%rdx,8), %r9
	movq	(%r11,%rdx,8), %rdi
	xorl	%r8d, %r8d
.LBB7_49:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_48 Depth=4
                                        # =>        This Inner Loop Header: Depth=5
	movss	(%r9,%r8,4), %xmm0              # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rax,%r8,4)
	movss	(%rdi,%r8,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rcx,%r8,4)
	incq	%r8
	cmpq	$1024, %r8                      # imm = 0x400
	jne	.LBB7_49
# %bb.50:                               #   in Loop: Header=BB7_48 Depth=4
	incq	%rdx
	addq	%r15, %rcx
	addq	%r15, %rax
	cmpq	$10, %rdx
	jne	.LBB7_48
# %bb.51:                               #   in Loop: Header=BB7_12 Depth=3
	movq	40(%rsp), %rdi
	movl	$40960, %edx                    # imm = 0xA000
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	movl	$40960, %edx                    # imm = 0xA000
	movq	64(%rsp), %rbp                  # 8-byte Reload
	movq	%rbp, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movabsq	$4294968320, %rdx               # imm = 0x100000400
	leaq	-1014(%rdx), %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_53
# %bb.52:                               #   in Loop: Header=BB7_12 Depth=3
	movq	40(%rsp), %rdi
	movq	32(%rsp), %rsi
	callq	_Z35__device_stub__update_dense_weightsPfS_
.LBB7_53:                               #   in Loop: Header=BB7_12 Depth=3
	incq	96(%rsp)                        # 8-byte Folded Spill
	movq	40(%rsp), %rsi
	movl	$40960, %edx                    # imm = 0xA000
	movq	%r13, %rdi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rsi
	movl	$40960, %edx                    # imm = 0xA000
	movq	%rbp, %rdi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rbp, %rcx
	xorl	%edx, %edx
	movq	8(%rsp), %r9                    # 8-byte Reload
.LBB7_54:                               # %.preheader248
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB7_55 Depth 5
	movq	(%rbx,%rdx,8), %rsi
	movq	(%r9,%rdx,8), %rdi
	xorl	%r8d, %r8d
.LBB7_55:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_54 Depth=4
                                        # =>        This Inner Loop Header: Depth=5
	movss	(%r13,%r8,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rsi,%r8,4)
	movss	(%rcx,%r8,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdi,%r8,4)
	incq	%r8
	cmpq	$1024, %r8                      # imm = 0x400
	jne	.LBB7_55
# %bb.56:                               #   in Loop: Header=BB7_54 Depth=4
	incq	%rdx
	addq	%r15, %rcx
	addq	%r15, %r13
	cmpq	$10, %rdx
	jne	.LBB7_54
# %bb.57:                               # %.preheader247.preheader
                                        #   in Loop: Header=BB7_12 Depth=3
	movq	80(%rsp), %rax                  # 8-byte Reload
	movq	72(%rsp), %rcx                  # 8-byte Reload
	xorl	%edx, %edx
.LBB7_58:                               # %.preheader247
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB7_59 Depth 5
                                        #             Child Loop BB7_60 Depth 6
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	(%rsi,%rdx,8), %rsi
	movq	24(%rsp), %rdi                  # 8-byte Reload
	movq	(%rdi,%rdx,8), %rdi
	movq	%rax, %r8
	movq	%rcx, %r9
	xorl	%r10d, %r10d
.LBB7_59:                               # %.preheader243
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_58 Depth=4
                                        # =>        This Loop Header: Depth=5
                                        #             Child Loop BB7_60 Depth 6
	movq	(%rsi,%r10,8), %r11
	movq	(%rdi,%r10,8), %r15
	xorl	%r13d, %r13d
.LBB7_60:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_58 Depth=4
                                        #           Parent Loop BB7_59 Depth=5
                                        # =>          This Inner Loop Header: Depth=6
	movss	(%r11,%r13,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r8,%r13,4)
	movss	(%r15,%r13,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r9,%r13,4)
	incq	%r13
	cmpq	$28, %r13
	jne	.LBB7_60
# %bb.61:                               #   in Loop: Header=BB7_59 Depth=5
	incq	%r10
	addq	$112, %r9
	addq	$112, %r8
	cmpq	$28, %r10
	jne	.LBB7_59
# %bb.62:                               #   in Loop: Header=BB7_58 Depth=4
	incq	%rdx
	movl	$3136, %esi                     # imm = 0xC40
	addq	%rsi, %rcx
	addq	%rsi, %rax
	cmpq	$1024, %rdx                     # imm = 0x400
	jne	.LBB7_58
# %bb.63:                               #   in Loop: Header=BB7_12 Depth=3
	movq	56(%rsp), %rdi
	movl	$3211264, %edx                  # imm = 0x310000
	movq	80(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	48(%rsp), %rdi
	movl	$3211264, %edx                  # imm = 0x310000
	movq	72(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movabsq	$4294968320, %rdx               # imm = 0x100000400
	leaq	-240(%rdx), %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_65
# %bb.64:                               #   in Loop: Header=BB7_12 Depth=3
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	callq	_Z35__device_stub__update_dense_weightsPfS_
.LBB7_65:                               #   in Loop: Header=BB7_12 Depth=3
	movq	56(%rsp), %rsi
	movl	$40960, %edx                    # imm = 0xA000
	movq	%r15, %rdi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	48(%rsp), %rsi
	movl	$40960, %edx                    # imm = 0xA000
	movq	%r13, %rdi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r15, %rax
	movq	%r13, %rcx
	xorl	%edx, %edx
.LBB7_66:                               # %.preheader246
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Loop Header: Depth=4
                                        #           Child Loop BB7_67 Depth 5
                                        #             Child Loop BB7_68 Depth 6
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	(%rsi,%rdx,8), %rsi
	movq	24(%rsp), %rdi                  # 8-byte Reload
	movq	(%rdi,%rdx,8), %rdi
	movq	%rax, %r8
	movq	%rcx, %r9
	xorl	%r10d, %r10d
.LBB7_67:                               # %.preheader
                                        #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_66 Depth=4
                                        # =>        This Loop Header: Depth=5
                                        #             Child Loop BB7_68 Depth 6
	movq	(%rsi,%r10,8), %r11
	movq	(%rdi,%r10,8), %r15
	xorl	%r13d, %r13d
.LBB7_68:                               #   Parent Loop BB7_10 Depth=1
                                        #     Parent Loop BB7_11 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        #         Parent Loop BB7_66 Depth=4
                                        #           Parent Loop BB7_67 Depth=5
                                        # =>          This Inner Loop Header: Depth=6
	movss	(%r8,%r13,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r11,%r13,4)
	movss	(%r9,%r13,4), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r15,%r13,4)
	incq	%r13
	cmpq	$28, %r13
	jne	.LBB7_68
# %bb.69:                               #   in Loop: Header=BB7_67 Depth=5
	incq	%r10
	addq	$112, %r9
	addq	$112, %r8
	cmpq	$28, %r10
	jne	.LBB7_67
# %bb.70:                               #   in Loop: Header=BB7_66 Depth=4
	incq	%rdx
	movl	$3136, %esi                     # imm = 0xC40
	addq	%rsi, %rcx
	addq	%rsi, %rax
	cmpq	$1024, %rdx                     # imm = 0x400
	jne	.LBB7_66
# %bb.71:                               #   in Loop: Header=BB7_12 Depth=3
	movq	96(%rsp), %rdx                  # 8-byte Reload
	cmpq	$100, %rdx
	movq	160(%rsp), %r13                 # 8-byte Reload
	jne	.LBB7_12
# %bb.72:                               #   in Loop: Header=BB7_11 Depth=2
	movq	144(%rsp), %r15                 # 8-byte Reload
	testq	%r15, %r15
	jne	.LBB7_74
# %bb.73:                               #   in Loop: Header=BB7_11 Depth=2
	movl	4(%rsp), %eax                   # 4-byte Reload
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	shrq	$37, %rcx
	movl	$.L.str.1, %edi
	movl	(%rsp), %esi                    # 4-byte Reload
	xorl	%edx, %edx
                                        # kill: def $ecx killed $ecx killed $rcx
	xorl	%eax, %eax
	callq	printf
.LBB7_74:                               #   in Loop: Header=BB7_11 Depth=2
	incq	%r15
	cmpq	$100, %r15
	jne	.LBB7_11
# %bb.27:                               #   in Loop: Header=BB7_10 Depth=1
	movl	(%rsp), %eax                    # 4-byte Reload
	incl	%eax
	movl	%eax, (%rsp)                    # 4-byte Spill
	cmpl	$100, %eax
	jne	.LBB7_10
# %bb.28:
	xorl	%eax, %eax
	addq	$200, %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
.LBB7_75:
	.cfi_def_cfa_offset 256
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$1, %edi
	callq	exit
.LBB7_26:
.Ltmp11:
	movq	%rax, %rbx
	movq	112(%rsp), %rdi
	cmpq	%r14, %rdi
	jne	.LBB7_24
	jmp	.LBB7_22
.LBB7_25:
.Ltmp8:
	jmp	.LBB7_21
.LBB7_23:
.Ltmp5:
	movq	%rax, %rbx
	leaq	128(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB7_22
.LBB7_24:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i226
	callq	_ZdlPv
	jmp	.LBB7_22
.LBB7_20:
.Ltmp2:
.LBB7_21:
	movq	%rax, %rbx
.LBB7_22:
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end7:
	.size	main, .Lfunc_end7-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table7:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 1 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp10-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp10
	.uleb128 .Ltmp11-.Lfunc_begin0          #     jumps to .Ltmp11
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Lfunc_end7-.Ltmp10            #   Call between .Ltmp10 and .Lfunc_end7
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_ # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	je	.LBB8_1
# %bb.2:
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movq	%rsi, %rdi
	callq	strlen
	leaq	(%rax,%rbx), %rdx
	movq	%r14, %rdi
	movq	%rbx, %rsi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # TAILCALL
.LBB8_1:
	.cfi_def_cfa_offset 32
	movl	$.L.str.2, %edi
	callq	_ZSt19__throw_logic_errorPKc
.Lfunc_end8:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .Lfunc_end8-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbx
	subq	%rsi, %r14
	movq	%r14, (%rsp)
	cmpq	$15, %r14
	jbe	.LBB9_1
# %bb.2:
	movq	%rsp, %r12
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm
	movq	%rax, (%rbx)
	movq	(%r12), %rcx
	movq	%rcx, 16(%rbx)
	jmp	.LBB9_3
.LBB9_1:                                # %._crit_edge
	movq	(%rbx), %rax
.LBB9_3:
	testq	%r14, %r14
	je	.LBB9_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB9_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB9_7
.LBB9_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB9_7:                                # %_ZZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tagEN6_GuardD2Ev.exit
	movq	(%rsp), %rax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rcx
	movb	$0, (%rcx,%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag, .Lfunc_end9-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE
.LCPI10_0:
	.long	0xbf800000                      # float -1
.LCPI10_1:
	.long	0x3f800000                      # float 1
.LCPI10_2:
	.long	0xc0000000                      # float -2
.LCPI10_3:
	.long	0x00000000                      # float 0
	.section	.text._ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE,"axG",@progbits,_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE,comdat
	.weak	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE
	.p2align	1, 0x90
	.type	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE,@function
_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE: # @_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %rbx
	movq	%rdi, %r14
	cmpb	$0, 12(%rdi)
	je	.LBB10_1
# %bb.9:
	movb	$0, 12(%r14)
	movss	8(%r14), %xmm1                  # xmm1 = mem[0],zero,zero,zero
	jmp	.LBB10_8
.LBB10_1:
	movq	%rsi, %r15
.LBB10_2:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	callq	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	movaps	%xmm0, %xmm1
	addss	%xmm0, %xmm1
	movss	.LCPI10_0(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
	addss	%xmm0, %xmm1
	movss	%xmm1, 4(%rsp)                  # 4-byte Spill
	movq	%r15, %rdi
	callq	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	addss	%xmm0, %xmm0
	addss	.LCPI10_0(%rip), %xmm0
	movss	4(%rsp), %xmm1                  # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm1
	movaps	%xmm0, %xmm2
	mulss	%xmm0, %xmm2
	addss	%xmm1, %xmm2
	ucomiss	.LCPI10_1(%rip), %xmm2
	ja	.LBB10_2
# %bb.3:                                # %.preheader
                                        #   in Loop: Header=BB10_2 Depth=1
	ucomiss	.LCPI10_3(%rip), %xmm2
	jne	.LBB10_4
	jnp	.LBB10_2
.LBB10_4:
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movaps	%xmm2, %xmm0
	movss	%xmm2, 8(%rsp)                  # 4-byte Spill
	callq	logf
	mulss	.LCPI10_2(%rip), %xmm0
	divss	8(%rsp), %xmm0                  # 4-byte Folded Reload
	xorps	%xmm1, %xmm1
	ucomiss	%xmm1, %xmm0
	jb	.LBB10_6
# %bb.5:
	sqrtss	%xmm0, %xmm0
	jmp	.LBB10_7
.LBB10_6:                               # %call.sqrt
	callq	sqrtf
.LBB10_7:                               # %.split
	movss	4(%rsp), %xmm1                  # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	movss	%xmm1, 8(%r14)
	movb	$1, 12(%r14)
	movss	12(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
.LBB10_8:
	mulss	4(%rbx), %xmm1
	addss	(%rbx), %xmm1
	movaps	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE, .Lfunc_end10-_ZNSt19normal_distributionIfEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEfRT_RKNS0_10param_typeE
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
.LCPI11_0:
	.quad	0x41dfffffff800000              # double 2147483646
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI11_1:
	.long	0x40000000                      # float 2
.LCPI11_2:
	.long	0x5f000000                      # float 9.22337203E+18
.LCPI11_3:
	.long	0x3f800000                      # float 1
	.section	.text._ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_,"axG",@progbits,_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_,comdat
	.weak	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	.type	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_,@function
_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_: # @_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$64, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	fldl	.LCPI11_0(%rip)
	fstpt	(%rsp)
	callq	logl
	fstpt	52(%rsp)                        # 10-byte Folded Spill
	flds	.LCPI11_1(%rip)
	fstpt	(%rsp)
	callq	logl
	fldt	52(%rsp)                        # 10-byte Folded Reload
	fdivp	%st, %st(1)
	flds	.LCPI11_2(%rip)
	xorl	%ecx, %ecx
	fxch	%st(1)
	fucomi	%st(1), %st
	fldz
	fcmovnb	%st(2), %st
	fstp	%st(2)
	fsubp	%st, %st(1)
	setae	%cl
	fnstcw	28(%rsp)
	movzwl	28(%rsp), %eax
	orl	$3072, %eax                     # imm = 0xC00
	movw	%ax, 30(%rsp)
	fldcw	30(%rsp)
	fistpll	40(%rsp)
	fldcw	28(%rsp)
	shlq	$63, %rcx
	xorq	40(%rsp), %rcx
	leaq	23(%rcx), %rax
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %rcx
	cmpq	$1, %rax
	adcq	$0, %rcx
	movq	(%rbx), %rsi
	xorps	%xmm0, %xmm0
	movss	.LCPI11_3(%rip), %xmm1          # xmm1 = mem[0],zero,zero,zero
	movabsq	$8589934597, %rdi               # imm = 0x200000005
.LBB11_1:                               # %select.unfold
                                        # =>This Inner Loop Header: Depth=1
	imulq	$16807, %rsi, %rsi              # imm = 0x41A7
	movq	%rsi, %rax
	mulq	%rdi
	movq	%rsi, %rax
	subq	%rdx, %rax
	shrq	%rax
	addq	%rdx, %rax
	shrq	$30, %rax
	movq	%rax, %rdx
	shlq	$31, %rdx
	subq	%rdx, %rax
	leaq	(%rsi,%rax), %rdx
	decq	%rdx
	testq	%rdx, %rdx
	js	.LBB11_2
# %bb.3:                                # %select.unfold
                                        #   in Loop: Header=BB11_1 Depth=1
	xorps	%xmm2, %xmm2
	cvtsi2ss	%rdx, %xmm2
	jmp	.LBB11_4
.LBB11_2:                               #   in Loop: Header=BB11_1 Depth=1
	movq	%rdx, %r8
	shrq	%r8
	andl	$1, %edx
	orq	%r8, %rdx
	xorps	%xmm2, %xmm2
	cvtsi2ss	%rdx, %xmm2
	addss	%xmm2, %xmm2
.LBB11_4:                               # %select.unfold
                                        #   in Loop: Header=BB11_1 Depth=1
	addq	%rax, %rsi
	mulss	%xmm1, %xmm2
	movss	%xmm1, 36(%rsp)
	flds	36(%rsp)
	fmull	.LCPI11_0(%rip)
	addss	%xmm2, %xmm0
	fstps	32(%rsp)
	movss	32(%rsp), %xmm1                 # xmm1 = mem[0],zero,zero,zero
	decq	%rcx
	jne	.LBB11_1
# %bb.5:
	movq	%rsi, (%rbx)
	divss	%xmm1, %xmm0
	ucomiss	.LCPI11_3(%rip), %xmm0
	jae	.LBB11_7
# %bb.6:
	addq	$64, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB11_7:
	.cfi_def_cfa_offset 80
	movss	.LCPI11_3(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
	xorps	%xmm1, %xmm1
	addq	$64, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	nextafterf                      # TAILCALL
.Lfunc_end11:
	.size	_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_, .Lfunc_end11-_ZSt18generate_canonicalIfLm24ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB12_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB12_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z20update_dense_weightsPfS_, %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_end12:
	.size	__hip_module_ctor, .Lfunc_end12-__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	.LBB13_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
.LBB13_2:
	retq
.Lfunc_end13:
	.size	__hip_module_dtor, .Lfunc_end13-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z20update_dense_weightsPfS_,@object # @_Z20update_dense_weightsPfS_
	.section	.rodata,"a",@progbits
	.globl	_Z20update_dense_weightsPfS_
	.p2align	3, 0x0
_Z20update_dense_weightsPfS_:
	.quad	_Z35__device_stub__update_dense_weightsPfS_
	.size	_Z20update_dense_weightsPfS_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Wrong number of inputs. Usage: ./parallelNN <images> <labels>"
	.size	.L.str, 62

	.type	_ZZ4mainE15training_images,@object # @_ZZ4mainE15training_images
	.local	_ZZ4mainE15training_images
	.comm	_ZZ4mainE15training_images,8,8
	.type	_ZZ4mainE15training_labels,@object # @_ZZ4mainE15training_labels
	.local	_ZZ4mainE15training_labels
	.comm	_ZZ4mainE15training_labels,8,8
	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Epoch %d: Round %d: accuracy=%f\n"
	.size	.L.str.1, 33

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"basic_string: construction from null is not valid"
	.size	.L.str.2, 50

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z20update_dense_weightsPfS_"
	.size	.L__unnamed_1, 29

	.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

	.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 _Z35__device_stub__update_dense_weightsPfS_
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z20update_dense_weightsPfS_
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _ZZ4mainE15training_images
	.addrsig_sym _ZZ4mainE15training_labels
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z20update_dense_weightsPfS_ ; -- Begin function _Z20update_dense_weightsPfS_
	.globl	_Z20update_dense_weightsPfS_
	.p2align	8
	.type	_Z20update_dense_weightsPfS_,@function
_Z20update_dense_weightsPfS_:           ; @_Z20update_dense_weightsPfS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_load_b32 v4, v[2:3], off
	global_load_b32 v5, v[0:1], off
	s_waitcnt vmcnt(0)
	v_dual_fmamk_f32 v4, v4, 0x80000000, v5 :: v_dual_mov_b32 v5, 0
	global_store_b32 v[0:1], v4, off
	global_store_b32 v[2:3], v5, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20update_dense_weightsPfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z20update_dense_weightsPfS_, .Lfunc_end0-_Z20update_dense_weightsPfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 148
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
