#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>

const int BLOCK_SIZE = 32;
const int THREADS_PER_BLOCK = 512;

void BranchCPU(const ssize_t e, uint32_t* set, const int blockCount, const int k) {
    set[e * blockCount + k / BLOCK_SIZE] |= (((uint32_t)1) << ((uint32_t)(k % BLOCK_SIZE)));
}

void BoundCPU(const ssize_t e, const uint32_t* set, int* flags,
              const int blockCount, const int k, const int n, const int m, const int* exprVar, const int* exprNeg) {
    for (int i = 0; i < m; ++i) {
        int disjunctRes = 0;
        for (int j = 0; j < 3; ++j) {
            int index = exprVar[i * 3 + j];
            if (index > k) {
                disjunctRes = -1;
            } else {
                int elem = (set[e * blockCount + index / BLOCK_SIZE] & (((uint32_t)1) << ((uint32_t)(index % BLOCK_SIZE)))) ? 1 : 0;
                elem ^= exprNeg[i * 3 + j];
                if (elem == 1) {
                    disjunctRes = 1;
                    break;
                }
            }
        }
        if (disjunctRes == 0) {
            flags[e] = 0;
            break;
        }
    }
}

__global__ void BranchGPU(uint32_t* set, const int blockCount, const int k, const ssize_t q) {
    ssize_t e = blockIdx.x * blockDim.x + threadIdx.x;
    if (e >= q) {
    	return;
    }
    set[e * blockCount + k / BLOCK_SIZE] |= (((uint32_t)1) << ((uint32_t)(k % BLOCK_SIZE)));
}

__global__ void BoundGPU(const uint32_t* set, int* flags,
              const int blockCount, const int k, const int n, const int m, const int* exprVar, const int* exprNeg, const ssize_t q) {
    ssize_t e = blockIdx.x * blockDim.x + threadIdx.x;
    if (e >= q) {
    	return;
    }

    for (int i = 0; i < m; ++i) {
        int disjunctRes = 0;
        for (int j = 0; j < 3; ++j) {
            int index = exprVar[i * 3 + j];
            if (index > k) {
                disjunctRes = -1;
            } else {
                int elem = (set[e * blockCount + index / BLOCK_SIZE] & (((uint32_t)1) << ((uint32_t)(index % BLOCK_SIZE)))) ? 1 : 0;
                elem ^= exprNeg[i * 3 + j];
                if (elem == 1) {
                    disjunctRes = 1;
                    break;
                }
            }
        }
        if (disjunctRes == 0) {
            flags[e] = 0;
            break;
        }
    }
}

