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

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

#define CITY_SIZE 10 //200
#define GPU_BLOCK_SIZE 10//40
#define GPU_NUM_THREADS 8 //96
#define GPU_BLOCK_SCALE (1.0)//(1.1)
#define NUM_FEATURES 1
#define QUEUE_MAX 1999
#define MAX_DIST 99
#define HISTORY_SIZE 10000

#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) {}
};

__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(NUM_FEATURES + 1);
	for (int i = 0; i < NUM_FEATURES + 1; ++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;
		}
	}
}



/**
 * 直近の店までの距離を計算する（マルチスレッド版、shared memory使用）
 */
__global__
void computeDistanceToStore(ZoningPlan* zoningPlan, DistanceMap* distanceMap, uint3* devQueue, int* devQueueStart, int* devQueueEnd, uint3* devHistory) {
	__shared__ int sDist[(int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE)][(int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE)][NUM_FEATURES];
	__shared__ uint3 sQueue[QUEUE_MAX + 1];
	__shared__ unsigned int queue_begin;
	__shared__ unsigned int queue_end;
	__shared__ unsigned int history_index;

	queue_begin = 0;
	queue_end = 0;
	history_index = 0;
	__syncthreads();

	// queueを初期化
	for (int i = threadIdx.x; i < QUEUE_MAX + 1; i += GPU_NUM_THREADS) {
		sQueue[i] = make_uint3(CITY_SIZE * 100, CITY_SIZE * 100, NUM_FEATURES);
	}

	// global memoryからshared memoryへコピー
	int num_strides = (GPU_BLOCK_SIZE * GPU_BLOCK_SIZE * GPU_BLOCK_SCALE * GPU_BLOCK_SCALE + GPU_NUM_THREADS - 1) / GPU_NUM_THREADS;
	int r0 = blockIdx.y * GPU_BLOCK_SIZE - GPU_BLOCK_SIZE * (GPU_BLOCK_SCALE - 1) * 0.5;
	int c0 = blockIdx.x * GPU_BLOCK_SIZE - GPU_BLOCK_SIZE * (GPU_BLOCK_SCALE - 1) * 0.5;
	for (int i = 0; i < num_strides; ++i) {
		int r1 = (i * GPU_NUM_THREADS + threadIdx.x) / (int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE);
		int c1 = (i * GPU_NUM_THREADS + threadIdx.x) % (int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE);

		// これ、忘れてた！！
		if (r1 >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE || c1 >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE) continue;

		int type = 0;
		if (r0 + r1 >= 0 && r0 + r1 < CITY_SIZE && c0 + c1 >= 0 && c0 + c1 < CITY_SIZE) {
			type = zoningPlan->zones[r0 + r1][c0 + c1].type;
		}
		for (int feature_id = 0; feature_id < NUM_FEATURES; ++feature_id) {
			distanceMap->distances[r0 + r1][c0 + c1][feature_id] = MAX_DIST;
			if (type - 1 == feature_id) {
				sDist[r1][c1][feature_id] = 0;
				unsigned int q_index = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index] = make_uint3(c1, r1, feature_id);
			} else {
				sDist[r1][c1][feature_id] = MAX_DIST;
			}
		}
	}
	__syncthreads();


	// 距離マップを生成
	unsigned int q_index;
	//while ((q_index = atomicInc(&queue_begin, QUEUE_MAX)) < queue_end) {
	for (int iter = 0; iter < 7000; ++iter) {
		q_index = atomicInc(&queue_begin, QUEUE_MAX);
		
	//while (queue_begin < queue_end) {
		uint3 pt = sQueue[q_index];
		if (pt.x < 0 || pt.x >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE || pt.y < 0 || pt.y >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE) {
			break;
		}

		int d = sDist[pt.y][pt.x][pt.z];
		int count = 0;

		if (pt.y > 0) {
			unsigned int old = atomicMin(&sDist[pt.y-1][pt.x][pt.z], d + 1);
			if (old > d + 1) {
				unsigned int q_index2 = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index2] = make_uint3(pt.x, pt.y-1, pt.z);
				count++;
				if (count == 60) {
					unsigned int h_ind = atomicInc(&history_index, HISTORY_SIZE - 1);
					//devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x + (pt.y-1) * CITY_SIZE, pt.z);
					devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x + (pt.y-1) * CITY_SIZE, q_index2);
				}
			}
		}
		if (pt.y < CITY_SIZE - 1) {
			unsigned int old = atomicMin(&sDist[pt.y+1][pt.x][pt.z], d + 1);
			if (old > d + 1) {
				unsigned int q_index2 = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index2] = make_uint3(pt.x, pt.y+1, pt.z);
				count++;
				if (count == 60) {
					unsigned int h_ind = atomicInc(&history_index, HISTORY_SIZE - 1);
					//devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x + (pt.y+1) * CITY_SIZE, pt.z);
					devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x + (pt.y+1) * CITY_SIZE, q_index2);
				}
			}
		}
		if (pt.x > 0) {
			unsigned int old = atomicMin(&sDist[pt.y][pt.x-1][pt.z], d + 1);
			if (old > d + 1) {
				unsigned int q_index2 = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index2] = make_uint3(pt.x-1, pt.y, pt.z);
				count++;
				if (count == 60) {
					unsigned int h_ind = atomicInc(&history_index, HISTORY_SIZE - 1);
					//devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x-1 + pt.y * CITY_SIZE, pt.z);
					devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x-1 + pt.y * CITY_SIZE, q_index2);
				}
			}
		}
		if (pt.x < CITY_SIZE - 1) {
			unsigned int old = atomicMin(&sDist[pt.y][pt.x+1][pt.z], d + 1);
			if (old > d + 1) {
				unsigned int q_index2 = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index2] = make_uint3(pt.x+1, pt.y, pt.z);
				count++;
				if (count == 60) {
					unsigned int h_ind = atomicInc(&history_index, HISTORY_SIZE - 1);
					//devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x+1 + pt.y * CITY_SIZE, pt.z);
					devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x+1 + pt.y * CITY_SIZE, q_index2);
				}
			}
		}

		sQueue[q_index] = make_uint3(CITY_SIZE * 100, CITY_SIZE * 100, NUM_FEATURES);
	}
	
	__syncthreads();

	// global memoryの距離マップへ、コピーする
	for (int i = 0; i < num_strides; ++i) {
		int r1 = (i * GPU_NUM_THREADS + threadIdx.x) / (int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE);
		int c1 = (i * GPU_NUM_THREADS + threadIdx.x) % (int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE);

		// これ、忘れてた！！
		if (r1 >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE || c1 >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE) continue;

		if (r0 + r1 >= 0 && r0 + r1 < CITY_SIZE && c0 + c1 >= 0 && c0 + c1 < CITY_SIZE) {
			for (int feature_id = 0; feature_id < NUM_FEATURES; ++feature_id) {
				atomicMin(&distanceMap->distances[r0 + r1][c0 + c1][feature_id], sDist[r1][c1][feature_id]);
			}
		}
	}

	// デバッグ用に、キュー情報をglobalにコピー
	for (int i = 0; i < queue_end; ++i) {
		devQueue[i] = sQueue[i];
	}
	*devQueueStart = queue_begin;
	*devQueueEnd = queue_end;

}

/**
 * 直近の店までの距離を計算する（CPU版）
 */
__host__
void computeDistanceToStoreCPU(ZoningPlan* zoningPLan, DistanceMap* distanceMap) {
	std::list<int3> 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(make_int3(c, r, feature_id));
				distanceMap->distances[r][c][feature_id] = 0;
			} else {
				distanceMap->distances[r][c][feature_id] = MAX_DIST;
			}
		}
	}

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

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

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

/**
 * デバッグ用に、ゾーンプランを表示する。
 */
__host__
void showDevZoningPlan(ZoningPlan* zoningPlan) {
	ZoningPlan plan;

	CUDA_CALL(cudaMemcpy(&plan, zoningPlan, sizeof(ZoningPlan), cudaMemcpyDeviceToHost));
	printf("Zone plan:\n");
	for (int r = CITY_SIZE - 1; r >= 0; --r) {
		for (int c = 0; c < CITY_SIZE; ++c) {
			printf("%2d, ", plan.zones[r][c].type);
		}
		printf("\n");
	}
	printf("\n");
}

/**
 * デバッグ用に、距離マップを表示する。
 */
__host__
void showDevDistMap(DistanceMap* distMap, int feature_id) {
	DistanceMap map;

	CUDA_CALL(cudaMemcpy(&map, distMap, sizeof(DistanceMap), cudaMemcpyDeviceToHost));
	printf("Distance map:\n");
	for (int r = CITY_SIZE - 1; r >= 0; --r) {
		for (int c = 0; c < CITY_SIZE; ++c) {
			printf("%2d, ", map.distances[r][c][feature_id]);
		}
		printf("\n");
	}
	printf("\n");
}

/**
 * デバッグ用に、キューの内容を表示する。
 */
__host__
void showDevQueue(uint3* queue, int* queueBegin, int* queueEnd, int featureId) {
	uint3 q[QUEUE_MAX + 1];
	int begin;
	int end;

	CUDA_CALL(cudaMemcpy(q, queue, sizeof(uint3) * (QUEUE_MAX + 1), cudaMemcpyDeviceToHost));
	CUDA_CALL(cudaMemcpy(&begin, queueBegin, sizeof(int), cudaMemcpyDeviceToHost));
	CUDA_CALL(cudaMemcpy(&end, queueEnd, sizeof(int), cudaMemcpyDeviceToHost));

	printf("Queue:\n");
	printf("Begin: %d, End: %d, featureId: %d\n", begin, end, featureId);

	int num = end - begin + 1;
	if (num < 0) {
		num = end + QUEUE_MAX + 1 - begin + 1;
	}

	for (int i = 0; i < num; ++i) {
		if (q[(begin + i) % (QUEUE_MAX + 1)].z == featureId) {
			printf("%3d: %3d, %3d\n", (begin + i) % (QUEUE_MAX + 1), q[(begin + i) % (QUEUE_MAX + 1)].x, q[(begin + i) % (QUEUE_MAX + 1)].y);
		}
	}
	printf("\n");
}

__host__
void showDevHistory(uint3* devHistory) {
	uint3 history[HISTORY_SIZE];
	CUDA_CALL(cudaMemcpy(history, devHistory, sizeof(uint3) * HISTORY_SIZE, cudaMemcpyDeviceToHost));

	printf("History:\n");
	for (int i = 0; i < 100; ++i) {
		int x0 = history[i].x % CITY_SIZE;
		int y0 = history[i].x / CITY_SIZE;
		int x1 = history[i].y % CITY_SIZE;
		int y1 = history[i].y / CITY_SIZE;
		int featureId = history[i].z;
		printf("%2d: (%3d, %3d) -> (%3d, %3d) (%d)\n", i, x0, y0, x1, y1, featureId);
	}
	printf("\n");
}


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, MAX_DIST, sizeof(DistanceMap));
	//memset(hostDistanceMap2, MAX_DIST, 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);
	
	// 初期プランをデバイスバッファへコピー
	ZoningPlan* devZoningPlan;
	CUDA_CALL(cudaMalloc((void**)&devZoningPlan, sizeof(ZoningPlan)));
	CUDA_CALL(cudaMemcpy(devZoningPlan, hostZoningPlan, sizeof(ZoningPlan), cudaMemcpyHostToDevice));

	// デバッグ用に、初期プランを表示
	if (CITY_SIZE <= 100) {
		showDevZoningPlan(devZoningPlan);
	}

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

	///////////////////////////////////////////////////////////////////////
	// 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);
	*/

	int* devQueueStart;
	CUDA_CALL(cudaMalloc((void**)&devQueueStart, sizeof(int)));
	int* devQueueEnd;
	CUDA_CALL(cudaMalloc((void**)&devQueueEnd, sizeof(int)));

	printf("start...\n");



	// デバッグ用に、globalにqueueメモリを確保
	uint3* devQueue;
	CUDA_CALL(cudaMalloc((void**)&devQueue, sizeof(uint3) * (QUEUE_MAX + 1)));

	// デバッグ用に、globalにwavefrontメモリを確保
	uint3* devHistory;
	CUDA_CALL(cudaMalloc((void**)&devHistory, sizeof(uint3) * HISTORY_SIZE));





	/*
	///////////////////////////////////////////////////////////////////////
	// warmp up
	computeDistanceToStore<<<dim3(CITY_SIZE / GPU_BLOCK_SIZE, CITY_SIZE / GPU_BLOCK_SIZE), GPU_NUM_THREADS>>>(devZoningPlan, devDistanceMap, devQueue);

	// マルチスレッドで、直近の店までの距離を計算
	start = clock();
	for (int iter = 0; iter < 1000; ++iter) {
		computeDistanceToStore<<<dim3(CITY_SIZE / GPU_BLOCK_SIZE, CITY_SIZE / GPU_BLOCK_SIZE), GPU_NUM_THREADS>>>(devZoningPlan, devDistanceMap, devQueue);
		cudaDeviceSynchronize();
	}
	end = clock();
	printf("computeDistanceToStore GPU: %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
	*/



	// テンポラリ　デバッグ用
	// バグの対処中。。。。
	FILE* fp = fopen("zone.txt", "r");
	for (int r = 0; r < CITY_SIZE; ++r) {
		for (int c = 0; c < CITY_SIZE; ++c) {
			fscanf(fp, "%d,", &hostZoningPlan->zones[r][c].type);
		}
	}
	CUDA_CALL(cudaMemcpy(devZoningPlan, hostZoningPlan, sizeof(ZoningPlan), cudaMemcpyHostToDevice));
	showDevZoningPlan(devZoningPlan);
	computeDistanceToStore<<<dim3(CITY_SIZE / GPU_BLOCK_SIZE, CITY_SIZE / GPU_BLOCK_SIZE), GPU_NUM_THREADS>>>(devZoningPlan, devDistanceMap, devQueue, devQueueStart, devQueueEnd, devHistory);
	cudaDeviceSynchronize();




	// 距離マップを表示
	showDevDistMap(devDistanceMap, 0);

	// キューを表示
	showDevQueue(devQueue, devQueueStart, devQueueEnd, 0);

	// hisotryを表示
	//showDevHistory(devHistory);

	/*
	// compare the results with the CPU version of the exact algrotihm
	int bad_k = 0;
	int bad_count = 0;
	{	
		for (int r = CITY_SIZE - 1; r >= 0; --r) {
			for (int c = 0; c < CITY_SIZE; ++c) {
				for (int k = 0; k < NUM_FEATURES; ++k) {
					if (hostDistanceMap->distances[r][c][k] != hostDistanceMap2->distances[r][c][k]) {
						if (bad_count == 0) {
							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;
						}
						bad_count++;
					}
				}
			}

		}
	}

	// for debug
	if (CITY_SIZE <= 200 && bad_count > 0) {
		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");
	}

	printf("Total error: %d\n", bad_count);
	*/

	// release device buffer
	cudaFree(devZoningPlan);
	cudaFree(devDistanceMap);

	// release host buffer
	free(hostZoningPlan);
	free(hostDistanceMap);
	free(hostDistanceMap2);

	//cudaDeviceReset();
}

	.file	"tmpxft_00292eb7_00000000-6_shared_zone.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3116:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3116:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z4randPj
	.type	_Z4randPj, @function
