
/**
 * Copyright 1993-2012 NVIDIA Corporation.  All rights reserved.
 *
 * Please refer to the NVIDIA end user license agreement (EULA) associated
 * with this source code for terms and conditions that govern your use of
 * this software. Any use, reproduction, disclosure, or distribution of
 * this software and related documentation outside the terms of the EULA
 * is strictly prohibited.
 */
#include <stdio.h>
#include <stdlib.h>
#include <tiffio.h>
#include <math.h>
#include <iostream>
#include <string.h>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <algorithm>
#include <time.h>
#include <chrono>
#include <queue>
#include <set>
#include <cuda.h>

static const int WORK_SIZE = 256;
const int AGP = 14, PAS = 15, AGR = 18, CAP = 19, CSP = 20, MAP = 21;

#define CHECK_CUDA_RESULT(N) {											\
	CUresult result = N;												\
	if (result != 0) {													\
		printf("CUDA call on line %d returned error %d\n", __LINE__,	\
			result);													\
		exit(1);														\
	} }

void setup(TIFF* new_tif, int width, int length, int bitsPerSample, int sampleFormat){

    TIFFSetField(new_tif, TIFFTAG_IMAGEWIDTH     , width);
    TIFFSetField(new_tif, TIFFTAG_IMAGELENGTH    , length);
    TIFFSetField(new_tif, TIFFTAG_BITSPERSAMPLE  , bitsPerSample);
    TIFFSetField(new_tif, TIFFTAG_SAMPLEFORMAT   , sampleFormat);
    TIFFSetField(new_tif, TIFFTAG_COMPRESSION    , 1);
    TIFFSetField(new_tif, TIFFTAG_PHOTOMETRIC    , 1);
    TIFFSetField(new_tif, TIFFTAG_SAMPLESPERPIXEL, 1);
    TIFFSetField(new_tif, TIFFTAG_ROWSPERSTRIP   , 1);
    TIFFSetField(new_tif, TIFFTAG_RESOLUTIONUNIT , 1);
    TIFFSetField(new_tif, TIFFTAG_XRESOLUTION    , 1);
    TIFFSetField(new_tif, TIFFTAG_YRESOLUTION    , 1);
    TIFFSetField(new_tif, TIFFTAG_PLANARCONFIG   , PLANARCONFIG_CONTIG);

};

void write_line_tiff(TIFF* tif, double tif_line[], int line){

    if (TIFFWriteScanline(tif, tif_line, line) < 0){
        std::cerr << "Write problem!" << std::endl;
        exit(4);
    }

};

void write_line_tiff(TIFF* tif, int tif_line[], int line){

    if (TIFFWriteScanline(tif, tif_line, line) < 0){
        std::cerr << "Write problem!" << std::endl;
        exit(4);
    }

};

void read_line_tiff(TIFF* tif, double tif_line[], int line){
    if(TIFFReadScanline(tif, tif_line, line) < 0){
        std::cerr << "Read problem" << std::endl;
        exit(3);
    }
};

void read_line_tiff(TIFF* tif, int tif_line[], int line){
    if(TIFFReadScanline(tif, tif_line, line) < 0){
        std::cerr << "Read problem" << std::endl;
        exit(3);
    }
};

__host__ __device__ bool checkLandCode(int value){

    return (value == AGP) || (value == PAS) || (value == AGR) || (value == CAP) || (value == CSP) || (value == MAP);

}

__global__ void landCoverHomogeneity(double* inputBuffer, int* output, int line, int numCol, int numLine){

	int column = threadIdx.x + blockIdx.x * blockDim.x;
	double pixel_value;
	int aux;

	while (column < numCol) {

		aux = line % 7;

		pixel_value = inputBuffer[aux * numCol + column];

		output[column] = false;

		if(checkLandCode(pixel_value)) { //Verify if the pixel is an AGR pixel

			output[column] = true;

			for(int i = -3; i <= 3 && output[column]; i++){

				for(int j = -3; j <= 3 && output[column]; j++){

					// Check if the neighbor is AGR too

					if (column + i >= 0 && column + i < numCol && line + j >= 0 && line + j < numLine) {

						aux = (line + j) % 7;

						pixel_value = inputBuffer[aux * numCol + column];

						if(!isnan(pixel_value))
							if(!checkLandCode(pixel_value))
								output[column] = false;

					}

				}

			}

		}

		column += blockDim.x * gridDim.x;

	}

}

void testLandCoverHomogeneity(TIFF* landCover, TIFF* mask){

    uint32 height_band, width_band;
    TIFFGetField(landCover, TIFFTAG_IMAGELENGTH, &height_band);
    TIFFGetField(landCover, TIFFTAG_IMAGEWIDTH, &width_band);

    double* buffer = (double *) malloc(7 * width_band * sizeof(double));

    int relation[7] = {-1, -1, -1, -1, -1, -1, -1}, aux;

    for(int line = 0; line < height_band; line++) {

        // Create the respective line of the binary map of eligibles pixels
        int mask_line[width_band];

        for(int column = 0; column < width_band; column++) {

            int pixel_value;

            aux = line % 7;

            if(relation[aux] != line) {

                read_line_tiff(landCover, buffer + aux * width_band, line);
                relation[aux] = line;

            }

            pixel_value = buffer[aux * width_band + column];

            mask_line[column] = false;

            if(checkLandCode(pixel_value)) { //Verify if the pixel is an AGR pixel

                mask_line[column] = true;

                for(int i = -3; i <= 3 && mask_line[column]; i++){

                    for(int j = -3; j <= 3 && mask_line[column]; j++){

                        // Check if the neighbor is AGR too

                        if (column + i >= 0 && column + i < width_band && line + j >= 0 && line + j < height_band) {

                            aux = (line + j) % 7;

                            if(relation[aux] != (line + j)) {

                                read_line_tiff(landCover, buffer + aux * width_band, line + j);
                                relation[aux] = (line + j);

                            }

                            pixel_value = buffer[aux * width_band + column];

                            if(!std::isnan(pixel_value))
                                if(!checkLandCode(pixel_value))
                                    mask_line[column] = false;

                        }

                    }

                }

            }

        }

        write_line_tiff(mask, mask_line, line);

    }

//    for(int i = 0; i < 7; i++){
//        free(buffer[i]);
//    }
    free(buffer);

}

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

	std::string landCoverPath = argv[1];
	std::string outputPath = argv[2];

	std::string outputCPU = outputPath + "/CPU.tif";
	std::string outputGPU = outputPath + "/GPU.tif";

	TIFF* landCover = TIFFOpen(landCoverPath.c_str(), "rm");

	uint32 height_band, width_band;

	TIFFGetField(landCover, TIFFTAG_IMAGEWIDTH, &width_band);
	TIFFGetField(landCover, TIFFTAG_IMAGELENGTH, &height_band);

	TIFF* CPU = TIFFOpen(outputCPU.c_str(), "w8m");
	setup(CPU, width_band, height_band, 32, 2);

	testLandCoverHomogeneity(landCover, CPU);

	TIFFClose(CPU);

	TIFF* GPU = TIFFOpen(outputGPU.c_str(), "w8m");
	setup(GPU, width_band, height_band, 32, 2);

	double* buffer = (double *) malloc(7 * width_band * sizeof(double));
	int* output_line = (int*) malloc(width_band * sizeof(int));

	double* buffer_dev;
	cudaMalloc((void**) &buffer_dev, 7 * width_band * sizeof(double*));

	int* output_dev;
	cudaMalloc((void**) &output_dev, width_band * sizeof(int*));

	int relation[7] = {-1, -1, -1, -1, -1, -1, -1};

	for(int line = 0; line < height_band; line++) {

		for(int i = -3; i < 4; i++) {

			if(line + i >= 0 && line + i < height_band){

				if(relation[(line + i) % 7] != (line + i)) {
					read_line_tiff(landCover, buffer + ((line + i) % 7) * width_band, line + i);
					relation[(line + i) % 7] = line + i;
				}

			}

		}

		cudaMemcpy(buffer_dev, buffer, 7 * width_band * sizeof(double), cudaMemcpyHostToDevice);

		landCoverHomogeneity<<< (width_band + 1) / WORK_SIZE , WORK_SIZE>>>(buffer_dev, output_dev, line, width_band, height_band);

		cudaMemcpy(output_line, output_dev, width_band * sizeof(int), cudaMemcpyDeviceToHost);

		write_line_tiff(GPU, output_line, line);

	}

	free(buffer);
	free(output_line);
	cudaFree(buffer_dev);
	cudaFree(output_dev);

	TIFFClose(landCover);
	TIFFClose(GPU);

	return 0;
}

	.file	"tmpxft_00273dfd_00000000-6_homogeneity.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB5338:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE5338:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0.str1.1,"aMS",@progbits,1
