﻿/**
 * Nearest neighbor search
 * マップ内に、店、工場などのゾーンがある確率で配備されている時、
 * 住宅ゾーンから直近の店、工場までのマンハッタン距離を計算する。
 *
 * 各店、工場から周辺に再帰的に距離を更新していくので、O(N)で済む。
 * しかも、GPUで並列化することで、さらに計算時間を短縮できる。
 */

#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <list>
#include <time.h>

#define CITY_SIZE 200
#define NUM_GPU_BLOCKS 4
#define NUM_GPU_THREADS 128
#define NUM_FEATURES 5
#define QUEUE_SIZE 5000

#define CUDA_CALL(x) {if((x) != cudaSuccess){ \
  printf("CUDA error at %s:%d\n",__FILE__,__LINE__); \
  printf("  %s\n", cudaGetErrorString(cudaGetLastError())); \
  exit(EXIT_FAILURE);}} 


struct ZoneType {
	int type;
	int level;
};

struct ZoningPlan {
	ZoneType zones[CITY_SIZE][CITY_SIZE];
};

struct DistanceMap {
	int distances[CITY_SIZE][CITY_SIZE][NUM_FEATURES];
};

struct Point2D {
	int x;
	int y;

	__host__ __device__
	Point2D() : x(0), y(0) {}

	__host__ __device__
	Point2D(int x, int y) : x(x), y(y) {}
};

struct Point2DAndFeature {
	int x;
	int y;
	int featureId;

	__host__ __device__
	Point2DAndFeature() : x(0), y(0), featureId(0) {}

	__host__ __device__
	Point2DAndFeature(int x, int y, int featureId) : x(x), y(y), featureId(featureId) {}
};

__host__ __device__
unsigned int rand(unsigned int* randx) {
    *randx = *randx * 1103515245 + 12345;
    return (*randx)&2147483647;
}

__host__ __device__
float randf(unsigned int* randx) {
	return rand(randx) / (float(2147483647) + 1);
}

__host__ __device__
float randf(unsigned int* randx, float a, float b) {
	return randf(randx) * (b - a) + a;
}

__host__ __device__
int sampleFromCdf(unsigned int* randx, float* cdf, int num) {
	float rnd = randf(randx, 0, cdf[num-1]);

	for (int i = 0; i < num; ++i) {
		if (rnd <= cdf[i]) return i;
	}

	return num - 1;
}

__host__ __device__
int sampleFromPdf(unsigned int* randx, float* pdf, int num) {
	if (num == 0) return 0;

	float cdf[40];
	cdf[0] = pdf[0];
	for (int i = 1; i < num; ++i) {
		if (pdf[i] >= 0) {
			cdf[i] = cdf[i - 1] + pdf[i];
		} else {
			cdf[i] = cdf[i - 1];
		}
	}

	return sampleFromCdf(randx, cdf, num);
}

/**
 * ゾーンプランを生成する。
 */
__host__
void generateZoningPlan(ZoningPlan& zoningPlan, std::vector<float> zoneTypeDistribution) {
	std::vector<float> numRemainings(zoneTypeDistribution.size());
	for (int i = 0; i < zoneTypeDistribution.size(); ++i) {
		numRemainings[i] = CITY_SIZE * CITY_SIZE * zoneTypeDistribution[i];
	}

	unsigned int randx = 0;

	for (int r = 0; r < CITY_SIZE; ++r) {
		for (int c = 0; c < CITY_SIZE; ++c) {
			int type = sampleFromPdf(&randx, numRemainings.data(), numRemainings.size());
			zoningPlan.zones[r][c].type = type;
			numRemainings[type] -= 1;
		}
	}
}




__global__
void initDistance(ZoningPlan* zoningPlan, DistanceMap* distanceMap, Point2DAndFeature* queue, int* queueEnd) {
	int idx = blockDim.x * blockIdx.x + threadIdx.x;

	queueEnd[idx] = 0;

	int stride = ceilf((float)(CITY_SIZE * CITY_SIZE) / NUM_GPU_BLOCKS / NUM_GPU_THREADS);
	
	// 分割された領域内で、店を探す
	for (int i = 0; i < stride; ++i) {
		int r = (idx * stride + i) / CITY_SIZE;
		int c = (idx * stride + i) % CITY_SIZE;
		if (r >= CITY_SIZE) continue;

		for (int feature_id = 0; feature_id < NUM_FEATURES; ++feature_id) {
			if (zoningPlan->zones[r][c].type - 1 == feature_id) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(c, r, feature_id);
				distanceMap->distances[r][c][feature_id] = 0;
			} else {
				distanceMap->distances[r][c][feature_id] = 9999;
			}

		}


	}
}



/**
 * 直近の店までの距離を計算する（マルチスレッド版）
 */
__global__
void computeDistanceToStore(ZoningPlan* zoningPlan, DistanceMap* distanceMap, Point2DAndFeature* queue, int* queueEnd) {
	int idx = blockDim.x * blockIdx.x + threadIdx.x;

	int queue_begin = 0;

	// 距離マップを生成
	while (queue_begin < queueEnd[idx]) {
		Point2DAndFeature pt = queue[idx * QUEUE_SIZE + queue_begin++];
		if (queue_begin >= QUEUE_SIZE) queue_begin = 0;

		int d = distanceMap->distances[pt.y][pt.x][pt.featureId];

		if (pt.y > 0) {
			int old = atomicMin(&distanceMap->distances[pt.y-1][pt.x][pt.featureId], d + 1);
			if (old > d + 1) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(pt.x, pt.y-1, pt.featureId);
				if (queueEnd[idx] >= QUEUE_SIZE) queueEnd[idx] = 0;
			}
		}
		if (pt.y < CITY_SIZE - 1) {
			int old = atomicMin(&distanceMap->distances[pt.y+1][pt.x][pt.featureId], d + 1);
			if (old > d + 1) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(pt.x, pt.y+1, pt.featureId);
				if (queueEnd[idx] >= QUEUE_SIZE) queueEnd[idx] = 0;
			}
		}
		if (pt.x > 0) {
			int old = atomicMin(&distanceMap->distances[pt.y][pt.x-1][pt.featureId], d + 1);
			if (old > d + 1) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(pt.x-1, pt.y, pt.featureId);
				if (queueEnd[idx] >= QUEUE_SIZE) queueEnd[idx] = 0;
			}
		}
		if (pt.x < CITY_SIZE - 1) {
			int old = atomicMin(&distanceMap->distances[pt.y][pt.x+1][pt.featureId], d + 1);
			if (old > d + 1) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(pt.x+1, pt.y, pt.featureId);
				if (queueEnd[idx] >= QUEUE_SIZE) queueEnd[idx] = 0;
			}
		}
	}
}

/**
 * 直近の店までの距離を計算する（CPU版）
 */
__host__
void computeDistanceToStoreCPU(ZoningPlan* zoningPLan, DistanceMap* distanceMap) {
	std::list<Point2DAndFeature> queue;

	for (int feature_id = 0; feature_id < NUM_FEATURES; ++feature_id) {
		for (int cell_id = 0; cell_id < CITY_SIZE * CITY_SIZE; ++cell_id) {
			int r = cell_id / CITY_SIZE;
			int c = cell_id % CITY_SIZE;

			if (zoningPLan->zones[r][c].type - 1== feature_id) {
				queue.push_back(Point2DAndFeature(c, r, feature_id));
				distanceMap->distances[r][c][feature_id] = 0;
			} else {
				distanceMap->distances[r][c][feature_id] = 9999;
			}
		}
	}

	while (!queue.empty()) {
		Point2DAndFeature pt = queue.front();
		queue.pop_front();

		int d = distanceMap->distances[pt.y][pt.x][pt.featureId];

		if (pt.y > 0) {
			if (distanceMap->distances[pt.y-1][pt.x][pt.featureId] > d + 1) {
				distanceMap->distances[pt.y-1][pt.x][pt.featureId] = d + 1;
				queue.push_back(Point2DAndFeature(pt.x, pt.y-1, pt.featureId));
			}
		}
		if (pt.y < CITY_SIZE - 1) {
			if (distanceMap->distances[pt.y+1][pt.x][pt.featureId] > d + 1) {
				distanceMap->distances[pt.y+1][pt.x][pt.featureId] = d + 1;
				queue.push_back(Point2DAndFeature(pt.x, pt.y+1, pt.featureId));
			}
		}
		if (pt.x > 0) {
			if (distanceMap->distances[pt.y][pt.x-1][pt.featureId] > d + 1) {
				distanceMap->distances[pt.y][pt.x-1][pt.featureId] = d + 1;
				queue.push_back(Point2DAndFeature(pt.x-1, pt.y, pt.featureId));
			}
		}
		if (pt.x < CITY_SIZE - 1) {
			if (distanceMap->distances[pt.y][pt.x+1][pt.featureId] > d + 1) {
				distanceMap->distances[pt.y][pt.x+1][pt.featureId] = d + 1;
				queue.push_back(Point2DAndFeature(pt.x+1, pt.y, pt.featureId));
			}
		}
	}
}