_Z4randPj:
.LFB3088:
	.cfi_startproc
	endbr64
	imull	$1103515245, (%rdi), %eax
	addl	$12345, %eax
	movl	%eax, (%rdi)
	andl	$2147483647, %eax
	ret
	.cfi_endproc
.LFE3088:
	.size	_Z4randPj, .-_Z4randPj
	.globl	_Z5randfPj
	.type	_Z5randfPj, @function
_Z5randfPj:
.LFB3089:
	.cfi_startproc
	endbr64
	call	_Z4randPj
	movl	%eax, %eax
	cvtsi2ssq	%rax, %xmm0
	mulss	.LC0(%rip), %xmm0
	ret
	.cfi_endproc
.LFE3089:
	.size	_Z5randfPj, .-_Z5randfPj
	.globl	_Z5randfPjff
	.type	_Z5randfPjff, @function
_Z5randfPjff:
.LFB3090:
	.cfi_startproc
	endbr64
	movaps	%xmm0, %xmm2
	call	_Z5randfPj
	subss	%xmm2, %xmm1
	mulss	%xmm0, %xmm1
	addss	%xmm2, %xmm1
	movaps	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE3090:
	.size	_Z5randfPjff, .-_Z5randfPjff
	.globl	_Z13sampleFromCdfPjPfi
	.type	_Z13sampleFromCdfPjPfi, @function
_Z13sampleFromCdfPjPfi:
.LFB3091:
	.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
.LFE3091:
	.size	_Z13sampleFromCdfPjPfi, .-_Z13sampleFromCdfPjPfi
	.globl	_Z13sampleFromPdfPjPfi
	.type	_Z13sampleFromPdfPjPfi, @function
_Z13sampleFromPdfPjPfi:
.LFB3092:
	.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
.LFE3092:
	.size	_Z13sampleFromPdfPjPfi, .-_Z13sampleFromPdfPjPfi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/gnishida/CUDATest/master/shared_zone.cu"
.LC3:
	.string	"CUDA error at %s:%d\n"
.LC4:
	.string	"  %s\n"
.LC5:
	.string	"Zone plan:\n"
.LC6:
	.string	"%2d, "
.LC7:
	.string	"\n"
	.text
	.globl	_Z17showDevZoningPlanP10ZoningPlan
	.type	_Z17showDevZoningPlanP10ZoningPlan, @function
