#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#define THREAD_NUM		96

/** 再帰バージョン 非CUDA
  1. バックトラック
  2. ビットマップ
14:            365596                 0          00:00:00:00.44
15:           2279184                 0          00:00:00:02.81
*/
long long nqInternal(int n,unsigned int left,unsigned int down,unsigned int right) {
  unsigned int msk=(1<<n)-1;
  if(down==msk){return 1;}
	unsigned int bm=(left|down|right);
	if((bm&msk)==msk){return 0;}
	long long total=0;
	unsigned int bit=(bm+1)&~bm;
	while((bit&msk)!=0){
		total+=nqInternal(n,(left|bit)<<1,down|bit,(right|bit)>>1);
		bm|=bit;
		bit=(bm+1)&~bm;
	}
	return total;
}
long long solve_nqueen_recursive(int n){
	return nqInternal(n,0,0,0);
}
/** 非再帰バージョン 非CUDA
  1. バックトラック
  2. ビットマップ
14:            365596                 0          00:00:00:00.22
15:           2279184                 0          00:00:00:01.50
*/
long long solve_nqueen_nonRecursive(int n){
  unsigned int down[32];unsigned int left[32];unsigned int right[32];unsigned int bm[32];
  if(n<=0||n>32){return 0;}
  const unsigned int msk=(1<<n)-1;long long total=0;long long uTotal=0;
  int i=0;int j=0;unsigned int bit;
  down[0]=0;left[0]=0;right[0]=0;bm[0]=0;
  for(j=0;j<(n+1)/2;j++){
    bit=(1<<j);
    bm[0]|=bit;down[1]=bit;left[1]=bit<<1;right[1]=bit>>1;
    bm[1]=(down[1]|left[1]|right[1]);
    i=1;
    if(n%2==1&&j==(n+1)/2-1){uTotal=total;total=0;}
    while(i>0){
      if((bm[i]&msk)==msk){i--;}
      else{
        bit=((bm[i]+1)^bm[i])&~bm[i];
        bm[i]|=bit;
        if((bit&msk)!=0){
          if(i+1==n){total++;i--;}
          else{
            down[i+1]=down[i]|bit;left[i+1]=(left[i]|bit)<<1;right[i+1]=(right[i]|bit)>>1;
            bm[i+1]=(down[i+1]|left[i+1]|right[i+1]);
            i++;
          }
        }else{i--;}
      }
    }
  }
  if(n%2==0){return total*2;}
  else{return uTotal*2+total;}
}
/** CUDA 非再帰バージョン 
  CPUイテレータから複数の初期条件を受け取り、カウント
  1. バックトラック backTrack
  2. ビットマップ   bitmap
14:            365596                 0          00:00:00:00.08
15:           2279184                 0          00:00:00:00.49
*/
__global__ void solve_nqueen_cuda_kernel_bt_bm(
  int n,int mark,
  unsigned int* totalDown,unsigned int* totalLeft,unsigned int* totalRight,
  unsigned int* results,int totalCond){
  const int tid=threadIdx.x,bid=blockIdx.x,idx=bid*blockDim.x+tid;
  __shared__ unsigned int down[THREAD_NUM][10],left[THREAD_NUM][10],right[THREAD_NUM][10],
                          bitmap[THREAD_NUM][10],sum[THREAD_NUM];
  const unsigned int mask=(1<<n)-1;int total=0,i=0;unsigned int bit;
  if(idx<totalCond){
    down[tid][i]=totalDown[idx];
    left[tid][i]=totalLeft[idx];
    right[tid][i]=totalRight[idx];
    bitmap[tid][i]=down[tid][i]|left[tid][i]|right[tid][i];
    while(i>=0){
      if((bitmap[tid][i]&mask)==mask){i--;}
      else{
        bit=(bitmap[tid][i]+1)&~bitmap[tid][i];
        bitmap[tid][i]|=bit;
        if((bit&mask)!=0){
          if(i+1==mark){total++;i--;}
          else{
            down[tid][i+1]=down[tid][i]|bit;
            left[tid][i+1]=(left[tid][i]|bit)<<1;
            right[tid][i+1]=(right[tid][i]|bit)>>1;
            bitmap[tid][i+1]=(down[tid][i+1]|left[tid][i+1]|right[tid][i+1]);
            i++;
          }
        }else{i--;}
      }
    }
    sum[tid]=total;
  }else{sum[tid]=0;} 
  __syncthreads();if(tid<64&&tid+64<THREAD_NUM){sum[tid]+=sum[tid+64];} 
  __syncthreads();if(tid<32){sum[tid]+=sum[tid+32];} 
  __syncthreads();if(tid<16){sum[tid]+=sum[tid+16];} 
  __syncthreads();if(tid<8){sum[tid]+=sum[tid+8];} 
  __syncthreads();if(tid<4){sum[tid]+=sum[tid+4];} 
  __syncthreads();if(tid<2){sum[tid]+=sum[tid+2];} 
  __syncthreads();if(tid<1){sum[tid]+=sum[tid+1];} 
  __syncthreads();if(tid==0){results[bid]=sum[0];}
}
long long solve_nqueen_cuda(int n,int steps) {
  unsigned int down[32];unsigned int left[32];unsigned int right[32];
  unsigned int m[32];unsigned int bit;
  if(n<=0||n>32){return 0;}
  unsigned int* totalDown=new unsigned int[steps];
  unsigned int* totalLeft=new unsigned int[steps];
  unsigned int* totalRight=new unsigned int[steps];
  unsigned int* results=new unsigned int[steps];
  unsigned int* downCuda;unsigned int* leftCuda;unsigned int* rightCuda;
  unsigned int* resultsCuda;
  cudaMalloc((void**) &downCuda,sizeof(int)*steps);
  cudaMalloc((void**) &leftCuda,sizeof(int)*steps);
  cudaMalloc((void**) &rightCuda,sizeof(int)*steps);
  cudaMalloc((void**) &resultsCuda,sizeof(int)*steps/THREAD_NUM);
  const unsigned int mask=(1<<n)-1;
  const unsigned int mark=n>11?n-10:2;
  long long total=0;int totalCond=0;
  int i=0,j;down[0]=0;left[0]=0;right[0]=0;m[0]=0;bool computed=false;
  for(j=0;j<n/2;j++){
    bit=(1<<j);m[0]|=bit;
    down[1]=bit;left[1]=bit<<1;right[1]=bit>>1;
    m[1]=(down[1]|left[1]|right[1]);
    i=1;
    while(i>0){
      if((m[i]&mask)==mask){i--;}
      else{
        bit=(m[i]+1)&~m[i];m[i]|=bit;
        if((bit&mask)!=0){
          down[i+1]=down[i]|bit;left[i+1]=(left[i]|bit)<<1;right[i+1]=(right[i]|bit)>>1;
          m[i+1]=(down[i+1]|left[i+1]|right[i+1]);
          i++;
          if(i==mark){
            totalDown[totalCond]=down[i];totalLeft[totalCond]=left[i];totalRight[totalCond]=right[i];
            totalCond++;
            if(totalCond==steps){
              if(computed){
                cudaMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,cudaMemcpyDeviceToHost);
                for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
                computed=false;
              }
              cudaMemcpy(downCuda,totalDown,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
              cudaMemcpy(leftCuda,totalLeft,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
              cudaMemcpy(rightCuda,totalRight,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
              /** backTrack+bitmap*/
              solve_nqueen_cuda_kernel_bt_bm<<<steps/THREAD_NUM,THREAD_NUM>>>(n,n-mark,downCuda,leftCuda,rightCuda,resultsCuda,totalCond);
              computed=true;totalCond=0;
            }
            i--;
          }
        }else{i --;}
      }
    }
  }
  if(computed){
    cudaMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,cudaMemcpyDeviceToHost);
    for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
    computed=false;
  }
  cudaMemcpy(downCuda,totalDown,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
  cudaMemcpy(leftCuda,totalLeft,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
  cudaMemcpy(rightCuda,totalRight,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
  /** backTrack+bitmap*/
  solve_nqueen_cuda_kernel_bt_bm<<<steps/THREAD_NUM,THREAD_NUM>>>(n,n-mark,downCuda,leftCuda,rightCuda,resultsCuda,totalCond);
  cudaMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,cudaMemcpyDeviceToHost);
  for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}	
  total*=2;
  if(n%2==1){
    computed=false;totalCond=0;bit=(1<<(n-1)/2);m[0]|=bit;
    down[1]=bit;left[1]=bit<<1;right[1]=bit>>1;
    m[1]=(down[1]|left[1]|right[1]);
    i=1;
    while(i>0){
      if((m[i]&mask)==mask){i--;}
      else{
        bit=(m[i]+1)&~m[i];m[i]|=bit;
        if((bit&mask)!=0){
          down[i+1]=down[i]|bit;left[i+1]=(left[i]|bit)<<1;right[i+1]=(right[i]|bit)>>1;
          m[i+1]=(down[i+1]|left[i+1]|right[i+1]);
          i++;
          if(i==mark){
            totalDown[totalCond]=down[i];totalLeft[totalCond]=left[i];totalRight[totalCond]=right[i];
            totalCond++;
            if(totalCond==steps){
              if(computed){
                cudaMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,cudaMemcpyDeviceToHost);
                for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
                computed=false;
              }
              cudaMemcpy(downCuda,totalDown,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
              cudaMemcpy(leftCuda,totalLeft,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
              cudaMemcpy(rightCuda,totalRight,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
              /** backTrack+bitmap*/
              solve_nqueen_cuda_kernel_bt_bm<<<steps/THREAD_NUM,THREAD_NUM>>>(n,n-mark,downCuda,leftCuda,rightCuda,resultsCuda,totalCond);
              computed=true;totalCond=0;
            }
            i--;
          }
        }else{i --;}
      }
    }
    if(computed){
      cudaMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,cudaMemcpyDeviceToHost);
      for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
      computed=false;
    }
    cudaMemcpy(downCuda,totalDown,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
    cudaMemcpy(leftCuda,totalLeft,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
    cudaMemcpy(rightCuda,totalRight,sizeof(int)*totalCond,cudaMemcpyHostToDevice);
    /** backTrack+bitmap*/
    solve_nqueen_cuda_kernel_bt_bm<<<steps/THREAD_NUM,THREAD_NUM>>>(n,n-mark,downCuda,leftCuda,rightCuda,resultsCuda,totalCond);
    cudaMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,cudaMemcpyDeviceToHost);
    for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
  }
  cudaFree(downCuda);cudaFree(leftCuda);cudaFree(rightCuda);cudaFree(resultsCuda);
  delete[] totalDown;delete[] totalLeft;delete[] totalRight;delete[] results;
  return total;
}
/** CUDA 初期化 **/
bool InitCUDA(){
  int count;
  cudaGetDeviceCount(&count);
  if(count==0){fprintf(stderr,"There is no device.\n");return false;}
  int i;
  for(i=0;i<count;i++){
    cudaDeviceProp prop;
    if(cudaGetDeviceProperties(&prop,i)==cudaSuccess){if(prop.major>=1){break;} }
  }
  if(i==count){fprintf(stderr,"There is no device supporting CUDA 1.x.\n");return false;}
  cudaSetDevice(i);
  return true;
}
int main(int argc,char** argv) {
  long long solution;
  bool cpu=true,gpu=true;
  int argstart=1,steps=24576;
  /** パラメータの処理 */
  if(argc>=2&&argv[1][0]=='-'){
    if(argv[1][1]=='c'||argv[1][1]=='C'){gpu=false;}
    else if(argv[1][1]=='g'||argv[1][1]=='G'){cpu=false;}
    argstart=2;
  }
  if(argc<argstart){
    printf("Usage: %s [-c|-g] n steps\n",argv[0]);
    printf("  -c: CPU only\n");
    printf("  -g: GPU only\n");
    printf("Default to 8 queen\n");
  }
  /** 出力と実行 */
  /** CPU */
  if(cpu){
    int min=4;int targetN=15;
    struct timeval t0;struct timeval t1;int ss;int ms;int dd;
    printf("%s\n"," N:          Total        Unique                 dd:hh:mm:ss.ms");
    for(int i=min;i<=targetN;i++){
      gettimeofday(&t0,NULL);   // 計測開始
      /** 再帰 */
      /* solution=solve_nqueen_recursive(i);*/
      /** 非再帰 */
      solution=solve_nqueen_nonRecursive(i);
      gettimeofday(&t1,NULL);   // 計測終了
      if (t1.tv_usec<t0.tv_usec) {
        dd=(int)(t1.tv_sec-t0.tv_sec-1)/86400;
        ss=(t1.tv_sec-t0.tv_sec-1)%86400;
        ms=(1000000+t1.tv_usec-t0.tv_usec+500)/10000;
      } else {
        dd=(int)(t1.tv_sec-t0.tv_sec)/86400;
        ss=(t1.tv_sec-t0.tv_sec)%86400;
        ms=(t1.tv_usec-t0.tv_usec+500)/10000;
      }
      int hh=ss/3600;
      int mm=(ss-hh*3600)/60;
      ss%=60;
      long lGUnique=0;
      printf("%2d:%18llu%18llu%12.2d:%02d:%02d:%02d.%02d\n", i,(unsigned long long)solution,(unsigned long long)lGUnique,dd,hh,mm,ss,ms);
    }
  }
  /** GPU */
  if(gpu){
    if(!InitCUDA()){return 0;}
    int min=4;int targetN=17;
    struct timeval t0;struct timeval t1;int ss;int ms;int dd;
    printf("%s\n"," N:          Total        Unique                 dd:hh:mm:ss.ms");
    for(int i=min;i<=targetN;i++){
      gettimeofday(&t0,NULL);   // 計測開始
      solution=solve_nqueen_cuda(i,steps);
      gettimeofday(&t1,NULL);   // 計測終了
      if (t1.tv_usec<t0.tv_usec) {
        dd=(int)(t1.tv_sec-t0.tv_sec-1)/86400;
        ss=(t1.tv_sec-t0.tv_sec-1)%86400;
        ms=(1000000+t1.tv_usec-t0.tv_usec+500)/10000;
      } else {
        dd=(int)(t1.tv_sec-t0.tv_sec)/86400;
        ss=(t1.tv_sec-t0.tv_sec)%86400;
        ms=(t1.tv_usec-t0.tv_usec+500)/10000;
      }
      int hh=ss/3600;
      int mm=(ss-hh*3600)/60;
      ss%=60;
      long lGUnique=0;
      printf("%2d:%18llu%18llu%12.2d:%02d:%02d:%02d.%02d\n", i,(unsigned long long)solution,(unsigned long long)lGUnique,dd,hh,mm,ss,ms);
    }
  }
  return 0;
}

	.file	"tmpxft_002fc41d_00000000-6_07_58cuda_queens.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_Z25solve_nqueen_nonRecursivei.part.0, @function
_Z25solve_nqueen_nonRecursivei.part.0:
.LFB2176:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edi, %ecx
	movl	%edi, %r10d
	leal	1(%rdi), %r11d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	$1, %r9d
	sarl	%r11d
	xorl	%edi, %edi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	sall	%cl, %r9d
	leal	-1(%r11), %r13d
	xorl	%ecx, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	decl	%r9d
	movl	$1, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%r10d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	andl	$1, %ebp
	subq	$536, %rsp
	.cfi_def_cfa_offset 592
	movq	%fs:40, %rax
	movq	%rax, 520(%rsp)
	xorl	%eax, %eax
.L10:
	movl	%r12d, %esi
	sall	%cl, %esi
	movl	%esi, %r8d
	leal	(%rsi,%rsi), %edx
	movl	%esi, 12(%rsp)
	shrl	%r8d
	movl	%edx, 140(%rsp)
	orl	%r8d, %edx
	movl	%r8d, 268(%rsp)
	orl	%esi, %edx
	movl	%edx, 396(%rsp)
	testl	%ebp, %ebp
	je	.L3
	cmpl	%ecx, %r13d
	jne	.L3
	movq	%rdi, %rax
	xorl	%edi, %edi
.L3:
	movl	$1, %ebx
.L9:
	movslq	%ebx, %r15
	movl	392(%rsp,%r15,4), %esi
	movl	%esi, %edx
	notl	%edx
	testl	%r9d, %edx
	je	.L21
	leal	1(%rsi), %r8d
	movl	%r8d, %edx
	orl	%esi, %edx
	xorl	%esi, %edx
	orl	%r8d, %esi
	leal	-1(%rbx), %r8d
	movl	%esi, 392(%rsp,%r15,4)
	testl	%edx, %r9d
	je	.L5
	leal	1(%rbx), %r8d
	cmpl	%r8d, %r10d
	jne	.L7
	incq	%rdi
.L21:
	leal	-1(%rbx), %r8d
	jmp	.L5
.L7:
	movl	8(%rsp,%r15,4), %r14d
	movl	136(%rsp,%r15,4), %esi
	movslq	%r8d, %rbx
	orl	%edx, %r14d
	orl	%edx, %esi
	orl	264(%rsp,%r15,4), %edx
	addl	%esi, %esi
	shrl	%edx
	movl	%r14d, 8(%rsp,%rbx,4)
	movl	%esi, 136(%rsp,%rbx,4)
	orl	%edx, %esi
	orl	%r14d, %esi
	movl	%edx, 264(%rsp,%rbx,4)
	movl	%esi, 392(%rsp,%rbx,4)
.L8:
	movl	%r8d, %ebx
	jmp	.L9
.L5:
	testl	%r8d, %r8d
	jne	.L8
	incl	%ecx
	cmpl	%r11d, %ecx
	jne	.L10
	addq	%rax, %rax
	leaq	(%rdi,%rdi), %rdx
	addq	%rdi, %rax
	testl	%ebp, %ebp
	cmove	%rdx, %rax
	movq	520(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	addq	$536, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2176:
	.size	_Z25solve_nqueen_nonRecursivei.part.0, .-_Z25solve_nqueen_nonRecursivei.part.0
	.globl	_Z10nqInternalijjj
	.type	_Z10nqInternalijjj, @function
_Z10nqInternalijjj:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%ecx, %r9d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	$1, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	$1, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	%edi, 8(%rsp)
	movb	8(%rsp), %cl
	sall	%cl, %r12d
	decl	%r12d
	cmpl	%edx, %r12d
	je	.L23
	movl	%esi, %ebp
	movl	%esi, %r15d
	movl	%edx, %r14d
	xorl	%r13d, %r13d
	orl	%r9d, %ebp
	orl	%edx, %ebp
	movl	%ebp, %eax
	notl	%eax
	testl	%r12d, %eax
	je	.L23
	movl	%ebp, %eax
	leal	1(%rbp), %ebx
	notl	%eax
	andl	%eax, %ebx
.L25:
	testl	%r12d, %ebx
	je	.L23
	movl	%ebx, %ecx
	movl	%ebx, %esi
	movl	%ebx, %edx
	movl	8(%rsp), %edi
	orl	%r9d, %ecx
	orl	%r15d, %esi
	orl	%r14d, %edx
	movl	%r9d, 12(%rsp)
	shrl	%ecx
	addl	%esi, %esi
	orl	%ebx, %ebp
	call	_Z10nqInternalijjj
	leal	1(%rbp), %ebx
	movl	12(%rsp), %r9d
	addq	%rax, %r13
	movl	%ebp, %eax
	notl	%eax
	andl	%eax, %ebx
	jmp	.L25
.L23:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	movq	%r13, %rax
	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
.LFE2027:
	.size	_Z10nqInternalijjj, .-_Z10nqInternalijjj
	.globl	_Z22solve_nqueen_recursivei
	.type	_Z22solve_nqueen_recursivei, @function
_Z22solve_nqueen_recursivei:
.LFB2028:
	.cfi_startproc
	endbr64
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	xorl	%esi, %esi
	jmp	_Z10nqInternalijjj
	.cfi_endproc
.LFE2028:
	.size	_Z22solve_nqueen_recursivei, .-_Z22solve_nqueen_recursivei
	.globl	_Z25solve_nqueen_nonRecursivei
	.type	_Z25solve_nqueen_nonRecursivei, @function
_Z25solve_nqueen_nonRecursivei:
.LFB2029:
	.cfi_startproc
	endbr64
	leal	-1(%rdi), %eax
	cmpl	$31, %eax
	ja	.L32
	jmp	_Z25solve_nqueen_nonRecursivei.part.0
.L32:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z25solve_nqueen_nonRecursivei, .-_Z25solve_nqueen_nonRecursivei
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"There is no device.\n"
.LC1:
	.string	"There is no device supporting CUDA 1.x.\n"
	.text
	.globl	_Z8InitCUDAv
	.type	_Z8InitCUDAv, @function
_Z8InitCUDAv:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$1064, %rsp
	.cfi_def_cfa_offset 1088
	movq	%fs:40, %rax
	movq	%rax, 1048(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdi
	call	cudaGetDeviceCount@PLT
	cmpl	$0, 12(%rsp)
	leaq	.LC0(%rip), %rdx
	je	.L47
	xorl	%ebx, %ebx
	leaq	16(%rsp), %rbp
.L34:
	cmpl	%ebx, 12(%rsp)
	jle	.L38
	movl	%ebx, %esi
	movq	%rbp, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	testl	%eax, %eax
	jne	.L36
	cmpl	$0, 376(%rsp)
	jg	.L38
.L36:
	incl	%ebx
	jmp	.L34
.L38:
	cmpl	%ebx, 12(%rsp)
	jne	.L40
	leaq	.LC1(%rip), %rdx
.L47:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	xorl	%eax, %eax
	jmp	.L33
.L40:
	movl	%ebx, %edi
	call	cudaSetDevice@PLT
	movb	$1, %al
.L33:
	movq	1048(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	addq	$1064, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z8InitCUDAv, .-_Z8InitCUDAv
	.globl	_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i
	.type	_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i, @function
_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movl	%edi, 44(%rsp)
	leaq	64(%rsp), %rdi
	movl	%esi, 40(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 32(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 24(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movq	%r9, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L48
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L48:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L50
	call	__stack_chk_fail@PLT
.L50:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i, .-_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i
	.globl	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.type	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i, @function
_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i
	.cfi_endproc
.LFE2058:
	.size	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i, .-_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.globl	_Z17solve_nqueen_cudaii
	.type	_Z17solve_nqueen_cudaii, @function
_Z17solve_nqueen_cudaii:
.LFB2030:
	.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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$648, %rsp
	.cfi_def_cfa_offset 704
	movl	%esi, 40(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 632(%rsp)
	xorl	%eax, %eax
	leal	-1(%rdi), %eax
	cmpl	$31, %eax
	ja	.L95
	movabsq	$2305843009213693950, %rax
	movslq	%esi, %rbp
	cmpq	%rbp, %rax
	jb	.L55
	salq	$2, %rbp
	movl	%edi, %ebx
	movq	%rbp, %rdi
	call	_Znam@PLT
	movq	%rbp, %rdi
	movq	%rax, (%rsp)
	call	_Znam@PLT
	movq	%rbp, %rdi
	movq	%rax, 8(%rsp)
	call	_Znam@PLT
	movq	%rbp, %rdi
	movq	%rax, 16(%rsp)
	call	_Znam@PLT
	movq	%rbp, %rsi
	leaq	64(%rsp), %rdi
	movq	%rax, %r12
	call	cudaMalloc@PLT
	movq	%rbp, %rsi
	leaq	72(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	%rbp, %rsi
	leaq	80(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$96, %ecx
	movq	%rbp, %rax
	xorl	%edx, %edx
	divq	%rcx
	leaq	88(%rsp), %rdi
	movq	%rax, %rsi
	movq	%rax, 24(%rsp)
	call	cudaMalloc@PLT
	movl	$1, %eax
	movl	%ebx, %ecx
	sall	%cl, %eax
	decl	%eax
	movl	%eax, 44(%rsp)
	movl	$12, %eax
	cmpl	%eax, %ebx
	cmovge	%ebx, %eax
	xorl	%esi, %esi
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	xorl	%ebp, %ebp
	subl	$10, %eax
	movl	%eax, 36(%rsp)
	movl	%ebx, %eax
	sarl	%eax
	movl	%eax, 60(%rsp)
	jmp	.L56
.L55:
	movq	632(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L115
	call	__cxa_throw_bad_array_new_length@PLT
.L58:
	leal	1(%rdx), %ecx
	movl	%edx, %eax
	notl	%eax
	orl	%ecx, %edx
	movl	%edx, 504(%rsp,%r9,4)
	andl	%ecx, %eax
	testl	%eax, 44(%rsp)
	je	.L60
	movl	248(%rsp,%r9,4), %edx
	movl	120(%rsp,%r9,4), %r8d
	leal	1(%r15), %edi
	movslq	%edi, %rcx
	orl	%eax, %edx
	orl	%eax, %r8d
	orl	376(%rsp,%r9,4), %eax
	addl	%edx, %edx
	shrl	%eax
	movl	%r8d, 120(%rsp,%rcx,4)
	movl	%edx, %r9d
	movl	%edx, 248(%rsp,%rcx,4)
	orl	%eax, %r9d
	movl	%eax, 376(%rsp,%rcx,4)
	orl	%r8d, %r9d
	movl	%r9d, 504(%rsp,%rcx,4)
	cmpl	%edi, 36(%rsp)
	jne	.L96
	movslq	%r13d, %rcx
	incl	%r13d
	leaq	0(,%rcx,4), %rdi
	movq	%rdi, 48(%rsp)
	movq	(%rsp), %rdi
	movl	%r8d, (%rdi,%rcx,4)
	movq	8(%rsp), %rdi
	movl	%edx, (%rdi,%rcx,4)
	movq	16(%rsp), %rdi
	movl	%eax, (%rdi,%rcx,4)
	cmpl	%r13d, 40(%rsp)
	je	.L116
.L67:
	movslq	%r15d, %r9
	movl	504(%rsp,%r9,4), %edx
	movl	%edx, %eax
	notl	%eax
	testl	%eax, 44(%rsp)
	jne	.L58
.L60:
	decl	%r15d
	testl	%r15d, %r15d
	jne	.L67
	incl	%r14d
.L56:
	cmpl	%r14d, 60(%rsp)
	je	.L117
	movl	%r14d, %ecx
	movl	$1, %edx
	movl	$1, %r15d
	sall	%cl, %edx
	movl	%edx, %ecx
	leal	(%rdx,%rdx), %eax
	movl	%edx, 124(%rsp)
	shrl	%ecx
	movl	%eax, 252(%rsp)
	orl	%ecx, %eax
	movl	%ecx, 380(%rsp)
	orl	%edx, %eax
	movl	%eax, 508(%rsp)
	jmp	.L67
.L116:
	movl	40(%rsp), %eax
	movl	$96, %ecx
	cltd
	idivl	%ecx
	movl	%eax, 56(%rsp)
	testb	%sil, %sil
	je	.L62
	movq	24(%rsp), %rdx
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L63:
	cmpl	%eax, 56(%rsp)
	jle	.L62
	movl	(%r12,%rax,4), %edx
	incq	%rax
	addq	%rdx, %rbp
	jmp	.L63
.L62:
	movq	48(%rsp), %rax
	movq	(%rsp), %rsi
	movl	$1, %ecx
	movq	64(%rsp), %rdi
	addq	$4, %rax
	movq	%rax, %rdx
	movq	%rax, 48(%rsp)
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdx
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movq	72(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	80(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$134217731, %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$5, %rax
	movl	$134217731, %edx
	movl	$1, %ecx
	movl	$1, 116(%rsp)
	movq	%rax, 108(%rsp)
	movl	56(%rsp), %eax
	salq	$5, %rdx
	movl	%eax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 100(%rsp)
	movq	96(%rsp), %rdi
	movl	104(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L65
	movl	36(%rsp), %eax
	movl	%ebx, %esi
	movl	%ebx, %edi
	subl	%eax, %esi
	pushq	%rax
	.cfi_def_cfa_offset 712
	pushq	%r13
	.cfi_def_cfa_offset 720
	movq	104(%rsp), %r9
	movq	96(%rsp), %r8
	movq	88(%rsp), %rcx
	movq	80(%rsp), %rdx
	call	_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i
	popq	%rax
	.cfi_def_cfa_offset 712
	popq	%rdx
	.cfi_def_cfa_offset 704
.L65:
	movb	$1, %sil
	xorl	%r13d, %r13d
	jmp	.L67
.L117:
	movl	40(%rsp), %eax
	movl	$96, %ecx
	cltd
	idivl	%ecx
	movl	%eax, %r14d
	testb	%sil, %sil
	je	.L69
	movq	24(%rsp), %rdx
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L70:
	cmpl	%eax, %r14d
	jle	.L69
	movl	(%r12,%rax,4), %edx
	incq	%rax
	addq	%rdx, %rbp
	jmp	.L70
.L69:
	movslq	%r13d, %r15
	movq	(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	salq	$2, %r15
	movq	%r15, %rdx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	72(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rsi
	movq	80(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%r14d, 96(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	$134217731, %edx
	movl	$1, %ecx
	movl	$1, 116(%rsp)
	movq	%rax, 100(%rsp)
	movq	96(%rsp), %rdi
	salq	$5, %rdx
	movl	104(%rsp), %esi
	movq	%rdx, 108(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L72
	movl	36(%rsp), %eax
	pushq	%r10
	.cfi_def_cfa_offset 712
	movl	%ebx, %esi
	movl	%ebx, %edi
	pushq	%r13
	.cfi_def_cfa_offset 720
	movq	104(%rsp), %r9
	movq	96(%rsp), %r8
	movq	88(%rsp), %rcx
	subl	%eax, %esi
	movq	80(%rsp), %rdx
	call	_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i
	popq	%r11
	.cfi_def_cfa_offset 712
	popq	%r13
	.cfi_def_cfa_offset 704
.L72:
	movq	24(%rsp), %rdx
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L73:
	cmpl	%eax, %r14d
	jle	.L118
	movl	(%r12,%rax,4), %edx
	incq	%rax
	addq	%rdx, %rbp
	jmp	.L73
.L118:
	movl	%ebx, %r15d
	addq	%rbp, %rbp
	andl	$1, %r15d
	je	.L75
	leal	-1(%rbx), %ecx
	movl	$1, %edx
	xorl	%edi, %edi
	sarl	%ecx
	sall	%cl, %edx
	movl	%edx, %ecx
	leal	(%rdx,%rdx), %eax
	movl	%edx, 124(%rsp)
	shrl	%ecx
	movl	%eax, 252(%rsp)
	orl	%ecx, %eax
	movl	%ecx, 380(%rsp)
	orl	%edx, %eax
	movl	%eax, 508(%rsp)
.L114:
	xorl	%r13d, %r13d
.L85:
	movslq	%r15d, %r9
	movl	504(%rsp,%r9,4), %edx
	movl	%edx, %eax
	notl	%eax
	testl	%eax, 44(%rsp)
	je	.L78
	leal	1(%rdx), %ecx
	movl	%edx, %eax
	notl	%eax
	orl	%ecx, %edx
	movl	%edx, 504(%rsp,%r9,4)
	andl	%ecx, %eax
	testl	%eax, 44(%rsp)
	je	.L78
	movl	248(%rsp,%r9,4), %edx
	movl	120(%rsp,%r9,4), %r8d
	leal	1(%r15), %esi
	movslq	%esi, %rcx
	orl	%eax, %edx
	orl	%eax, %r8d
	orl	376(%rsp,%r9,4), %eax
	addl	%edx, %edx
	shrl	%eax
	movl	%r8d, 120(%rsp,%rcx,4)
	movl	%edx, %r9d
	movl	%edx, 248(%rsp,%rcx,4)
	orl	%eax, %r9d
	movl	%eax, 376(%rsp,%rcx,4)
	orl	%r8d, %r9d
	movl	%r9d, 504(%rsp,%rcx,4)
	cmpl	%esi, 36(%rsp)
	jne	.L97
	movslq	%r13d, %rcx
	incl	%r13d
	leaq	0(,%rcx,4), %rsi
	movq	%rsi, 48(%rsp)
	movq	(%rsp), %rsi
	movl	%r8d, (%rsi,%rcx,4)
	movq	8(%rsp), %rsi
	movl	%edx, (%rsi,%rcx,4)
	movq	16(%rsp), %rsi
	movl	%eax, (%rsi,%rcx,4)
	cmpl	%r13d, 40(%rsp)
	jne	.L85
	testb	%dil, %dil
	je	.L80
	movq	24(%rsp), %rdx
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L81:
	cmpl	%eax, %r14d
	jle	.L80
	movl	(%r12,%rax,4), %edx
	incq	%rax
	addq	%rdx, %rbp
	jmp	.L81
.L80:
	movq	48(%rsp), %rax
	movq	(%rsp), %rsi
	movl	$1, %ecx
	movq	64(%rsp), %rdi
	addq	$4, %rax
	movq	%rax, %rdx
	movq	%rax, 48(%rsp)
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdx
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movq	72(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdx
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	80(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	%r14d, 96(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	$134217731, %edx
	movl	$1, %ecx
	movl	$1, 116(%rsp)
	movq	%rax, 100(%rsp)
	movq	96(%rsp), %rdi
	salq	$5, %rdx
	movl	104(%rsp), %esi
	movq	%rdx, 108(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L83
	movl	36(%rsp), %eax
	pushq	%rdi
	.cfi_def_cfa_offset 712
	movl	%ebx, %esi
	movl	%ebx, %edi
	pushq	%r13
	.cfi_def_cfa_offset 720
	movq	104(%rsp), %r9
	movq	96(%rsp), %r8
	movq	88(%rsp), %rcx
	subl	%eax, %esi
	movq	80(%rsp), %rdx
	call	_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i
	popq	%r8
	.cfi_def_cfa_offset 712
	popq	%r9
	.cfi_def_cfa_offset 704
.L83:
	movb	$1, %dil
	jmp	.L114
.L78:
	decl	%r15d
	testl	%r15d, %r15d
	jne	.L85
	testb	%dil, %dil
	je	.L86
	movq	24(%rsp), %rdx
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L87:
	cmpl	%eax, %r14d
	jle	.L86
	movl	(%r12,%rax,4), %edx
	incq	%rax
	addq	%rdx, %rbp
	jmp	.L87
.L86:
	movslq	%r13d, %r15
	movq	(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	salq	$2, %r15
	movq	%r15, %rdx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	72(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rsi
	movq	80(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%r14d, 96(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	$134217731, %edx
	movl	$1, %ecx
	movl	$1, 116(%rsp)
	movq	%rax, 100(%rsp)
	movq	96(%rsp), %rdi
	salq	$5, %rdx
	movl	104(%rsp), %esi
	movq	%rdx, 108(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L89
	movl	36(%rsp), %eax
	movl	%ebx, %esi
	movl	%ebx, %edi
	subl	%eax, %esi
	pushq	%rax
	.cfi_def_cfa_offset 712
	pushq	%r13
	.cfi_def_cfa_offset 720
	movq	104(%rsp), %r9
	movq	96(%rsp), %r8
	movq	88(%rsp), %rcx
	movq	80(%rsp), %rdx
	call	_Z59__device_stub__Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_iiiPjS_S_S_i
	popq	%rdx
	.cfi_def_cfa_offset 712
	popq	%rcx
	.cfi_def_cfa_offset 704
.L89:
	movq	24(%rsp), %rdx
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L90:
	cmpl	%eax, %r14d
	jle	.L75
	movl	(%r12,%rax,4), %edx
	incq	%rax
	addq	%rdx, %rbp
	jmp	.L90
.L75:
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	8(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	16(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	%r12, %rdi
	call	_ZdaPv@PLT
	jmp	.L53
.L95:
	xorl	%ebp, %ebp
	jmp	.L53
.L96:
	movl	%edi, %r15d
	jmp	.L67
.L97:
	movl	%esi, %r15d
	jmp	.L85
.L53:
	movq	632(%rsp), %rax
	subq	%fs:40, %rax
	je	.L94
.L115:
	call	__stack_chk_fail@PLT
.L94:
	addq	$648, %rsp
	.cfi_def_cfa_offset 56
	movq	%rbp, %rax
	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
.LFE2030:
	.size	_Z17solve_nqueen_cudaii, .-_Z17solve_nqueen_cudaii
	.section	.rodata.str1.1
.LC2:
	.string	"Usage: %s [-c|-g] n steps\n"
.LC3:
	.string	"  -c: CPU only\n"
.LC4:
	.string	"  -g: GPU only\n"
.LC5:
	.string	"Default to 8 queen\n"
.LC6:
	.string	" N:          Total        Unique                 dd:hh:mm:ss.ms"
.LC7:
	.string	"%s\n"
.LC8:
	.string	"%2d:%18llu%18llu%12.2d:%02d:%02d:%02d.%02d\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	decl	%edi
	jle	.L120
	movq	8(%rsi), %rax
	cmpb	$45, (%rax)
	jne	.L121
	movb	1(%rax), %al
	xorl	%ebp, %ebp
	andl	$-33, %eax
	cmpb	$67, %al
	je	.L122
	cmpb	$71, %al
	je	.L123
.L121:
	movb	$1, %bpl
.L122:
	leaq	.LC6(%rip), %rdx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$4, %ebx
	leaq	.LC8(%rip), %r12
.L126:
	xorl	%esi, %esi
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	movl	%ebx, %edi
	call	_Z25solve_nqueen_nonRecursivei
	xorl	%esi, %esi
	leaq	24(%rsp), %rdi
	movq	%rax, %r13
	call	gettimeofday@PLT
	movq	32(%rsp), %rcx
	movq	16(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	8(%rsp), %r8
	cmpq	%rdi, %rcx
	jge	.L124
	leal	-1(%rsi), %eax
	movl	$86400, %r9d
	subq	%rdi, %rcx
	subl	%r8d, %eax
	addq	$1000500, %rcx
	cltd
	idivl	%r9d
	movl	%eax, %r9d
	movq	%rsi, %rax
	subq	%r8, %rax
	movl	$86400, %r8d
	decq	%rax
	cqto
	idivq	%r8
	movl	%edx, %esi
	jmp	.L147
.L124:
	movl	%esi, %eax
	movl	$86400, %r10d
	subq	%rdi, %rcx
	subl	%r8d, %eax
	addq	$500, %rcx
	cltd
	idivl	%r10d
	movl	%eax, %r9d
	movq	%rsi, %rax
	subq	%r8, %rax
	movl	$86400, %r8d
	cqto
	idivq	%r8
	movl	%edx, %esi
.L147:
	movq	%rcx, %rax
	movl	$10000, %edi
	xorl	%r8d, %r8d
	cqto
	idivq	%rdi
	movl	$3600, %edi
	movq	%rax, %rcx
	movl	%esi, %eax
	cltd
	pushq	%rcx
	.cfi_def_cfa_offset 104
	movl	$60, %ecx
	idivl	%edi
	movl	%eax, %edi
	movl	%esi, %eax
	cltd
	idivl	%ecx
	imull	$-3600, %edi, %eax
	addl	%esi, %eax
	movq	%r12, %rsi
	pushq	%rdx
	.cfi_def_cfa_offset 112
	cltd
	idivl	%ecx
	movl	%ebx, %edx
	movq	%r13, %rcx
	incl	%ebx
	pushq	%rax
	.cfi_def_cfa_offset 120
	xorl	%eax, %eax
	pushq	%rdi
	.cfi_def_cfa_offset 128
	movl	$2, %edi
	call	__printf_chk@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 96
	cmpl	$16, %ebx
	jne	.L126
	testb	%bpl, %bpl
	je	.L127
.L123:
	call	_Z8InitCUDAv
	testb	%al, %al
	je	.L127
	leaq	.LC6(%rip), %rdx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$4, %ebx
	leaq	.LC8(%rip), %rbp
.L131:
	xorl	%esi, %esi
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	movl	$24576, %esi
	movl	%ebx, %edi
	call	_Z17solve_nqueen_cudaii
	xorl	%esi, %esi
	leaq	24(%rsp), %rdi
	movq	%rax, %r12
	call	gettimeofday@PLT
	movq	32(%rsp), %rcx
	movq	16(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	8(%rsp), %r8
	cmpq	%rdi, %rcx
	jge	.L129
	leal	-1(%rsi), %eax
	movl	$86400, %r9d
	subq	%r8, %rsi
	subq	%rdi, %rcx
	subl	%r8d, %eax
	movl	$86400, %r8d
	addq	$1000500, %rcx
	cltd
	idivl	%r9d
	movl	%eax, %r9d
	leaq	-1(%rsi), %rax
	cqto
	idivq	%r8
	movl	%edx, %esi
	jmp	.L148
.L129:
	movl	%esi, %eax
	movl	$86400, %r10d
	subq	%rdi, %rcx
	subl	%r8d, %eax
	addq	$500, %rcx
	cltd
	idivl	%r10d
	movl	%eax, %r9d
	movq	%rsi, %rax
	subq	%r8, %rax
	movl	$86400, %r8d
	cqto
	idivq	%r8
	movl	%edx, %esi
.L148:
	movq	%rcx, %rax
	movl	$10000, %edi
	xorl	%r8d, %r8d
	cqto
	idivq	%rdi
	movl	$3600, %edi
	movq	%rax, %rcx
	movl	%esi, %eax
	cltd
	pushq	%rcx
	.cfi_def_cfa_offset 104
	movl	$60, %ecx
	idivl	%edi
	movl	%eax, %edi
	movl	%esi, %eax
	cltd
	idivl	%ecx
	imull	$-3600, %edi, %eax
	addl	%esi, %eax
	movq	%rbp, %rsi
	pushq	%rdx
	.cfi_def_cfa_offset 112
	cltd
	idivl	%ecx
	movl	%ebx, %edx
	movq	%r12, %rcx
	incl	%ebx
	pushq	%rax
	.cfi_def_cfa_offset 120
	xorl	%eax, %eax
	pushq	%rdi
	.cfi_def_cfa_offset 128
	movl	$2, %edi
	call	__printf_chk@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 96
	cmpl	$18, %ebx
	jne	.L131
.L127:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L134
	call	__stack_chk_fail@PLT
.L120:
	je	.L121
	movq	(%rsi), %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L121
.L134:
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i(%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
.LFE2060:
	.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
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

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


#define THREAD_NUM		96

/** 再帰バージョン 非CUDA
  1. バックトラック
  2. ビットマップ
14:            365596                 0          00:00:00:00.44
15:           2279184                 0          00:00:00:02.81
*/
long long nqInternal(int n,unsigned int left,unsigned int down,unsigned int right) {
  unsigned int msk=(1<<n)-1;
  if(down==msk){return 1;}
	unsigned int bm=(left|down|right);
	if((bm&msk)==msk){return 0;}
	long long total=0;
	unsigned int bit=(bm+1)&~bm;
	while((bit&msk)!=0){
		total+=nqInternal(n,(left|bit)<<1,down|bit,(right|bit)>>1);
		bm|=bit;
		bit=(bm+1)&~bm;
	}
	return total;
}
long long solve_nqueen_recursive(int n){
	return nqInternal(n,0,0,0);
}
/** 非再帰バージョン 非CUDA
  1. バックトラック
  2. ビットマップ
14:            365596                 0          00:00:00:00.22
15:           2279184                 0          00:00:00:01.50
*/
long long solve_nqueen_nonRecursive(int n){
  unsigned int down[32];unsigned int left[32];unsigned int right[32];unsigned int bm[32];
  if(n<=0||n>32){return 0;}
  const unsigned int msk=(1<<n)-1;long long total=0;long long uTotal=0;
  int i=0;int j=0;unsigned int bit;
  down[0]=0;left[0]=0;right[0]=0;bm[0]=0;
  for(j=0;j<(n+1)/2;j++){
    bit=(1<<j);
    bm[0]|=bit;down[1]=bit;left[1]=bit<<1;right[1]=bit>>1;
    bm[1]=(down[1]|left[1]|right[1]);
    i=1;
    if(n%2==1&&j==(n+1)/2-1){uTotal=total;total=0;}
    while(i>0){
      if((bm[i]&msk)==msk){i--;}
      else{
        bit=((bm[i]+1)^bm[i])&~bm[i];
        bm[i]|=bit;
        if((bit&msk)!=0){
          if(i+1==n){total++;i--;}
          else{
            down[i+1]=down[i]|bit;left[i+1]=(left[i]|bit)<<1;right[i+1]=(right[i]|bit)>>1;
            bm[i+1]=(down[i+1]|left[i+1]|right[i+1]);
            i++;
          }
        }else{i--;}
      }
    }
  }
  if(n%2==0){return total*2;}
  else{return uTotal*2+total;}
}
/** CUDA 非再帰バージョン 
  CPUイテレータから複数の初期条件を受け取り、カウント
  1. バックトラック backTrack
  2. ビットマップ   bitmap
14:            365596                 0          00:00:00:00.08
15:           2279184                 0          00:00:00:00.49
*/
__global__ void solve_nqueen_cuda_kernel_bt_bm(
  int n,int mark,
  unsigned int* totalDown,unsigned int* totalLeft,unsigned int* totalRight,
  unsigned int* results,int totalCond){
  const int tid=threadIdx.x,bid=blockIdx.x,idx=bid*blockDim.x+tid;
  __shared__ unsigned int down[THREAD_NUM][10],left[THREAD_NUM][10],right[THREAD_NUM][10],
                          bitmap[THREAD_NUM][10],sum[THREAD_NUM];
  const unsigned int mask=(1<<n)-1;int total=0,i=0;unsigned int bit;
  if(idx<totalCond){
    down[tid][i]=totalDown[idx];
    left[tid][i]=totalLeft[idx];
    right[tid][i]=totalRight[idx];
    bitmap[tid][i]=down[tid][i]|left[tid][i]|right[tid][i];
    while(i>=0){
      if((bitmap[tid][i]&mask)==mask){i--;}
      else{
        bit=(bitmap[tid][i]+1)&~bitmap[tid][i];
        bitmap[tid][i]|=bit;
        if((bit&mask)!=0){
          if(i+1==mark){total++;i--;}
          else{
            down[tid][i+1]=down[tid][i]|bit;
            left[tid][i+1]=(left[tid][i]|bit)<<1;
            right[tid][i+1]=(right[tid][i]|bit)>>1;
            bitmap[tid][i+1]=(down[tid][i+1]|left[tid][i+1]|right[tid][i+1]);
            i++;
          }
        }else{i--;}
      }
    }
    sum[tid]=total;
  }else{sum[tid]=0;} 
  __syncthreads();if(tid<64&&tid+64<THREAD_NUM){sum[tid]+=sum[tid+64];} 
  __syncthreads();if(tid<32){sum[tid]+=sum[tid+32];} 
  __syncthreads();if(tid<16){sum[tid]+=sum[tid+16];} 
  __syncthreads();if(tid<8){sum[tid]+=sum[tid+8];} 
  __syncthreads();if(tid<4){sum[tid]+=sum[tid+4];} 
  __syncthreads();if(tid<2){sum[tid]+=sum[tid+2];} 
  __syncthreads();if(tid<1){sum[tid]+=sum[tid+1];} 
  __syncthreads();if(tid==0){results[bid]=sum[0];}
}
long long solve_nqueen_cuda(int n,int steps) {
  unsigned int down[32];unsigned int left[32];unsigned int right[32];
  unsigned int m[32];unsigned int bit;
  if(n<=0||n>32){return 0;}
  unsigned int* totalDown=new unsigned int[steps];
  unsigned int* totalLeft=new unsigned int[steps];
  unsigned int* totalRight=new unsigned int[steps];
  unsigned int* results=new unsigned int[steps];
  unsigned int* downCuda;unsigned int* leftCuda;unsigned int* rightCuda;
  unsigned int* resultsCuda;
  hipMalloc((void**) &downCuda,sizeof(int)*steps);
  hipMalloc((void**) &leftCuda,sizeof(int)*steps);
  hipMalloc((void**) &rightCuda,sizeof(int)*steps);
  hipMalloc((void**) &resultsCuda,sizeof(int)*steps/THREAD_NUM);
  const unsigned int mask=(1<<n)-1;
  const unsigned int mark=n>11?n-10:2;
  long long total=0;int totalCond=0;
  int i=0,j;down[0]=0;left[0]=0;right[0]=0;m[0]=0;bool computed=false;
  for(j=0;j<n/2;j++){
    bit=(1<<j);m[0]|=bit;
    down[1]=bit;left[1]=bit<<1;right[1]=bit>>1;
    m[1]=(down[1]|left[1]|right[1]);
    i=1;
    while(i>0){
      if((m[i]&mask)==mask){i--;}
      else{
        bit=(m[i]+1)&~m[i];m[i]|=bit;
        if((bit&mask)!=0){
          down[i+1]=down[i]|bit;left[i+1]=(left[i]|bit)<<1;right[i+1]=(right[i]|bit)>>1;
          m[i+1]=(down[i+1]|left[i+1]|right[i+1]);
          i++;
          if(i==mark){
            totalDown[totalCond]=down[i];totalLeft[totalCond]=left[i];totalRight[totalCond]=right[i];
            totalCond++;
            if(totalCond==steps){
              if(computed){
                hipMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,hipMemcpyDeviceToHost);
                for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
                computed=false;
              }
              hipMemcpy(downCuda,totalDown,sizeof(int)*totalCond,hipMemcpyHostToDevice);
              hipMemcpy(leftCuda,totalLeft,sizeof(int)*totalCond,hipMemcpyHostToDevice);
              hipMemcpy(rightCuda,totalRight,sizeof(int)*totalCond,hipMemcpyHostToDevice);
              /** backTrack+bitmap*/
              solve_nqueen_cuda_kernel_bt_bm<<<steps/THREAD_NUM,THREAD_NUM>>>(n,n-mark,downCuda,leftCuda,rightCuda,resultsCuda,totalCond);
              computed=true;totalCond=0;
            }
            i--;
          }
        }else{i --;}
      }
    }
  }
  if(computed){
    hipMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,hipMemcpyDeviceToHost);
    for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
    computed=false;
  }
  hipMemcpy(downCuda,totalDown,sizeof(int)*totalCond,hipMemcpyHostToDevice);
  hipMemcpy(leftCuda,totalLeft,sizeof(int)*totalCond,hipMemcpyHostToDevice);
  hipMemcpy(rightCuda,totalRight,sizeof(int)*totalCond,hipMemcpyHostToDevice);
  /** backTrack+bitmap*/
  solve_nqueen_cuda_kernel_bt_bm<<<steps/THREAD_NUM,THREAD_NUM>>>(n,n-mark,downCuda,leftCuda,rightCuda,resultsCuda,totalCond);
  hipMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,hipMemcpyDeviceToHost);
  for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}	
  total*=2;
  if(n%2==1){
    computed=false;totalCond=0;bit=(1<<(n-1)/2);m[0]|=bit;
    down[1]=bit;left[1]=bit<<1;right[1]=bit>>1;
    m[1]=(down[1]|left[1]|right[1]);
    i=1;
    while(i>0){
      if((m[i]&mask)==mask){i--;}
      else{
        bit=(m[i]+1)&~m[i];m[i]|=bit;
        if((bit&mask)!=0){
          down[i+1]=down[i]|bit;left[i+1]=(left[i]|bit)<<1;right[i+1]=(right[i]|bit)>>1;
          m[i+1]=(down[i+1]|left[i+1]|right[i+1]);
          i++;
          if(i==mark){
            totalDown[totalCond]=down[i];totalLeft[totalCond]=left[i];totalRight[totalCond]=right[i];
            totalCond++;
            if(totalCond==steps){
              if(computed){
                hipMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,hipMemcpyDeviceToHost);
                for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
                computed=false;
              }
              hipMemcpy(downCuda,totalDown,sizeof(int)*totalCond,hipMemcpyHostToDevice);
              hipMemcpy(leftCuda,totalLeft,sizeof(int)*totalCond,hipMemcpyHostToDevice);
              hipMemcpy(rightCuda,totalRight,sizeof(int)*totalCond,hipMemcpyHostToDevice);
              /** backTrack+bitmap*/
              solve_nqueen_cuda_kernel_bt_bm<<<steps/THREAD_NUM,THREAD_NUM>>>(n,n-mark,downCuda,leftCuda,rightCuda,resultsCuda,totalCond);
              computed=true;totalCond=0;
            }
            i--;
          }
        }else{i --;}
      }
    }
    if(computed){
      hipMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,hipMemcpyDeviceToHost);
      for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
      computed=false;
    }
    hipMemcpy(downCuda,totalDown,sizeof(int)*totalCond,hipMemcpyHostToDevice);
    hipMemcpy(leftCuda,totalLeft,sizeof(int)*totalCond,hipMemcpyHostToDevice);
    hipMemcpy(rightCuda,totalRight,sizeof(int)*totalCond,hipMemcpyHostToDevice);
    /** backTrack+bitmap*/
    solve_nqueen_cuda_kernel_bt_bm<<<steps/THREAD_NUM,THREAD_NUM>>>(n,n-mark,downCuda,leftCuda,rightCuda,resultsCuda,totalCond);
    hipMemcpy(results,resultsCuda,sizeof(int)*steps/THREAD_NUM,hipMemcpyDeviceToHost);
    for(int j=0;j<steps/THREAD_NUM;j++){total+=results[j];}
  }
  hipFree(downCuda);hipFree(leftCuda);hipFree(rightCuda);hipFree(resultsCuda);
  delete[] totalDown;delete[] totalLeft;delete[] totalRight;delete[] results;
  return total;
}
/** CUDA 初期化 **/
bool InitCUDA(){
  int count;
  hipGetDeviceCount(&count);
  if(count==0){fprintf(stderr,"There is no device.\n");return false;}
  int i;
  for(i=0;i<count;i++){
    hipDeviceProp_t prop;
    if(hipGetDeviceProperties(&prop,i)==hipSuccess){if(prop.major>=1){break;} }
  }
  if(i==count){fprintf(stderr,"There is no device supporting CUDA 1.x.\n");return false;}
  hipSetDevice(i);
  return true;
}
int main(int argc,char** argv) {
  long long solution;
  bool cpu=true,gpu=true;
  int argstart=1,steps=24576;
  /** パラメータの処理 */
  if(argc>=2&&argv[1][0]=='-'){
    if(argv[1][1]=='c'||argv[1][1]=='C'){gpu=false;}
    else if(argv[1][1]=='g'||argv[1][1]=='G'){cpu=false;}
    argstart=2;
  }
  if(argc<argstart){
    printf("Usage: %s [-c|-g] n steps\n",argv[0]);
    printf("  -c: CPU only\n");
    printf("  -g: GPU only\n");
    printf("Default to 8 queen\n");
  }
  /** 出力と実行 */
  /** CPU */
  if(cpu){
    int min=4;int targetN=15;
    struct timeval t0;struct timeval t1;int ss;int ms;int dd;
    printf("%s\n"," N:          Total        Unique                 dd:hh:mm:ss.ms");
    for(int i=min;i<=targetN;i++){
      gettimeofday(&t0,NULL);   // 計測開始
      /** 再帰 */
      /* solution=solve_nqueen_recursive(i);*/
      /** 非再帰 */
      solution=solve_nqueen_nonRecursive(i);
      gettimeofday(&t1,NULL);   // 計測終了
      if (t1.tv_usec<t0.tv_usec) {
        dd=(int)(t1.tv_sec-t0.tv_sec-1)/86400;
        ss=(t1.tv_sec-t0.tv_sec-1)%86400;
        ms=(1000000+t1.tv_usec-t0.tv_usec+500)/10000;
      } else {
        dd=(int)(t1.tv_sec-t0.tv_sec)/86400;
        ss=(t1.tv_sec-t0.tv_sec)%86400;
        ms=(t1.tv_usec-t0.tv_usec+500)/10000;
      }
      int hh=ss/3600;
      int mm=(ss-hh*3600)/60;
      ss%=60;
      long lGUnique=0;
      printf("%2d:%18llu%18llu%12.2d:%02d:%02d:%02d.%02d\n", i,(unsigned long long)solution,(unsigned long long)lGUnique,dd,hh,mm,ss,ms);
    }
  }
  /** GPU */
  if(gpu){
    if(!InitCUDA()){return 0;}
    int min=4;int targetN=17;
    struct timeval t0;struct timeval t1;int ss;int ms;int dd;
    printf("%s\n"," N:          Total        Unique                 dd:hh:mm:ss.ms");
    for(int i=min;i<=targetN;i++){
      gettimeofday(&t0,NULL);   // 計測開始
      solution=solve_nqueen_cuda(i,steps);
      gettimeofday(&t1,NULL);   // 計測終了
      if (t1.tv_usec<t0.tv_usec) {
        dd=(int)(t1.tv_sec-t0.tv_sec-1)/86400;
        ss=(t1.tv_sec-t0.tv_sec-1)%86400;
        ms=(1000000+t1.tv_usec-t0.tv_usec+500)/10000;
      } else {
        dd=(int)(t1.tv_sec-t0.tv_sec)/86400;
        ss=(t1.tv_sec-t0.tv_sec)%86400;
        ms=(t1.tv_usec-t0.tv_usec+500)/10000;
      }
      int hh=ss/3600;
      int mm=(ss-hh*3600)/60;
      ss%=60;
      long lGUnique=0;
      printf("%2d:%18llu%18llu%12.2d:%02d:%02d:%02d.%02d\n", i,(unsigned long long)solution,(unsigned long long)lGUnique,dd,hh,mm,ss,ms);
    }
  }
  return 0;
}

	.text
	.file	"07_58cuda_queens.hip"
	.globl	_Z10nqInternalijjj              # -- Begin function _Z10nqInternalijjj
	.type	_Z10nqInternalijjj,@function
_Z10nqInternalijjj:                     # @_Z10nqInternalijjj
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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	%ecx, %r14d
	movl	%edx, %r13d
	movl	%edi, %ebp
	movl	$-1, %edx
	movl	%ebp, %ecx
	shll	%cl, %edx
	notl	%edx
	movl	$1, %r12d
	cmpl	%r13d, %edx
	je	.LBB0_6
# %bb.1:
	movl	%esi, %ecx
	movl	%r13d, %ebx
	orl	%esi, %ebx
	orl	%r14d, %ebx
	movl	%ebx, %eax
	notl	%eax
	testl	%eax, %edx
	je	.LBB0_2
# %bb.3:
	leal	1(%rbx), %r15d
	andl	%eax, %r15d
	testl	%edx, %r15d
	je	.LBB0_2
# %bb.4:                                # %.lr.ph.preheader
	xorl	%r12d, %r12d
	movl	%edx, 4(%rsp)                   # 4-byte Spill
	movl	%ecx, (%rsp)                    # 4-byte Spill
.LBB0_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, %esi
	orl	%ecx, %esi
	addl	%esi, %esi
	movl	%r15d, %edx
	orl	%r13d, %edx
	movl	%r15d, %ecx
	orl	%r14d, %ecx
	shrl	%ecx
	movl	%ebp, %edi
	callq	_Z10nqInternalijjj
	movl	(%rsp), %ecx                    # 4-byte Reload
	movl	4(%rsp), %edx                   # 4-byte Reload
	addq	%rax, %r12
	orl	%r15d, %ebx
	leal	1(%rbx), %eax
	movl	%ebx, %r15d
	notl	%r15d
	andl	%eax, %r15d
	testl	%edx, %r15d
	jne	.LBB0_5
	jmp	.LBB0_6
.LBB0_2:
	xorl	%r12d, %r12d
.LBB0_6:                                # %.loopexit
	movq	%r12, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z10nqInternalijjj, .Lfunc_end0-_Z10nqInternalijjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z22solve_nqueen_recursivei     # -- Begin function _Z22solve_nqueen_recursivei
	.type	_Z22solve_nqueen_recursivei,@function
_Z22solve_nqueen_recursivei:            # @_Z22solve_nqueen_recursivei
	.cfi_startproc
# %bb.0:
	xorl	%esi, %esi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	jmp	_Z10nqInternalijjj              # TAILCALL
.Lfunc_end1:
	.size	_Z22solve_nqueen_recursivei, .Lfunc_end1-_Z22solve_nqueen_recursivei
	.cfi_endproc
                                        # -- End function
	.globl	_Z25solve_nqueen_nonRecursivei  # -- Begin function _Z25solve_nqueen_nonRecursivei
	.type	_Z25solve_nqueen_nonRecursivei,@function
_Z25solve_nqueen_nonRecursivei:         # @_Z25solve_nqueen_nonRecursivei
	.cfi_startproc
# %bb.0:
                                        # kill: def $edi killed $edi def $rdi
	leal	-33(%rdi), %ecx
	xorl	%eax, %eax
	cmpl	$-32, %ecx
	jb	.LBB2_11
# %bb.1:                                # %.lr.ph
	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	$392, %rsp                      # imm = 0x188
	.cfi_def_cfa_offset 448
	.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	$-1, %edx
	movl	%edi, %ecx
	shll	%cl, %edx
	notl	%edx
	leal	1(%rdi), %esi
	shrl	%esi
	leal	-1(%rsi), %r8d
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.LBB2_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
	movl	$1, %r11d
	movl	%eax, %ecx
	shll	%cl, %r11d
	movl	$1, %ebx
	movl	%r11d, 260(%rsp)
	movl	$2, %ebp
	shll	%cl, %ebp
	movl	%ebp, 132(%rsp)
	shrl	%r11d
	movl	%r11d, 4(%rsp)
	movl	$3, %ebp
	shll	%cl, %ebp
	orl	%r11d, %ebp
	movl	%ebp, -124(%rsp)
	cmpl	%r8d, %eax
	sete	%r11b
	andb	%dil, %r11b
	movl	$0, %ecx
	cmoveq	%r10, %rcx
.LBB2_3:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebx, %r14d
	movl	-128(%rsp,%r14,4), %ebx
	movl	%ebx, %ebp
	notl	%ebp
	testl	%ebp, %edx
	je	.LBB2_7
# %bb.4:                                #   in Loop: Header=BB2_3 Depth=2
	leal	1(%rbx), %r15d
	andl	%r15d, %ebp
	orl	%ebx, %r15d
	movl	%r15d, -128(%rsp,%r14,4)
	testl	%edx, %ebp
	je	.LBB2_7
# %bb.5:                                #   in Loop: Header=BB2_3 Depth=2
	leal	1(%r14), %ebx
	cmpl	%edi, %ebx
	jne	.LBB2_12
# %bb.6:                                #   in Loop: Header=BB2_3 Depth=2
	incq	%rcx
.LBB2_7:                                #   in Loop: Header=BB2_3 Depth=2
	decl	%r14d
	movl	%r14d, %ebx
.LBB2_8:                                #   in Loop: Header=BB2_3 Depth=2
	testl	%ebx, %ebx
	jg	.LBB2_3
	jmp	.LBB2_9
.LBB2_12:                               #   in Loop: Header=BB2_3 Depth=2
	movl	256(%rsp,%r14,4), %r15d
	orl	%ebp, %r15d
	movl	%ebx, %r12d
	movl	%r15d, 256(%rsp,%r12,4)
	movl	128(%rsp,%r14,4), %r13d
	orl	%ebp, %r13d
	addl	%r13d, %r13d
	movl	%r13d, 128(%rsp,%r12,4)
	orl	(%rsp,%r14,4), %ebp
	shrl	%ebp
	movl	%ebp, (%rsp,%r12,4)
	orl	%r15d, %r13d
	orl	%ebp, %r13d
	movl	%r13d, -128(%rsp,%r12,4)
	jmp	.LBB2_8
.LBB2_9:                                #   in Loop: Header=BB2_2 Depth=1
	testb	%r11b, %r11b
	cmovneq	%r10, %r9
	incl	%eax
	movq	%rcx, %r10
	cmpl	%esi, %eax
	jne	.LBB2_2
# %bb.10:                               # %._crit_edge
	leaq	(%rcx,%rcx), %rdx
	testb	$1, %dil
	leaq	(%rcx,%r9,2), %rax
	cmoveq	%rdx, %rax
	addq	$392, %rsp                      # imm = 0x188
	.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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB2_11:
	retq
.Lfunc_end2:
	.size	_Z25solve_nqueen_nonRecursivei, .Lfunc_end2-_Z25solve_nqueen_nonRecursivei
	.cfi_endproc
                                        # -- End function
	.globl	_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i # -- Begin function _Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.type	_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i,@function
_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i: # @_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	56(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	32(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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_end3:
	.size	_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i, .Lfunc_end3-_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z17solve_nqueen_cudaii         # -- Begin function _Z17solve_nqueen_cudaii
	.type	_Z17solve_nqueen_cudaii,@function
_Z17solve_nqueen_cudaii:                # @_Z17solve_nqueen_cudaii
	.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	$680, %rsp                      # imm = 0x2A8
	.cfi_def_cfa_offset 736
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
                                        # kill: def $edi killed $edi def $rdi
	leal	-33(%rdi), %eax
	xorl	%ebx, %ebx
	cmpl	$-32, %eax
	jae	.LBB4_2
# %bb.1:
	xorl	%r13d, %r13d
	jmp	.LBB4_62
.LBB4_2:
	movabsq	$4294967392, %r15               # imm = 0x100000060
	movl	%esi, 16(%rsp)                  # 4-byte Spill
	movslq	%esi, %r12
	leaq	(,%r12,4), %r13
	testl	%r12d, %r12d
	movq	%rdi, %rbp
	movq	$-1, %r14
	cmovnsq	%r13, %r14
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	movq	%rbp, %r14
	callq	_Znam
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	leaq	48(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	40(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	movabsq	$-6148914691236517205, %rcx     # imm = 0xAAAAAAAAAAAAAAAB
	movq	%r13, 128(%rsp)                 # 8-byte Spill
	movq	%r13, %rax
	mulq	%rcx
	shrq	$6, %rdx
	leaq	24(%rsp), %rdi
	movq	%rdx, 104(%rsp)                 # 8-byte Spill
	movq	%rdx, %rsi
	callq	hipMalloc
	movl	$-1, %ebp
	movl	%r14d, %ecx
	shll	%cl, %ebp
	notl	%ebp
	leal	-10(%r14), %r10d
	cmpl	$12, %r14d
	movl	$2, %eax
	cmovbl	%eax, %r10d
	movl	%ebx, 544(%rsp)
	movl	%ebx, 416(%rsp)
	movl	%ebx, 288(%rsp)
	cmpl	$2, %r14d
	movl	%r10d, 20(%rsp)                 # 4-byte Spill
	movq	%r14, 96(%rsp)                  # 8-byte Spill
	jae	.LBB4_4
# %bb.3:
	xorl	%r13d, %r13d
	jmp	.LBB4_24
.LBB4_4:                                # %.lr.ph310
	movl	%r14d, %eax
	shrl	%eax
	movl	%eax, 124(%rsp)                 # 4-byte Spill
	movq	%r12, 152(%rsp)                 # 8-byte Spill
	imulq	$715827883, %r12, %rcx          # imm = 0x2AAAAAAB
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$36, %rcx
	movq	%r14, %rax
	movq	%rcx, 144(%rsp)                 # 8-byte Spill
	movq	%rdx, 136(%rsp)                 # 8-byte Spill
	leal	(%rcx,%rdx), %r14d
	leaq	(%r15,%r14), %rcx
	addq	$-96, %rcx
	movq	%rcx, 112(%rsp)                 # 8-byte Spill
                                        # kill: def $eax killed $eax killed $rax
	subl	%r10d, %eax
	movl	%eax, 120(%rsp)                 # 4-byte Spill
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	xorl	%ecx, %ecx
	xorl	%r11d, %r11d
	movl	16(%rsp), %r9d                  # 4-byte Reload
.LBB4_5:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_6 Depth 2
                                        #       Child Loop BB4_13 Depth 3
	movl	$1, %eax
	shll	%cl, %eax
	movl	$2, %edx
	shll	%cl, %edx
	movl	%eax, 548(%rsp)
	movl	%edx, 420(%rsp)
	shrl	%eax
	movl	$3, %edx
	movl	%ecx, 60(%rsp)                  # 4-byte Spill
                                        # kill: def $cl killed $cl killed $ecx
	shll	%cl, %edx
	movl	%eax, 292(%rsp)
	orl	%eax, %edx
	movl	%edx, 164(%rsp)
	movl	$1, %r12d
.LBB4_6:                                #   Parent Loop BB4_5 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_13 Depth 3
	movl	%r12d, %ecx
	movl	160(%rsp,%rcx,4), %edx
	movl	%edx, %eax
	notl	%eax
	testl	%eax, %ebp
	je	.LBB4_17
# %bb.7:                                #   in Loop: Header=BB4_6 Depth=2
	leal	1(%rdx), %esi
	andl	%esi, %eax
	orl	%edx, %esi
	movl	%esi, 160(%rsp,%rcx,4)
	testl	%ebp, %eax
	je	.LBB4_17
# %bb.8:                                #   in Loop: Header=BB4_6 Depth=2
	movl	544(%rsp,%rcx,4), %edx
	orl	%eax, %edx
	leal	1(%r12), %esi
	movl	%edx, 548(%rsp,%rcx,4)
	movl	416(%rsp,%rcx,4), %edi
	orl	%eax, %edi
	addl	%edi, %edi
	orl	288(%rsp,%rcx,4), %eax
	movl	%edi, 420(%rsp,%rcx,4)
	shrl	%eax
	movl	%eax, 292(%rsp,%rcx,4)
	movl	%edi, %r8d
	orl	%edx, %r8d
	orl	%eax, %r8d
	movl	%r8d, 164(%rsp,%rcx,4)
	cmpl	%r10d, %esi
	jne	.LBB4_19
# %bb.9:                                #   in Loop: Header=BB4_6 Depth=2
	movslq	%ebx, %rbx
	movq	88(%rsp), %rcx                  # 8-byte Reload
	movl	%edx, (%rcx,%rbx,4)
	movq	80(%rsp), %rcx                  # 8-byte Reload
	movl	%edi, (%rcx,%rbx,4)
	movq	72(%rsp), %rcx                  # 8-byte Reload
	movl	%eax, (%rcx,%rbx,4)
	incl	%ebx
	cmpl	%r9d, %ebx
	jne	.LBB4_18
# %bb.10:                               #   in Loop: Header=BB4_6 Depth=2
	testb	$1, %r11b
	je	.LBB4_14
# %bb.11:                               #   in Loop: Header=BB4_6 Depth=2
	movq	24(%rsp), %rsi
	movq	64(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	104(%rsp), %rdx                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$96, 16(%rsp)                   # 4-byte Folded Reload
	jl	.LBB4_14
# %bb.12:                               # %.lr.ph.preheader
                                        #   in Loop: Header=BB4_6 Depth=2
	xorl	%eax, %eax
.LBB4_13:                               # %.lr.ph
                                        #   Parent Loop BB4_5 Depth=1
                                        #     Parent Loop BB4_6 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%rbx,%rax,4), %ecx
	addq	%rcx, %r13
	incq	%rax
	cmpq	%rax, %r14
	jne	.LBB4_13
.LBB4_14:                               # %.loopexit299
                                        #   in Loop: Header=BB4_6 Depth=2
	movq	48(%rsp), %rdi
	movq	88(%rsp), %rsi                  # 8-byte Reload
	movq	128(%rsp), %rbx                 # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	movq	80(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	xorl	%ebx, %ebx
	movq	112(%rsp), %rdi                 # 8-byte Reload
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	movb	$1, %r11b
	testl	%eax, %eax
	je	.LBB4_20
# %bb.15:                               #   in Loop: Header=BB4_6 Depth=2
	movl	16(%rsp), %r9d                  # 4-byte Reload
	jmp	.LBB4_16
.LBB4_17:                               #   in Loop: Header=BB4_6 Depth=2
	decl	%r12d
.LBB4_18:                               #   in Loop: Header=BB4_6 Depth=2
	testl	%r12d, %r12d
	jg	.LBB4_6
	jmp	.LBB4_21
.LBB4_19:                               #   in Loop: Header=BB4_6 Depth=2
	movl	%esi, %r12d
	jmp	.LBB4_18
.LBB4_20:                               #   in Loop: Header=BB4_6 Depth=2
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rcx
	movq	32(%rsp), %r8
	movq	24(%rsp), %r9
	movl	16(%rsp), %r15d                 # 4-byte Reload
	movl	%r15d, (%rsp)
	movq	96(%rsp), %rdi                  # 8-byte Reload
                                        # kill: def $edi killed $edi killed $rdi
	movl	120(%rsp), %esi                 # 4-byte Reload
	callq	_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	movb	$1, %r11b
	movl	%r15d, %r9d
	movabsq	$4294967392, %r15               # imm = 0x100000060
.LBB4_16:                               #   in Loop: Header=BB4_6 Depth=2
	movl	20(%rsp), %r10d                 # 4-byte Reload
	jmp	.LBB4_18
.LBB4_21:                               #   in Loop: Header=BB4_5 Depth=1
	movl	60(%rsp), %ecx                  # 4-byte Reload
	incl	%ecx
	cmpl	124(%rsp), %ecx                 # 4-byte Folded Reload
	jne	.LBB4_5
# %bb.22:                               # %._crit_edge
	testb	$1, %r11b
	jne	.LBB4_25
# %bb.23:
	movq	96(%rsp), %r14                  # 8-byte Reload
	movq	152(%rsp), %r12                 # 8-byte Reload
.LBB4_24:                               # %._crit_edge..loopexit298_crit_edge
	imulq	$715827883, %r12, %r12          # imm = 0x2AAAAAAB
	movq	%r12, %rax
	shrq	$63, %rax
	sarq	$36, %r12
	addl	%eax, %r12d
	jmp	.LBB4_29
.LBB4_25:
	movq	24(%rsp), %rsi
	movq	64(%rsp), %rdi                  # 8-byte Reload
	movq	104(%rsp), %rdx                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movq	144(%rsp), %r12                 # 8-byte Reload
	addl	136(%rsp), %r12d                # 4-byte Folded Reload
	cmpl	$96, 16(%rsp)                   # 4-byte Folded Reload
	jl	.LBB4_28
# %bb.26:                               # %.lr.ph318.preheader
	movl	%r12d, %eax
	xorl	%ecx, %ecx
	movq	64(%rsp), %rsi                  # 8-byte Reload
.LBB4_27:                               # %.lr.ph318
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rsi,%rcx,4), %edx
	addq	%rdx, %r13
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB4_27
.LBB4_28:
	movq	96(%rsp), %r14                  # 8-byte Reload
.LBB4_29:                               # %.loopexit298
	movq	48(%rsp), %rdi
	movslq	%ebx, %r15
	shlq	$2, %r15
	movq	88(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	movq	80(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%r12d, %r15d
	movabsq	$4294967392, %rdx               # imm = 0x100000060
	leaq	(%rdx,%r15), %rdi
	addq	$-96, %rdi
	movq	%rdi, 112(%rsp)                 # 8-byte Spill
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_31
# %bb.30:
	movl	%r14d, %esi
	subl	20(%rsp), %esi                  # 4-byte Folded Reload
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rcx
	movq	32(%rsp), %r8
	movq	24(%rsp), %r9
	movl	%ebx, (%rsp)
	movl	%r14d, %edi
	callq	_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
.LBB4_31:
	movq	24(%rsp), %rsi
	movq	64(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	104(%rsp), %rdx                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movl	16(%rsp), %r9d                  # 4-byte Reload
	cmpl	$96, %r9d
	jl	.LBB4_34
# %bb.32:                               # %.lr.ph323.preheader
	xorl	%eax, %eax
	movl	20(%rsp), %r10d                 # 4-byte Reload
.LBB4_33:                               # %.lr.ph323
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%rax,4), %ecx
	addq	%rcx, %r13
	incq	%rax
	cmpq	%rax, %r15
	jne	.LBB4_33
	jmp	.LBB4_35
.LBB4_34:
	movl	20(%rsp), %r10d                 # 4-byte Reload
.LBB4_35:                               # %._crit_edge324
	addq	%r13, %r13
	testb	$1, %r14b
	je	.LBB4_61
# %bb.36:
	leal	-1(%r14), %ecx
	shrl	%ecx
	movl	$1, %eax
	shll	%cl, %eax
	movl	$2, %edx
	shll	%cl, %edx
	movl	$1, %ebx
	movl	%eax, 548(%rsp)
	movl	%edx, 420(%rsp)
	movl	$3, %edx
                                        # kill: def $cl killed $cl killed $ecx
	shll	%cl, %edx
	shrl	%eax
	movl	%eax, 292(%rsp)
	orl	%eax, %edx
	movl	%edx, 164(%rsp)
	movq	%r14, %r12
	movl	%r14d, %eax
	subl	%r10d, %eax
	movl	%eax, 60(%rsp)                  # 4-byte Spill
	xorl	%r14d, %r14d
	xorl	%r11d, %r11d
.LBB4_37:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_44 Depth 2
	movl	%ebx, %ecx
	movl	160(%rsp,%rcx,4), %edx
	movl	%edx, %eax
	notl	%eax
	testl	%eax, %ebp
	je	.LBB4_48
# %bb.38:                               #   in Loop: Header=BB4_37 Depth=1
	leal	1(%rdx), %esi
	andl	%esi, %eax
	orl	%edx, %esi
	movl	%esi, 160(%rsp,%rcx,4)
	testl	%ebp, %eax
	je	.LBB4_48
# %bb.39:                               #   in Loop: Header=BB4_37 Depth=1
	movl	544(%rsp,%rcx,4), %edx
	orl	%eax, %edx
	leal	1(%rbx), %esi
	movl	%edx, 548(%rsp,%rcx,4)
	movl	416(%rsp,%rcx,4), %edi
	orl	%eax, %edi
	addl	%edi, %edi
	orl	288(%rsp,%rcx,4), %eax
	movl	%edi, 420(%rsp,%rcx,4)
	shrl	%eax
	movl	%eax, 292(%rsp,%rcx,4)
	movl	%edi, %r8d
	orl	%edx, %r8d
	orl	%eax, %r8d
	movl	%r8d, 164(%rsp,%rcx,4)
	cmpl	%r10d, %esi
	jne	.LBB4_50
# %bb.40:                               #   in Loop: Header=BB4_37 Depth=1
	movslq	%r14d, %r14
	movq	88(%rsp), %rcx                  # 8-byte Reload
	movl	%edx, (%rcx,%r14,4)
	movq	80(%rsp), %rcx                  # 8-byte Reload
	movl	%edi, (%rcx,%r14,4)
	movq	72(%rsp), %rcx                  # 8-byte Reload
	movl	%eax, (%rcx,%r14,4)
	incl	%r14d
	cmpl	%r9d, %r14d
	jne	.LBB4_49
# %bb.41:                               #   in Loop: Header=BB4_37 Depth=1
	testb	$1, %r11b
	je	.LBB4_45
# %bb.42:                               #   in Loop: Header=BB4_37 Depth=1
	movq	24(%rsp), %rsi
	movq	64(%rsp), %rdi                  # 8-byte Reload
	movq	104(%rsp), %rdx                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$96, 16(%rsp)                   # 4-byte Folded Reload
	jl	.LBB4_45
# %bb.43:                               # %.lr.ph329.preheader
                                        #   in Loop: Header=BB4_37 Depth=1
	xorl	%eax, %eax
	movq	64(%rsp), %rdx                  # 8-byte Reload
.LBB4_44:                               # %.lr.ph329
                                        #   Parent Loop BB4_37 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rdx,%rax,4), %ecx
	addq	%rcx, %r13
	incq	%rax
	cmpq	%rax, %r15
	jne	.LBB4_44
.LBB4_45:                               # %.loopexit297
                                        #   in Loop: Header=BB4_37 Depth=1
	movq	48(%rsp), %rdi
	movq	88(%rsp), %rsi                  # 8-byte Reload
	movq	128(%rsp), %r14                 # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	movq	80(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	xorl	%r14d, %r14d
	movq	112(%rsp), %rdi                 # 8-byte Reload
	movl	$1, %esi
	movabsq	$4294967392, %rdx               # imm = 0x100000060
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	movb	$1, %r11b
	testl	%eax, %eax
	je	.LBB4_51
# %bb.46:                               #   in Loop: Header=BB4_37 Depth=1
	movl	16(%rsp), %r9d                  # 4-byte Reload
	jmp	.LBB4_47
.LBB4_48:                               #   in Loop: Header=BB4_37 Depth=1
	decl	%ebx
.LBB4_49:                               #   in Loop: Header=BB4_37 Depth=1
	testl	%ebx, %ebx
	jg	.LBB4_37
	jmp	.LBB4_52
.LBB4_50:                               #   in Loop: Header=BB4_37 Depth=1
	movl	%esi, %ebx
	jmp	.LBB4_49
.LBB4_51:                               #   in Loop: Header=BB4_37 Depth=1
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rcx
	movq	32(%rsp), %r8
	movq	24(%rsp), %r9
	movl	16(%rsp), %r12d                 # 4-byte Reload
	movl	%r12d, (%rsp)
	movq	96(%rsp), %rdi                  # 8-byte Reload
                                        # kill: def $edi killed $edi killed $rdi
	movl	60(%rsp), %esi                  # 4-byte Reload
	callq	_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	movb	$1, %r11b
	movl	%r12d, %r9d
	movq	96(%rsp), %r12                  # 8-byte Reload
.LBB4_47:                               #   in Loop: Header=BB4_37 Depth=1
	movl	20(%rsp), %r10d                 # 4-byte Reload
	jmp	.LBB4_49
.LBB4_52:
	testb	$1, %r11b
	je	.LBB4_56
# %bb.53:
	movq	24(%rsp), %rsi
	movq	64(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	104(%rsp), %rdx                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$96, 16(%rsp)                   # 4-byte Folded Reload
	jl	.LBB4_56
# %bb.54:                               # %.lr.ph338.preheader
	xorl	%eax, %eax
.LBB4_55:                               # %.lr.ph338
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%rax,4), %ecx
	addq	%rcx, %r13
	incq	%rax
	cmpq	%rax, %r15
	jne	.LBB4_55
.LBB4_56:                               # %.loopexit296
	movq	48(%rsp), %rdi
	movslq	%r14d, %rbx
	shlq	$2, %rbx
	movq	88(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	movq	80(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	112(%rsp), %rdi                 # 8-byte Reload
	movl	$1, %esi
	movabsq	$4294967392, %rdx               # imm = 0x100000060
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_58
# %bb.57:
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rcx
	movq	32(%rsp), %r8
	movq	24(%rsp), %r9
	movl	%r14d, (%rsp)
	movl	%r12d, %edi
	movl	60(%rsp), %esi                  # 4-byte Reload
	callq	_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
.LBB4_58:
	movq	24(%rsp), %rsi
	movq	64(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	104(%rsp), %rdx                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$96, 16(%rsp)                   # 4-byte Folded Reload
	jl	.LBB4_61
# %bb.59:                               # %.lr.ph343.preheader
	xorl	%eax, %eax
.LBB4_60:                               # %.lr.ph343
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%rax,4), %ecx
	addq	%rcx, %r13
	incq	%rax
	cmpq	%rax, %r15
	jne	.LBB4_60
.LBB4_61:                               # %.loopexit
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	88(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	80(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	72(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	%rbx, %rdi
	callq	_ZdaPv
.LBB4_62:
	movq	%r13, %rax
	addq	$680, %rsp                      # imm = 0x2A8
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z17solve_nqueen_cudaii, .Lfunc_end4-_Z17solve_nqueen_cudaii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8InitCUDAv                    # -- Begin function _Z8InitCUDAv
	.type	_Z8InitCUDAv,@function
_Z8InitCUDAv:                           # @_Z8InitCUDAv
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 1504
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leaq	4(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	movl	(%rbx), %ecx
	testl	%ecx, %ecx
	je	.LBB5_3
# %bb.1:                                # %.preheader
	jle	.LBB5_2
# %bb.5:                                # %.lr.ph
	xorl	%ebx, %ebx
	leaq	8(%rsp), %r14
.LBB5_6:                                # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	hipGetDevicePropertiesR0600
	movl	4(%rsp), %ecx
	testl	%eax, %eax
	jne	.LBB5_8
# %bb.7:                                #   in Loop: Header=BB5_6 Depth=1
	cmpl	$0, 368(%rsp)
	jg	.LBB5_9
.LBB5_8:                                #   in Loop: Header=BB5_6 Depth=1
	incl	%ebx
	cmpl	%ecx, %ebx
	jl	.LBB5_6
	jmp	.LBB5_9
.LBB5_2:
	xorl	%ebx, %ebx
.LBB5_9:                                # %._crit_edge
	cmpl	%ecx, %ebx
	je	.LBB5_10
# %bb.11:
	movl	%ebx, %edi
	callq	hipSetDevice
	movb	$1, %al
.LBB5_12:
                                        # kill: def $al killed $al killed $eax
	addq	$1480, %rsp                     # imm = 0x5C8
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB5_3:
	.cfi_def_cfa_offset 1504
	movq	stderr(%rip), %rcx
	movl	$.L.str, %edi
	movl	$20, %esi
	jmp	.LBB5_4
.LBB5_10:
	movq	stderr(%rip), %rcx
	movl	$.L.str.1, %edi
	movl	$40, %esi
.LBB5_4:
	movl	$1, %edx
	callq	fwrite@PLT
	xorl	%eax, %eax
	jmp	.LBB5_12
.Lfunc_end5:
	.size	_Z8InitCUDAv, .Lfunc_end5-_Z8InitCUDAv
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movb	$1, %bl
	movl	$1, %eax
	cmpl	$2, %edi
	jl	.LBB6_6
# %bb.1:
	movq	8(%rsi), %rcx
	cmpb	$45, (%rcx)
	jne	.LBB6_6
# %bb.2:
	movb	1(%rcx), %cl
	addb	$-67, %cl
	rolb	$6, %cl
	movl	$2, %eax
	cmpb	$9, %cl
	ja	.LBB6_6
# %bb.3:
	movzbl	%cl, %ecx
	jmpq	*.LJTI6_0(,%rcx,8)
.LBB6_4:
	xorl	%ebp, %ebp
	jmp	.LBB6_7
.LBB6_5:
	xorl	%ebx, %ebx
.LBB6_6:                                # %.fold.split
	movb	$1, %bpl
.LBB6_7:
	cmpl	%edi, %eax
	jle	.LBB6_9
# %bb.8:
	movq	(%rsi), %rsi
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
.LBB6_9:
	testb	%bl, %bl
	je	.LBB6_13
# %bb.10:
	movl	%ebp, 4(%rsp)                   # 4-byte Spill
	movl	$.L.str.7, %edi
	callq	puts@PLT
	movl	$4, %ebx
	leaq	8(%rsp), %r15
	movabsq	$1749024623285053783, %r13      # imm = 0x1845C8A0CE512957
	movabsq	$3777893186295716171, %rbp      # imm = 0x346DC5D63886594B
.LBB6_11:                               # =>This Inner Loop Header: Depth=1
	leaq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	%ebx, %edi
	callq	_Z25solve_nqueen_nonRecursivei
	movq	%rax, %r12
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	16(%rsp), %rax
	movq	24(%rsp), %rsi
	movq	32(%rsp), %rdi
	leaq	1000000(%rax), %rcx
	movq	%rsi, %rdx
	negq	%rdx
	cmpq	%rdi, %rax
	notq	%rsi
	cmovgeq	%rdx, %rsi
	cmovgeq	%rax, %rcx
	addq	8(%rsp), %rsi
	movq	%rsi, %rax
	imulq	%r13
	movq	%rdx, %rax
	shrq	$63, %rax
	sarq	$13, %rdx
	addq	%rax, %rdx
	imulq	$86400, %rdx, %r9               # imm = 0x15180
	movslq	%esi, %r8
	subq	%rdi, %rcx
	addq	$500, %rcx                      # imm = 0x1F4
	movq	%rcx, %rax
	imulq	%rbp
	movq	%rdx, %r10
	subq	%r9, %rsi
	movq	%rdx, %rax
	shrq	$63, %rax
	shrq	$11, %r10
	addl	%eax, %r10d
	imulq	$-1037155065, %r8, %rax         # imm = 0xC22E4507
	shrq	$32, %rax
	addl	%eax, %r8d
	movl	%r8d, %eax
	shrl	$31, %eax
	sarl	$16, %r8d
	addl	%eax, %r8d
	movslq	%esi, %r11
	imulq	$-1851608123, %r11, %r9         # imm = 0x91A2B3C5
	shrq	$32, %r9
	addl	%r11d, %r9d
	movl	%r9d, %eax
	shrl	$31, %eax
	sarl	$11, %r9d
	addl	%eax, %r9d
	imull	$-3600, %r9d, %eax              # imm = 0xF1F0
	addl	%r11d, %eax
	movslq	%eax, %r14
	imulq	$-2004318071, %r14, %rax        # imm = 0x88888889
	shrq	$32, %rax
	addl	%eax, %r14d
	movl	%r14d, %eax
	shrl	$31, %eax
	sarl	$5, %r14d
	addl	%eax, %r14d
	imulq	$-2004318071, %r11, %rax        # imm = 0x88888889
	shrq	$32, %rax
	addl	%r11d, %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	sarl	$5, %eax
	addl	%ecx, %eax
	imull	$60, %eax, %eax
	subl	%eax, %r11d
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movl	$.L.str.8, %edi
	movl	%ebx, %esi
	movq	%r12, %rdx
	xorl	%ecx, %ecx
                                        # kill: def $r8d killed $r8d killed $r8
                                        # kill: def $r9d killed $r9d killed $r9
	xorl	%eax, %eax
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	callq	printf
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	incl	%ebx
	cmpl	$16, %ebx
	jne	.LBB6_11
# %bb.12:
	movl	4(%rsp), %ebp                   # 4-byte Reload
.LBB6_13:
	testb	%bpl, %bpl
	je	.LBB6_17
# %bb.14:
	callq	_Z8InitCUDAv
	testb	%al, %al
	je	.LBB6_17
# %bb.15:
	movl	$.L.str.7, %edi
	callq	puts@PLT
	movl	$4, %ebx
	leaq	8(%rsp), %r15
	movabsq	$3777893186295716171, %r13      # imm = 0x346DC5D63886594B
	movabsq	$1749024623285053783, %rbp      # imm = 0x1845C8A0CE512957
.LBB6_16:                               # =>This Inner Loop Header: Depth=1
	leaq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	%ebx, %edi
	movl	$24576, %esi                    # imm = 0x6000
	callq	_Z17solve_nqueen_cudaii
	movq	%rax, %r12
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	16(%rsp), %rdx
	movq	24(%rsp), %rcx
	movq	32(%rsp), %rsi
	leaq	1000000(%rdx), %rax
	movq	%rcx, %rdi
	negq	%rdi
	cmpq	%rsi, %rdx
	notq	%rcx
	cmovgeq	%rdi, %rcx
	cmovgeq	%rdx, %rax
	addq	8(%rsp), %rcx
	movslq	%ecx, %r8
	imulq	$-1037155065, %r8, %rdx         # imm = 0xC22E4507
	shrq	$32, %rdx
	addl	%edx, %r8d
	movl	%r8d, %edx
	shrl	$31, %edx
	sarl	$16, %r8d
	addl	%edx, %r8d
	subq	%rsi, %rax
	addq	$500, %rax                      # imm = 0x1F4
	imulq	%r13
	movq	%rdx, %r10
	movq	%rdx, %rax
	shrq	$63, %rax
	shrq	$11, %r10
	addl	%eax, %r10d
	movq	%rcx, %rax
	imulq	%rbp
	movq	%rdx, %rax
	shrq	$63, %rax
	sarq	$13, %rdx
	addq	%rax, %rdx
	imulq	$86400, %rdx, %rax              # imm = 0x15180
	subq	%rax, %rcx
	movslq	%ecx, %r11
	imulq	$-1851608123, %r11, %r9         # imm = 0x91A2B3C5
	shrq	$32, %r9
	addl	%r11d, %r9d
	movl	%r9d, %eax
	shrl	$31, %eax
	sarl	$11, %r9d
	addl	%eax, %r9d
	imull	$-3600, %r9d, %eax              # imm = 0xF1F0
	addl	%r11d, %eax
	movslq	%eax, %r14
	imulq	$-2004318071, %r14, %rax        # imm = 0x88888889
	shrq	$32, %rax
	addl	%eax, %r14d
	movl	%r14d, %eax
	shrl	$31, %eax
	sarl	$5, %r14d
	addl	%eax, %r14d
	imulq	$-2004318071, %r11, %rax        # imm = 0x88888889
	shrq	$32, %rax
	addl	%r11d, %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	sarl	$5, %eax
	addl	%ecx, %eax
	imull	$60, %eax, %eax
	subl	%eax, %r11d
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movl	$.L.str.8, %edi
	movl	%ebx, %esi
	movq	%r12, %rdx
	xorl	%ecx, %ecx
                                        # kill: def $r8d killed $r8d killed $r8
                                        # kill: def $r9d killed $r9d killed $r9
	xorl	%eax, %eax
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	callq	printf
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	incl	%ebx
	cmpl	$18, %ebx
	jne	.LBB6_16
.LBB6_17:
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	main, .Lfunc_end6-main
	.cfi_endproc
	.section	.rodata,"a",@progbits
	.p2align	3, 0x0
.LJTI6_0:
	.quad	.LBB6_4
	.quad	.LBB6_5
	.quad	.LBB6_6
	.quad	.LBB6_6
	.quad	.LBB6_6
	.quad	.LBB6_6
	.quad	.LBB6_6
	.quad	.LBB6_6
	.quad	.LBB6_4
	.quad	.LBB6_5
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i,@object # @_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.p2align	3, 0x0
_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i:
	.quad	_Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.size	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"There is no device.\n"
	.size	.L.str, 21

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"There is no device supporting CUDA 1.x.\n"
	.size	.L.str.1, 41

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Usage: %s [-c|-g] n steps\n"
	.size	.L.str.2, 27

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	" N:          Total        Unique                 dd:hh:mm:ss.ms"
	.size	.L.str.7, 64

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"%2d:%18llu%18llu%12.2d:%02d:%02d:%02d.%02d\n"
	.size	.L.str.8, 44

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i"
	.size	.L__unnamed_1, 46

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"  -c: CPU only"
	.size	.Lstr, 15

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"  -g: GPU only"
	.size	.Lstr.1, 15

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Default to 8 queen"
	.size	.Lstr.2, 19

	.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 _Z45__device_stub__solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i ; -- Begin function _Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.globl	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
	.p2align	8
	.type	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i,@function
_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i: ; @_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
; %bb.0:
	s_clause 0x2
	s_load_b32 s3, s[0:1], 0x3c
	s_load_b32 s12, s[0:1], 0x28
	s_load_b256 s[4:11], s[0:1], 0x8
	s_mov_b32 s2, s15
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[1:2], null, s2, s3, v[0:1]
	v_mov_b32_e32 v2, 0
	s_mov_b32 s3, exec_lo
	v_cmpx_gt_i32_e64 s12, v1
	s_cbranch_execz .LBB0_16
; %bb.1:
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b64 s[0:1], s[0:1], 0x0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	v_add_co_u32 v3, vcc_lo, s4, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v2, vcc_lo
	v_add_co_u32 v5, vcc_lo, s6, v1
	v_add_co_ci_u32_e32 v6, vcc_lo, s7, v2, vcc_lo
	v_add_co_u32 v1, vcc_lo, s8, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s9, v2, vcc_lo
	global_load_b32 v3, v[3:4], off
	global_load_b32 v4, v[5:6], off
	global_load_b32 v5, v[1:2], off
	v_mul_u32_u24_e32 v6, 40, v0
	v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v1, 0
	s_waitcnt lgkmcnt(0)
	s_lshl_b32 s0, -1, s0
	s_mov_b32 s4, 0
	s_not_b32 s0, s0
	s_waitcnt vmcnt(1)
	ds_store_2addr_stride64_b32 v6, v3, v4 offset1:15
	s_waitcnt vmcnt(0)
	v_or3_b32 v7, v4, v3, v5
	ds_store_2addr_stride64_b32 v6, v5, v7 offset0:30 offset1:45
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	v_lshlrev_b32_e32 v3, 2, v1
	s_mov_b32 s5, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_mad_u32_u24 v4, v0, 40, v3
	ds_load_b32 v3, v4 offset:11520
	s_waitcnt lgkmcnt(0)
	v_and_b32_e32 v5, s0, v3
	v_cmpx_ne_u32_e64 s0, v5
	s_xor_b32 s5, exec_lo, s5
	s_cbranch_execz .LBB0_12
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v7, 1, v3
	v_not_b32_e32 v5, v3
	s_mov_b32 s6, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_or_b32_e32 v3, v7, v3
	v_and_b32_e32 v6, v7, v5
	v_add_nc_u32_e32 v5, 0x2d00, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_and_b32_e32 v8, s0, v6
	ds_store_b32 v5, v3
                                        ; implicit-def: $vgpr3
	v_cmpx_ne_u32_e32 0, v8
	s_xor_b32 s6, exec_lo, s6
	s_cbranch_execz .LBB0_9
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v3, 1, v1
	s_mov_b32 s7, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_ne_u32_e64 s1, v3
	s_xor_b32 s7, exec_lo, s7
	s_cbranch_execz .LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_2 Depth=1
	ds_load_2addr_stride64_b32 v[7:8], v4 offset1:15
	ds_load_b32 v1, v4 offset:7680
	s_waitcnt lgkmcnt(1)
	v_or_b32_e32 v8, v8, v6
	s_waitcnt lgkmcnt(0)
	v_or_b32_e32 v1, v1, v6
	v_or_b32_e32 v6, v7, v6
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b32_e32 v7, 1, v8
	v_lshrrev_b32_e32 v1, 1, v1
	v_add_nc_u32_e32 v8, 4, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_or3_b32 v9, v7, v6, v1
	ds_store_2addr_stride64_b32 v8, v6, v7 offset1:15
	ds_store_b32 v4, v1 offset:7684
	ds_store_b32 v5, v9 offset:4
                                        ; implicit-def: $vgpr1
.LBB0_6:                                ; %Flow
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_and_not1_saveexec_b32 s7, s7
; %bb.7:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v2, 1, v2
	v_add_nc_u32_e32 v3, -1, v1
; %bb.8:                                ; %Flow130
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s7
                                        ; implicit-def: $vgpr1
.LBB0_9:                                ; %Flow131
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_and_not1_saveexec_b32 s6, s6
; %bb.10:                               ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v3, -1, v1
; %bb.11:                               ; %Flow132
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s6
	s_delay_alu instid0(VALU_DEP_1)
	v_mov_b32_e32 v1, v3
.LBB0_12:                               ; %Flow133
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_and_not1_saveexec_b32 s5, s5
; %bb.13:                               ;   in Loop: Header=BB0_2 Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v1, -1, v1
; %bb.14:                               ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_i32_e32 vcc_lo, 0, v1
	s_or_b32 s4, vcc_lo, s4
	s_and_not1_b32 exec_lo, exec_lo, s4
	s_cbranch_execnz .LBB0_2
; %bb.15:                               ; %Flow134
	s_or_b32 exec_lo, exec_lo, s4
.LBB0_16:                               ; %Flow135
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	s_or_b32 exec_lo, exec_lo, s3
	v_or_b32_e32 v4, 64, v0
	v_lshlrev_b32_e32 v3, 2, v0
	v_cmp_gt_u32_e32 vcc_lo, 64, v0
	v_cmp_gt_u32_e64 s0, 0x60, v4
	s_delay_alu instid0(VALU_DEP_3)
	v_add_nc_u32_e32 v1, 0x3c00, v3
	ds_store_b32 v3, v2 offset:15360
	s_waitcnt lgkmcnt(0)
	s_barrier
	s_and_b32 s1, vcc_lo, s0
	buffer_gl0_inv
	s_and_saveexec_b32 s0, s1
	s_cbranch_execz .LBB0_18
; %bb.17:
	v_lshlrev_b32_e32 v2, 2, v4
	ds_load_b32 v2, v2 offset:15360
	ds_load_b32 v4, v1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, v4, v2
	ds_store_b32 v1, v2
.LBB0_18:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 32, v0
	s_cbranch_execz .LBB0_20
; %bb.19:
	ds_load_b32 v2, v3 offset:15488
	ds_load_b32 v4, v1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, v4, v2
	ds_store_b32 v1, v2
.LBB0_20:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 16, v0
	s_cbranch_execz .LBB0_22
; %bb.21:
	ds_load_b32 v2, v3 offset:15424
	ds_load_b32 v4, v1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, v4, v2
	ds_store_b32 v1, v2
.LBB0_22:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 8, v0
	s_cbranch_execz .LBB0_24
; %bb.23:
	ds_load_b32 v2, v3 offset:15392
	ds_load_b32 v4, v1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, v4, v2
	ds_store_b32 v1, v2
.LBB0_24:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 4, v0
	s_cbranch_execz .LBB0_26
; %bb.25:
	ds_load_b32 v2, v3 offset:15376
	ds_load_b32 v4, v1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, v4, v2
	ds_store_b32 v1, v2
.LBB0_26:
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s0, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e32 2, v0
	s_cbranch_execz .LBB0_28
; %bb.27:
	ds_load_b32 v2, v3 offset:15368
	ds_load_b32 v3, v1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v2, v3, v2
	ds_store_b32 v1, v2
.LBB0_28:
	s_or_b32 exec_lo, exec_lo, s0
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB0_30
; %bb.29:
	v_mov_b32_e32 v2, 0
	ds_load_b64 v[0:1], v2 offset:15360
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v0, v0, v1
	ds_store_b32 v2, v0 offset:15360
.LBB0_30:
	s_or_b32 exec_lo, exec_lo, s0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB0_32
; %bb.31:
	v_mov_b32_e32 v0, 0
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[0:1], s[2:3], 2
	s_add_u32 s0, s10, s0
	ds_load_b32 v1, v0 offset:15360
	s_addc_u32 s1, s11, s1
	s_waitcnt lgkmcnt(0)
	global_store_b32 v0, v1, s[0:1]
.LBB0_32:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
		.amdhsa_group_segment_fixed_size 15744
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.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 10
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i, .Lfunc_end0-_Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1128
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 15744 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 15744
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z30solve_nqueen_cuda_kernel_bt_bmiiPjS_S_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