int main()
{
	time_t start, end;


	ZoningPlan* hostZoningPlan = (ZoningPlan*)malloc(sizeof(ZoningPlan));
	DistanceMap* hostDistanceMap = (DistanceMap*)malloc(sizeof(DistanceMap));
	DistanceMap* hostDistanceMap2 = (DistanceMap*)malloc(sizeof(DistanceMap));

	// 距離を初期化
	memset(hostDistanceMap, 9999, sizeof(DistanceMap));
	memset(hostDistanceMap2, 9999, sizeof(DistanceMap));

	std::vector<float> zoneTypeDistribution(6);
	zoneTypeDistribution[0] = 0.5f;
	zoneTypeDistribution[1] = 0.2f;
	zoneTypeDistribution[2] = 0.1f;
	zoneTypeDistribution[3] = 0.1f;
	zoneTypeDistribution[4] = 0.05f;
	zoneTypeDistribution[5] = 0.05f;
	
	// 初期プランを生成
	start = clock();
	generateZoningPlan(*hostZoningPlan, zoneTypeDistribution);
	end = clock();
	printf("generateZoningPlan: %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
	
	// デバッグ用
	if (CITY_SIZE <= 100) {
		for (int r = CITY_SIZE - 1; r >= 0; --r) {
			for (int c = 0; c < CITY_SIZE; ++c) {
				printf("%d, ", hostZoningPlan->zones[r][c].type);
			}
			printf("\n");
		}
		printf("\n");
	}

	// 初期プランをデバイスバッファへコピー
	ZoningPlan* devZoningPlan;
	CUDA_CALL(cudaMalloc((void**)&devZoningPlan, sizeof(ZoningPlan)));
	CUDA_CALL(cudaMemcpy(devZoningPlan, hostZoningPlan, sizeof(ZoningPlan), cudaMemcpyHostToDevice));

	// 距離マップ用に、デバイスバッファを確保
	DistanceMap* devDistanceMap;
	CUDA_CALL(cudaMalloc((void**)&devDistanceMap, sizeof(DistanceMap)));

	// キュー用にデバイスバッファを確保
	Point2DAndFeature* devQueue;
	CUDA_CALL(cudaMalloc((void**)&devQueue, sizeof(Point2DAndFeature) * QUEUE_SIZE * NUM_GPU_BLOCKS * NUM_GPU_THREADS));
	int* devQueueEnd;
	CUDA_CALL(cudaMalloc((void**)&devQueueEnd, sizeof(int) * NUM_GPU_BLOCKS * NUM_GPU_THREADS));



	///////////////////////////////////////////////////////////////////////
	// CPU版で、直近の店までの距離を計算
	start = clock();
	for (int iter = 0; iter < 1000; ++iter) {
		computeDistanceToStoreCPU(hostZoningPlan, hostDistanceMap2);
	}
	end = clock();
	printf("computeDistanceToStore CPU: %lf\n", (double)(end-start)/CLOCKS_PER_SEC);







	///////////////////////////////////////////////////////////////////////
	// マルチスレッドで、直近の店までの距離を計算
	float elapsed1 = 0.0f;
	float elapsed2 = 0.0f;
	for (int iter = 0; iter < 1000; ++iter) {
		start = clock();
		initDistance<<<NUM_GPU_BLOCKS, NUM_GPU_THREADS>>>(devZoningPlan, devDistanceMap, devQueue, devQueueEnd);
		cudaDeviceSynchronize();
		end = clock();
		elapsed1 += (double)(end-start)/CLOCKS_PER_SEC;
		start = clock();
		computeDistanceToStore<<<NUM_GPU_BLOCKS, NUM_GPU_THREADS>>>(devZoningPlan, devDistanceMap, devQueue, devQueueEnd);
		cudaDeviceSynchronize();
		end = clock();
		elapsed2 += (double)(end-start)/CLOCKS_PER_SEC;
	}
	printf("computeDistanceToStore: initDistance = %lf, updateDistance = %lf\n", elapsed1, elapsed2);

	// 距離をCPUバッファへコピー
	CUDA_CALL(cudaMemcpy(hostDistanceMap, devDistanceMap, sizeof(DistanceMap), cudaMemcpyDeviceToHost));


	
	// CPU版とマルチスレッドの結果を比較
	int bad_k = 0;
	bool err = false;
	{	
		for (int r = CITY_SIZE - 1; r >= 0 && !err; --r) {
			for (int c = 0; c < CITY_SIZE && !err; ++c) {
				for (int k = 0; k < NUM_FEATURES && !err; ++k) {
					if (hostDistanceMap->distances[r][c][k] != hostDistanceMap2->distances[r][c][k]) {
						err = true;
						printf("ERROR! %d,%d k=%d, %d != %d\n", r, c, k, hostDistanceMap->distances[r][c][k], hostDistanceMap2->distances[r][c][k]);
						bad_k = k;
					}
				}
			}

		}
	}


	// デバッグ用
	if (CITY_SIZE <= 100 && err) {
		for (int r = CITY_SIZE - 1; r >= 0; --r) {
			for (int c = 0; c < CITY_SIZE; ++c) {
				printf("%d, ", hostDistanceMap->distances[r][c][bad_k]);
			}
			printf("\n");
		}
		printf("\n");

		for (int r = CITY_SIZE - 1; r >= 0; --r) {
			for (int c = 0; c < CITY_SIZE; ++c) {
				printf("%d, ", hostDistanceMap2->distances[r][c][bad_k]);
			}
			printf("\n");
		}
		printf("\n");
	}


	// デバイスバッファの開放
	cudaFree(devZoningPlan);
	cudaFree(devDistanceMap);

	// CPUバッファの開放
	free(hostZoningPlan);
	free(hostDistanceMap);
	free(hostDistanceMap2);

	cudaDeviceReset();
}

	.file	"tmpxft_002fdd88_00000000-6_complex_zone.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3118:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3118:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z4randPj
	.type	_Z4randPj, @function
_Z4randPj:
.LFB3094:
	.cfi_startproc
	endbr64
	imull	$1103515245, (%rdi), %eax
	addl	$12345, %eax
	movl	%eax, (%rdi)
	andl	$2147483647, %eax
	ret
	.cfi_endproc
.LFE3094:
	.size	_Z4randPj, .-_Z4randPj
	.globl	_Z5randfPj
	.type	_Z5randfPj, @function
_Z5randfPj:
.LFB3095:
	.cfi_startproc
	endbr64
	call	_Z4randPj
	movl	%eax, %eax
	cvtsi2ssq	%rax, %xmm0
	mulss	.LC0(%rip), %xmm0
	ret
	.cfi_endproc
.LFE3095:
	.size	_Z5randfPj, .-_Z5randfPj
	.globl	_Z5randfPjff
	.type	_Z5randfPjff, @function
_Z5randfPjff:
.LFB3096:
	.cfi_startproc
	endbr64
	movaps	%xmm0, %xmm2
	call	_Z5randfPj
	subss	%xmm2, %xmm1
	mulss	%xmm0, %xmm1
	addss	%xmm2, %xmm1
	movaps	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE3096:
	.size	_Z5randfPjff, .-_Z5randfPjff
	.globl	_Z13sampleFromCdfPjPfi
	.type	_Z13sampleFromCdfPjPfi, @function
_Z13sampleFromCdfPjPfi:
.LFB3097:
	.cfi_startproc
	endbr64
	movslq	%edx, %rax
	xorps	%xmm0, %xmm0
	movss	-4(%rsi,%rax,4), %xmm1
	call	_Z5randfPjff
	xorl	%eax, %eax
.L8:
	cmpl	%eax, %edx
	jle	.L16
	leaq	1(%rax), %rcx
	movss	-4(%rsi,%rcx,4), %xmm1
	comiss	%xmm0, %xmm1
	jnb	.L7
	movq	%rcx, %rax
	jmp	.L8
.L16:
	leal	-1(%rdx), %eax
.L7:
	ret
	.cfi_endproc
.LFE3097:
	.size	_Z13sampleFromCdfPjPfi, .-_Z13sampleFromCdfPjPfi
	.globl	_Z13sampleFromPdfPjPfi
	.type	_Z13sampleFromPdfPjPfi, @function
_Z13sampleFromPdfPjPfi:
.LFB3098:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movl	%edx, %eax
	movq	%fs:40, %rdx
	movq	%rdx, 168(%rsp)
	xorl	%edx, %edx
	testl	%eax, %eax
	je	.L18
	movss	(%rsi), %xmm0
	movl	$1, %edx
	xorps	%xmm2, %xmm2
	movss	%xmm0, 8(%rsp)
.L19:
	cmpl	%edx, %eax
	leaq	8(%rsp), %rcx
	jle	.L29
	movss	(%rsi,%rdx,4), %xmm1
	movss	4(%rsp,%rdx,4), %xmm0
	comiss	%xmm2, %xmm1
	jb	.L20
	addss	%xmm1, %xmm0
.L20:
	movss	%xmm0, (%rcx,%rdx,4)
	incq	%rdx
	jmp	.L19
.L29:
	movl	%eax, %edx
	movq	%rcx, %rsi
	call	_Z13sampleFromCdfPjPfi
.L18:
	movq	168(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3098:
	.size	_Z13sampleFromPdfPjPfi, .-_Z13sampleFromPdfPjPfi
	.globl	_Z79__device_stub__Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.type	_Z79__device_stub__Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, @function
_Z79__device_stub__Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi:
.LFB3140:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L30:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3140:
	.size	_Z79__device_stub__Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, .-_Z79__device_stub__Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.globl	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.type	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, @function
_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi:
.LFB3141:
	.cfi_startproc
	endbr64
	jmp	_Z79__device_stub__Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.cfi_endproc
.LFE3141:
	.size	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, .-_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.globl	_Z89__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.type	_Z89__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, @function
_Z89__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi:
.LFB3142:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L35:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3142:
	.size	_Z89__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, .-_Z89__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.globl	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.type	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, @function
_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi:
.LFB3143:
	.cfi_startproc
	endbr64
	jmp	_Z89__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.cfi_endproc
.LFE3143:
	.size	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, .-_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi"
.LC3:
	.string	"_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3145:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC2(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC3(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3145:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIfSaIfEED2Ev,"axG",@progbits,_ZNSt6vectorIfSaIfEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEED2Ev
	.type	_ZNSt6vectorIfSaIfEED2Ev, @function
_ZNSt6vectorIfSaIfEED2Ev:
.LFB3204:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L42
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L42:
	ret
	.cfi_endproc
.LFE3204:
	.size	_ZNSt6vectorIfSaIfEED2Ev, .-_ZNSt6vectorIfSaIfEED2Ev
	.weak	_ZNSt6vectorIfSaIfEED1Ev
	.set	_ZNSt6vectorIfSaIfEED1Ev,_ZNSt6vectorIfSaIfEED2Ev
	.section	.text._ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_,"axG",@progbits,_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_,comdat
	.align 2
	.weak	_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_
	.type	_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_, @function
_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_:
.LFB3217:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	movl	$32, %edi
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	_Znwm@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	movq	0(%rbp), %rax
	movq	%rax, 16(%rdi)
	movl	8(%rbp), %eax
	movl	%eax, 24(%rdi)
	call	_ZNSt8__detail15_List_node_base7_M_hookEPS0_@PLT
	incq	16(%rbx)
	popq	%rdx
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3217:
	.size	_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_, .-_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_
	.section	.text._ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv,"axG",@progbits,_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv,comdat
	.align 2
	.weak	_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv
	.type	_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv, @function
_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv:
.LFB3289:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
.L47:
	cmpq	%rdi, %rbx
	je	.L50
	movq	(%rdi), %rbp
	movl	$32, %esi
	call	_ZdlPvm@PLT
	movq	%rbp, %rdi
	jmp	.L47
.L50:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3289:
	.size	_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv, .-_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv
	.text
	.globl	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
	.type	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap, @function
_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap:
.LFB3100:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3100
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	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
	xorl	%r12d, %r12d
	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	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	64(%rsp), %rax
	movq	%rax, 8(%rsp)
	movq	%rax, 72(%rsp)
	movq	%rax, 64(%rsp)
	xorl	%eax, %eax
	movq	%rax, 80(%rsp)
.L52:
	movslq	%r12d, %rax
	xorl	%r13d, %r13d
	movq	%rax, 16(%rsp)
.L54:
	movl	%r13d, %eax
	movl	$200, %edi
	movl	$9999, %esi
	cltd
	idivl	%edi
	movslq	%eax, %rbp
	movslq	%edx, %r14
	imulq	$200, %rbp, %rcx
	addq	%r14, %rcx
	movl	(%r15,%rcx,8), %ecx
	decl	%ecx
	cmpl	%r12d, %ecx
	jne	.L53
	movq	8(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movl	%edx, 52(%rsp)
	movl	%eax, 56(%rsp)
	movl	%r12d, 60(%rsp)
.LEHB0:
	call	_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_
	xorl	%esi, %esi
.L53:
	imulq	$1000, %rbp, %rbp
	movq	16(%rsp), %rax
	leaq	(%r14,%r14,4), %r14
	incl	%r13d
	addq	%r14, %rbp
	addq	%rax, %rbp
	movl	%esi, (%rbx,%rbp,4)
	cmpl	$40000, %r13d
	jne	.L54
	incl	%r12d
	cmpl	$5, %r12d
	jne	.L52
	leaq	52(%rsp), %rax
	movq	%rax, 16(%rsp)
.L55:
	movq	64(%rsp), %r13
	movq	8(%rsp), %rax
	cmpq	%rax, %r13
	je	.L78
	movl	20(%r13), %r12d
	movq	%r13, %rdi
	movl	16(%r13), %ebp
	movslq	24(%r13), %r15
	decq	80(%rsp)
	call	_ZNSt8__detail15_List_node_base9_M_unhookEv@PLT
	movq	%r13, %rdi
	movl	$32, %esi
	call	_ZdlPvm@PLT
	movslq	%r12d, %rax
	movq	%r15, %r14
	movq	%rax, 24(%rsp)
	movslq	%ebp, %rax
	movq	%rax, 40(%rsp)
	imulq	$5, 40(%rsp), %rcx
	imulq	$1000, 24(%rsp), %rax
	addq	%rcx, %rax
	addq	%r15, %rax
	testl	%r12d, %r12d
	movl	(%rbx,%rax,4), %eax
	movl	%eax, 36(%rsp)
	leal	1(%rax), %r13d
	jg	.L56
.L60:
	imulq	$5, 40(%rsp), %rcx
	leal	1(%r12), %edx
	movslq	%edx, %rax
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	addq	%r15, %rax
	cmpl	%r13d, (%rbx,%rax,4)
	jle	.L61
	jmp	.L79
.L56:
	leal	-1(%r12), %edx
	movslq	%edx, %rax
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	addq	%r15, %rax
	cmpl	%r13d, (%rbx,%rax,4)
	jle	.L59
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	%r13d, (%rbx,%rax,4)
	movl	%ebp, 52(%rsp)
	movl	%edx, 56(%rsp)
	movl	%r15d, 60(%rsp)
	call	_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_
.L59:
	cmpl	$198, %r12d
	jg	.L61
	jmp	.L60
.L79:
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	%r13d, (%rbx,%rax,4)
	movl	%ebp, 52(%rsp)
	movl	%edx, 56(%rsp)
	movl	%r14d, 60(%rsp)
	call	_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_
.L61:
	movl	36(%rsp), %r13d
	incl	%r13d
	testl	%ebp, %ebp
	jg	.L62
.L66:
	imulq	$1000, 24(%rsp), %rax
	incl	%ebp
	movslq	%ebp, %rdx
	leaq	(%rdx,%rdx,4), %rdx
	addq	%rdx, %rax
	addq	%r15, %rax
	cmpl	%r13d, (%rbx,%rax,4)
	jle	.L55
	jmp	.L80
.L62:
	imulq	$1000, 24(%rsp), %rax
	leal	-1(%rbp), %ecx
	movslq	%ecx, %rdx
	leaq	(%rdx,%rdx,4), %rdx
	addq	%rdx, %rax
	addq	%r15, %rax
	cmpl	%r13d, (%rbx,%rax,4)
	jle	.L65
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	%r13d, (%rbx,%rax,4)
	movl	%ecx, 52(%rsp)
	movl	%r12d, 56(%rsp)
	movl	%r14d, 60(%rsp)
	call	_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_
.L65:
	cmpl	$198, %ebp
	jg	.L55
	jmp	.L66
.L80:
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	%r13d, (%rbx,%rax,4)
	movl	%ebp, 52(%rsp)
	movl	%r12d, 56(%rsp)
	movl	%r14d, 60(%rsp)
	call	_ZNSt7__cxx114listI17Point2DAndFeatureSaIS1_EE9push_backEOS1_
.LEHE0:
	jmp	.L55
.L78:
	movq	%rax, %rdi
	call	_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L71
	jmp	.L76
.L73:
	endbr64
	movq	%rax, %rbx
.L69:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EE8_M_clearEv
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	movq	%rbx, %rdi
.LEHB1:
	call	_Unwind_Resume@PLT
.LEHE1:
.L76:
	call	__stack_chk_fail@PLT
.L71:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3100:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3100:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3100-.LLSDACSB3100
.LLSDACSB3100:
	.uleb128 .LEHB0-.LFB3100
	.uleb128 .LEHE0-.LEHB0
	.uleb128 .L73-.LFB3100
	.uleb128 0
	.uleb128 .LEHB1-.LFB3100
	.uleb128 .LEHE1-.LEHB1
	.uleb128 0
	.uleb128 0
.LLSDACSE3100:
	.text
	.size	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap, .-_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
	.section	.text._ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm,"axG",@progbits,_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm,comdat
	.align 2
	.weak	_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm
	.type	_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm, @function
_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm:
.LFB3331:
	.cfi_startproc
	endbr64
	testq	%rsi, %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	0(,%rsi,4), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 32
	je	.L85
	movabsq	$2305843009213693951, %rax
	cmpq	%rsi, %rax
	jnb	.L83
	movabsq	$4611686018427387903, %rax
	cmpq	%rsi, %rax
	jnb	.L84
	call	_ZSt28__throw_bad_array_new_lengthv@PLT
.L84:
	call	_ZSt17__throw_bad_allocv@PLT
.L83:
	movq	%rbp, %rdi
	call	_Znwm@PLT
	jmp	.L82
.L85:
	xorl	%eax, %eax
.L82:
	movq	%rax, (%rbx)
	movq	%rax, 8(%rbx)
	addq	%rbp, %rax
	movq	%rax, 16(%rbx)
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3331:
	.size	_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm, .-_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm
	.section	.rodata._ZNSt6vectorIfSaIfEEC2EmRKS0_.str1.1,"aMS",@progbits,1
.LC4:
	.string	"cannot create std::vector larger than max_size()"
	.section	.text._ZNSt6vectorIfSaIfEEC2EmRKS0_,"axG",@progbits,_ZNSt6vectorIfSaIfEEC5EmRKS0_,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEEC2EmRKS0_
	.type	_ZNSt6vectorIfSaIfEEC2EmRKS0_, @function
_ZNSt6vectorIfSaIfEEC2EmRKS0_:
.LFB3201:
	.cfi_startproc
	endbr64
	movabsq	$2305843009213693951, %rax
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rcx
	.cfi_def_cfa_offset 32
	cmpq	%rsi, %rax
	jnb	.L88
	leaq	.LC4(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L88:
	xorl	%edx, %edx
	movq	%rdi, %rbp
	movq	%rsi, %rbx
	movq	%rdx, (%rdi)
	movq	%rdx, 8(%rdi)
	movq	%rdx, 16(%rdi)
	call	_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm
	movq	0(%rbp), %rax
	testq	%rbx, %rbx
	je	.L89
	movl	$0x00000000, (%rax)
	leaq	4(%rax), %rdx
	decq	%rbx
	je	.L92
	leaq	(%rdx,%rbx,4), %rcx
	movq	%rdx, %rsi
.L90:
	cmpq	%rsi, %rcx
	je	.L97
	movl	$0x00000000, (%rsi)
	addq	$4, %rsi
	jmp	.L90
.L97:
	subq	%rax, %rcx
	leaq	-4(%rdx,%rcx), %rax
	jmp	.L89
.L92:
	movq	%rdx, %rax
.L89:
	movq	%rax, 8(%rbp)
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3201:
	.size	_ZNSt6vectorIfSaIfEEC2EmRKS0_, .-_ZNSt6vectorIfSaIfEEC2EmRKS0_
	.weak	_ZNSt6vectorIfSaIfEEC1EmRKS0_
	.set	_ZNSt6vectorIfSaIfEEC1EmRKS0_,_ZNSt6vectorIfSaIfEEC2EmRKS0_
	.text
	.globl	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.type	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE, @function
_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE:
.LFB3099:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	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	%rdi, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	8(%rsi), %rsi
	subq	0(%r13), %rsi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	leaq	16(%rsp), %rbp
	sarq	$2, %rsi
	movq	%r12, %rdx
	movq	%rbp, %rdi
	call	_ZNSt6vectorIfSaIfEEC1EmRKS0_
	movq	0(%r13), %rcx
	movq	8(%r13), %rdx
	xorl	%eax, %eax
	movq	16(%rsp), %r15
	movss	.LC5(%rip), %xmm0
	subq	%rcx, %rdx
	sarq	$2, %rdx
.L99:
	cmpq	%rax, %rdx
	je	.L107
	movss	(%rcx,%rax,4), %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%r15,%rax,4)
	incq	%rax
	jmp	.L99
.L107:
	xorl	%eax, %eax
	leaq	320000(%rbx), %r14
	movl	%eax, 12(%rsp)
.L101:
	xorl	%r13d, %r13d
.L102:
	movq	24(%rsp), %rdx
	movq	%r15, %rsi
	movq	%r12, %rdi
	subq	%r15, %rdx
	sarq	$2, %rdx
	call	_Z13sampleFromPdfPjPfi
	movl	%eax, (%rbx,%r13,8)
	cltq
	incq	%r13
	leaq	(%r15,%rax,4), %rax
	movss	(%rax), %xmm0
	subss	.LC6(%rip), %xmm0
	movss	%xmm0, (%rax)
	cmpq	$200, %r13
	jne	.L102
	addq	$1600, %rbx
	cmpq	%r14, %rbx
	jne	.L101
	movq	%rbp, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L104
	call	__stack_chk_fail@PLT
.L104:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3099:
	.size	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE, .-_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.section	.rodata.str1.1
.LC8:
	.string	"generateZoningPlan: %lf\n"
.LC9:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/gnishida/CUDATest/master/complex_zone.cu"
.LC10:
	.string	"CUDA error at %s:%d\n"
.LC11:
	.string	"  %s\n"
.LC12:
	.string	"computeDistanceToStore CPU: %lf\n"
.LC13:
	.string	"computeDistanceToStore: initDistance = %lf, updateDistance = %lf\n"
.LC14:
	.string	"ERROR! %d,%d k=%d, %d != %d\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3115:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3115
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$320000, %edi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	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
	movabsq	$4453159313439771853, %rbx
	subq	$152, %rsp
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$800000, %edi
	movq	%rax, -168(%rbp)
	call	malloc@PLT
	movl	$800000, %edi
	movq	%rax, -176(%rbp)
	call	malloc@PLT
	movl	$800000, %ecx
	movl	$6, %esi
	movq	-176(%rbp), %rdi
	movq	%rax, -184(%rbp)
	movb	$15, %al
	rep stosb
	movq	-184(%rbp), %rdi
	movl	$800000, %ecx
	rep stosb
	leaq	-80(%rbp), %rax
	leaq	-104(%rbp), %rdi
	movq	%rax, %rdx
	movq	%rax, %r15
.LEHB2:
	call	_ZNSt6vectorIfSaIfEEC1EmRKS0_
.LEHE2:
	movq	-104(%rbp), %rax
	movabsq	$4489188110478868480, %rcx
	movq	%rcx, (%rax)
	movabsq	$4417130516412419277, %rcx
	movq	%rbx, 8(%rax)
	movq	%rcx, 16(%rax)
	call	clock@PLT
	xorl	%edi, %edi
	movq	-96(%rbp), %rsi
	subq	-104(%rbp), %rsi
	movq	%rdi, -80(%rbp)
	sarq	$2, %rsi
	movq	%rax, %r12
	movq	%rdi, -72(%rbp)
	movq	%rdi, -64(%rbp)
	movq	%r15, %rdi
.LEHB3:
	call	_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm
.LEHE3:
	movq	-104(%rbp), %rsi
	movq	-96(%rbp), %rbx
	movq	-80(%rbp), %rcx
	subq	%rsi, %rbx
	cmpq	$4, %rbx
	jle	.L109
	movq	%rcx, %rdi
	movq	%rbx, %rdx
	call	memmove@PLT
	movq	%rax, %rcx
	jmp	.L110
.L109:
	jne	.L110
	movss	(%rsi), %xmm0
	movss	%xmm0, (%rcx)
.L110:
	movq	-168(%rbp), %rdi
	addq	%rbx, %rcx
	movq	%r15, %rsi
	movq	%rcx, -72(%rbp)
.LEHB4:
	call	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
.LEHE4:
	movq	%r15, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	call	clock@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	divsd	.LC7(%rip), %xmm0
.LEHB5:
	call	__printf_chk@PLT
	leaq	-152(%rbp), %rdi
	movl	$320000, %esi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L111
	movl	$303, %ecx
.L174:
	leaq	.LC9(%rip), %rdx
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %rdx
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L111:
	movq	-168(%rbp), %rsi
	movl	$1, %ecx
	movl	$320000, %edx
	movq	-152(%rbp), %rdi
	call	cudaMemcpy@PLT
	movl	$304, %ecx
	testl	%eax, %eax
	jne	.L174
	leaq	-144(%rbp), %rdi
	movl	$800000, %esi
	call	cudaMalloc@PLT
	movl	$308, %ecx
	testl	%eax, %eax
	jne	.L174
	leaq	-136(%rbp), %rdi
	movl	$30720000, %esi
	call	cudaMalloc@PLT
	movl	$312, %ecx
	testl	%eax, %eax
	jne	.L174
	leaq	-128(%rbp), %rdi
	movl	$2048, %esi
	call	cudaMalloc@PLT
	movl	$314, %ecx
	testl	%eax, %eax
	jne	.L174
	call	clock@PLT
	movl	$1000, %r14d
	movq	%rax, %rbx
.L117:
	movq	-184(%rbp), %rsi
	movq	-168(%rbp), %rdi
	call	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
	movl	%r14d, %eax
	decl	%eax
	movl	%eax, %r14d
	jne	.L117
	call	clock@PLT
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	subq	%rbx, %rax
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	divsd	.LC7(%rip), %xmm0
	call	__printf_chk@PLT
	movl	$1000, %r12d
	xorl	%r14d, %r14d
	xorl	%ebx, %ebx
.L120:
	call	clock@PLT
	movl	$1073741825, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, %r13
	movl	$33554433, %eax
	salq	$2, %rdi
	movl	$1, %ecx
	salq	$7, %rax
	movl	$1, %esi
	movq	%rdi, -116(%rbp)
	movq	%rax, %rdx
	movq	%rax, -80(%rbp)
	movl	$1, -72(%rbp)
	movl	$1, -108(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L118
	movq	-128(%rbp), %rcx
	movq	-136(%rbp), %rdx
	movq	-144(%rbp), %rsi
	movq	-152(%rbp), %rdi
	call	_Z79__device_stub__Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
.L118:
	call	cudaDeviceSynchronize@PLT
	call	clock@PLT
	movd	%r14d, %xmm2
	subq	%r13, %rax
	cvtss2sd	%xmm2, %xmm1
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC7(%rip), %xmm0
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm3
	movd	%xmm3, %r14d
	call	clock@PLT
	movl	$1073741825, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, %r13
	movl	$33554433, %eax
	salq	$2, %rdi
	movl	$1, %ecx
	salq	$7, %rax
	movl	$1, %esi
	movq	%rdi, -116(%rbp)
	movq	%rax, %rdx
	movq	%rax, -80(%rbp)
	movl	$1, -72(%rbp)
	movl	$1, -108(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L119
	movq	-128(%rbp), %rcx
	movq	-136(%rbp), %rdx
	movq	-144(%rbp), %rsi
	movq	-152(%rbp), %rdi
	call	_Z89__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePiP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
.L119:
	call	cudaDeviceSynchronize@PLT
	call	clock@PLT
	movd	%ebx, %xmm4
	subq	%r13, %rax
	cvtss2sd	%xmm4, %xmm1
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC7(%rip), %xmm0
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm5
	movd	%xmm5, %ebx
	decl	%r12d
	jne	.L120
	movd	%r14d, %xmm6
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movb	$2, %al
	cvtss2sd	%xmm6, %xmm0
	cvtss2sd	%xmm5, %xmm1
	call	__printf_chk@PLT
	movq	-144(%rbp), %rsi
	movl	$2, %ecx
	movl	$800000, %edx
	movq	-176(%rbp), %rdi
	call	cudaMemcpy@PLT
	movl	$199, -188(%rbp)
	movl	$796000, %r15d
	movl	$352, %ecx
	testl	%eax, %eax
	jne	.L174
.L121:
	movq	%r15, %r14
	xorl	%ebx, %ebx
.L127:
	movq	%r14, %r13
	xorl	%r12d, %r12d
.L123:
	movq	-176(%rbp), %rax
	movl	(%rax,%r13), %r9d
	movq	-184(%rbp), %rax
	movl	(%rax,%r13), %edx
	xorl	%eax, %eax
	cmpl	%edx, %r9d
	je	.L122
	pushq	%rcx
	movl	%r12d, %r8d
	movl	%ebx, %ecx
	leaq	.LC14(%rip), %rsi
	pushq	%rdx
	movl	-188(%rbp), %edx
	movl	$2, %edi
	.cfi_escape 0x2e,0x10
	call	__printf_chk@PLT
	popq	%rax
	movb	$1, %al
	popq	%rdx
.L122:
	incl	%r12d
	xorl	$1, %eax
	addq	$4, %r13
	cmpl	$4, %r12d
	jg	.L136
	testb	%al, %al
	jne	.L123
.L136:
	incl	%ebx
	addq	$20, %r14
	cmpl	$199, %ebx
	jg	.L125
	testb	%al, %al
	jne	.L127
.L125:
	subq	$4000, %r15
	decl	-188(%rbp)
	js	.L126
	testb	%al, %al
	jne	.L121
.L126:
	movq	-152(%rbp), %rdi
	.cfi_escape 0x2e,0
	call	cudaFree@PLT
	movq	-144(%rbp), %rdi
	call	cudaFree@PLT
	movq	-168(%rbp), %rdi
	call	free@PLT
	movq	-176(%rbp), %rdi
	call	free@PLT
	movq	-184(%rbp), %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
.LEHE5:
	leaq	-104(%rbp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L131
	jmp	.L153
.L134:
	endbr64
	movq	%rax, %rbx
.L128:
	movq	%r15, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	jmp	.L129
.L135:
	endbr64
	movq	%rax, %rbx
.L129:
	leaq	-104(%rbp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L153
	movq	%rbx, %rdi
.LEHB6:
	call	_Unwind_Resume@PLT
.LEHE6:
.L153:
	call	__stack_chk_fail@PLT
.L131:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3115:
	.section	.gcc_except_table
.LLSDA3115:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3115-.LLSDACSB3115
.LLSDACSB3115:
	.uleb128 .LEHB2-.LFB3115
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB3-.LFB3115
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L135-.LFB3115
	.uleb128 0
	.uleb128 .LEHB4-.LFB3115
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L134-.LFB3115
	.uleb128 0
	.uleb128 .LEHB5-.LFB3115
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L135-.LFB3115
	.uleb128 0
	.uleb128 .LEHB6-.LFB3115
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
.LLSDACSE3115:
	.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
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	805306368
	.align 4
.LC5:
	.long	1193033728
	.align 4
.LC6:
	.long	1065353216
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC7:
	.long	0
	.long	1093567616
	.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:

﻿/**
 * Nearest neighbor search
 * マップ内に、店、工場などのゾーンがある確率で配備されている時、
 * 住宅ゾーンから直近の店、工場までのマンハッタン距離を計算する。
 *
 * 各店、工場から周辺に再帰的に距離を更新していくので、O(N)で済む。
 * しかも、GPUで並列化することで、さらに計算時間を短縮できる。
 */


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <list>
#include <time.h>

#define CITY_SIZE 200
#define NUM_GPU_BLOCKS 4
#define NUM_GPU_THREADS 128
#define NUM_FEATURES 5
#define QUEUE_SIZE 5000

#define CUDA_CALL(x) {if((x) != hipSuccess){ \
  printf("CUDA error at %s:%d\n",__FILE__,__LINE__); \
  printf("  %s\n", hipGetErrorString(hipGetLastError())); \
  exit(EXIT_FAILURE);}} 


struct ZoneType {
	int type;
	int level;
};

struct ZoningPlan {
	ZoneType zones[CITY_SIZE][CITY_SIZE];
};

struct DistanceMap {
	int distances[CITY_SIZE][CITY_SIZE][NUM_FEATURES];
};

struct Point2D {
	int x;
	int y;

	__host__ __device__
	Point2D() : x(0), y(0) {}

	__host__ __device__
	Point2D(int x, int y) : x(x), y(y) {}
};

struct Point2DAndFeature {
	int x;
	int y;
	int featureId;

	__host__ __device__
	Point2DAndFeature() : x(0), y(0), featureId(0) {}

	__host__ __device__
	Point2DAndFeature(int x, int y, int featureId) : x(x), y(y), featureId(featureId) {}
};

__host__ __device__
unsigned int rand(unsigned int* randx) {
    *randx = *randx * 1103515245 + 12345;
    return (*randx)&2147483647;
}

__host__ __device__
float randf(unsigned int* randx) {
	return rand(randx) / (float(2147483647) + 1);
}

__host__ __device__
float randf(unsigned int* randx, float a, float b) {
	return randf(randx) * (b - a) + a;
}

__host__ __device__
int sampleFromCdf(unsigned int* randx, float* cdf, int num) {
	float rnd = randf(randx, 0, cdf[num-1]);

	for (int i = 0; i < num; ++i) {
		if (rnd <= cdf[i]) return i;
	}

	return num - 1;
}

__host__ __device__
int sampleFromPdf(unsigned int* randx, float* pdf, int num) {
	if (num == 0) return 0;

	float cdf[40];
	cdf[0] = pdf[0];
	for (int i = 1; i < num; ++i) {
		if (pdf[i] >= 0) {
			cdf[i] = cdf[i - 1] + pdf[i];
		} else {
			cdf[i] = cdf[i - 1];
		}
	}

	return sampleFromCdf(randx, cdf, num);
}

/**
 * ゾーンプランを生成する。
 */
__host__
void generateZoningPlan(ZoningPlan& zoningPlan, std::vector<float> zoneTypeDistribution) {
	std::vector<float> numRemainings(zoneTypeDistribution.size());
	for (int i = 0; i < zoneTypeDistribution.size(); ++i) {
		numRemainings[i] = CITY_SIZE * CITY_SIZE * zoneTypeDistribution[i];
	}

	unsigned int randx = 0;

	for (int r = 0; r < CITY_SIZE; ++r) {
		for (int c = 0; c < CITY_SIZE; ++c) {
			int type = sampleFromPdf(&randx, numRemainings.data(), numRemainings.size());
			zoningPlan.zones[r][c].type = type;
			numRemainings[type] -= 1;
		}
	}
}




__global__
void initDistance(ZoningPlan* zoningPlan, DistanceMap* distanceMap, Point2DAndFeature* queue, int* queueEnd) {
	int idx = blockDim.x * blockIdx.x + threadIdx.x;

	queueEnd[idx] = 0;

	int stride = ceilf((float)(CITY_SIZE * CITY_SIZE) / NUM_GPU_BLOCKS / NUM_GPU_THREADS);
	
	// 分割された領域内で、店を探す
	for (int i = 0; i < stride; ++i) {
		int r = (idx * stride + i) / CITY_SIZE;
		int c = (idx * stride + i) % CITY_SIZE;
		if (r >= CITY_SIZE) continue;

		for (int feature_id = 0; feature_id < NUM_FEATURES; ++feature_id) {
			if (zoningPlan->zones[r][c].type - 1 == feature_id) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(c, r, feature_id);
				distanceMap->distances[r][c][feature_id] = 0;
			} else {
				distanceMap->distances[r][c][feature_id] = 9999;
			}

		}


	}
}



/**
 * 直近の店までの距離を計算する（マルチスレッド版）
 */
__global__
void computeDistanceToStore(ZoningPlan* zoningPlan, DistanceMap* distanceMap, Point2DAndFeature* queue, int* queueEnd) {
	int idx = blockDim.x * blockIdx.x + threadIdx.x;

	int queue_begin = 0;

	// 距離マップを生成
	while (queue_begin < queueEnd[idx]) {
		Point2DAndFeature pt = queue[idx * QUEUE_SIZE + queue_begin++];
		if (queue_begin >= QUEUE_SIZE) queue_begin = 0;

		int d = distanceMap->distances[pt.y][pt.x][pt.featureId];

		if (pt.y > 0) {
			int old = atomicMin(&distanceMap->distances[pt.y-1][pt.x][pt.featureId], d + 1);
			if (old > d + 1) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(pt.x, pt.y-1, pt.featureId);
				if (queueEnd[idx] >= QUEUE_SIZE) queueEnd[idx] = 0;
			}
		}
		if (pt.y < CITY_SIZE - 1) {
			int old = atomicMin(&distanceMap->distances[pt.y+1][pt.x][pt.featureId], d + 1);
			if (old > d + 1) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(pt.x, pt.y+1, pt.featureId);
				if (queueEnd[idx] >= QUEUE_SIZE) queueEnd[idx] = 0;
			}
		}
		if (pt.x > 0) {
			int old = atomicMin(&distanceMap->distances[pt.y][pt.x-1][pt.featureId], d + 1);
			if (old > d + 1) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(pt.x-1, pt.y, pt.featureId);
				if (queueEnd[idx] >= QUEUE_SIZE) queueEnd[idx] = 0;
			}
		}
		if (pt.x < CITY_SIZE - 1) {
			int old = atomicMin(&distanceMap->distances[pt.y][pt.x+1][pt.featureId], d + 1);
			if (old > d + 1) {
				queue[idx * QUEUE_SIZE + queueEnd[idx]++] = Point2DAndFeature(pt.x+1, pt.y, pt.featureId);
				if (queueEnd[idx] >= QUEUE_SIZE) queueEnd[idx] = 0;
			}
		}
	}
}

/**
 * 直近の店までの距離を計算する（CPU版）
 */
__host__
void computeDistanceToStoreCPU(ZoningPlan* zoningPLan, DistanceMap* distanceMap) {
	std::list<Point2DAndFeature> queue;

	for (int feature_id = 0; feature_id < NUM_FEATURES; ++feature_id) {
		for (int cell_id = 0; cell_id < CITY_SIZE * CITY_SIZE; ++cell_id) {
			int r = cell_id / CITY_SIZE;
			int c = cell_id % CITY_SIZE;

			if (zoningPLan->zones[r][c].type - 1== feature_id) {
				queue.push_back(Point2DAndFeature(c, r, feature_id));
				distanceMap->distances[r][c][feature_id] = 0;
			} else {
				distanceMap->distances[r][c][feature_id] = 9999;
			}
		}
	}

	while (!queue.empty()) {
		Point2DAndFeature pt = queue.front();
		queue.pop_front();

		int d = distanceMap->distances[pt.y][pt.x][pt.featureId];

		if (pt.y > 0) {
			if (distanceMap->distances[pt.y-1][pt.x][pt.featureId] > d + 1) {
				distanceMap->distances[pt.y-1][pt.x][pt.featureId] = d + 1;
				queue.push_back(Point2DAndFeature(pt.x, pt.y-1, pt.featureId));
			}
		}
		if (pt.y < CITY_SIZE - 1) {
			if (distanceMap->distances[pt.y+1][pt.x][pt.featureId] > d + 1) {
				distanceMap->distances[pt.y+1][pt.x][pt.featureId] = d + 1;
				queue.push_back(Point2DAndFeature(pt.x, pt.y+1, pt.featureId));
			}
		}
		if (pt.x > 0) {
			if (distanceMap->distances[pt.y][pt.x-1][pt.featureId] > d + 1) {
				distanceMap->distances[pt.y][pt.x-1][pt.featureId] = d + 1;
				queue.push_back(Point2DAndFeature(pt.x-1, pt.y, pt.featureId));
			}
		}
		if (pt.x < CITY_SIZE - 1) {
			if (distanceMap->distances[pt.y][pt.x+1][pt.featureId] > d + 1) {
				distanceMap->distances[pt.y][pt.x+1][pt.featureId] = d + 1;
				queue.push_back(Point2DAndFeature(pt.x+1, pt.y, pt.featureId));
			}
		}
	}
}

int main()
{
	time_t start, end;


	ZoningPlan* hostZoningPlan = (ZoningPlan*)malloc(sizeof(ZoningPlan));
	DistanceMap* hostDistanceMap = (DistanceMap*)malloc(sizeof(DistanceMap));
	DistanceMap* hostDistanceMap2 = (DistanceMap*)malloc(sizeof(DistanceMap));

	// 距離を初期化
	memset(hostDistanceMap, 9999, sizeof(DistanceMap));
	memset(hostDistanceMap2, 9999, sizeof(DistanceMap));

	std::vector<float> zoneTypeDistribution(6);
	zoneTypeDistribution[0] = 0.5f;
	zoneTypeDistribution[1] = 0.2f;
	zoneTypeDistribution[2] = 0.1f;
	zoneTypeDistribution[3] = 0.1f;
	zoneTypeDistribution[4] = 0.05f;
	zoneTypeDistribution[5] = 0.05f;
	
	// 初期プランを生成
	start = clock();
	generateZoningPlan(*hostZoningPlan, zoneTypeDistribution);
	end = clock();
	printf("generateZoningPlan: %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
	
	// デバッグ用
	if (CITY_SIZE <= 100) {
		for (int r = CITY_SIZE - 1; r >= 0; --r) {
			for (int c = 0; c < CITY_SIZE; ++c) {
				printf("%d, ", hostZoningPlan->zones[r][c].type);
			}
			printf("\n");
		}
		printf("\n");
	}

	// 初期プランをデバイスバッファへコピー
	ZoningPlan* devZoningPlan;
	CUDA_CALL(hipMalloc((void**)&devZoningPlan, sizeof(ZoningPlan)));
	CUDA_CALL(hipMemcpy(devZoningPlan, hostZoningPlan, sizeof(ZoningPlan), hipMemcpyHostToDevice));

	// 距離マップ用に、デバイスバッファを確保
	DistanceMap* devDistanceMap;
	CUDA_CALL(hipMalloc((void**)&devDistanceMap, sizeof(DistanceMap)));

	// キュー用にデバイスバッファを確保
	Point2DAndFeature* devQueue;
	CUDA_CALL(hipMalloc((void**)&devQueue, sizeof(Point2DAndFeature) * QUEUE_SIZE * NUM_GPU_BLOCKS * NUM_GPU_THREADS));
	int* devQueueEnd;
	CUDA_CALL(hipMalloc((void**)&devQueueEnd, sizeof(int) * NUM_GPU_BLOCKS * NUM_GPU_THREADS));



	///////////////////////////////////////////////////////////////////////
	// CPU版で、直近の店までの距離を計算
	start = clock();
	for (int iter = 0; iter < 1000; ++iter) {
		computeDistanceToStoreCPU(hostZoningPlan, hostDistanceMap2);
	}
	end = clock();
	printf("computeDistanceToStore CPU: %lf\n", (double)(end-start)/CLOCKS_PER_SEC);







	///////////////////////////////////////////////////////////////////////
	// マルチスレッドで、直近の店までの距離を計算
	float elapsed1 = 0.0f;
	float elapsed2 = 0.0f;
	for (int iter = 0; iter < 1000; ++iter) {
		start = clock();
		initDistance<<<NUM_GPU_BLOCKS, NUM_GPU_THREADS>>>(devZoningPlan, devDistanceMap, devQueue, devQueueEnd);
		hipDeviceSynchronize();
		end = clock();
		elapsed1 += (double)(end-start)/CLOCKS_PER_SEC;
		start = clock();
		computeDistanceToStore<<<NUM_GPU_BLOCKS, NUM_GPU_THREADS>>>(devZoningPlan, devDistanceMap, devQueue, devQueueEnd);
		hipDeviceSynchronize();
		end = clock();
		elapsed2 += (double)(end-start)/CLOCKS_PER_SEC;
	}
	printf("computeDistanceToStore: initDistance = %lf, updateDistance = %lf\n", elapsed1, elapsed2);

	// 距離をCPUバッファへコピー
	CUDA_CALL(hipMemcpy(hostDistanceMap, devDistanceMap, sizeof(DistanceMap), hipMemcpyDeviceToHost));


	
	// CPU版とマルチスレッドの結果を比較
	int bad_k = 0;
	bool err = false;
	{	
		for (int r = CITY_SIZE - 1; r >= 0 && !err; --r) {
			for (int c = 0; c < CITY_SIZE && !err; ++c) {
				for (int k = 0; k < NUM_FEATURES && !err; ++k) {
					if (hostDistanceMap->distances[r][c][k] != hostDistanceMap2->distances[r][c][k]) {
						err = true;
						printf("ERROR! %d,%d k=%d, %d != %d\n", r, c, k, hostDistanceMap->distances[r][c][k], hostDistanceMap2->distances[r][c][k]);
						bad_k = k;
					}
				}
			}

		}
	}


	// デバッグ用
	if (CITY_SIZE <= 100 && err) {
		for (int r = CITY_SIZE - 1; r >= 0; --r) {
			for (int c = 0; c < CITY_SIZE; ++c) {
				printf("%d, ", hostDistanceMap->distances[r][c][bad_k]);
			}
			printf("\n");
		}
		printf("\n");

		for (int r = CITY_SIZE - 1; r >= 0; --r) {
			for (int c = 0; c < CITY_SIZE; ++c) {
				printf("%d, ", hostDistanceMap2->distances[r][c][bad_k]);
			}
			printf("\n");
		}
		printf("\n");
	}


	// デバイスバッファの開放
	hipFree(devZoningPlan);
	hipFree(devDistanceMap);

	// CPUバッファの開放
	free(hostZoningPlan);
	free(hostDistanceMap);
	free(hostDistanceMap2);

	hipDeviceReset();
}

	.text
	.file	"complex_zone.hip"
	.globl	_Z4randPj                       # -- Begin function _Z4randPj
	.type	_Z4randPj,@function
_Z4randPj:                              # @_Z4randPj
	.cfi_startproc
# %bb.0:
	imull	$1103515245, (%rdi), %eax       # imm = 0x41C64E6D
	addl	$12345, %eax                    # imm = 0x3039
	movl	%eax, (%rdi)
	andl	$2147483647, %eax               # imm = 0x7FFFFFFF
	retq
.Lfunc_end0:
	.size	_Z4randPj, .Lfunc_end0-_Z4randPj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z5randfPj
.LCPI1_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	_Z5randfPj
	.type	_Z5randfPj,@function
_Z5randfPj:                             # @_Z5randfPj
	.cfi_startproc
# %bb.0:
	imull	$1103515245, (%rdi), %eax       # imm = 0x41C64E6D
	addl	$12345, %eax                    # imm = 0x3039
	movl	%eax, (%rdi)
	andl	$2147483647, %eax               # imm = 0x7FFFFFFF
	cvtsi2ss	%eax, %xmm0
	mulss	.LCPI1_0(%rip), %xmm0
	retq
.Lfunc_end1:
	.size	_Z5randfPj, .Lfunc_end1-_Z5randfPj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z5randfPjff
.LCPI2_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	_Z5randfPjff
	.type	_Z5randfPjff,@function
_Z5randfPjff:                           # @_Z5randfPjff
	.cfi_startproc
# %bb.0:
	imull	$1103515245, (%rdi), %eax       # imm = 0x41C64E6D
	addl	$12345, %eax                    # imm = 0x3039
	movl	%eax, (%rdi)
	andl	$2147483647, %eax               # imm = 0x7FFFFFFF
	cvtsi2ss	%eax, %xmm2
	mulss	.LCPI2_0(%rip), %xmm2
	subss	%xmm0, %xmm1
	mulss	%xmm1, %xmm2
	addss	%xmm2, %xmm0
	retq
.Lfunc_end2:
	.size	_Z5randfPjff, .Lfunc_end2-_Z5randfPjff
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z13sampleFromCdfPjPfi
.LCPI3_0:
	.long	0x30000000                      # float 4.65661287E-10
	.text
	.globl	_Z13sampleFromCdfPjPfi
	.type	_Z13sampleFromCdfPjPfi,@function
_Z13sampleFromCdfPjPfi:                 # @_Z13sampleFromCdfPjPfi
	.cfi_startproc
# %bb.0:
                                        # kill: def $edx killed $edx def $rdx
	imull	$1103515245, (%rdi), %ecx       # imm = 0x41C64E6D
	addl	$12345, %ecx                    # imm = 0x3039
	movl	%ecx, %eax
	andl	$2147483647, %eax               # imm = 0x7FFFFFFF
	cvtsi2ss	%eax, %xmm0
	leal	-1(%rdx), %eax
	movslq	%edx, %r8
	mulss	.LCPI3_0(%rip), %xmm0
	mulss	-4(%rsi,%r8,4), %xmm0
	movl	%ecx, (%rdi)
	testl	%r8d, %r8d
	jle	.LBB3_5
# %bb.1:                                # %.lr.ph.preheader
	xorps	%xmm1, %xmm1
	addss	%xmm1, %xmm0
	movl	%edx, %edx
	xorl	%ecx, %ecx
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rsi,%rcx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jae	.LBB3_4
# %bb.3:                                #   in Loop: Header=BB3_2 Depth=1
	incq	%rcx
	cmpq	%rcx, %rdx
	jne	.LBB3_2
.LBB3_5:                                # %._crit_edge
	retq
.LBB3_4:                                # %._crit_edge.loopexit.split.loop.exit
	movl	%ecx, %eax
	retq
.Lfunc_end3:
	.size	_Z13sampleFromCdfPjPfi, .Lfunc_end3-_Z13sampleFromCdfPjPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z13sampleFromPdfPjPfi
.LCPI4_0:
	.long	0x80000000                      # float -0
	.text
	.globl	_Z13sampleFromPdfPjPfi
	.type	_Z13sampleFromPdfPjPfi,@function
_Z13sampleFromPdfPjPfi:                 # @_Z13sampleFromPdfPjPfi
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	je	.LBB4_1
# %bb.2:
	subq	$168, %rsp
	.cfi_def_cfa_offset 176
	movss	(%rsi), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rsp)
	cmpl	$2, %edx
	jl	.LBB4_5
# %bb.3:                                # %.lr.ph.preheader
	movl	%edx, %eax
	movl	$1, %ecx
	movss	.LCPI4_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
.LBB4_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rsi,%rcx,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	xorps	%xmm3, %xmm3
	cmpnless	%xmm2, %xmm3
	movaps	%xmm3, %xmm4
	andnps	%xmm2, %xmm4
	andps	%xmm1, %xmm3
	orps	%xmm4, %xmm3
	addss	%xmm3, %xmm0
	movss	%xmm0, (%rsp,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB4_4
.LBB4_5:                                # %._crit_edge
	movq	%rsp, %rsi
	callq	_Z13sampleFromCdfPjPfi
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	retq
.LBB4_1:
	xorl	%eax, %eax
	retq
.Lfunc_end4:
	.size	_Z13sampleFromPdfPjPfi, .Lfunc_end4-_Z13sampleFromPdfPjPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
.LCPI5_0:
	.long	0x471c4000                      # float 4.0E+4
.LCPI5_1:
	.long	0xbf800000                      # float -1
	.text
	.globl	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.type	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE,@function
_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE: # @_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.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, %r14
	movq	%rdi, %rbx
	movq	8(%rsi), %rsi
	subq	(%r14), %rsi
	sarq	$2, %rsi
	leaq	16(%rsp), %r15
	leaq	12(%rsp), %rdx
	movq	%r15, %rdi
	callq	_ZNSt6vectorIfSaIfEEC2EmRKS0_
	movq	(%r14), %rax
	movq	8(%r14), %rcx
	movq	(%r15), %r14
	subq	%rax, %rcx
	je	.LBB5_3
# %bb.1:                                # %.lr.ph
	sarq	$2, %rcx
	cmpq	$1, %rcx
	adcq	$0, %rcx
	xorl	%edx, %edx
	movss	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB5_2:                                # =>This Inner Loop Header: Depth=1
	movss	(%rax,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%r14,%rdx,4)
	incq	%rdx
	cmpq	%rdx, %rcx
	jne	.LBB5_2
.LBB5_3:                                # %._crit_edge
	leaq	12(%rsp), %r15
	movl	$0, (%r15)
	movq	24(%rsp), %r12
	subq	%r14, %r12
	shrq	$2, %r12
	xorl	%r13d, %r13d
.LBB5_4:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_5 Depth 2
	xorl	%ebp, %ebp
.LBB5_5:                                #   Parent Loop BB5_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r15, %rdi
	movq	%r14, %rsi
	movl	%r12d, %edx
	callq	_Z13sampleFromPdfPjPfi
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movl	%eax, (%rbx,%rbp,8)
	cltq
	movss	(%r14,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	%xmm1, %xmm0
	movss	%xmm0, (%r14,%rax,4)
	incq	%rbp
	cmpq	$200, %rbp
	jne	.LBB5_5
# %bb.6:                                #   in Loop: Header=BB5_4 Depth=1
	incq	%r13
	addq	$1600, %rbx                     # imm = 0x640
	cmpq	$200, %r13
	jne	.LBB5_4
# %bb.7:                                # %_ZNSt6vectorIfSaIfEED2Ev.exit
	movq	%r14, %rdi
	callq	_ZdlPv
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE, .Lfunc_end5-_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorIfSaIfEEC2EmRKS0_,"axG",@progbits,_ZNSt6vectorIfSaIfEEC2EmRKS0_,comdat
	.weak	_ZNSt6vectorIfSaIfEEC2EmRKS0_   # -- Begin function _ZNSt6vectorIfSaIfEEC2EmRKS0_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIfSaIfEEC2EmRKS0_,@function
_ZNSt6vectorIfSaIfEEC2EmRKS0_:          # @_ZNSt6vectorIfSaIfEEC2EmRKS0_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rax
	shrq	$61, %rax
	jne	.LBB6_7
# %bb.1:                                # %_ZNSt6vectorIfSaIfEE17_S_check_init_lenEmRKS0_.exit
	movq	%rsi, %r14
	movq	%rdi, %rbx
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rdi)
	movq	$0, 16(%rdi)
	testq	%rsi, %rsi
	je	.LBB6_2
# %bb.3:
	movq	%rbx, %rdi
	movq	%r14, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIfE8allocateEmPKv
	movq	%rax, (%rbx)
	leaq	(%rax,%r14,4), %r15
	movq	%r15, 16(%rbx)
	movl	$0, (%rax)
	addq	$4, %rax
	cmpq	$1, %r14
	jne	.LBB6_5
# %bb.4:
	movq	%rax, %r15
	jmp	.LBB6_6
.LBB6_2:                                # %_ZNSt12_Vector_baseIfSaIfEEC2EmRKS0_.exit.thread
	movups	%xmm0, (%rbx)
	movq	$0, 16(%rbx)
	xorl	%r15d, %r15d
	jmp	.LBB6_6
.LBB6_5:                                # %_ZSt6fill_nIPfmfET_S1_T0_RKT1_.exit.loopexit.i.i.i.i
	leaq	-4(,%r14,4), %rdx
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.LBB6_6:
	movq	%r15, 8(%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB6_7:
	.cfi_def_cfa_offset 32
	movl	$.L.str.7, %edi
	callq	_ZSt20__throw_length_errorPKc
.Lfunc_end6:
	.size	_ZNSt6vectorIfSaIfEEC2EmRKS0_, .Lfunc_end6-_ZNSt6vectorIfSaIfEEC2EmRKS0_
	.cfi_endproc
                                        # -- End function
	.text
	.globl	_Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi # -- Begin function _Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.type	_Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi,@function
_Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi: # @_Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	_Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, .Lfunc_end7-_Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.cfi_endproc
                                        # -- End function
	.globl	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi # -- Begin function _Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.type	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi,@function
_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi: # @_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, .Lfunc_end8-_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.cfi_endproc
                                        # -- End function
	.globl	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap # -- Begin function _Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
	.type	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap,@function
_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap: # @_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
.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	$88, %rsp
	.cfi_def_cfa_offset 144
	.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	%rdi, %r15
	leaq	32(%rsp), %rbx
	movq	%rbx, 8(%rbx)
	movq	%rbx, (%rbx)
	movq	$0, 16(%rbx)
	xorl	%r14d, %r14d
	movq	%rsi, 56(%rsp)                  # 8-byte Spill
	movq	%rsi, %r12
.LBB9_1:                                # %.preheader115
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_2 Depth 2
	movq	%r12, %r13
	xorl	%ebp, %ebp
.LBB9_2:                                #   Parent Loop BB9_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r15,%rbp,8), %ecx
	decl	%ecx
	movl	$9999, %eax                     # imm = 0x270F
	cmpq	%rcx, %r14
	jne	.LBB9_5
# %bb.3:                                #   in Loop: Header=BB9_2 Depth=2
.Ltmp0:
	movl	$32, %edi
	callq	_Znwm
.Ltmp1:
# %bb.4:                                #   in Loop: Header=BB9_2 Depth=2
	movl	%ebp, %ecx
	imulq	$1374389535, %rcx, %rcx         # imm = 0x51EB851F
	shrq	$38, %rcx
	imull	$-200, %ecx, %ecx
	movzwl	%bp, %edx
	shrl	$3, %edx
	imull	$5243, %edx, %edx               # imm = 0x147B
	shrl	$17, %edx
	addq	%rbp, %rcx
	movl	%ecx, 16(%rax)
	movl	%edx, 20(%rax)
	movl	%r14d, 24(%rax)
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	48(%rsp)
	xorl	%eax, %eax
.LBB9_5:                                #   in Loop: Header=BB9_2 Depth=2
	movl	%eax, (%r13)
	incq	%rbp
	addq	$20, %r13
	cmpl	$40000, %ebp                    # imm = 0x9C40
	jne	.LBB9_2
# %bb.6:                                #   in Loop: Header=BB9_1 Depth=1
	incq	%r14
	addq	$4, %r12
	cmpq	$5, %r14
	jne	.LBB9_1
	jmp	.LBB9_7
.LBB9_8:                                # %.lr.ph
                                        #   in Loop: Header=BB9_7 Depth=1
	movl	16(%r15), %eax
	movl	24(%r15), %ebp
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movslq	%eax, %r14
	movslq	20(%r15), %r12
	decq	48(%rsp)
	movq	%r15, %rdi
	callq	_ZNSt8__detail15_List_node_base9_M_unhookEv
	movq	%r15, %rdi
	callq	_ZdlPv
	movq	%r12, %rdx
	imulq	$4000, %r12, %rsi               # imm = 0xFA0
	movq	56(%rsp), %rcx                  # 8-byte Reload
	addq	%rcx, %rsi
	movl	%ebp, 12(%rsp)                  # 4-byte Spill
	movslq	%ebp, %r15
	leaq	(%r14,%r14,4), %r13
	leaq	(%rsi,%r13,4), %rax
	movl	(%rax,%r15,4), %r12d
	testq	%rdx, %rdx
	movq	%r14, 64(%rsp)                  # 8-byte Spill
	jle	.LBB9_9
# %bb.10:                               #   in Loop: Header=BB9_7 Depth=1
	leal	-1(%rdx), %edi
	imulq	$4000, %rdi, %rax               # imm = 0xFA0
	addq	%rcx, %rax
	leaq	(%rax,%r13,4), %rax
	leal	1(%r12), %ebp
	cmpl	%ebp, (%rax,%r15,4)
	jle	.LBB9_13
# %bb.11:                               #   in Loop: Header=BB9_7 Depth=1
	movq	%rdi, 72(%rsp)                  # 8-byte Spill
	movq	%rsi, 24(%rsp)                  # 8-byte Spill
	movq	%rdx, 80(%rsp)                  # 8-byte Spill
	leaq	(%rax,%r15,4), %rax
	movl	%ebp, (%rax)
.Ltmp3:
	movl	$32, %edi
	callq	_Znwm
.Ltmp4:
# %bb.12:                               #   in Loop: Header=BB9_7 Depth=1
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movl	%ecx, 16(%rax)
	movq	72(%rsp), %rcx                  # 8-byte Reload
	movl	%ecx, 20(%rax)
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ecx, 24(%rax)
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	48(%rsp)
	movq	56(%rsp), %rcx                  # 8-byte Reload
	movq	80(%rsp), %rdx                  # 8-byte Reload
	movq	24(%rsp), %rsi                  # 8-byte Reload
.LBB9_13:                               #   in Loop: Header=BB9_7 Depth=1
	cmpl	$198, %edx
	jbe	.LBB9_14
	jmp	.LBB9_17
.LBB9_9:                                # %.lr.ph..thread_crit_edge
                                        #   in Loop: Header=BB9_7 Depth=1
	leal	1(%r12), %ebp
.LBB9_14:                               # %.thread
                                        #   in Loop: Header=BB9_7 Depth=1
	movq	%rdx, %r14
	incq	%r14
	imulq	$4000, %r14, %rax               # imm = 0xFA0
	addq	%rcx, %rax
	leaq	(%rax,%r13,4), %rax
	cmpl	%ebp, (%rax,%r15,4)
	jle	.LBB9_17
# %bb.15:                               #   in Loop: Header=BB9_7 Depth=1
	movq	%rsi, 24(%rsp)                  # 8-byte Spill
	movq	%rdx, %r13
	leaq	(%rax,%r15,4), %rax
	movl	%ebp, (%rax)
.Ltmp6:
	movl	$32, %edi
	callq	_Znwm
.Ltmp7:
# %bb.16:                               #   in Loop: Header=BB9_7 Depth=1
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movl	%ecx, 16(%rax)
	movl	%r14d, 20(%rax)
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ecx, 24(%rax)
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	48(%rsp)
	movq	%r13, %rdx
	movq	24(%rsp), %rsi                  # 8-byte Reload
.LBB9_17:                               #   in Loop: Header=BB9_7 Depth=1
	movq	16(%rsp), %rcx                  # 8-byte Reload
	testl	%ecx, %ecx
	jle	.LBB9_18
# %bb.19:                               #   in Loop: Header=BB9_7 Depth=1
	leal	-1(%rcx), %r14d
	leaq	(%r14,%r14,4), %rax
	leaq	(%rsi,%rax,4), %rax
	incl	%r12d
	cmpl	%r12d, (%rax,%r15,4)
	jle	.LBB9_22
# %bb.20:                               #   in Loop: Header=BB9_7 Depth=1
	movq	%rsi, %rbp
	movq	%rdx, %r13
	leaq	(%rax,%r15,4), %rax
	movl	%r12d, (%rax)
.Ltmp9:
	movl	$32, %edi
	callq	_Znwm
.Ltmp10:
# %bb.21:                               #   in Loop: Header=BB9_7 Depth=1
	movl	%r14d, 16(%rax)
	movl	%r13d, 20(%rax)
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ecx, 24(%rax)
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	movq	%r13, %rdx
	incq	48(%rsp)
	movq	%rbp, %rsi
	movq	16(%rsp), %rcx                  # 8-byte Reload
.LBB9_22:                               #   in Loop: Header=BB9_7 Depth=1
	cmpl	$198, %ecx
	movq	64(%rsp), %r14                  # 8-byte Reload
	ja	.LBB9_7
	jmp	.LBB9_23
.LBB9_18:                               # %..thread112_crit_edge
                                        #   in Loop: Header=BB9_7 Depth=1
	incl	%r12d
	movq	64(%rsp), %r14                  # 8-byte Reload
.LBB9_23:                               # %.thread112
                                        #   in Loop: Header=BB9_7 Depth=1
	incq	%r14
	leaq	(%r14,%r14,4), %rax
	leaq	(%rsi,%rax,4), %rax
	cmpl	%r12d, (%rax,%r15,4)
	jle	.LBB9_7
# %bb.24:                               #   in Loop: Header=BB9_7 Depth=1
	movq	%rdx, %r13
	leaq	(%rax,%r15,4), %rax
	movl	%r12d, (%rax)
.Ltmp12:
	movl	$32, %edi
	callq	_Znwm
.Ltmp13:
# %bb.25:                               #   in Loop: Header=BB9_7 Depth=1
	movl	%r14d, 16(%rax)
	movl	%r13d, 20(%rax)
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ecx, 24(%rax)
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	48(%rsp)
.LBB9_7:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	32(%rsp), %r15
	cmpq	%rbx, %r15
	jne	.LBB9_8
# %bb.26:                               # %_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EED2Ev.exit
	addq	$88, %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
.LBB9_33:
	.cfi_def_cfa_offset 144
.Ltmp11:
	jmp	.LBB9_28
.LBB9_31:
.Ltmp5:
	jmp	.LBB9_28
.LBB9_34:
.Ltmp14:
	jmp	.LBB9_28
.LBB9_32:
.Ltmp8:
	jmp	.LBB9_28
.LBB9_27:
.Ltmp2:
.LBB9_28:
	movq	%rax, %r14
	movq	32(%rsp), %rdi
	cmpq	%rbx, %rdi
	je	.LBB9_30
.LBB9_29:                               # %.lr.ph.i.i95
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rdi), %r15
	callq	_ZdlPv
	movq	%r15, %rdi
	cmpq	%rbx, %r15
	jne	.LBB9_29
.LBB9_30:                               # %_ZNSt7__cxx1110_List_baseI17Point2DAndFeatureSaIS1_EED2Ev.exit98
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end9:
	.size	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap, .Lfunc_end9-_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table9:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 1 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp10-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp10
	.uleb128 .Ltmp11-.Lfunc_begin0          #     jumps to .Ltmp11
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp12-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp13-.Ltmp12                #   Call between .Ltmp12 and .Ltmp13
	.uleb128 .Ltmp14-.Lfunc_begin0          #     jumps to .Ltmp14
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp13-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Lfunc_end9-.Ltmp13            #   Call between .Ltmp13 and .Lfunc_end9
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI10_0:
	.long	0x3f000000                      # float 0.5
	.long	0x3e4ccccd                      # float 0.200000003
	.long	0x3dcccccd                      # float 0.100000001
	.long	0x3dcccccd                      # float 0.100000001
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI10_1:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %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	$120, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$320000, %edi                   # imm = 0x4E200
	callq	malloc
	movq	%rax, %rbx
	movl	$800000, %edi                   # imm = 0xC3500
	callq	malloc
	movq	%rax, %r14
	movl	$800000, %edi                   # imm = 0xC3500
	callq	malloc
	movq	%rax, %r15
	movl	$800000, %edx                   # imm = 0xC3500
	movq	%r14, 56(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	movl	$15, %esi
	callq	memset@PLT
	movl	$800000, %edx                   # imm = 0xC3500
	movq	%r15, %rdi
	movl	$15, %esi
	callq	memset@PLT
	movl	$24, %edi
	callq	_Znwm
	leaq	96(%rsp), %r13
	movq	%rax, (%r13)
	leaq	24(%rax), %rcx
	movq	%rcx, 16(%r13)
	movq	%rcx, 8(%r13)
	movaps	.LCPI10_0(%rip), %xmm0          # xmm0 = [5.0E-1,2.00000003E-1,1.00000001E-1,1.00000001E-1]
	movups	%xmm0, (%rax)
	movabsq	$4417130516412419277, %rcx      # imm = 0x3D4CCCCD3D4CCCCD
	movq	%rcx, 16(%rax)
	callq	clock
	movq	%rax, %r12
.Ltmp15:
	leaq	72(%rsp), %rdi
	movq	%r13, %rsi
	callq	_ZNSt6vectorIfSaIfEEC2ERKS1_
.Ltmp16:
# %bb.1:
.Ltmp18:
	leaq	72(%rsp), %rsi
	movq	%rbx, %rdi
	callq	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
.Ltmp19:
# %bb.2:
	movq	72(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB10_4
# %bb.3:
	callq	_ZdlPv
.LBB10_4:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit
	callq	clock
	subq	%r12, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI10_1(%rip), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
.Ltmp21:
	leaq	24(%rsp), %rdi
	movl	$320000, %esi                   # imm = 0x4E200
	callq	hipMalloc
.Ltmp22:
# %bb.5:
	testl	%eax, %eax
	jne	.LBB10_6
# %bb.13:
	movq	24(%rsp), %rdi
.Ltmp27:
	movl	$320000, %edx                   # imm = 0x4E200
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp28:
# %bb.14:
	testl	%eax, %eax
	jne	.LBB10_15
# %bb.17:
.Ltmp34:
	leaq	16(%rsp), %rdi
	movl	$800000, %esi                   # imm = 0xC3500
	callq	hipMalloc
.Ltmp35:
# %bb.18:
	testl	%eax, %eax
	jne	.LBB10_19
# %bb.22:
.Ltmp41:
	leaq	48(%rsp), %rdi
	movl	$30720000, %esi                 # imm = 0x1D4C000
	callq	hipMalloc
.Ltmp42:
# %bb.23:
	testl	%eax, %eax
	jne	.LBB10_24
# %bb.27:
.Ltmp48:
	leaq	40(%rsp), %rdi
	movl	$2048, %esi                     # imm = 0x800
	callq	hipMalloc
.Ltmp49:
# %bb.28:
	testl	%eax, %eax
	jne	.LBB10_29
# %bb.32:
	movl	$1000, %ebp                     # imm = 0x3E8
	callq	clock
	movq	%rax, %r12
.LBB10_33:                              # =>This Inner Loop Header: Depth=1
.Ltmp55:
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
.Ltmp56:
# %bb.34:                               #   in Loop: Header=BB10_33 Depth=1
	decl	%ebp
	jne	.LBB10_33
# %bb.35:
	callq	clock
	subq	%r12, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI10_1(%rip), %xmm0
	movl	$.L.str.4, %edi
	movb	$1, %al
	callq	printf
	xorpd	%xmm0, %xmm0
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movl	$1000, %r14d                    # imm = 0x3E8
	movabsq	$4294967300, %r12               # imm = 0x100000004
	movabsq	$4294967424, %r13               # imm = 0x100000080
	xorps	%xmm1, %xmm1
.LBB10_36:                              # =>This Inner Loop Header: Depth=1
	movss	%xmm1, 36(%rsp)                 # 4-byte Spill
	callq	clock
	movq	%rax, %rbp
.Ltmp58:
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp59:
# %bb.37:                               #   in Loop: Header=BB10_36 Depth=1
	testl	%eax, %eax
	jne	.LBB10_39
# %bb.38:                               #   in Loop: Header=BB10_36 Depth=1
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rcx
.Ltmp60:
	callq	_Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
.Ltmp61:
.LBB10_39:                              #   in Loop: Header=BB10_36 Depth=1
.Ltmp62:
	callq	hipDeviceSynchronize
.Ltmp63:
# %bb.40:                               #   in Loop: Header=BB10_36 Depth=1
	callq	clock
	subq	%rbp, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI10_1(%rip), %xmm0
	movsd	%xmm0, 64(%rsp)                 # 8-byte Spill
	callq	clock
	movq	%rax, %rbp
.Ltmp64:
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp65:
# %bb.41:                               #   in Loop: Header=BB10_36 Depth=1
	testl	%eax, %eax
	jne	.LBB10_43
# %bb.42:                               #   in Loop: Header=BB10_36 Depth=1
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rcx
.Ltmp66:
	callq	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
.Ltmp67:
.LBB10_43:                              #   in Loop: Header=BB10_36 Depth=1
.Ltmp68:
	callq	hipDeviceSynchronize
.Ltmp69:
# %bb.44:                               #   in Loop: Header=BB10_36 Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	12(%rsp), %xmm0                 # 4-byte Folded Reload
	movsd	64(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	addsd	%xmm0, %xmm1
	xorps	%xmm0, %xmm0
	cvtsd2ss	%xmm1, %xmm0
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	callq	clock
	subq	%rbp, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI10_1(%rip), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	36(%rsp), %xmm1                 # 4-byte Folded Reload
	addsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	decl	%r14d
	jne	.LBB10_36
# %bb.45:
	xorps	%xmm0, %xmm0
	cvtss2sd	12(%rsp), %xmm0                 # 4-byte Folded Reload
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.5, %edi
	movb	$2, %al
	callq	printf
	movq	16(%rsp), %rsi
.Ltmp71:
	movl	$800000, %edx                   # imm = 0xC3500
	movq	56(%rsp), %r12                  # 8-byte Reload
	movq	%r12, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp72:
# %bb.46:
	testl	%eax, %eax
	jne	.LBB10_54
# %bb.47:                               # %.preheader121.preheader
	movl	$796000, %ecx                   # imm = 0xC2560
	movq	%r12, %rax
	addq	%rcx, %rax
	movq	%r15, %rdi
	addq	%rcx, %rdi
	movl	$199, %esi
	movq	$-4000, %r10                    # imm = 0xF060
.LBB10_48:                              # %.preheader121
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_49 Depth 2
                                        #       Child Loop BB10_50 Depth 3
	movq	%rdi, %r11
	movq	%rax, %r14
	xorl	%edx, %edx
.LBB10_49:                              # %.preheader
                                        #   Parent Loop BB10_48 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB10_50 Depth 3
	xorl	%ecx, %ecx
.LBB10_50:                              # %.lr.ph
                                        #   Parent Loop BB10_48 Depth=1
                                        #     Parent Loop BB10_49 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%r14,%rcx,4), %r8d
	movl	(%r11,%rcx,4), %r9d
	cmpl	%r9d, %r8d
	jne	.LBB10_51
# %bb.57:                               #   in Loop: Header=BB10_50 Depth=3
	leaq	1(%rcx), %r8
	cmpq	$4, %rcx
	movq	%r8, %rcx
	jb	.LBB10_50
# %bb.58:                               # %._crit_edge
                                        #   in Loop: Header=BB10_49 Depth=2
	leaq	1(%rdx), %rcx
	addq	$20, %r14
	addq	$20, %r11
	cmpq	$199, %rdx
	movq	%rcx, %rdx
	jb	.LBB10_49
# %bb.59:                               # %._crit_edge135
                                        #   in Loop: Header=BB10_48 Depth=1
	addq	%r10, %rax
	addq	%r10, %rdi
	subq	$1, %rsi
	jae	.LBB10_48
	jmp	.LBB10_60
.LBB10_51:                              # %._crit_edge135.thread167
	movl	$.L.str.6, %edi
                                        # kill: def $esi killed $esi killed $rsi
                                        # kill: def $edx killed $edx killed $rdx
                                        # kill: def $ecx killed $ecx killed $rcx
	xorl	%eax, %eax
	callq	printf
.LBB10_60:                              # %._crit_edge135.thread
	movq	24(%rsp), %rdi
.Ltmp78:
	callq	hipFree
.Ltmp79:
# %bb.61:
	movq	16(%rsp), %rdi
.Ltmp80:
	callq	hipFree
.Ltmp81:
# %bb.62:
	movq	%rbx, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
.Ltmp82:
	callq	hipDeviceReset
.Ltmp83:
# %bb.63:
	movq	96(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB10_65
# %bb.64:
	callq	_ZdlPv
.LBB10_65:                              # %_ZNSt6vectorIfSaIfEED2Ev.exit108
	xorl	%eax, %eax
	addq	$120, %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
.LBB10_6:
	.cfi_def_cfa_offset 176
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	movl	$305, %edx                      # imm = 0x131
	xorl	%eax, %eax
	callq	printf
.Ltmp23:
	callq	hipGetLastError
.Ltmp24:
# %bb.7:
.Ltmp25:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp26:
	jmp	.LBB10_8
.LBB10_15:
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	movl	$306, %edx                      # imm = 0x132
	xorl	%eax, %eax
	callq	printf
.Ltmp29:
	callq	hipGetLastError
.Ltmp30:
# %bb.16:
.Ltmp31:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp32:
	jmp	.LBB10_8
.LBB10_19:
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	movl	$310, %edx                      # imm = 0x136
	xorl	%eax, %eax
	callq	printf
.Ltmp36:
	callq	hipGetLastError
.Ltmp37:
# %bb.20:
.Ltmp38:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp39:
	jmp	.LBB10_8
.LBB10_24:
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	movl	$314, %edx                      # imm = 0x13A
	xorl	%eax, %eax
	callq	printf
.Ltmp43:
	callq	hipGetLastError
.Ltmp44:
# %bb.25:
.Ltmp45:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp46:
	jmp	.LBB10_8
.LBB10_29:
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	movl	$316, %edx                      # imm = 0x13C
	xorl	%eax, %eax
	callq	printf
.Ltmp50:
	callq	hipGetLastError
.Ltmp51:
# %bb.30:
.Ltmp52:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp53:
	jmp	.LBB10_8
.LBB10_54:
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	movl	$354, %edx                      # imm = 0x162
	xorl	%eax, %eax
	callq	printf
.Ltmp73:
	callq	hipGetLastError
.Ltmp74:
# %bb.55:
.Ltmp75:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp76:
.LBB10_8:
	movl	$.L.str.3, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.LBB10_10:
.Ltmp20:
	movq	%rax, %rbx
	movq	72(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB10_68
# %bb.11:
	callq	_ZdlPv
	jmp	.LBB10_68
.LBB10_9:
.Ltmp17:
	jmp	.LBB10_67
.LBB10_56:
.Ltmp77:
	jmp	.LBB10_67
.LBB10_31:
.Ltmp54:
	jmp	.LBB10_67
.LBB10_26:
.Ltmp47:
	jmp	.LBB10_67
.LBB10_21:
.Ltmp40:
	jmp	.LBB10_67
.LBB10_66:
.Ltmp84:
	jmp	.LBB10_67
.LBB10_12:
.Ltmp33:
	jmp	.LBB10_67
.LBB10_52:
.Ltmp57:
	jmp	.LBB10_67
.LBB10_53:
.Ltmp70:
.LBB10_67:
	movq	%rax, %rbx
.LBB10_68:                              # %_ZNSt6vectorIfSaIfEED2Ev.exit106
	movq	96(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB10_70
# %bb.69:
	callq	_ZdlPv
.LBB10_70:                              # %_ZNSt6vectorIfSaIfEED2Ev.exit110
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end10:
	.size	main, .Lfunc_end10-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table10:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Lfunc_begin1-.Lfunc_begin1    # >> Call Site 1 <<
	.uleb128 .Ltmp15-.Lfunc_begin1          #   Call between .Lfunc_begin1 and .Ltmp15
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp15-.Lfunc_begin1          # >> Call Site 2 <<
	.uleb128 .Ltmp16-.Ltmp15                #   Call between .Ltmp15 and .Ltmp16
	.uleb128 .Ltmp17-.Lfunc_begin1          #     jumps to .Ltmp17
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp18-.Lfunc_begin1          # >> Call Site 3 <<
	.uleb128 .Ltmp19-.Ltmp18                #   Call between .Ltmp18 and .Ltmp19
	.uleb128 .Ltmp20-.Lfunc_begin1          #     jumps to .Ltmp20
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp21-.Lfunc_begin1          # >> Call Site 4 <<
	.uleb128 .Ltmp28-.Ltmp21                #   Call between .Ltmp21 and .Ltmp28
	.uleb128 .Ltmp33-.Lfunc_begin1          #     jumps to .Ltmp33
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp34-.Lfunc_begin1          # >> Call Site 5 <<
	.uleb128 .Ltmp35-.Ltmp34                #   Call between .Ltmp34 and .Ltmp35
	.uleb128 .Ltmp40-.Lfunc_begin1          #     jumps to .Ltmp40
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp41-.Lfunc_begin1          # >> Call Site 6 <<
	.uleb128 .Ltmp42-.Ltmp41                #   Call between .Ltmp41 and .Ltmp42
	.uleb128 .Ltmp47-.Lfunc_begin1          #     jumps to .Ltmp47
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp48-.Lfunc_begin1          # >> Call Site 7 <<
	.uleb128 .Ltmp49-.Ltmp48                #   Call between .Ltmp48 and .Ltmp49
	.uleb128 .Ltmp54-.Lfunc_begin1          #     jumps to .Ltmp54
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp55-.Lfunc_begin1          # >> Call Site 8 <<
	.uleb128 .Ltmp56-.Ltmp55                #   Call between .Ltmp55 and .Ltmp56
	.uleb128 .Ltmp57-.Lfunc_begin1          #     jumps to .Ltmp57
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp58-.Lfunc_begin1          # >> Call Site 9 <<
	.uleb128 .Ltmp69-.Ltmp58                #   Call between .Ltmp58 and .Ltmp69
	.uleb128 .Ltmp70-.Lfunc_begin1          #     jumps to .Ltmp70
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp71-.Lfunc_begin1          # >> Call Site 10 <<
	.uleb128 .Ltmp72-.Ltmp71                #   Call between .Ltmp71 and .Ltmp72
	.uleb128 .Ltmp77-.Lfunc_begin1          #     jumps to .Ltmp77
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp78-.Lfunc_begin1          # >> Call Site 11 <<
	.uleb128 .Ltmp83-.Ltmp78                #   Call between .Ltmp78 and .Ltmp83
	.uleb128 .Ltmp84-.Lfunc_begin1          #     jumps to .Ltmp84
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp23-.Lfunc_begin1          # >> Call Site 12 <<
	.uleb128 .Ltmp32-.Ltmp23                #   Call between .Ltmp23 and .Ltmp32
	.uleb128 .Ltmp33-.Lfunc_begin1          #     jumps to .Ltmp33
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp36-.Lfunc_begin1          # >> Call Site 13 <<
	.uleb128 .Ltmp39-.Ltmp36                #   Call between .Ltmp36 and .Ltmp39
	.uleb128 .Ltmp40-.Lfunc_begin1          #     jumps to .Ltmp40
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp43-.Lfunc_begin1          # >> Call Site 14 <<
	.uleb128 .Ltmp46-.Ltmp43                #   Call between .Ltmp43 and .Ltmp46
	.uleb128 .Ltmp47-.Lfunc_begin1          #     jumps to .Ltmp47
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp50-.Lfunc_begin1          # >> Call Site 15 <<
	.uleb128 .Ltmp53-.Ltmp50                #   Call between .Ltmp50 and .Ltmp53
	.uleb128 .Ltmp54-.Lfunc_begin1          #     jumps to .Ltmp54
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp73-.Lfunc_begin1          # >> Call Site 16 <<
	.uleb128 .Ltmp76-.Ltmp73                #   Call between .Ltmp73 and .Ltmp76
	.uleb128 .Ltmp77-.Lfunc_begin1          #     jumps to .Ltmp77
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp76-.Lfunc_begin1          # >> Call Site 17 <<
	.uleb128 .Lfunc_end10-.Ltmp76           #   Call between .Ltmp76 and .Lfunc_end10
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end1:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt6vectorIfSaIfEEC2ERKS1_,"axG",@progbits,_ZNSt6vectorIfSaIfEEC2ERKS1_,comdat
	.weak	_ZNSt6vectorIfSaIfEEC2ERKS1_    # -- Begin function _ZNSt6vectorIfSaIfEEC2ERKS1_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIfSaIfEEC2ERKS1_,@function
_ZNSt6vectorIfSaIfEEC2ERKS1_:           # @_ZNSt6vectorIfSaIfEEC2ERKS1_
	.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	%rsi, %r14
	movq	%rdi, %rbx
	movq	8(%rsi), %rax
	movq	(%rsi), %rcx
	movq	%rax, %r12
	subq	%rcx, %r12
	sarq	$2, %r12
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rdi)
	movq	$0, 16(%rdi)
	cmpq	%rcx, %rax
	je	.LBB11_1
# %bb.2:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIfE8allocateEmPKv
	movq	%rax, %r15
	jmp	.LBB11_3
.LBB11_1:
	xorl	%r15d, %r15d
.LBB11_3:
	movq	%r15, (%rbx)
	movq	%r15, 8(%rbx)
	leaq	(%r15,%r12,4), %rax
	movq	%rax, 16(%rbx)
	movq	(%r14), %rsi
	movq	8(%r14), %r14
	subq	%rsi, %r14
	cmpq	$5, %r14
	jl	.LBB11_5
# %bb.4:
	movq	%r15, %rdi
	movq	%r14, %rdx
	callq	memmove@PLT
.LBB11_7:
	addq	%r14, %r15
	movq	%r15, 8(%rbx)
	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
.LBB11_5:
	.cfi_def_cfa_offset 48
	cmpq	$4, %r14
	jne	.LBB11_7
# %bb.6:
	movss	(%rsi), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r15)
	jmp	.LBB11_7
.Lfunc_end11:
	.size	_ZNSt6vectorIfSaIfEEC2ERKS1_, .Lfunc_end11-_ZNSt6vectorIfSaIfEEC2ERKS1_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt15__new_allocatorIfE8allocateEmPKv,"axG",@progbits,_ZNSt15__new_allocatorIfE8allocateEmPKv,comdat
	.weak	_ZNSt15__new_allocatorIfE8allocateEmPKv # -- Begin function _ZNSt15__new_allocatorIfE8allocateEmPKv
	.p2align	1, 0x90
	.type	_ZNSt15__new_allocatorIfE8allocateEmPKv,@function
_ZNSt15__new_allocatorIfE8allocateEmPKv: # @_ZNSt15__new_allocatorIfE8allocateEmPKv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rax
	shrq	$61, %rax
	jne	.LBB12_1
# %bb.3:
	shlq	$2, %rsi
	movq	%rsi, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Znwm                           # TAILCALL
.LBB12_1:
	.cfi_def_cfa_offset 16
	shrq	$62, %rsi
	je	.LBB12_2
# %bb.4:
	callq	_ZSt28__throw_bad_array_new_lengthv
.LBB12_2:
	callq	_ZSt17__throw_bad_allocv
.Lfunc_end12:
	.size	_ZNSt15__new_allocatorIfE8allocateEmPKv, .Lfunc_end12-_ZNSt15__new_allocatorIfE8allocateEmPKv
	.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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB13_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB13_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end13:
	.size	__hip_module_ctor, .Lfunc_end13-__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	.LBB14_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
.LBB14_2:
	retq
.Lfunc_end14:
	.size	__hip_module_dtor, .Lfunc_end14-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi,@object # @_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.section	.rodata,"a",@progbits
	.globl	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.p2align	3, 0x0
_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi:
	.quad	_Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.size	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, 8

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"generateZoningPlan: %lf\n"
	.size	.L.str, 25

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"CUDA error at %s:%d\n"
	.size	.L.str.1, 21

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/gnishida/CUDATest/master/complex_zone.hip"
	.size	.L.str.2, 104

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"computeDistanceToStore CPU: %lf\n"
	.size	.L.str.4, 33

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"computeDistanceToStore: initDistance = %lf, updateDistance = %lf\n"
	.size	.L.str.5, 66

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"ERROR! %d,%d k=%d, %d != %d\n"
	.size	.L.str.6, 29

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"cannot create std::vector larger than max_size()"
	.size	.L.str.7, 49

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi"
	.size	.L__unnamed_1, 66

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi"
	.size	.L__unnamed_2, 76

	.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 __gxx_personality_v0
	.addrsig_sym _Z27__device_stub__initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.addrsig_sym _Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.addrsig_sym _Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi ; -- Begin function _Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.globl	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.p2align	8
	.type	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi,@function
_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi: ; @_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
; %bb.0:
	s_clause 0x1
	s_load_b32 s8, s[0:1], 0x2c
	s_load_b256 s[0:7], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s8, s8, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[1:2], null, s15, s8, v[0:1]
	v_mov_b32_e32 v0, 0
	v_ashrrev_i32_e32 v2, 31, v1
	v_mul_lo_u32 v9, 0x4f, v1
	v_mul_lo_u32 v10, 0x1388, v1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[1:2]
	v_add_co_u32 v3, vcc_lo, s6, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s7, v4, vcc_lo
	s_mov_b32 s6, 0
	global_store_b32 v[3:4], v0, off
.LBB0_1:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_3 Depth 2
	v_add_nc_u32_e32 v0, s6, v9
	s_mov_b32 s7, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e32 0x9c40, v0
	s_cbranch_execz .LBB0_6
; %bb.2:                                ; %.preheader
                                        ;   in Loop: Header=BB0_1 Depth=1
	v_mul_hi_i32 v1, 0x51eb851f, v0
	s_mov_b32 s8, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v2, 31, v1
	v_ashrrev_i32_e32 v1, 6, v1
	v_add_nc_u32_e32 v1, v1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v2, 0xc8, v1
	v_mad_i64_i32 v[11:12], null, 0x640, v1, s[0:1]
	v_sub_nc_u32_e32 v0, v0, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_i64_i32 v[7:8], null, v0, 20, 0
	v_ashrrev_i32_e32 v6, 31, v0
	v_mov_b32_e32 v5, v0
	v_lshlrev_b64 v[5:6], 3, v[5:6]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mad_i64_i32 v[13:14], null, 0xfa0, v1, v[7:8]
	v_add_co_u32 v5, vcc_lo, v11, v5
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v6, vcc_lo, v12, v6, vcc_lo
	v_add_co_u32 v7, vcc_lo, s2, v13
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v14, vcc_lo
.LBB0_3:                                ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b32 v2, v[5:6], off
	s_mov_b32 s9, exec_lo
	s_waitcnt vmcnt(0)
	v_dual_mov_b32 v11, 0x270f :: v_dual_add_nc_u32 v2, -1, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e64 s8, v2
	s_cbranch_execz .LBB0_5
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=2
	global_load_b32 v2, v[3:4], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v11, v2, v10
	v_add_nc_u32_e32 v14, 1, v2
	v_mov_b32_e32 v2, s8
	s_delay_alu instid0(VALU_DEP_3)
	v_mad_i64_i32 v[12:13], null, v11, 12, s[4:5]
	v_mov_b32_e32 v11, 0
	global_store_b32 v[3:4], v14, off
	global_store_b96 v[12:13], v[0:2], off
.LBB0_5:                                ;   in Loop: Header=BB0_3 Depth=2
	s_or_b32 exec_lo, exec_lo, s9
	global_store_b32 v[7:8], v11, off
	v_add_co_u32 v7, vcc_lo, v7, 4
	v_add_co_ci_u32_e32 v8, vcc_lo, 0, v8, vcc_lo
	s_add_i32 s8, s8, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s8, 5
	s_cbranch_scc1 .LBB0_3
.LBB0_6:                                ; %Flow56
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s7
	s_add_i32 s6, s6, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmpk_eq_i32 s6, 0x4f
	s_cbranch_scc0 .LBB0_1
; %bb.7:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
		.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 15
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, .Lfunc_end0-_Z12initDistanceP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 452
; NumSgprs: 18
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 15
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi ; -- Begin function _Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.globl	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
	.p2align	8
	.type	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi,@function
_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi: ; @_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x2c
	s_load_b64 s[2:3], s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	s_mov_b32 s4, 0
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v6, vcc_lo, s2, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v7, vcc_lo, s3, v3, vcc_lo
	s_mov_b32 s2, exec_lo
	global_load_b32 v0, v[6:7], off
	s_waitcnt vmcnt(0)
	v_cmpx_lt_i32_e32 0, v0
	s_cbranch_execz .LBB1_23
; %bb.1:                                ; %.lr.ph
	s_load_b128 s[0:3], s[0:1], 0x8
	v_mul_lo_u32 v14, 0x1388, v1
	v_mov_b32_e32 v15, 0
	s_mov_b32 s5, 0
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v2, s5, v14
	s_mov_b32 s6, exec_lo
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_i64_i32 v[0:1], null, v2, 12, s[2:3]
	global_load_b96 v[0:2], v[0:1], off
	s_waitcnt vmcnt(0)
	v_mad_i64_i32 v[10:11], null, 0xfa0, v1, s[0:1]
	v_ashrrev_i32_e32 v4, 31, v2
	v_mov_b32_e32 v3, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[12:13], 2, v[3:4]
	v_mad_i64_i32 v[8:9], null, v0, 20, v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v8, vcc_lo, v8, v12
	v_add_co_ci_u32_e32 v9, vcc_lo, v9, v13, vcc_lo
	global_load_b32 v3, v[8:9], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v16, 1, v3
	v_cmpx_lt_i32_e32 0, v1
	s_cbranch_execz .LBB1_6
; %bb.3:                                ;   in Loop: Header=BB1_2 Depth=1
	v_add_nc_u32_e32 v4, -1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[17:18], null, 0xfa0, v4, s[0:1]
	v_mad_i64_i32 v[19:20], null, v0, 20, v[17:18]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v17, vcc_lo, v19, v12
	v_add_co_ci_u32_e32 v18, vcc_lo, v20, v13, vcc_lo
	global_atomic_min_i32 v3, v[17:18], v16, off glc
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, v3, v16
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_6
; %bb.4:                                ;   in Loop: Header=BB1_2 Depth=1
	global_load_b32 v3, v[6:7], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v5, v3, v14
	v_add_nc_u32_e32 v19, 1, v3
	v_mov_b32_e32 v3, v0
	s_delay_alu instid0(VALU_DEP_3)
	v_mad_i64_i32 v[17:18], null, v5, 12, s[2:3]
	v_mov_b32_e32 v5, v2
	global_store_b32 v[6:7], v19, off
	global_store_b96 v[17:18], v[3:5], off
	global_load_b32 v3, v[6:7], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, 0x1387, v3
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_6
; %bb.5:                                ;   in Loop: Header=BB1_2 Depth=1
	global_store_b32 v[6:7], v15, off
.LBB1_6:                                ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s6, exec_lo
	v_cmpx_gt_i32_e32 0xc7, v1
	s_cbranch_execz .LBB1_10
; %bb.7:                                ;   in Loop: Header=BB1_2 Depth=1
	global_atomic_min_i32 v3, v[8:9], v16, off offset:4000 glc
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, v3, v16
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_10
; %bb.8:                                ;   in Loop: Header=BB1_2 Depth=1
	global_load_b32 v3, v[6:7], off
	v_add_nc_u32_e32 v4, 1, v1
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v5, v3, v14
	v_add_nc_u32_e32 v19, 1, v3
	v_mov_b32_e32 v3, v0
	s_delay_alu instid0(VALU_DEP_3)
	v_mad_i64_i32 v[17:18], null, v5, 12, s[2:3]
	v_mov_b32_e32 v5, v2
	global_store_b32 v[6:7], v19, off
	global_store_b96 v[17:18], v[3:5], off
	global_load_b32 v3, v[6:7], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, 0x1387, v3
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_10
; %bb.9:                                ;   in Loop: Header=BB1_2 Depth=1
	global_store_b32 v[6:7], v15, off
.LBB1_10:                               ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s6, exec_lo
	v_cmpx_lt_i32_e32 0, v0
	s_cbranch_execz .LBB1_14
; %bb.11:                               ;   in Loop: Header=BB1_2 Depth=1
	v_add_nc_u32_e32 v3, -1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[4:5], null, v3, 20, v[10:11]
	v_add_co_u32 v4, vcc_lo, v4, v12
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, v5, v13, vcc_lo
	global_atomic_min_i32 v4, v[4:5], v16, off glc
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, v4, v16
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_14
; %bb.12:                               ;   in Loop: Header=BB1_2 Depth=1
	global_load_b32 v4, v[6:7], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v5, v4, v14
	v_add_nc_u32_e32 v12, 1, v4
	v_mov_b32_e32 v4, v1
	s_delay_alu instid0(VALU_DEP_3)
	v_mad_i64_i32 v[10:11], null, v5, 12, s[2:3]
	v_mov_b32_e32 v5, v2
	global_store_b32 v[6:7], v12, off
	global_store_b96 v[10:11], v[3:5], off
	global_load_b32 v3, v[6:7], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, 0x1387, v3
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_14
; %bb.13:                               ;   in Loop: Header=BB1_2 Depth=1
	global_store_b32 v[6:7], v15, off
.LBB1_14:                               ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s6, exec_lo
                                        ; implicit-def: $vgpr3
	v_cmpx_lt_i32_e32 0xc6, v0
	s_xor_b32 s6, exec_lo, s6
	s_cbranch_execz .LBB1_16
; %bb.15:                               ; %._crit_edge98
                                        ;   in Loop: Header=BB1_2 Depth=1
	global_load_b32 v3, v[6:7], off
                                        ; implicit-def: $vgpr8_vgpr9
                                        ; implicit-def: $vgpr16
                                        ; implicit-def: $vgpr0_vgpr1_vgpr2
.LBB1_16:                               ; %Flow111
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_and_not1_saveexec_b32 s6, s6
	s_cbranch_execz .LBB1_22
; %bb.17:                               ;   in Loop: Header=BB1_2 Depth=1
	global_atomic_min_i32 v4, v[8:9], v16, off offset:20 glc
	global_load_b32 v3, v[6:7], off
	s_mov_b32 s7, exec_lo
	s_waitcnt vmcnt(1)
	v_cmpx_gt_i32_e64 v4, v16
	s_cbranch_execz .LBB1_21
; %bb.18:                               ;   in Loop: Header=BB1_2 Depth=1
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v8, v3, v14
	v_add_nc_u32_e32 v3, 1, v3
	v_add_nc_u32_e32 v0, 1, v0
	s_mov_b32 s8, exec_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_mad_i64_i32 v[4:5], null, v8, 12, s[2:3]
	global_store_b32 v[6:7], v3, off
	global_store_b96 v[4:5], v[0:2], off
	global_load_b32 v3, v[6:7], off
	s_waitcnt vmcnt(0)
	v_cmpx_lt_i32_e32 0x1387, v3
	s_cbranch_execz .LBB1_20
; %bb.19:                               ;   in Loop: Header=BB1_2 Depth=1
	v_mov_b32_e32 v3, 0
	global_store_b32 v[6:7], v15, off
.LBB1_20:                               ; %Flow
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s8
.LBB1_21:                               ; %Flow110
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s7
.LBB1_22:                               ;   in Loop: Header=BB1_2 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s6
	s_add_i32 s6, s5, 1
	s_cmpk_lt_i32 s5, 0x1387
	s_cselect_b32 s5, s6, 0
	s_waitcnt vmcnt(0)
	v_cmp_ge_i32_e32 vcc_lo, s5, v3
	s_or_b32 s4, vcc_lo, s4
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s4
	s_cbranch_execnz .LBB1_2
.LBB1_23:                               ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
		.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 21
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi, .Lfunc_end1-_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP17Point2DAndFeaturePi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 956
; NumSgprs: 18
; NumVgprs: 21
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 21
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