_Z17showDevZoningPlanP10ZoningPlan:
.LFB3109:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdi, %rsi
	movl	$2, %ecx
	movl	$800, %edx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$824, %rsp
	.cfi_def_cfa_offset 864
	movq	%fs:40, %rax
	movq	%rax, 808(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r12
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L31
	movl	$332, %ecx
	leaq	.LC2(%rip), %rdx
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	$2, %edi
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L31:
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	728(%rsp), %rbp
	leaq	.LC6(%rip), %r13
.L32:
	xorl	%ebx, %ebx
.L33:
	movl	0(%rbp,%rbx,8), %edx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	call	__printf_chk@PLT
	cmpq	$10, %rbx
	jne	.L33
	leaq	.LC7(%rip), %rbx
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%rbx, %rsi
	call	__printf_chk@PLT
	leaq	-80(%rbp), %rax
	cmpq	%r12, %rbp
	je	.L34
	movq	%rax, %rbp
	jmp	.L32
.L34:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	808(%rsp), %rax
	subq	%fs:40, %rax
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	addq	$824, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3109:
	.size	_Z17showDevZoningPlanP10ZoningPlan, .-_Z17showDevZoningPlanP10ZoningPlan
	.section	.rodata.str1.1
.LC8:
	.string	"Distance map:\n"
	.text
	.globl	_Z14showDevDistMapP11DistanceMapi
	.type	_Z14showDevDistMapP11DistanceMapi, @function
_Z14showDevDistMapP11DistanceMapi:
.LFB3110:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$2, %ecx
	movl	$400, %edx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movslq	%esi, %rbp
	movq	%rdi, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$424, %rsp
	.cfi_def_cfa_offset 464
	movq	%fs:40, %rax
	movq	%rax, 408(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L39
	movl	$350, %ecx
	leaq	.LC2(%rip), %rdx
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	$2, %edi
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L39:
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	360(,%rbp,4), %rax
	leaq	.LC6(%rip), %r13
	addq	%rax, %rbx
	leaq	-392(%rsp,%rax), %r12
.L40:
	xorl	%ebp, %ebp
.L41:
	movl	(%rbx,%rbp,4), %edx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbp
	call	__printf_chk@PLT
	cmpq	$10, %rbp
	jne	.L41
	leaq	.LC7(%rip), %rbp
	movl	$2, %edi
	xorl	%eax, %eax
	subq	$40, %rbx
	movq	%rbp, %rsi
	call	__printf_chk@PLT
	cmpq	%r12, %rbx
	jne	.L40
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	408(%rsp), %rax
	subq	%fs:40, %rax
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	addq	$424, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3110:
	.size	_Z14showDevDistMapP11DistanceMapi, .-_Z14showDevDistMapP11DistanceMapi
	.section	.rodata.str1.1
.LC9:
	.string	"Queue:\n"
.LC10:
	.string	"Begin: %d, End: %d, featureId: %d\n"
.LC11:
	.string	"%3d: %3d, %3d\n"
	.text
	.globl	_Z12showDevQueueP5uint3PiS1_i
	.type	_Z12showDevQueueP5uint3PiS1_i, @function
_Z12showDevQueueP5uint3PiS1_i:
.LFB3111:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-20480(%rsp), %r11
	.cfi_def_cfa 11, 20520
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3544, %rsp
	.cfi_def_cfa_offset 24064
	movq	%fs:40, %rax
	movq	%rax, 24008(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movq	%rsi, %rbp
	movq	%rdx, %rbx
	movq	%rdi, %rsi
	movl	%ecx, %r12d
	movl	$24000, %edx
	movl	$2, %ecx
	movq	%rax, %rdi
	call	cudaMemcpy@PLT
	movl	$370, %ecx
	testl	%eax, %eax
	jne	.L56
	movq	%rsp, %rdi
	movl	$2, %ecx
	movl	$4, %edx
	movq	%rbp, %rsi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L48
	movl	$371, %ecx
.L56:
	leaq	.LC2(%rip), %rdx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	$2, %edi
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L48:
	movl	$2, %ecx
	leaq	4(%rsp), %rdi
	movl	$4, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	movl	$372, %ecx
	testl	%eax, %eax
	jne	.L56
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	(%rsp), %edx
	movl	4(%rsp), %ecx
	movl	%r12d, %r8d
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	4(%rsp), %eax
	movl	(%rsp), %edx
	movl	%eax, %ebx
	subl	%edx, %ebx
	incl	%ebx
	jns	.L50
	subl	%edx, %eax
	leal	2001(%rax), %ebx
.L50:
	xorl	%ebp, %ebp
	leaq	.LC11(%rip), %r13
.L51:
	cmpl	%ebp, %ebx
	jle	.L57
	movl	(%rsp), %eax
	movl	$2000, %ecx
	addl	%ebp, %eax
	cltd
	idivl	%ecx
	movslq	%edx, %rax
	imulq	$12, %rax, %rax
	cmpl	%r12d, 16(%rsp,%rax)
	jne	.L52
	movl	12(%rsp,%rax), %r8d
	movl	8(%rsp,%rax), %ecx
	movq	%r13, %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
.L52:
	incl	%ebp
	jmp	.L51
.L57:
	xorl	%eax, %eax
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	24008(%rsp), %rax
	subq	%fs:40, %rax
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$24024, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3111:
	.size	_Z12showDevQueueP5uint3PiS1_i, .-_Z12showDevQueueP5uint3PiS1_i
	.section	.rodata.str1.1
.LC12:
	.string	"History:\n"
.LC13:
	.string	"%2d: (%3d, %3d) -> (%3d, %3d) (%d)\n"
	.text
	.globl	_Z14showDevHistoryP5uint3
	.type	_Z14showDevHistoryP5uint3, @function
_Z14showDevHistoryP5uint3:
.LFB3112:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-118784(%rsp), %r11
	.cfi_def_cfa 11, 118816
.LPSRL1:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL1
	.cfi_def_cfa_register 7
	subq	$1232, %rsp
	.cfi_def_cfa_offset 120048
	movl	$2, %ecx
	movl	$120000, %edx
	movq	%fs:40, %rax
	movq	%rax, 120008(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rbx
	movq	%rdi, %rsi
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L59
	movl	$393, %ecx
	leaq	.LC2(%rip), %rdx
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movl	$2, %edi
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L59:
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	call	__printf_chk@PLT
	leaq	.LC13(%rip), %r12
.L60:
	movl	4(%rbx), %eax
	movl	$10, %edi
	xorl	%edx, %edx
	addq	$12, %rbx
	divl	%edi
	movl	%eax, %esi
	movl	-12(%rbx), %eax
	movl	%edx, %r9d
	xorl	%edx, %edx
	divl	%edi
	movl	$2, %edi
	movl	%eax, %r8d
	movl	-4(%rbx), %eax
	movl	%edx, %ecx
	movl	%ebp, %edx
	incl	%ebp
	pushq	%rax
	.cfi_def_cfa_offset 120056
	xorl	%eax, %eax
	pushq	%rsi
	.cfi_def_cfa_offset 120064
	movq	%r12, %rsi
	call	__printf_chk@PLT
	popq	%rax
	.cfi_def_cfa_offset 120056
	popq	%rdx
	.cfi_def_cfa_offset 120048
	cmpl	$100, %ebp
	jne	.L60
	xorl	%eax, %eax
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	120008(%rsp), %rax
	subq	%fs:40, %rax
	je	.L61
	call	__stack_chk_fail@PLT
.L61:
	addq	$120016, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3112:
	.size	_Z14showDevHistoryP5uint3, .-_Z14showDevHistoryP5uint3
	.globl	_Z82__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_P10ZoningPlanP11DistanceMapP5uint3PiS5_S4_
	.type	_Z82__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_P10ZoningPlanP11DistanceMapP5uint3PiS5_S4_, @function
_Z82__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_P10ZoningPlanP11DistanceMapP5uint3PiS5_S4_:
.LFB3138:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%r9, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 152(%rsp)
	movq	%rsp, %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L64
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L64:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L66
	call	__stack_chk_fail@PLT
.L66:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3138:
	.size	_Z82__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_P10ZoningPlanP11DistanceMapP5uint3PiS5_S4_, .-_Z82__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_P10ZoningPlanP11DistanceMapP5uint3PiS5_S4_
	.globl	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_
	.type	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_, @function
_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_:
.LFB3139:
	.cfi_startproc
	endbr64
	jmp	_Z82__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_P10ZoningPlanP11DistanceMapP5uint3PiS5_S4_
	.cfi_endproc
.LFE3139:
	.size	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_, .-_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_
	.section	.rodata.str1.1
.LC14:
	.string	"_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3141:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC14(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3141:
	.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:
.LFB3199:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L71
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L71:
	ret
	.cfi_endproc
.LFE3199:
	.size	_ZNSt6vectorIfSaIfEED2Ev, .-_ZNSt6vectorIfSaIfEED2Ev
	.weak	_ZNSt6vectorIfSaIfEED1Ev
	.set	_ZNSt6vectorIfSaIfEED1Ev,_ZNSt6vectorIfSaIfEED2Ev
	.section	.text._ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_,"axG",@progbits,_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_,comdat
	.align 2
	.weak	_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_
	.type	_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_, @function
_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_:
.LFB3213:
	.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
.LFE3213:
	.size	_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_, .-_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_
	.section	.text._ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv,"axG",@progbits,_ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv,comdat
	.align 2
	.weak	_ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv
	.type	_ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv, @function
_ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv:
.LFB3285:
	.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
.L76:
	cmpq	%rdi, %rbx
	je	.L79
	movq	(%rdi), %rbp
	movl	$32, %esi
	call	_ZdlPvm@PLT
	movq	%rbp, %rdi
	jmp	.L76
.L79:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3285:
	.size	_ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv, .-_ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv
	.text
	.globl	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
	.type	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap, @function
_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap:
.LFB3094:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3094
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%edx, %edx
	movl	$10, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	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	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	48(%rsp), %rax
	movq	%rdx, 64(%rsp)
	movq	%rax, (%rsp)
	movq	%rax, 56(%rsp)
	movq	%rax, 48(%rsp)
.L82:
	movl	%r12d, %eax
	movl	$99, %esi
	cltd
	idivl	%r15d
	movslq	%eax, %rbp
	movslq	%edx, %r14
	imulq	$10, %rbp, %rcx
	addq	%r14, %rcx
	cmpl	$1, 0(%r13,%rcx,8)
	jne	.L81
	movq	(%rsp), %rdi
	movl	%eax, 40(%rsp)
	leaq	36(%rsp), %rsi
	xorl	%eax, %eax
	movl	%edx, 36(%rsp)
	movl	%eax, 44(%rsp)
.LEHB0:
	call	_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_
	xorl	%esi, %esi
.L81:
	imulq	$10, %rbp, %rbp
	incl	%r12d
	addq	%r14, %rbp
	movl	%esi, (%rbx,%rbp,4)
	cmpl	$100, %r12d
	jne	.L82
	leaq	36(%rsp), %rax
	movq	%rax, 8(%rsp)
.L83:
	movq	48(%rsp), %r13
	movq	(%rsp), %rax
	cmpq	%rax, %r13
	je	.L105
	movl	20(%r13), %r12d
	movq	%r13, %rdi
	movl	16(%r13), %ebp
	movslq	24(%r13), %r15
	decq	64(%rsp)
	call	_ZNSt8__detail15_List_node_base9_M_unhookEv@PLT
	movq	%r13, %rdi
	movl	$32, %esi
	call	_ZdlPvm@PLT
	movslq	%r12d, %rax
	movslq	%ebp, %rcx
	movq	%r15, %r14
	movq	%rax, 16(%rsp)
	imulq	$10, %rax, %rax
	addq	%r15, %rax
	addq	%rcx, %rax
	testl	%r12d, %r12d
	movl	(%rbx,%rax,4), %eax
	movl	%eax, 28(%rsp)
	leal	1(%rax), %r13d
	jg	.L84
.L88:
	leal	1(%r12), %edx
	movslq	%ebp, %rcx
	movslq	%edx, %rax
	imulq	$10, %rax, %rax
	addq	%r15, %rax
	addq	%rcx, %rax
	cmpl	%r13d, (%rbx,%rax,4)
	jle	.L89
	jmp	.L106
.L84:
	leal	-1(%r12), %edx
	movslq	%ebp, %rcx
	movslq	%edx, %rax
	imulq	$10, %rax, %rax
	addq	%r15, %rax
	addq	%rcx, %rax
	cmpl	%r13d, (%rbx,%rax,4)
	jle	.L87
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	%r13d, (%rbx,%rax,4)
	movl	%ebp, 36(%rsp)
	movl	%edx, 40(%rsp)
	movl	%r15d, 44(%rsp)
	call	_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_
.L87:
	cmpl	$8, %r12d
	jg	.L89
	jmp	.L88
.L106:
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	%r13d, (%rbx,%rax,4)
	movl	%ebp, 36(%rsp)
	movl	%edx, 40(%rsp)
	movl	%r14d, 44(%rsp)
	call	_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_
.L89:
	movl	28(%rsp), %r13d
	incl	%r13d
	testl	%ebp, %ebp
	jg	.L90
.L94:
	imulq	$10, 16(%rsp), %rax
	incl	%ebp
	movslq	%ebp, %rdx
	addq	%r15, %rax
	addq	%rdx, %rax
	cmpl	%r13d, (%rbx,%rax,4)
	jle	.L83
	jmp	.L107
.L90:
	imulq	$10, 16(%rsp), %rax
	leal	-1(%rbp), %edx
	movslq	%edx, %rcx
	addq	%r15, %rax
	addq	%rcx, %rax
	cmpl	%r13d, (%rbx,%rax,4)
	jle	.L93
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	%r13d, (%rbx,%rax,4)
	movl	%edx, 36(%rsp)
	movl	%r12d, 40(%rsp)
	movl	%r14d, 44(%rsp)
	call	_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_
.L93:
	cmpl	$8, %ebp
	jg	.L83
	jmp	.L94
.L107:
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	%r13d, (%rbx,%rax,4)
	movl	%ebp, 36(%rsp)
	movl	%r12d, 40(%rsp)
	movl	%r14d, 44(%rsp)
	call	_ZNSt7__cxx114listI4int3SaIS1_EE9push_backEOS1_
.LEHE0:
	jmp	.L83
.L105:
	movq	%rax, %rdi
	call	_ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L99
	jmp	.L103
.L101:
	endbr64
	movq	%rax, %rbx
.L97:
	movq	(%rsp), %rdi
	call	_ZNSt7__cxx1110_List_baseI4int3SaIS1_EE8_M_clearEv
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L103
	movq	%rbx, %rdi
.LEHB1:
	call	_Unwind_Resume@PLT
.LEHE1:
.L103:
	call	__stack_chk_fail@PLT
.L99:
	addq	$88, %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
.LFE3094:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3094:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3094-.LLSDACSB3094
.LLSDACSB3094:
	.uleb128 .LEHB0-.LFB3094
	.uleb128 .LEHE0-.LEHB0
	.uleb128 .L101-.LFB3094
	.uleb128 0
	.uleb128 .LEHB1-.LFB3094
	.uleb128 .LEHE1-.LEHB1
	.uleb128 0
	.uleb128 0
.LLSDACSE3094:
	.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:
.LFB3327:
	.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	.L112
	movabsq	$2305843009213693951, %rax
	cmpq	%rsi, %rax
	jnb	.L110
	movabsq	$4611686018427387903, %rax
	cmpq	%rsi, %rax
	jnb	.L111
	call	_ZSt28__throw_bad_array_new_lengthv@PLT
.L111:
	call	_ZSt17__throw_bad_allocv@PLT
.L110:
	movq	%rbp, %rdi
	call	_Znwm@PLT
	jmp	.L109
.L112:
	xorl	%eax, %eax
.L109:
	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
.LFE3327:
	.size	_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm, .-_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm
	.section	.rodata._ZNSt6vectorIfSaIfEEC2EmRKS0_.str1.1,"aMS",@progbits,1
.LC15:
	.string	"cannot create std::vector larger than max_size()"
	.section	.text._ZNSt6vectorIfSaIfEEC2EmRKS0_,"axG",@progbits,_ZNSt6vectorIfSaIfEEC5EmRKS0_,comdat
	.align 2
	.weak	_ZNSt6vectorIfSaIfEEC2EmRKS0_
	.type	_ZNSt6vectorIfSaIfEEC2EmRKS0_, @function
_ZNSt6vectorIfSaIfEEC2EmRKS0_:
.LFB3196:
	.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	.L115
	leaq	.LC15(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L115:
	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	.L116
	movl	$0x00000000, (%rax)
	leaq	4(%rax), %rdx
	decq	%rbx
	je	.L119
	leaq	(%rdx,%rbx,4), %rcx
	movq	%rdx, %rsi
.L117:
	cmpq	%rsi, %rcx
	je	.L124
	movl	$0x00000000, (%rsi)
	addq	$4, %rsi
	jmp	.L117
.L124:
	subq	%rax, %rcx
	leaq	-4(%rdx,%rcx), %rax
	jmp	.L116
.L119:
	movq	%rdx, %rax
.L116:
	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
.LFE3196:
	.size	_ZNSt6vectorIfSaIfEEC2EmRKS0_, .-_ZNSt6vectorIfSaIfEEC2EmRKS0_
	.weak	_ZNSt6vectorIfSaIfEEC1EmRKS0_
	.set	_ZNSt6vectorIfSaIfEEC1EmRKS0_,_ZNSt6vectorIfSaIfEEC2EmRKS0_
	.text
	.globl	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.type	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE, @function
_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE:
.LFB3093:
	.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
	movl	$2, %esi
	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	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	leaq	16(%rsp), %rbp
	movq	%r12, %rdx
	movq	%rbp, %rdi
	call	_ZNSt6vectorIfSaIfEEC1EmRKS0_
	movq	0(%r13), %rax
	movq	16(%rsp), %r15
	leaq	800(%rbx), %r13
	movss	.LC16(%rip), %xmm0
	movss	(%rax), %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%r15)
	mulss	4(%rax), %xmm0
	xorl	%eax, %eax
	movl	%eax, 12(%rsp)
	movss	%xmm0, 4(%r15)
.L126:
	xorl	%r14d, %r14d
.L127:
	movq	24(%rsp), %rdx
	movq	%r15, %rsi
	movq	%r12, %rdi
	subq	%r15, %rdx
	sarq	$2, %rdx
	call	_Z13sampleFromPdfPjPfi
	movl	%eax, (%rbx,%r14,8)
	cltq
	incq	%r14
	leaq	(%r15,%rax,4), %rax
	movss	(%rax), %xmm0
	subss	.LC17(%rip), %xmm0
	movss	%xmm0, (%rax)
	cmpq	$10, %r14
	jne	.L127
	addq	$80, %rbx
	cmpq	%rbx, %r13
	jne	.L126
	movq	%rbp, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L129
	call	__stack_chk_fail@PLT
.L129:
	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
.LFE3093:
	.size	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE, .-_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.section	.rodata.str1.1
.LC19:
	.string	"generateZoningPlan: %lf\n"
.LC20:
	.string	"start...\n"
.LC21:
	.string	"r"
.LC22:
	.string	"zone.txt"
.LC23:
	.string	"%d,"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3113:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3113
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$800, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$152, %rsp
	.cfi_def_cfa_offset 208
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	112(%rsp), %r12
	call	malloc@PLT
	movl	$6, %esi
	movq	%r12, %rdx
	movq	%rax, %rbx
	leaq	88(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
.LEHB2:
	call	_ZNSt6vectorIfSaIfEEC1EmRKS0_
.LEHE2:
	movq	88(%rsp), %r13
	movabsq	$4489188110478868480, %rax
	movq	%rax, 0(%r13)
	movabsq	$4453159313439771853, %rax
	movq	%rax, 8(%r13)
	movabsq	$4417130516412419277, %rax
	movq	%rax, 16(%r13)
	call	clock@PLT
	movq	96(%rsp), %rbp
	movq	%r12, %rdi
	movq	%rax, %r14
	xorl	%eax, %eax
	subq	%r13, %rbp
	movq	%rax, 112(%rsp)
	movq	%rbp, %rsi
	movq	%rax, 120(%rsp)
	sarq	$2, %rsi
	movq	%rax, 128(%rsp)
.LEHB3:
	call	_ZNSt12_Vector_baseIfSaIfEE17_M_create_storageEm
.LEHE3:
	movq	112(%rsp), %rcx
	cmpq	$4, %rbp
	jle	.L133
	movq	%rcx, %rdi
	movq	%rbp, %rdx
	movq	%r13, %rsi
	call	memmove@PLT
	movq	%rax, %rcx
	jmp	.L134
.L133:
	jne	.L134
	movss	0(%r13), %xmm0
	movss	%xmm0, (%rcx)
.L134:
	addq	%rbp, %rcx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	movq	%rcx, 120(%rsp)
.LEHB4:
	call	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
.LEHE4:
	movq	%r12, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	call	clock@PLT
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	subq	%r14, %rax
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	divsd	.LC18(%rip), %xmm0
.LEHB5:
	call	__printf_chk@PLT
	leaq	24(%rsp), %rdi
	movl	$800, %esi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L135
	movl	$437, %ecx
.L183:
	leaq	.LC2(%rip), %rdx
	leaq	.LC3(%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	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L135:
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movl	$800, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	movl	$438, %ecx
	testl	%eax, %eax
	jne	.L183
	movq	24(%rsp), %rdi
	call	_Z17showDevZoningPlanP10ZoningPlan
	leaq	32(%rsp), %rdi
	movl	$400, %esi
	call	cudaMalloc@PLT
	movl	$447, %ecx
	testl	%eax, %eax
	jne	.L183
	leaq	40(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movl	$461, %ecx
	testl	%eax, %eax
	jne	.L183
	leaq	48(%rsp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movl	$463, %ecx
	testl	%eax, %eax
	jne	.L183
	leaq	.LC20(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	56(%rsp), %rdi
	movl	$24000, %esi
	call	cudaMalloc@PLT
	movl	$471, %ecx
	testl	%eax, %eax
	jne	.L183
	leaq	64(%rsp), %rdi
	movl	$120000, %esi
	call	cudaMalloc@PLT
	movl	$475, %ecx
	testl	%eax, %eax
	jne	.L183
	leaq	.LC21(%rip), %rsi
	leaq	.LC22(%rip), %rdi
	call	fopen@PLT
	movq	%rax, %r14
	xorl	%ebp, %ebp
	leaq	.LC23(%rip), %r15
.L143:
	leaq	(%rbx,%rbp,8), %r13
	xorl	%r12d, %r12d
.L144:
	movq	%r13, %rdx
	movq	%r15, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	incl	%r12d
	addq	$8, %r13
	cmpl	$10, %r12d
	jne	.L144
	addq	$10, %rbp
	cmpq	$100, %rbp
	jne	.L143
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movl	$800, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	movl	$506, %ecx
	testl	%eax, %eax
	jne	.L183
	movq	24(%rsp), %rdi
	call	_Z17showDevZoningPlanP10ZoningPlan
	movl	$536870913, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	salq	$3, %rdx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	$1, 120(%rsp)
	movq	%rdx, 112(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L147
	movq	64(%rsp), %r9
	movq	48(%rsp), %r8
	movq	40(%rsp), %rcx
	movq	56(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z82__device_stub__Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP5uint3PiS5_S4_P10ZoningPlanP11DistanceMapP5uint3PiS5_S4_
.L147:
	call	cudaDeviceSynchronize@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	_Z14showDevDistMapP11DistanceMapi
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	xorl	%ecx, %ecx
	movq	56(%rsp), %rdi
	call	_Z12showDevQueueP5uint3PiS1_i
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
.LEHE5:
	movq	%rbx, %rdi
	call	free@PLT
	leaq	88(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L151
	jmp	.L156
.L153:
	endbr64
	movq	%rax, %rbx
.L148:
	movq	%r12, %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	jmp	.L149
.L154:
	endbr64
	movq	%rax, %rbx
.L149:
	movq	8(%rsp), %rdi
	call	_ZNSt6vectorIfSaIfEED1Ev
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L156
	movq	%rbx, %rdi
.LEHB6:
	call	_Unwind_Resume@PLT
.LEHE6:
.L156:
	call	__stack_chk_fail@PLT
.L151:
	addq	$152, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3113:
	.section	.gcc_except_table
.LLSDA3113:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3113-.LLSDACSB3113
.LLSDACSB3113:
	.uleb128 .LEHB2-.LFB3113
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB3-.LFB3113
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L154-.LFB3113
	.uleb128 0
	.uleb128 .LEHB4-.LFB3113
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L153-.LFB3113
	.uleb128 0
	.uleb128 .LEHB5-.LFB3113
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L154-.LFB3113
	.uleb128 0
	.uleb128 .LEHB6-.LFB3113
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
.LLSDACSE3113:
	.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
.LC16:
	.long	1120403456
	.align 4
.LC17:
	.long	1065353216
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC18:
	.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で並列化することで、さらに計算時間を短縮できる。
 *
 * shared memoryを使用して高速化できるか？
 */


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

#define CITY_SIZE 10 //200
#define GPU_BLOCK_SIZE 10//40
#define GPU_NUM_THREADS 8 //96
#define GPU_BLOCK_SCALE (1.0)//(1.1)
#define NUM_FEATURES 1
#define QUEUE_MAX 1999
#define MAX_DIST 99
#define HISTORY_SIZE 10000

#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) {}
};

__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(NUM_FEATURES + 1);
	for (int i = 0; i < NUM_FEATURES + 1; ++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;
		}
	}
}



/**
 * 直近の店までの距離を計算する（マルチスレッド版、shared memory使用）
 */
__global__
void computeDistanceToStore(ZoningPlan* zoningPlan, DistanceMap* distanceMap, uint3* devQueue, int* devQueueStart, int* devQueueEnd, uint3* devHistory) {
	__shared__ int sDist[(int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE)][(int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE)][NUM_FEATURES];
	__shared__ uint3 sQueue[QUEUE_MAX + 1];
	__shared__ unsigned int queue_begin;
	__shared__ unsigned int queue_end;
	__shared__ unsigned int history_index;

	queue_begin = 0;
	queue_end = 0;
	history_index = 0;
	__syncthreads();

	// queueを初期化
	for (int i = threadIdx.x; i < QUEUE_MAX + 1; i += GPU_NUM_THREADS) {
		sQueue[i] = make_uint3(CITY_SIZE * 100, CITY_SIZE * 100, NUM_FEATURES);
	}

	// global memoryからshared memoryへコピー
	int num_strides = (GPU_BLOCK_SIZE * GPU_BLOCK_SIZE * GPU_BLOCK_SCALE * GPU_BLOCK_SCALE + GPU_NUM_THREADS - 1) / GPU_NUM_THREADS;
	int r0 = blockIdx.y * GPU_BLOCK_SIZE - GPU_BLOCK_SIZE * (GPU_BLOCK_SCALE - 1) * 0.5;
	int c0 = blockIdx.x * GPU_BLOCK_SIZE - GPU_BLOCK_SIZE * (GPU_BLOCK_SCALE - 1) * 0.5;
	for (int i = 0; i < num_strides; ++i) {
		int r1 = (i * GPU_NUM_THREADS + threadIdx.x) / (int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE);
		int c1 = (i * GPU_NUM_THREADS + threadIdx.x) % (int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE);

		// これ、忘れてた！！
		if (r1 >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE || c1 >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE) continue;

		int type = 0;
		if (r0 + r1 >= 0 && r0 + r1 < CITY_SIZE && c0 + c1 >= 0 && c0 + c1 < CITY_SIZE) {
			type = zoningPlan->zones[r0 + r1][c0 + c1].type;
		}
		for (int feature_id = 0; feature_id < NUM_FEATURES; ++feature_id) {
			distanceMap->distances[r0 + r1][c0 + c1][feature_id] = MAX_DIST;
			if (type - 1 == feature_id) {
				sDist[r1][c1][feature_id] = 0;
				unsigned int q_index = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index] = make_uint3(c1, r1, feature_id);
			} else {
				sDist[r1][c1][feature_id] = MAX_DIST;
			}
		}
	}
	__syncthreads();


	// 距離マップを生成
	unsigned int q_index;
	//while ((q_index = atomicInc(&queue_begin, QUEUE_MAX)) < queue_end) {
	for (int iter = 0; iter < 7000; ++iter) {
		q_index = atomicInc(&queue_begin, QUEUE_MAX);
		
	//while (queue_begin < queue_end) {
		uint3 pt = sQueue[q_index];
		if (pt.x < 0 || pt.x >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE || pt.y < 0 || pt.y >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE) {
			break;
		}

		int d = sDist[pt.y][pt.x][pt.z];
		int count = 0;

		if (pt.y > 0) {
			unsigned int old = atomicMin(&sDist[pt.y-1][pt.x][pt.z], d + 1);
			if (old > d + 1) {
				unsigned int q_index2 = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index2] = make_uint3(pt.x, pt.y-1, pt.z);
				count++;
				if (count == 60) {
					unsigned int h_ind = atomicInc(&history_index, HISTORY_SIZE - 1);
					//devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x + (pt.y-1) * CITY_SIZE, pt.z);
					devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x + (pt.y-1) * CITY_SIZE, q_index2);
				}
			}
		}
		if (pt.y < CITY_SIZE - 1) {
			unsigned int old = atomicMin(&sDist[pt.y+1][pt.x][pt.z], d + 1);
			if (old > d + 1) {
				unsigned int q_index2 = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index2] = make_uint3(pt.x, pt.y+1, pt.z);
				count++;
				if (count == 60) {
					unsigned int h_ind = atomicInc(&history_index, HISTORY_SIZE - 1);
					//devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x + (pt.y+1) * CITY_SIZE, pt.z);
					devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x + (pt.y+1) * CITY_SIZE, q_index2);
				}
			}
		}
		if (pt.x > 0) {
			unsigned int old = atomicMin(&sDist[pt.y][pt.x-1][pt.z], d + 1);
			if (old > d + 1) {
				unsigned int q_index2 = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index2] = make_uint3(pt.x-1, pt.y, pt.z);
				count++;
				if (count == 60) {
					unsigned int h_ind = atomicInc(&history_index, HISTORY_SIZE - 1);
					//devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x-1 + pt.y * CITY_SIZE, pt.z);
					devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x-1 + pt.y * CITY_SIZE, q_index2);
				}
			}
		}
		if (pt.x < CITY_SIZE - 1) {
			unsigned int old = atomicMin(&sDist[pt.y][pt.x+1][pt.z], d + 1);
			if (old > d + 1) {
				unsigned int q_index2 = atomicInc(&queue_end, QUEUE_MAX);
				sQueue[q_index2] = make_uint3(pt.x+1, pt.y, pt.z);
				count++;
				if (count == 60) {
					unsigned int h_ind = atomicInc(&history_index, HISTORY_SIZE - 1);
					//devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x+1 + pt.y * CITY_SIZE, pt.z);
					devHistory[h_ind] = make_uint3(pt.x + pt.y * CITY_SIZE, pt.x+1 + pt.y * CITY_SIZE, q_index2);
				}
			}
		}

		sQueue[q_index] = make_uint3(CITY_SIZE * 100, CITY_SIZE * 100, NUM_FEATURES);
	}
	
	__syncthreads();

	// global memoryの距離マップへ、コピーする
	for (int i = 0; i < num_strides; ++i) {
		int r1 = (i * GPU_NUM_THREADS + threadIdx.x) / (int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE);
		int c1 = (i * GPU_NUM_THREADS + threadIdx.x) % (int)(GPU_BLOCK_SIZE * GPU_BLOCK_SCALE);

		// これ、忘れてた！！
		if (r1 >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE || c1 >= GPU_BLOCK_SIZE * GPU_BLOCK_SCALE) continue;

		if (r0 + r1 >= 0 && r0 + r1 < CITY_SIZE && c0 + c1 >= 0 && c0 + c1 < CITY_SIZE) {
			for (int feature_id = 0; feature_id < NUM_FEATURES; ++feature_id) {
				atomicMin(&distanceMap->distances[r0 + r1][c0 + c1][feature_id], sDist[r1][c1][feature_id]);
			}
		}
	}

	// デバッグ用に、キュー情報をglobalにコピー
	for (int i = 0; i < queue_end; ++i) {
		devQueue[i] = sQueue[i];
	}
	*devQueueStart = queue_begin;
	*devQueueEnd = queue_end;

}

/**
 * 直近の店までの距離を計算する（CPU版）
 */
__host__
void computeDistanceToStoreCPU(ZoningPlan* zoningPLan, DistanceMap* distanceMap) {
	std::list<int3> 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(make_int3(c, r, feature_id));
				distanceMap->distances[r][c][feature_id] = 0;
			} else {
				distanceMap->distances[r][c][feature_id] = MAX_DIST;
			}
		}
	}

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

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

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