int main(int argc, char* argv[]) {
    std::chrono::high_resolution_clock::time_point totalStart = std::chrono::high_resolution_clock::now();

    if (argc != 3) {
        std::cerr << "Usage: " << argv[0] << " input_file output_file" << std::endl;
        return 0;
    }

    std::ifstream fin(argv[1]);
    std::ofstream fout(argv[2]);
    
    int n, m;
    fin >> n >> m;
    
    int* exprVar = (int*)malloc(3 * m * sizeof(*exprVar));
    int* exprNeg = (int*)malloc(3 * m * sizeof(*exprNeg));
    int* cudaExprVar = nullptr;
    int* cudaExprNeg = nullptr;
    for (int i = 0; i < m; ++i) {
        fin >> exprVar[3 * i]
            >> exprNeg[3 * i]
            >> exprVar[3 * i + 1]
            >> exprNeg[3 * i + 1]
            >> exprVar[3 * i + 2]
            >> exprNeg[3 * i + 2];
        --exprVar[3 * i];
        --exprVar[3 * i + 1];
        --exprVar[3 * i + 2];
    }

    ssize_t q = 1;

    const int blockCount = (n + BLOCK_SIZE - 1) / BLOCK_SIZE;
    uint32_t* set = (uint32_t*)calloc(q * blockCount, sizeof(*set));
    int* flags = (int*)malloc(q * sizeof(*flags));
    flags[0] = 1;

    for (int k = 0; k < n; ++k) {
        std::cout << "Step " << k + 1 << ", q = " << q << std::endl;
        if (q > 1000) {
            if (cudaExprVar == nullptr) {
                cudaMalloc(&cudaExprVar, 3 * m * sizeof(*exprVar));
                cudaMalloc(&cudaExprNeg, 3 * m * sizeof(*exprNeg));
                cudaMemcpy(cudaExprVar, exprVar, 3 * m * sizeof(*exprVar), cudaMemcpyHostToDevice);
                cudaMemcpy(cudaExprNeg, exprNeg, 3 * m * sizeof(*exprNeg), cudaMemcpyHostToDevice);
            }

            uint32_t* cudaSet;
            int* cudaFlags;
            cudaMalloc(&cudaSet, 2 * q * blockCount * sizeof(*set));
            cudaMalloc(&cudaFlags, 2 * q * sizeof(*flags));
            cudaMemcpy(cudaSet, set, q * blockCount * sizeof(*set), cudaMemcpyHostToDevice);
            cudaMemcpy(cudaSet + q * blockCount, set, q * blockCount * sizeof(*set), cudaMemcpyHostToDevice);
            cudaMemcpy(cudaFlags, flags, q * sizeof(*flags), cudaMemcpyHostToDevice);
            cudaMemcpy(cudaFlags + q, flags, q * sizeof(*flags), cudaMemcpyHostToDevice);

            ssize_t qBlock = (q + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK;
            BranchGPU<<<qBlock, THREADS_PER_BLOCK>>>(cudaSet, blockCount, k, q);
            cudaDeviceSynchronize();

            q *= 2;

            qBlock = (q + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; 
            BoundGPU<<<qBlock, THREADS_PER_BLOCK>>>(cudaSet, cudaFlags, blockCount, k, n, m, cudaExprVar, cudaExprNeg, q);
            cudaDeviceSynchronize();

            set = (uint32_t*)realloc(set, q * blockCount * sizeof(*set));
            flags = (int*)realloc(flags, q * sizeof(*flags));
            cudaMemcpy(set, cudaSet, q * blockCount * sizeof(*set), cudaMemcpyDeviceToHost);
            cudaMemcpy(flags, cudaFlags, q * sizeof(*flags), cudaMemcpyDeviceToHost);
            cudaFree(cudaSet);
            cudaFree(cudaFlags);

        } else {

            set = (uint32_t*)realloc(set, 2 * q * blockCount * sizeof(*set));
            flags = (int*)realloc(flags, 2 * q * sizeof(*flags));
            memcpy(set + q * blockCount, set, q * blockCount * sizeof(*set));
            memcpy(flags + q, flags, q * sizeof(*flags));

            for (ssize_t e = 0; e < q; ++e) {
                BranchCPU(e, set, blockCount, k);
            }
            q *= 2;
            for (ssize_t e = 0; e < q; ++e) {
                BoundCPU(e, set, flags, blockCount, k, n, m, exprVar, exprNeg);
            }
        }

        for (ssize_t i = 0, j = q - 1;;) {
            while (i < q && flags[i] != 0) {
                ++i;
            }
            while (j >= 0 && flags[j] == 0) {
                --j;
            }
            if (i >= j) {
                q = i;
                break;
            }
            memcpy(set + i * blockCount, set + j * blockCount, blockCount * sizeof(*set));
            std::swap(flags[i], flags[j]);
        }

        if (q == 0) {
            break;
        }
    }

    if (cudaExprVar != nullptr) {
        cudaFree(cudaExprVar);
        cudaFree(cudaExprNeg);
    }

    if (q == 0) {
        fout << "No solution" << std::endl;
    } else {
        for (int i = 0; i < n; ++i) {
            fout << "x_" << i + 1 << " = " <<
                ((set[i / BLOCK_SIZE] & (((uint32_t)1) << ((uint32_t)(i % BLOCK_SIZE)))) ? 1 : 0) << std::endl;
        }
    }

    free(exprVar);
    free(exprNeg);
    free(set);
    free(flags);

    std::chrono::high_resolution_clock::time_point totalEnd = std::chrono::high_resolution_clock::now();
    double totalTime = std::chrono::duration_cast<std::chrono::duration<double>>(totalEnd - totalStart).count();
    std::cout << "Total time: " << totalTime << std::endl;

    return 0;
}

	.file	"tmpxft_00227aa5_00000000-6_3sat_bfs_gpu.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3873:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3873:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4651:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4651:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.globl	_Z9BranchCPUlPjii
	.type	_Z9BranchCPUlPjii, @function
_Z9BranchCPUlPjii:
.LFB3865:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movq	%rsi, %rdi
	movslq	%edx, %rsi
	movl	$32, %r8d
	imulq	%rax, %rsi
	movl	%ecx, %eax
	cltd
	idivl	%r8d
	cltq
	movl	%edx, %ecx
	addq	%rsi, %rax
	movl	$1, %esi
	sall	%cl, %esi
	orl	%esi, (%rdi,%rax,4)
	ret
	.cfi_endproc
.LFE3865:
	.size	_Z9BranchCPUlPjii, .-_Z9BranchCPUlPjii
	.globl	_Z8BoundCPUlPKjPiiiiiPKiS3_
	.type	_Z8BoundCPUlPKjPiiiiiPKiS3_, @function
_Z8BoundCPUlPKjPiiiiiPKiS3_:
.LFB3866:
	.cfi_startproc
	endbr64
	movq	%rsi, %r11
	movslq	%ecx, %rsi
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdi, %r9
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	imulq	%rdi, %rsi
	movl	$32, %r13d
	xorl	%edi, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdx, %rbx
.L5:
	cmpl	%edi, 40(%rsp)
	jle	.L4
	imulq	$12, %rdi, %r10
	xorl	%r12d, %r12d
	xorl	%ebp, %ebp
.L8:
	movq	48(%rsp), %rax
	movl	(%rax,%r10), %eax
	cmpl	%r8d, %eax
	jg	.L11
	cltd
	idivl	%r13d
	cltq
	movl	%edx, %ecx
	movq	56(%rsp), %rdx
	addq	%rsi, %rax
	movl	(%r11,%rax,4), %eax
	shrl	%cl, %eax
	andl	$1, %eax
	xorl	(%rdx,%r10), %eax
	decl	%eax
	jne	.L6
	jmp	.L17
.L11:
	orl	$-1, %ebp
.L6:
	incl	%r12d
	addq	$4, %r10
	cmpl	$3, %r12d
	jne	.L8
	jmp	.L7
.L17:
	movl	$1, %ebp
.L7:
	incq	%rdi
	testl	%ebp, %ebp
	jne	.L5
	xorl	%eax, %eax
	movl	%eax, (%rbx,%r9,4)
.L4:
	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
.LFE3866:
	.size	_Z8BoundCPUlPKjPiiiiiPKiS3_, .-_Z8BoundCPUlPKjPiiiiiPKiS3_
	.globl	_Z31__device_stub__Z9BranchGPUPjiilPjiil
	.type	_Z31__device_stub__Z9BranchGPUPjiilPjiil, @function
_Z31__device_stub__Z9BranchGPUPjiilPjiil:
.LFB3895:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 16(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9BranchGPUPjiil(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L18:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3895:
	.size	_Z31__device_stub__Z9BranchGPUPjiilPjiil, .-_Z31__device_stub__Z9BranchGPUPjiilPjiil
	.globl	_Z9BranchGPUPjiil
	.type	_Z9BranchGPUPjiil, @function
_Z9BranchGPUPjiil:
.LFB3896:
	.cfi_startproc
	endbr64
	jmp	_Z31__device_stub__Z9BranchGPUPjiilPjiil
	.cfi_endproc
.LFE3896:
	.size	_Z9BranchGPUPjiil, .-_Z9BranchGPUPjiil
	.globl	_Z41__device_stub__Z8BoundGPUPKjPiiiiiPKiS3_lPKjPiiiiiPKiS3_l
	.type	_Z41__device_stub__Z8BoundGPUPKjPiiiiiPKiS3_lPKjPiiiiiPKiS3_l, @function
_Z41__device_stub__Z8BoundGPUPKjPiiiiiPKiS3_lPKjPiiiiiPKiS3_l:
.LFB3897:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	208(%rsp), %rax
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rax, 8(%rsp)
	movq	216(%rsp), %rax
	movl	%edx, 28(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 24(%rsp)
	leaq	56(%rsp), %rcx
	movl	%r8d, 20(%rsp)
	movl	%r9d, 16(%rsp)
	movq	%rax, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movq	%rsp, %rax
	movq	%rax, 168(%rsp)
	leaq	224(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	pushq	56(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z8BoundGPUPKjPiiiiiPKiS3_l(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 224
	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 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L23:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3897:
	.size	_Z41__device_stub__Z8BoundGPUPKjPiiiiiPKiS3_lPKjPiiiiiPKiS3_l, .-_Z41__device_stub__Z8BoundGPUPKjPiiiiiPKiS3_lPKjPiiiiiPKiS3_l
	.globl	_Z8BoundGPUPKjPiiiiiPKiS3_l
	.type	_Z8BoundGPUPKjPiiiiiPKiS3_l, @function
_Z8BoundGPUPKjPiiiiiPKiS3_l:
.LFB3898:
	.cfi_startproc
	endbr64
	jmp	_Z41__device_stub__Z8BoundGPUPKjPiiiiiPKiS3_lPKjPiiiiiPKiS3_l
	.cfi_endproc
.LFE3898:
	.size	_Z8BoundGPUPKjPiiiiiPKiS3_l, .-_Z8BoundGPUPKjPiiiiiPKiS3_l
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z8BoundGPUPKjPiiiiiPKiS3_l"
.LC1:
	.string	"_Z9BranchGPUPjiil"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3900:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z8BoundGPUPKjPiiiiiPKiS3_l(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC1(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z9BranchGPUPjiil(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3900:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC2:
	.string	"Usage: "
.LC3:
	.string	" input_file output_file"
.LC4:
	.string	"Step "
.LC5:
	.string	", q = "
.LC6:
	.string	"No solution"
.LC8:
	.string	"Total time: "
.LC9:
	.string	"x_"
.LC10:
	.string	" = "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3867:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3867
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	movl	%edi, %r15d
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$1176, %rsp
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	%rax, -1216(%rbp)
	cmpl	$3, %r15d
	je	.L31
	leaq	.LC2(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
.LEHB0:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	(%rbx), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L32
.L31:
	movq	8(%rbx), %rsi
	leaq	-576(%rbp), %r13
	movl	$8, %edx
	movq	%r13, %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE0:
	movq	16(%rbx), %rsi
	movl	$16, %edx
	leaq	-1088(%rbp), %rdi
.LEHB1:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE1:
	leaq	-1152(%rbp), %rsi
	movq	%r13, %rdi
.LEHB2:
	call	_ZNSirsERi@PLT
	movq	%rax, %rdi
	leaq	-1148(%rbp), %rsi
	call	_ZNSirsERi@PLT
	imull	$3, -1148(%rbp), %ebx
	xorl	%r12d, %r12d
	movslq	%ebx, %rbx
	salq	$2, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, -1184(%rbp)
	call	malloc@PLT
	xorl	%esi, %esi
	movq	-1184(%rbp), %rbx
	movq	%rsi, -1144(%rbp)
	movq	%rsi, -1136(%rbp)
	movq	%rax, -1192(%rbp)
	addq	$8, %rax
	movq	%rax, %r14
.L33:
	cmpl	%r12d, -1148(%rbp)
	jle	.L83
	movq	%rbx, %rsi
	movq	%r13, %rdi
	call	_ZNSirsERi@PLT
	movq	%rax, %rdi
	leaq	-8(%r14), %rsi
	call	_ZNSirsERi@PLT
	movq	%rax, %rdi
	leaq	4(%rbx), %rsi
	call	_ZNSirsERi@PLT
	movq	%rax, %rdi
	leaq	-4(%r14), %rsi
	call	_ZNSirsERi@PLT
	movq	%rax, %rdi
	leaq	8(%rbx), %rsi
	call	_ZNSirsERi@PLT
	movq	%rax, %rdi
	movq	%r14, %rsi
	call	_ZNSirsERi@PLT
	movq	%r14, %rax
	decl	(%rbx)
	incl	%r12d
	addq	$12, %rax
	decl	4(%rbx)
	decl	8(%rbx)
	movq	%rax, %r14
	addq	$12, %rbx
	jmp	.L33
.L83:
	movl	-1152(%rbp), %eax
	movl	$32, %ecx
	movl	$4, %esi
	movl	$1, %ebx
	addl	$31, %eax
	cltd
	idivl	%ecx
	movslq	%eax, %r14
	movl	%eax, -1172(%rbp)
	movq	%r14, %rdi
	call	calloc@PLT
	movl	$4, %edi
	movq	%rax, %r12
	call	malloc@PLT
	xorl	%ecx, %ecx
	movq	%rax, -1160(%rbp)
	movl	$1, (%rax)
	leaq	0(,%r14,4), %rax
	movq	%rax, -1208(%rbp)
	movl	%ecx, -1168(%rbp)
.L35:
	movl	-1168(%rbp), %eax
	cmpl	%eax, -1152(%rbp)
	jle	.L58
	leaq	.LC4(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movl	-1168(%rbp), %eax
	incl	%eax
	movl	%eax, %esi
	movl	%eax, -1176(%rbp)
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	leaq	.LC5(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%rbx, %rsi
	call	_ZNSo9_M_insertIlEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	cmpq	$1000, %rbx
	jle	.L36
	cmpq	$0, -1144(%rbp)
	je	.L37
.L39:
	movq	%r14, %r13
	leaq	-1128(%rbp), %rdi
	imulq	%rbx, %r13
	leaq	0(,%r13,8), %rsi
	call	cudaMalloc@PLT
	jmp	.L84
.L37:
	imull	$3, -1148(%rbp), %esi
	leaq	-1144(%rbp), %rdi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	imull	$3, -1148(%rbp), %esi
	leaq	-1136(%rbp), %rdi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	imull	$3, -1148(%rbp), %edx
	movq	-1184(%rbp), %rsi
	movl	$1, %ecx
	movq	-1144(%rbp), %rdi
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	imull	$3, -1148(%rbp), %edx
	movq	-1192(%rbp), %rsi
	movl	$1, %ecx
	movq	-1136(%rbp), %rdi
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	jmp	.L39
.L84:
	leaq	0(,%rbx,8), %rax
	leaq	-1120(%rbp), %rdi
	movq	%rax, %rsi
	movq	%rax, -1200(%rbp)
	call	cudaMalloc@PLT
	salq	$2, %r13
	movq	-1128(%rbp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movq	%r13, %rdx
	call	cudaMemcpy@PLT
	movq	-1128(%rbp), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movq	%r12, %rsi
	addq	%r13, %rdi
	call	cudaMemcpy@PLT
	leaq	0(,%rbx,4), %r13
	movq	-1160(%rbp), %rsi
	movl	$1, %ecx
	movq	-1120(%rbp), %rdi
	movq	%r13, %rdx
	call	cudaMemcpy@PLT
	movq	-1120(%rbp), %rdi
	movq	-1160(%rbp), %rsi
	movl	$1, %ecx
	movq	%r13, %rdx
	addq	%r13, %rdi
	call	cudaMemcpy@PLT
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	leaq	511(%rbx), %rax
	salq	$9, %rdx
	movl	$1, -1092(%rbp)
	sarq	$9, %rax
	movq	%rdx, -1100(%rbp)
	movl	%eax, -1112(%rbp)
	movabsq	$4294967297, %rax
	movq	%rax, -1108(%rbp)
	movq	-1112(%rbp), %rdi
	movl	-1104(%rbp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	je	.L40
.L42:
	call	cudaDeviceSynchronize@PLT
	jmp	.L85
.L40:
	movl	-1168(%rbp), %edx
	movl	-1172(%rbp), %esi
	movq	%rbx, %rcx
	movq	-1128(%rbp), %rdi
	call	_Z31__device_stub__Z9BranchGPUPjiilPjiil
	jmp	.L42
.L85:
	addq	%rbx, %rbx
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	leaq	511(%rbx), %rax
	salq	$9, %rdx
	movq	%rbx, %r15
	movl	$1, %ecx
	sarq	$9, %rax
	movq	%rdx, -1100(%rbp)
	movl	%eax, -1112(%rbp)
	movabsq	$4294967297, %rax
	movq	%rax, -1108(%rbp)
	movl	-1104(%rbp), %esi
	movq	-1112(%rbp), %rdi
	movl	$1, -1092(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	je	.L43
.L45:
	call	cudaDeviceSynchronize@PLT
	jmp	.L86
.L43:
	pushq	%rdx
	movl	-1148(%rbp), %r9d
	movl	-1152(%rbp), %r8d
	movl	-1168(%rbp), %ecx
	pushq	%rbx
	pushq	-1136(%rbp)
	movl	-1172(%rbp), %edx
	movq	-1128(%rbp), %rdi
	pushq	-1144(%rbp)
	movq	-1120(%rbp), %rsi
	.cfi_escape 0x2e,0x20
	call	_Z41__device_stub__Z8BoundGPUPKjPiiiiiPKiS3_lPKjPiiiiiPKiS3_l
	addq	$32, %rsp
	jmp	.L45
.L86:
	imulq	%r14, %rbx
	movq	%r12, %rdi
	leaq	0(,%rbx,4), %r13
	movq	%r13, %rsi
	call	realloc@PLT
	movq	-1200(%rbp), %rsi
	movq	-1160(%rbp), %rdi
	movq	%rax, %r12
	call	realloc@PLT
	movl	$2, %ecx
	movq	%r13, %rdx
	movq	%r12, %rdi
	movq	-1128(%rbp), %rsi
	movq	%rax, -1160(%rbp)
	.cfi_escape 0x2e,0
	call	cudaMemcpy@PLT
	movq	-1200(%rbp), %rdx
	movq	-1120(%rbp), %rsi
	movl	$2, %ecx
	movq	-1160(%rbp), %rdi
	call	cudaMemcpy@PLT
	movq	-1128(%rbp), %rdi
	call	cudaFree@PLT
	movq	-1120(%rbp), %rdi
	call	cudaFree@PLT
	jmp	.L46
.L36:
	movq	%r14, %r15
	movq	%r12, %rdi
	imulq	%rbx, %r15
	leaq	0(,%r15,8), %r13
	movq	%r13, %rsi
	call	realloc@PLT
	leaq	0(,%rbx,8), %r8
	movq	-1160(%rbp), %rdi
	movq	%r8, %rsi
	movq	%r8, -1200(%rbp)
	movq	%rax, %r12
	call	realloc@PLT
	leaq	0(,%r15,4), %rdx
	movq	%r12, %rsi
	cmpq	%rdx, %r13
	movq	%rdx, %rcx
	leaq	(%r12,%rdx), %rdi
	movq	%rax, -1160(%rbp)
	cmovnb	%r13, %rcx
	subq	%rdx, %rcx
	call	__memcpy_chk@PLT
	movq	-1200(%rbp), %r8
	leaq	0(,%rbx,4), %rdx
	movq	-1160(%rbp), %rax
	cmpq	%rdx, %r8
	movq	%r8, %rcx
	leaq	(%rax,%rdx), %rdi
	movq	%rax, %rsi
	cmovb	%rdx, %rcx
	subq	%rdx, %rcx
	call	__memcpy_chk@PLT
	xorl	%r9d, %r9d
.L47:
	cmpq	%r9, %rbx
	jle	.L87
	movl	-1168(%rbp), %ecx
	movl	-1172(%rbp), %edx
	movq	%r9, %rdi
	movq	%r12, %rsi
	incq	%r9
	call	_Z9BranchCPUlPjii
	jmp	.L47
.L87:
	leaq	(%rbx,%rbx), %rax
	xorl	%ebx, %ebx
	movq	%rax, %r15
.L49:
	cmpq	%rax, %rbx
	jge	.L46
	movq	%rax, -1200(%rbp)
	movq	%rbx, %rdi
	movq	%r12, %rsi
	incq	%rbx
	pushq	%rax
	movl	-1148(%rbp), %edx
	pushq	-1192(%rbp)
	movl	-1168(%rbp), %r8d
	movl	-1172(%rbp), %ecx
	pushq	-1184(%rbp)
	pushq	%rdx
	movq	-1160(%rbp), %rdx
	movl	-1152(%rbp), %r9d
	call	_Z8BoundCPUlPKjPiiiiiPKiS3_
	movq	-1200(%rbp), %rax
	addq	$32, %rsp
	jmp	.L49
.L46:
	leaq	-1(%r15), %r8
	xorl	%ebx, %ebx
.L51:
	cmpq	%rbx, %r15
	jle	.L54
	movq	-1160(%rbp), %rax
	cmpl	$0, (%rax,%rbx,4)
	je	.L54
	incq	%rbx
	jmp	.L51
.L88:
	movq	-1160(%rbp), %rax
	cmpl	$0, (%rax,%r8,4)
	jne	.L55
	decq	%r8
.L54:
	testq	%r8, %r8
	jns	.L88
.L55:
	cmpq	%r8, %rbx
	jl	.L57
	testq	%rbx, %rbx
	je	.L58
	movl	-1176(%rbp), %eax
	movl	%eax, -1168(%rbp)
	jmp	.L35
.L57:
	movq	%r14, %rdi
	movq	%r13, %rcx
	movq	%r14, %rax
	movq	-1208(%rbp), %rdx
	imulq	%rbx, %rdi
	movq	%r8, -1168(%rbp)
	salq	$2, %rdi
	cmpq	%r13, %rdi
	cmovnb	%rdi, %rcx
	imulq	%r8, %rax
	subq	%rdi, %rcx
	addq	%r12, %rdi
	leaq	(%r12,%rax,4), %rsi
	call	__memcpy_chk@PLT
	movq	-1160(%rbp), %rcx
	movq	-1160(%rbp), %rax
	movq	-1168(%rbp), %r8
	leaq	(%rcx,%rbx,4), %rdx
	leaq	(%rax,%r8,4), %rax
	movl	(%rdx), %ecx
	movl	(%rax), %esi
	movl	%esi, (%rdx)
	movl	%ecx, (%rax)
	jmp	.L51
.L58:
	movq	-1144(%rbp), %rdi
	testq	%rdi, %rdi
	jne	.L61
.L64:
	testq	%rbx, %rbx
	leaq	-1088(%rbp), %r13
	je	.L62
	xorl	%ebx, %ebx
	leaq	.LC9(%rip), %r15
	jmp	.L63
.L61:
	call	cudaFree@PLT
	movq	-1136(%rbp), %rdi
	call	cudaFree@PLT
	jmp	.L64
.L62:
	leaq	.LC6(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L67:
	movq	-1184(%rbp), %rdi
	call	free@PLT
	movq	-1192(%rbp), %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	-1160(%rbp), %rdi
	call	free@PLT
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	-1216(%rbp), %rcx
	leaq	.LC8(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	subq	%rcx, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC7(%rip), %xmm0
	movq	%xmm0, %rbx
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%rbx, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	jmp	.L89
.L66:
	movq	%r15, %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leal	1(%rbx), %r14d
	movq	%rax, %rdi
	movl	%r14d, %esi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	leaq	.LC10(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movl	%ebx, %eax
	movl	%ebx, %ecx
	sarl	$5, %eax
	cltq
	movl	(%r12,%rax,4), %esi
	shrl	%cl, %esi
	andl	$1, %esi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	%r14d, %ebx
.L63:
	cmpl	%ebx, -1152(%rbp)
	jg	.L66
	jmp	.L67
.L89:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.LEHE2:
	movq	%r13, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	leaq	-576(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
.L32:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L71
	jmp	.L81
.L73:
	endbr64
	movq	%rax, %rbx
.L68:
	leaq	-1088(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L69
.L72:
	endbr64
	movq	%rax, %rbx
.L69:
	leaq	-576(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L81
	movq	%rbx, %rdi
.LEHB3:
	call	_Unwind_Resume@PLT
.LEHE3:
.L81:
	call	__stack_chk_fail@PLT
.L71:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3867:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3867:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3867-.LLSDACSB3867
.LLSDACSB3867:
	.uleb128 .LEHB0-.LFB3867
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3867
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L72-.LFB3867
	.uleb128 0
	.uleb128 .LEHB2-.LFB3867
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L73-.LFB3867
	.uleb128 0
	.uleb128 .LEHB3-.LFB3867
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
.LLSDACSE3867:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC7:
	.long	0
	.long	1104006501
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>

const int BLOCK_SIZE = 32;
const int THREADS_PER_BLOCK = 512;

void BranchCPU(const ssize_t e, uint32_t* set, const int blockCount, const int k) {
    set[e * blockCount + k / BLOCK_SIZE] |= (((uint32_t)1) << ((uint32_t)(k % BLOCK_SIZE)));
}

void BoundCPU(const ssize_t e, const uint32_t* set, int* flags,
              const int blockCount, const int k, const int n, const int m, const int* exprVar, const int* exprNeg) {
    for (int i = 0; i < m; ++i) {
        int disjunctRes = 0;
        for (int j = 0; j < 3; ++j) {
            int index = exprVar[i * 3 + j];
            if (index > k) {
                disjunctRes = -1;
            } else {
                int elem = (set[e * blockCount + index / BLOCK_SIZE] & (((uint32_t)1) << ((uint32_t)(index % BLOCK_SIZE)))) ? 1 : 0;
                elem ^= exprNeg[i * 3 + j];
                if (elem == 1) {
                    disjunctRes = 1;
                    break;
                }
            }
        }
        if (disjunctRes == 0) {
            flags[e] = 0;
            break;
        }
    }
}

__global__ void BranchGPU(uint32_t* set, const int blockCount, const int k, const ssize_t q) {
    ssize_t e = blockIdx.x * blockDim.x + threadIdx.x;
    if (e >= q) {
    	return;
    }
    set[e * blockCount + k / BLOCK_SIZE] |= (((uint32_t)1) << ((uint32_t)(k % BLOCK_SIZE)));
}

__global__ void BoundGPU(const uint32_t* set, int* flags,
              const int blockCount, const int k, const int n, const int m, const int* exprVar, const int* exprNeg, const ssize_t q) {
    ssize_t e = blockIdx.x * blockDim.x + threadIdx.x;
    if (e >= q) {
    	return;
    }

    for (int i = 0; i < m; ++i) {
        int disjunctRes = 0;
        for (int j = 0; j < 3; ++j) {
            int index = exprVar[i * 3 + j];
            if (index > k) {
                disjunctRes = -1;
            } else {
                int elem = (set[e * blockCount + index / BLOCK_SIZE] & (((uint32_t)1) << ((uint32_t)(index % BLOCK_SIZE)))) ? 1 : 0;
                elem ^= exprNeg[i * 3 + j];
                if (elem == 1) {
                    disjunctRes = 1;
                    break;
                }
            }
        }
        if (disjunctRes == 0) {
            flags[e] = 0;
            break;
        }
    }
}

int main(int argc, char* argv[]) {
    std::chrono::high_resolution_clock::time_point totalStart = std::chrono::high_resolution_clock::now();

    if (argc != 3) {
        std::cerr << "Usage: " << argv[0] << " input_file output_file" << std::endl;
        return 0;
    }

    std::ifstream fin(argv[1]);
    std::ofstream fout(argv[2]);
    
    int n, m;
    fin >> n >> m;
    
    int* exprVar = (int*)malloc(3 * m * sizeof(*exprVar));
    int* exprNeg = (int*)malloc(3 * m * sizeof(*exprNeg));
    int* cudaExprVar = nullptr;
    int* cudaExprNeg = nullptr;
    for (int i = 0; i < m; ++i) {
        fin >> exprVar[3 * i]
            >> exprNeg[3 * i]
            >> exprVar[3 * i + 1]
            >> exprNeg[3 * i + 1]
            >> exprVar[3 * i + 2]
            >> exprNeg[3 * i + 2];
        --exprVar[3 * i];
        --exprVar[3 * i + 1];
        --exprVar[3 * i + 2];
    }

    ssize_t q = 1;

    const int blockCount = (n + BLOCK_SIZE - 1) / BLOCK_SIZE;
    uint32_t* set = (uint32_t*)calloc(q * blockCount, sizeof(*set));
    int* flags = (int*)malloc(q * sizeof(*flags));
    flags[0] = 1;

    for (int k = 0; k < n; ++k) {
        std::cout << "Step " << k + 1 << ", q = " << q << std::endl;
        if (q > 1000) {
            if (cudaExprVar == nullptr) {
                hipMalloc(&cudaExprVar, 3 * m * sizeof(*exprVar));
                hipMalloc(&cudaExprNeg, 3 * m * sizeof(*exprNeg));
                hipMemcpy(cudaExprVar, exprVar, 3 * m * sizeof(*exprVar), hipMemcpyHostToDevice);
                hipMemcpy(cudaExprNeg, exprNeg, 3 * m * sizeof(*exprNeg), hipMemcpyHostToDevice);
            }

            uint32_t* cudaSet;
            int* cudaFlags;
            hipMalloc(&cudaSet, 2 * q * blockCount * sizeof(*set));
            hipMalloc(&cudaFlags, 2 * q * sizeof(*flags));
            hipMemcpy(cudaSet, set, q * blockCount * sizeof(*set), hipMemcpyHostToDevice);
            hipMemcpy(cudaSet + q * blockCount, set, q * blockCount * sizeof(*set), hipMemcpyHostToDevice);
            hipMemcpy(cudaFlags, flags, q * sizeof(*flags), hipMemcpyHostToDevice);
            hipMemcpy(cudaFlags + q, flags, q * sizeof(*flags), hipMemcpyHostToDevice);

            ssize_t qBlock = (q + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK;
            BranchGPU<<<qBlock, THREADS_PER_BLOCK>>>(cudaSet, blockCount, k, q);
            hipDeviceSynchronize();

            q *= 2;

            qBlock = (q + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; 
            BoundGPU<<<qBlock, THREADS_PER_BLOCK>>>(cudaSet, cudaFlags, blockCount, k, n, m, cudaExprVar, cudaExprNeg, q);
            hipDeviceSynchronize();

            set = (uint32_t*)realloc(set, q * blockCount * sizeof(*set));
            flags = (int*)realloc(flags, q * sizeof(*flags));
            hipMemcpy(set, cudaSet, q * blockCount * sizeof(*set), hipMemcpyDeviceToHost);
            hipMemcpy(flags, cudaFlags, q * sizeof(*flags), hipMemcpyDeviceToHost);
            hipFree(cudaSet);
            hipFree(cudaFlags);

        } else {

            set = (uint32_t*)realloc(set, 2 * q * blockCount * sizeof(*set));
            flags = (int*)realloc(flags, 2 * q * sizeof(*flags));
            memcpy(set + q * blockCount, set, q * blockCount * sizeof(*set));
            memcpy(flags + q, flags, q * sizeof(*flags));

            for (ssize_t e = 0; e < q; ++e) {
                BranchCPU(e, set, blockCount, k);
            }
            q *= 2;
            for (ssize_t e = 0; e < q; ++e) {
                BoundCPU(e, set, flags, blockCount, k, n, m, exprVar, exprNeg);
            }
        }

        for (ssize_t i = 0, j = q - 1;;) {
            while (i < q && flags[i] != 0) {
                ++i;
            }
            while (j >= 0 && flags[j] == 0) {
                --j;
            }
            if (i >= j) {
                q = i;
                break;
            }
            memcpy(set + i * blockCount, set + j * blockCount, blockCount * sizeof(*set));
            std::swap(flags[i], flags[j]);
        }

        if (q == 0) {
            break;
        }
    }

    if (cudaExprVar != nullptr) {
        hipFree(cudaExprVar);
        hipFree(cudaExprNeg);
    }

    if (q == 0) {
        fout << "No solution" << std::endl;
    } else {
        for (int i = 0; i < n; ++i) {
            fout << "x_" << i + 1 << " = " <<
                ((set[i / BLOCK_SIZE] & (((uint32_t)1) << ((uint32_t)(i % BLOCK_SIZE)))) ? 1 : 0) << std::endl;
        }
    }

    free(exprVar);
    free(exprNeg);
    free(set);
    free(flags);

    std::chrono::high_resolution_clock::time_point totalEnd = std::chrono::high_resolution_clock::now();
    double totalTime = std::chrono::duration_cast<std::chrono::duration<double>>(totalEnd - totalStart).count();
    std::cout << "Total time: " << totalTime << std::endl;

    return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z9BranchCPUlPjii               # -- Begin function _Z9BranchCPUlPjii
	.type	_Z9BranchCPUlPjii,@function
_Z9BranchCPUlPjii:                      # @_Z9BranchCPUlPjii
	.cfi_startproc
# %bb.0:
                                        # kill: def $ecx killed $ecx def $rcx
	movl	$1, %eax
	shll	%cl, %eax
	movslq	%edx, %rdx
	imulq	%rdi, %rdx
	leal	31(%rcx), %edi
	testl	%ecx, %ecx
	cmovnsl	%ecx, %edi
	sarl	$5, %edi
	movslq	%edi, %rcx
	leaq	(%rsi,%rdx,4), %rdx
	orl	%eax, (%rdx,%rcx,4)
	retq
.Lfunc_end0:
	.size	_Z9BranchCPUlPjii, .Lfunc_end0-_Z9BranchCPUlPjii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8BoundCPUlPKjPiiiiiPKiS3_     # -- Begin function _Z8BoundCPUlPKjPiiiiiPKiS3_
	.type	_Z8BoundCPUlPKjPiiiiiPKiS3_,@function
_Z8BoundCPUlPKjPiiiiiPKiS3_:            # @_Z8BoundCPUlPKjPiiiiiPKiS3_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	40(%rsp), %r10d
	testl	%r10d, %r10d
	jle	.LBB1_9
# %bb.1:                                # %.preheader.lr.ph
	movq	56(%rsp), %rax
	movq	48(%rsp), %r9
	movslq	%ecx, %rcx
	imulq	%rdi, %rcx
	leaq	(%rsi,%rcx,4), %rcx
	movl	%r10d, %esi
	xorl	%r10d, %r10d
.LBB1_3:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	xorl	%r11d, %r11d
	xorl	%ebx, %ebx
.LBB1_4:                                #   Parent Loop BB1_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r9,%r11,4), %r14d
	movl	$-1, %ebp
	cmpl	%r8d, %r14d
	jg	.LBB1_6
# %bb.5:                                #   in Loop: Header=BB1_4 Depth=2
	leal	31(%r14), %ebp
	testl	%r14d, %r14d
	cmovnsl	%r14d, %ebp
	sarl	$5, %ebp
	movslq	%ebp, %r15
	movl	(%rcx,%r15,4), %ebp
	xorl	%r15d, %r15d
	btl	%r14d, %ebp
	setb	%r15b
	xorl	(%rax,%r11,4), %r15d
	movl	%ebx, %ebp
	cmpl	$1, %r15d
	je	.LBB1_2
.LBB1_6:                                # %.thread
                                        #   in Loop: Header=BB1_4 Depth=2
	incq	%r11
	movl	%ebp, %ebx
	cmpq	$3, %r11
	jne	.LBB1_4
# %bb.7:                                # %.critedge
                                        #   in Loop: Header=BB1_3 Depth=1
	testl	%ebp, %ebp
	je	.LBB1_8
.LBB1_2:                                # %.critedge.thread
                                        #   in Loop: Header=BB1_3 Depth=1
	incq	%r10
	addq	$12, %rax
	addq	$12, %r9
	cmpq	%rsi, %r10
	jne	.LBB1_3
	jmp	.LBB1_9
.LBB1_8:
	movl	$0, (%rdx,%rdi,4)
.LBB1_9:                                # %.loopexit
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z8BoundCPUlPKjPiiiiiPKiS3_, .Lfunc_end1-_Z8BoundCPUlPKjPiiiiiPKiS3_
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__BranchGPUPjiil # -- Begin function _Z24__device_stub__BranchGPUPjiil
	.type	_Z24__device_stub__BranchGPUPjiil,@function
_Z24__device_stub__BranchGPUPjiil:      # @_Z24__device_stub__BranchGPUPjiil
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	12(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	8(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	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	$_Z9BranchGPUPjiil, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z24__device_stub__BranchGPUPjiil, .Lfunc_end2-_Z24__device_stub__BranchGPUPjiil
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l # -- Begin function _Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l
	.type	_Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l,@function
_Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l: # @_Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l
	.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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	movq	%rsp, %r8
	movl	%r9d, (%r8)
	leaq	80(%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	216(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	224(%rsp), %rax
	movq	%rax, 64(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8BoundGPUPKjPiiiiiPKiS3_l, %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	_Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l, .Lfunc_end3-_Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x41cdcd6500000000              # double 1.0E+9
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$1176, %rsp                     # imm = 0x498
	.cfi_def_cfa_offset 1232
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	.cfi_escape 0x2e, 0x00
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	cmpl	$3, %ebp
	jne	.LBB4_1
# %bb.6:
	movq	%rax, %r13
	movq	8(%rbx), %rsi
	.cfi_escape 0x2e, 0x00
	leaq	656(%rsp), %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
	movq	16(%rbx), %rsi
.Ltmp0:
	.cfi_escape 0x2e, 0x00
	leaq	144(%rsp), %rdi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
.Ltmp1:
# %bb.7:
.Ltmp3:
	.cfi_escape 0x2e, 0x00
	leaq	656(%rsp), %rdi
	leaq	28(%rsp), %rsi
	callq	_ZNSirsERi
.Ltmp4:
# %bb.8:
.Ltmp5:
	.cfi_escape 0x2e, 0x00
	leaq	8(%rsp), %rsi
	movq	%rax, %rdi
	callq	_ZNSirsERi
.Ltmp6:
# %bb.9:
	movslq	8(%rsp), %r14
	leaq	(,%r14,4), %rax
	leaq	(%rax,%rax,2), %rbx
	.cfi_escape 0x2e, 0x00
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	.cfi_escape 0x2e, 0x00
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	xorl	%eax, %eax
	movq	%rax, 48(%rsp)
	movq	%rax, 80(%rsp)
	testq	%r14, %r14
	jle	.LBB4_18
# %bb.10:                               # %.lr.ph.preheader
	movq	64(%rsp), %rax                  # 8-byte Reload
	leaq	8(%rax), %rbx
	xorl	%r12d, %r12d
	leaq	656(%rsp), %r14
	movq	56(%rsp), %r15                  # 8-byte Reload
.LBB4_11:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leaq	-8(%rbx), %rsi
.Ltmp8:
	.cfi_escape 0x2e, 0x00
	movq	%r14, %rdi
	callq	_ZNSirsERi
.Ltmp9:
# %bb.12:                               #   in Loop: Header=BB4_11 Depth=1
.Ltmp10:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	movq	%r15, %rsi
	callq	_ZNSirsERi
.Ltmp11:
# %bb.13:                               #   in Loop: Header=BB4_11 Depth=1
	leaq	-4(%rbx), %rsi
.Ltmp12:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	callq	_ZNSirsERi
.Ltmp13:
# %bb.14:                               #   in Loop: Header=BB4_11 Depth=1
	leaq	4(%r15), %rsi
.Ltmp14:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	callq	_ZNSirsERi
.Ltmp15:
# %bb.15:                               #   in Loop: Header=BB4_11 Depth=1
.Ltmp16:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_ZNSirsERi
.Ltmp17:
# %bb.16:                               #   in Loop: Header=BB4_11 Depth=1
	leaq	8(%r15), %rsi
.Ltmp18:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	callq	_ZNSirsERi
.Ltmp19:
# %bb.17:                               #   in Loop: Header=BB4_11 Depth=1
	decl	-8(%rbx)
	decl	-4(%rbx)
	decl	(%rbx)
	incq	%r12
	movslq	8(%rsp), %rax
	addq	$12, %r15
	addq	$12, %rbx
	cmpq	%rax, %r12
	jl	.LBB4_11
.LBB4_18:                               # %._crit_edge
	movq	%r13, 112(%rsp)                 # 8-byte Spill
	movl	28(%rsp), %ebx
	leal	31(%rbx), %eax
	addl	$62, %ebx
	testl	%eax, %eax
	cmovnsl	%eax, %ebx
	sarl	$5, %ebx
	movslq	%ebx, %r14
	.cfi_escape 0x2e, 0x00
	movl	$4, %esi
	movq	%r14, %rdi
	callq	calloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	.cfi_escape 0x2e, 0x00
	movl	$4, %edi
	callq	malloc
	movq	%rax, %r13
	movl	$1, (%rax)
	movq	%r14, 96(%rsp)                  # 8-byte Spill
	leaq	(,%r14,4), %rax
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movl	$1, %ebp
	xorl	%r12d, %r12d
	movq	%rbx, 88(%rsp)                  # 8-byte Spill
.LBB4_19:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_59 Depth 2
                                        #     Child Loop BB4_62 Depth 2
                                        #     Child Loop BB4_64 Depth 2
                                        #       Child Loop BB4_65 Depth 3
                                        #       Child Loop BB4_69 Depth 3
	movl	%r12d, %eax
	movl	%r12d, 12(%rsp)                 # 4-byte Spill
	movl	28(%rsp), %r15d
	cmpl	%r15d, %r12d
	movl	%r15d, 108(%rsp)                # 4-byte Spill
	jge	.LBB4_74
# %bb.20:                               #   in Loop: Header=BB4_19 Depth=1
.Ltmp21:
	.cfi_escape 0x2e, 0x00
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$5, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp22:
# %bb.21:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit194
                                        #   in Loop: Header=BB4_19 Depth=1
	leaq	1(%r12), %rsi
.Ltmp23:
	.cfi_escape 0x2e, 0x00
	movl	$_ZSt4cout, %edi
	movq	%rsi, 120(%rsp)                 # 8-byte Spill
                                        # kill: def $esi killed $esi killed $rsi
	callq	_ZNSolsEi
.Ltmp24:
# %bb.22:                               #   in Loop: Header=BB4_19 Depth=1
.Ltmp25:
	movq	%rax, %r14
	.cfi_escape 0x2e, 0x00
	movl	$.L.str.3, %esi
	movl	$6, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp26:
# %bb.23:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit195
                                        #   in Loop: Header=BB4_19 Depth=1
.Ltmp27:
	.cfi_escape 0x2e, 0x00
	movq	%r14, %rdi
	movq	%rbp, %rsi
	callq	_ZNSo9_M_insertIlEERSoT_
.Ltmp28:
# %bb.24:                               # %_ZNSolsEl.exit
                                        #   in Loop: Header=BB4_19 Depth=1
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp29:
	.cfi_escape 0x2e, 0x00
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp30:
# %bb.25:                               # %.noexc
                                        #   in Loop: Header=BB4_19 Depth=1
.Ltmp31:
	.cfi_escape 0x2e, 0x00
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
.Ltmp32:
# %bb.26:                               # %.noexc205
                                        #   in Loop: Header=BB4_19 Depth=1
.Ltmp33:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp34:
# %bb.27:                               # %_ZNSolsEPFRSoS_E.exit
                                        #   in Loop: Header=BB4_19 Depth=1
	cmpq	$1001, %rbp                     # imm = 0x3E9
	jl	.LBB4_57
# %bb.28:                               #   in Loop: Header=BB4_19 Depth=1
	cmpq	$0, 48(%rsp)
	jne	.LBB4_33
# %bb.29:                               #   in Loop: Header=BB4_19 Depth=1
	movslq	8(%rsp), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rsi
.Ltmp35:
	.cfi_escape 0x2e, 0x00
	leaq	48(%rsp), %rdi
	callq	hipMalloc
.Ltmp36:
# %bb.30:                               # %_ZL9hipMallocIiE10hipError_tPPT_m.exit
                                        #   in Loop: Header=BB4_19 Depth=1
	movslq	8(%rsp), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rsi
.Ltmp37:
	.cfi_escape 0x2e, 0x00
	leaq	80(%rsp), %rdi
	callq	hipMalloc
.Ltmp38:
# %bb.31:                               # %_ZL9hipMallocIiE10hipError_tPPT_m.exit196
                                        #   in Loop: Header=BB4_19 Depth=1
	movq	48(%rsp), %rdi
	movslq	8(%rsp), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rdx
.Ltmp39:
	.cfi_escape 0x2e, 0x00
	movq	64(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp40:
# %bb.32:                               #   in Loop: Header=BB4_19 Depth=1
	movq	80(%rsp), %rdi
	movslq	8(%rsp), %rax
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rdx
.Ltmp41:
	.cfi_escape 0x2e, 0x00
	movq	56(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp42:
.LBB4_33:                               #   in Loop: Header=BB4_19 Depth=1
	leaq	(,%rbp,2), %r15
	movq	72(%rsp), %rsi                  # 8-byte Reload
	imulq	%r15, %rsi
.Ltmp44:
	.cfi_escape 0x2e, 0x00
	leaq	32(%rsp), %rdi
	movq	%rsi, %rbx
	callq	hipMalloc
.Ltmp45:
# %bb.34:                               # %_ZL9hipMallocIjE10hipError_tPPT_m.exit
                                        #   in Loop: Header=BB4_19 Depth=1
	leaq	(,%rbp,8), %rsi
.Ltmp46:
	.cfi_escape 0x2e, 0x00
	leaq	40(%rsp), %rdi
	movq	%rsi, %r12
	callq	hipMalloc
.Ltmp47:
# %bb.35:                               # %_ZL9hipMallocIiE10hipError_tPPT_m.exit197
                                        #   in Loop: Header=BB4_19 Depth=1
	movq	32(%rsp), %rdi
	movq	%rbp, %r14
	imulq	96(%rsp), %r14                  # 8-byte Folded Reload
	shlq	$2, %r14
.Ltmp48:
	.cfi_escape 0x2e, 0x00
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp49:
# %bb.36:                               #   in Loop: Header=BB4_19 Depth=1
	movq	32(%rsp), %rdi
	addq	%r14, %rdi
.Ltmp50:
	.cfi_escape 0x2e, 0x00
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp51:
# %bb.37:                               #   in Loop: Header=BB4_19 Depth=1
	movq	40(%rsp), %rdi
	leaq	(,%rbp,4), %r14
.Ltmp52:
	.cfi_escape 0x2e, 0x00
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp53:
# %bb.38:                               #   in Loop: Header=BB4_19 Depth=1
	movq	40(%rsp), %rdi
	addq	%r14, %rdi
.Ltmp54:
	.cfi_escape 0x2e, 0x00
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp55:
# %bb.39:                               #   in Loop: Header=BB4_19 Depth=1
	leaq	511(%rbp), %rax
	shrq	$9, %rax
	movl	%eax, %edi
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
.Ltmp57:
	.cfi_escape 0x2e, 0x00
	movl	$1, %esi
	movabsq	$4294967808, %rdx               # imm = 0x100000200
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp58:
# %bb.40:                               #   in Loop: Header=BB4_19 Depth=1
	movq	%r12, %r14
	testl	%eax, %eax
	jne	.LBB4_42
# %bb.41:                               #   in Loop: Header=BB4_19 Depth=1
	movq	32(%rsp), %rdi
.Ltmp59:
	.cfi_escape 0x2e, 0x00
	movq	88(%rsp), %rsi                  # 8-byte Reload
                                        # kill: def $esi killed $esi killed $rsi
	movl	12(%rsp), %edx                  # 4-byte Reload
	movq	%rbp, %rcx
	callq	_Z24__device_stub__BranchGPUPjiil
.Ltmp60:
.LBB4_42:                               #   in Loop: Header=BB4_19 Depth=1
.Ltmp61:
	.cfi_escape 0x2e, 0x00
	callq	hipDeviceSynchronize
.Ltmp62:
# %bb.43:                               #   in Loop: Header=BB4_19 Depth=1
	leaq	511(%r15), %rax
	shrq	$9, %rax
	movl	%eax, %edi
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
.Ltmp63:
	.cfi_escape 0x2e, 0x00
	movl	$1, %esi
	movabsq	$4294967808, %rdx               # imm = 0x100000200
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp64:
# %bb.44:                               #   in Loop: Header=BB4_19 Depth=1
	testl	%eax, %eax
	jne	.LBB4_46
# %bb.45:                               #   in Loop: Header=BB4_19 Depth=1
	movq	32(%rsp), %rdi
	movq	40(%rsp), %rsi
	movl	28(%rsp), %r8d
	movl	8(%rsp), %r9d
.Ltmp65:
	.cfi_escape 0x2e, 0x20
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	96(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	movl	20(%rsp), %ecx                  # 4-byte Reload
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	96(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	72(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
.Ltmp66:
.LBB4_46:                               #   in Loop: Header=BB4_19 Depth=1
.Ltmp67:
	.cfi_escape 0x2e, 0x00
	callq	hipDeviceSynchronize
.Ltmp68:
# %bb.47:                               #   in Loop: Header=BB4_19 Depth=1
	.cfi_escape 0x2e, 0x00
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movq	%rbx, %r12
	movq	%rbx, %rsi
	callq	realloc
	movq	%rax, %rbx
	.cfi_escape 0x2e, 0x00
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	realloc
	movq	%rax, %r13
	movq	32(%rsp), %rsi
.Ltmp69:
	.cfi_escape 0x2e, 0x00
	movq	%rbx, 16(%rsp)                  # 8-byte Spill
	movq	%rbx, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp70:
# %bb.48:                               #   in Loop: Header=BB4_19 Depth=1
	movq	40(%rsp), %rsi
.Ltmp71:
	.cfi_escape 0x2e, 0x00
	movq	%r13, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp72:
# %bb.49:                               #   in Loop: Header=BB4_19 Depth=1
	movq	32(%rsp), %rdi
.Ltmp73:
	.cfi_escape 0x2e, 0x00
	callq	hipFree
.Ltmp74:
# %bb.50:                               #   in Loop: Header=BB4_19 Depth=1
	movq	40(%rsp), %rdi
.Ltmp75:
	.cfi_escape 0x2e, 0x00
	callq	hipFree
.Ltmp76:
	jmp	.LBB4_63
.LBB4_57:                               #   in Loop: Header=BB4_19 Depth=1
	leaq	(,%rbp,2), %r15
	movq	72(%rsp), %rsi                  # 8-byte Reload
	imulq	%r15, %rsi
	.cfi_escape 0x2e, 0x00
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	realloc
	movq	%rax, %rbx
	leaq	(,%rbp,8), %rsi
	.cfi_escape 0x2e, 0x00
	movq	%r13, %rdi
	callq	realloc
	movq	%rax, %r13
	movq	%rbp, %rdx
	imulq	96(%rsp), %rdx                  # 8-byte Folded Reload
	leaq	(%rbx,%rdx,4), %rdi
	shlq	$2, %rdx
	.cfi_escape 0x2e, 0x00
	movq	%rbx, %rsi
	callq	memcpy@PLT
	leaq	(,%rbp,4), %rdi
	addq	%r13, %rdi
	leaq	(,%rbp,4), %rdx
	.cfi_escape 0x2e, 0x00
	movq	%r13, %rsi
	callq	memcpy@PLT
	testq	%rbp, %rbp
	movq	%rbx, 16(%rsp)                  # 8-byte Spill
	jle	.LBB4_63
# %bb.58:                               # %.lr.ph239
                                        #   in Loop: Header=BB4_19 Depth=1
	shrq	$3, %r12
	movl	$1, %eax
	movl	12(%rsp), %ecx                  # 4-byte Reload
                                        # kill: def $cl killed $cl killed $ecx
	shll	%cl, %eax
	andq	$-4, %r12
	addq	%r12, %rbx
	movq	%rbp, %rdx
	movq	72(%rsp), %rsi                  # 8-byte Reload
.LBB4_59:                               #   Parent Loop BB4_19 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	orl	%eax, (%rbx)
	addq	%rsi, %rbx
	decq	%rdx
	jne	.LBB4_59
# %bb.60:                               # %.preheader
                                        #   in Loop: Header=BB4_19 Depth=1
	testq	%rbp, %rbp
	jle	.LBB4_63
# %bb.61:                               # %.lr.ph241
                                        #   in Loop: Header=BB4_19 Depth=1
	movl	8(%rsp), %eax
	movq	%rax, 136(%rsp)                 # 8-byte Spill
	cmpq	$2, %r15
	movl	$1, %eax
	cmovgeq	%r15, %rax
	movq	%rax, 128(%rsp)                 # 8-byte Spill
	xorl	%r14d, %r14d
	movq	56(%rsp), %rbp                  # 8-byte Reload
	movq	16(%rsp), %rbx                  # 8-byte Reload
	movl	12(%rsp), %r12d                 # 4-byte Reload
.LBB4_62:                               #   Parent Loop BB4_19 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	.cfi_escape 0x2e, 0x20
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	%r14, %rdi
	movq	%rbx, %rsi
	movq	%r13, %rdx
	movq	96(%rsp), %rcx                  # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	movl	%r12d, %r8d
	pushq	%rbp
	.cfi_adjust_cfa_offset 8
	pushq	80(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	160(%rsp)                       # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	callq	_Z8BoundCPUlPKjPiiiiiPKiS3_
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	incq	%r14
	cmpq	%r14, 128(%rsp)                 # 8-byte Folded Reload
	jne	.LBB4_62
.LBB4_63:                               # %.loopexit232
                                        #   in Loop: Header=BB4_19 Depth=1
	leaq	-1(%r15), %r14
	xorl	%ebp, %ebp
.LBB4_64:                               #   Parent Loop BB4_19 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_65 Depth 3
                                        #       Child Loop BB4_69 Depth 3
	cmpq	%r15, %rbp
	jge	.LBB4_68
.LBB4_65:                               # %.lr.ph244
                                        #   Parent Loop BB4_19 Depth=1
                                        #     Parent Loop BB4_64 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	cmpl	$0, (%r13,%rbp,4)
	je	.LBB4_68
# %bb.66:                               #   in Loop: Header=BB4_65 Depth=3
	incq	%rbp
	cmpq	%rbp, %r15
	jne	.LBB4_65
# %bb.67:                               #   in Loop: Header=BB4_64 Depth=2
	movq	%r15, %rbp
.LBB4_68:                               # %.critedge
                                        #   in Loop: Header=BB4_64 Depth=2
	testq	%r14, %r14
	js	.LBB4_72
.LBB4_69:                               # %.lr.ph248
                                        #   Parent Loop BB4_19 Depth=1
                                        #     Parent Loop BB4_64 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	cmpl	$0, (%r13,%r14,4)
	jne	.LBB4_72
# %bb.70:                               #   in Loop: Header=BB4_69 Depth=3
	leaq	-1(%r14), %rax
	testq	%r14, %r14
	movq	%rax, %r14
	jg	.LBB4_69
# %bb.71:                               #   in Loop: Header=BB4_64 Depth=2
	movq	$-1, %r14
.LBB4_72:                               # %.critedge2
                                        #   in Loop: Header=BB4_64 Depth=2
	cmpq	%r14, %rbp
	jge	.LBB4_73
# %bb.100:                              #   in Loop: Header=BB4_64 Depth=2
	movq	%rbp, %rax
	movq	96(%rsp), %rdx                  # 8-byte Reload
	imulq	%rdx, %rax
	movq	16(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rdi
	movq	%r14, %rax
	imulq	%rdx, %rax
	leaq	(%rcx,%rax,4), %rsi
	.cfi_escape 0x2e, 0x00
	movq	72(%rsp), %rdx                  # 8-byte Reload
	callq	memcpy@PLT
	movl	(%r13,%rbp,4), %eax
	movl	(%r13,%r14,4), %ecx
	movl	%ecx, (%r13,%rbp,4)
	movl	%eax, (%r13,%r14,4)
	jmp	.LBB4_64
.LBB4_73:                               #   in Loop: Header=BB4_19 Depth=1
	movq	120(%rsp), %r12                 # 8-byte Reload
	testq	%rbp, %rbp
	jne	.LBB4_19
.LBB4_74:
	movq	48(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB4_77
# %bb.75:
.Ltmp78:
	.cfi_escape 0x2e, 0x00
	callq	hipFree
.Ltmp79:
# %bb.76:
	movq	80(%rsp), %rdi
.Ltmp80:
	.cfi_escape 0x2e, 0x00
	callq	hipFree
.Ltmp81:
.LBB4_77:
	movl	108(%rsp), %eax                 # 4-byte Reload
	cmpl	%eax, 12(%rsp)                  # 4-byte Folded Reload
	jge	.LBB4_78
# %bb.87:
.Ltmp97:
	.cfi_escape 0x2e, 0x00
	leaq	144(%rsp), %rbx
	movl	$.L.str.4, %esi
	movl	$11, %edx
	movq	%rbx, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp98:
# %bb.88:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit198
	movq	144(%rsp), %rax
	addq	-24(%rax), %rbx
.Ltmp99:
	.cfi_escape 0x2e, 0x00
	movq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp100:
# %bb.89:                               # %.noexc207
.Ltmp101:
	.cfi_escape 0x2e, 0x00
	movsbl	%al, %esi
	leaq	144(%rsp), %rdi
	callq	_ZNSo3putEc
.Ltmp102:
# %bb.90:                               # %.noexc208
.Ltmp103:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp104:
.LBB4_91:                               # %.loopexit
	.cfi_escape 0x2e, 0x00
	movq	64(%rsp), %rdi                  # 8-byte Reload
	callq	free
	.cfi_escape 0x2e, 0x00
	movq	56(%rsp), %rdi                  # 8-byte Reload
	callq	free
	.cfi_escape 0x2e, 0x00
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	free
	.cfi_escape 0x2e, 0x00
	movq	%r13, %rdi
	callq	free
	.cfi_escape 0x2e, 0x00
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %rbx
.Ltmp106:
	.cfi_escape 0x2e, 0x00
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp107:
# %bb.92:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit203
	subq	112(%rsp), %rbx                 # 8-byte Folded Reload
	cvtsi2sd	%rbx, %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
.Ltmp108:
	.cfi_escape 0x2e, 0x00
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp109:
# %bb.93:                               # %_ZNSolsEd.exit
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp110:
	.cfi_escape 0x2e, 0x00
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp111:
# %bb.94:                               # %.noexc215
.Ltmp112:
	.cfi_escape 0x2e, 0x00
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
.Ltmp113:
# %bb.95:                               # %.noexc216
.Ltmp114:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp115:
# %bb.96:                               # %_ZNSolsEPFRSoS_E.exit204
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	152(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 144(%rsp,%rax)
	.cfi_escape 0x2e, 0x00
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	392(%rsp), %rdi
	.cfi_escape 0x2e, 0x00
	callq	_ZNSt8ios_baseD2Ev
	.cfi_escape 0x2e, 0x00
	leaq	656(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	jmp	.LBB4_5
.LBB4_1:
	.cfi_escape 0x2e, 0x00
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	movl	$7, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %rbx
	testq	%rbx, %rbx
	je	.LBB4_2
# %bb.3:
	.cfi_escape 0x2e, 0x00
	movq	%rbx, %rdi
	callq	strlen
	.cfi_escape 0x2e, 0x00
	movl	$_ZSt4cerr, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB4_4
.LBB4_78:                               # %_ZNSolsEPFRSoS_E.exit202.preheader
	xorl	%r15d, %r15d
	leaq	144(%rsp), %rbx
.LBB4_79:                               # %_ZNSolsEPFRSoS_E.exit202
                                        # =>This Inner Loop Header: Depth=1
	cmpl	28(%rsp), %r15d
	jge	.LBB4_91
# %bb.80:                               #   in Loop: Header=BB4_79 Depth=1
.Ltmp82:
	.cfi_escape 0x2e, 0x00
	movl	$.L.str.5, %esi
	movl	$2, %edx
	movq	%rbx, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp83:
# %bb.81:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit200
                                        #   in Loop: Header=BB4_79 Depth=1
	leal	1(%r15), %ebp
.Ltmp84:
	.cfi_escape 0x2e, 0x00
	movq	%rbx, %rdi
	movl	%ebp, %esi
	callq	_ZNSolsEi
.Ltmp85:
# %bb.82:                               #   in Loop: Header=BB4_79 Depth=1
.Ltmp86:
	movq	%rax, %r14
	.cfi_escape 0x2e, 0x00
	movl	$.L.str.6, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp87:
# %bb.83:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit201
                                        #   in Loop: Header=BB4_79 Depth=1
	movl	%r15d, %eax
	shrl	$5, %eax
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movl	(%rcx,%rax,4), %eax
	xorl	%esi, %esi
	btl	%r15d, %eax
	setb	%sil
.Ltmp88:
	.cfi_escape 0x2e, 0x00
	movq	%r14, %rdi
	callq	_ZNSolsEi
.Ltmp89:
# %bb.84:                               #   in Loop: Header=BB4_79 Depth=1
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp90:
	.cfi_escape 0x2e, 0x00
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp91:
# %bb.85:                               # %.noexc211
                                        #   in Loop: Header=BB4_79 Depth=1
.Ltmp92:
	.cfi_escape 0x2e, 0x00
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
.Ltmp93:
# %bb.86:                               # %.noexc212
                                        #   in Loop: Header=BB4_79 Depth=1
.Ltmp94:
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp95:
	movl	%ebp, %r15d
	jmp	.LBB4_79
.LBB4_2:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	.cfi_escape 0x2e, 0x00
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB4_4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	.cfi_escape 0x2e, 0x00
	movl	$_ZSt4cerr, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	movl	$23, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	.cfi_escape 0x2e, 0x00
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	.cfi_escape 0x2e, 0x00
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	.cfi_escape 0x2e, 0x00
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB4_5:
	xorl	%eax, %eax
	addq	$1176, %rsp                     # imm = 0x498
	.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
.LBB4_51:
	.cfi_def_cfa_offset 1232
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB4_99
.LBB4_52:
.Ltmp7:
	jmp	.LBB4_98
.LBB4_101:
.Ltmp105:
	jmp	.LBB4_98
.LBB4_97:
.Ltmp116:
	jmp	.LBB4_98
.LBB4_55:
.Ltmp56:
	jmp	.LBB4_98
.LBB4_56:
.Ltmp77:
	jmp	.LBB4_98
.LBB4_102:
.Ltmp96:
	jmp	.LBB4_98
.LBB4_53:
.Ltmp20:
	jmp	.LBB4_98
.LBB4_54:
.Ltmp43:
.LBB4_98:
	movq	%rax, %rbx
	.cfi_escape 0x2e, 0x00
	leaq	144(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
.LBB4_99:
	.cfi_escape 0x2e, 0x00
	leaq	656(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	.cfi_escape 0x2e, 0x00
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table4:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp6-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp6
	.uleb128 .Ltmp7-.Lfunc_begin0           #     jumps to .Ltmp7
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp19-.Ltmp8                 #   Call between .Ltmp8 and .Ltmp19
	.uleb128 .Ltmp20-.Lfunc_begin0          #     jumps to .Ltmp20
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp21-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp42-.Ltmp21                #   Call between .Ltmp21 and .Ltmp42
	.uleb128 .Ltmp43-.Lfunc_begin0          #     jumps to .Ltmp43
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp44-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp55-.Ltmp44                #   Call between .Ltmp44 and .Ltmp55
	.uleb128 .Ltmp56-.Lfunc_begin0          #     jumps to .Ltmp56
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp57-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp76-.Ltmp57                #   Call between .Ltmp57 and .Ltmp76
	.uleb128 .Ltmp77-.Lfunc_begin0          #     jumps to .Ltmp77
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp76-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp78-.Ltmp76                #   Call between .Ltmp76 and .Ltmp78
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp78-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp104-.Ltmp78               #   Call between .Ltmp78 and .Ltmp104
	.uleb128 .Ltmp105-.Lfunc_begin0         #     jumps to .Ltmp105
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp106-.Lfunc_begin0         # >> Call Site 10 <<
	.uleb128 .Ltmp115-.Ltmp106              #   Call between .Ltmp106 and .Ltmp115
	.uleb128 .Ltmp116-.Lfunc_begin0         #     jumps to .Ltmp116
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp115-.Lfunc_begin0         # >> Call Site 11 <<
	.uleb128 .Ltmp82-.Ltmp115               #   Call between .Ltmp115 and .Ltmp82
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp82-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp95-.Ltmp82                #   Call between .Ltmp82 and .Ltmp95
	.uleb128 .Ltmp96-.Lfunc_begin0          #     jumps to .Ltmp96
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp95-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Lfunc_end4-.Ltmp95            #   Call between .Ltmp95 and .Lfunc_end4
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9BranchGPUPjiil, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8BoundGPUPKjPiiiiiPKiS3_l, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z9BranchGPUPjiil,@object       # @_Z9BranchGPUPjiil
	.section	.rodata,"a",@progbits
	.globl	_Z9BranchGPUPjiil
	.p2align	3, 0x0
_Z9BranchGPUPjiil:
	.quad	_Z24__device_stub__BranchGPUPjiil
	.size	_Z9BranchGPUPjiil, 8

	.type	_Z8BoundGPUPKjPiiiiiPKiS3_l,@object # @_Z8BoundGPUPKjPiiiiiPKiS3_l
	.globl	_Z8BoundGPUPKjPiiiiiPKiS3_l
	.p2align	3, 0x0
_Z8BoundGPUPKjPiiiiiPKiS3_l:
	.quad	_Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l
	.size	_Z8BoundGPUPKjPiiiiiPKiS3_l, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Usage: "
	.size	.L.str, 8

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" input_file output_file"
	.size	.L.str.1, 24

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Step "
	.size	.L.str.2, 6

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	", q = "
	.size	.L.str.3, 7

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"No solution"
	.size	.L.str.4, 12

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"x_"
	.size	.L.str.5, 3

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" = "
	.size	.L.str.6, 4

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Total time: "
	.size	.L.str.7, 13

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9BranchGPUPjiil"
	.size	.L__unnamed_1, 18

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z8BoundGPUPKjPiiiiiPKiS3_l"
	.size	.L__unnamed_2, 28

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z24__device_stub__BranchGPUPjiil
	.addrsig_sym _Z23__device_stub__BoundGPUPKjPiiiiiPKiS3_l
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z9BranchGPUPjiil
	.addrsig_sym _Z8BoundGPUPKjPiiiiiPKiS3_l
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9BranchGPUPjiil       ; -- Begin function _Z9BranchGPUPjiil
	.globl	_Z9BranchGPUPjiil
	.p2align	8
	.type	_Z9BranchGPUPjiil,@function
_Z9BranchGPUPjiil:                      ; @_Z9BranchGPUPjiil
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x24
	s_load_b64 s[2:3], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_mov_b32_e32 v2, 0
	v_cmp_gt_i64_e32 vcc_lo, s[2:3], v[1:2]
	s_and_saveexec_b32 s2, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[2:3], null, v1, s2, 0
	s_ashr_i32 s2, s2, 31
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v0, v3
	v_mad_u64_u32 v[3:4], null, v1, s2, v[0:1]
	s_ashr_i32 s2, s3, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s2, s2, 27
	s_add_i32 s2, s3, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_ashr_i32 s4, s2, 5
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_ashr_i32 s5, s4, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[4:5], s[4:5], 2
	s_add_u32 s0, s4, s0
	s_addc_u32 s1, s5, s1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_load_b32 v2, v[0:1], off
	s_waitcnt vmcnt(0)
	v_lshl_or_b32 v2, 1, s3, v2
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9BranchGPUPjiil
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 5
		.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	_Z9BranchGPUPjiil, .Lfunc_end0-_Z9BranchGPUPjiil
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 208
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; 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
	.protected	_Z8BoundGPUPKjPiiiiiPKiS3_l ; -- Begin function _Z8BoundGPUPKjPiiiiiPKiS3_l
	.globl	_Z8BoundGPUPKjPiiiiiPKiS3_l
	.p2align	8
	.type	_Z8BoundGPUPKjPiiiiiPKiS3_l,@function
_Z8BoundGPUPKjPiiiiiPKiS3_l:            ; @_Z8BoundGPUPKjPiiiiiPKiS3_l
; %bb.0:
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x44
	s_load_b64 s[2:3], s[0:1], 0x30
	s_load_b32 s12, s[0:1], 0x1c
	s_mov_b32 s13, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_mov_b32_e32 v2, 0
	s_cmp_gt_i32 s12, 0
	v_cmp_gt_i64_e32 vcc_lo, s[2:3], v[1:2]
	s_cselect_b32 s2, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB1_12
; %bb.1:                                ; %.preheader.lr.ph
	s_clause 0x1
	s_load_b64 s[8:9], s[0:1], 0x10
	s_load_b128 s[4:7], s[0:1], 0x0
	s_mov_b32 s14, 0
                                        ; implicit-def: $sgpr15
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[3:4], null, v1, s8, 0
	s_ashr_i32 s2, s8, 31
                                        ; implicit-def: $sgpr8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v0, v4
	v_mad_u64_u32 v[4:5], null, v1, s2, v[0:1]
	s_load_b128 s[0:3], s[0:1], 0x20
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	v_add_co_u32 v0, vcc_lo, s4, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v4, vcc_lo
.LBB1_2:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_3 Depth 2
	v_mov_b32_e32 v4, 0
	s_mov_b32 s16, 0
	s_waitcnt lgkmcnt(0)
	s_mov_b64 s[4:5], s[2:3]
	s_mov_b64 s[10:11], s[0:1]
	s_mov_b32 s17, 0
.LBB1_3:                                ;   Parent Loop BB1_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_load_b32 s18, s[10:11], 0x0
	s_waitcnt lgkmcnt(0)
	s_cmp_gt_i32 s18, s9
	s_cbranch_scc1 .LBB1_5
; %bb.4:                                ;   in Loop: Header=BB1_3 Depth=2
	s_ashr_i32 s19, s18, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s19, s19, 27
	s_add_i32 s19, s18, s19
	s_and_b32 s18, s18, 31
	s_ashr_i32 s20, s19, 5
	s_load_b32 s19, s[4:5], 0x0
	s_ashr_i32 s21, s20, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[20:21], s[20:21], 2
	v_add_co_u32 v5, vcc_lo, v0, s20
	v_add_co_ci_u32_e32 v6, vcc_lo, s21, v3, vcc_lo
	global_load_b32 v5, v[5:6], off
	s_waitcnt vmcnt(0)
	v_bfe_u32 v5, v5, s18, 1
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_xor_b32_e32 v5, s19, v5
	v_cmp_eq_u32_e32 vcc_lo, 1, v5
	v_cndmask_b32_e64 v4, v4, 1, vcc_lo
	v_cndmask_b32_e64 v5, 0, 5, vcc_lo
	s_branch .LBB1_6
.LBB1_5:                                ;   in Loop: Header=BB1_3 Depth=2
	v_dual_mov_b32 v4, -1 :: v_dual_mov_b32 v5, 0
.LBB1_6:                                ;   in Loop: Header=BB1_3 Depth=2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_cmp_ne_u32_e32 vcc_lo, 0, v5
	s_add_i32 s18, s17, 1
	s_cmp_gt_u32 s17, 1
	s_cselect_b32 s17, -1, 0
	s_or_b32 s17, vcc_lo, s17
	s_add_u32 s10, s10, 4
	s_addc_u32 s11, s11, 0
	s_add_u32 s4, s4, 4
	s_addc_u32 s5, s5, 0
	s_and_b32 s17, exec_lo, s17
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s16, s17, s16
	s_mov_b32 s17, s18
	s_and_not1_b32 exec_lo, exec_lo, s16
	s_cbranch_execnz .LBB1_3
; %bb.7:                                ; %.critedge
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s16
	s_mov_b32 s5, -1
	s_or_b32 s15, s15, exec_lo
	s_mov_b32 s4, exec_lo
	v_cmpx_ne_u32_e32 0, v4
; %bb.8:                                ;   in Loop: Header=BB1_2 Depth=1
	s_add_i32 s14, s14, 1
	s_add_u32 s0, s0, 12
	s_addc_u32 s1, s1, 0
	s_add_u32 s2, s2, 12
	s_addc_u32 s3, s3, 0
	s_cmp_eq_u32 s14, s12
	s_cselect_b32 s5, -1, 0
	s_and_not1_b32 s15, s15, exec_lo
	s_or_not1_b32 s5, s5, exec_lo
; %bb.9:                                ; %Flow76
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s4, exec_lo, s5
	s_or_b32 s13, s4, s13
	s_and_not1_b32 s4, s8, exec_lo
	s_and_b32 s5, s15, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s8, s4, s5
	s_and_not1_b32 exec_lo, exec_lo, s13
	s_cbranch_execnz .LBB1_2
; %bb.10:                               ; %loop.exit.guard
	s_or_b32 exec_lo, exec_lo, s13
	s_and_saveexec_b32 s0, s8
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB1_12
; %bb.11:
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB1_12:                               ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8BoundGPUPKjPiiiiiPKiS3_l
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 312
		.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 7
		.amdhsa_next_free_sgpr 22
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z8BoundGPUPKjPiiiiiPKiS3_l, .Lfunc_end1-_Z8BoundGPUPKjPiiiiiPKiS3_l
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 572
; NumSgprs: 24
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 24
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           8
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9BranchGPUPjiil
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9BranchGPUPjiil.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .offset:         48
        .size:           8
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         60
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         68
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         70
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         72
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         74
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         76
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         78
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         120
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 312
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8BoundGPUPKjPiiiiiPKiS3_l
    .private_segment_fixed_size: 0
    .sgpr_count:     24
    .sgpr_spill_count: 0
    .symbol:         _Z8BoundGPUPKjPiiiiiPKiS3_l.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
