/* The MIT License (MIT)
 *
 * Copyright (c) 2013 Johannes Reinhardt <jreinhardt@ist-dein-freund.de>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

/* Monte Carlo Sudoku solver in CUDA */


#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <time.h>
#include <cuda_runtime.h>

//this must be smaller than 16 (but is realisticly 3 or 4 or maybe 5)
#define BLK_SIZE 3
#define SUD_SIZE (BLK_SIZE*BLK_SIZE)
#define N_ENTRIES (SUD_SIZE*SUD_SIZE)
#define THREADS_PER_BLOCK 256
#define N_BLOCKS 256
#define N_THREADS (THREADS_PER_BLOCK*N_BLOCKS)
#define N_STEPS 100

#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true)
{
   if (code != cudaSuccess) 
   {
      fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}

//TODO: Why does this not work
//__constant__ int lut_exp[256];

//a form to describe a sudoku that is suitable for fast access, consists of two
//parts: One part describes the constant structure, i.e. the positions of the
//unknowns and the hints, and is the same for all instances.  The other parts
//contains the values of the unknowns, the current energy, and space for
//bookkeeping.

typedef struct {
	//Constant part, applies to all sudokus:

	//There are three tables that map an idx for each unknown to the entities it
	//belongs, i.e. its row, column and block.
	char* unk_row;
	char* unk_col;
	char* unk_blk;

	//There are three tables that contain the counts for the hints for each
	//symbol for each entity, souch that hnt_*[idx*SUD_SIZE + sym] gives the
	//number of occurences of hints of value sym in entity idx.
	char* hnt_row;
	char* hnt_col;
	char* hnt_blk;

	//Number of unknowns (a single number, for memory purposes pointerized)
	unsigned int n_unk;

	//Variable part: contains information about the individual instances
	//The energy of the current configuration
	unsigned int* energy;

	//prng state
	unsigned int* random;
	//This table maps an idx of a unknown to its value.
	char** unk_val;

	//This is space for accumulating counts.  cnt_*[sym*SUD_SIZE + idx] gives
	//the number of occurences of symbol sym in entity idx
	char** cnt_row;
	char** cnt_col;
	char** cnt_blk;

} sudoku_t;

__device__ __host__ void mc_step(sudoku_t sud, int* lut_exp, unsigned int thread_idx){
	char val,old_val;
	unsigned int energy,rnd;
	int i,delta,idx;

	//generate a new random number
	rnd = sud.random[thread_idx];
	rnd = 1664525*rnd + 1013904223;
	sud.random[thread_idx] = rnd;

	//dissect the random number
	idx = (rnd >> 0) % sud.n_unk;
	val = (rnd >> 8) % SUD_SIZE;
	rnd = (rnd >> 16);

	//save old value, put new value in //TODO: Suboptimal access pattern
	old_val = sud.unk_val[idx][thread_idx];
	sud.unk_val[idx][thread_idx] = val;

	//put the hints into the counters
	for(i=0;i<N_ENTRIES;i++){
		sud.cnt_row[i][thread_idx] = sud.hnt_row[i];
		sud.cnt_col[i][thread_idx] = sud.hnt_col[i];
		sud.cnt_blk[i][thread_idx] = sud.hnt_blk[i];
	}

	//count the unknowns TODO: Suboptimal access pattern.
	for(i=0;i<sud.n_unk;i++){
		sud.cnt_row[sud.unk_row[i]*SUD_SIZE + sud.unk_val[i][thread_idx]][thread_idx]++;
		sud.cnt_col[sud.unk_col[i]*SUD_SIZE + sud.unk_val[i][thread_idx]][thread_idx]++;
		sud.cnt_blk[sud.unk_blk[i]*SUD_SIZE + sud.unk_val[i][thread_idx]][thread_idx]++;
	}

	//calculate the energy
	energy = 0;
	for(i=0;i<N_ENTRIES;i++){
		energy += (sud.cnt_row[i][thread_idx] == 0) ? 1 : sud.cnt_row[i][thread_idx] - 1;
		energy += (sud.cnt_col[i][thread_idx] == 0) ? 1 : sud.cnt_col[i][thread_idx] - 1;
		energy += (sud.cnt_blk[i][thread_idx] == 0) ? 1 : sud.cnt_blk[i][thread_idx] - 1;
	}

	delta = energy - sud.energy[thread_idx];
	delta = delta > 255 ? 255 : delta;

	if(((delta > 0) && (lut_exp[delta > 255 ? 255 : delta] < rnd)) || (energy == 0)){
		//discard step TODO: suboptimal access pattern
		sud.unk_val[idx][thread_idx] = old_val;
	} else {
		sud.energy[thread_idx] = energy;
	}
}


//Memory is laid out such that data for different threads is as close together
//as possible to allow coalesced accesses
void sudoku_alloc_host(sudoku_t* sud, int* lut_exp, unsigned int n_unk){
	int i,j;

	sud->unk_row = (char*) malloc(n_unk*sizeof(char));
	sud->unk_col = (char*) malloc(n_unk*sizeof(char));
	sud->unk_blk = (char*) malloc(n_unk*sizeof(char));

	sud->hnt_row = (char*) malloc(N_ENTRIES*sizeof(char));
	sud->hnt_col = (char*) malloc(N_ENTRIES*sizeof(char));
	sud->hnt_blk = (char*) malloc(N_ENTRIES*sizeof(char));

	sud->n_unk = n_unk;

	sud->energy = (unsigned int*) malloc(N_THREADS*sizeof(unsigned int));
	sud->random = (unsigned int*) malloc(N_THREADS*sizeof(unsigned int));

	sud->unk_val = (char**) malloc(n_unk*sizeof(char*));
	for(i=0;i<n_unk;i++){
		sud->unk_val[i] = (char*) malloc(N_THREADS*sizeof(char));
	}

	sud->cnt_row = (char**) malloc(N_ENTRIES*sizeof(char*));
	sud->cnt_col = (char**) malloc(N_ENTRIES*sizeof(char*));
	sud->cnt_blk = (char**) malloc(N_ENTRIES*sizeof(char*));

	for(i=0;i<N_ENTRIES;i++){
		sud->cnt_row[i] = (char*) malloc(N_THREADS*sizeof(char));
		sud->cnt_col[i] = (char*) malloc(N_THREADS*sizeof(char));
		sud->cnt_blk[i] = (char*) malloc(N_THREADS*sizeof(char));
	}

	//Setup a simple prng (coefficients from Numerical recipies)
	for(i=0;i<N_THREADS;i++){
		sud->random[i] = 1664525*i + 1013904223;
		//run it a few times
		for(j=0;j<5;j++){
			sud->random[i] = 1664525*sud->random[i] + 1013904223;
		}
	}

	//Fill the unknowns
	for(i=0;i<sud->n_unk;i++){
		for(j=0;j<N_THREADS;j++){
			sud->unk_val[i][j] = sud->random[j] % SUD_SIZE;
			sud->random[j] = 1664525*sud->random[j] + 1013904223;
		}
	}
	//Set energy to a really high arbitrary value, this will cause the first step to be accepted
	for(i=0;i<N_THREADS;i++){
		sud->energy[i] = 1<<20;
	}
}

void sudoku_free_host(sudoku_t* sud){
	int i;
	free(sud->unk_row);
	free(sud->unk_col);
	free(sud->unk_blk);

	free(sud->hnt_row);
	free(sud->hnt_col);
	free(sud->hnt_blk);

	free(sud->energy);
	free(sud->random);

	for(i=0; i<sud->n_unk;i++){
		free(sud->unk_val[i]);
	}
	free(sud->unk_val);

	for(i=0;i<N_ENTRIES;i++){
		free(sud->cnt_row[i]);
		free(sud->cnt_col[i]);
		free(sud->cnt_blk[i]);
	}

	free(sud->cnt_row);
	free(sud->cnt_col);
	free(sud->cnt_blk);
}

void sudoku_free_device(sudoku_t* sud){
	int i;
	char **tmp_val, **tmp_row, **tmp_col, **tmp_blk;
	cudaFree(sud->unk_row);
	cudaFree(sud->unk_col);
	cudaFree(sud->unk_blk);

	cudaFree(sud->hnt_row);
	cudaFree(sud->hnt_col);
	cudaFree(sud->hnt_blk);

	cudaFree(sud->energy);
	cudaFree(sud->random);

	tmp_val = (char**) malloc(sud->n_unk*sizeof(char*));
	cudaMemcpy(tmp_val,sud->unk_val,sud->n_unk*sizeof(char*),cudaMemcpyDeviceToHost);
	for(i=0; i<sud->n_unk;i++){
		cudaFree(tmp_val[i]);
	}
	free(tmp_val);
	cudaFree(sud->unk_val);

	tmp_col = (char**) malloc(N_ENTRIES*sizeof(char*));
	tmp_row = (char**) malloc(N_ENTRIES*sizeof(char*));
	tmp_blk = (char**) malloc(N_ENTRIES*sizeof(char*));
	cudaMemcpy(tmp_row,sud->cnt_row,N_ENTRIES*sizeof(char*),cudaMemcpyDeviceToHost);
	cudaMemcpy(tmp_col,sud->cnt_col,N_ENTRIES*sizeof(char*),cudaMemcpyDeviceToHost);
	cudaMemcpy(tmp_blk,sud->cnt_blk,N_ENTRIES*sizeof(char*),cudaMemcpyDeviceToHost);
	for(i=0;i<N_ENTRIES;i++){
		cudaFree(tmp_row[i]);
		cudaFree(tmp_col[i]);
		cudaFree(tmp_blk[i]);
	}
	free(tmp_col);
	free(tmp_row);
	free(tmp_blk);
	cudaFree(sud->cnt_row);
	cudaFree(sud->cnt_col);
	cudaFree(sud->cnt_blk);
}


void sudoku_alloc_and_copy_device(sudoku_t* d_sud, sudoku_t* h_sud){
	int i;
	char **tmp_val, **tmp_row, **tmp_col, **tmp_blk;

	int n_unk = h_sud->n_unk;
	//alloc
	gpuErrchk(cudaMalloc(&d_sud->unk_row,n_unk*sizeof(char)));
	gpuErrchk(cudaMalloc(&d_sud->unk_col,n_unk*sizeof(char)));
	gpuErrchk(cudaMalloc(&d_sud->unk_blk,n_unk*sizeof(char)));

	gpuErrchk(cudaMalloc(&d_sud->hnt_row,N_ENTRIES*sizeof(char)));
	gpuErrchk(cudaMalloc(&d_sud->hnt_col,N_ENTRIES*sizeof(char)));
	gpuErrchk(cudaMalloc(&d_sud->hnt_blk,N_ENTRIES*sizeof(char)));

	gpuErrchk(cudaMalloc(&d_sud->energy, N_THREADS*sizeof(unsigned int)));
	gpuErrchk(cudaMalloc(&d_sud->random, N_THREADS*sizeof(unsigned int)));

	//Nested array setup is a bit annoying. The result of cudaMalloc can not
	//directly written to device memory, so we have to cache it in tmp and then
	//copy it to the device

	gpuErrchk(cudaMalloc(&d_sud->unk_val, n_unk*sizeof(char*)));
	tmp_val = (char**) malloc(n_unk*sizeof(char*));
	for(i=0;i<n_unk;i++){
		gpuErrchk(cudaMalloc(&tmp_val[i],N_THREADS*sizeof(char)));
	}
	gpuErrchk(cudaMemcpy(d_sud->unk_val,tmp_val,n_unk*sizeof(char*),cudaMemcpyHostToDevice));

	gpuErrchk(cudaMalloc(&d_sud->cnt_row,N_ENTRIES*sizeof(char*)));
	gpuErrchk(cudaMalloc(&d_sud->cnt_col,N_ENTRIES*sizeof(char*)));
	gpuErrchk(cudaMalloc(&d_sud->cnt_blk,N_ENTRIES*sizeof(char*)));

	tmp_row = (char**) malloc(N_ENTRIES*sizeof(char*));
	tmp_col = (char**) malloc(N_ENTRIES*sizeof(char*));
	tmp_blk = (char**) malloc(N_ENTRIES*sizeof(char*));

	for(i=0;i<N_ENTRIES;i++){
		gpuErrchk(cudaMalloc(&tmp_row[i],N_THREADS*sizeof(char)));
		gpuErrchk(cudaMalloc(&tmp_col[i],N_THREADS*sizeof(char)));
		gpuErrchk(cudaMalloc(&tmp_blk[i],N_THREADS*sizeof(char)));
	}
	gpuErrchk(cudaMemcpy(d_sud->cnt_row,tmp_row, N_ENTRIES*sizeof(char*),cudaMemcpyHostToDevice));
	gpuErrchk(cudaMemcpy(d_sud->cnt_col,tmp_col, N_ENTRIES*sizeof(char*),cudaMemcpyHostToDevice));
	gpuErrchk(cudaMemcpy(d_sud->cnt_blk,tmp_blk, N_ENTRIES*sizeof(char*),cudaMemcpyHostToDevice));

  //copy
  //constant
	d_sud->n_unk = h_sud->n_unk;
	gpuErrchk(cudaMemcpy(d_sud->unk_row,h_sud->unk_row,sizeof(char)*n_unk,cudaMemcpyHostToDevice));
	gpuErrchk(cudaMemcpy(d_sud->unk_col,h_sud->unk_col,sizeof(char)*n_unk,cudaMemcpyHostToDevice));
	gpuErrchk(cudaMemcpy(d_sud->unk_blk,h_sud->unk_blk,sizeof(char)*n_unk,cudaMemcpyHostToDevice));

	gpuErrchk(cudaMemcpy(d_sud->hnt_row,h_sud->hnt_row,sizeof(char)*N_ENTRIES,cudaMemcpyHostToDevice));
	gpuErrchk(cudaMemcpy(d_sud->hnt_col,h_sud->hnt_col,sizeof(char)*N_ENTRIES,cudaMemcpyHostToDevice));
	gpuErrchk(cudaMemcpy(d_sud->hnt_blk,h_sud->hnt_blk,sizeof(char)*N_ENTRIES,cudaMemcpyHostToDevice));

	//variable
	gpuErrchk(cudaMemcpy(d_sud->energy,h_sud->energy,sizeof(unsigned int)*N_THREADS,cudaMemcpyHostToDevice));
	gpuErrchk(cudaMemcpy(d_sud->random,h_sud->random,sizeof(unsigned int)*N_THREADS,cudaMemcpyHostToDevice));

	for(i=0;i<h_sud->n_unk;i++){
		gpuErrchk(cudaMemcpy(tmp_val[i],h_sud->unk_val[i],sizeof(char)*N_THREADS,cudaMemcpyHostToDevice));
	}

	for(i=0;i<N_ENTRIES;i++){
		gpuErrchk(cudaMemcpy(tmp_row[i],h_sud->cnt_row[i],sizeof(char)*N_THREADS,cudaMemcpyHostToDevice));
		gpuErrchk(cudaMemcpy(tmp_col[i],h_sud->cnt_col[i],sizeof(char)*N_THREADS,cudaMemcpyHostToDevice));
		gpuErrchk(cudaMemcpy(tmp_blk[i],h_sud->cnt_blk[i],sizeof(char)*N_THREADS,cudaMemcpyHostToDevice));
	}

	free(tmp_val);
	free(tmp_row);
	free(tmp_col);
	free(tmp_blk);
}

__global__ void step_gpu(sudoku_t sud, int* lut_exp){
	unsigned int thread_idx = blockIdx.x*blockDim.x + threadIdx.x;
	mc_step(sud, lut_exp, thread_idx);
}

void step_cpu(sudoku_t sud, int* lut_exp){
	unsigned int thread_idx;
	for(thread_idx=0; thread_idx < N_THREADS; thread_idx++){
		mc_step(sud, lut_exp, thread_idx);
	}
}


void add_unk(sudoku_t* sud, int i, int j){
	int blk = (i / BLK_SIZE)*BLK_SIZE + (j / BLK_SIZE);
	sud->unk_row[sud->n_unk] = i;
	sud->unk_col[sud->n_unk] = j;
	sud->unk_blk[sud->n_unk] = blk;
	sud->n_unk++;
}

void add_hin(sudoku_t* sud, int i, int j, int val){
	int blk = (i / BLK_SIZE)*BLK_SIZE + (j / BLK_SIZE);
	sud->hnt_row[val*SUD_SIZE + i]++;
	sud->hnt_col[val*SUD_SIZE + j]++;
	sud->hnt_blk[val*SUD_SIZE + blk]++;
}

void hint1(sudoku_t* sud){
	sud->n_unk = 0;
	int i,j;
	for(i=0;i<SUD_SIZE*SUD_SIZE;i++){
		sud->hnt_row[i] = 0;
		sud->hnt_col[i] = 0;
		sud->hnt_blk[i] = 0;
	}
	int vals[81] = {
		0, 9, 0, 7, 0, 3, 0, 6, 0, 0, 5, 0, 4, 0, 8, 0, 1, 0, 1, 0, 8, 0, 5, 0, 9, 0,
		4, 7, 0, 0, 1, 8, 2, 0, 0, 3, 0, 4, 2, 0, 6, 0, 5, 8, 0, 3, 0, 0, 9, 4, 5, 0,
		0, 2, 8, 0, 6, 0, 7, 0, 1, 0, 9, 0, 2, 0, 8, 0, 1, 0, 5, 0, 0, 1, 0, 6, 0, 9,
		0, 4, 0};
	for(i=0;i<SUD_SIZE;i++){
		for(j=0;j<SUD_SIZE;j++){
			if(vals[SUD_SIZE*i+j] == 0){
				add_unk(sud,i,j);
			} else {
				add_hin(sud,i,j,vals[SUD_SIZE*i+j]-1);
			}
		}
	}
}

void empty(sudoku_t* sud){
	sud->n_unk = 0;
	int i,j;
	for(i=0;i<SUD_SIZE*SUD_SIZE;i++){
		sud->hnt_row[i] = 0;
		sud->hnt_col[i] = 0;
		sud->hnt_blk[i] = 0;
	}
	for(i=0;i<SUD_SIZE;i++){
		for(j=0;j<SUD_SIZE;j++){
			add_unk(sud,i,j);
		}
	}
}

void hint16(sudoku_t* sud){
	sud->n_unk = 0;
	int i,j;
	for(i=0;i<SUD_SIZE*SUD_SIZE;i++){
		sud->hnt_row[i] = 0;
		sud->hnt_col[i] = 0;
		sud->hnt_blk[i] = 0;
	}
	int vals[256] = {
		0, 2, 0, 1, 0, 9, 0, 0, 0, 0, 11, 0, 0, 15, 14, 0, 0, 13, 11, 0, 0, 0, 0, 0, 9, 0, 7, 0, 16, 8, 0, 12, 
		4, 0, 10, 7, 15, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 9, 0, 0, 0, 0, 10, 0, 0, 12, 13, 0, 0, 0, 0, 4, 0, 0, 
		3, 0, 0, 0, 0, 0, 0, 0, 0, 16, 9, 11, 0, 0, 0, 0, 15, 5, 0, 16, 0, 0, 0, 4, 1, 0, 3, 0, 0, 10, 0, 0, 
		1, 0, 9, 12, 13, 15, 0, 0, 0, 6, 10, 0, 4, 0, 0, 0, 0, 11, 0, 0, 2, 6, 0, 0, 0, 0, 0, 0, 13, 0, 9, 8, 
		7, 10, 0, 6, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 8, 0, 0, 0, 0, 11, 0, 13, 7, 0, 0, 0, 6, 10, 1, 12, 0, 4, 
		0, 0, 12, 0, 0, 5, 0, 16, 7, 0, 0, 0, 11, 0, 10, 13, 0, 0, 0, 0, 6, 8, 14, 0, 0, 0, 0, 0, 0, 0, 0, 2, 
		0, 0, 3, 0, 0, 0, 0, 13, 16, 0, 0, 12, 0, 0, 0, 0, 13, 0, 0, 4, 0, 0, 0, 0, 11, 0, 0, 14, 2, 1, 0, 3, 
		9, 0, 2, 5, 0, 3, 0, 15, 0, 0, 0, 0, 0, 14, 7, 0, 0, 7, 1, 0, 0, 14, 0, 0, 0, 0, 5, 0, 8, 0, 16, 0};
	for(i=0;i<SUD_SIZE;i++){
		for(j=0;j<SUD_SIZE;j++){
			if(vals[SUD_SIZE*i+j] == 0){
				add_unk(sud,i,j);
			} else {
				add_hin(sud,i,j,vals[SUD_SIZE*i+j]-1);
			}
		}
	}
}

void energy_stats(int round, unsigned int *energies, unsigned int n_threads){
	int max_energy=0, min_energy=100000, total_energy=0;
	int i;
	for(i=0;i<n_threads;i++){
		max_energy = (energies[i] > max_energy) ? energies[i] : max_energy;
		min_energy = (energies[i] < min_energy) ? energies[i] : min_energy;
		total_energy += energies[i];
	}
	printf("Round: %03d Mean: %3.2f Min: %03d Max: %03d\r",round,float(total_energy)/n_threads, min_energy, max_energy);
	fflush(stdout);
}

int main(){
	int i,j;
	long int n_steps;
	float time;

	int *h_lut_exp, *d_lut_exp;
	h_lut_exp = (int*) malloc(256*sizeof(int));
	gpuErrchk(cudaMalloc(&d_lut_exp,256*sizeof(int)));

	unsigned int* energies;

	energies = (unsigned int*) malloc(N_THREADS*sizeof(unsigned int));

	dim3 threads_per_block(THREADS_PER_BLOCK);
	dim3 num_blocks(N_BLOCKS);

	sudoku_t d_sudoku, h_sudoku;

	//set up exp(delta_E/T) lut
	//256 is a safe upper bound for SUD_SIZE 9 and we clamp delta E for
	//SUD_SIZE 16. But anyway, for useful temperatures it is zero very quickly
	//anyway
	float temp = 0.7;
	for(i=0;i<256;i++){
		h_lut_exp[i] = exp(-i/temp)*(1<<16);
	}
	gpuErrchk(cudaMemcpy(d_lut_exp,h_lut_exp,256*sizeof(int),cudaMemcpyHostToDevice));

	//set up sudoku description
	if(SUD_SIZE==9){
		sudoku_alloc_host(&h_sudoku,h_lut_exp,81);
		empty(&h_sudoku);
	} else {
		sudoku_alloc_host(&h_sudoku, h_lut_exp, 165);
		hint16(&h_sudoku);
	}
	printf("Unknowns: %d\n",h_sudoku.n_unk);
	sudoku_alloc_and_copy_device(&d_sudoku,&h_sudoku);

	n_steps = N_THREADS*N_STEPS;
	//GPU Run
	time = clock();

	for(j=0;j<15000;j++){
		step_gpu<<<num_blocks,threads_per_block>>>(d_sudoku,d_lut_exp);
		gpuErrchk(cudaMemcpy(energies,d_sudoku.energy,N_THREADS*sizeof(unsigned int),cudaMemcpyDeviceToHost));
		energy_stats(j,energies,N_THREADS);
	}
	time = (clock() - time)/CLOCKS_PER_SEC;
	printf("\nGPU: Steps: %ld, Time: %f s, %.1f Steps/s\n",n_steps,time,n_steps/time);

	//CPU Run
	time = clock();

	for(j=0;j<N_STEPS;j++){
		step_cpu(h_sudoku,h_lut_exp);
		gpuErrchk(cudaMemcpy(energies,h_sudoku.energy,N_THREADS*sizeof(unsigned int),cudaMemcpyHostToHost));
		energy_stats(j,energies,N_THREADS);
	}
	time = (clock() - time)/CLOCKS_PER_SEC;
	printf("\nCPU: Steps: %ld, Time: %f s, %.1f Steps/s\n",n_steps,time,n_steps/time);

	sudoku_free_host(&h_sudoku);
	sudoku_free_device(&d_sudoku);
	free(energies);
	cudaFree(d_lut_exp);
}

	.file	"tmpxft_003198b2_00000000-6_mcsudoku.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2043:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2043:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._Z9gpuAssert9cudaErrorPcib.str1.1,"aMS",@progbits,1
.LC2:
	.string	"GPUassert: %s %s %d\n"
	.section	.text._Z9gpuAssert9cudaErrorPcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPcib
	.type	_Z9gpuAssert9cudaErrorPcib, @function
_Z9gpuAssert9cudaErrorPcib:
.LFB2027:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L8
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r9d
	movq	(%rsp), %r8
	leaq	.LC2(%rip), %rdx
	movq	stderr(%rip), %rdi
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	testb	%bpl, %bpl
	je	.L2
	movl	%ebx, %edi
	call	exit@PLT
.L2:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z9gpuAssert9cudaErrorPcib, .-_Z9gpuAssert9cudaErrorPcib
	.text
	.globl	_Z7mc_step8sudoku_tPij
	.type	_Z7mc_step8sudoku_tPij, @function
_Z7mc_step8sudoku_tPij:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %ecx
	xorl	%edx, %edx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	$9, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	0(,%rcx,4), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	112(%rsp), %rax
	movl	104(%rsp), %r11d
	movq	136(%rsp), %r8
	movq	144(%rsp), %r9
	movq	152(%rsp), %r10
	movq	%rax, -16(%rsp)
	movq	120(%rsp), %rax
	movq	%rdi, -8(%rsp)
	movq	128(%rsp), %rdi
	addq	%rbp, %rax
	movq	80(%rsp), %r14
	imull	$1664525, (%rax), %esi
	addl	$1013904223, %esi
	movl	%esi, (%rax)
	movl	%esi, %eax
	divl	%r11d
	movslq	%edx, %rdx
	leaq	(%rdi,%rdx,8), %rbx
	xorl	%edx, %edx
	movq	(%rbx), %r12
	addq	%rcx, %r12
	movb	(%r12), %al
	movb	%al, -17(%rsp)
	movl	%esi, %eax
	shrl	$8, %eax
	divl	%r13d
	movq	88(%rsp), %r13
	xorl	%eax, %eax
	movb	%dl, (%r12)
	movq	96(%rsp), %r12
.L13:
	movb	(%r14,%rax), %r15b
	movq	(%r8,%rax,8), %rdx
	movb	%r15b, (%rdx,%rcx)
	movb	0(%r13,%rax), %r15b
	movq	(%r9,%rax,8), %rdx
	movb	%r15b, (%rdx,%rcx)
	movb	(%r12,%rax), %r15b
	movq	(%r10,%rax,8), %rdx
	incq	%rax
	movb	%r15b, (%rdx,%rcx)
	cmpq	$81, %rax
	jne	.L13
	movq	56(%rsp), %r12
	movq	64(%rsp), %r13
	xorl	%eax, %eax
	movq	72(%rsp), %r14
.L14:
	cmpl	%r11d, %eax
	jnb	.L33
	movq	(%rdi,%rax,8), %rdx
	movsbl	(%r12,%rax), %r15d
	movsbl	(%rdx,%rcx), %edx
	leal	(%r15,%r15,8), %r15d
	addl	%r15d, %edx
	movslq	%edx, %rdx
	movq	(%r8,%rdx,8), %r15
	addq	%rcx, %r15
	incb	(%r15)
	movq	(%rdi,%rax,8), %rdx
	movsbl	0(%r13,%rax), %r15d
	movsbl	(%rdx,%rcx), %edx
	leal	(%r15,%r15,8), %r15d
	addl	%r15d, %edx
	movslq	%edx, %rdx
	movq	(%r9,%rdx,8), %r15
	addq	%rcx, %r15
	incb	(%r15)
	movq	(%rdi,%rax,8), %rdx
	movsbl	(%r14,%rax), %r15d
	incq	%rax
	movsbl	(%rdx,%rcx), %edx
	leal	(%r15,%r15,8), %r15d
	addl	%r15d, %edx
	movslq	%edx, %rdx
	movq	(%r10,%rdx,8), %r15
	addq	%rcx, %r15
	incb	(%r15)
	jmp	.L14
.L33:
	xorl	%eax, %eax
	xorl	%edx, %edx
.L19:
	movq	(%r8,%rax), %rdi
	movl	$1, %r11d
	movsbl	(%rdi,%rcx), %edi
	testb	%dil, %dil
	je	.L16
	leal	-1(%rdi), %r11d
.L16:
	movq	(%r9,%rax), %rdi
	movl	$1, %r12d
	movsbl	(%rdi,%rcx), %edi
	testb	%dil, %dil
	je	.L17
	leal	-1(%rdi), %r12d
.L17:
	movq	(%r10,%rax), %rdi
	addl	%r12d, %r11d
	movsbl	(%rdi,%rcx), %r12d
	movl	$1, %edi
	testb	%r12b, %r12b
	je	.L18
	leal	-1(%r12), %edi
.L18:
	addl	%r11d, %edi
	addq	$8, %rax
	addl	%edi, %edx
	cmpq	$648, %rax
	jne	.L19
	movq	-16(%rsp), %rdi
	movl	%edx, %eax
	addq	%rbp, %rdi
	subl	(%rdi), %eax
	testl	%eax, %eax
	jle	.L20
	movl	$255, %r8d
	movq	-8(%rsp), %r9
	cmpl	%r8d, %eax
	cmovg	%r8d, %eax
	shrl	$16, %esi
	cltq
	cmpl	%esi, (%r9,%rax,4)
	jb	.L21
.L20:
	testl	%edx, %edx
	jne	.L22
.L21:
	movq	(%rbx), %rax
	movb	-17(%rsp), %bl
	movb	%bl, (%rax,%rcx)
	jmp	.L12
.L22:
	movl	%edx, (%rdi)
.L12:
	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
.LFE2028:
	.size	_Z7mc_step8sudoku_tPij, .-_Z7mc_step8sudoku_tPij
	.globl	_Z17sudoku_alloc_hostP8sudoku_tPij
	.type	_Z17sudoku_alloc_hostP8sudoku_tPij, @function
_Z17sudoku_alloc_hostP8sudoku_tPij:
.LFB2029:
	.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
	movl	%edx, %r13d
	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
	movq	%r13, %rdi
	pushq	%rcx
	.cfi_def_cfa_offset 64
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, (%rbx)
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, 8(%rbx)
	call	malloc@PLT
	movl	$81, %edi
	movq	%rax, 16(%rbx)
	call	malloc@PLT
	movl	$81, %edi
	movq	%rax, 24(%rbx)
	call	malloc@PLT
	movl	$81, %edi
	movq	%rax, 32(%rbx)
	call	malloc@PLT
	movl	%r13d, 48(%rbx)
	movl	$262144, %edi
	salq	$3, %r13
	movq	%rax, 40(%rbx)
	call	malloc@PLT
	movl	$262144, %edi
	movq	%rax, 56(%rbx)
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, 64(%rbx)
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rax, 72(%rbx)
	movq	%rax, %rbp
	addq	%rax, %r13
.L35:
	cmpq	%r13, %rbp
	je	.L48
	movl	$65536, %edi
	addq	$8, %rbp
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	jmp	.L35
.L48:
	movl	$648, %edi
	xorl	%ebp, %ebp
	call	malloc@PLT
	movl	$648, %edi
	movq	%rax, 80(%rbx)
	movq	%rax, %r15
	call	malloc@PLT
	movl	$648, %edi
	movq	%rax, 88(%rbx)
	movq	%rax, %r14
	call	malloc@PLT
	movq	%rax, 96(%rbx)
	movq	%rax, %r13
.L37:
	movl	$65536, %edi
	call	malloc@PLT
	movl	$65536, %edi
	movq	%rax, (%r15,%rbp)
	call	malloc@PLT
	movl	$65536, %edi
	movq	%rax, (%r14,%rbp)
	call	malloc@PLT
	movq	%rax, 0(%r13,%rbp)
	addq	$8, %rbp
	cmpq	$648, %rbp
	jne	.L37
	movl	$-1624324474, %eax
.L38:
	movl	%eax, (%r12)
	subl	$1083573575, %eax
	addq	$4, %r12
	cmpl	$-1712863610, %eax
	jne	.L38
	xorl	%esi, %esi
	movl	$9, %edi
.L39:
	cmpl	48(%rbx), %esi
	jnb	.L49
	leaq	0(,%rsi,8), %r9
	xorl	%ecx, %ecx
.L40:
	movq	72(%rbx), %rax
	xorl	%edx, %edx
	movq	(%rax,%r9), %r8
	movq	64(%rbx), %rax
	movl	(%rax,%rcx,4), %eax
	divl	%edi
	movb	%dl, (%r8,%rcx)
	movq	64(%rbx), %rax
	leaq	(%rax,%rcx,4), %rdx
	incq	%rcx
	imull	$1664525, (%rdx), %eax
	addl	$1013904223, %eax
	movl	%eax, (%rdx)
	cmpq	$65536, %rcx
	jne	.L40
	incq	%rsi
	jmp	.L39
.L49:
	movq	56(%rbx), %rdx
	xorl	%eax, %eax
.L42:
	movl	$1048576, (%rdx,%rax,4)
	incq	%rax
	cmpq	$65536, %rax
	jne	.L42
	popq	%rax
	.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
.LFE2029:
	.size	_Z17sudoku_alloc_hostP8sudoku_tPij, .-_Z17sudoku_alloc_hostP8sudoku_tPij
	.globl	_Z16sudoku_free_hostP8sudoku_t
	.type	_Z16sudoku_free_hostP8sudoku_t, @function
_Z16sudoku_free_hostP8sudoku_t:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
	call	free@PLT
	movq	8(%rbx), %rdi
	call	free@PLT
	movq	16(%rbx), %rdi
	call	free@PLT
	movq	24(%rbx), %rdi
	call	free@PLT
	movq	32(%rbx), %rdi
	call	free@PLT
	movq	40(%rbx), %rdi
	call	free@PLT
	movq	56(%rbx), %rdi
	call	free@PLT
	movq	64(%rbx), %rdi
	call	free@PLT
.L51:
	movq	72(%rbx), %rdi
	cmpl	48(%rbx), %ebp
	jnb	.L56
	movq	(%rdi,%rbp,8), %rdi
	incq	%rbp
	call	free@PLT
	jmp	.L51
.L56:
	call	free@PLT
	xorl	%ebp, %ebp
.L53:
	movq	80(%rbx), %rax
	movq	(%rax,%rbp), %rdi
	call	free@PLT
	movq	88(%rbx), %rax
	movq	(%rax,%rbp), %rdi
	call	free@PLT
	movq	96(%rbx), %rax
	movq	(%rax,%rbp), %rdi
	addq	$8, %rbp
	call	free@PLT
	cmpq	$648, %rbp
	jne	.L53
	movq	80(%rbx), %rdi
	call	free@PLT
	movq	88(%rbx), %rdi
	call	free@PLT
	movq	96(%rbx), %rdi
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z16sudoku_free_hostP8sudoku_t, .-_Z16sudoku_free_hostP8sudoku_t
	.globl	_Z18sudoku_free_deviceP8sudoku_t
	.type	_Z18sudoku_free_deviceP8sudoku_t, @function
_Z18sudoku_free_deviceP8sudoku_t:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	call	cudaFree@PLT
	movq	8(%rbx), %rdi
	call	cudaFree@PLT
	movq	16(%rbx), %rdi
	call	cudaFree@PLT
	movq	24(%rbx), %rdi
	call	cudaFree@PLT
	movq	32(%rbx), %rdi
	call	cudaFree@PLT
	movq	40(%rbx), %rdi
	call	cudaFree@PLT
	movq	56(%rbx), %rdi
	call	cudaFree@PLT
	movq	64(%rbx), %rdi
	call	cudaFree@PLT
	movl	48(%rbx), %r12d
	salq	$3, %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	72(%rbx), %rsi
	movq	%r12, %rdx
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %rbp
	xorl	%r12d, %r12d
	call	cudaMemcpy@PLT
.L58:
	cmpl	48(%rbx), %r12d
	jnb	.L63
	movq	0(%rbp,%r12,8), %rdi
	incq	%r12
	call	cudaFree@PLT
	jmp	.L58
.L63:
	movq	%rbp, %rdi
	xorl	%ebp, %ebp
	call	free@PLT
	movq	72(%rbx), %rdi
	call	cudaFree@PLT
	movl	$648, %edi
	call	malloc@PLT
	movl	$648, %edi
	movq	%rax, %r14
	call	malloc@PLT
	movl	$648, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movq	80(%rbx), %rsi
	movl	$2, %ecx
	movq	%r13, %rdi
	movl	$648, %edx
	movq	%rax, %r12
	call	cudaMemcpy@PLT
	movq	88(%rbx), %rsi
	movl	$2, %ecx
	movq	%r14, %rdi
	movl	$648, %edx
	call	cudaMemcpy@PLT
	movq	96(%rbx), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	movl	$648, %edx
	call	cudaMemcpy@PLT
.L60:
	movq	0(%r13,%rbp), %rdi
	call	cudaFree@PLT
	movq	(%r14,%rbp), %rdi
	call	cudaFree@PLT
	movq	(%r12,%rbp), %rdi
	addq	$8, %rbp
	call	cudaFree@PLT
	cmpq	$648, %rbp
	jne	.L60
	movq	%r14, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	80(%rbx), %rdi
	call	cudaFree@PLT
	movq	88(%rbx), %rdi
	call	cudaFree@PLT
	movq	96(%rbx), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	cudaFree@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z18sudoku_free_deviceP8sudoku_t, .-_Z18sudoku_free_deviceP8sudoku_t
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/shaowei-su/sudocuda/master/mcsudoku.cu"
	.text
	.globl	_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_
	.type	_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_, @function
_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_:
.LFB2032:
	.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
	xorl	%r14d, %r14d
	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
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movslq	48(%rsi), %rax
	movq	%rax, %rsi
	movq	%rax, %r13
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$283, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	8(%rbx), %rdi
	movslq	%r13d, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$284, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	16(%rbx), %rdi
	movslq	%r13d, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$285, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	24(%rbx), %rdi
	movl	$81, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$287, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	32(%rbx), %rdi
	movl	$81, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$288, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	40(%rbx), %rdi
	movl	$81, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$289, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	56(%rbx), %rdi
	movl	$262144, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$291, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	64(%rbx), %rdi
	movl	$262144, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$292, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movslq	%r13d, %rax
	leaq	72(%rbx), %rdi
	leaq	0(,%rax,8), %r12
	movq	%r12, %rsi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$298, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	%r12, %rdi
	call	malloc@PLT
	movq	%rax, (%rsp)
	movq	%rax, %r15
.L65:
	cmpl	%r13d, %r14d
	jge	.L74
	movq	%r15, %rdi
	movl	$65536, %esi
	incl	%r14d
	addq	$8, %r15
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$301, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	jmp	.L65
.L74:
	movq	72(%rbx), %rdi
	movq	(%rsp), %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r15d, %r15d
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$303, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	80(%rbx), %rdi
	movl	$648, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$305, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	88(%rbx), %rdi
	movl	$648, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$306, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	96(%rbx), %rdi
	movl	$648, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$307, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movl	$648, %edi
	call	malloc@PLT
	movl	$648, %edi
	movq	%rax, %r14
	call	malloc@PLT
	movl	$648, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movq	%rax, %r12
.L67:
	leaq	(%r14,%r15), %rdi
	movl	$65536, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$314, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	0(%r13,%r15), %rdi
	movl	$65536, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$315, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	leaq	(%r12,%r15), %rdi
	movl	$65536, %esi
	addq	$8, %r15
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$316, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	cmpq	$648, %r15
	jne	.L67
	movq	80(%rbx), %rdi
	movl	$1, %ecx
	movl	$648, %edx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$318, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	88(%rbx), %rdi
	movl	$1, %ecx
	movq	%r13, %rsi
	movl	$648, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$319, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	96(%rbx), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$648, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$320, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movl	48(%rbp), %eax
	movq	(%rbx), %rdi
	movl	$1, %ecx
	movq	8(%rsp), %rdx
	movq	0(%rbp), %rsi
	movl	%eax, 48(%rbx)
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$325, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	8(%rbx), %rdi
	movq	8(%rbp), %rsi
	movl	$1, %ecx
	movq	8(%rsp), %rdx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$326, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	16(%rbx), %rdi
	movq	16(%rbp), %rsi
	movl	$1, %ecx
	movq	8(%rsp), %rdx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$327, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	24(%rbx), %rdi
	movq	24(%rbp), %rsi
	movl	$1, %ecx
	movl	$81, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$329, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	32(%rbx), %rdi
	movq	32(%rbp), %rsi
	movl	$1, %ecx
	movl	$81, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$330, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	40(%rbx), %rdi
	movq	40(%rbp), %rsi
	movl	$1, %ecx
	movl	$81, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$331, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	56(%rbx), %rdi
	movq	56(%rbp), %rsi
	movl	$1, %ecx
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$334, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	64(%rbx), %rdi
	movq	64(%rbp), %rsi
	xorl	%ebx, %ebx
	movl	$1, %ecx
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$335, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
.L68:
	cmpl	48(%rbp), %ebx
	jnb	.L75
	movq	72(%rbp), %rax
	movl	$1, %ecx
	movl	$65536, %edx
	movq	(%rax,%rbx,8), %rsi
	movq	(%rsp), %rax
	movq	(%rax,%rbx,8), %rdi
	incq	%rbx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$338, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	jmp	.L68
.L75:
	xorl	%ebx, %ebx
.L70:
	movq	80(%rbp), %rax
	movq	(%r14,%rbx), %rdi
	movl	$1, %ecx
	movl	$65536, %edx
	movq	(%rax,%rbx), %rsi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$342, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	88(%rbp), %rax
	movq	0(%r13,%rbx), %rdi
	movl	$1, %ecx
	movl	$65536, %edx
	movq	(%rax,%rbx), %rsi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$343, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	96(%rbp), %rax
	movq	(%r12,%rbx), %rdi
	movl	$1, %ecx
	movl	$65536, %edx
	movq	(%rax,%rbx), %rsi
	addq	$8, %rbx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$344, %edx
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	cmpq	$648, %rbx
	jne	.L70
	movq	(%rsp), %rdi
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	movq	%r12, %rdi
	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
	jmp	free@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_, .-_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_
	.globl	_Z8step_cpu8sudoku_tPi
	.type	_Z8step_cpu8sudoku_tPi, @function
_Z8step_cpu8sudoku_tPi:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	xorl	%ebx, %ebx
.L77:
	subq	$104, %rsp
	.cfi_def_cfa_offset 128
	movl	$26, %ecx
	movq	%rsp, %rdi
	leaq	128(%rsp), %rsi
	rep movsl
	movl	%ebx, %esi
	movq	%rbp, %rdi
	incl	%ebx
	call	_Z7mc_step8sudoku_tPij
	addq	$104, %rsp
	.cfi_def_cfa_offset 24
	cmpl	$65536, %ebx
	jne	.L77
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z8step_cpu8sudoku_tPi, .-_Z8step_cpu8sudoku_tPi
	.globl	_Z7add_unkP8sudoku_tii
	.type	_Z7add_unkP8sudoku_tii, @function
_Z7add_unkP8sudoku_tii:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	movl	%edx, %edi
	movl	$3, %r8d
	movl	48(%rcx), %eax
	movq	(%rcx), %rdx
	movb	%sil, (%rdx,%rax)
	movl	48(%rcx), %eax
	movq	8(%rcx), %rdx
	movb	%dil, (%rdx,%rax)
	movl	%esi, %eax
	movl	48(%rcx), %r9d
	cltd
	movq	16(%rcx), %r10
	idivl	%r8d
	movl	%edi, %eax
	subl	%edx, %esi
	cltd
	idivl	%r8d
	addl	%eax, %esi
	movb	%sil, (%r10,%r9)
	incl	48(%rcx)
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z7add_unkP8sudoku_tii, .-_Z7add_unkP8sudoku_tii
	.globl	_Z7add_hinP8sudoku_tiii
	.type	_Z7add_hinP8sudoku_tiii, @function
_Z7add_hinP8sudoku_tiii:
.LFB2035:
	.cfi_startproc
	endbr64
	leal	(%rcx,%rcx,8), %ecx
	movq	%rdi, %r8
	movl	$3, %r9d
	movl	%edx, %edi
	leal	(%rcx,%rsi), %eax
	cltq
	addq	24(%r8), %rax
	incb	(%rax)
	leal	(%rcx,%rdx), %eax
	cltq
	addq	32(%r8), %rax
	incb	(%rax)
	movl	%esi, %eax
	cltd
	idivl	%r9d
	movl	%edi, %eax
	subl	%edx, %esi
	cltd
	idivl	%r9d
	addl	%eax, %esi
	addl	%ecx, %esi
	movslq	%esi, %rsi
	addq	40(%r8), %rsi
	incb	(%rsi)
	ret
	.cfi_endproc
.LFE2035:
	.size	_Z7add_hinP8sudoku_tiii, .-_Z7add_hinP8sudoku_tiii
	.section	.rodata
	.align 32
.LC0:
	.long	0
	.long	9
	.long	0
	.long	7
	.long	0
	.long	3
	.long	0
	.long	6
	.long	0
	.long	0
	.long	5
	.long	0
	.long	4
	.long	0
	.long	8
	.long	0
	.long	1
	.long	0
	.long	1
	.long	0
	.long	8
	.long	0
	.long	5
	.long	0
	.long	9
	.long	0
	.long	4
	.long	7
	.long	0
	.long	0
	.long	1
	.long	8
	.long	2
	.long	0
	.long	0
	.long	3
	.long	0
	.long	4
	.long	2
	.long	0
	.long	6
	.long	0
	.long	5
	.long	8
	.long	0
	.long	3
	.long	0
	.long	0
	.long	9
	.long	4
	.long	5
	.long	0
	.long	0
	.long	2
	.long	8
	.long	0
	.long	6
	.long	0
	.long	7
	.long	0
	.long	1
	.long	0
	.long	9
	.long	0
	.long	2
	.long	0
	.long	8
	.long	0
	.long	1
	.long	0
	.long	5
	.long	0
	.long	0
	.long	1
	.long	0
	.long	6
	.long	0
	.long	9
	.long	0
	.long	4
	.long	0
	.text
	.globl	_Z5hint1P8sudoku_t
	.type	_Z5hint1P8sudoku_t, @function
_Z5hint1P8sudoku_t:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%rdi, %r11
	xorl	%ecx, %ecx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$336, %rsp
	.cfi_def_cfa_offset 384
	movq	%fs:40, %rax
	movq	%rax, 328(%rsp)
	xorl	%eax, %eax
	xorl	%eax, %eax
	movl	%eax, 48(%rdi)
.L83:
	movq	24(%r11), %rax
	movb	$0, (%rax,%rcx)
	movq	32(%r11), %rax
	movb	$0, (%rax,%rcx)
	movq	40(%r11), %rax
	movb	$0, (%rax,%rcx)
	incq	%rcx
	cmpq	$81, %rcx
	jne	.L83
	leaq	4(%rsp), %rdi
	leaq	.LC0(%rip), %rsi
	xorl	%ebp, %ebp
	rep movsl
	leaq	4(%rsp), %r14
.L84:
	imulq	$36, %rbp, %r12
	movl	%ebp, %r13d
	xorl	%ebx, %ebx
	addq	%r14, %r12
.L87:
	movl	(%r12,%rbx,4), %ecx
	movl	%ebx, %edx
	testl	%ecx, %ecx
	jne	.L85
	movl	%r13d, %esi
	movq	%r11, %rdi
	call	_Z7add_unkP8sudoku_tii
	jmp	.L86
.L85:
	decl	%ecx
	movl	%r13d, %esi
	movq	%r11, %rdi
	call	_Z7add_hinP8sudoku_tiii
.L86:
	incq	%rbx
	cmpq	$9, %rbx
	jne	.L87
	incq	%rbp
	cmpq	$9, %rbp
	jne	.L84
	movq	328(%rsp), %rax
	subq	%fs:40, %rax
	je	.L89
	call	__stack_chk_fail@PLT
.L89:
	addq	$336, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z5hint1P8sudoku_t, .-_Z5hint1P8sudoku_t
	.globl	_Z5emptyP8sudoku_t
	.type	_Z5emptyP8sudoku_t, @function
_Z5emptyP8sudoku_t:
.LFB2037:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %r11
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%eax, 48(%rdi)
	xorl	%eax, %eax
.L94:
	movq	24(%r11), %rdx
	movb	$0, (%rdx,%rax)
	movq	32(%r11), %rdx
	movb	$0, (%rdx,%rax)
	movq	40(%r11), %rdx
	movb	$0, (%rdx,%rax)
	incq	%rax
	cmpq	$81, %rax
	jne	.L94
	xorl	%ebp, %ebp
.L95:
	xorl	%ebx, %ebx
.L96:
	movl	%ebx, %edx
	movl	%ebp, %esi
	movq	%r11, %rdi
	incl	%ebx
	call	_Z7add_unkP8sudoku_tii
	cmpl	$9, %ebx
	jne	.L96
	incl	%ebp
	cmpl	$9, %ebp
	jne	.L95
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2037:
	.size	_Z5emptyP8sudoku_t, .-_Z5emptyP8sudoku_t
	.section	.rodata
	.align 32
.LC1:
	.long	0
	.long	2
	.long	0
	.long	1
	.long	0
	.long	9
	.long	0
	.long	0
	.long	0
	.long	0
	.long	11
	.long	0
	.long	0
	.long	15
	.long	14
	.long	0
	.long	0
	.long	13
	.long	11
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	9
	.long	0
	.long	7
	.long	0
	.long	16
	.long	8
	.long	0
	.long	12
	.long	4
	.long	0
	.long	10
	.long	7
	.long	15
	.long	0
	.long	0
	.long	2
	.long	0
	.long	0
	.long	0
	.long	0
	.long	3
	.long	0
	.long	0
	.long	9
	.long	0
	.long	0
	.long	0
	.long	0
	.long	10
	.long	0
	.long	0
	.long	12
	.long	13
	.long	0
	.long	0
	.long	0
	.long	0
	.long	4
	.long	0
	.long	0
	.long	3
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	16
	.long	9
	.long	11
	.long	0
	.long	0
	.long	0
	.long	0
	.long	15
	.long	5
	.long	0
	.long	16
	.long	0
	.long	0
	.long	0
	.long	4
	.long	1
	.long	0
	.long	3
	.long	0
	.long	0
	.long	10
	.long	0
	.long	0
	.long	1
	.long	0
	.long	9
	.long	12
	.long	13
	.long	15
	.long	0
	.long	0
	.long	0
	.long	6
	.long	10
	.long	0
	.long	4
	.long	0
	.long	0
	.long	0
	.long	0
	.long	11
	.long	0
	.long	0
	.long	2
	.long	6
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	13
	.long	0
	.long	9
	.long	8
	.long	7
	.long	10
	.long	0
	.long	6
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	1
	.long	3
	.long	0
	.long	0
	.long	8
	.long	0
	.long	0
	.long	0
	.long	0
	.long	11
	.long	0
	.long	13
	.long	7
	.long	0
	.long	0
	.long	0
	.long	6
	.long	10
	.long	1
	.long	12
	.long	0
	.long	4
	.long	0
	.long	0
	.long	12
	.long	0
	.long	0
	.long	5
	.long	0
	.long	16
	.long	7
	.long	0
	.long	0
	.long	0
	.long	11
	.long	0
	.long	10
	.long	13
	.long	0
	.long	0
	.long	0
	.long	0
	.long	6
	.long	8
	.long	14
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	2
	.long	0
	.long	0
	.long	3
	.long	0
	.long	0
	.long	0
	.long	0
	.long	13
	.long	16
	.long	0
	.long	0
	.long	12
	.long	0
	.long	0
	.long	0
	.long	0
	.long	13
	.long	0
	.long	0
	.long	4
	.long	0
	.long	0
	.long	0
	.long	0
	.long	11
	.long	0
	.long	0
	.long	14
	.long	2
	.long	1
	.long	0
	.long	3
	.long	9
	.long	0
	.long	2
	.long	5
	.long	0
	.long	3
	.long	0
	.long	15
	.long	0
	.long	0
	.long	0
	.long	0
	.long	0
	.long	14
	.long	7
	.long	0
	.long	0
	.long	7
	.long	1
	.long	0
	.long	0
	.long	14
	.long	0
	.long	0
	.long	0
	.long	0
	.long	5
	.long	0
	.long	8
	.long	0
	.long	16
	.long	0
	.text
	.globl	_Z6hint16P8sudoku_t
	.type	_Z6hint16P8sudoku_t, @function
_Z6hint16P8sudoku_t:
.LFB2038:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%edx, %edx
	movq	%rdi, %r11
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$1040, %rsp
	.cfi_def_cfa_offset 1088
	movq	%fs:40, %rax
	movq	%rax, 1032(%rsp)
	xorl	%eax, %eax
	movl	%edx, 48(%rdi)
.L102:
	movq	24(%r11), %rdx
	movb	$0, (%rdx,%rax)
	movq	32(%r11), %rdx
	movb	$0, (%rdx,%rax)
	movq	40(%r11), %rdx
	movb	$0, (%rdx,%rax)
	incq	%rax
	cmpq	$81, %rax
	jne	.L102
	leaq	8(%rsp), %rdi
	leaq	.LC1(%rip), %rsi
	movl	$256, %ecx
	xorl	%ebp, %ebp
	rep movsl
	leaq	8(%rsp), %r14
.L103:
	imulq	$36, %rbp, %r12
	movl	%ebp, %r13d
	xorl	%ebx, %ebx
	addq	%r14, %r12
.L106:
	movl	(%r12,%rbx,4), %ecx
	movl	%ebx, %edx
	testl	%ecx, %ecx
	jne	.L104
	movl	%r13d, %esi
	movq	%r11, %rdi
	call	_Z7add_unkP8sudoku_tii
	jmp	.L105
.L104:
	decl	%ecx
	movl	%r13d, %esi
	movq	%r11, %rdi
	call	_Z7add_hinP8sudoku_tiii
.L105:
	incq	%rbx
	cmpq	$9, %rbx
	jne	.L106
	incq	%rbp
	cmpq	$9, %rbp
	jne	.L103
	movq	1032(%rsp), %rax
	subq	%fs:40, %rax
	je	.L108
	call	__stack_chk_fail@PLT
.L108:
	addq	$1040, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2038:
	.size	_Z6hint16P8sudoku_t, .-_Z6hint16P8sudoku_t
	.section	.rodata.str1.1
.LC4:
	.string	"Round: %03d Mean: %3.2f Min: %03d Max: %03d\r"
	.text
	.globl	_Z12energy_statsiPjj
	.type	_Z12energy_statsiPjj, @function
_Z12energy_statsiPjj:
.LFB2039:
	.cfi_startproc
	endbr64
	movl	%edi, %r9d
	pushq	%rcx
	.cfi_def_cfa_offset 16
	xorl	%edi, %edi
	xorl	%r10d, %r10d
	movl	$100000, %ecx
	xorl	%r8d, %r8d
.L113:
	cmpl	%edx, %edi
	jnb	.L118
	movl	(%rsi,%rdi,4), %eax
	cmpl	%eax, %r8d
	cmovb	%eax, %r8d
	cmpl	%eax, %ecx
	cmova	%eax, %ecx
	addl	%eax, %r10d
	incq	%rdi
	jmp	.L113
.L118:
	cvtsi2ssl	%edx, %xmm1
	movl	$2, %edi
	movl	%r9d, %edx
	movb	$1, %al
	cvtsi2ssl	%r10d, %xmm0
	leaq	.LC4(%rip), %rsi
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	fflush@PLT
	.cfi_endproc
.LFE2039:
	.size	_Z12energy_statsiPjj, .-_Z12energy_statsiPjj
	.globl	_Z36__device_stub__Z8step_gpu8sudoku_tPiR8sudoku_tPi
	.type	_Z36__device_stub__Z8step_gpu8sudoku_tPiR8sudoku_tPi, @function
_Z36__device_stub__Z8step_gpu8sudoku_tPiR8sudoku_tPi:
.LFB2065:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rsi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movq	%rdi, 88(%rsp)
	leaq	40(%rsp), %rdi
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movl	$1, 48(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L119
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z8step_gpu8sudoku_tPi(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L119:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L121
	call	__stack_chk_fail@PLT
.L121:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2065:
	.size	_Z36__device_stub__Z8step_gpu8sudoku_tPiR8sudoku_tPi, .-_Z36__device_stub__Z8step_gpu8sudoku_tPiR8sudoku_tPi
	.globl	_Z8step_gpu8sudoku_tPi
	.type	_Z8step_gpu8sudoku_tPi, @function
_Z8step_gpu8sudoku_tPi:
.LFB2066:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdi, %rsi
	leaq	16(%rsp), %rdi
	call	_Z36__device_stub__Z8step_gpu8sudoku_tPiR8sudoku_tPi
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2066:
	.size	_Z8step_gpu8sudoku_tPi, .-_Z8step_gpu8sudoku_tPi
	.section	.rodata.str1.1
.LC7:
	.string	"Unknowns: %d\n"
.LC10:
	.string	"\nGPU: Steps: %ld, Time: %f s, %.1f Steps/s\n"
.LC11:
	.string	"\nCPU: Steps: %ld, Time: %f s, %.1f Steps/s\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2040:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1024, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC3(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$376, %rsp
	.cfi_def_cfa_offset 432
	movq	%fs:40, %rax
	movq	%rax, 360(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	leaq	16(%rsp), %rdi
	movl	$1024, %esi
	movq	%rax, %rbp
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$467, %edx
	movq	%r13, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movl	$262144, %edi
	call	malloc@PLT
	movl	$1, 32(%rsp)
	movq	%rax, (%rsp)
	movl	$16777217, %eax
	salq	$8, %rax
	movl	$1, 44(%rsp)
	movq	%rax, 24(%rsp)
	movq	%rax, 36(%rsp)
.L126:
	movl	%ebx, %eax
	negl	%eax
	cvtsi2ssl	%eax, %xmm0
	divss	.LC5(%rip), %xmm0
	call	expf@PLT
	mulss	.LC6(%rip), %xmm0
	cvttss2sil	%xmm0, %eax
	movl	%eax, 0(%rbp,%rbx,4)
	incq	%rbx
	cmpq	$256, %rbx
	jne	.L126
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	xorl	%r14d, %r14d
	movl	$1024, %edx
	leaq	152(%rsp), %rbx
	leaq	48(%rsp), %r12
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movq	%r13, %rsi
	movl	$486, %edx
	movl	%eax, %edi
	leaq	256(%rsp), %r15
	call	_Z9gpuAssert9cudaErrorPcib
	movl	$81, %edx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	_Z17sudoku_alloc_hostP8sudoku_tPij
	movq	%rbx, %rdi
	call	_Z5emptyP8sudoku_t
	movl	200(%rsp), %edx
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_
	call	clock@PLT
	cvtsi2ssq	%rax, %xmm2
	movss	%xmm2, 12(%rsp)
.L128:
	movl	32(%rsp), %ecx
	movq	24(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	36(%rsp), %rdi
	movl	44(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L127
	leaq	256(%rsp), %rdi
	movl	$26, %ecx
	movq	%r12, %rsi
	rep movsl
	movq	16(%rsp), %rsi
	movq	%r15, %rdi
	call	_Z36__device_stub__Z8step_gpu8sudoku_tPiR8sudoku_tPi
.L127:
	movq	104(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	$2, %ecx
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$505, %edx
	movq	%r13, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	(%rsp), %rsi
	movl	%r14d, %edi
	movl	$65536, %edx
	incl	%r14d
	call	_Z12energy_statsiPjj
	cmpl	$15000, %r14d
	jne	.L128
	call	clock@PLT
	movss	.LC9(%rip), %xmm1
	movl	$6553600, %edx
	xorl	%r14d, %r14d
	cvtsi2ssq	%rax, %xmm0
	subss	12(%rsp), %xmm0
	movl	$2, %edi
	movb	$2, %al
	divss	.LC8(%rip), %xmm0
	divss	%xmm0, %xmm1
	leaq	.LC10(%rip), %rsi
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__printf_chk@PLT
	call	clock@PLT
	cvtsi2ssq	%rax, %xmm4
	movss	%xmm4, 12(%rsp)
.L129:
	subq	$112, %rsp
	.cfi_def_cfa_offset 544
	movl	$26, %ecx
	movq	%rbx, %rsi
	movq	%rsp, %rdi
	rep movsl
	movq	%rbp, %rdi
	call	_Z8step_cpu8sudoku_tPi
	movq	112(%rsp), %rdi
	addq	$112, %rsp
	.cfi_def_cfa_offset 432
	xorl	%ecx, %ecx
	movq	208(%rsp), %rsi
	movl	$262144, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$516, %edx
	movq	%r13, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPcib
	movq	(%rsp), %rsi
	movl	%r14d, %edi
	movl	$65536, %edx
	incl	%r14d
	call	_Z12energy_statsiPjj
	cmpl	$100, %r14d
	jne	.L129
	call	clock@PLT
	movl	$6553600, %edx
	movl	$2, %edi
	movss	.LC9(%rip), %xmm1
	cvtsi2ssq	%rax, %xmm0
	subss	12(%rsp), %xmm0
	divss	.LC8(%rip), %xmm0
	movb	$2, %al
	divss	%xmm0, %xmm1
	leaq	.LC11(%rip), %rsi
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	call	_Z16sudoku_free_hostP8sudoku_t
	movq	%r12, %rdi
	call	_Z18sudoku_free_deviceP8sudoku_t
	movq	(%rsp), %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	360(%rsp), %rax
	subq	%fs:40, %rax
	je	.L130
	call	__stack_chk_fail@PLT
.L130:
	addq	$376, %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
.LFE2040:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z8step_gpu8sudoku_tPi"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2068:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z8step_gpu8sudoku_tPi(%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
.LFE2068:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC5:
	.long	1060320051
	.align 4
.LC6:
	.long	1199570944
	.align 4
.LC8:
	.long	1232348160
	.align 4
.LC9:
	.long	1254621184
	.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:

/* The MIT License (MIT)
 *
 * Copyright (c) 2013 Johannes Reinhardt <jreinhardt@ist-dein-freund.de>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

/* Monte Carlo Sudoku solver in CUDA */


#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <time.h>
#include <hip/hip_runtime.h>

//this must be smaller than 16 (but is realisticly 3 or 4 or maybe 5)
#define BLK_SIZE 3
#define SUD_SIZE (BLK_SIZE*BLK_SIZE)
#define N_ENTRIES (SUD_SIZE*SUD_SIZE)
#define THREADS_PER_BLOCK 256
#define N_BLOCKS 256
#define N_THREADS (THREADS_PER_BLOCK*N_BLOCKS)
#define N_STEPS 100

#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, char *file, int line, bool abort=true)
{
   if (code != hipSuccess) 
   {
      fprintf(stderr,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line);
      if (abort) exit(code);
   }
}

//TODO: Why does this not work
//__constant__ int lut_exp[256];

//a form to describe a sudoku that is suitable for fast access, consists of two
//parts: One part describes the constant structure, i.e. the positions of the
//unknowns and the hints, and is the same for all instances.  The other parts
//contains the values of the unknowns, the current energy, and space for
//bookkeeping.

typedef struct {
	//Constant part, applies to all sudokus:

	//There are three tables that map an idx for each unknown to the entities it
	//belongs, i.e. its row, column and block.
	char* unk_row;
	char* unk_col;
	char* unk_blk;

	//There are three tables that contain the counts for the hints for each
	//symbol for each entity, souch that hnt_*[idx*SUD_SIZE + sym] gives the
	//number of occurences of hints of value sym in entity idx.
	char* hnt_row;
	char* hnt_col;
	char* hnt_blk;

	//Number of unknowns (a single number, for memory purposes pointerized)
	unsigned int n_unk;

	//Variable part: contains information about the individual instances
	//The energy of the current configuration
	unsigned int* energy;

	//prng state
	unsigned int* random;
	//This table maps an idx of a unknown to its value.
	char** unk_val;

	//This is space for accumulating counts.  cnt_*[sym*SUD_SIZE + idx] gives
	//the number of occurences of symbol sym in entity idx
	char** cnt_row;
	char** cnt_col;
	char** cnt_blk;

} sudoku_t;

__device__ __host__ void mc_step(sudoku_t sud, int* lut_exp, unsigned int thread_idx){
	char val,old_val;
	unsigned int energy,rnd;
	int i,delta,idx;

	//generate a new random number
	rnd = sud.random[thread_idx];
	rnd = 1664525*rnd + 1013904223;
	sud.random[thread_idx] = rnd;

	//dissect the random number
	idx = (rnd >> 0) % sud.n_unk;
	val = (rnd >> 8) % SUD_SIZE;
	rnd = (rnd >> 16);

	//save old value, put new value in //TODO: Suboptimal access pattern
	old_val = sud.unk_val[idx][thread_idx];
	sud.unk_val[idx][thread_idx] = val;

	//put the hints into the counters
	for(i=0;i<N_ENTRIES;i++){
		sud.cnt_row[i][thread_idx] = sud.hnt_row[i];
		sud.cnt_col[i][thread_idx] = sud.hnt_col[i];
		sud.cnt_blk[i][thread_idx] = sud.hnt_blk[i];
	}

	//count the unknowns TODO: Suboptimal access pattern.
	for(i=0;i<sud.n_unk;i++){
		sud.cnt_row[sud.unk_row[i]*SUD_SIZE + sud.unk_val[i][thread_idx]][thread_idx]++;
		sud.cnt_col[sud.unk_col[i]*SUD_SIZE + sud.unk_val[i][thread_idx]][thread_idx]++;
		sud.cnt_blk[sud.unk_blk[i]*SUD_SIZE + sud.unk_val[i][thread_idx]][thread_idx]++;
	}

	//calculate the energy
	energy = 0;
	for(i=0;i<N_ENTRIES;i++){
		energy += (sud.cnt_row[i][thread_idx] == 0) ? 1 : sud.cnt_row[i][thread_idx] - 1;
		energy += (sud.cnt_col[i][thread_idx] == 0) ? 1 : sud.cnt_col[i][thread_idx] - 1;
		energy += (sud.cnt_blk[i][thread_idx] == 0) ? 1 : sud.cnt_blk[i][thread_idx] - 1;
	}

	delta = energy - sud.energy[thread_idx];
	delta = delta > 255 ? 255 : delta;

	if(((delta > 0) && (lut_exp[delta > 255 ? 255 : delta] < rnd)) || (energy == 0)){
		//discard step TODO: suboptimal access pattern
		sud.unk_val[idx][thread_idx] = old_val;
	} else {
		sud.energy[thread_idx] = energy;
	}
}


//Memory is laid out such that data for different threads is as close together
//as possible to allow coalesced accesses
void sudoku_alloc_host(sudoku_t* sud, int* lut_exp, unsigned int n_unk){
	int i,j;

	sud->unk_row = (char*) malloc(n_unk*sizeof(char));
	sud->unk_col = (char*) malloc(n_unk*sizeof(char));
	sud->unk_blk = (char*) malloc(n_unk*sizeof(char));

	sud->hnt_row = (char*) malloc(N_ENTRIES*sizeof(char));
	sud->hnt_col = (char*) malloc(N_ENTRIES*sizeof(char));
	sud->hnt_blk = (char*) malloc(N_ENTRIES*sizeof(char));

	sud->n_unk = n_unk;

	sud->energy = (unsigned int*) malloc(N_THREADS*sizeof(unsigned int));
	sud->random = (unsigned int*) malloc(N_THREADS*sizeof(unsigned int));

	sud->unk_val = (char**) malloc(n_unk*sizeof(char*));
	for(i=0;i<n_unk;i++){
		sud->unk_val[i] = (char*) malloc(N_THREADS*sizeof(char));
	}

	sud->cnt_row = (char**) malloc(N_ENTRIES*sizeof(char*));
	sud->cnt_col = (char**) malloc(N_ENTRIES*sizeof(char*));
	sud->cnt_blk = (char**) malloc(N_ENTRIES*sizeof(char*));

	for(i=0;i<N_ENTRIES;i++){
		sud->cnt_row[i] = (char*) malloc(N_THREADS*sizeof(char));
		sud->cnt_col[i] = (char*) malloc(N_THREADS*sizeof(char));
		sud->cnt_blk[i] = (char*) malloc(N_THREADS*sizeof(char));
	}

	//Setup a simple prng (coefficients from Numerical recipies)
	for(i=0;i<N_THREADS;i++){
		sud->random[i] = 1664525*i + 1013904223;
		//run it a few times
		for(j=0;j<5;j++){
			sud->random[i] = 1664525*sud->random[i] + 1013904223;
		}
	}

	//Fill the unknowns
	for(i=0;i<sud->n_unk;i++){
		for(j=0;j<N_THREADS;j++){
			sud->unk_val[i][j] = sud->random[j] % SUD_SIZE;
			sud->random[j] = 1664525*sud->random[j] + 1013904223;
		}
	}
	//Set energy to a really high arbitrary value, this will cause the first step to be accepted
	for(i=0;i<N_THREADS;i++){
		sud->energy[i] = 1<<20;
	}
}

void sudoku_free_host(sudoku_t* sud){
	int i;
	free(sud->unk_row);
	free(sud->unk_col);
	free(sud->unk_blk);

	free(sud->hnt_row);
	free(sud->hnt_col);
	free(sud->hnt_blk);

	free(sud->energy);
	free(sud->random);

	for(i=0; i<sud->n_unk;i++){
		free(sud->unk_val[i]);
	}
	free(sud->unk_val);

	for(i=0;i<N_ENTRIES;i++){
		free(sud->cnt_row[i]);
		free(sud->cnt_col[i]);
		free(sud->cnt_blk[i]);
	}

	free(sud->cnt_row);
	free(sud->cnt_col);
	free(sud->cnt_blk);
}

void sudoku_free_device(sudoku_t* sud){
	int i;
	char **tmp_val, **tmp_row, **tmp_col, **tmp_blk;
	hipFree(sud->unk_row);
	hipFree(sud->unk_col);
	hipFree(sud->unk_blk);

	hipFree(sud->hnt_row);
	hipFree(sud->hnt_col);
	hipFree(sud->hnt_blk);

	hipFree(sud->energy);
	hipFree(sud->random);

	tmp_val = (char**) malloc(sud->n_unk*sizeof(char*));
	hipMemcpy(tmp_val,sud->unk_val,sud->n_unk*sizeof(char*),hipMemcpyDeviceToHost);
	for(i=0; i<sud->n_unk;i++){
		hipFree(tmp_val[i]);
	}
	free(tmp_val);
	hipFree(sud->unk_val);

	tmp_col = (char**) malloc(N_ENTRIES*sizeof(char*));
	tmp_row = (char**) malloc(N_ENTRIES*sizeof(char*));
	tmp_blk = (char**) malloc(N_ENTRIES*sizeof(char*));
	hipMemcpy(tmp_row,sud->cnt_row,N_ENTRIES*sizeof(char*),hipMemcpyDeviceToHost);
	hipMemcpy(tmp_col,sud->cnt_col,N_ENTRIES*sizeof(char*),hipMemcpyDeviceToHost);
	hipMemcpy(tmp_blk,sud->cnt_blk,N_ENTRIES*sizeof(char*),hipMemcpyDeviceToHost);
	for(i=0;i<N_ENTRIES;i++){
		hipFree(tmp_row[i]);
		hipFree(tmp_col[i]);
		hipFree(tmp_blk[i]);
	}
	free(tmp_col);
	free(tmp_row);
	free(tmp_blk);
	hipFree(sud->cnt_row);
	hipFree(sud->cnt_col);
	hipFree(sud->cnt_blk);
}


void sudoku_alloc_and_copy_device(sudoku_t* d_sud, sudoku_t* h_sud){
	int i;
	char **tmp_val, **tmp_row, **tmp_col, **tmp_blk;

	int n_unk = h_sud->n_unk;
	//alloc
	gpuErrchk(hipMalloc(&d_sud->unk_row,n_unk*sizeof(char)));
	gpuErrchk(hipMalloc(&d_sud->unk_col,n_unk*sizeof(char)));
	gpuErrchk(hipMalloc(&d_sud->unk_blk,n_unk*sizeof(char)));

	gpuErrchk(hipMalloc(&d_sud->hnt_row,N_ENTRIES*sizeof(char)));
	gpuErrchk(hipMalloc(&d_sud->hnt_col,N_ENTRIES*sizeof(char)));
	gpuErrchk(hipMalloc(&d_sud->hnt_blk,N_ENTRIES*sizeof(char)));

	gpuErrchk(hipMalloc(&d_sud->energy, N_THREADS*sizeof(unsigned int)));
	gpuErrchk(hipMalloc(&d_sud->random, N_THREADS*sizeof(unsigned int)));

	//Nested array setup is a bit annoying. The result of cudaMalloc can not
	//directly written to device memory, so we have to cache it in tmp and then
	//copy it to the device

	gpuErrchk(hipMalloc(&d_sud->unk_val, n_unk*sizeof(char*)));
	tmp_val = (char**) malloc(n_unk*sizeof(char*));
	for(i=0;i<n_unk;i++){
		gpuErrchk(hipMalloc(&tmp_val[i],N_THREADS*sizeof(char)));
	}
	gpuErrchk(hipMemcpy(d_sud->unk_val,tmp_val,n_unk*sizeof(char*),hipMemcpyHostToDevice));

	gpuErrchk(hipMalloc(&d_sud->cnt_row,N_ENTRIES*sizeof(char*)));
	gpuErrchk(hipMalloc(&d_sud->cnt_col,N_ENTRIES*sizeof(char*)));
	gpuErrchk(hipMalloc(&d_sud->cnt_blk,N_ENTRIES*sizeof(char*)));

	tmp_row = (char**) malloc(N_ENTRIES*sizeof(char*));
	tmp_col = (char**) malloc(N_ENTRIES*sizeof(char*));
	tmp_blk = (char**) malloc(N_ENTRIES*sizeof(char*));

	for(i=0;i<N_ENTRIES;i++){
		gpuErrchk(hipMalloc(&tmp_row[i],N_THREADS*sizeof(char)));
		gpuErrchk(hipMalloc(&tmp_col[i],N_THREADS*sizeof(char)));
		gpuErrchk(hipMalloc(&tmp_blk[i],N_THREADS*sizeof(char)));
	}
	gpuErrchk(hipMemcpy(d_sud->cnt_row,tmp_row, N_ENTRIES*sizeof(char*),hipMemcpyHostToDevice));
	gpuErrchk(hipMemcpy(d_sud->cnt_col,tmp_col, N_ENTRIES*sizeof(char*),hipMemcpyHostToDevice));
	gpuErrchk(hipMemcpy(d_sud->cnt_blk,tmp_blk, N_ENTRIES*sizeof(char*),hipMemcpyHostToDevice));

  //copy
  //constant
	d_sud->n_unk = h_sud->n_unk;
	gpuErrchk(hipMemcpy(d_sud->unk_row,h_sud->unk_row,sizeof(char)*n_unk,hipMemcpyHostToDevice));
	gpuErrchk(hipMemcpy(d_sud->unk_col,h_sud->unk_col,sizeof(char)*n_unk,hipMemcpyHostToDevice));
	gpuErrchk(hipMemcpy(d_sud->unk_blk,h_sud->unk_blk,sizeof(char)*n_unk,hipMemcpyHostToDevice));

	gpuErrchk(hipMemcpy(d_sud->hnt_row,h_sud->hnt_row,sizeof(char)*N_ENTRIES,hipMemcpyHostToDevice));
	gpuErrchk(hipMemcpy(d_sud->hnt_col,h_sud->hnt_col,sizeof(char)*N_ENTRIES,hipMemcpyHostToDevice));
	gpuErrchk(hipMemcpy(d_sud->hnt_blk,h_sud->hnt_blk,sizeof(char)*N_ENTRIES,hipMemcpyHostToDevice));

	//variable
	gpuErrchk(hipMemcpy(d_sud->energy,h_sud->energy,sizeof(unsigned int)*N_THREADS,hipMemcpyHostToDevice));
	gpuErrchk(hipMemcpy(d_sud->random,h_sud->random,sizeof(unsigned int)*N_THREADS,hipMemcpyHostToDevice));

	for(i=0;i<h_sud->n_unk;i++){
		gpuErrchk(hipMemcpy(tmp_val[i],h_sud->unk_val[i],sizeof(char)*N_THREADS,hipMemcpyHostToDevice));
	}

	for(i=0;i<N_ENTRIES;i++){
		gpuErrchk(hipMemcpy(tmp_row[i],h_sud->cnt_row[i],sizeof(char)*N_THREADS,hipMemcpyHostToDevice));
		gpuErrchk(hipMemcpy(tmp_col[i],h_sud->cnt_col[i],sizeof(char)*N_THREADS,hipMemcpyHostToDevice));
		gpuErrchk(hipMemcpy(tmp_blk[i],h_sud->cnt_blk[i],sizeof(char)*N_THREADS,hipMemcpyHostToDevice));
	}

	free(tmp_val);
	free(tmp_row);
	free(tmp_col);
	free(tmp_blk);
}

__global__ void step_gpu(sudoku_t sud, int* lut_exp){
	unsigned int thread_idx = blockIdx.x*blockDim.x + threadIdx.x;
	mc_step(sud, lut_exp, thread_idx);
}

void step_cpu(sudoku_t sud, int* lut_exp){
	unsigned int thread_idx;
	for(thread_idx=0; thread_idx < N_THREADS; thread_idx++){
		mc_step(sud, lut_exp, thread_idx);
	}
}


void add_unk(sudoku_t* sud, int i, int j){
	int blk = (i / BLK_SIZE)*BLK_SIZE + (j / BLK_SIZE);
	sud->unk_row[sud->n_unk] = i;
	sud->unk_col[sud->n_unk] = j;
	sud->unk_blk[sud->n_unk] = blk;
	sud->n_unk++;
}

void add_hin(sudoku_t* sud, int i, int j, int val){
	int blk = (i / BLK_SIZE)*BLK_SIZE + (j / BLK_SIZE);
	sud->hnt_row[val*SUD_SIZE + i]++;
	sud->hnt_col[val*SUD_SIZE + j]++;
	sud->hnt_blk[val*SUD_SIZE + blk]++;
}

void hint1(sudoku_t* sud){
	sud->n_unk = 0;
	int i,j;
	for(i=0;i<SUD_SIZE*SUD_SIZE;i++){
		sud->hnt_row[i] = 0;
		sud->hnt_col[i] = 0;
		sud->hnt_blk[i] = 0;
	}
	int vals[81] = {
		0, 9, 0, 7, 0, 3, 0, 6, 0, 0, 5, 0, 4, 0, 8, 0, 1, 0, 1, 0, 8, 0, 5, 0, 9, 0,
		4, 7, 0, 0, 1, 8, 2, 0, 0, 3, 0, 4, 2, 0, 6, 0, 5, 8, 0, 3, 0, 0, 9, 4, 5, 0,
		0, 2, 8, 0, 6, 0, 7, 0, 1, 0, 9, 0, 2, 0, 8, 0, 1, 0, 5, 0, 0, 1, 0, 6, 0, 9,
		0, 4, 0};
	for(i=0;i<SUD_SIZE;i++){
		for(j=0;j<SUD_SIZE;j++){
			if(vals[SUD_SIZE*i+j] == 0){
				add_unk(sud,i,j);
			} else {
				add_hin(sud,i,j,vals[SUD_SIZE*i+j]-1);
			}
		}
	}
}

void empty(sudoku_t* sud){
	sud->n_unk = 0;
	int i,j;
	for(i=0;i<SUD_SIZE*SUD_SIZE;i++){
		sud->hnt_row[i] = 0;
		sud->hnt_col[i] = 0;
		sud->hnt_blk[i] = 0;
	}
	for(i=0;i<SUD_SIZE;i++){
		for(j=0;j<SUD_SIZE;j++){
			add_unk(sud,i,j);
		}
	}
}

void hint16(sudoku_t* sud){
	sud->n_unk = 0;
	int i,j;
	for(i=0;i<SUD_SIZE*SUD_SIZE;i++){
		sud->hnt_row[i] = 0;
		sud->hnt_col[i] = 0;
		sud->hnt_blk[i] = 0;
	}
	int vals[256] = {
		0, 2, 0, 1, 0, 9, 0, 0, 0, 0, 11, 0, 0, 15, 14, 0, 0, 13, 11, 0, 0, 0, 0, 0, 9, 0, 7, 0, 16, 8, 0, 12, 
		4, 0, 10, 7, 15, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 9, 0, 0, 0, 0, 10, 0, 0, 12, 13, 0, 0, 0, 0, 4, 0, 0, 
		3, 0, 0, 0, 0, 0, 0, 0, 0, 16, 9, 11, 0, 0, 0, 0, 15, 5, 0, 16, 0, 0, 0, 4, 1, 0, 3, 0, 0, 10, 0, 0, 
		1, 0, 9, 12, 13, 15, 0, 0, 0, 6, 10, 0, 4, 0, 0, 0, 0, 11, 0, 0, 2, 6, 0, 0, 0, 0, 0, 0, 13, 0, 9, 8, 
		7, 10, 0, 6, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 8, 0, 0, 0, 0, 11, 0, 13, 7, 0, 0, 0, 6, 10, 1, 12, 0, 4, 
		0, 0, 12, 0, 0, 5, 0, 16, 7, 0, 0, 0, 11, 0, 10, 13, 0, 0, 0, 0, 6, 8, 14, 0, 0, 0, 0, 0, 0, 0, 0, 2, 
		0, 0, 3, 0, 0, 0, 0, 13, 16, 0, 0, 12, 0, 0, 0, 0, 13, 0, 0, 4, 0, 0, 0, 0, 11, 0, 0, 14, 2, 1, 0, 3, 
		9, 0, 2, 5, 0, 3, 0, 15, 0, 0, 0, 0, 0, 14, 7, 0, 0, 7, 1, 0, 0, 14, 0, 0, 0, 0, 5, 0, 8, 0, 16, 0};
	for(i=0;i<SUD_SIZE;i++){
		for(j=0;j<SUD_SIZE;j++){
			if(vals[SUD_SIZE*i+j] == 0){
				add_unk(sud,i,j);
			} else {
				add_hin(sud,i,j,vals[SUD_SIZE*i+j]-1);
			}
		}
	}
}

void energy_stats(int round, unsigned int *energies, unsigned int n_threads){
	int max_energy=0, min_energy=100000, total_energy=0;
	int i;
	for(i=0;i<n_threads;i++){
		max_energy = (energies[i] > max_energy) ? energies[i] : max_energy;
		min_energy = (energies[i] < min_energy) ? energies[i] : min_energy;
		total_energy += energies[i];
	}
	printf("Round: %03d Mean: %3.2f Min: %03d Max: %03d\r",round,float(total_energy)/n_threads, min_energy, max_energy);
	fflush(stdout);
}

int main(){
	int i,j;
	long int n_steps;
	float time;

	int *h_lut_exp, *d_lut_exp;
	h_lut_exp = (int*) malloc(256*sizeof(int));
	gpuErrchk(hipMalloc(&d_lut_exp,256*sizeof(int)));

	unsigned int* energies;

	energies = (unsigned int*) malloc(N_THREADS*sizeof(unsigned int));

	dim3 threads_per_block(THREADS_PER_BLOCK);
	dim3 num_blocks(N_BLOCKS);

	sudoku_t d_sudoku, h_sudoku;

	//set up exp(delta_E/T) lut
	//256 is a safe upper bound for SUD_SIZE 9 and we clamp delta E for
	//SUD_SIZE 16. But anyway, for useful temperatures it is zero very quickly
	//anyway
	float temp = 0.7;
	for(i=0;i<256;i++){
		h_lut_exp[i] = exp(-i/temp)*(1<<16);
	}
	gpuErrchk(hipMemcpy(d_lut_exp,h_lut_exp,256*sizeof(int),hipMemcpyHostToDevice));

	//set up sudoku description
	if(SUD_SIZE==9){
		sudoku_alloc_host(&h_sudoku,h_lut_exp,81);
		empty(&h_sudoku);
	} else {
		sudoku_alloc_host(&h_sudoku, h_lut_exp, 165);
		hint16(&h_sudoku);
	}
	printf("Unknowns: %d\n",h_sudoku.n_unk);
	sudoku_alloc_and_copy_device(&d_sudoku,&h_sudoku);

	n_steps = N_THREADS*N_STEPS;
	//GPU Run
	time = clock();

	for(j=0;j<15000;j++){
		step_gpu<<<num_blocks,threads_per_block>>>(d_sudoku,d_lut_exp);
		gpuErrchk(hipMemcpy(energies,d_sudoku.energy,N_THREADS*sizeof(unsigned int),hipMemcpyDeviceToHost));
		energy_stats(j,energies,N_THREADS);
	}
	time = (clock() - time)/CLOCKS_PER_SEC;
	printf("\nGPU: Steps: %ld, Time: %f s, %.1f Steps/s\n",n_steps,time,n_steps/time);

	//CPU Run
	time = clock();

	for(j=0;j<N_STEPS;j++){
		step_cpu(h_sudoku,h_lut_exp);
		gpuErrchk(hipMemcpy(energies,h_sudoku.energy,N_THREADS*sizeof(unsigned int),hipMemcpyHostToHost));
		energy_stats(j,energies,N_THREADS);
	}
	time = (clock() - time)/CLOCKS_PER_SEC;
	printf("\nCPU: Steps: %ld, Time: %f s, %.1f Steps/s\n",n_steps,time,n_steps/time);

	sudoku_free_host(&h_sudoku);
	sudoku_free_device(&d_sudoku);
	free(energies);
	hipFree(d_lut_exp);
}

	.text
	.file	"mcsudoku.hip"
	.globl	_Z7mc_step8sudoku_tPij          # -- Begin function _Z7mc_step8sudoku_tPij
	.type	_Z7mc_step8sudoku_tPij,@function
_Z7mc_step8sudoku_tPij:                 # @_Z7mc_step8sudoku_tPij
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, -8(%rsp)                  # 8-byte Spill
	leaq	56(%rsp), %r8
	movq	64(%r8), %rax
	movl	%esi, %esi
	imull	$1664525, (%rax,%rsi,4), %ecx   # imm = 0x19660D
	addl	$1013904223, %ecx               # imm = 0x3C6EF35F
	movl	%ecx, (%rax,%rsi,4)
	movl	48(%r8), %r14d
	xorl	%r15d, %r15d
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%r14d
	movl	%ecx, %r10d
	shrl	$8, %r10d
	imulq	$477218589, %r10, %rax          # imm = 0x1C71C71D
	shrq	$32, %rax
	leal	(%rax,%rax,8), %eax
	subl	%eax, %r10d
	movq	72(%r8), %rax
	movslq	%edx, %rdi
	movq	(%rax,%rdi,8), %r11
	movb	(%r11,%rsi), %dl
	movb	%dl, -9(%rsp)                   # 1-byte Spill
	movb	%r10b, (%r11,%rsi)
	movq	24(%r8), %r12
	movq	32(%r8), %r13
	movq	80(%r8), %r10
	movq	88(%r8), %r11
	movq	40(%r8), %rbp
	movq	96(%r8), %rbx
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	movb	(%r12,%r15), %r9b
	movq	(%r10,%r15,8), %rdx
	movb	%r9b, (%rdx,%rsi)
	movb	(%r13,%r15), %dl
	movq	(%r11,%r15,8), %r9
	movb	%dl, (%r9,%rsi)
	movb	(%rbp,%r15), %dl
	movq	(%rbx,%r15,8), %r9
	movb	%dl, (%r9,%rsi)
	incq	%r15
	cmpq	$81, %r15
	jne	.LBB0_1
# %bb.2:                                # %.preheader75
	movq	(%r8), %r15
	movq	8(%r8), %r12
	movq	16(%r8), %r13
	cmpl	$1, %r14d
	adcl	$0, %r14d
	xorl	%ebp, %ebp
.LBB0_3:                                # =>This Inner Loop Header: Depth=1
	movsbq	(%r15,%rbp), %rdx
	movq	(%rax,%rbp,8), %r9
	movsbq	(%r9,%rsi), %r9
	leaq	(%rdx,%rdx,8), %rdx
	leaq	(%r10,%rdx,8), %rdx
	movq	(%rdx,%r9,8), %rdx
	incb	(%rdx,%rsi)
	movsbq	(%r12,%rbp), %rdx
	movq	(%rax,%rbp,8), %r9
	movsbq	(%r9,%rsi), %r9
	leaq	(%rdx,%rdx,8), %rdx
	leaq	(%r11,%rdx,8), %rdx
	movq	(%rdx,%r9,8), %rdx
	incb	(%rdx,%rsi)
	movsbq	(%r13,%rbp), %rdx
	movq	(%rax,%rbp,8), %r9
	movsbq	(%r9,%rsi), %r9
	leaq	(%rdx,%rdx,8), %rdx
	leaq	(%rbx,%rdx,8), %rdx
	movq	(%rdx,%r9,8), %rdx
	incb	(%rdx,%rsi)
	incq	%rbp
	cmpq	%rbp, %r14
	jne	.LBB0_3
# %bb.4:                                # %.preheader.preheader
	xorl	%r14d, %r14d
	movl	$1, %r15d
	xorl	%ebp, %ebp
.LBB0_5:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r10,%r14,8), %rdx
	movsbl	(%rdx,%rsi), %edx
	leal	-1(%rdx), %r9d
	testl	%edx, %edx
	cmovel	%r15d, %r9d
	addl	%ebp, %r9d
	movq	(%r11,%r14,8), %rdx
	movsbl	(%rdx,%rsi), %edx
	leal	-1(%rdx), %r12d
	testl	%edx, %edx
	cmovel	%r15d, %r12d
	movq	(%rbx,%r14,8), %rdx
	movsbl	(%rdx,%rsi), %edx
	leal	-1(%rdx), %ebp
	testl	%edx, %edx
	cmovel	%r15d, %ebp
	addl	%r12d, %ebp
	addl	%r9d, %ebp
	incq	%r14
	cmpq	$81, %r14
	jne	.LBB0_5
# %bb.6:
	movq	56(%r8), %r8
	movl	%ebp, %r10d
	subl	(%r8,%rsi,4), %r10d
	testl	%r10d, %r10d
	jle	.LBB0_8
# %bb.7:
	shrl	$16, %ecx
	movl	$255, %edx
	cmpl	%edx, %r10d
	cmovll	%r10d, %edx
	movq	-8(%rsp), %r9                   # 8-byte Reload
	cmpl	%ecx, (%r9,%rdx,4)
	jb	.LBB0_9
.LBB0_8:
	testl	%ebp, %ebp
	je	.LBB0_9
# %bb.10:
	movl	%ebp, (%r8,%rsi,4)
	jmp	.LBB0_11
.LBB0_9:
	movq	(%rax,%rdi,8), %rax
	movb	-9(%rsp), %cl                   # 1-byte Reload
	movb	%cl, (%rax,%rsi)
.LBB0_11:
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z7mc_step8sudoku_tPij, .Lfunc_end0-_Z7mc_step8sudoku_tPij
	.cfi_endproc
                                        # -- End function
	.globl	_Z17sudoku_alloc_hostP8sudoku_tPij # -- Begin function _Z17sudoku_alloc_hostP8sudoku_tPij
	.type	_Z17sudoku_alloc_hostP8sudoku_tPij,@function
_Z17sudoku_alloc_hostP8sudoku_tPij:     # @_Z17sudoku_alloc_hostP8sudoku_tPij
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movq	%rdi, %rbx
	movl	%edx, %r14d
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, (%rbx)
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 8(%rbx)
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 16(%rbx)
	movl	$81, %edi
	callq	malloc
	movq	%rax, 24(%rbx)
	movl	$81, %edi
	callq	malloc
	movq	%rax, 32(%rbx)
	movl	$81, %edi
	callq	malloc
	movq	%rax, 40(%rbx)
	movl	%ebp, 48(%rbx)
	movl	$262144, %edi                   # imm = 0x40000
	callq	malloc
	movq	%rax, 56(%rbx)
	movl	$262144, %edi                   # imm = 0x40000
	callq	malloc
	movq	%rax, 64(%rbx)
	leaq	(,%r14,8), %rdi
	callq	malloc
	movq	%rax, 72(%rbx)
	testl	%ebp, %ebp
	je	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%r15d, %r15d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	72(%rbx), %rcx
	movq	%rax, (%rcx,%r15,8)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, 80(%rbx)
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, 88(%rbx)
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, 96(%rbx)
	xorl	%r14d, %r14d
.LBB1_4:                                # =>This Inner Loop Header: Depth=1
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	80(%rbx), %rcx
	movq	%rax, (%rcx,%r14,8)
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	88(%rbx), %rcx
	movq	%rax, (%rcx,%r14,8)
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	96(%rbx), %rcx
	movq	%rax, (%rcx,%r14,8)
	incq	%r14
	cmpq	$81, %r14
	jne	.LBB1_4
# %bb.5:                                # %.preheader63
	movq	64(%rbx), %rax
	xorl	%ecx, %ecx
.LBB1_6:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_7 Depth 2
	imull	$1664525, %ecx, %edx            # imm = 0x19660D
	addl	$1013904223, %edx               # imm = 0x3C6EF35F
	movl	$5, %esi
.LBB1_7:                                #   Parent Loop BB1_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	imull	$1664525, %edx, %edx            # imm = 0x19660D
	addl	$1013904223, %edx               # imm = 0x3C6EF35F
	decl	%esi
	jne	.LBB1_7
# %bb.8:                                #   in Loop: Header=BB1_6 Depth=1
	movl	%edx, (%rax,%rcx,4)
	incq	%rcx
	cmpq	$65536, %rcx                    # imm = 0x10000
	jne	.LBB1_6
# %bb.9:                                # %.preheader62
	cmpl	$0, 48(%rbx)
	je	.LBB1_14
# %bb.10:                               # %.preheader61.preheader
	xorl	%ecx, %ecx
.LBB1_11:                               # %.preheader61
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_12 Depth 2
	xorl	%edx, %edx
.LBB1_12:                               #   Parent Loop BB1_11 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rax,%rdx,4), %eax
	imulq	$954437177, %rax, %rsi          # imm = 0x38E38E39
	shrq	$33, %rsi
	leal	(%rsi,%rsi,8), %esi
	subl	%esi, %eax
	movq	72(%rbx), %rsi
	movq	(%rsi,%rcx,8), %rsi
	movb	%al, (%rsi,%rdx)
	movq	64(%rbx), %rax
	imull	$1664525, (%rax,%rdx,4), %esi   # imm = 0x19660D
	addl	$1013904223, %esi               # imm = 0x3C6EF35F
	movl	%esi, (%rax,%rdx,4)
	incq	%rdx
	cmpq	$65536, %rdx                    # imm = 0x10000
	jne	.LBB1_12
# %bb.13:                               #   in Loop: Header=BB1_11 Depth=1
	incq	%rcx
	movl	48(%rbx), %edx
	cmpq	%rdx, %rcx
	jb	.LBB1_11
.LBB1_14:                               # %.preheader
	movq	56(%rbx), %rax
	xorl	%ecx, %ecx
.LBB1_15:                               # =>This Inner Loop Header: Depth=1
	movl	$1048576, (%rax,%rcx,4)         # imm = 0x100000
	incq	%rcx
	cmpq	$65536, %rcx                    # imm = 0x10000
	jne	.LBB1_15
# %bb.16:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z17sudoku_alloc_hostP8sudoku_tPij, .Lfunc_end1-_Z17sudoku_alloc_hostP8sudoku_tPij
	.cfi_endproc
                                        # -- End function
	.globl	_Z16sudoku_free_hostP8sudoku_t  # -- Begin function _Z16sudoku_free_hostP8sudoku_t
	.type	_Z16sudoku_free_hostP8sudoku_t,@function
_Z16sudoku_free_hostP8sudoku_t:         # @_Z16sudoku_free_hostP8sudoku_t
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	callq	free
	movq	8(%rbx), %rdi
	callq	free
	movq	16(%rbx), %rdi
	callq	free
	movq	24(%rbx), %rdi
	callq	free
	movq	32(%rbx), %rdi
	callq	free
	movq	40(%rbx), %rdi
	callq	free
	movq	56(%rbx), %rdi
	callq	free
	movq	64(%rbx), %rdi
	callq	free
	cmpl	$0, 48(%rbx)
	je	.LBB2_3
# %bb.1:                                # %.lr.ph
	xorl	%r14d, %r14d
.LBB2_2:                                # =>This Inner Loop Header: Depth=1
	movq	72(%rbx), %rax
	movq	(%rax,%r14,8), %rdi
	callq	free
	incq	%r14
	movl	48(%rbx), %eax
	cmpq	%rax, %r14
	jb	.LBB2_2
.LBB2_3:                                # %._crit_edge
	movq	72(%rbx), %rdi
	callq	free
	xorl	%r14d, %r14d
.LBB2_4:                                # =>This Inner Loop Header: Depth=1
	movq	80(%rbx), %rax
	movq	(%rax,%r14,8), %rdi
	callq	free
	movq	88(%rbx), %rax
	movq	(%rax,%r14,8), %rdi
	callq	free
	movq	96(%rbx), %rax
	movq	(%rax,%r14,8), %rdi
	callq	free
	incq	%r14
	cmpq	$81, %r14
	jne	.LBB2_4
# %bb.5:
	movq	80(%rbx), %rdi
	callq	free
	movq	88(%rbx), %rdi
	callq	free
	movq	96(%rbx), %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end2:
	.size	_Z16sudoku_free_hostP8sudoku_t, .Lfunc_end2-_Z16sudoku_free_hostP8sudoku_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z18sudoku_free_deviceP8sudoku_t # -- Begin function _Z18sudoku_free_deviceP8sudoku_t
	.type	_Z18sudoku_free_deviceP8sudoku_t,@function
_Z18sudoku_free_deviceP8sudoku_t:       # @_Z18sudoku_free_deviceP8sudoku_t
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	callq	hipFree
	movq	8(%rbx), %rdi
	callq	hipFree
	movq	16(%rbx), %rdi
	callq	hipFree
	movq	24(%rbx), %rdi
	callq	hipFree
	movq	32(%rbx), %rdi
	callq	hipFree
	movq	40(%rbx), %rdi
	callq	hipFree
	movq	56(%rbx), %rdi
	callq	hipFree
	movq	64(%rbx), %rdi
	callq	hipFree
	movl	48(%rbx), %r15d
	shlq	$3, %r15
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	72(%rbx), %rsi
	movq	%rax, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$0, 48(%rbx)
	je	.LBB3_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%r15d, %r15d
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r14,%r15,8), %rdi
	callq	hipFree
	incq	%r15
	movl	48(%rbx), %eax
	cmpq	%rax, %r15
	jb	.LBB3_2
.LBB3_3:                                # %._crit_edge
	movq	%r14, %rdi
	callq	free
	movq	72(%rbx), %rdi
	callq	hipFree
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, %r14
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, %r15
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, %r12
	movq	80(%rbx), %rsi
	movl	$648, %edx                      # imm = 0x288
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	88(%rbx), %rsi
	movl	$648, %edx                      # imm = 0x288
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	96(%rbx), %rsi
	movl	$648, %edx                      # imm = 0x288
	movq	%r12, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	xorl	%r13d, %r13d
.LBB3_4:                                # =>This Inner Loop Header: Depth=1
	movq	(%r15,%r13,8), %rdi
	callq	hipFree
	movq	(%r14,%r13,8), %rdi
	callq	hipFree
	movq	(%r12,%r13,8), %rdi
	callq	hipFree
	incq	%r13
	cmpq	$81, %r13
	jne	.LBB3_4
# %bb.5:
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	80(%rbx), %rdi
	callq	hipFree
	movq	88(%rbx), %rdi
	callq	hipFree
	movq	96(%rbx), %rdi
	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	hipFree                         # TAILCALL
.Lfunc_end3:
	.size	_Z18sudoku_free_deviceP8sudoku_t, .Lfunc_end3-_Z18sudoku_free_deviceP8sudoku_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_ # -- Begin function _Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_
	.type	_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_,@function
_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_: # @_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movq	%rdi, %r13
	movslq	48(%rsi), %r14
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_1
# %bb.3:                                # %_Z9gpuAssert10hipError_tPcib.exit
	leaq	8(%r13), %r15
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_4
# %bb.5:                                # %_Z9gpuAssert10hipError_tPcib.exit86
	leaq	16(%r13), %r12
	movq	%r12, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_6
# %bb.7:                                # %_Z9gpuAssert10hipError_tPcib.exit88
	movq	%r15, 96(%rsp)                  # 8-byte Spill
	leaq	24(%r13), %r15
	movl	$81, %esi
	movq	%r15, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_8
# %bb.9:                                # %_Z9gpuAssert10hipError_tPcib.exit90
	movq	%r12, 88(%rsp)                  # 8-byte Spill
	leaq	32(%r13), %rbp
	movl	$81, %esi
	movq	%rbp, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_76
# %bb.10:                               # %_Z9gpuAssert10hipError_tPcib.exit92
	movq	%r15, 80(%rsp)                  # 8-byte Spill
	leaq	40(%r13), %r12
	movl	$81, %esi
	movq	%r12, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_11
# %bb.13:                               # %_Z9gpuAssert10hipError_tPcib.exit94
	leaq	56(%r13), %r15
	movl	$262144, %esi                   # imm = 0x40000
	movq	%r15, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_14
# %bb.15:                               # %_Z9gpuAssert10hipError_tPcib.exit96
	movq	%rbp, 72(%rsp)                  # 8-byte Spill
	movq	%r12, 64(%rsp)                  # 8-byte Spill
	movq	%r15, 56(%rsp)                  # 8-byte Spill
	leaq	64(%r13), %r15
	movl	$262144, %esi                   # imm = 0x40000
	movq	%r15, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_16
# %bb.17:                               # %_Z9gpuAssert10hipError_tPcib.exit98
	movq	%r15, 48(%rsp)                  # 8-byte Spill
	movq	%r13, 16(%rsp)                  # 8-byte Spill
	addq	$72, %r13
	leaq	(,%r14,8), %r12
	movq	%r13, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_18
# %bb.19:                               # %_Z9gpuAssert10hipError_tPcib.exit100
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, (%rsp)                    # 8-byte Spill
	movq	%r14, 8(%rsp)                   # 8-byte Spill
	testl	%r14d, %r14d
	jle	.LBB4_24
# %bb.20:                               # %_Z9gpuAssert10hipError_tPcib.exit102.preheader
	movl	8(%rsp), %r14d                  # 4-byte Reload
	movq	(%rsp), %r15                    # 8-byte Reload
.LBB4_22:                               # %_Z9gpuAssert10hipError_tPcib.exit102
                                        # =>This Inner Loop Header: Depth=1
	movl	$65536, %esi                    # imm = 0x10000
	movq	%r15, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_23
# %bb.21:                               #   in Loop: Header=BB4_22 Depth=1
	addq	$8, %r15
	decq	%r14
	jne	.LBB4_22
.LBB4_24:                               # %._crit_edge
	movq	(%r13), %rdi
	movq	(%rsp), %rsi                    # 8-byte Reload
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_25
# %bb.26:                               # %_Z9gpuAssert10hipError_tPcib.exit104
	movq	16(%rsp), %r14                  # 8-byte Reload
	leaq	80(%r14), %r12
	movl	$648, %esi                      # imm = 0x288
	movq	%r12, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_27
# %bb.28:                               # %_Z9gpuAssert10hipError_tPcib.exit106
	leaq	88(%r14), %r15
	movl	$648, %esi                      # imm = 0x288
	movq	%r15, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_29
# %bb.30:                               # %_Z9gpuAssert10hipError_tPcib.exit108
	movq	%r12, 40(%rsp)                  # 8-byte Spill
	addq	$96, %r14
	movl	$648, %esi                      # imm = 0x288
	movq	%r14, %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_31
# %bb.32:                               # %_Z9gpuAssert10hipError_tPcib.exit110
	movq	%r15, 32(%rsp)                  # 8-byte Spill
	movq	%r14, 24(%rsp)                  # 8-byte Spill
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, %r12
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, %r13
	movl	$648, %edi                      # imm = 0x288
	callq	malloc
	movq	%rax, %rbp
	xorl	%r14d, %r14d
.LBB4_34:                               # =>This Inner Loop Header: Depth=1
	leaq	(%r12,%r14), %rdi
	movl	$65536, %esi                    # imm = 0x10000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_35
# %bb.36:                               # %_Z9gpuAssert10hipError_tPcib.exit112
                                        #   in Loop: Header=BB4_34 Depth=1
	leaq	(%r14,%r13), %rdi
	movl	$65536, %esi                    # imm = 0x10000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_37
# %bb.38:                               # %_Z9gpuAssert10hipError_tPcib.exit114
                                        #   in Loop: Header=BB4_34 Depth=1
	leaq	(%r14,%rbp), %rdi
	movl	$65536, %esi                    # imm = 0x10000
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB4_39
# %bb.33:                               #   in Loop: Header=BB4_34 Depth=1
	addq	$8, %r14
	cmpq	$648, %r14                      # imm = 0x288
	jne	.LBB4_34
# %bb.40:
	movq	40(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movl	$648, %edx                      # imm = 0x288
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_41
# %bb.42:                               # %_Z9gpuAssert10hipError_tPcib.exit118
	movq	32(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movl	$648, %edx                      # imm = 0x288
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	movq	8(%rsp), %r14                   # 8-byte Reload
	jne	.LBB4_43
# %bb.44:                               # %_Z9gpuAssert10hipError_tPcib.exit120
	movq	24(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movl	$648, %edx                      # imm = 0x288
	movq	%rbp, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_45
# %bb.46:                               # %_Z9gpuAssert10hipError_tPcib.exit122
	movl	48(%rbx), %eax
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movl	%eax, 48(%rcx)
	movq	(%rcx), %rdi
	movq	(%rbx), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_47
# %bb.48:                               # %_Z9gpuAssert10hipError_tPcib.exit124
	movq	96(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movq	8(%rbx), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_49
# %bb.50:                               # %_Z9gpuAssert10hipError_tPcib.exit126
	movq	88(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movq	16(%rbx), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_51
# %bb.52:                               # %_Z9gpuAssert10hipError_tPcib.exit128
	movq	80(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movq	24(%rbx), %rsi
	movl	$81, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_53
# %bb.54:                               # %_Z9gpuAssert10hipError_tPcib.exit130
	movq	72(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movq	32(%rbx), %rsi
	movl	$81, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_55
# %bb.56:                               # %_Z9gpuAssert10hipError_tPcib.exit132
	movq	64(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movq	40(%rbx), %rsi
	movl	$81, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_57
# %bb.58:                               # %_Z9gpuAssert10hipError_tPcib.exit134
	movq	56(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movq	56(%rbx), %rsi
	movl	$262144, %edx                   # imm = 0x40000
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_59
# %bb.60:                               # %_Z9gpuAssert10hipError_tPcib.exit136
	movq	48(%rsp), %rax                  # 8-byte Reload
	movq	(%rax), %rdi
	movq	64(%rbx), %rsi
	movl	$262144, %edx                   # imm = 0x40000
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_65
# %bb.61:                               # %_Z9gpuAssert10hipError_tPcib.exit138.preheader
	cmpl	$0, 48(%rbx)
	je	.LBB4_67
# %bb.62:                               # %_Z9gpuAssert10hipError_tPcib.exit140.lr.ph
	xorl	%r14d, %r14d
.LBB4_63:                               # %_Z9gpuAssert10hipError_tPcib.exit140
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rsp), %rax                    # 8-byte Reload
	movq	(%rax,%r14,8), %rdi
	movq	72(%rbx), %rax
	movq	(%rax,%r14,8), %rsi
	movl	$65536, %edx                    # imm = 0x10000
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_64
# %bb.66:                               # %_Z9gpuAssert10hipError_tPcib.exit138
                                        #   in Loop: Header=BB4_63 Depth=1
	incq	%r14
	movl	48(%rbx), %eax
	cmpq	%rax, %r14
	jb	.LBB4_63
.LBB4_67:                               # %.preheader
	xorl	%r14d, %r14d
.LBB4_69:                               # =>This Inner Loop Header: Depth=1
	movq	(%r12,%r14,8), %rdi
	movq	80(%rbx), %rax
	movq	(%rax,%r14,8), %rsi
	movl	$65536, %edx                    # imm = 0x10000
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_70
# %bb.71:                               # %_Z9gpuAssert10hipError_tPcib.exit142
                                        #   in Loop: Header=BB4_69 Depth=1
	movq	(%r13,%r14,8), %rdi
	movq	88(%rbx), %rax
	movq	(%rax,%r14,8), %rsi
	movl	$65536, %edx                    # imm = 0x10000
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_72
# %bb.73:                               # %_Z9gpuAssert10hipError_tPcib.exit144
                                        #   in Loop: Header=BB4_69 Depth=1
	movq	(%rbp,%r14,8), %rdi
	movq	96(%rbx), %rax
	movq	(%rax,%r14,8), %rsi
	movl	$65536, %edx                    # imm = 0x10000
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB4_74
# %bb.68:                               #   in Loop: Header=BB4_69 Depth=1
	incq	%r14
	cmpq	$81, %r14
	jne	.LBB4_69
# %bb.75:
	movq	(%rsp), %rdi                    # 8-byte Reload
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	%rbp, %rdi
	addq	$104, %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
	jmp	free                            # TAILCALL
.LBB4_39:
	.cfi_def_cfa_offset 160
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$316, %r8d                      # imm = 0x13C
	jmp	.LBB4_12
.LBB4_37:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$315, %r8d                      # imm = 0x13B
	jmp	.LBB4_12
.LBB4_35:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$314, %r8d                      # imm = 0x13A
	jmp	.LBB4_12
.LBB4_74:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$344, %r8d                      # imm = 0x158
	jmp	.LBB4_12
.LBB4_72:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$343, %r8d                      # imm = 0x157
	jmp	.LBB4_12
.LBB4_70:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$342, %r8d                      # imm = 0x156
	jmp	.LBB4_12
.LBB4_23:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$301, %r8d                      # imm = 0x12D
.LBB4_2:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, %edi
	callq	exit
.LBB4_64:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$338, %r8d                      # imm = 0x152
.LBB4_12:
	xorl	%eax, %eax
	callq	fprintf
	movl	%r15d, %edi
	callq	exit
.LBB4_1:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$283, %r8d                      # imm = 0x11B
	jmp	.LBB4_2
.LBB4_4:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$284, %r8d                      # imm = 0x11C
	jmp	.LBB4_2
.LBB4_6:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$285, %r8d                      # imm = 0x11D
	jmp	.LBB4_2
.LBB4_8:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$287, %r8d                      # imm = 0x11F
	jmp	.LBB4_2
.LBB4_76:
	movl	%eax, %r12d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$288, %r8d                      # imm = 0x120
	xorl	%eax, %eax
	callq	fprintf
	movl	%r12d, %edi
	callq	exit
.LBB4_11:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$289, %r8d                      # imm = 0x121
	jmp	.LBB4_12
.LBB4_14:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	movl	%eax, %ebp
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$291, %r8d                      # imm = 0x123
	jmp	.LBB4_2
.LBB4_16:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$292, %r8d                      # imm = 0x124
	jmp	.LBB4_2
.LBB4_18:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$298, %r8d                      # imm = 0x12A
	jmp	.LBB4_2
.LBB4_25:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$303, %r8d                      # imm = 0x12F
	jmp	.LBB4_2
.LBB4_27:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$305, %r8d                      # imm = 0x131
	jmp	.LBB4_2
.LBB4_29:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$306, %r8d                      # imm = 0x132
	jmp	.LBB4_2
.LBB4_31:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$307, %r8d                      # imm = 0x133
	jmp	.LBB4_2
.LBB4_41:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$318, %r8d                      # imm = 0x13E
	jmp	.LBB4_12
.LBB4_43:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$319, %r8d                      # imm = 0x13F
	jmp	.LBB4_12
.LBB4_45:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$320, %r8d                      # imm = 0x140
	jmp	.LBB4_12
.LBB4_47:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$325, %r8d                      # imm = 0x145
	jmp	.LBB4_12
.LBB4_49:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$326, %r8d                      # imm = 0x146
	jmp	.LBB4_12
.LBB4_51:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$327, %r8d                      # imm = 0x147
	jmp	.LBB4_12
.LBB4_53:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$329, %r8d                      # imm = 0x149
	jmp	.LBB4_12
.LBB4_55:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$330, %r8d                      # imm = 0x14A
	jmp	.LBB4_12
.LBB4_57:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$331, %r8d                      # imm = 0x14B
	jmp	.LBB4_12
.LBB4_59:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$334, %r8d                      # imm = 0x14E
	jmp	.LBB4_12
.LBB4_65:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$335, %r8d                      # imm = 0x14F
	jmp	.LBB4_12
.Lfunc_end4:
	.size	_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_, .Lfunc_end4-_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__step_gpu8sudoku_tPi # -- Begin function _Z23__device_stub__step_gpu8sudoku_tPi
	.type	_Z23__device_stub__step_gpu8sudoku_tPi,@function
_Z23__device_stub__step_gpu8sudoku_tPi: # @_Z23__device_stub__step_gpu8sudoku_tPi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	128(%rsp), %rcx
	leaq	64(%rsp), %rbx
	movq	%rcx, (%rbx)
	movq	%rax, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8step_gpu8sudoku_tPi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z23__device_stub__step_gpu8sudoku_tPi, .Lfunc_end5-_Z23__device_stub__step_gpu8sudoku_tPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z8step_cpu8sudoku_tPi          # -- Begin function _Z8step_cpu8sudoku_tPi
	.type	_Z8step_cpu8sudoku_tPi,@function
_Z8step_cpu8sudoku_tPi:                 # @_Z8step_cpu8sudoku_tPi
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$112, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movq	%rdi, %rbx
	xorl	%ebp, %ebp
	leaq	144(%rsp), %r14
.LBB6_1:                                # =>This Inner Loop Header: Depth=1
	movl	$13, %ecx
	movq	%rsp, %rdi
	movq	%r14, %rsi
	rep;movsq (%rsi), %es:(%rdi)
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	_Z7mc_step8sudoku_tPij
	incl	%ebp
	cmpl	$65536, %ebp                    # imm = 0x10000
	jne	.LBB6_1
# %bb.2:
	addq	$112, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z8step_cpu8sudoku_tPi, .Lfunc_end6-_Z8step_cpu8sudoku_tPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z7add_unkP8sudoku_tii          # -- Begin function _Z7add_unkP8sudoku_tii
	.type	_Z7add_unkP8sudoku_tii,@function
_Z7add_unkP8sudoku_tii:                 # @_Z7add_unkP8sudoku_tii
	.cfi_startproc
# %bb.0:
	movslq	%esi, %rax
	imulq	$1431655766, %rax, %rcx         # imm = 0x55555556
	movq	%rcx, %rsi
	shrq	$63, %rsi
	shrq	$32, %rcx
	addl	%esi, %ecx
	leal	(%rcx,%rcx,2), %ecx
	movslq	%edx, %rdx
	imulq	$1431655766, %rdx, %rsi         # imm = 0x55555556
	movq	%rsi, %r8
	shrq	$63, %r8
	shrq	$32, %rsi
	addl	%r8d, %esi
	addl	%ecx, %esi
	movq	(%rdi), %rcx
	movl	48(%rdi), %r8d
	movb	%al, (%rcx,%r8)
	movq	8(%rdi), %rax
	movl	48(%rdi), %ecx
	movb	%dl, (%rax,%rcx)
	movq	16(%rdi), %rax
	movl	48(%rdi), %ecx
	movb	%sil, (%rax,%rcx)
	incl	48(%rdi)
	retq
.Lfunc_end7:
	.size	_Z7add_unkP8sudoku_tii, .Lfunc_end7-_Z7add_unkP8sudoku_tii
	.cfi_endproc
                                        # -- End function
	.globl	_Z7add_hinP8sudoku_tiii         # -- Begin function _Z7add_hinP8sudoku_tiii
	.type	_Z7add_hinP8sudoku_tiii,@function
_Z7add_hinP8sudoku_tiii:                # @_Z7add_hinP8sudoku_tiii
	.cfi_startproc
# %bb.0:
                                        # kill: def $ecx killed $ecx def $rcx
	movslq	%esi, %rsi
	imulq	$1431655766, %rsi, %rax         # imm = 0x55555556
	movq	%rax, %r8
	shrq	$63, %r8
	shrq	$32, %rax
	addl	%r8d, %eax
	leal	(%rax,%rax,2), %eax
	movslq	%edx, %r8
	imulq	$1431655766, %r8, %rdx          # imm = 0x55555556
	movq	24(%rdi), %r9
	leal	(%rcx,%rcx,8), %ecx
	addl	%ecx, %esi
	movslq	%esi, %rsi
	incb	(%r9,%rsi)
	movq	%rdx, %rsi
	shrq	$63, %rsi
	shrq	$32, %rdx
	movq	32(%rdi), %r9
	addl	%ecx, %r8d
	movslq	%r8d, %r8
	incb	(%r9,%r8)
	addl	%esi, %edx
	movq	40(%rdi), %rsi
	addl	%ecx, %edx
	addl	%eax, %edx
	movslq	%edx, %rax
	incb	(%rsi,%rax)
	retq
.Lfunc_end8:
	.size	_Z7add_hinP8sudoku_tiii, .Lfunc_end8-_Z7add_hinP8sudoku_tiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z5hint1P8sudoku_t              # -- Begin function _Z5hint1P8sudoku_t
	.type	_Z5hint1P8sudoku_t,@function
_Z5hint1P8sudoku_t:                     # @_Z5hint1P8sudoku_t
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	$0, 48(%rdi)
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB9_1:                                # =>This Inner Loop Header: Depth=1
	movq	24(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	movq	32(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	movq	40(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	incq	%rcx
	cmpq	$81, %rcx
	jne	.LBB9_1
# %bb.2:                                # %.preheader26
	movl	$.L__const._Z5hint1P8sudoku_t.vals, %eax
	xorl	%ecx, %ecx
	movl	$2863311531, %edx               # imm = 0xAAAAAAAB
.LBB9_3:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_4 Depth 2
	movl	%ecx, %esi
	imulq	%rdx, %rsi
	shrq	$33, %rsi
	leal	(%rsi,%rsi,2), %esi
	xorl	%r8d, %r8d
.LBB9_4:                                #   Parent Loop BB9_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rax,%r8,4), %r9d
	testl	%r9d, %r9d
	je	.LBB9_5
# %bb.6:                                #   in Loop: Header=BB9_4 Depth=2
	movq	24(%rdi), %r10
	leal	(%r9,%r9,8), %r11d
	leal	(%rcx,%r11), %ebx
	addl	$-9, %ebx
	movslq	%ebx, %rbx
	incb	(%r10,%rbx)
	movzbl	%r8b, %r10d
	imull	$171, %r10d, %r10d
	shrl	$9, %r10d
	addl	%esi, %r10d
	leal	(%r9,%r9,8), %r9d
	addl	$-9, %r9d
	addl	%r10d, %r9d
	movq	32(%rdi), %r10
	addl	%r8d, %r11d
	addl	$-9, %r11d
	movslq	%r11d, %r11
	incb	(%r10,%r11)
	movq	40(%rdi), %r10
	movslq	%r9d, %r9
	incb	(%r10,%r9)
	jmp	.LBB9_7
.LBB9_5:                                #   in Loop: Header=BB9_4 Depth=2
	movzbl	%r8b, %r9d
	imull	$171, %r9d, %r9d
	shrl	$9, %r9d
	movq	(%rdi), %r10
	movl	48(%rdi), %r11d
	movb	%cl, (%r10,%r11)
	movq	8(%rdi), %r10
	movl	48(%rdi), %r11d
	movb	%r8b, (%r10,%r11)
	addb	%sil, %r9b
	movq	16(%rdi), %r10
	movl	48(%rdi), %r11d
	movb	%r9b, (%r10,%r11)
	incl	48(%rdi)
.LBB9_7:                                #   in Loop: Header=BB9_4 Depth=2
	incq	%r8
	cmpq	$9, %r8
	jne	.LBB9_4
# %bb.8:                                #   in Loop: Header=BB9_3 Depth=1
	incq	%rcx
	addq	$36, %rax
	cmpq	$9, %rcx
	jne	.LBB9_3
# %bb.9:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	_Z5hint1P8sudoku_t, .Lfunc_end9-_Z5hint1P8sudoku_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z5emptyP8sudoku_t              # -- Begin function _Z5emptyP8sudoku_t
	.type	_Z5emptyP8sudoku_t,@function
_Z5emptyP8sudoku_t:                     # @_Z5emptyP8sudoku_t
	.cfi_startproc
# %bb.0:
	movl	$0, 48(%rdi)
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB10_1:                               # =>This Inner Loop Header: Depth=1
	movq	24(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	movq	32(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	movq	40(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	incq	%rcx
	cmpq	$81, %rcx
	jne	.LBB10_1
# %bb.2:                                # %.preheader16
	movl	48(%rdi), %edx
	xorl	%eax, %eax
	movl	$2863311531, %ecx               # imm = 0xAAAAAAAB
.LBB10_3:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_4 Depth 2
	movl	%eax, %esi
	imulq	%rcx, %rsi
	shrq	$33, %rsi
	leal	(%rsi,%rsi,2), %esi
	xorl	%r8d, %r8d
.LBB10_4:                               #   Parent Loop BB10_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	%r8b, %r9d
	imull	$171, %r9d, %r10d
	shrl	$9, %r10d
	movq	(%rdi), %r11
	movl	%edx, %edx
	movb	%al, (%r11,%rdx)
	movq	8(%rdi), %rdx
	movl	48(%rdi), %r11d
	movb	%r9b, (%rdx,%r11)
	addb	%sil, %r10b
	movq	16(%rdi), %rdx
	movl	48(%rdi), %r9d
	movb	%r10b, (%rdx,%r9)
	movl	48(%rdi), %edx
	incl	%edx
	movl	%edx, 48(%rdi)
	incl	%r8d
	cmpl	$9, %r8d
	jne	.LBB10_4
# %bb.5:                                #   in Loop: Header=BB10_3 Depth=1
	incl	%eax
	cmpl	$9, %eax
	jne	.LBB10_3
# %bb.6:
	retq
.Lfunc_end10:
	.size	_Z5emptyP8sudoku_t, .Lfunc_end10-_Z5emptyP8sudoku_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z6hint16P8sudoku_t             # -- Begin function _Z6hint16P8sudoku_t
	.type	_Z6hint16P8sudoku_t,@function
_Z6hint16P8sudoku_t:                    # @_Z6hint16P8sudoku_t
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	$0, 48(%rdi)
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB11_1:                               # =>This Inner Loop Header: Depth=1
	movq	24(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	movq	32(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	movq	40(%rdi), %rdx
	movb	%al, (%rdx,%rcx)
	incq	%rcx
	cmpq	$81, %rcx
	jne	.LBB11_1
# %bb.2:                                # %.preheader26
	movl	$.L__const._Z6hint16P8sudoku_t.vals, %eax
	xorl	%ecx, %ecx
	movl	$2863311531, %edx               # imm = 0xAAAAAAAB
.LBB11_3:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB11_4 Depth 2
	movl	%ecx, %esi
	imulq	%rdx, %rsi
	shrq	$33, %rsi
	leal	(%rsi,%rsi,2), %esi
	xorl	%r8d, %r8d
.LBB11_4:                               #   Parent Loop BB11_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rax,%r8,4), %r9d
	testl	%r9d, %r9d
	je	.LBB11_5
# %bb.6:                                #   in Loop: Header=BB11_4 Depth=2
	movq	24(%rdi), %r10
	leal	(%r9,%r9,8), %r11d
	leal	(%rcx,%r11), %ebx
	addl	$-9, %ebx
	movslq	%ebx, %rbx
	incb	(%r10,%rbx)
	movzbl	%r8b, %r10d
	imull	$171, %r10d, %r10d
	shrl	$9, %r10d
	addl	%esi, %r10d
	leal	(%r9,%r9,8), %r9d
	addl	$-9, %r9d
	addl	%r10d, %r9d
	movq	32(%rdi), %r10
	addl	%r8d, %r11d
	addl	$-9, %r11d
	movslq	%r11d, %r11
	incb	(%r10,%r11)
	movq	40(%rdi), %r10
	movslq	%r9d, %r9
	incb	(%r10,%r9)
	jmp	.LBB11_7
.LBB11_5:                               #   in Loop: Header=BB11_4 Depth=2
	movzbl	%r8b, %r9d
	imull	$171, %r9d, %r9d
	shrl	$9, %r9d
	movq	(%rdi), %r10
	movl	48(%rdi), %r11d
	movb	%cl, (%r10,%r11)
	movq	8(%rdi), %r10
	movl	48(%rdi), %r11d
	movb	%r8b, (%r10,%r11)
	addb	%sil, %r9b
	movq	16(%rdi), %r10
	movl	48(%rdi), %r11d
	movb	%r9b, (%r10,%r11)
	incl	48(%rdi)
.LBB11_7:                               #   in Loop: Header=BB11_4 Depth=2
	incq	%r8
	cmpq	$9, %r8
	jne	.LBB11_4
# %bb.8:                                #   in Loop: Header=BB11_3 Depth=1
	incq	%rcx
	addq	$36, %rax
	cmpq	$9, %rcx
	jne	.LBB11_3
# %bb.9:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end11:
	.size	_Z6hint16P8sudoku_t, .Lfunc_end11-_Z6hint16P8sudoku_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z12energy_statsiPjj            # -- Begin function _Z12energy_statsiPjj
	.type	_Z12energy_statsiPjj,@function
_Z12energy_statsiPjj:                   # @_Z12energy_statsiPjj
	.cfi_startproc
# %bb.0:
	movl	%edi, %eax
	movl	%edx, %edi
	testl	%edx, %edx
	je	.LBB12_1
# %bb.2:                                # %.lr.ph.preheader
	movl	$100000, %edx                   # imm = 0x186A0
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	xorl	%ecx, %ecx
.LBB12_3:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rsi,%r8,4), %r10d
	cmpl	%ecx, %r10d
	cmoval	%r10d, %ecx
	cmpl	%edx, %r10d
	cmovbl	%r10d, %edx
	addl	%r10d, %r9d
	incq	%r8
	cmpq	%r8, %rdi
	jne	.LBB12_3
# %bb.4:                                # %._crit_edge.loopexit
	cvtsi2ss	%r9d, %xmm0
	jmp	.LBB12_5
.LBB12_1:
	xorps	%xmm0, %xmm0
	movl	$100000, %edx                   # imm = 0x186A0
	xorl	%ecx, %ecx
.LBB12_5:                               # %._crit_edge
	pushq	%rax
	.cfi_def_cfa_offset 16
	cvtsi2ss	%rdi, %xmm1
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.1, %edi
	movl	%eax, %esi
	movb	$1, %al
	callq	printf
	movq	stdout(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	fflush                          # TAILCALL
.Lfunc_end12:
	.size	_Z12energy_statsiPjj, .Lfunc_end12-_Z12energy_statsiPjj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI13_0:
	.long	0x3f333333                      # float 0.699999988
.LCPI13_1:
	.long	0x47800000                      # float 65536
.LCPI13_2:
	.long	0x49742400                      # float 1.0E+6
.LCPI13_3:
	.long	0x4ac80000                      # float 6553600
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$328, %rsp                      # imm = 0x148
	.cfi_def_cfa_offset 384
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$1024, %edi                     # imm = 0x400
	callq	malloc
	movq	%rax, %r14
	leaq	112(%rsp), %rdi
	movl	$1024, %esi                     # imm = 0x400
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB13_18
# %bb.1:                                # %_Z9gpuAssert10hipError_tPcib.exit
	movl	$262144, %edi                   # imm = 0x40000
	callq	malloc
	movq	%rax, %rbx
	xorl	%r15d, %r15d
	movq	%r14, %r12
.LBB13_2:                               # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r15d, %xmm0
	divss	.LCPI13_0(%rip), %xmm0
	callq	expf
	mulss	.LCPI13_1(%rip), %xmm0
	cvttss2si	%xmm0, %eax
	movl	%eax, (%r12)
	decq	%r15
	addq	$4, %r12
	cmpq	$-256, %r15
	jne	.LBB13_2
# %bb.3:
	movq	112(%rsp), %rdi
	movl	$1024, %edx                     # imm = 0x400
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB13_4
# %bb.6:                                # %_Z9gpuAssert10hipError_tPcib.exit38
	movabsq	$4294967552, %r15               # imm = 0x100000100
	leaq	120(%rsp), %rbp
	movq	%rbp, %rdi
	movl	$81, %edx
	callq	_Z17sudoku_alloc_hostP8sudoku_tPij
	movq	%rbp, %rdi
	callq	_Z5emptyP8sudoku_t
	movl	48(%rbp), %esi
	xorl	%r12d, %r12d
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	224(%rsp), %r13
	movq	%r13, %rdi
	movq	%rbp, %rsi
	callq	_Z28sudoku_alloc_and_copy_deviceP8sudoku_tS0_
	callq	clock
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	movss	%xmm0, 104(%rsp)                # 4-byte Spill
.LBB13_7:                               # =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB13_9
# %bb.8:                                #   in Loop: Header=BB13_7 Depth=1
	movq	112(%rsp), %rax
	movl	$13, %ecx
	movq	%rsp, %rdi
	movq	%r13, %rsi
	rep;movsq (%rsi), %es:(%rdi)
	movq	%rax, %rdi
	callq	_Z23__device_stub__step_gpu8sudoku_tPi
.LBB13_9:                               #   in Loop: Header=BB13_7 Depth=1
	movq	280(%rsp), %rsi
	movl	$262144, %edx                   # imm = 0x40000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB13_10
# %bb.11:                               # %_Z9gpuAssert10hipError_tPcib.exit40
                                        #   in Loop: Header=BB13_7 Depth=1
	movl	%r12d, %edi
	movq	%rbx, %rsi
	movl	$65536, %edx                    # imm = 0x10000
	callq	_Z12energy_statsiPjj
	incl	%r12d
	cmpl	$15000, %r12d                   # imm = 0x3A98
	jne	.LBB13_7
# %bb.12:
	callq	clock
	cvtsi2ss	%rax, %xmm1
	subss	104(%rsp), %xmm1                # 4-byte Folded Reload
	divss	.LCPI13_2(%rip), %xmm1
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	movss	.LCPI13_3(%rip), %xmm2          # xmm2 = mem[0],zero,zero,zero
	divss	%xmm1, %xmm2
	xorps	%xmm1, %xmm1
	cvtss2sd	%xmm2, %xmm1
	movl	$.L.str.3, %edi
	movl	$6553600, %esi                  # imm = 0x640000
	movb	$2, %al
	callq	printf
	callq	clock
	movq	%rax, 104(%rsp)                 # 8-byte Spill
	xorl	%ebp, %ebp
	leaq	120(%rsp), %r12
	movq	56(%r12), %r13
.LBB13_13:                              # =>This Loop Header: Depth=1
                                        #     Child Loop BB13_14 Depth 2
	xorl	%r15d, %r15d
.LBB13_14:                              #   Parent Loop BB13_13 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$13, %ecx
	movq	%rsp, %rdi
	movq	%r12, %rsi
	rep;movsq (%rsi), %es:(%rdi)
	movq	%r14, %rdi
	movl	%r15d, %esi
	callq	_Z7mc_step8sudoku_tPij
	incl	%r15d
	cmpl	$65536, %r15d                   # imm = 0x10000
	jne	.LBB13_14
# %bb.15:                               # %_Z8step_cpu8sudoku_tPi.exit
                                        #   in Loop: Header=BB13_13 Depth=1
	movl	$262144, %edx                   # imm = 0x40000
	movq	%rbx, %rdi
	movq	%r13, %rsi
	xorl	%ecx, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB13_19
# %bb.16:                               # %_Z9gpuAssert10hipError_tPcib.exit42
                                        #   in Loop: Header=BB13_13 Depth=1
	movl	%ebp, %edi
	movq	%rbx, %rsi
	movl	$65536, %edx                    # imm = 0x10000
	callq	_Z12energy_statsiPjj
	incl	%ebp
	cmpl	$100, %ebp
	jne	.LBB13_13
# %bb.17:
	xorps	%xmm0, %xmm0
	cvtsi2ssq	104(%rsp), %xmm0        # 8-byte Folded Reload
	movss	%xmm0, 104(%rsp)                # 4-byte Spill
	callq	clock
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rax, %xmm1
	subss	104(%rsp), %xmm1                # 4-byte Folded Reload
	divss	.LCPI13_2(%rip), %xmm1
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	movss	.LCPI13_3(%rip), %xmm2          # xmm2 = mem[0],zero,zero,zero
	divss	%xmm1, %xmm2
	xorps	%xmm1, %xmm1
	cvtss2sd	%xmm2, %xmm1
	movl	$.L.str.4, %edi
	movl	$6553600, %esi                  # imm = 0x640000
	movb	$2, %al
	callq	printf
	leaq	120(%rsp), %rdi
	callq	_Z16sudoku_free_hostP8sudoku_t
	leaq	224(%rsp), %rdi
	callq	_Z18sudoku_free_deviceP8sudoku_t
	movq	%rbx, %rdi
	callq	free
	movq	112(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$328, %rsp                      # imm = 0x148
	.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
.LBB13_10:
	.cfi_def_cfa_offset 384
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$505, %r8d                      # imm = 0x1F9
.LBB13_5:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, %edi
	callq	exit
.LBB13_19:
	movl	%eax, %r15d
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$516, %r8d                      # imm = 0x204
	xorl	%eax, %eax
	callq	fprintf
	movl	%r15d, %edi
	callq	exit
.LBB13_18:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$467, %r8d                      # imm = 0x1D3
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebx, %edi
	callq	exit
.LBB13_4:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$486, %r8d                      # imm = 0x1E6
	jmp	.LBB13_5
.Lfunc_end13:
	.size	main, .Lfunc_end13-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB14_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB14_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8step_gpu8sudoku_tPi, %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_end14:
	.size	__hip_module_ctor, .Lfunc_end14-__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	.LBB15_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
.LBB15_2:
	retq
.Lfunc_end15:
	.size	__hip_module_dtor, .Lfunc_end15-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/shaowei-su/sudocuda/master/mcsudoku.hip"
	.size	.L.str, 102

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

	.type	.L__const._Z5hint1P8sudoku_t.vals,@object # @__const._Z5hint1P8sudoku_t.vals
	.p2align	4, 0x0
.L__const._Z5hint1P8sudoku_t.vals:
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	0                               # 0x0
	.long	7                               # 0x7
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	6                               # 0x6
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	5                               # 0x5
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	0                               # 0x0
	.long	8                               # 0x8
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	8                               # 0x8
	.long	0                               # 0x0
	.long	5                               # 0x5
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	7                               # 0x7
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	8                               # 0x8
	.long	2                               # 0x2
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	2                               # 0x2
	.long	0                               # 0x0
	.long	6                               # 0x6
	.long	0                               # 0x0
	.long	5                               # 0x5
	.long	8                               # 0x8
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	4                               # 0x4
	.long	5                               # 0x5
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	2                               # 0x2
	.long	8                               # 0x8
	.long	0                               # 0x0
	.long	6                               # 0x6
	.long	0                               # 0x0
	.long	7                               # 0x7
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	0                               # 0x0
	.long	2                               # 0x2
	.long	0                               # 0x0
	.long	8                               # 0x8
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	5                               # 0x5
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	6                               # 0x6
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	0                               # 0x0
	.size	.L__const._Z5hint1P8sudoku_t.vals, 324

	.type	.L__const._Z6hint16P8sudoku_t.vals,@object # @__const._Z6hint16P8sudoku_t.vals
	.p2align	4, 0x0
.L__const._Z6hint16P8sudoku_t.vals:
	.long	0                               # 0x0
	.long	2                               # 0x2
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	11                              # 0xb
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	15                              # 0xf
	.long	14                              # 0xe
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	13                              # 0xd
	.long	11                              # 0xb
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	0                               # 0x0
	.long	7                               # 0x7
	.long	0                               # 0x0
	.long	16                              # 0x10
	.long	8                               # 0x8
	.long	0                               # 0x0
	.long	12                              # 0xc
	.long	4                               # 0x4
	.long	0                               # 0x0
	.long	10                              # 0xa
	.long	7                               # 0x7
	.long	15                              # 0xf
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	2                               # 0x2
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	10                              # 0xa
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	12                              # 0xc
	.long	13                              # 0xd
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	16                              # 0x10
	.long	9                               # 0x9
	.long	11                              # 0xb
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	15                              # 0xf
	.long	5                               # 0x5
	.long	0                               # 0x0
	.long	16                              # 0x10
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	10                              # 0xa
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	12                              # 0xc
	.long	13                              # 0xd
	.long	15                              # 0xf
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	6                               # 0x6
	.long	10                              # 0xa
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	11                              # 0xb
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	2                               # 0x2
	.long	6                               # 0x6
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	13                              # 0xd
	.long	0                               # 0x0
	.long	9                               # 0x9
	.long	8                               # 0x8
	.long	7                               # 0x7
	.long	10                              # 0xa
	.long	0                               # 0x0
	.long	6                               # 0x6
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	8                               # 0x8
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	11                              # 0xb
	.long	0                               # 0x0
	.long	13                              # 0xd
	.long	7                               # 0x7
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	6                               # 0x6
	.long	10                              # 0xa
	.long	1                               # 0x1
	.long	12                              # 0xc
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	12                              # 0xc
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	5                               # 0x5
	.long	0                               # 0x0
	.long	16                              # 0x10
	.long	7                               # 0x7
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	11                              # 0xb
	.long	0                               # 0x0
	.long	10                              # 0xa
	.long	13                              # 0xd
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	6                               # 0x6
	.long	8                               # 0x8
	.long	14                              # 0xe
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	2                               # 0x2
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	13                              # 0xd
	.long	16                              # 0x10
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	12                              # 0xc
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	13                              # 0xd
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	4                               # 0x4
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	11                              # 0xb
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	14                              # 0xe
	.long	2                               # 0x2
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	9                               # 0x9
	.long	0                               # 0x0
	.long	2                               # 0x2
	.long	5                               # 0x5
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	0                               # 0x0
	.long	15                              # 0xf
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	14                              # 0xe
	.long	7                               # 0x7
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	7                               # 0x7
	.long	1                               # 0x1
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	14                              # 0xe
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	5                               # 0x5
	.long	0                               # 0x0
	.long	8                               # 0x8
	.long	0                               # 0x0
	.long	16                              # 0x10
	.long	0                               # 0x0
	.size	.L__const._Z6hint16P8sudoku_t.vals, 1024

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Round: %03d Mean: %3.2f Min: %03d Max: %03d\r"
	.size	.L.str.1, 45

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"\nGPU: Steps: %ld, Time: %f s, %.1f Steps/s\n"
	.size	.L.str.3, 44

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"\nCPU: Steps: %ld, Time: %f s, %.1f Steps/s\n"
	.size	.L.str.4, 44

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"GPUassert: %s %s %d\n"
	.size	.L.str.5, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8step_gpu8sudoku_tPi"
	.size	.L__unnamed_1, 23

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8step_gpu8sudoku_tPi  ; -- Begin function _Z8step_gpu8sudoku_tPi
	.globl	_Z8step_gpu8sudoku_tPi
	.p2align	8
	.type	_Z8step_gpu8sudoku_tPi,@function
_Z8step_gpu8sudoku_tPi:                 ; @_Z8step_gpu8sudoku_tPi
; %bb.0:
	s_clause 0x3
	s_load_b32 s33, s[0:1], 0x30
	s_load_b128 s[20:23], s[0:1], 0x58
	s_load_b32 s2, s[0:1], 0x7c
	s_load_b256 s[4:11], s[0:1], 0x38
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_u32_e32 v3, s33
	s_and_b32 s2, s2, 0xffff
	s_mov_b64 s[28:29], s[20:21]
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_2)
	v_rcp_iflag_f32_e32 v3, v3
	v_mov_b32_e32 v2, 0
	s_sub_i32 s2, 0, s33
	s_mov_b64 s[30:31], s[10:11]
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v3, 0x4f7ffffe, v3
	v_lshlrev_b64 v[7:8], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cvt_u32_f32_e32 v3, v3
	v_add_co_u32 v9, vcc_lo, s6, v7
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v10, vcc_lo, s7, v8, vcc_lo
	v_mul_lo_u32 v4, s2, v3
	s_mov_b32 s2, 0x19660d
	s_mov_b64 s[6:7], s[22:23]
	global_load_b32 v0, v[9:10], off
	v_mul_hi_u32 v4, v3, v4
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[5:6], null, v0, s2, 0x3c6ef35f
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, v3, v4
	v_mul_hi_u32 v0, v5, v0
	global_store_b32 v[9:10], v5, off
	v_lshrrev_b32_e32 v6, 8, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_hi_u32 v9, 0x1c71c71d, v6
	v_mul_lo_u32 v0, v0, s33
	v_mul_u32_u24_e32 v9, 9, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v0, v5, v0
	v_sub_nc_u32_e32 v6, v6, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_subrev_nc_u32_e32 v3, s33, v0
	v_cmp_le_u32_e32 vcc_lo, s33, v0
	v_cndmask_b32_e32 v0, v0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_subrev_nc_u32_e32 v3, s33, v0
	v_cmp_le_u32_e32 vcc_lo, s33, v0
	v_cndmask_b32_e32 v3, v0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v4, 31, v3
	v_lshlrev_b64 v[3:4], 3, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v3, vcc_lo, s8, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s9, v4, vcc_lo
	global_load_b64 v[11:12], v[3:4], off
	s_waitcnt vmcnt(0)
	v_add_co_u32 v11, vcc_lo, v11, v1
	v_add_co_ci_u32_e32 v12, vcc_lo, 0, v12, vcc_lo
	flat_load_u8 v0, v[11:12]
	s_clause 0x2
	s_load_b64 s[2:3], s[0:1], 0x68
	s_load_b128 s[24:27], s[0:1], 0x20
	s_load_b256 s[12:19], s[0:1], 0x0
	s_mov_b64 s[0:1], 0
	flat_store_b8 v[11:12], v6
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	s_waitcnt lgkmcnt(0)
	s_add_u32 s34, s18, s0
	s_addc_u32 s35, s19, s1
	s_clause 0x1
	global_load_b64 v[9:10], v2, s[30:31]
	global_load_u8 v6, v2, s[34:35]
	s_add_u32 s34, s24, s0
	s_addc_u32 s35, s25, s1
	s_waitcnt vmcnt(1)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	s_waitcnt vmcnt(0)
	flat_store_b8 v[9:10], v6
	s_clause 0x1
	global_load_b64 v[9:10], v2, s[28:29]
	global_load_u8 v6, v2, s[34:35]
	s_add_u32 s34, s26, s0
	s_addc_u32 s35, s27, s1
	s_add_u32 s0, s0, 1
	s_addc_u32 s1, s1, 0
	s_add_u32 s30, s30, 8
	s_addc_u32 s31, s31, 0
	s_add_u32 s28, s28, 8
	s_addc_u32 s29, s29, 0
	s_waitcnt vmcnt(1)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	s_waitcnt vmcnt(0)
	flat_store_b8 v[9:10], v6
	s_clause 0x1
	global_load_b64 v[9:10], v2, s[6:7]
	global_load_u8 v6, v2, s[34:35]
	s_add_u32 s6, s6, 8
	s_addc_u32 s7, s7, 0
	s_cmpk_lg_i32 s0, 0x51
	s_waitcnt vmcnt(1)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	s_waitcnt vmcnt(0)
	flat_store_b8 v[9:10], v6
	s_cbranch_scc1 .LBB0_1
; %bb.2:                                ; %.preheader93.preheader.i
	v_mov_b32_e32 v2, 0
	s_max_u32 s0, s33, 1
.LBB0_3:                                ; %.preheader93.i
                                        ; =>This Inner Loop Header: Depth=1
	s_clause 0x1
	global_load_b64 v[9:10], v2, s[8:9]
	global_load_i8 v6, v2, s[12:13]
	s_add_i32 s0, s0, -1
	s_add_u32 s12, s12, 1
	s_addc_u32 s13, s13, 0
	s_waitcnt vmcnt(1)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	flat_load_i8 v9, v[9:10]
	s_waitcnt vmcnt(1)
	v_mul_lo_u32 v10, 0x48, v6
	v_mul_hi_i32 v6, 0x48, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v11, vcc_lo, s10, v10
	v_add_co_ci_u32_e32 v6, vcc_lo, s11, v6, vcc_lo
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_bfe_i32 v9, v9, 0, 16
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v10, 31, v9
	v_lshlrev_b64 v[9:10], 3, v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v9, vcc_lo, v11, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, v6, v10, vcc_lo
	global_load_b64 v[9:10], v[9:10], off
	s_waitcnt vmcnt(0)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	flat_load_u8 v6, v[9:10]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_nc_u16 v6, v6, 1
	flat_store_b8 v[9:10], v6
	s_clause 0x1
	global_load_b64 v[9:10], v2, s[8:9]
	global_load_i8 v6, v2, s[14:15]
	s_waitcnt vmcnt(1)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	flat_load_i8 v9, v[9:10]
	s_waitcnt vmcnt(1)
	v_mul_lo_u32 v10, 0x48, v6
	v_mul_hi_i32 v6, 0x48, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v11, vcc_lo, s20, v10
	v_add_co_ci_u32_e32 v6, vcc_lo, s21, v6, vcc_lo
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_bfe_i32 v9, v9, 0, 16
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v10, 31, v9
	v_lshlrev_b64 v[9:10], 3, v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v9, vcc_lo, v11, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, v6, v10, vcc_lo
	global_load_b64 v[9:10], v[9:10], off
	s_waitcnt vmcnt(0)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	flat_load_u8 v6, v[9:10]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_nc_u16 v6, v6, 1
	flat_store_b8 v[9:10], v6
	s_clause 0x1
	global_load_b64 v[9:10], v2, s[8:9]
	global_load_i8 v6, v2, s[16:17]
	s_add_u32 s8, s8, 8
	s_addc_u32 s9, s9, 0
	s_add_u32 s14, s14, 1
	s_addc_u32 s15, s15, 0
	s_add_u32 s16, s16, 1
	s_addc_u32 s17, s17, 0
	s_cmp_lg_u32 s0, 0
	s_waitcnt vmcnt(1)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	flat_load_i8 v9, v[9:10]
	s_waitcnt vmcnt(1)
	v_mul_lo_u32 v10, 0x48, v6
	v_mul_hi_i32 v6, 0x48, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v11, vcc_lo, s22, v10
	v_add_co_ci_u32_e32 v6, vcc_lo, s23, v6, vcc_lo
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_bfe_i32 v9, v9, 0, 16
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v10, 31, v9
	v_lshlrev_b64 v[9:10], 3, v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v9, vcc_lo, v11, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, v6, v10, vcc_lo
	global_load_b64 v[9:10], v[9:10], off
	s_waitcnt vmcnt(0)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	flat_load_u8 v6, v[9:10]
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_nc_u16 v6, v6, 1
	flat_store_b8 v[9:10], v6
	s_cbranch_scc1 .LBB0_3
; %bb.4:                                ; %.preheader.i.preheader
	v_mov_b32_e32 v6, 0
	v_mov_b32_e32 v2, 0
	s_mov_b64 s[6:7], 0
.LBB0_5:                                ; %.preheader.i
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s0, s10, s6
	s_addc_u32 s1, s11, s7
	s_add_u32 s8, s20, s6
	global_load_b64 v[9:10], v6, s[0:1]
	s_addc_u32 s9, s21, s7
	global_load_b64 v[11:12], v6, s[8:9]
	s_add_u32 s0, s22, s6
	s_addc_u32 s1, s23, s7
	s_add_u32 s6, s6, 8
	global_load_b64 v[13:14], v6, s[0:1]
	s_addc_u32 s7, s7, 0
	s_cmpk_lg_i32 s6, 0x288
	s_waitcnt vmcnt(2)
	v_add_co_u32 v9, vcc_lo, v9, v1
	v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo
	s_waitcnt vmcnt(1)
	v_add_co_u32 v11, vcc_lo, v11, v1
	v_add_co_ci_u32_e32 v12, vcc_lo, 0, v12, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_co_u32 v13, vcc_lo, v13, v1
	v_add_co_ci_u32_e32 v14, vcc_lo, 0, v14, vcc_lo
	flat_load_i8 v9, v[9:10]
	flat_load_i8 v10, v[11:12]
	flat_load_i8 v11, v[13:14]
	s_waitcnt vmcnt(2) lgkmcnt(2)
	v_add_nc_u32_e32 v12, -1, v9
	v_cmp_ne_u32_e32 vcc_lo, 0, v9
	s_waitcnt vmcnt(1) lgkmcnt(1)
	v_add_nc_u32_e32 v9, -1, v10
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_nc_u32_e32 v13, -1, v11
	v_cmp_ne_u32_e64 s0, 0, v11
	v_cndmask_b32_e32 v12, 1, v12, vcc_lo
	v_cmp_ne_u32_e32 vcc_lo, 0, v10
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cndmask_b32_e64 v10, 1, v13, s0
	v_dual_cndmask_b32 v9, 1, v9 :: v_dual_add_nc_u32 v2, v12, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_add3_u32 v2, v2, v9, v10
	s_cbranch_scc1 .LBB0_5
; %bb.6:
	v_add_co_u32 v7, vcc_lo, s4, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s5, v8, vcc_lo
	s_mov_b32 s4, 0
	s_mov_b32 s1, 0
	s_mov_b32 s0, exec_lo
	global_load_b32 v6, v[7:8], off
	s_waitcnt vmcnt(0)
	v_sub_nc_u32_e32 v6, v2, v6
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e32 1, v6
	s_xor_b32 s0, exec_lo, s0
; %bb.7:
	v_cmp_ne_u32_e32 vcc_lo, 0, v2
                                        ; implicit-def: $vgpr5_vgpr6
	s_mov_b32 s1, exec_lo
                                        ; implicit-def: $vgpr6
	s_and_b32 s4, vcc_lo, exec_lo
; %bb.8:                                ; %Flow
	s_and_not1_saveexec_b32 s5, s0
	s_cbranch_execz .LBB0_10
; %bb.9:
	v_min_i32_e32 v9, 0xff, v6
	v_mov_b32_e32 v10, 0
	v_lshrrev_b32_e32 v5, 16, v5
	s_and_not1_b32 s1, s1, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[9:10], 2, v[9:10]
	v_add_co_u32 v9, vcc_lo, s2, v9
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v10, vcc_lo, s3, v10, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, 0, v2
	s_and_not1_b32 s3, s4, exec_lo
	global_load_b32 v6, v[9:10], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_u32_e64 s0, v6, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s0, s0, vcc_lo
	s_xor_b32 s2, s0, -1
	s_and_b32 s0, s0, exec_lo
	s_and_b32 s2, s2, exec_lo
	s_or_b32 s1, s1, s0
	s_or_b32 s4, s3, s2
.LBB0_10:                               ; %Flow41
	s_or_b32 exec_lo, exec_lo, s5
	s_and_saveexec_b32 s0, s4
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_12
; %bb.11:
	s_and_not1_b32 s1, s1, exec_lo
	global_store_b32 v[7:8], v2, off
.LBB0_12:                               ; %Flow42
	s_or_b32 exec_lo, exec_lo, s0
	s_and_saveexec_b32 s0, s1
	s_cbranch_execz .LBB0_14
; %bb.13:
	global_load_b64 v[2:3], v[3:4], off
	s_waitcnt vmcnt(0)
	v_add_co_u32 v1, vcc_lo, v2, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v3, vcc_lo
	flat_store_b8 v[1:2], v0
.LBB0_14:                               ; %_Z7mc_step8sudoku_tPij.exit
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8step_gpu8sudoku_tPi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 368
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 15
		.amdhsa_next_free_sgpr 36
		.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	_Z8step_gpu8sudoku_tPi, .Lfunc_end0-_Z8step_gpu8sudoku_tPi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1684
; NumSgprs: 38
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 4
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 38
; NumVGPRsForWavesPerEU: 15
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.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:
      - .offset:         0
        .size:           104
        .value_kind:     by_value
      - .address_space:  global
        .offset:         104
        .size:           8
        .value_kind:     global_buffer
      - .offset:         112
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         116
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         120
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         124
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         126
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         128
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         130
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         132
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         134
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         152
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         160
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         168
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         176
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 368
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8step_gpu8sudoku_tPi
    .private_segment_fixed_size: 0
    .sgpr_count:     38
    .sgpr_spill_count: 0
    .symbol:         _Z8step_gpu8sudoku_tPi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