/**
 * デバッグ用に、ゾーンプランを表示する。
 */
__host__
void showDevZoningPlan(ZoningPlan* zoningPlan) {
	ZoningPlan plan;

	CUDA_CALL(hipMemcpy(&plan, zoningPlan, sizeof(ZoningPlan), hipMemcpyDeviceToHost));
	printf("Zone plan:\n");
	for (int r = CITY_SIZE - 1; r >= 0; --r) {
		for (int c = 0; c < CITY_SIZE; ++c) {
			printf("%2d, ", plan.zones[r][c].type);
		}
		printf("\n");
	}
	printf("\n");
}

/**
 * デバッグ用に、距離マップを表示する。
 */
__host__
void showDevDistMap(DistanceMap* distMap, int feature_id) {
	DistanceMap map;

	CUDA_CALL(hipMemcpy(&map, distMap, sizeof(DistanceMap), hipMemcpyDeviceToHost));
	printf("Distance map:\n");
	for (int r = CITY_SIZE - 1; r >= 0; --r) {
		for (int c = 0; c < CITY_SIZE; ++c) {
			printf("%2d, ", map.distances[r][c][feature_id]);
		}
		printf("\n");
	}
	printf("\n");
}

/**
 * デバッグ用に、キューの内容を表示する。
 */
__host__
void showDevQueue(uint3* queue, int* queueBegin, int* queueEnd, int featureId) {
	uint3 q[QUEUE_MAX + 1];
	int begin;
	int end;

	CUDA_CALL(hipMemcpy(q, queue, sizeof(uint3) * (QUEUE_MAX + 1), hipMemcpyDeviceToHost));
	CUDA_CALL(hipMemcpy(&begin, queueBegin, sizeof(int), hipMemcpyDeviceToHost));
	CUDA_CALL(hipMemcpy(&end, queueEnd, sizeof(int), hipMemcpyDeviceToHost));

	printf("Queue:\n");
	printf("Begin: %d, End: %d, featureId: %d\n", begin, end, featureId);

	int num = end - begin + 1;
	if (num < 0) {
		num = end + QUEUE_MAX + 1 - begin + 1;
	}

	for (int i = 0; i < num; ++i) {
		if (q[(begin + i) % (QUEUE_MAX + 1)].z == featureId) {
			printf("%3d: %3d, %3d\n", (begin + i) % (QUEUE_MAX + 1), q[(begin + i) % (QUEUE_MAX + 1)].x, q[(begin + i) % (QUEUE_MAX + 1)].y);
		}
	}
	printf("\n");
}