.LC0:
	.string	"basic_string::append"
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0,"axG",@progbits,_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,comdat
	.align 2
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0:
.LFB6077:
	.cfi_startproc
	movabsq	$4611686018427387903, %rax
	subq	8(%rdi), %rax
	cmpq	%rdx, %rax
	jnb	.L3
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC0(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L3:
	.cfi_def_cfa_offset 8
	jmp	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@PLT
	.cfi_endproc
.LFE6077:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0
	.text
	.globl	_Z5setupP4tiffiiii
	.type	_Z5setupP4tiffiiii, @function
_Z5setupP4tiffiiii:
.LFB5328:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edx, %r13d
	movl	%esi, %edx
	movl	$256, %esi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%ecx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%r8d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdi, %rbx
	pushq	%rax
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	call	TIFFSetField@PLT
	movl	%r13d, %edx
	movq	%rbx, %rdi
	movl	$257, %esi
	xorl	%eax, %eax
	call	TIFFSetField@PLT
	movl	%r12d, %edx
	movq	%rbx, %rdi
	movl	$258, %esi
	xorl	%eax, %eax
	call	TIFFSetField@PLT
	movl	%ebp, %edx
	movq	%rbx, %rdi
	movl	$339, %esi
	xorl	%eax, %eax
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$259, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$262, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$277, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$278, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$296, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$282, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$283, %esi
	call	TIFFSetField@PLT
	popq	%rcx
	.cfi_def_cfa_offset 40
	movq	%rbx, %rdi
	movl	$1, %edx
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$284, %esi
	popq	%rbp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	TIFFSetField@PLT
	.cfi_endproc
.LFE5328:
	.size	_Z5setupP4tiffiiii, .-_Z5setupP4tiffiiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Write problem!"
	.text
	.globl	_Z15write_line_tiffP4tiffPdi
	.type	_Z15write_line_tiffP4tiffPdi, @function
_Z15write_line_tiffP4tiffPdi:
.LFB5329:
	.cfi_startproc
	endbr64
	pushq	%rcx
	.cfi_def_cfa_offset 16
	xorl	%ecx, %ecx
	call	TIFFWriteScanline@PLT
	testl	%eax, %eax
	jns	.L10
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$4, %edi
	call	exit@PLT
.L10:
	popq	%rax
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5329:
	.size	_Z15write_line_tiffP4tiffPdi, .-_Z15write_line_tiffP4tiffPdi
	.globl	_Z15write_line_tiffP4tiffPii
	.type	_Z15write_line_tiffP4tiffPii, @function
_Z15write_line_tiffP4tiffPii:
.LFB5330:
	.cfi_startproc
	endbr64
	pushq	%rcx
	.cfi_def_cfa_offset 16
	xorl	%ecx, %ecx
	call	TIFFWriteScanline@PLT
	testl	%eax, %eax
	jns	.L13
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$4, %edi
	call	exit@PLT
.L13:
	popq	%rax
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5330:
	.size	_Z15write_line_tiffP4tiffPii, .-_Z15write_line_tiffP4tiffPii
	.section	.rodata.str1.1
.LC2:
	.string	"Read problem"
	.text
	.globl	_Z14read_line_tiffP4tiffPdi
	.type	_Z14read_line_tiffP4tiffPdi, @function
_Z14read_line_tiffP4tiffPdi:
.LFB5331:
	.cfi_startproc
	endbr64
	pushq	%rcx
	.cfi_def_cfa_offset 16
	xorl	%ecx, %ecx
	call	TIFFReadScanline@PLT
	testl	%eax, %eax
	jns	.L16
	leaq	.LC2(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$3, %edi
	call	exit@PLT
.L16:
	popq	%rax
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5331:
	.size	_Z14read_line_tiffP4tiffPdi, .-_Z14read_line_tiffP4tiffPdi
	.globl	_Z14read_line_tiffP4tiffPii
	.type	_Z14read_line_tiffP4tiffPii, @function
_Z14read_line_tiffP4tiffPii:
.LFB5332:
	.cfi_startproc
	endbr64
	pushq	%rcx
	.cfi_def_cfa_offset 16
	xorl	%ecx, %ecx
	call	TIFFReadScanline@PLT
	testl	%eax, %eax
	jns	.L19
	leaq	.LC2(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$3, %edi
	call	exit@PLT
.L19:
	popq	%rax
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5332:
	.size	_Z14read_line_tiffP4tiffPii, .-_Z14read_line_tiffP4tiffPii
	.globl	_Z13checkLandCodei
	.type	_Z13checkLandCodei, @function
_Z13checkLandCodei:
.LFB5333:
	.cfi_startproc
	endbr64
	leal	-14(%rdi), %eax
	cmpl	$1, %eax
	setbe	%al
	subl	$18, %edi
	cmpl	$3, %edi
	setbe	%dl
	orl	%edx, %eax
	ret
	.cfi_endproc
.LFE5333:
	.size	_Z13checkLandCodei, .-_Z13checkLandCodei
	.globl	_Z24testLandCoverHomogeneityP4tiffS0_
	.type	_Z24testLandCoverHomogeneityP4tiffS0_, @function
_Z24testLandCoverHomogeneityP4tiffS0_:
.LFB5334:
	.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
	leaq	-92(%rbp), %rdx
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$120, %rsp
	movq	%rdi, -104(%rbp)
	movq	%rsi, -136(%rbp)
	movl	$257, %esi
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	TIFFGetField@PLT
	movq	-104(%rbp), %rdi
	leaq	-88(%rbp), %rdx
	xorl	%eax, %eax
	movl	$256, %esi
	call	TIFFGetField@PLT
	imull	$7, -88(%rbp), %edi
	salq	$3, %rdi
	call	malloc@PLT
	movq	$-1, -84(%rbp)
	movq	$-1, -76(%rbp)
	movq	%rax, %r12
	movq	$-1, -68(%rbp)
	movl	$-1, -60(%rbp)
.L24:
	cmpl	-92(%rbp), %ebx
	jnb	.L50
	movl	-88(%rbp), %eax
	movq	%rsp, -128(%rbp)
	movq	%rsp, %rdx
	leaq	15(,%rax,4), %rax
	shrq	$4, %rax
	salq	$4, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	subq	%rcx, %rdx
.L25:
	cmpq	%rdx, %rsp
	je	.L26
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L25
.L26:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L27
	orq	$0, -8(%rsp,%rax)
.L27:
	movl	%ebx, %eax
	movl	$7, %ecx
	movq	%rsp, %r13
	xorl	%r15d, %r15d
	cltd
	idivl	%ecx
	movslq	%edx, %rax
	movl	%edx, -108(%rbp)
	movq	%rax, -120(%rbp)
.L28:
	movl	-88(%rbp), %eax
	movl	%r15d, %r14d
	cmpl	%eax, %r15d
	jnb	.L51
	movq	-120(%rbp), %rsi
	cmpl	%ebx, -84(%rbp,%rsi,4)
	je	.L29
	movl	-108(%rbp), %ecx
	movq	-104(%rbp), %rdi
	movl	%ebx, %edx
	imull	%ecx, %eax
	leaq	(%r12,%rax,8), %rsi
	call	_Z14read_line_tiffP4tiffPdi
	movq	-120(%rbp), %rax
	movl	%ebx, -84(%rbp,%rax,4)
.L29:
	movl	-108(%rbp), %eax
	imull	-88(%rbp), %eax
	addl	%r14d, %eax
	movl	%eax, %eax
	cvttsd2sil	(%r12,%rax,8), %edi
	call	_Z13checkLandCodei
	testb	%al, %al
	jne	.L30
	xorl	%edx, %edx
	movl	%edx, 0(%r13,%r15,4)
.L37:
	incq	%r15
	jmp	.L28
.L30:
	movl	$1, 0(%r13,%r15,4)
	leal	4(%rbx), %eax
	leal	-3(%r14), %r9d
	movl	%eax, -112(%rbp)
.L31:
	cmpl	$0, 0(%r13,%r15,4)
	je	.L37
	leal	-3(%rbx), %ecx
.L36:
	cmpl	$0, 0(%r13,%r15,4)
	movl	-88(%rbp), %esi
	je	.L39
	testl	%r9d, %r9d
	js	.L33
	cmpl	%esi, %r9d
	jnb	.L33
	testl	%ecx, %ecx
	js	.L33
	cmpl	-92(%rbp), %ecx
	jnb	.L33
	movl	%ecx, %eax
	movl	$7, %edi
	cltd
	idivl	%edi
	movslq	%edx, %rax
	cmpl	-84(%rbp,%rax,4), %ecx
	movq	%rax, -160(%rbp)
	movq	%rax, %r10
	je	.L35
	imull	%eax, %esi
	movq	-104(%rbp), %rdi
	movl	%ecx, %edx
	movl	%r9d, -148(%rbp)
	movl	%eax, -144(%rbp)
	movl	%ecx, -140(%rbp)
	leaq	(%r12,%rsi,8), %rsi
	call	_Z14read_line_tiffP4tiffPdi
	movl	-140(%rbp), %ecx
	movq	-160(%rbp), %rax
	movl	-148(%rbp), %r9d
	movl	-144(%rbp), %r10d
	movl	%ecx, -84(%rbp,%rax,4)
.L35:
	imull	-88(%rbp), %r10d
	leal	(%r10,%r14), %eax
	cvttsd2sil	(%r12,%rax,8), %edi
	call	_Z13checkLandCodei
	testb	%al, %al
	jne	.L33
	xorl	%eax, %eax
	movl	%eax, 0(%r13,%r15,4)
.L33:
	incl	%ecx
	cmpl	%ecx, -112(%rbp)
	jne	.L36
.L39:
	incl	%r9d
	leal	4(%r14), %eax
	cmpl	%r9d, %eax
	jne	.L31
	jmp	.L37
.L51:
	movq	-136(%rbp), %rdi
	movl	%ebx, %edx
	movq	%r13, %rsi
	incl	%ebx
	call	_Z15write_line_tiffP4tiffPii
	movq	-128(%rbp), %rsp
	jmp	.L24
.L50:
	movq	%r12, %rdi
	call	free@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE5334:
	.size	_Z24testLandCoverHomogeneityP4tiffS0_, .-_Z24testLandCoverHomogeneityP4tiffS0_
	.globl	_Z45__device_stub__Z20landCoverHomogeneityPdPiiiiPdPiiii
	.type	_Z45__device_stub__Z20landCoverHomogeneityPdPiiiiPdPiiii, @function
_Z45__device_stub__Z20landCoverHomogeneityPdPiiiiPdPiiii:
.LFB5360:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movl	%r8d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L52
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z20landCoverHomogeneityPdPiiii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L52:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5360:
	.size	_Z45__device_stub__Z20landCoverHomogeneityPdPiiiiPdPiiii, .-_Z45__device_stub__Z20landCoverHomogeneityPdPiiiiPdPiiii
	.globl	_Z20landCoverHomogeneityPdPiiii
	.type	_Z20landCoverHomogeneityPdPiiii, @function
_Z20landCoverHomogeneityPdPiiii:
.LFB5361:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z20landCoverHomogeneityPdPiiiiPdPiiii
	.cfi_endproc
.LFE5361:
	.size	_Z20landCoverHomogeneityPdPiiii, .-_Z20landCoverHomogeneityPdPiiii
	.section	.rodata.str1.1
.LC3:
	.string	"_Z20landCoverHomogeneityPdPiiii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB5363:
	.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	.LC3(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z20landCoverHomogeneityPdPiiii(%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
.LFE5363:
	.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
.LC4:
	.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_:
.LFB5712:
	.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	.L60
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L65
	leaq	.LC4(%rip), %rdi
	call	_ZSt19__throw_logic_errorPKc@PLT
.L60:
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	movq	%rsi, %rbp
	call	strlen@PLT
	movq	%rax, (%rsp)
	leaq	0(%rbp,%rax), %r12
	cmpq	$15, %rax
	jbe	.L62
	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)
.L62:
	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	.L63
.L65:
	call	__stack_chk_fail@PLT
.L63:
	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
.LFE5712:
	.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._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,"axG",@progbits,_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,comdat
	.weak	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
	.type	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_, @function
_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_:
.LFB5714:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA5714
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdi, %rbx
	movq	%rdx, %rdi
	call	strlen@PLT
	movq	8(%r13), %r14
	movq	0(%r13), %r13
	movq	%rbx, %rdi
	movq	%rax, %r12
	leaq	16(%rbx), %rax
	movb	$0, 16(%rbx)
	movq	%rax, (%rbx)
	xorl	%eax, %eax
	leaq	(%r12,%r14), %rsi
	movq	%rax, 8(%rbx)
.LEHB0:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm@PLT
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0
.LEHE0:
	movq	%rbx, %rax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L69:
	.cfi_restore_state
	endbr64
	movq	%rax, %rbp
.L68:
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%rbp, %rdi
.LEHB1:
	call	_Unwind_Resume@PLT
.LEHE1:
	.cfi_endproc
.LFE5714:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,"aG",@progbits,_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,comdat
.LLSDA5714:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE5714-.LLSDACSB5714
.LLSDACSB5714:
	.uleb128 .LEHB0-.LFB5714
	.uleb128 .LEHE0-.LEHB0
	.uleb128 .L69-.LFB5714
	.uleb128 0
	.uleb128 .LEHB1-.LFB5714
	.uleb128 .LEHE1-.LEHB1
	.uleb128 0
	.uleb128 0
.LLSDACSE5714:
	.section	.text._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,"axG",@progbits,_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,comdat
	.size	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_, .-_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
	.section	.rodata.str1.1
.LC5:
	.string	"/CPU.tif"
.LC6:
	.string	"/GPU.tif"
.LC7:
	.string	"rm"
.LC8:
	.string	"w8m"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB5335:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA5335
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$296, %rsp
	.cfi_def_cfa_offset 352
	movq	8(%rsi), %rsi
	movq	%fs:40, %rax
	movq	%rax, 280(%rsp)
	xorl	%eax, %eax
	leaq	112(%rsp), %rbp
	leaq	152(%rsp), %rax
	movq	%rax, %rdi
	movq	%rbp, %rdx
	movq	%rax, 40(%rsp)
.LEHB2:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE2:
	leaq	184(%rsp), %rax
	movq	16(%rbx), %rsi
	movq	%rbp, %rdx
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
.LEHB3:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE3:
	leaq	216(%rsp), %rax
	movq	16(%rsp), %rsi
	leaq	.LC5(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, 48(%rsp)
.LEHB4:
	call	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
.LEHE4:
	leaq	248(%rsp), %rax
	movq	16(%rsp), %rsi
	leaq	.LC6(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, 56(%rsp)
.LEHB5:
	call	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
.LEHE5:
	movq	152(%rsp), %rdi
	leaq	.LC7(%rip), %rsi
.LEHB6:
	call	TIFFOpen@PLT
	movq	%rax, 8(%rsp)
	movq	%rax, %rdi
	leaq	76(%rsp), %rdx
	xorl	%eax, %eax
	movl	$256, %esi
	call	TIFFGetField@PLT
	movq	8(%rsp), %rdi
	leaq	72(%rsp), %rdx
	movl	$257, %esi
	xorl	%eax, %eax
	call	TIFFGetField@PLT
	leaq	.LC8(%rip), %rbp
	movq	216(%rsp), %rdi
	movq	%rbp, %rsi
	call	TIFFOpen@PLT
	movl	72(%rsp), %edx
	movl	76(%rsp), %esi
	movl	$32, %ecx
	movq	%rax, %rdi
	movl	$2, %r8d
	movq	%rax, %rbx
	call	_Z5setupP4tiffiiii
	movq	8(%rsp), %rdi
	movq	%rbx, %rsi
	call	_Z24testLandCoverHomogeneityP4tiffS0_
	movq	%rbx, %rdi
	call	TIFFClose@PLT
	movq	248(%rsp), %rdi
	movq	%rbp, %rsi
	call	TIFFOpen@PLT
	movl	72(%rsp), %edx
	movl	76(%rsp), %esi
	movl	$32, %ecx
	movq	%rax, %rdi
	movl	$2, %r8d
	movq	%rax, 24(%rsp)
	call	_Z5setupP4tiffiiii
	movl	76(%rsp), %ebp
	imull	$7, %ebp, %ebx
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movl	%ebp, %edi
	salq	$2, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	leaq	80(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rax, 32(%rsp)
	call	cudaMalloc@PLT
	movl	76(%rsp), %esi
	leaq	88(%rsp), %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movq	$-1, 124(%rsp)
	xorl	%ebp, %ebp
	movabsq	$4294967552, %r13
	movq	$-1, 132(%rsp)
	movq	$-1, 140(%rsp)
	movl	$-1, 148(%rsp)
.L73:
	cmpl	72(%rsp), %ebp
	jnb	.L91
	leal	-3(%rbp), %ebx
	movl	$7, %r14d
.L75:
	movl	76(%rsp), %ecx
	testl	%ebx, %ebx
	js	.L74
	cmpl	72(%rsp), %ebx
	jnb	.L74
	movl	%ebx, %eax
	cltd
	idivl	%r14d
	movslq	%edx, %r15
	cmpl	124(%rsp,%r15,4), %ebx
	je	.L74
	imull	%ecx, %edx
	movq	8(%rsp), %rdi
	leaq	(%r12,%rdx,8), %rsi
	movl	%ebx, %edx
	call	_Z14read_line_tiffP4tiffPdi
	movl	%ebx, 124(%rsp,%r15,4)
.L74:
	incl	%ebx
	leal	4(%rbp), %eax
	cmpl	%eax, %ebx
	jne	.L75
	imull	$7, 76(%rsp), %edx
	movq	80(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movl	76(%rsp), %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r13, %rdx
	movl	$1, %ecx
	movq	%r13, 112(%rsp)
	incl	%eax
	movl	$1, 120(%rsp)
	shrl	$8, %eax
	movl	%eax, 100(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 104(%rsp)
	movq	100(%rsp), %rdi
	movl	108(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	movl	76(%rsp), %ecx
	movq	88(%rsp), %rsi
	testl	%eax, %eax
	jne	.L76
	movl	72(%rsp), %r8d
	movq	80(%rsp), %rdi
	movl	%ebp, %edx
	call	_Z45__device_stub__Z20landCoverHomogeneityPdPiiiiPdPiiii
.L76:
	movl	76(%rsp), %edx
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	32(%rsp), %rdi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	movl	%ebp, %edx
	call	_Z15write_line_tiffP4tiffPii
	incl	%ebp
	jmp	.L73
.L91:
	movq	%r12, %rdi
	call	free@PLT
	movq	32(%rsp), %rdi
	call	free@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	TIFFClose@PLT
	movq	24(%rsp), %rdi
	call	TIFFClose@PLT
.LEHE6:
	movq	56(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	48(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	16(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	40(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	280(%rsp), %rax
	subq	%fs:40, %rax
	je	.L83
	jmp	.L89
.L87:
	endbr64
	movq	%rax, %rbx
.L78:
	movq	56(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L79
.L86:
	endbr64
	movq	%rax, %rbx
.L79:
	movq	48(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L80
.L85:
	endbr64
	movq	%rax, %rbx
.L80:
	movq	16(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L81
.L84:
	endbr64
	movq	%rax, %rbx
.L81:
	movq	40(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	280(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L89
	movq	%rbx, %rdi
.LEHB7:
	call	_Unwind_Resume@PLT
.LEHE7:
.L89:
	call	__stack_chk_fail@PLT
.L83:
	addq	$296, %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
.LFE5335:
	.section	.gcc_except_table,"a",@progbits
.LLSDA5335:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE5335-.LLSDACSB5335
.LLSDACSB5335:
	.uleb128 .LEHB2-.LFB5335
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB3-.LFB5335
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L84-.LFB5335
	.uleb128 0
	.uleb128 .LEHB4-.LFB5335
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L85-.LFB5335
	.uleb128 0
	.uleb128 .LEHB5-.LFB5335
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L86-.LFB5335
	.uleb128 0
	.uleb128 .LEHB6-.LFB5335
	.uleb128 .LEHE6-.LEHB6
	.uleb128 .L87-.LFB5335
	.uleb128 0
	.uleb128 .LEHB7-.LFB5335
	.uleb128 .LEHE7-.LEHB7
	.uleb128 0
	.uleb128 0
.LLSDACSE5335:
	.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
	.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:


/**
 * Copyright 1993-2012 NVIDIA Corporation.  All rights reserved.
 *
 * Please refer to the NVIDIA end user license agreement (EULA) associated
 * with this source code for terms and conditions that govern your use of
 * this software. Any use, reproduction, disclosure, or distribution of
 * this software and related documentation outside the terms of the EULA
 * is strictly prohibited.
 */
#include <stdio.h>
#include <stdlib.h>
#include <tiffio.h>
#include <math.h>
#include <iostream>
#include <string.h>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <algorithm>
#include <time.h>
#include <chrono>
#include <queue>
#include <set>
#include <hip/hip_runtime.h>

static const int WORK_SIZE = 256;
const int AGP = 14, PAS = 15, AGR = 18, CAP = 19, CSP = 20, MAP = 21;

#define CHECK_CUDA_RESULT(N) {											\
	hipError_t result = N;												\
	if (result != 0) {													\
		printf("CUDA call on line %d returned error %d\n", __LINE__,	\
			result);													\
		exit(1);														\
	} }

void setup(TIFF* new_tif, int width, int length, int bitsPerSample, int sampleFormat){

    TIFFSetField(new_tif, TIFFTAG_IMAGEWIDTH     , width);
    TIFFSetField(new_tif, TIFFTAG_IMAGELENGTH    , length);
    TIFFSetField(new_tif, TIFFTAG_BITSPERSAMPLE  , bitsPerSample);
    TIFFSetField(new_tif, TIFFTAG_SAMPLEFORMAT   , sampleFormat);
    TIFFSetField(new_tif, TIFFTAG_COMPRESSION    , 1);
    TIFFSetField(new_tif, TIFFTAG_PHOTOMETRIC    , 1);
    TIFFSetField(new_tif, TIFFTAG_SAMPLESPERPIXEL, 1);
    TIFFSetField(new_tif, TIFFTAG_ROWSPERSTRIP   , 1);
    TIFFSetField(new_tif, TIFFTAG_RESOLUTIONUNIT , 1);
    TIFFSetField(new_tif, TIFFTAG_XRESOLUTION    , 1);
    TIFFSetField(new_tif, TIFFTAG_YRESOLUTION    , 1);
    TIFFSetField(new_tif, TIFFTAG_PLANARCONFIG   , PLANARCONFIG_CONTIG);

};

void write_line_tiff(TIFF* tif, double tif_line[], int line){

    if (TIFFWriteScanline(tif, tif_line, line) < 0){
        std::cerr << "Write problem!" << std::endl;
        exit(4);
    }

};

void write_line_tiff(TIFF* tif, int tif_line[], int line){

    if (TIFFWriteScanline(tif, tif_line, line) < 0){
        std::cerr << "Write problem!" << std::endl;
        exit(4);
    }

};

void read_line_tiff(TIFF* tif, double tif_line[], int line){
    if(TIFFReadScanline(tif, tif_line, line) < 0){
        std::cerr << "Read problem" << std::endl;
        exit(3);
    }
};

void read_line_tiff(TIFF* tif, int tif_line[], int line){
    if(TIFFReadScanline(tif, tif_line, line) < 0){
        std::cerr << "Read problem" << std::endl;
        exit(3);
    }
};

__host__ __device__ bool checkLandCode(int value){

    return (value == AGP) || (value == PAS) || (value == AGR) || (value == CAP) || (value == CSP) || (value == MAP);

}

__global__ void landCoverHomogeneity(double* inputBuffer, int* output, int line, int numCol, int numLine){

	int column = threadIdx.x + blockIdx.x * blockDim.x;
	double pixel_value;
	int aux;

	while (column < numCol) {

		aux = line % 7;

		pixel_value = inputBuffer[aux * numCol + column];

		output[column] = false;

		if(checkLandCode(pixel_value)) { //Verify if the pixel is an AGR pixel

			output[column] = true;

			for(int i = -3; i <= 3 && output[column]; i++){

				for(int j = -3; j <= 3 && output[column]; j++){

					// Check if the neighbor is AGR too

					if (column + i >= 0 && column + i < numCol && line + j >= 0 && line + j < numLine) {

						aux = (line + j) % 7;

						pixel_value = inputBuffer[aux * numCol + column];

						if(!isnan(pixel_value))
							if(!checkLandCode(pixel_value))
								output[column] = false;

					}

				}

			}

		}

		column += blockDim.x * gridDim.x;

	}

}

void testLandCoverHomogeneity(TIFF* landCover, TIFF* mask){

    uint32 height_band, width_band;
    TIFFGetField(landCover, TIFFTAG_IMAGELENGTH, &height_band);
    TIFFGetField(landCover, TIFFTAG_IMAGEWIDTH, &width_band);

    double* buffer = (double *) malloc(7 * width_band * sizeof(double));

    int relation[7] = {-1, -1, -1, -1, -1, -1, -1}, aux;

    for(int line = 0; line < height_band; line++) {

        // Create the respective line of the binary map of eligibles pixels
        int mask_line[width_band];

        for(int column = 0; column < width_band; column++) {

            int pixel_value;

            aux = line % 7;

            if(relation[aux] != line) {

                read_line_tiff(landCover, buffer + aux * width_band, line);
                relation[aux] = line;

            }

            pixel_value = buffer[aux * width_band + column];

            mask_line[column] = false;

            if(checkLandCode(pixel_value)) { //Verify if the pixel is an AGR pixel

                mask_line[column] = true;

                for(int i = -3; i <= 3 && mask_line[column]; i++){

                    for(int j = -3; j <= 3 && mask_line[column]; j++){

                        // Check if the neighbor is AGR too

                        if (column + i >= 0 && column + i < width_band && line + j >= 0 && line + j < height_band) {

                            aux = (line + j) % 7;

                            if(relation[aux] != (line + j)) {

                                read_line_tiff(landCover, buffer + aux * width_band, line + j);
                                relation[aux] = (line + j);

                            }

                            pixel_value = buffer[aux * width_band + column];

                            if(!std::isnan(pixel_value))
                                if(!checkLandCode(pixel_value))
                                    mask_line[column] = false;

                        }

                    }

                }

            }

        }

        write_line_tiff(mask, mask_line, line);

    }

//    for(int i = 0; i < 7; i++){
//        free(buffer[i]);
//    }
    free(buffer);

}

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

	std::string landCoverPath = argv[1];
	std::string outputPath = argv[2];

	std::string outputCPU = outputPath + "/CPU.tif";
	std::string outputGPU = outputPath + "/GPU.tif";

	TIFF* landCover = TIFFOpen(landCoverPath.c_str(), "rm");

	uint32 height_band, width_band;

	TIFFGetField(landCover, TIFFTAG_IMAGEWIDTH, &width_band);
	TIFFGetField(landCover, TIFFTAG_IMAGELENGTH, &height_band);

	TIFF* CPU = TIFFOpen(outputCPU.c_str(), "w8m");
	setup(CPU, width_band, height_band, 32, 2);

	testLandCoverHomogeneity(landCover, CPU);

	TIFFClose(CPU);

	TIFF* GPU = TIFFOpen(outputGPU.c_str(), "w8m");
	setup(GPU, width_band, height_band, 32, 2);

	double* buffer = (double *) malloc(7 * width_band * sizeof(double));
	int* output_line = (int*) malloc(width_band * sizeof(int));

	double* buffer_dev;
	hipMalloc((void**) &buffer_dev, 7 * width_band * sizeof(double*));

	int* output_dev;
	hipMalloc((void**) &output_dev, width_band * sizeof(int*));

	int relation[7] = {-1, -1, -1, -1, -1, -1, -1};

	for(int line = 0; line < height_band; line++) {

		for(int i = -3; i < 4; i++) {

			if(line + i >= 0 && line + i < height_band){

				if(relation[(line + i) % 7] != (line + i)) {
					read_line_tiff(landCover, buffer + ((line + i) % 7) * width_band, line + i);
					relation[(line + i) % 7] = line + i;
				}

			}

		}

		hipMemcpy(buffer_dev, buffer, 7 * width_band * sizeof(double), hipMemcpyHostToDevice);

		landCoverHomogeneity<<< (width_band + 1) / WORK_SIZE , WORK_SIZE>>>(buffer_dev, output_dev, line, width_band, height_band);

		hipMemcpy(output_line, output_dev, width_band * sizeof(int), hipMemcpyDeviceToHost);

		write_line_tiff(GPU, output_line, line);

	}

	free(buffer);
	free(output_line);
	hipFree(buffer_dev);
	hipFree(output_dev);

	TIFFClose(landCover);
	TIFFClose(GPU);

	return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z5setupP4tiffiiii              # -- Begin function _Z5setupP4tiffiiii
	.type	_Z5setupP4tiffiiii,@function
_Z5setupP4tiffiiii:                     # @_Z5setupP4tiffiiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r8d, %ebp
	movl	%ecx, %r14d
	movl	%edx, %r15d
	movl	%esi, %edx
	movq	%rdi, %rbx
	movl	$256, %esi                      # imm = 0x100
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$257, %esi                      # imm = 0x101
	movl	%r15d, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$258, %esi                      # imm = 0x102
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$339, %esi                      # imm = 0x153
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$259, %esi                      # imm = 0x103
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$262, %esi                      # imm = 0x106
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$277, %esi                      # imm = 0x115
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$278, %esi                      # imm = 0x116
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$296, %esi                      # imm = 0x128
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$282, %esi                      # imm = 0x11A
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$283, %esi                      # imm = 0x11B
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%rbx, %rdi
	movl	$284, %esi                      # imm = 0x11C
	movl	$1, %edx
	xorl	%eax, %eax
	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	TIFFSetField                    # TAILCALL
.Lfunc_end0:
	.size	_Z5setupP4tiffiiii, .Lfunc_end0-_Z5setupP4tiffiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z15write_line_tiffP4tiffPdi    # -- Begin function _Z15write_line_tiffP4tiffPdi
	.type	_Z15write_line_tiffP4tiffPdi,@function
_Z15write_line_tiffP4tiffPdi:           # @_Z15write_line_tiffP4tiffPdi
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%ecx, %ecx
	callq	TIFFWriteScanline
	testl	%eax, %eax
	js	.LBB1_2
# %bb.1:
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.LBB1_2:
	.cfi_def_cfa_offset 16
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$4, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z15write_line_tiffP4tiffPdi, .Lfunc_end1-_Z15write_line_tiffP4tiffPdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z15write_line_tiffP4tiffPii    # -- Begin function _Z15write_line_tiffP4tiffPii
	.type	_Z15write_line_tiffP4tiffPii,@function
_Z15write_line_tiffP4tiffPii:           # @_Z15write_line_tiffP4tiffPii
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%ecx, %ecx
	callq	TIFFWriteScanline
	testl	%eax, %eax
	js	.LBB2_2
# %bb.1:
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.LBB2_2:
	.cfi_def_cfa_offset 16
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$4, %edi
	callq	exit
.Lfunc_end2:
	.size	_Z15write_line_tiffP4tiffPii, .Lfunc_end2-_Z15write_line_tiffP4tiffPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z14read_line_tiffP4tiffPdi     # -- Begin function _Z14read_line_tiffP4tiffPdi
	.type	_Z14read_line_tiffP4tiffPdi,@function
_Z14read_line_tiffP4tiffPdi:            # @_Z14read_line_tiffP4tiffPdi
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%ecx, %ecx
	callq	TIFFReadScanline
	testl	%eax, %eax
	js	.LBB3_2
# %bb.1:
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.LBB3_2:
	.cfi_def_cfa_offset 16
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$3, %edi
	callq	exit
.Lfunc_end3:
	.size	_Z14read_line_tiffP4tiffPdi, .Lfunc_end3-_Z14read_line_tiffP4tiffPdi
	.cfi_endproc
                                        # -- End function
	.globl	_Z14read_line_tiffP4tiffPii     # -- Begin function _Z14read_line_tiffP4tiffPii
	.type	_Z14read_line_tiffP4tiffPii,@function
_Z14read_line_tiffP4tiffPii:            # @_Z14read_line_tiffP4tiffPii
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%ecx, %ecx
	callq	TIFFReadScanline
	testl	%eax, %eax
	js	.LBB4_2
# %bb.1:
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.LBB4_2:
	.cfi_def_cfa_offset 16
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$3, %edi
	callq	exit
.Lfunc_end4:
	.size	_Z14read_line_tiffP4tiffPii, .Lfunc_end4-_Z14read_line_tiffP4tiffPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z13checkLandCodei              # -- Begin function _Z13checkLandCodei
	.type	_Z13checkLandCodei,@function
_Z13checkLandCodei:                     # @_Z13checkLandCodei
	.cfi_startproc
# %bb.0:                                # %switch.edge
	cmpl	$22, %edi
	setb	%cl
	movl	$3981312, %eax                  # imm = 0x3CC000
	btl	%edi, %eax
	setb	%al
	andb	%cl, %al
	retq
.Lfunc_end5:
	.size	_Z13checkLandCodei, .Lfunc_end5-_Z13checkLandCodei
	.cfi_endproc
                                        # -- End function
	.globl	_Z35__device_stub__landCoverHomogeneityPdPiiii # -- Begin function _Z35__device_stub__landCoverHomogeneityPdPiiii
	.type	_Z35__device_stub__landCoverHomogeneityPdPiiii,@function
_Z35__device_stub__landCoverHomogeneityPdPiiii: # @_Z35__device_stub__landCoverHomogeneityPdPiiii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z20landCoverHomogeneityPdPiiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z35__device_stub__landCoverHomogeneityPdPiiii, .Lfunc_end6-_Z35__device_stub__landCoverHomogeneityPdPiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z24testLandCoverHomogeneityP4tiffS0_ # -- Begin function _Z24testLandCoverHomogeneityP4tiffS0_
	.type	_Z24testLandCoverHomogeneityP4tiffS0_,@function
_Z24testLandCoverHomogeneityP4tiffS0_:  # @_Z24testLandCoverHomogeneityP4tiffS0_
	.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	$120, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, -88(%rbp)                 # 8-byte Spill
	movq	%rdi, %r14
	xorl	%r15d, %r15d
	leaq	-52(%rbp), %rbx
	movl	$257, %esi                      # imm = 0x101
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	TIFFGetField
	leaq	-44(%rbp), %r12
	movq	%r14, -72(%rbp)                 # 8-byte Spill
	movq	%r14, %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	TIFFGetField
	movl	(%r12), %eax
	leal	(,%rax,8), %edi
	subl	%eax, %edi
	shlq	$3, %rdi
	callq	malloc
	movq	%rax, %rdi
	pcmpeqd	%xmm0, %xmm0
	movdqu	%xmm0, -148(%rbp)
	movdqa	%xmm0, -160(%rbp)
	cmpl	$0, (%rbx)
	je	.LBB7_10
# %bb.1:                                # %.lr.ph77.preheader
	movl	$-3, -48(%rbp)                  # 4-byte Folded Spill
	movq	%rdi, -64(%rbp)                 # 8-byte Spill
.LBB7_2:                                # %.lr.ph77
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_4 Depth 2
                                        #       Child Loop BB7_12 Depth 3
                                        #         Child Loop BB7_13 Depth 4
	movq	%rsp, -96(%rbp)                 # 8-byte Spill
	movl	-44(%rbp), %eax
	movq	%rsp, %rsi
	leaq	15(,%rax,4), %rax
	andq	$-16, %rax
	subq	%rax, %rsi
	movq	%rsi, %rsp
	movl	-44(%rbp), %eax
	testl	%eax, %eax
	je	.LBB7_9
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB7_2 Depth=1
	movl	%r15d, %ecx
	imulq	$613566757, %rcx, %rcx          # imm = 0x24924925
	shrq	$32, %rcx
	movl	%r15d, %ebx
	subl	%ecx, %ebx
	shrl	%ebx
	addl	%ecx, %ebx
	shrl	$2, %ebx
	leal	(,%rbx,8), %ecx
	subl	%ecx, %ebx
	addl	%r15d, %ebx
	xorl	%r14d, %r14d
	movq	%r15, -112(%rbp)                # 8-byte Spill
	movq	%rsi, -80(%rbp)                 # 8-byte Spill
	movq	%rbx, -104(%rbp)                # 8-byte Spill
.LBB7_4:                                #   Parent Loop BB7_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB7_12 Depth 3
                                        #         Child Loop BB7_13 Depth 4
	cmpl	%r15d, -160(%rbp,%rbx,4)
	je	.LBB7_6
# %bb.5:                                #   in Loop: Header=BB7_4 Depth=2
	imull	%ebx, %eax
	leaq	(%rdi,%rax,8), %rsi
	movq	-72(%rbp), %rdi                 # 8-byte Reload
	movl	%r15d, %edx
	callq	_Z14read_line_tiffP4tiffPdi
	movq	-80(%rbp), %rsi                 # 8-byte Reload
	movq	-64(%rbp), %rdi                 # 8-byte Reload
	movl	%r15d, -160(%rbp,%rbx,4)
	movl	-44(%rbp), %eax
.LBB7_6:                                #   in Loop: Header=BB7_4 Depth=2
	movl	%eax, %ecx
	imull	%ebx, %ecx
	addl	%r14d, %ecx
	cvttsd2si	(%rdi,%rcx,8), %ecx
	movl	$0, (%rsi,%r14,4)
	cmpl	$21, %ecx
	ja	.LBB7_15
# %bb.7:                                #   in Loop: Header=BB7_4 Depth=2
	movl	$3981312, %edx                  # imm = 0x3CC000
	btl	%ecx, %edx
	jae	.LBB7_15
# %bb.8:                                #   in Loop: Header=BB7_4 Depth=2
	movl	$1, (%rsi,%r14,4)
	movl	$-3, %ecx
.LBB7_12:                               # %.preheader
                                        #   Parent Loop BB7_2 Depth=1
                                        #     Parent Loop BB7_4 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB7_13 Depth 4
	movq	%rcx, -120(%rbp)                # 8-byte Spill
	leal	(%rcx,%r14), %r12d
	movl	$7, %r15d
	movl	-48(%rbp), %ebx                 # 4-byte Reload
.LBB7_13:                               #   Parent Loop BB7_2 Depth=1
                                        #     Parent Loop BB7_4 Depth=2
                                        #       Parent Loop BB7_12 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	cmpl	$0, (%rsi,%r14,4)
	je	.LBB7_14
# %bb.16:                               #   in Loop: Header=BB7_13 Depth=4
	testl	%r12d, %r12d
	js	.LBB7_25
# %bb.17:                               #   in Loop: Header=BB7_13 Depth=4
	cmpl	%eax, %r12d
	jae	.LBB7_25
# %bb.18:                               #   in Loop: Header=BB7_13 Depth=4
	testl	%ebx, %ebx
	js	.LBB7_25
# %bb.19:                               #   in Loop: Header=BB7_13 Depth=4
	cmpl	-52(%rbp), %ebx
	jae	.LBB7_25
# %bb.20:                               #   in Loop: Header=BB7_13 Depth=4
	movl	%ebx, %ecx
	imulq	$613566757, %rcx, %rcx          # imm = 0x24924925
	shrq	$32, %rcx
	movl	%ebx, %r13d
	subl	%ecx, %r13d
	shrl	%r13d
	addl	%ecx, %r13d
	shrl	$2, %r13d
	leal	(,%r13,8), %ecx
	subl	%ecx, %r13d
	addl	%ebx, %r13d
	cmpl	-160(%rbp,%r13,4), %ebx
	je	.LBB7_22
# %bb.21:                               #   in Loop: Header=BB7_13 Depth=4
	imull	%r13d, %eax
	leaq	(%rdi,%rax,8), %rsi
	movq	-72(%rbp), %rdi                 # 8-byte Reload
	movl	%ebx, %edx
	callq	_Z14read_line_tiffP4tiffPdi
	movq	-80(%rbp), %rsi                 # 8-byte Reload
	movq	-64(%rbp), %rdi                 # 8-byte Reload
	movl	%ebx, -160(%rbp,%r13,4)
	movl	-44(%rbp), %eax
.LBB7_22:                               #   in Loop: Header=BB7_13 Depth=4
	imull	%eax, %r13d
	addl	%r14d, %r13d
	cvttsd2si	(%rdi,%r13,8), %ecx
	cmpl	$21, %ecx
	ja	.LBB7_24
# %bb.23:                               #   in Loop: Header=BB7_13 Depth=4
	movl	$3981312, %edx                  # imm = 0x3CC000
	btl	%ecx, %edx
	jae	.LBB7_24
.LBB7_25:                               # %_Z13checkLandCodei.exit70.thread
                                        #   in Loop: Header=BB7_13 Depth=4
	incl	%ebx
	decl	%r15d
	jne	.LBB7_13
	jmp	.LBB7_14
.LBB7_24:                               # %_Z13checkLandCodei.exit70
                                        #   in Loop: Header=BB7_13 Depth=4
	movl	$0, (%rsi,%r14,4)
	jmp	.LBB7_25
.LBB7_14:                               # %.critedge2
                                        #   in Loop: Header=BB7_12 Depth=3
	movq	-120(%rbp), %rcx                # 8-byte Reload
	incl	%ecx
	cmpl	$4, %ecx
	je	.LBB7_15
# %bb.11:                               # %thread-pre-split
                                        #   in Loop: Header=BB7_12 Depth=3
	cmpl	$0, (%rsi,%r14,4)
	jne	.LBB7_12
.LBB7_15:                               # %.critedge
                                        #   in Loop: Header=BB7_4 Depth=2
	incq	%r14
	movl	%eax, %ecx
	cmpq	%rcx, %r14
	movq	-112(%rbp), %r15                # 8-byte Reload
	movq	-104(%rbp), %rbx                # 8-byte Reload
	jb	.LBB7_4
.LBB7_9:                                # %._crit_edge
                                        #   in Loop: Header=BB7_2 Depth=1
	movq	-88(%rbp), %rdi                 # 8-byte Reload
	movl	%r15d, %edx
	callq	_Z15write_line_tiffP4tiffPii
	movq	-64(%rbp), %rdi                 # 8-byte Reload
	movq	-96(%rbp), %rsp                 # 8-byte Reload
	incl	%r15d
	incl	-48(%rbp)                       # 4-byte Folded Spill
	cmpl	-52(%rbp), %r15d
	jb	.LBB7_2
.LBB7_10:                               # %._crit_edge78
	callq	free
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end7:
	.size	_Z24testLandCoverHomogeneityP4tiffS0_, .Lfunc_end7-_Z24testLandCoverHomogeneityP4tiffS0_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$216, %rsp
	.cfi_def_cfa_offset 272
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movq	8(%rsi), %rsi
	leaq	184(%rsp), %rdi
	leaq	112(%rsp), %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	movq	16(%rbx), %rsi
.Ltmp0:
	leaq	112(%rsp), %rdi
	leaq	24(%rsp), %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
.Ltmp1:
# %bb.1:
	movq	112(%rsp), %rbx
	movq	120(%rsp), %r14
	leaq	40(%rsp), %r15
	movq	%r15, -16(%r15)
	movq	$0, -8(%r15)
	movb	$0, (%r15)
	leaq	8(%r14), %rsi
.Ltmp3:
	leaq	24(%rsp), %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm
.Ltmp4:
# %bb.2:
.Ltmp5:
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp6:
# %bb.3:
.Ltmp7:
	leaq	24(%rsp), %rdi
	movl	$.L.str.2, %esi
	movl	$8, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp8:
# %bb.4:                                # %_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_.exit
	movq	112(%rsp), %rbx
	movq	120(%rsp), %r14
	leaq	88(%rsp), %rbp
	movq	%rbp, -16(%rbp)
	movq	$0, -8(%rbp)
	movb	$0, (%rbp)
	leaq	8(%r14), %rsi
.Ltmp10:
	leaq	72(%rsp), %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm
.Ltmp11:
# %bb.5:
.Ltmp12:
	leaq	72(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp13:
# %bb.6:
.Ltmp14:
	leaq	72(%rsp), %rdi
	movl	$.L.str.3, %esi
	movl	$8, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp15:
# %bb.7:                                # %_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_.exit79
	movq	184(%rsp), %rdi
.Ltmp17:
	movl	$.L.str.4, %esi
	callq	TIFFOpen
.Ltmp18:
# %bb.8:
.Ltmp20:
	movq	%rax, %rbx
	movq	%rsp, %rdx
	movq	%rax, %rdi
	movl	$256, %esi                      # imm = 0x100
	xorl	%eax, %eax
	callq	TIFFGetField
.Ltmp21:
# %bb.9:
.Ltmp22:
	leaq	4(%rsp), %rdx
	movq	%rbx, %rdi
	movl	$257, %esi                      # imm = 0x101
	xorl	%eax, %eax
	callq	TIFFGetField
.Ltmp23:
# %bb.10:
	movq	24(%rsp), %rdi
.Ltmp25:
	movl	$.L.str.5, %esi
	callq	TIFFOpen
.Ltmp26:
# %bb.11:
	movq	%rax, %r14
	movl	(%rsp), %esi
	movl	4(%rsp), %edx
.Ltmp27:
	movq	%rax, %rdi
	movl	$32, %ecx
	movl	$2, %r8d
	callq	_Z5setupP4tiffiiii
.Ltmp28:
# %bb.12:
.Ltmp29:
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_Z24testLandCoverHomogeneityP4tiffS0_
.Ltmp30:
# %bb.13:
.Ltmp31:
	movq	%r14, %rdi
	callq	TIFFClose
.Ltmp32:
# %bb.14:
	movq	72(%rsp), %rdi
.Ltmp34:
	movl	$.L.str.5, %esi
	callq	TIFFOpen
.Ltmp35:
# %bb.15:
	movq	%rax, %r14
	movl	(%rsp), %esi
	movl	4(%rsp), %edx
.Ltmp36:
	movq	%rax, %rdi
	movl	$32, %ecx
	movl	$2, %r8d
	callq	_Z5setupP4tiffiiii
.Ltmp37:
# %bb.16:
	movl	(%rsp), %r12d
	leal	(,%r12,8), %r13d
	subl	%r12d, %r13d
	shlq	$3, %r13
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %r15
	shlq	$2, %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r12
.Ltmp39:
	leaq	16(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
.Ltmp40:
# %bb.17:
	movq	%r14, 56(%rsp)                  # 8-byte Spill
	movq	%rbx, 64(%rsp)                  # 8-byte Spill
	movl	(%rsp), %esi
	shlq	$3, %rsi
.Ltmp42:
	leaq	8(%rsp), %rdi
	callq	hipMalloc
.Ltmp43:
# %bb.18:
	pcmpeqd	%xmm0, %xmm0
	movdqu	%xmm0, 156(%rsp)
	movdqa	%xmm0, 144(%rsp)
	cmpl	$0, 4(%rsp)
	je	.LBB8_34
# %bb.19:                               # %.preheader.preheader
	xorl	%r13d, %r13d
	movl	$-3, %r14d
	movq	%r12, 104(%rsp)                 # 8-byte Spill
.LBB8_20:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_21 Depth 2
	movl	$7, %r12d
	movl	%r14d, %ebp
.LBB8_21:                               #   Parent Loop BB8_20 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	testl	%ebp, %ebp
	js	.LBB8_26
# %bb.22:                               #   in Loop: Header=BB8_21 Depth=2
	cmpl	4(%rsp), %ebp
	jae	.LBB8_26
# %bb.23:                               #   in Loop: Header=BB8_21 Depth=2
	movl	%ebp, %eax
	imulq	$613566757, %rax, %rax          # imm = 0x24924925
	shrq	$32, %rax
	movl	%ebp, %ebx
	subl	%eax, %ebx
	shrl	%ebx
	addl	%eax, %ebx
	shrl	$2, %ebx
	leal	(,%rbx,8), %eax
	subl	%eax, %ebx
	addl	%ebp, %ebx
	cmpl	144(%rsp,%rbx,4), %ebp
	je	.LBB8_26
# %bb.24:                               #   in Loop: Header=BB8_21 Depth=2
	movl	(%rsp), %eax
	imull	%ebx, %eax
	leaq	(%r15,%rax,8), %rsi
.Ltmp45:
	movq	64(%rsp), %rdi                  # 8-byte Reload
	movl	%ebp, %edx
	callq	_Z14read_line_tiffP4tiffPdi
.Ltmp46:
# %bb.25:                               #   in Loop: Header=BB8_21 Depth=2
	movl	%ebp, 144(%rsp,%rbx,4)
.LBB8_26:                               #   in Loop: Header=BB8_21 Depth=2
	incl	%ebp
	decl	%r12d
	jne	.LBB8_21
# %bb.27:                               #   in Loop: Header=BB8_20 Depth=1
	movq	16(%rsp), %rdi
	movl	(%rsp), %eax
	leal	(,%rax,8), %edx
	subl	%eax, %edx
	shlq	$3, %rdx
.Ltmp48:
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp49:
	movq	104(%rsp), %r12                 # 8-byte Reload
# %bb.28:                               #   in Loop: Header=BB8_20 Depth=1
	movl	(%rsp), %edi
	incl	%edi
	shrl	$8, %edi
	btsq	$32, %rdi
.Ltmp50:
	movl	$1, %esi
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp51:
# %bb.29:                               #   in Loop: Header=BB8_20 Depth=1
	testl	%eax, %eax
	jne	.LBB8_31
# %bb.30:                               #   in Loop: Header=BB8_20 Depth=1
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movl	(%rsp), %ecx
	movl	4(%rsp), %r8d
.Ltmp52:
	movl	%r13d, %edx
	callq	_Z35__device_stub__landCoverHomogeneityPdPiiii
.Ltmp53:
.LBB8_31:                               #   in Loop: Header=BB8_20 Depth=1
	movq	8(%rsp), %rsi
	movl	(%rsp), %edx
	shlq	$2, %rdx
.Ltmp54:
	movq	%r12, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp55:
# %bb.32:                               #   in Loop: Header=BB8_20 Depth=1
.Ltmp56:
	movq	56(%rsp), %rdi                  # 8-byte Reload
	movq	%r12, %rsi
	movl	%r13d, %edx
	callq	_Z15write_line_tiffP4tiffPii
.Ltmp57:
# %bb.33:                               #   in Loop: Header=BB8_20 Depth=1
	incl	%r13d
	incl	%r14d
	cmpl	4(%rsp), %r13d
	jb	.LBB8_20
.LBB8_34:                               # %._crit_edge
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	16(%rsp), %rdi
.Ltmp59:
	callq	hipFree
.Ltmp60:
# %bb.35:
	movq	8(%rsp), %rdi
.Ltmp61:
	callq	hipFree
.Ltmp62:
# %bb.36:
.Ltmp63:
	movq	64(%rsp), %rdi                  # 8-byte Reload
	callq	TIFFClose
.Ltmp64:
# %bb.37:
.Ltmp65:
	movq	56(%rsp), %rdi                  # 8-byte Reload
	callq	TIFFClose
.Ltmp66:
# %bb.38:
	movq	72(%rsp), %rdi
	leaq	88(%rsp), %rax
	cmpq	%rax, %rdi
	leaq	40(%rsp), %rbx
	je	.LBB8_40
# %bb.39:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
	callq	_ZdlPv
.LBB8_40:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
	movq	24(%rsp), %rdi
	cmpq	%rbx, %rdi
	je	.LBB8_42
# %bb.41:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i80
	callq	_ZdlPv
.LBB8_42:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit82
	leaq	128(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB8_44
# %bb.43:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i83
	callq	_ZdlPv
.LBB8_44:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit85
	leaq	200(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB8_46
# %bb.45:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i86
	callq	_ZdlPv
.LBB8_46:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit88
	xorl	%eax, %eax
	addq	$216, %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
.LBB8_47:
	.cfi_def_cfa_offset 272
.Ltmp44:
	jmp	.LBB8_60
.LBB8_48:
.Ltmp41:
	movq	%rax, %rbx
	leaq	40(%rsp), %r15
	jmp	.LBB8_61
.LBB8_49:
.Ltmp19:
	jmp	.LBB8_54
.LBB8_50:
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB8_67
.LBB8_51:
.Ltmp38:
	jmp	.LBB8_54
.LBB8_52:
.Ltmp24:
	jmp	.LBB8_54
.LBB8_53:
.Ltmp16:
	jmp	.LBB8_54
.LBB8_55:
.Ltmp9:
	movq	%rax, %rbx
	jmp	.LBB8_63
.LBB8_56:
.Ltmp67:
	jmp	.LBB8_60
.LBB8_57:
.Ltmp33:
.LBB8_54:
	movq	%rax, %rbx
	jmp	.LBB8_61
.LBB8_58:
.Ltmp58:
	jmp	.LBB8_60
.LBB8_59:
.Ltmp47:
.LBB8_60:
	movq	%rax, %rbx
	leaq	40(%rsp), %r15
	leaq	88(%rsp), %rbp
.LBB8_61:
	movq	72(%rsp), %rdi
	cmpq	%rbp, %rdi
	je	.LBB8_63
# %bb.62:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i89
	callq	_ZdlPv
.LBB8_63:                               # %.body77
	movq	24(%rsp), %rdi
	cmpq	%r15, %rdi
	je	.LBB8_65
# %bb.64:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i92
	callq	_ZdlPv
.LBB8_65:                               # %.body
	leaq	128(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB8_67
# %bb.66:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i95
	callq	_ZdlPv
.LBB8_67:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit97
	leaq	200(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB8_69
# %bb.68:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i98
	callq	_ZdlPv
.LBB8_69:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit100
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end8:
	.size	main, .Lfunc_end8-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table8:
.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 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.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 3 <<
	.uleb128 .Ltmp8-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp8
	.uleb128 .Ltmp9-.Lfunc_begin0           #     jumps to .Ltmp9
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp15-.Ltmp10                #   Call between .Ltmp10 and .Ltmp15
	.uleb128 .Ltmp16-.Lfunc_begin0          #     jumps to .Ltmp16
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp17-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp18-.Ltmp17                #   Call between .Ltmp17 and .Ltmp18
	.uleb128 .Ltmp19-.Lfunc_begin0          #     jumps to .Ltmp19
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp20-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp23-.Ltmp20                #   Call between .Ltmp20 and .Ltmp23
	.uleb128 .Ltmp24-.Lfunc_begin0          #     jumps to .Ltmp24
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp25-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp32-.Ltmp25                #   Call between .Ltmp25 and .Ltmp32
	.uleb128 .Ltmp33-.Lfunc_begin0          #     jumps to .Ltmp33
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp34-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp37-.Ltmp34                #   Call between .Ltmp34 and .Ltmp37
	.uleb128 .Ltmp38-.Lfunc_begin0          #     jumps to .Ltmp38
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp39-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp40-.Ltmp39                #   Call between .Ltmp39 and .Ltmp40
	.uleb128 .Ltmp41-.Lfunc_begin0          #     jumps to .Ltmp41
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp42-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp43-.Ltmp42                #   Call between .Ltmp42 and .Ltmp43
	.uleb128 .Ltmp44-.Lfunc_begin0          #     jumps to .Ltmp44
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp45-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp46-.Ltmp45                #   Call between .Ltmp45 and .Ltmp46
	.uleb128 .Ltmp47-.Lfunc_begin0          #     jumps to .Ltmp47
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp48-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp57-.Ltmp48                #   Call between .Ltmp48 and .Ltmp57
	.uleb128 .Ltmp58-.Lfunc_begin0          #     jumps to .Ltmp58
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp59-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Ltmp66-.Ltmp59                #   Call between .Ltmp59 and .Ltmp66
	.uleb128 .Ltmp67-.Lfunc_begin0          #     jumps to .Ltmp67
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp66-.Lfunc_begin0          # >> Call Site 14 <<
	.uleb128 .Lfunc_end8-.Ltmp66            #   Call between .Ltmp66 and .Lfunc_end8
	.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	.LBB9_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
.LBB9_1:
	.cfi_def_cfa_offset 32
	movl	$.L.str.6, %edi
	callq	_ZSt19__throw_logic_errorPKc
.Lfunc_end9:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .Lfunc_end9-_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	.LBB10_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	.LBB10_3
.LBB10_1:                               # %._crit_edge
	movq	(%rbx), %rax
.LBB10_3:
	testq	%r14, %r14
	je	.LBB10_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB10_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB10_7
.LBB10_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB10_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_end10:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag, .Lfunc_end10-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.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	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z20landCoverHomogeneityPdPiiii, %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_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__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	.LBB12_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
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Write problem!"
	.size	.L.str, 15

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Read problem"
	.size	.L.str.1, 13

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

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"/CPU.tif"
	.size	.L.str.2, 9

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"/GPU.tif"
	.size	.L.str.3, 9

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"rm"
	.size	.L.str.4, 3

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"w8m"
	.size	.L.str.5, 4

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z20landCoverHomogeneityPdPiiii"
	.size	.L__unnamed_1, 32

	.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__landCoverHomogeneityPdPiiii
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _Z20landCoverHomogeneityPdPiiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z20landCoverHomogeneityPdPiiii ; -- Begin function _Z20landCoverHomogeneityPdPiiii
	.globl	_Z20landCoverHomogeneityPdPiiii
	.p2align	8
	.type	_Z20landCoverHomogeneityPdPiiii,@function
_Z20landCoverHomogeneityPdPiiii:        ; @_Z20landCoverHomogeneityPdPiiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s8, s[0:1], 0x2c
	s_load_b128 s[4:7], s[0:1], 0x10
	s_add_u32 s2, s0, 32
	s_addc_u32 s3, s1, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s7, s8, 0xffff
	s_mov_b32 s8, exec_lo
	v_mad_u64_u32 v[1:2], null, s15, s7, v[0:1]
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s5, v1
	s_cbranch_execz .LBB0_27
; %bb.1:                                ; %.lr.ph
	s_load_b32 s3, s[2:3], 0x0
	s_load_b128 s[8:11], s[0:1], 0x0
	s_mul_hi_i32 s0, s4, 0x92492493
	v_mov_b32_e32 v0, 0
	s_add_i32 s0, s0, s4
	v_mov_b32_e32 v6, 1
	s_lshr_b32 s1, s0, 31
	s_ashr_i32 s0, s0, 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_add_i32 s0, s0, s1
	s_add_i32 s1, s4, -3
	s_mul_i32 s0, s0, 7
	s_sub_i32 s2, s4, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mul_i32 s2, s2, s5
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s3, s3, s7
	s_mov_b32 s7, 0
.LBB0_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_8 Depth 2
                                        ;       Child Loop BB0_10 Depth 3
	v_add_nc_u32_e32 v4, s2, v1
	v_ashrrev_i32_e32 v2, 31, v1
	s_mov_b32 s0, 0
	s_mov_b32 s12, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[4:5], 3, v[4:5]
	v_add_co_u32 v2, vcc_lo, s10, v2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v3, vcc_lo, s11, v3, vcc_lo
	v_add_co_u32 v4, vcc_lo, s8, v4
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v5, vcc_lo, s9, v5, vcc_lo
	global_store_b32 v[2:3], v0, off
	global_load_b64 v[4:5], v[4:5], off
	s_waitcnt vmcnt(0)
	v_cvt_i32_f64_e32 v4, v[4:5]
	v_cmpx_lt_i32_e32 17, v4
	s_xor_b32 s12, exec_lo, s12
; %bb.3:                                ; %LeafBlock80
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_cmp_gt_i32_e32 vcc_lo, 22, v4
                                        ; implicit-def: $vgpr4
	s_and_b32 s0, vcc_lo, exec_lo
; %bb.4:                                ; %Flow96
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_and_not1_saveexec_b32 s12, s12
; %bb.5:                                ; %LeafBlock
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v4, -14, v4
	s_and_not1_b32 s0, s0, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_u32_e32 vcc_lo, 2, v4
	s_and_b32 s13, vcc_lo, exec_lo
	s_or_b32 s0, s0, s13
; %bb.6:                                ; %Flow97
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	s_and_saveexec_b32 s12, s0
	s_cbranch_execz .LBB0_26
; %bb.7:                                ; %.critedge52
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v7, 1
	s_mov_b32 s13, -3
	s_mov_b32 s14, 0
	global_store_b32 v[2:3], v6, off
                                        ; implicit-def: $sgpr15
.LBB0_8:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_10 Depth 3
	s_or_b32 s15, s15, exec_lo
	s_mov_b32 s16, exec_lo
	v_cmpx_ne_u32_e32 0, v7
	s_cbranch_execz .LBB0_25
; %bb.9:                                ; %.preheader
                                        ;   in Loop: Header=BB0_8 Depth=2
	v_add_nc_u32_e32 v4, s13, v1
	s_mov_b32 s17, 0
	s_mov_b32 s18, s1
	s_mov_b32 s19, 0
                                        ; implicit-def: $sgpr20
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_lt_i32_e32 vcc_lo, -1, v4
	v_cmp_gt_i32_e64 s0, s5, v4
	s_and_b32 s0, vcc_lo, s0
.LBB0_10:                               ;   Parent Loop BB0_2 Depth=1
                                        ;     Parent Loop BB0_8 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	s_or_b32 s20, s20, exec_lo
	s_mov_b32 s21, exec_lo
	v_cmpx_ne_u32_e32 0, v7
	s_cbranch_execz .LBB0_23
; %bb.11:                               ;   in Loop: Header=BB0_10 Depth=3
	s_and_saveexec_b32 s22, s0
	s_cbranch_execz .LBB0_22
; %bb.12:                               ;   in Loop: Header=BB0_10 Depth=3
	s_add_i32 s23, s4, s19
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s24, s23, -3
	s_cmp_lt_i32 s24, 0
	s_cselect_b32 s25, -1, 0
	s_cmp_ge_i32 s24, s6
	s_cselect_b32 s24, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s24, s25, s24
	s_and_b32 vcc_lo, exec_lo, s24
	s_cbranch_vccnz .LBB0_22
; %bb.13:                               ;   in Loop: Header=BB0_10 Depth=3
	s_mul_hi_u32 s24, s18, 0x24924925
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_sub_i32 s25, s18, s24
	s_lshr_b32 s25, s25, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s25, s25, s24
	s_lshr_b32 s24, s25, 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s24, s24, 7
	s_sub_i32 s23, s23, s24
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s23, s23, -3
	v_mad_u64_u32 v[4:5], null, s23, s5, v[1:2]
	s_mov_b32 s23, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[4:5], 3, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, s8, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s9, v5, vcc_lo
	global_load_b64 v[4:5], v[4:5], off
	s_waitcnt vmcnt(0)
	v_cmpx_o_f64_e32 v[4:5], v[4:5]
	s_cbranch_execz .LBB0_21
; %bb.14:                               ; %NodeBlock87
                                        ;   in Loop: Header=BB0_10 Depth=3
	v_cvt_i32_f64_e32 v4, v[4:5]
	s_mov_b32 s24, 0
	s_mov_b32 s25, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_lt_i32_e32 17, v4
	s_xor_b32 s25, exec_lo, s25
; %bb.15:                               ; %LeafBlock85
                                        ;   in Loop: Header=BB0_10 Depth=3
	v_cmp_lt_i32_e32 vcc_lo, 21, v4
                                        ; implicit-def: $vgpr4
	s_and_b32 s24, vcc_lo, exec_lo
; %bb.16:                               ; %Flow
                                        ;   in Loop: Header=BB0_10 Depth=3
	s_and_not1_saveexec_b32 s25, s25
; %bb.17:                               ; %LeafBlock82
                                        ;   in Loop: Header=BB0_10 Depth=3
	v_add_nc_u32_e32 v4, -14, v4
	s_and_not1_b32 s24, s24, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_lt_u32_e32 vcc_lo, 1, v4
	s_and_b32 s26, vcc_lo, exec_lo
	s_or_b32 s24, s24, s26
; %bb.18:                               ; %Flow89
                                        ;   in Loop: Header=BB0_10 Depth=3
	s_or_b32 exec_lo, exec_lo, s25
	s_and_saveexec_b32 s25, s24
	s_cbranch_execz .LBB0_20
; %bb.19:                               ; %_Z13checkLandCodei.exit51
                                        ;   in Loop: Header=BB0_10 Depth=3
	v_mov_b32_e32 v7, 0
	global_store_b32 v[2:3], v0, off
.LBB0_20:                               ; %Flow90
                                        ;   in Loop: Header=BB0_10 Depth=3
	s_or_b32 exec_lo, exec_lo, s25
.LBB0_21:                               ; %Flow91
                                        ;   in Loop: Header=BB0_10 Depth=3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s23
.LBB0_22:                               ; %.critedge53
                                        ;   in Loop: Header=BB0_10 Depth=3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s22
	s_add_i32 s19, s19, 1
	s_add_i32 s18, s18, 1
	s_cmp_eq_u32 s19, 7
	s_cselect_b32 s22, -1, 0
	s_and_not1_b32 s20, s20, exec_lo
	s_and_b32 s22, s22, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s20, s20, s22
.LBB0_23:                               ; %Flow93
                                        ;   in Loop: Header=BB0_10 Depth=3
	s_or_b32 exec_lo, exec_lo, s21
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s21, exec_lo, s20
	s_or_b32 s17, s21, s17
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s17
	s_cbranch_execnz .LBB0_10
; %bb.24:                               ; %.critedge2
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_or_b32 exec_lo, exec_lo, s17
	s_add_i32 s13, s13, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	s_cmp_eq_u32 s13, 4
	s_cselect_b32 s0, -1, 0
	s_and_not1_b32 s15, s15, exec_lo
	s_and_b32 s0, s0, exec_lo
	s_or_b32 s15, s15, s0
.LBB0_25:                               ; %Flow94
                                        ;   in Loop: Header=BB0_8 Depth=2
	s_or_b32 exec_lo, exec_lo, s16
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, exec_lo, s15
	s_or_b32 s14, s0, s14
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s14
	s_cbranch_execnz .LBB0_8
.LBB0_26:                               ; %Flow98
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	v_add_nc_u32_e32 v1, s3, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_le_i32_e32 vcc_lo, s5, v1
	s_or_b32 s7, vcc_lo, s7
	s_and_not1_b32 exec_lo, exec_lo, s7
	s_cbranch_execnz .LBB0_2
.LBB0_27:                               ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20landCoverHomogeneityPdPiiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 27
		.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	_Z20landCoverHomogeneityPdPiiii, .Lfunc_end0-_Z20landCoverHomogeneityPdPiiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 828
; NumSgprs: 29
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 29
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