__host__
void showDevHistory(uint3* devHistory) {
	uint3 history[HISTORY_SIZE];
	CUDA_CALL(hipMemcpy(history, devHistory, sizeof(uint3) * HISTORY_SIZE, hipMemcpyDeviceToHost));

	printf("History:\n");
	for (int i = 0; i < 100; ++i) {
		int x0 = history[i].x % CITY_SIZE;
		int y0 = history[i].x / CITY_SIZE;
		int x1 = history[i].y % CITY_SIZE;
		int y1 = history[i].y / CITY_SIZE;
		int featureId = history[i].z;
		printf("%2d: (%3d, %3d) -> (%3d, %3d) (%d)\n", i, x0, y0, x1, y1, featureId);
	}
	printf("\n");
}


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, MAX_DIST, sizeof(DistanceMap));
	//memset(hostDistanceMap2, MAX_DIST, 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);
	
	// 初期プランをデバイスバッファへコピー
	ZoningPlan* devZoningPlan;
	CUDA_CALL(hipMalloc((void**)&devZoningPlan, sizeof(ZoningPlan)));
	CUDA_CALL(hipMemcpy(devZoningPlan, hostZoningPlan, sizeof(ZoningPlan), hipMemcpyHostToDevice));

	// デバッグ用に、初期プランを表示
	if (CITY_SIZE <= 100) {
		showDevZoningPlan(devZoningPlan);
	}

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

	///////////////////////////////////////////////////////////////////////
	// 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);
	*/

	int* devQueueStart;
	CUDA_CALL(hipMalloc((void**)&devQueueStart, sizeof(int)));
	int* devQueueEnd;
	CUDA_CALL(hipMalloc((void**)&devQueueEnd, sizeof(int)));

	printf("start...\n");



	// デバッグ用に、globalにqueueメモリを確保
	uint3* devQueue;
	CUDA_CALL(hipMalloc((void**)&devQueue, sizeof(uint3) * (QUEUE_MAX + 1)));

	// デバッグ用に、globalにwavefrontメモリを確保
	uint3* devHistory;
	CUDA_CALL(hipMalloc((void**)&devHistory, sizeof(uint3) * HISTORY_SIZE));





	/*
	///////////////////////////////////////////////////////////////////////
	// warmp up
	computeDistanceToStore<<<dim3(CITY_SIZE / GPU_BLOCK_SIZE, CITY_SIZE / GPU_BLOCK_SIZE), GPU_NUM_THREADS>>>(devZoningPlan, devDistanceMap, devQueue);

	// マルチスレッドで、直近の店までの距離を計算
	start = clock();
	for (int iter = 0; iter < 1000; ++iter) {
		computeDistanceToStore<<<dim3(CITY_SIZE / GPU_BLOCK_SIZE, CITY_SIZE / GPU_BLOCK_SIZE), GPU_NUM_THREADS>>>(devZoningPlan, devDistanceMap, devQueue);
		cudaDeviceSynchronize();
	}
	end = clock();
	printf("computeDistanceToStore GPU: %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
	*/



	// テンポラリ　デバッグ用
	// バグの対処中。。。。
	FILE* fp = fopen("zone.txt", "r");
	for (int r = 0; r < CITY_SIZE; ++r) {
		for (int c = 0; c < CITY_SIZE; ++c) {
			fscanf(fp, "%d,", &hostZoningPlan->zones[r][c].type);
		}
	}
	CUDA_CALL(hipMemcpy(devZoningPlan, hostZoningPlan, sizeof(ZoningPlan), hipMemcpyHostToDevice));
	showDevZoningPlan(devZoningPlan);
	computeDistanceToStore<<<dim3(CITY_SIZE / GPU_BLOCK_SIZE, CITY_SIZE / GPU_BLOCK_SIZE), GPU_NUM_THREADS>>>(devZoningPlan, devDistanceMap, devQueue, devQueueStart, devQueueEnd, devHistory);
	hipDeviceSynchronize();




	// 距離マップを表示
	showDevDistMap(devDistanceMap, 0);

	// キューを表示
	showDevQueue(devQueue, devQueueStart, devQueueEnd, 0);

	// hisotryを表示
	//showDevHistory(devHistory);

	/*
	// compare the results with the CPU version of the exact algrotihm
	int bad_k = 0;
	int bad_count = 0;
	{	
		for (int r = CITY_SIZE - 1; r >= 0; --r) {
			for (int c = 0; c < CITY_SIZE; ++c) {
				for (int k = 0; k < NUM_FEATURES; ++k) {
					if (hostDistanceMap->distances[r][c][k] != hostDistanceMap2->distances[r][c][k]) {
						if (bad_count == 0) {
							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;
						}
						bad_count++;
					}
				}
			}

		}
	}

	// for debug
	if (CITY_SIZE <= 200 && bad_count > 0) {
		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");
	}

	printf("Total error: %d\n", bad_count);
	*/

	// release device buffer
	hipFree(devZoningPlan);
	hipFree(devDistanceMap);

	// release host buffer
	free(hostZoningPlan);
	free(hostDistanceMap);
	free(hostDistanceMap2);

	//cudaDeviceReset();
}

	.text
	.file	"shared_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	0x42c80000                      # float 100
.LCPI5_1:
	.long	0xbf800000                      # float -1
	.text
	.globl	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.type	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE,@function
_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE: # @_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.cfi_startproc
# %bb.0:                                # %.critedge
	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	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %r15
	movq	%rdi, %rbx
	movl	$8, %edi
	callq	_Znwm
	movq	%rax, %r14
	movq	$0, (%rax)
	movq	(%r15), %rax
	movss	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	(%rax), %xmm1                   # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%r14)
	mulss	4(%rax), %xmm0
	movss	%xmm0, 4(%r14)
	leaq	12(%rsp), %r15
	movl	$0, (%r15)
	xorl	%r12d, %r12d
.LBB5_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_2 Depth 2
	xorl	%r13d, %r13d
.LBB5_2:                                #   Parent Loop BB5_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r15, %rdi
	movq	%r14, %rsi
	movl	$2, %edx
	callq	_Z13sampleFromPdfPjPfi
	movss	.LCPI5_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movl	%eax, (%rbx,%r13,8)
	cltq
	movss	(%r14,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	%xmm1, %xmm0
	movss	%xmm0, (%r14,%rax,4)
	incq	%r13
	cmpq	$10, %r13
	jne	.LBB5_2
# %bb.3:                                #   in Loop: Header=BB5_1 Depth=1
	incq	%r12
	addq	$80, %rbx
	cmpq	$10, %r12
	jne	.LBB5_1
# %bb.4:                                # %_ZNSt6vectorIfSaIfEED2Ev.exit
	movq	%r14, %rdi
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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
	jmp	_ZdlPv                          # TAILCALL
.Lfunc_end5:
	.size	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE, .Lfunc_end5-_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
	.cfi_endproc
                                        # -- End function
	.globl	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_ # -- Begin function _Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.type	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_,@function
_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_: # @_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_, .Lfunc_end6-_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.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:                                # %.critedge
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, 48(%rsp)                  # 8-byte Spill
	movq	%rdi, %r15
	leaq	16(%rsp), %rbp
	movq	%rbp, 8(%rbp)
	movq	%rbp, (%rbp)
	movq	$0, 16(%rbp)
	xorl	%r12d, %r12d
	movabsq	$-3689348814741910323, %rbx     # imm = 0xCCCCCCCCCCCCCCCD
	movl	$4294967286, %r14d              # imm = 0xFFFFFFF6
.LBB7_1:                                # =>This Inner Loop Header: Depth=1
	movq	%r12, %rax
	mulq	%rbx
	movl	$99, %eax
	cmpl	$1, (%r15,%r12,8)
	jne	.LBB7_4
# %bb.2:                                #   in Loop: Header=BB7_1 Depth=1
.Ltmp0:
	movq	%rdx, %r13
	movl	$32, %edi
	callq	_Znwm
.Ltmp1:
# %bb.3:                                #   in Loop: Header=BB7_1 Depth=1
	shrq	$3, %r13
	imulq	%r14, %r13
	addq	%r12, %r13
	movq	%r13, 16(%rax)
	movl	$0, 24(%rax)
	movq	%rax, %rdi
	movq	%rbp, %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	32(%rsp)
	xorl	%eax, %eax
.LBB7_4:                                #   in Loop: Header=BB7_1 Depth=1
	movq	48(%rsp), %rcx                  # 8-byte Reload
	movl	%eax, (%rcx,%r12,4)
	incq	%r12
	cmpl	$100, %r12d
	jne	.LBB7_1
	jmp	.LBB7_5
.LBB7_6:                                # %.lr.ph
                                        #   in Loop: Header=BB7_5 Depth=1
	movl	16(%r15), %eax
	movl	24(%r15), %ebx
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movslq	%eax, %r13
	movslq	20(%r15), %r12
	decq	32(%rsp)
	movq	%r15, %rdi
	callq	_ZNSt8__detail15_List_node_base9_M_unhookEv
	movq	%r15, %rdi
	callq	_ZdlPv
	movl	%ebx, 4(%rsp)                   # 4-byte Spill
	movslq	%ebx, %r15
	leaq	(%r12,%r12,4), %rax
	movq	48(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,8), %rdx
	leaq	(%rdx,%r13,4), %rax
	movl	(%rax,%r15,4), %r14d
	testq	%r12, %r12
	jle	.LBB7_7
# %bb.8:                                #   in Loop: Header=BB7_5 Depth=1
	leal	-1(%r12), %ebx
	leaq	(%rbx,%rbx,4), %rax
	leaq	(%rcx,%rax,8), %rax
	leaq	(%rax,%r13,4), %rax
	leal	1(%r14), %ebp
	cmpl	%ebp, (%rax,%r15,4)
	jle	.LBB7_11
# %bb.9:                                #   in Loop: Header=BB7_5 Depth=1
	movq	%r13, 8(%rsp)                   # 8-byte Spill
	movq	%rdx, %r13
	leaq	(%rax,%r15,4), %rax
	movl	%ebp, (%rax)
.Ltmp3:
	movl	$32, %edi
	callq	_Znwm
.Ltmp4:
# %bb.10:                               #   in Loop: Header=BB7_5 Depth=1
	shlq	$32, %rbx
	addq	40(%rsp), %rbx                  # 8-byte Folded Reload
	movq	%rbx, 16(%rax)
	movl	4(%rsp), %ecx                   # 4-byte Reload
	movl	%ecx, 24(%rax)
	movq	%rax, %rdi
	leaq	16(%rsp), %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	32(%rsp)
	movq	%r13, %rdx
	movq	8(%rsp), %r13                   # 8-byte Reload
.LBB7_11:                               #   in Loop: Header=BB7_5 Depth=1
	cmpl	$8, %r12d
	jbe	.LBB7_12
	jmp	.LBB7_15
.LBB7_7:                                # %.lr.ph..thread_crit_edge
                                        #   in Loop: Header=BB7_5 Depth=1
	leal	1(%r14), %ebp
.LBB7_12:                               # %.thread
                                        #   in Loop: Header=BB7_5 Depth=1
	leaq	1(%r12), %rbx
	leaq	(%rbx,%rbx,4), %rax
	movq	48(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,8), %rax
	leaq	(%rax,%r13,4), %rax
	cmpl	%ebp, (%rax,%r15,4)
	jle	.LBB7_15
# %bb.13:                               #   in Loop: Header=BB7_5 Depth=1
	movq	%rdx, 8(%rsp)                   # 8-byte Spill
	leaq	(%rax,%r15,4), %rax
	movl	%ebp, (%rax)
.Ltmp6:
	movl	$32, %edi
	callq	_Znwm
.Ltmp7:
# %bb.14:                               #   in Loop: Header=BB7_5 Depth=1
	shlq	$32, %rbx
	movl	%r13d, %ecx
	orq	%rbx, %rcx
	movq	%rcx, 16(%rax)
	movl	4(%rsp), %ecx                   # 4-byte Reload
	movl	%ecx, 24(%rax)
	movq	%rax, %rdi
	leaq	16(%rsp), %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	32(%rsp)
	movq	8(%rsp), %rdx                   # 8-byte Reload
.LBB7_15:                               #   in Loop: Header=BB7_5 Depth=1
	movq	40(%rsp), %rcx                  # 8-byte Reload
	testl	%ecx, %ecx
	jle	.LBB7_16
# %bb.17:                               #   in Loop: Header=BB7_5 Depth=1
	movl	%ecx, %ebx
	decl	%ebx
	leaq	(%rdx,%rbx,4), %rax
	incl	%r14d
	cmpl	%r14d, (%rax,%r15,4)
	leaq	16(%rsp), %rbp
	jle	.LBB7_20
# %bb.18:                               #   in Loop: Header=BB7_5 Depth=1
	movq	%r13, 8(%rsp)                   # 8-byte Spill
	movq	%rdx, %r13
	leaq	(%rax,%r15,4), %rax
	movl	%r14d, (%rax)
.Ltmp9:
	movl	$32, %edi
	callq	_Znwm
.Ltmp10:
# %bb.19:                               #   in Loop: Header=BB7_5 Depth=1
	movq	%r12, %rcx
	shlq	$32, %rcx
	orq	%rbx, %rcx
	movq	%rcx, 16(%rax)
	movl	4(%rsp), %ecx                   # 4-byte Reload
	movl	%ecx, 24(%rax)
	movq	%rax, %rdi
	movq	%rbp, %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	32(%rsp)
	movq	40(%rsp), %rcx                  # 8-byte Reload
	movq	%r13, %rdx
	movq	8(%rsp), %r13                   # 8-byte Reload
.LBB7_20:                               #   in Loop: Header=BB7_5 Depth=1
	cmpl	$8, %ecx
	ja	.LBB7_5
	jmp	.LBB7_21
.LBB7_16:                               # %..thread148_crit_edge
                                        #   in Loop: Header=BB7_5 Depth=1
	incl	%r14d
	leaq	16(%rsp), %rbp
.LBB7_21:                               # %.thread148
                                        #   in Loop: Header=BB7_5 Depth=1
	leaq	(%rdx,%r13,4), %rax
	addq	$4, %rax
	cmpl	%r14d, (%rax,%r15,4)
	jle	.LBB7_5
# %bb.22:                               #   in Loop: Header=BB7_5 Depth=1
	leaq	(%rax,%r15,4), %rax
	movl	%r14d, (%rax)
.Ltmp12:
	movl	$32, %edi
	callq	_Znwm
.Ltmp13:
# %bb.23:                               #   in Loop: Header=BB7_5 Depth=1
	incq	%r13
	shlq	$32, %r12
	movl	%r13d, %ecx
	orq	%r12, %rcx
	movq	%rcx, 16(%rax)
	movl	4(%rsp), %ecx                   # 4-byte Reload
	movl	%ecx, 24(%rax)
	movq	%rax, %rdi
	movq	%rbp, %rsi
	callq	_ZNSt8__detail15_List_node_base7_M_hookEPS0_
	incq	32(%rsp)
.LBB7_5:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	16(%rsp), %r15
	cmpq	%rbp, %r15
	jne	.LBB7_6
# %bb.24:                               # %_ZNSt7__cxx1110_List_baseI15HIP_vector_typeIiLj3EESaIS2_EED2Ev.exit
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB7_31:
	.cfi_def_cfa_offset 112
.Ltmp11:
	jmp	.LBB7_26
.LBB7_29:
.Ltmp5:
	jmp	.LBB7_26
.LBB7_32:
.Ltmp14:
	jmp	.LBB7_26
.LBB7_30:
.Ltmp8:
	jmp	.LBB7_26
.LBB7_25:
.Ltmp2:
.LBB7_26:
	movq	%rax, %r14
	movq	16(%rsp), %rdi
	leaq	16(%rsp), %r15
	cmpq	%r15, %rdi
	je	.LBB7_28
.LBB7_27:                               # %.lr.ph.i.i136
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rdi), %rbx
	callq	_ZdlPv
	movq	%rbx, %rdi
	cmpq	%r15, %rbx
	jne	.LBB7_27
.LBB7_28:                               # %_ZNSt7__cxx1110_List_baseI15HIP_vector_typeIiLj3EESaIS2_EED2Ev.exit139
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end7:
	.size	_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap, .Lfunc_end7-_Z25computeDistanceToStoreCPUP10ZoningPlanP11DistanceMap
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table7:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 1 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp10-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp10
	.uleb128 .Ltmp11-.Lfunc_begin0          #     jumps to .Ltmp11
	.byte	0                               #   On action: cleanup
	.uleb128 .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_end7-.Ltmp13            #   Call between .Ltmp13 and .Lfunc_end7
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z17showDevZoningPlanP10ZoningPlan # -- Begin function _Z17showDevZoningPlanP10ZoningPlan
	.type	_Z17showDevZoningPlanP10ZoningPlan,@function
_Z17showDevZoningPlanP10ZoningPlan:     # @_Z17showDevZoningPlanP10ZoningPlan
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$800, %rsp                      # imm = 0x320
	.cfi_def_cfa_offset 832
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rsi
	movq	%rsp, %rdi
	movl	$800, %edx                      # imm = 0x320
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB8_6
# %bb.1:
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$9, %ebx
	leaq	720(%rsp), %r14
.LBB8_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_3 Depth 2
	xorl	%r15d, %r15d
.LBB8_3:                                #   Parent Loop BB8_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r14,%r15,8), %esi
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	$10, %r15
	jne	.LBB8_3
# %bb.4:                                #   in Loop: Header=BB8_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	addq	$-80, %r14
	subq	$1, %rbx
	jae	.LBB8_2
# %bb.5:
	movl	$10, %edi
	callq	putchar@PLT
	addq	$800, %rsp                      # imm = 0x320
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB8_6:
	.cfi_def_cfa_offset 832
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$334, %edx                      # imm = 0x14E
	xorl	%eax, %eax
	callq	printf
	callq	hipGetLastError
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end8:
	.size	_Z17showDevZoningPlanP10ZoningPlan, .Lfunc_end8-_Z17showDevZoningPlanP10ZoningPlan
	.cfi_endproc
                                        # -- End function
	.globl	_Z14showDevDistMapP11DistanceMapi # -- Begin function _Z14showDevDistMapP11DistanceMapi
	.type	_Z14showDevDistMapP11DistanceMapi,@function
_Z14showDevDistMapP11DistanceMapi:      # @_Z14showDevDistMapP11DistanceMapi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$400, %rsp                      # imm = 0x190
	.cfi_def_cfa_offset 432
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%esi, %ebx
	movq	%rdi, %rsi
	movq	%rsp, %rdi
	movl	$400, %edx                      # imm = 0x190
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB9_6
# %bb.1:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movslq	%ebx, %rax
	leaq	(%rsp,%rax,4), %rbx
	addq	$360, %rbx                      # imm = 0x168
	movl	$9, %r14d
.LBB9_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_3 Depth 2
	xorl	%r15d, %r15d
.LBB9_3:                                #   Parent Loop BB9_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rbx,%r15,4), %esi
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	$10, %r15
	jne	.LBB9_3
# %bb.4:                                #   in Loop: Header=BB9_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	addq	$-40, %rbx
	subq	$1, %r14
	jae	.LBB9_2
# %bb.5:
	movl	$10, %edi
	callq	putchar@PLT
	addq	$400, %rsp                      # imm = 0x190
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB9_6:
	.cfi_def_cfa_offset 432
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$352, %edx                      # imm = 0x160
	xorl	%eax, %eax
	callq	printf
	callq	hipGetLastError
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end9:
	.size	_Z14showDevDistMapP11DistanceMapi, .Lfunc_end9-_Z14showDevDistMapP11DistanceMapi
	.cfi_endproc
                                        # -- End function
	.globl	_Z12showDevQueueP15HIP_vector_typeIjLj3EEPiS2_i # -- Begin function _Z12showDevQueueP15HIP_vector_typeIjLj3EEPiS2_i
	.type	_Z12showDevQueueP15HIP_vector_typeIjLj3EEPiS2_i,@function
_Z12showDevQueueP15HIP_vector_typeIjLj3EEPiS2_i: # @_Z12showDevQueueP15HIP_vector_typeIjLj3EEPiS2_i
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$24024, %rsp                    # imm = 0x5DD8
	.cfi_def_cfa_offset 24064
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebx
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rsi
	leaq	16(%rsp), %rdi
	movl	$24000, %edx                    # imm = 0x5DC0
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB10_1
# %bb.3:
	leaq	8(%rsp), %rdi
	movl	$4, %edx
	movq	%r15, %rsi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB10_4
# %bb.5:
	leaq	12(%rsp), %rdi
	movl	$4, %edx
	movq	%r14, %rsi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB10_6
# %bb.7:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	8(%rsp), %esi
	movl	12(%rsp), %edx
	movl	$.L.str.8, %edi
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	12(%rsp), %eax
	subl	8(%rsp), %eax
	leal	2000(%rax), %ebp
	cmpl	$-1, %eax
	cmovgel	%eax, %ebp
	testl	%ebp, %ebp
	js	.LBB10_12
# %bb.8:                                # %.lr.ph.preheader
	incl	%ebp
	xorl	%r14d, %r14d
.LBB10_9:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	8(%rsp), %eax
	addl	%r14d, %eax
	movslq	%eax, %rsi
	imulq	$274877907, %rsi, %rax          # imm = 0x10624DD3
	movq	%rax, %rcx
	shrq	$63, %rcx
	sarq	$39, %rax
	addl	%ecx, %eax
	imull	$2000, %eax, %eax               # imm = 0x7D0
	subl	%eax, %esi
	movslq	%esi, %rax
	leaq	(%rax,%rax,2), %rax
	cmpl	%ebx, 24(%rsp,%rax,4)
	jne	.LBB10_11
# %bb.10:                               #   in Loop: Header=BB10_9 Depth=1
	leaq	(%rsp,%rax,4), %rax
	addq	$16, %rax
	movl	(%rax), %edx
	movl	4(%rax), %ecx
	movl	$.L.str.9, %edi
                                        # kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	printf
.LBB10_11:                              #   in Loop: Header=BB10_9 Depth=1
	incl	%r14d
	cmpl	%r14d, %ebp
	jne	.LBB10_9
.LBB10_12:                              # %._crit_edge
	movl	$10, %edi
	callq	putchar@PLT
	addq	$24024, %rsp                    # imm = 0x5DD8
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB10_1:
	.cfi_def_cfa_offset 24064
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$372, %edx                      # imm = 0x174
	jmp	.LBB10_2
.LBB10_4:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$373, %edx                      # imm = 0x175
	jmp	.LBB10_2
.LBB10_6:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$374, %edx                      # imm = 0x176
.LBB10_2:
	xorl	%eax, %eax
	callq	printf
	callq	hipGetLastError
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end10:
	.size	_Z12showDevQueueP15HIP_vector_typeIjLj3EEPiS2_i, .Lfunc_end10-_Z12showDevQueueP15HIP_vector_typeIjLj3EEPiS2_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z14showDevHistoryP15HIP_vector_typeIjLj3EE # -- Begin function _Z14showDevHistoryP15HIP_vector_typeIjLj3EE
	.type	_Z14showDevHistoryP15HIP_vector_typeIjLj3EE,@function
_Z14showDevHistoryP15HIP_vector_typeIjLj3EE: # @_Z14showDevHistoryP15HIP_vector_typeIjLj3EE
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$120016, %rsp                   # imm = 0x1D4D0
	.cfi_def_cfa_offset 120048
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rsi
	leaq	16(%rsp), %rdi
	movl	$120000, %edx                   # imm = 0x1D4C0
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB11_4
# %bb.1:
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	leaq	24(%rsp), %r14
	movl	$3435973837, %r15d              # imm = 0xCCCCCCCD
	xorl	%ebx, %ebx
.LBB11_2:                               # =>This Inner Loop Header: Depth=1
	movl	-8(%r14), %edx
	movl	-4(%r14), %r8d
	movq	%rdx, %rcx
	imulq	%r15, %rcx
	shrq	$35, %rcx
	leal	(%rcx,%rcx), %eax
	leal	(%rax,%rax,4), %eax
	subl	%eax, %edx
	movq	%r8, %r9
	imulq	%r15, %r9
	shrq	$35, %r9
	leal	(%r9,%r9), %eax
	leal	(%rax,%rax,4), %eax
	subl	%eax, %r8d
	movl	(%r14), %eax
	movl	%eax, (%rsp)
	movl	$.L.str.11, %edi
	movl	%ebx, %esi
                                        # kill: def $edx killed $edx killed $rdx
                                        # kill: def $ecx killed $ecx killed $rcx
                                        # kill: def $r8d killed $r8d killed $r8
                                        # kill: def $r9d killed $r9d killed $r9
	xorl	%eax, %eax
	callq	printf
	incq	%rbx
	addq	$12, %r14
	cmpq	$100, %rbx
	jne	.LBB11_2
# %bb.3:
	movl	$10, %edi
	callq	putchar@PLT
	addq	$120016, %rsp                   # imm = 0x1D4D0
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB11_4:
	.cfi_def_cfa_offset 120048
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$395, %edx                      # imm = 0x18B
	xorl	%eax, %eax
	callq	printf
	callq	hipGetLastError
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end11:
	.size	_Z14showDevHistoryP15HIP_vector_typeIjLj3EE, .Lfunc_end11-_Z14showDevHistoryP15HIP_vector_typeIjLj3EE
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI12_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
.LCPI12_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	%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	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$800, %edi                      # imm = 0x320
	callq	malloc
	movq	%rax, %rbx
	movl	$24, %edi
	callq	_Znwm
	leaq	72(%rsp), %r15
	movq	%rax, (%r15)
	leaq	24(%rax), %rcx
	movq	%rcx, 16(%r15)
	movq	%rcx, 8(%r15)
	movapd	.LCPI12_0(%rip), %xmm0          # xmm0 = [5.0E-1,2.00000003E-1,1.00000001E-1,1.00000001E-1]
	movupd	%xmm0, (%rax)
	movabsq	$4417130516412419277, %rcx      # imm = 0x3D4CCCCD3D4CCCCD
	movq	%rcx, 16(%rax)
	callq	clock
	movq	%rax, %r14
.Ltmp15:
	leaq	48(%rsp), %rdi
	movq	%r15, %rsi
	callq	_ZNSt6vectorIfSaIfEEC2ERKS1_
.Ltmp16:
# %bb.1:
.Ltmp18:
	leaq	48(%rsp), %rsi
	movq	%rbx, %rdi
	callq	_Z18generateZoningPlanR10ZoningPlanSt6vectorIfSaIfEE
.Ltmp19:
# %bb.2:
	movq	48(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB12_4
# %bb.3:
	callq	_ZdlPv
.LBB12_4:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit
	callq	clock
	subq	%r14, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI12_1(%rip), %xmm0
	movl	$.L.str.12, %edi
	movb	$1, %al
	callq	printf
.Ltmp21:
	movq	%rsp, %rdi
	movl	$800, %esi                      # imm = 0x320
	callq	hipMalloc
.Ltmp22:
# %bb.5:
	testl	%eax, %eax
	jne	.LBB12_6
# %bb.13:
	movq	(%rsp), %rdi
.Ltmp27:
	movl	$800, %edx                      # imm = 0x320
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp28:
# %bb.14:
	testl	%eax, %eax
	jne	.LBB12_15
# %bb.17:
	movq	(%rsp), %rdi
.Ltmp33:
	callq	_Z17showDevZoningPlanP10ZoningPlan
.Ltmp34:
# %bb.18:
.Ltmp36:
	leaq	8(%rsp), %rdi
	movl	$400, %esi                      # imm = 0x190
	callq	hipMalloc
.Ltmp37:
# %bb.19:
	testl	%eax, %eax
	jne	.LBB12_20
# %bb.23:
.Ltmp43:
	leaq	32(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
.Ltmp44:
# %bb.24:
	testl	%eax, %eax
	jne	.LBB12_25
# %bb.28:
.Ltmp50:
	leaq	24(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
.Ltmp51:
# %bb.29:
	testl	%eax, %eax
	jne	.LBB12_30
# %bb.33:
	movl	$.Lstr.4, %edi
	callq	puts@PLT
.Ltmp57:
	leaq	16(%rsp), %rdi
	movl	$24000, %esi                    # imm = 0x5DC0
	callq	hipMalloc
.Ltmp58:
# %bb.34:
	testl	%eax, %eax
	jne	.LBB12_35
# %bb.38:
.Ltmp64:
	leaq	40(%rsp), %rdi
	movl	$120000, %esi                   # imm = 0x1D4C0
	callq	hipMalloc
.Ltmp65:
# %bb.39:
	testl	%eax, %eax
	jne	.LBB12_40
# %bb.42:
	movl	$.L.str.14, %edi
	movl	$.L.str.15, %esi
	callq	fopen
	movq	%rax, %r14
	movq	%rbx, %r15
	xorl	%r12d, %r12d
.LBB12_43:                              # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_44 Depth 2
	xorl	%r13d, %r13d
.LBB12_44:                              #   Parent Loop BB12_43 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leaq	(%r15,%r13), %rdx
.Ltmp71:
	movl	$.L.str.16, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
.Ltmp72:
# %bb.45:                               #   in Loop: Header=BB12_44 Depth=2
	addq	$8, %r13
	cmpq	$80, %r13
	jne	.LBB12_44
# %bb.46:                               #   in Loop: Header=BB12_43 Depth=1
	incq	%r12
	addq	$80, %r15
	cmpq	$10, %r12
	jne	.LBB12_43
# %bb.47:
	movq	(%rsp), %rdi
.Ltmp74:
	movl	$800, %edx                      # imm = 0x320
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp75:
# %bb.48:
	testl	%eax, %eax
	jne	.LBB12_49
# %bb.51:
	movq	(%rsp), %rdi
.Ltmp80:
	callq	_Z17showDevZoningPlanP10ZoningPlan
.Ltmp81:
# %bb.52:
.Ltmp82:
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movabsq	$4294967304, %rdx               # imm = 0x100000008
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp83:
# %bb.53:
	testl	%eax, %eax
	jne	.LBB12_55
# %bb.54:
	movq	(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	32(%rsp), %rcx
	movq	24(%rsp), %r8
	movq	40(%rsp), %r9
.Ltmp84:
	callq	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
.Ltmp85:
.LBB12_55:
.Ltmp86:
	callq	hipDeviceSynchronize
.Ltmp87:
# %bb.56:
	movq	8(%rsp), %rdi
.Ltmp88:
	xorl	%esi, %esi
	callq	_Z14showDevDistMapP11DistanceMapi
.Ltmp89:
# %bb.57:
	movq	16(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdx
.Ltmp90:
	xorl	%ecx, %ecx
	callq	_Z12showDevQueueP15HIP_vector_typeIjLj3EEPiS2_i
.Ltmp91:
# %bb.58:
	movq	(%rsp), %rdi
.Ltmp92:
	callq	hipFree
.Ltmp93:
# %bb.59:
	movq	8(%rsp), %rdi
.Ltmp94:
	callq	hipFree
.Ltmp95:
# %bb.60:
	movq	%rbx, %rdi
	callq	free
	movq	72(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB12_62
# %bb.61:
	callq	_ZdlPv
.LBB12_62:                              # %_ZNSt6vectorIfSaIfEED2Ev.exit57
	xorl	%eax, %eax
	addq	$96, %rsp
	.cfi_def_cfa_offset 48
	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
.LBB12_6:
	.cfi_def_cfa_offset 144
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$439, %edx                      # imm = 0x1B7
	xorl	%eax, %eax
	callq	printf
.Ltmp23:
	callq	hipGetLastError
.Ltmp24:
# %bb.7:
.Ltmp25:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp26:
	jmp	.LBB12_8
.LBB12_15:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$440, %edx                      # imm = 0x1B8
	xorl	%eax, %eax
	callq	printf
.Ltmp29:
	callq	hipGetLastError
.Ltmp30:
# %bb.16:
.Ltmp31:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp32:
	jmp	.LBB12_8
.LBB12_20:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$449, %edx                      # imm = 0x1C1
	xorl	%eax, %eax
	callq	printf
.Ltmp38:
	callq	hipGetLastError
.Ltmp39:
# %bb.21:
.Ltmp40:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp41:
	jmp	.LBB12_8
.LBB12_25:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$463, %edx                      # imm = 0x1CF
	xorl	%eax, %eax
	callq	printf
.Ltmp45:
	callq	hipGetLastError
.Ltmp46:
# %bb.26:
.Ltmp47:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp48:
	jmp	.LBB12_8
.LBB12_30:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$465, %edx                      # imm = 0x1D1
	xorl	%eax, %eax
	callq	printf
.Ltmp52:
	callq	hipGetLastError
.Ltmp53:
# %bb.31:
.Ltmp54:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp55:
	jmp	.LBB12_8
.LBB12_35:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$473, %edx                      # imm = 0x1D9
	xorl	%eax, %eax
	callq	printf
.Ltmp59:
	callq	hipGetLastError
.Ltmp60:
# %bb.36:
.Ltmp61:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp62:
	jmp	.LBB12_8
.LBB12_40:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$477, %edx                      # imm = 0x1DD
	xorl	%eax, %eax
	callq	printf
.Ltmp66:
	callq	hipGetLastError
.Ltmp67:
# %bb.41:
.Ltmp68:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp69:
	jmp	.LBB12_8
.LBB12_49:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	movl	$508, %edx                      # imm = 0x1FC
	xorl	%eax, %eax
	callq	printf
.Ltmp76:
	callq	hipGetLastError
.Ltmp77:
# %bb.50:
.Ltmp78:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp79:
.LBB12_8:
	movl	$.L.str.2, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.LBB12_10:
.Ltmp20:
	movq	%rax, %rbx
	movq	48(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB12_65
# %bb.11:
	callq	_ZdlPv
	jmp	.LBB12_65
.LBB12_9:
.Ltmp17:
	jmp	.LBB12_64
.LBB12_63:
.Ltmp70:
	jmp	.LBB12_64
.LBB12_37:
.Ltmp63:
	jmp	.LBB12_64
.LBB12_32:
.Ltmp56:
	jmp	.LBB12_64
.LBB12_27:
.Ltmp49:
	jmp	.LBB12_64
.LBB12_22:
.Ltmp42:
	jmp	.LBB12_64
.LBB12_12:
.Ltmp35:
	jmp	.LBB12_64
.LBB12_69:
.Ltmp96:
	jmp	.LBB12_64
.LBB12_68:
.Ltmp73:
.LBB12_64:                              # %_ZNSt6vectorIfSaIfEED2Ev.exit55
	movq	%rax, %rbx
.LBB12_65:                              # %_ZNSt6vectorIfSaIfEED2Ev.exit55
	movq	72(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB12_67
# %bb.66:
	callq	_ZdlPv
.LBB12_67:                              # %_ZNSt6vectorIfSaIfEED2Ev.exit59
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end12:
	.size	main, .Lfunc_end12-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table12:
.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 .Ltmp34-.Ltmp21                #   Call between .Ltmp21 and .Ltmp34
	.uleb128 .Ltmp35-.Lfunc_begin1          #     jumps to .Ltmp35
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp36-.Lfunc_begin1          # >> Call Site 5 <<
	.uleb128 .Ltmp37-.Ltmp36                #   Call between .Ltmp36 and .Ltmp37
	.uleb128 .Ltmp42-.Lfunc_begin1          #     jumps to .Ltmp42
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp43-.Lfunc_begin1          # >> Call Site 6 <<
	.uleb128 .Ltmp44-.Ltmp43                #   Call between .Ltmp43 and .Ltmp44
	.uleb128 .Ltmp49-.Lfunc_begin1          #     jumps to .Ltmp49
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp50-.Lfunc_begin1          # >> Call Site 7 <<
	.uleb128 .Ltmp51-.Ltmp50                #   Call between .Ltmp50 and .Ltmp51
	.uleb128 .Ltmp56-.Lfunc_begin1          #     jumps to .Ltmp56
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp57-.Lfunc_begin1          # >> Call Site 8 <<
	.uleb128 .Ltmp58-.Ltmp57                #   Call between .Ltmp57 and .Ltmp58
	.uleb128 .Ltmp63-.Lfunc_begin1          #     jumps to .Ltmp63
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp64-.Lfunc_begin1          # >> Call Site 9 <<
	.uleb128 .Ltmp65-.Ltmp64                #   Call between .Ltmp64 and .Ltmp65
	.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 .Ltmp73-.Lfunc_begin1          #     jumps to .Ltmp73
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp74-.Lfunc_begin1          # >> Call Site 11 <<
	.uleb128 .Ltmp95-.Ltmp74                #   Call between .Ltmp74 and .Ltmp95
	.uleb128 .Ltmp96-.Lfunc_begin1          #     jumps to .Ltmp96
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp23-.Lfunc_begin1          # >> Call Site 12 <<
	.uleb128 .Ltmp32-.Ltmp23                #   Call between .Ltmp23 and .Ltmp32
	.uleb128 .Ltmp35-.Lfunc_begin1          #     jumps to .Ltmp35
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp38-.Lfunc_begin1          # >> Call Site 13 <<
	.uleb128 .Ltmp41-.Ltmp38                #   Call between .Ltmp38 and .Ltmp41
	.uleb128 .Ltmp42-.Lfunc_begin1          #     jumps to .Ltmp42
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp45-.Lfunc_begin1          # >> Call Site 14 <<
	.uleb128 .Ltmp48-.Ltmp45                #   Call between .Ltmp45 and .Ltmp48
	.uleb128 .Ltmp49-.Lfunc_begin1          #     jumps to .Ltmp49
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp52-.Lfunc_begin1          # >> Call Site 15 <<
	.uleb128 .Ltmp55-.Ltmp52                #   Call between .Ltmp52 and .Ltmp55
	.uleb128 .Ltmp56-.Lfunc_begin1          #     jumps to .Ltmp56
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp59-.Lfunc_begin1          # >> Call Site 16 <<
	.uleb128 .Ltmp62-.Ltmp59                #   Call between .Ltmp59 and .Ltmp62
	.uleb128 .Ltmp63-.Lfunc_begin1          #     jumps to .Ltmp63
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp66-.Lfunc_begin1          # >> Call Site 17 <<
	.uleb128 .Ltmp69-.Ltmp66                #   Call between .Ltmp66 and .Ltmp69
	.uleb128 .Ltmp70-.Lfunc_begin1          #     jumps to .Ltmp70
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp76-.Lfunc_begin1          # >> Call Site 18 <<
	.uleb128 .Ltmp79-.Ltmp76                #   Call between .Ltmp76 and .Ltmp79
	.uleb128 .Ltmp96-.Lfunc_begin1          #     jumps to .Ltmp96
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp79-.Lfunc_begin1          # >> Call Site 19 <<
	.uleb128 .Lfunc_end12-.Ltmp79           #   Call between .Ltmp79 and .Lfunc_end12
	.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	.LBB13_1
# %bb.2:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIfE8allocateEmPKv
	movq	%rax, %r15
	jmp	.LBB13_3
.LBB13_1:
	xorl	%r15d, %r15d
.LBB13_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	.LBB13_5
# %bb.4:
	movq	%r15, %rdi
	movq	%r14, %rdx
	callq	memmove@PLT
.LBB13_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
.LBB13_5:
	.cfi_def_cfa_offset 48
	cmpq	$4, %r14
	jne	.LBB13_7
# %bb.6:
	movss	(%rsi), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r15)
	jmp	.LBB13_7
.Lfunc_end13:
	.size	_ZNSt6vectorIfSaIfEEC2ERKS1_, .Lfunc_end13-_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	.LBB14_1
# %bb.3:
	shlq	$2, %rsi
	movq	%rsi, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Znwm                           # TAILCALL
.LBB14_1:
	.cfi_def_cfa_offset 16
	shrq	$62, %rsi
	je	.LBB14_2
# %bb.4:
	callq	_ZSt28__throw_bad_array_new_lengthv
.LBB14_2:
	callq	_ZSt17__throw_bad_allocv
.Lfunc_end14:
	.size	_ZNSt15__new_allocatorIfE8allocateEmPKv, .Lfunc_end14-_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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB15_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB15_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end15:
	.size	__hip_module_ctor, .Lfunc_end15-__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	.LBB16_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
.LBB16_2:
	retq
.Lfunc_end16:
	.size	__hip_module_dtor, .Lfunc_end16-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_,@object # @_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.section	.rodata,"a",@progbits
	.globl	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.p2align	3, 0x0
_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_:
	.quad	_Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.size	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_, 8

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

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

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

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Begin: %d, End: %d, featureId: %d\n"
	.size	.L.str.8, 35

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

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"%2d: (%3d, %3d) -> (%3d, %3d) (%d)\n"
	.size	.L.str.11, 36

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"generateZoningPlan: %lf\n"
	.size	.L.str.12, 25

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"zone.txt"
	.size	.L.str.14, 9

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"r"
	.size	.L.str.15, 2

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_"
	.size	.L__unnamed_1, 87

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Zone plan:"
	.size	.Lstr, 11

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Distance map:"
	.size	.Lstr.1, 14

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Queue:"
	.size	.Lstr.2, 7

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"History:"
	.size	.Lstr.3, 9

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"start..."
	.size	.Lstr.4, 9

	.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 _Z37__device_stub__computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_ ; -- Begin function _Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.globl	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
	.p2align	8
	.type	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_,@function
_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_: ; @_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
; %bb.0:
	v_dual_mov_b32 v5, 0 :: v_dual_mov_b32 v4, 0x3e8
	v_mul_u32_u24_e32 v2, 12, v0
	v_mov_b32_e32 v3, 1
	s_mov_b32 s2, 0
	s_delay_alu instid0(VALU_DEP_3)
	v_dual_mov_b32 v6, v5 :: v_dual_add_nc_u32 v1, -8, v0
	ds_store_b64 v5, v[5:6] offset:24400
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v1, 8, v1
	ds_store_2addr_b32 v2, v4, v4 offset1:1
	ds_store_b32 v2, v3 offset:8
	v_add_nc_u32_e32 v2, 0x60, v2
	v_cmp_lt_u32_e32 vcc_lo, 0x7c7, v1
	s_or_b32 s2, vcc_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB0_1
; %bb.2:
	s_or_b32 exec_lo, exec_lo, s2
	s_clause 0x1
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x20
	v_dual_mov_b32 v3, 0 :: v_dual_mov_b32 v4, 0x63
	v_mov_b32_e32 v5, 0x7cf
	s_mul_i32 s15, s15, 10
	s_mul_i32 s14, s14, 10
	s_mov_b32 s2, 0
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v1, s2, v0
	s_mov_b32 s3, exec_lo
	v_cmpx_gt_u32_e32 0x64, v1
	s_cbranch_execz .LBB0_10
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	v_mul_hi_u32 v2, 0xcccccccd, v1
	s_mov_b32 s12, exec_lo
	v_mov_b32_e32 v9, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v6, 3, v2
	v_mul_lo_u32 v2, v6, 10
	v_add_nc_u32_e32 v8, s15, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v7, v1, v2
	v_add_nc_u32_e32 v1, s14, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_max_u32_e32 v2, v8, v1
	v_cmpx_gt_u32_e32 10, v2
	s_cbranch_execz .LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	v_mov_b32_e32 v2, v3
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[9:10], null, 0x50, v8, s[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[11:12], 3, v[1:2]
	v_add_co_u32 v9, vcc_lo, v9, v11
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v10, vcc_lo, v10, v12, vcc_lo
	global_load_b32 v9, v[9:10], off
.LBB0_6:                                ; %.critedge
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	v_ashrrev_i32_e32 v2, 31, v1
	s_waitcnt lgkmcnt(0)
	v_mad_i64_i32 v[10:11], null, v8, 40, s[6:7]
	v_mul_lo_u32 v8, v6, 40
	v_lshlrev_b32_e32 v12, 2, v7
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_mov_b32 s12, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v10, vcc_lo, v10, v1
	v_add_co_ci_u32_e32 v11, vcc_lo, v11, v2, vcc_lo
	v_add3_u32 v1, v8, v12, 0x5dc0
	global_store_b32 v[10:11], v4, off
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e32 1, v9
	s_xor_b32 s12, exec_lo, s12
	s_cbranch_execz .LBB0_8
; %bb.7:                                ;   in Loop: Header=BB0_3 Depth=1
	ds_store_b32 v1, v4
                                        ; implicit-def: $vgpr1
                                        ; implicit-def: $vgpr7
                                        ; implicit-def: $vgpr6
.LBB0_8:                                ; %Flow330
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_and_not1_saveexec_b32 s12, s12
	s_cbranch_execz .LBB0_10
; %bb.9:                                ;   in Loop: Header=BB0_3 Depth=1
	ds_store_b32 v1, v3
	ds_inc_rtn_u32 v1, v3, v5 offset:24404
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v1, v1, 12
	ds_store_2addr_b32 v1, v7, v6 offset1:1
	ds_store_b32 v1, v3 offset:8
.LBB0_10:                               ; %Flow332
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s3
	s_add_i32 s2, s2, 8
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmpk_eq_i32 s2, 0x68
	s_cbranch_scc0 .LBB0_3
; %bb.11:
	v_dual_mov_b32 v3, 0x7cf :: v_dual_mov_b32 v4, 0
	v_dual_mov_b32 v5, 1 :: v_dual_mov_b32 v6, 0x3e8
	s_movk_i32 s3, 0x1b58
	s_mov_b32 s2, 0
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
                                        ; implicit-def: $sgpr4
.LBB0_12:                               ; =>This Inner Loop Header: Depth=1
	ds_inc_rtn_u32 v1, v4, v3 offset:24400
	s_or_b32 s4, s4, exec_lo
	s_mov_b32 s5, exec_lo
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v7, v1, 12
	ds_load_2addr_b32 v[1:2], v7 offset1:1
	s_waitcnt lgkmcnt(0)
	v_max_u32_e32 v8, v1, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_u32_e32 10, v8
	s_cbranch_execz .LBB0_28
; %bb.13:                               ;   in Loop: Header=BB0_12 Depth=1
	ds_load_b32 v8, v7 offset:8
	v_mul_lo_u32 v9, v2, 40
	v_lshlrev_b32_e32 v10, 2, v1
	s_mov_b32 s13, -1
	s_mov_b32 s12, exec_lo
	s_waitcnt lgkmcnt(0)
	v_lshlrev_b32_e32 v11, 2, v8
	s_delay_alu instid0(VALU_DEP_1)
	v_add3_u32 v9, v9, v10, v11
	ds_load_b32 v10, v9 offset:24000
	v_add_nc_u32_e32 v9, 0x5dc0, v9
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v10, 1, v10
	v_cmpx_ne_u32_e32 0, v2
	s_cbranch_execz .LBB0_17
; %bb.14:                               ;   in Loop: Header=BB0_12 Depth=1
	v_subrev_nc_u32_e32 v11, 40, v9
	s_mov_b32 s13, exec_lo
	ds_min_rtn_i32 v11, v11, v10
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_u32_e64 v11, v10
	s_cbranch_execz .LBB0_16
; %bb.15:                               ;   in Loop: Header=BB0_12 Depth=1
	ds_inc_rtn_u32 v11, v4, v3 offset:24404
	v_add_nc_u32_e32 v12, -1, v2
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v11, v11, 12
	ds_store_2addr_b32 v11, v1, v12 offset1:1
	ds_store_b32 v11, v8 offset:8
.LBB0_16:                               ;   in Loop: Header=BB0_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s13
	v_cmp_ne_u32_e32 vcc_lo, 9, v2
	s_or_not1_b32 s13, vcc_lo, exec_lo
.LBB0_17:                               ; %Flow328
                                        ;   in Loop: Header=BB0_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	s_and_saveexec_b32 s12, s13
	s_cbranch_execz .LBB0_20
; %bb.18:                               ;   in Loop: Header=BB0_12 Depth=1
	ds_min_rtn_i32 v11, v9, v10 offset:40
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_u32_e32 vcc_lo, v11, v10
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_20
; %bb.19:                               ;   in Loop: Header=BB0_12 Depth=1
	ds_inc_rtn_u32 v11, v4, v3 offset:24404
	v_add_nc_u32_e32 v12, 1, v2
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v11, v11, 12
	ds_store_2addr_b32 v11, v1, v12 offset1:1
	ds_store_b32 v11, v8 offset:8
.LBB0_20:                               ;   in Loop: Header=BB0_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	s_mov_b32 s13, -1
	s_mov_b32 s12, exec_lo
	v_cmpx_ne_u32_e32 0, v1
	s_cbranch_execz .LBB0_24
; %bb.21:                               ;   in Loop: Header=BB0_12 Depth=1
	v_add_nc_u32_e32 v11, -4, v9
	s_mov_b32 s13, exec_lo
	ds_min_rtn_i32 v11, v11, v10
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_u32_e64 v11, v10
	s_cbranch_execz .LBB0_23
; %bb.22:                               ;   in Loop: Header=BB0_12 Depth=1
	ds_inc_rtn_u32 v11, v4, v3 offset:24404
	v_add_nc_u32_e32 v12, -1, v1
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v11, v11, 12
	ds_store_2addr_b32 v11, v12, v2 offset1:1
	ds_store_b32 v11, v8 offset:8
.LBB0_23:                               ;   in Loop: Header=BB0_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s13
	v_cmp_ne_u32_e32 vcc_lo, 9, v1
	s_or_not1_b32 s13, vcc_lo, exec_lo
.LBB0_24:                               ; %Flow326
                                        ;   in Loop: Header=BB0_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	s_and_saveexec_b32 s12, s13
	s_cbranch_execz .LBB0_27
; %bb.25:                               ;   in Loop: Header=BB0_12 Depth=1
	ds_min_rtn_i32 v9, v9, v10 offset:4
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_u32_e32 vcc_lo, v9, v10
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_27
; %bb.26:                               ;   in Loop: Header=BB0_12 Depth=1
	ds_inc_rtn_u32 v9, v4, v3 offset:24404
	v_add_nc_u32_e32 v1, 1, v1
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v9, v9, 12
	ds_store_2addr_b32 v9, v1, v2 offset1:1
	ds_store_b32 v9, v8 offset:8
.LBB0_27:                               ; %.critedge253
                                        ;   in Loop: Header=BB0_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s12
	s_add_i32 s3, s3, -1
	ds_store_2addr_b32 v7, v6, v6 offset1:1
	ds_store_b32 v7, v5 offset:8
	s_cmp_eq_u32 s3, 0
	s_cselect_b32 s12, -1, 0
	s_and_not1_b32 s4, s4, exec_lo
	s_and_b32 s12, s12, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s4, s4, s12
.LBB0_28:                               ; %Flow329
                                        ;   in Loop: Header=BB0_12 Depth=1
	s_or_b32 exec_lo, exec_lo, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s5, exec_lo, s4
	s_or_b32 s2, s5, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB0_12
; %bb.29:
	s_or_b32 exec_lo, exec_lo, s2
	v_mov_b32_e32 v2, 0
	s_mov_b32 s2, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB0_30:                               ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v1, s2, v0
	s_mov_b32 s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_u32_e32 0x64, v1
	s_cbranch_execz .LBB0_34
; %bb.31:                               ;   in Loop: Header=BB0_30 Depth=1
	v_mul_hi_u32 v3, 0xcccccccd, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v4, 3, v3
	v_add_nc_u32_e32 v3, s15, v4
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_u32_e32 vcc_lo, 10, v3
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_34
; %bb.32:                               ;   in Loop: Header=BB0_30 Depth=1
	v_mul_lo_u32 v5, v4, 10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v5, v1, v5
	v_add_nc_u32_e32 v1, s14, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_u32_e32 vcc_lo, 10, v1
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_34
; %bb.33:                               ; %.critedge257
                                        ;   in Loop: Header=BB0_30 Depth=1
	v_mul_lo_u32 v4, v4, 40
	v_lshlrev_b64 v[6:7], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_lshl_add_u32 v4, v5, 2, v4
	ds_load_b32 v8, v4 offset:24000
	v_mad_u64_u32 v[4:5], null, v3, 40, s[6:7]
	v_add_co_u32 v3, vcc_lo, v4, v6
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, v5, v7, vcc_lo
	s_waitcnt lgkmcnt(0)
	global_atomic_min_i32 v[3:4], v8, off
.LBB0_34:                               ;   in Loop: Header=BB0_30 Depth=1
	s_or_b32 exec_lo, exec_lo, s3
	s_add_i32 s2, s2, 8
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmpk_eq_i32 s2, 0x68
	s_cbranch_scc0 .LBB0_30
; %bb.35:                               ; %.preheader
	v_mov_b32_e32 v0, 0
	s_mov_b32 s2, 0
	ds_load_b32 v1, v0 offset:24404
	s_waitcnt lgkmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, 0, v1
	s_cbranch_vccnz .LBB0_38
; %bb.36:                               ; %.lr.ph.preheader
	v_mov_b32_e32 v2, v1
.LBB0_37:                               ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_mov_b32 v3, s2 :: v_dual_add_nc_u32 v2, -1, v2
	ds_load_b32 v5, v3 offset:8
	ds_load_2addr_b32 v[3:4], v3 offset1:1
	v_cmp_eq_u32_e32 vcc_lo, 0, v2
	s_waitcnt lgkmcnt(0)
	global_store_b96 v0, v[3:5], s[8:9]
	s_add_u32 s8, s8, 12
	s_addc_u32 s9, s9, 0
	s_add_i32 s2, s2, 12
	s_cbranch_vccz .LBB0_37
.LBB0_38:                               ; %._crit_edge
	ds_load_b32 v2, v0 offset:24400
	s_waitcnt lgkmcnt(0)
	s_clause 0x1
	global_store_b32 v0, v2, s[10:11]
	global_store_b32 v0, v1, s[0:1]
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
		.amdhsa_group_segment_fixed_size 24408
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 48
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 13
		.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	_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_, .Lfunc_end0-_Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1452
; NumSgprs: 18
; NumVgprs: 13
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 24408 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 13
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 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
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 24408
    .kernarg_segment_align: 8
    .kernarg_segment_size: 48
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z22computeDistanceToStoreP10ZoningPlanP11DistanceMapP15HIP_vector_typeIjLj3EEPiS6_S5_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     13
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
