#include <iostream>
#include <cuda_runtime.h>
#include <vector>
#include <algorithm>

#define BLOCK_SIZE 256
#define NUM_GPUS 2

// B-tree node structure
struct BTNode {
    int keys[128];
    BTNode* children[129];
    int count;
    bool isLeaf;
};

// Kernel to initialize B-tree nodes
__global__ void initNodes(BTNode* nodes, int numNodes) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < numNodes) {
        nodes[idx].count = 0;
        nodes[idx].isLeaf = true;
        for (int i = 0; i < 128; ++i) {
            nodes[idx].keys[i] = 0;
            nodes[idx].children[i] = nullptr;
        }
        nodes[idx].children[128] = nullptr;
    }
}

// Function to insert a key into a B-tree node
__device__ void insertIntoNode(BTNode* node, int key) {
    int i = node->count - 1;
    while (i >= 0 && node->keys[i] > key) {
        node->keys[i + 1] = node->keys[i];
        i--;
    }
    node->keys[i + 1] = key;
    node->count++;
}

// Kernel to insert keys into B-tree nodes
__global__ void insertKeys(BTNode* nodes, int* keys, int numKeys) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < numKeys) {
        insertIntoNode(&nodes[idx % 1024], keys[idx]);
    }
}

// Host function to allocate memory on device
BTNode* allocateNodes(int numNodes, cudaStream_t stream) {
    BTNode* d_nodes;
    cudaMallocAsync(&d_nodes, numNodes * sizeof(BTNode), stream);
    return d_nodes;
}

// Host function to free device memory
void freeNodes(BTNode* d_nodes, cudaStream_t stream) {
    cudaFreeAsync(d_nodes, stream);
}

// Host function to generate random keys
std::vector<int> generateKeys(int numKeys) {
    std::vector<int> keys(numKeys);
    for (int i = 0; i < numKeys; ++i) {
        keys[i] = rand() % 10000;
    }
    return keys;
}

int main() {
    int numNodes = 1024;
    int numKeys = 1024 * NUM_GPUS * BLOCK_SIZE;
    std::vector<int> keys = generateKeys(numKeys);

    cudaStream_t streams[NUM_GPUS];
    BTNode* d_nodes[NUM_GPUS];
    int* d_keys[NUM_GPUS];
    int keysPerGPU = numKeys / NUM_GPUS;

    // Initialize streams and allocate memory
    for (int i = 0; i < NUM_GPUS; ++i) {
        cudaSetDevice(i);
        cudaStreamCreate(&streams[i]);
        d_nodes[i] = allocateNodes(numNodes, streams[i]);
        cudaMallocAsync(&d_keys[i], keysPerGPU * sizeof(int), streams[i]);
        cudaMemcpyAsync(d_keys[i], keys.data() + i * keysPerGPU, keysPerGPU * sizeof(int), cudaMemcpyHostToDevice, streams[i]);
    }

    // Initialize nodes on all GPUs
    for (int i = 0; i < NUM_GPUS; ++i) {
        cudaSetDevice(i);
        initNodes<<<(numNodes + BLOCK_SIZE - 1) / BLOCK_SIZE, BLOCK_SIZE, 0, streams[i]>>>(d_nodes[i], numNodes);
    }

    // Insert keys into nodes on all GPUs
    for (int i = 0; i < NUM_GPUS; ++i) {
        cudaSetDevice(i);
        insertKeys<<<(keysPerGPU + BLOCK_SIZE - 1) / BLOCK_SIZE, BLOCK_SIZE, 0, streams[i]>>>(d_nodes[i], d_keys[i], keysPerGPU);
    }

    // Synchronize and check for errors
    for (int i = 0; i < NUM_GPUS; ++i) {
        cudaSetDevice(i);
        cudaStreamSynchronize(streams[i]);
        cudaError_t err = cudaGetLastError();
        if (err != cudaSuccess) {
            std::cerr << "CUDA error: " << cudaGetErrorString(err) << std::endl;
            return -1;
        }
    }

    // Free allocated memory
    for (int i = 0; i < NUM_GPUS; ++i) {
        cudaSetDevice(i);
        freeNodes(d_nodes[i], streams[i]);
        cudaFreeAsync(d_keys[i], streams[i]);
        cudaStreamDestroy(streams[i]);
    }

    std::cout << "B-tree insertion completed successfully on " << NUM_GPUS << " GPUs." << std::endl;
    return 0;
}
	.file	"tmpxft_00166e3b_00000000-6_cuda_code_037289.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4268:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4268:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z14insertIntoNodeP6BTNodei
	.type	_Z14insertIntoNodeP6BTNodei, @function
_Z14insertIntoNodeP6BTNodei:
.LFB4252:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE4252:
	.size	_Z14insertIntoNodeP6BTNodei, .-_Z14insertIntoNodeP6BTNodei
	.globl	_Z13allocateNodesiP11CUstream_st
	.type	_Z13allocateNodesiP11CUstream_st, @function
_Z13allocateNodesiP11CUstream_st:
.LFB4253:
	.cfi_startproc
	endbr64
	movslq	%edi, %rdi
	movq	%rsi, %rdx
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	imulq	$1552, %rdi, %rsi
	movq	%rsp, %rdi
	call	cudaMallocAsync@PLT
	movq	(%rsp), %rax
	movq	8(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4253:
	.size	_Z13allocateNodesiP11CUstream_st, .-_Z13allocateNodesiP11CUstream_st
	.globl	_Z9freeNodesP6BTNodeP11CUstream_st
	.type	_Z9freeNodesP6BTNodeP11CUstream_st, @function
_Z9freeNodesP6BTNodeP11CUstream_st:
.LFB4254:
	.cfi_startproc
	endbr64
	jmp	cudaFreeAsync@PLT
	.cfi_endproc
.LFE4254:
	.size	_Z9freeNodesP6BTNodeP11CUstream_st, .-_Z9freeNodesP6BTNodeP11CUstream_st
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"cannot create std::vector larger than max_size()"
	.text
	.globl	_Z12generateKeysi
	.type	_Z12generateKeysi, @function
_Z12generateKeysi:
.LFB4255:
	.cfi_startproc
	endbr64
	movabsq	$2305843009213693951, %rax
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movslq	%esi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%r8
	.cfi_def_cfa_offset 48
	cmpq	%r13, %rax
	jnb	.L10
	leaq	.LC0(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L10:
	movq	%rdi, %rbx
	xorl	%edi, %edi
	movq	%r13, %r12
	xorl	%eax, %eax
	movq	%rdi, (%rbx)
	leaq	0(,%r13,4), %rbp
	movq	%rdi, 8(%rbx)
	movq	%rdi, 16(%rbx)
	testq	%r13, %r13
	je	.L11
	movq	%rbp, %rdi
	call	_Znwm@PLT
.L11:
	addq	%rax, %rbp
	movq	%rax, (%rbx)
	movq	%rax, 8(%rbx)
	movq	%rbp, 16(%rbx)
	testq	%r13, %r13
	je	.L12
	xorl	%esi, %esi
	addq	$4, %rax
	movl	%esi, -4(%rax)
	decq	%r13
	je	.L12
.L13:
	cmpq	%rax, %rbp
	je	.L12
	xorl	%ecx, %ecx
	addq	$4, %rax
	movl	%ecx, -4(%rax)
	jmp	.L13
.L12:
	movq	%rax, 8(%rbx)
	xorl	%ebp, %ebp
	movl	$10000, %r13d
.L15:
	cmpl	%ebp, %r12d
	jle	.L26
	call	rand@PLT
	movq	(%rbx), %rcx
	cltd
	idivl	%r13d
	movl	%edx, (%rcx,%rbp,4)
	incq	%rbp
	jmp	.L15
.L26:
	popq	%rdx
	.cfi_def_cfa_offset 40
	movq	%rbx, %rax
	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
.LFE4255:
	.size	_Z12generateKeysi, .-_Z12generateKeysi
	.globl	_Z35__device_stub__Z9initNodesP6BTNodeiP6BTNodei
	.type	_Z35__device_stub__Z9initNodesP6BTNodeiP6BTNodei, @function
_Z35__device_stub__Z9initNodesP6BTNodeiP6BTNodei:
.LFB4290:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z9initNodesP6BTNodei(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L27:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4290:
	.size	_Z35__device_stub__Z9initNodesP6BTNodeiP6BTNodei, .-_Z35__device_stub__Z9initNodesP6BTNodeiP6BTNodei
	.globl	_Z9initNodesP6BTNodei
	.type	_Z9initNodesP6BTNodei, @function
_Z9initNodesP6BTNodei:
.LFB4291:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z9initNodesP6BTNodeiP6BTNodei
	.cfi_endproc
.LFE4291:
	.size	_Z9initNodesP6BTNodei, .-_Z9initNodesP6BTNodei
	.globl	_Z39__device_stub__Z10insertKeysP6BTNodePiiP6BTNodePii
	.type	_Z39__device_stub__Z10insertKeysP6BTNodePiiP6BTNodePii, @function
_Z39__device_stub__Z10insertKeysP6BTNodePiiP6BTNodePii:
.LFB4292:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z10insertKeysP6BTNodePii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L32:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4292:
	.size	_Z39__device_stub__Z10insertKeysP6BTNodePiiP6BTNodePii, .-_Z39__device_stub__Z10insertKeysP6BTNodePiiP6BTNodePii
	.globl	_Z10insertKeysP6BTNodePii
	.type	_Z10insertKeysP6BTNodePii, @function
_Z10insertKeysP6BTNodePii:
.LFB4293:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z10insertKeysP6BTNodePiiP6BTNodePii
	.cfi_endproc
.LFE4293:
	.size	_Z10insertKeysP6BTNodePii, .-_Z10insertKeysP6BTNodePii
	.section	.rodata.str1.1
.LC1:
	.string	"_Z10insertKeysP6BTNodePii"
.LC2:
	.string	"_Z9initNodesP6BTNodei"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4295:
	.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	.LC1(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z10insertKeysP6BTNodePii(%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	.LC2(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z9initNodesP6BTNodei(%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
.LFE4295:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIiSaIiEED2Ev,"axG",@progbits,_ZNSt6vectorIiSaIiEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIiSaIiEED2Ev
	.type	_ZNSt6vectorIiSaIiEED2Ev, @function
_ZNSt6vectorIiSaIiEED2Ev:
.LFB4606:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L39
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L39:
	ret
	.cfi_endproc
.LFE4606:
	.size	_ZNSt6vectorIiSaIiEED2Ev, .-_ZNSt6vectorIiSaIiEED2Ev
	.weak	_ZNSt6vectorIiSaIiEED1Ev
	.set	_ZNSt6vectorIiSaIiEED1Ev,_ZNSt6vectorIiSaIiEED2Ev
	.section	.rodata.str1.1
.LC3:
	.string	"CUDA error: "
.LC4:
	.string	"B-tree insertion completed successfully on "
.LC5:
	.string	" GPUs."
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4265:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4265
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$524288, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	48(%rsp), %rax
	leaq	88(%rsp), %r13
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
.LEHB0:
	call	_Z12generateKeysi
.LEHE0:
.L42:
	movl	%r12d, %edi
.LEHB1:
	call	cudaSetDevice@PLT
	leaq	72(%rsp), %rbx
	leaq	0(%rbp,%rbx), %rdi
	call	cudaStreamCreate@PLT
	movq	72(%rsp,%rbp), %rsi
	movl	$1024, %edi
	call	_Z13allocateNodesiP11CUstream_st
	leaq	104(%rsp), %r14
	movq	72(%rsp,%rbp), %rdx
	movl	$1048576, %esi
	movq	%rax, 0(%r13,%rbp)
	leaq	(%r14,%rbp), %rdi
	call	cudaMallocAsync@PLT
	movq	%rbp, %rsi
	movq	104(%rsp,%rbp), %rdi
	movq	72(%rsp,%rbp), %r8
	movl	$1, %ecx
	salq	$17, %rsi
	movl	$1048576, %edx
	addq	48(%rsp), %rsi
	call	cudaMemcpyAsync@PLT
	addq	$8, %rbp
	testl	%r12d, %r12d
	jne	.L64
	movl	$1, %r12d
	jmp	.L42
.L64:
	movabsq	$4294967552, %r12
	xorl	%ebp, %ebp
.L44:
	movl	%ebp, %edi
	call	cudaSetDevice@PLT
	movl	$1073741825, %edi
	movq	(%rbx,%rbp,8), %r9
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	salq	$2, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r12, 36(%rsp)
	movl	$1, 44(%rsp)
	movq	%rdi, 24(%rsp)
	movl	$1, 32(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L43
	movq	0(%r13,%rbp,8), %rdi
	movl	$1024, %esi
	call	_Z35__device_stub__Z9initNodesP6BTNodeiP6BTNodei
.L43:
	testq	%rbp, %rbp
	jne	.L65
	movl	$1, %ebp
	jmp	.L44
.L65:
	movabsq	$4294967552, %r15
	xorl	%r12d, %r12d
.L46:
	movl	%r12d, %edi
	call	cudaSetDevice@PLT
	movl	$4194305, %edi
	movq	(%rbx,%r12,8), %r9
	xorl	%r8d, %r8d
	movq	%r15, %rdx
	salq	$10, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r15, 36(%rsp)
	movl	$1, 44(%rsp)
	movq	%rdi, 24(%rsp)
	movl	$1, 32(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L45
	movq	(%r14,%r12,8), %rsi
	movq	0(%r13,%r12,8), %rdi
	movl	$262144, %edx
	call	_Z39__device_stub__Z10insertKeysP6BTNodePiiP6BTNodePii
.L45:
	testq	%r12, %r12
	jne	.L66
	movq	%rbp, %r12
	jmp	.L46
.L66:
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movq	72(%rsp), %rdi
	call	cudaStreamSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L47
	movl	$1, %edi
	call	cudaSetDevice@PLT
	movq	80(%rsp), %rdi
	call	cudaStreamSynchronize@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %ebp
	xorl	%r15d, %r15d
	testl	%eax, %eax
	je	.L48
.L47:
	leaq	.LC3(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebp, %edi
	movq	%rax, %rbx
	call	cudaGetErrorString@PLT
	movq	%rax, %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	orl	$-1, %ebx
	jmp	.L49
.L68:
	movq	0(%r13,%r15,8), %rdi
	movq	(%rbx), %rsi
	call	cudaFreeAsync@PLT
	movq	(%r14,%r15,8), %rdi
	movq	(%rbx), %rsi
	call	cudaFreeAsync@PLT
	movq	(%rbx), %rdi
	call	cudaStreamDestroy@PLT
	addq	$8, %rbx
	testq	%r15, %r15
	jne	.L67
	movq	%r12, %r15
.L48:
	movl	%r15d, %edi
	call	cudaSetDevice@PLT
	jmp	.L68
.L67:
	leaq	.LC4(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movl	$2, %esi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	leaq	.LC5(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.LEHE1:
	xorl	%ebx, %ebx
.L49:
	movq	8(%rsp), %rdi
	call	_ZNSt6vectorIiSaIiEED1Ev
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L52
	jmp	.L62
.L59:
	endbr64
	movq	%rax, %rbx
.L50:
	movq	8(%rsp), %rdi
	call	_ZNSt6vectorIiSaIiEED1Ev
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L62
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L62:
	call	__stack_chk_fail@PLT
.L52:
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	movl	%ebx, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4265:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4265:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4265-.LLSDACSB4265
.LLSDACSB4265:
	.uleb128 .LEHB0-.LFB4265
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4265
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L59-.LFB4265
	.uleb128 0
	.uleb128 .LEHB2-.LFB4265
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE4265:
	.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
	.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 <iostream>
#include <hip/hip_runtime.h>
#include <vector>
#include <algorithm>

#define BLOCK_SIZE 256
#define NUM_GPUS 2

// B-tree node structure
struct BTNode {
    int keys[128];
    BTNode* children[129];
    int count;
    bool isLeaf;
};

// Kernel to initialize B-tree nodes
__global__ void initNodes(BTNode* nodes, int numNodes) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < numNodes) {
        nodes[idx].count = 0;
        nodes[idx].isLeaf = true;
        for (int i = 0; i < 128; ++i) {
            nodes[idx].keys[i] = 0;
            nodes[idx].children[i] = nullptr;
        }
        nodes[idx].children[128] = nullptr;
    }
}

// Function to insert a key into a B-tree node
__device__ void insertIntoNode(BTNode* node, int key) {
    int i = node->count - 1;
    while (i >= 0 && node->keys[i] > key) {
        node->keys[i + 1] = node->keys[i];
        i--;
    }
    node->keys[i + 1] = key;
    node->count++;
}

// Kernel to insert keys into B-tree nodes
__global__ void insertKeys(BTNode* nodes, int* keys, int numKeys) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < numKeys) {
        insertIntoNode(&nodes[idx % 1024], keys[idx]);
    }
}

// Host function to allocate memory on device
BTNode* allocateNodes(int numNodes, hipStream_t stream) {
    BTNode* d_nodes;
    hipMallocAsync(&d_nodes, numNodes * sizeof(BTNode), stream);
    return d_nodes;
}

// Host function to free device memory
void freeNodes(BTNode* d_nodes, hipStream_t stream) {
    hipFreeAsync(d_nodes, stream);
}

// Host function to generate random keys
std::vector<int> generateKeys(int numKeys) {
    std::vector<int> keys(numKeys);
    for (int i = 0; i < numKeys; ++i) {
        keys[i] = rand() % 10000;
    }
    return keys;
}

int main() {
    int numNodes = 1024;
    int numKeys = 1024 * NUM_GPUS * BLOCK_SIZE;
    std::vector<int> keys = generateKeys(numKeys);

    hipStream_t streams[NUM_GPUS];
    BTNode* d_nodes[NUM_GPUS];
    int* d_keys[NUM_GPUS];
    int keysPerGPU = numKeys / NUM_GPUS;

    // Initialize streams and allocate memory
    for (int i = 0; i < NUM_GPUS; ++i) {
        hipSetDevice(i);
        hipStreamCreate(&streams[i]);
        d_nodes[i] = allocateNodes(numNodes, streams[i]);
        hipMallocAsync(&d_keys[i], keysPerGPU * sizeof(int), streams[i]);
        hipMemcpyAsync(d_keys[i], keys.data() + i * keysPerGPU, keysPerGPU * sizeof(int), hipMemcpyHostToDevice, streams[i]);
    }

    // Initialize nodes on all GPUs
    for (int i = 0; i < NUM_GPUS; ++i) {
        hipSetDevice(i);
        initNodes<<<(numNodes + BLOCK_SIZE - 1) / BLOCK_SIZE, BLOCK_SIZE, 0, streams[i]>>>(d_nodes[i], numNodes);
    }

    // Insert keys into nodes on all GPUs
    for (int i = 0; i < NUM_GPUS; ++i) {
        hipSetDevice(i);
        insertKeys<<<(keysPerGPU + BLOCK_SIZE - 1) / BLOCK_SIZE, BLOCK_SIZE, 0, streams[i]>>>(d_nodes[i], d_keys[i], keysPerGPU);
    }

    // Synchronize and check for errors
    for (int i = 0; i < NUM_GPUS; ++i) {
        hipSetDevice(i);
        hipStreamSynchronize(streams[i]);
        hipError_t err = hipGetLastError();
        if (err != hipSuccess) {
            std::cerr << "CUDA error: " << hipGetErrorString(err) << std::endl;
            return -1;
        }
    }

    // Free allocated memory
    for (int i = 0; i < NUM_GPUS; ++i) {
        hipSetDevice(i);
        freeNodes(d_nodes[i], streams[i]);
        hipFreeAsync(d_keys[i], streams[i]);
        hipStreamDestroy(streams[i]);
    }

    std::cout << "B-tree insertion completed successfully on " << NUM_GPUS << " GPUs." << std::endl;
    return 0;
}
	.text
	.file	"cuda_code_037289.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z24__device_stub__initNodesP6BTNodei # -- Begin function _Z24__device_stub__initNodesP6BTNodei
	.type	_Z24__device_stub__initNodesP6BTNodei,@function
_Z24__device_stub__initNodesP6BTNodei:  # @_Z24__device_stub__initNodesP6BTNodei
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z9initNodesP6BTNodei, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z24__device_stub__initNodesP6BTNodei, .Lfunc_end0-_Z24__device_stub__initNodesP6BTNodei
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__insertKeysP6BTNodePii # -- Begin function _Z25__device_stub__insertKeysP6BTNodePii
	.type	_Z25__device_stub__insertKeysP6BTNodePii,@function
_Z25__device_stub__insertKeysP6BTNodePii: # @_Z25__device_stub__insertKeysP6BTNodePii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%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	$_Z10insertKeysP6BTNodePii, %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_end1:
	.size	_Z25__device_stub__insertKeysP6BTNodePii, .Lfunc_end1-_Z25__device_stub__insertKeysP6BTNodePii
	.cfi_endproc
                                        # -- End function
	.globl	_Z13allocateNodesiP12ihipStream_t # -- Begin function _Z13allocateNodesiP12ihipStream_t
	.type	_Z13allocateNodesiP12ihipStream_t,@function
_Z13allocateNodesiP12ihipStream_t:      # @_Z13allocateNodesiP12ihipStream_t
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsi, %rdx
	movslq	%edi, %rax
	imulq	$1552, %rax, %rsi               # imm = 0x610
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipMallocAsync
	movq	(%rbx), %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z13allocateNodesiP12ihipStream_t, .Lfunc_end2-_Z13allocateNodesiP12ihipStream_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z9freeNodesP6BTNodeP12ihipStream_t # -- Begin function _Z9freeNodesP6BTNodeP12ihipStream_t
	.type	_Z9freeNodesP6BTNodeP12ihipStream_t,@function
_Z9freeNodesP6BTNodeP12ihipStream_t:    # @_Z9freeNodesP6BTNodeP12ihipStream_t
	.cfi_startproc
# %bb.0:
	jmp	hipFreeAsync                    # TAILCALL
.Lfunc_end3:
	.size	_Z9freeNodesP6BTNodeP12ihipStream_t, .Lfunc_end3-_Z9freeNodesP6BTNodeP12ihipStream_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z12generateKeysi               # -- Begin function _Z12generateKeysi
	.type	_Z12generateKeysi,@function
_Z12generateKeysi:                      # @_Z12generateKeysi
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movslq	%esi, %r14
	leaq	7(%rsp), %rdx
	movq	%r14, %rsi
	callq	_ZNSt6vectorIiSaIiEEC2EmRKS0_
	testl	%r14d, %r14d
	jle	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1759218605, %rax, %rcx         # imm = 0x68DB8BAD
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$44, %rcx
	addl	%edx, %ecx
	imull	$10000, %ecx, %ecx              # imm = 0x2710
	subl	%ecx, %eax
	movq	(%rbx), %rcx
	movl	%eax, (%rcx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB4_2
.LBB4_3:                                # %._crit_edge
	movq	%rbx, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z12generateKeysi, .Lfunc_end4-_Z12generateKeysi
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorIiSaIiEEC2EmRKS0_,"axG",@progbits,_ZNSt6vectorIiSaIiEEC2EmRKS0_,comdat
	.weak	_ZNSt6vectorIiSaIiEEC2EmRKS0_   # -- Begin function _ZNSt6vectorIiSaIiEEC2EmRKS0_
	.p2align	1, 0x90
	.type	_ZNSt6vectorIiSaIiEEC2EmRKS0_,@function
_ZNSt6vectorIiSaIiEEC2EmRKS0_:          # @_ZNSt6vectorIiSaIiEEC2EmRKS0_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rax
	shrq	$61, %rax
	jne	.LBB5_7
# %bb.1:                                # %_ZNSt6vectorIiSaIiEE17_S_check_init_lenEmRKS0_.exit
	movq	%rsi, %r14
	movq	%rdi, %rbx
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rdi)
	movq	$0, 16(%rdi)
	testq	%rsi, %rsi
	je	.LBB5_2
# %bb.3:
	movq	%rbx, %rdi
	movq	%r14, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorIiE8allocateEmPKv
	movq	%rax, (%rbx)
	leaq	(%rax,%r14,4), %r15
	movq	%r15, 16(%rbx)
	movl	$0, (%rax)
	addq	$4, %rax
	cmpq	$1, %r14
	jne	.LBB5_5
# %bb.4:
	movq	%rax, %r15
	jmp	.LBB5_6
.LBB5_2:                                # %_ZNSt12_Vector_baseIiSaIiEEC2EmRKS0_.exit.thread
	movups	%xmm0, (%rbx)
	movq	$0, 16(%rbx)
	xorl	%r15d, %r15d
	jmp	.LBB5_6
.LBB5_5:                                # %_ZSt6fill_nIPimiET_S1_T0_RKT1_.exit.loopexit.i.i.i.i
	leaq	-4(,%r14,4), %rdx
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.LBB5_6:
	movq	%r15, 8(%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB5_7:
	.cfi_def_cfa_offset 32
	movl	$.L.str.3, %edi
	callq	_ZSt20__throw_length_errorPKc
.Lfunc_end5:
	.size	_ZNSt6vectorIiSaIiEEC2EmRKS0_, .Lfunc_end5-_ZNSt6vectorIiSaIiEEC2EmRKS0_
	.cfi_endproc
                                        # -- End function
	.text
	.globl	main                            # -- Begin function 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	%rbx
	.cfi_def_cfa_offset 40
	subq	$88, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	64(%rsp), %rdi
	movl	$524288, %esi                   # imm = 0x80000
	callq	_Z12generateKeysi
	movb	$1, %bpl
	xorl	%r14d, %r14d
	leaq	56(%rsp), %rbx
.LBB6_1:                                # =>This Inner Loop Header: Depth=1
.Ltmp0:
	movl	%r14d, %edi
	callq	hipSetDevice
.Ltmp1:
# %bb.2:                                #   in Loop: Header=BB6_1 Depth=1
	leaq	(%rsp,%r14,8), %r15
.Ltmp2:
	movq	%r15, %rdi
	callq	hipStreamCreate
.Ltmp3:
# %bb.3:                                #   in Loop: Header=BB6_1 Depth=1
	movq	(%r15), %rdx
.Ltmp4:
	movl	$1589248, %esi                  # imm = 0x184000
	movq	%rbx, %rdi
	callq	hipMallocAsync
.Ltmp5:
# %bb.4:                                #   in Loop: Header=BB6_1 Depth=1
	movq	56(%rsp), %rax
	movq	%rax, 32(%rsp,%r14,8)
	leaq	(%rsp,%r14,8), %rdi
	addq	$16, %rdi
	movq	(%rsp,%r14,8), %rdx
.Ltmp6:
	movl	$1048576, %esi                  # imm = 0x100000
	callq	hipMallocAsync
.Ltmp7:
# %bb.5:                                # %_ZL14hipMallocAsyncIiE10hipError_tPPT_mP12ihipStream_t.exit
                                        #   in Loop: Header=BB6_1 Depth=1
	movq	16(%rsp,%r14,8), %rdi
	movq	%r14, %rsi
	shlq	$20, %rsi
	addq	64(%rsp), %rsi
	movq	(%rsp,%r14,8), %r8
.Ltmp8:
	movl	$1048576, %edx                  # imm = 0x100000
	movl	$1, %ecx
	callq	hipMemcpyAsync
.Ltmp9:
# %bb.6:                                #   in Loop: Header=BB6_1 Depth=1
	movl	$1, %r14d
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB6_1
# %bb.7:                                # %.preheader107.preheader
	movb	$1, %bpl
	xorl	%r15d, %r15d
	movabsq	$4294967300, %rbx               # imm = 0x100000004
	movabsq	$4294967552, %r14               # imm = 0x100000100
.LBB6_8:                                # %.preheader107
                                        # =>This Inner Loop Header: Depth=1
.Ltmp11:
	movl	%r15d, %edi
	callq	hipSetDevice
.Ltmp12:
# %bb.9:                                #   in Loop: Header=BB6_8 Depth=1
	movq	(%rsp,%r15,8), %r9
.Ltmp13:
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
.Ltmp14:
# %bb.10:                               #   in Loop: Header=BB6_8 Depth=1
	testl	%eax, %eax
	jne	.LBB6_12
# %bb.11:                               #   in Loop: Header=BB6_8 Depth=1
	movq	32(%rsp,%r15,8), %rdi
.Ltmp15:
	movl	$1024, %esi                     # imm = 0x400
	callq	_Z24__device_stub__initNodesP6BTNodei
.Ltmp16:
.LBB6_12:                               #   in Loop: Header=BB6_8 Depth=1
	movl	$1, %r15d
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB6_8
# %bb.13:                               # %.preheader106.preheader
	movb	$1, %bpl
	xorl	%r15d, %r15d
	movabsq	$4294968320, %rbx               # imm = 0x100000400
	movabsq	$4294967552, %r14               # imm = 0x100000100
.LBB6_14:                               # %.preheader106
                                        # =>This Inner Loop Header: Depth=1
.Ltmp18:
	movl	%r15d, %edi
	callq	hipSetDevice
.Ltmp19:
# %bb.15:                               #   in Loop: Header=BB6_14 Depth=1
	movq	(%rsp,%r15,8), %r9
.Ltmp20:
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
.Ltmp21:
# %bb.16:                               #   in Loop: Header=BB6_14 Depth=1
	testl	%eax, %eax
	jne	.LBB6_18
# %bb.17:                               #   in Loop: Header=BB6_14 Depth=1
	movq	32(%rsp,%r15,8), %rdi
	movq	16(%rsp,%r15,8), %rsi
.Ltmp22:
	movl	$262144, %edx                   # imm = 0x40000
	callq	_Z25__device_stub__insertKeysP6BTNodePii
.Ltmp23:
.LBB6_18:                               #   in Loop: Header=BB6_14 Depth=1
	movl	$1, %r15d
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB6_14
# %bb.19:                               # %.preheader.preheader
	movb	$1, %bpl
	xorl	%ebx, %ebx
.LBB6_20:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
.Ltmp25:
	movl	%ebx, %edi
	callq	hipSetDevice
.Ltmp26:
# %bb.21:                               #   in Loop: Header=BB6_20 Depth=1
	movq	(%rsp,%rbx,8), %rdi
.Ltmp27:
	callq	hipStreamSynchronize
.Ltmp28:
# %bb.22:                               #   in Loop: Header=BB6_20 Depth=1
.Ltmp30:
	callq	hipGetLastError
.Ltmp31:
# %bb.23:                               #   in Loop: Header=BB6_20 Depth=1
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.LBB6_37
# %bb.24:                               #   in Loop: Header=BB6_20 Depth=1
	movl	$1, %ebx
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB6_20
# %bb.25:                               # %_ZNSolsEPFRSoS_E.exit.preheader.preheader
	movb	$1, %bpl
	xorl	%ebx, %ebx
.LBB6_26:                               # %_ZNSolsEPFRSoS_E.exit.preheader
                                        # =>This Inner Loop Header: Depth=1
.Ltmp48:
	movl	%ebx, %edi
	callq	hipSetDevice
.Ltmp49:
# %bb.27:                               #   in Loop: Header=BB6_26 Depth=1
	movq	32(%rsp,%rbx,8), %rdi
	movq	(%rsp,%rbx,8), %rsi
.Ltmp50:
	callq	hipFreeAsync
.Ltmp51:
# %bb.28:                               # %_Z9freeNodesP6BTNodeP12ihipStream_t.exit
                                        #   in Loop: Header=BB6_26 Depth=1
	movq	16(%rsp,%rbx,8), %rdi
	movq	(%rsp,%rbx,8), %rsi
.Ltmp52:
	callq	hipFreeAsync
.Ltmp53:
# %bb.29:                               #   in Loop: Header=BB6_26 Depth=1
	movq	(%rsp,%rbx,8), %rdi
.Ltmp54:
	callq	hipStreamDestroy
.Ltmp55:
# %bb.30:                               # %_ZNSolsEPFRSoS_E.exit
                                        #   in Loop: Header=BB6_26 Depth=1
	movl	$1, %ebx
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB6_26
# %bb.31:
.Ltmp57:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$43, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp58:
# %bb.32:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit78
.Ltmp59:
	movl	$_ZSt4cout, %edi
	movl	$2, %esi
	callq	_ZNSolsEi
.Ltmp60:
# %bb.33:
.Ltmp61:
	movq	%rax, %rbx
	movl	$.L.str.2, %esi
	movl	$6, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp62:
# %bb.34:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit81
	movq	(%rbx), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp63:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp64:
# %bb.35:                               # %.noexc89
.Ltmp65:
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
.Ltmp66:
# %bb.36:                               # %.noexc90
	xorl	%ebx, %ebx
.Ltmp67:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp68:
	jmp	.LBB6_45
.LBB6_37:
.Ltmp33:
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp34:
# %bb.38:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
.Ltmp35:
	movl	%ebx, %edi
	callq	hipGetErrorString
.Ltmp36:
# %bb.39:
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.LBB6_40
# %bb.41:
	movq	%rbx, %rdi
	callq	strlen
.Ltmp37:
	movl	$_ZSt4cerr, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp38:
	jmp	.LBB6_42
.LBB6_40:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
.Ltmp39:
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.Ltmp40:
.LBB6_42:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit75
	movq	_ZSt4cerr(%rip), %rax
	movl	$_ZSt4cerr, %edi
	addq	-24(%rax), %rdi
.Ltmp41:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp42:
# %bb.43:                               # %.noexc86
.Ltmp43:
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
.Ltmp44:
# %bb.44:                               # %.noexc87
	movl	$-1, %ebx
.Ltmp45:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp46:
.LBB6_45:                               # %_ZNSolsEPFRSoS_E.exit83
	movq	64(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB6_47
# %bb.46:
	callq	_ZdlPv
.LBB6_47:                               # %_ZNSt6vectorIiSaIiEED2Ev.exit
	movl	%ebx, %eax
	addq	$88, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB6_52:
	.cfi_def_cfa_offset 128
.Ltmp69:
	jmp	.LBB6_54
.LBB6_50:                               # %.loopexit.split-lp
.Ltmp47:
	jmp	.LBB6_54
.LBB6_49:                               # %.loopexit
.Ltmp32:
	jmp	.LBB6_54
.LBB6_48:
.Ltmp29:
	jmp	.LBB6_54
.LBB6_51:
.Ltmp56:
	jmp	.LBB6_54
.LBB6_58:
.Ltmp24:
	jmp	.LBB6_54
.LBB6_57:
.Ltmp17:
	jmp	.LBB6_54
.LBB6_53:
.Ltmp10:
.LBB6_54:
	movq	%rax, %rbx
	movq	64(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB6_56
# %bb.55:
	callq	_ZdlPv
.LBB6_56:                               # %_ZNSt6vectorIiSaIiEED2Ev.exit85
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end6:
	.size	main, .Lfunc_end6-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table6:
.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 .Ltmp9-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp9
	.uleb128 .Ltmp10-.Lfunc_begin0          #     jumps to .Ltmp10
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp11-.Lfunc_begin0          # >> Call Site 3 <<
	.uleb128 .Ltmp16-.Ltmp11                #   Call between .Ltmp11 and .Ltmp16
	.uleb128 .Ltmp17-.Lfunc_begin0          #     jumps to .Ltmp17
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp18-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp23-.Ltmp18                #   Call between .Ltmp18 and .Ltmp23
	.uleb128 .Ltmp24-.Lfunc_begin0          #     jumps to .Ltmp24
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp25-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp28-.Ltmp25                #   Call between .Ltmp25 and .Ltmp28
	.uleb128 .Ltmp29-.Lfunc_begin0          #     jumps to .Ltmp29
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp30-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp31-.Ltmp30                #   Call between .Ltmp30 and .Ltmp31
	.uleb128 .Ltmp32-.Lfunc_begin0          #     jumps to .Ltmp32
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp48-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp55-.Ltmp48                #   Call between .Ltmp48 and .Ltmp55
	.uleb128 .Ltmp56-.Lfunc_begin0          #     jumps to .Ltmp56
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp57-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp68-.Ltmp57                #   Call between .Ltmp57 and .Ltmp68
	.uleb128 .Ltmp69-.Lfunc_begin0          #     jumps to .Ltmp69
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp33-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp46-.Ltmp33                #   Call between .Ltmp33 and .Ltmp46
	.uleb128 .Ltmp47-.Lfunc_begin0          #     jumps to .Ltmp47
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp46-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Lfunc_end6-.Ltmp46            #   Call between .Ltmp46 and .Lfunc_end6
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt15__new_allocatorIiE8allocateEmPKv,"axG",@progbits,_ZNSt15__new_allocatorIiE8allocateEmPKv,comdat
	.weak	_ZNSt15__new_allocatorIiE8allocateEmPKv # -- Begin function _ZNSt15__new_allocatorIiE8allocateEmPKv
	.p2align	1, 0x90
	.type	_ZNSt15__new_allocatorIiE8allocateEmPKv,@function
_ZNSt15__new_allocatorIiE8allocateEmPKv: # @_ZNSt15__new_allocatorIiE8allocateEmPKv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rax
	shrq	$61, %rax
	jne	.LBB7_1
# %bb.3:
	shlq	$2, %rsi
	movq	%rsi, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Znwm                           # TAILCALL
.LBB7_1:
	.cfi_def_cfa_offset 16
	shrq	$62, %rsi
	je	.LBB7_2
# %bb.4:
	callq	_ZSt28__throw_bad_array_new_lengthv
.LBB7_2:
	callq	_ZSt17__throw_bad_allocv
.Lfunc_end7:
	.size	_ZNSt15__new_allocatorIiE8allocateEmPKv, .Lfunc_end7-_ZNSt15__new_allocatorIiE8allocateEmPKv
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9initNodesP6BTNodei, %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	$_Z10insertKeysP6BTNodePii, %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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z9initNodesP6BTNodei,@object   # @_Z9initNodesP6BTNodei
	.section	.rodata,"a",@progbits
	.globl	_Z9initNodesP6BTNodei
	.p2align	3, 0x0
_Z9initNodesP6BTNodei:
	.quad	_Z24__device_stub__initNodesP6BTNodei
	.size	_Z9initNodesP6BTNodei, 8

	.type	_Z10insertKeysP6BTNodePii,@object # @_Z10insertKeysP6BTNodePii
	.globl	_Z10insertKeysP6BTNodePii
	.p2align	3, 0x0
_Z10insertKeysP6BTNodePii:
	.quad	_Z25__device_stub__insertKeysP6BTNodePii
	.size	_Z10insertKeysP6BTNodePii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CUDA error: "
	.size	.L.str, 13

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"B-tree insertion completed successfully on "
	.size	.L.str.1, 44

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	" GPUs."
	.size	.L.str.2, 7

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9initNodesP6BTNodei"
	.size	.L__unnamed_1, 22

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z10insertKeysP6BTNodePii"
	.size	.L__unnamed_2, 26

	.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__initNodesP6BTNodei
	.addrsig_sym _Z25__device_stub__insertKeysP6BTNodePii
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z9initNodesP6BTNodei
	.addrsig_sym _Z10insertKeysP6BTNodePii
	.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	_Z9initNodesP6BTNodei   ; -- Begin function _Z9initNodesP6BTNodei
	.globl	_Z9initNodesP6BTNodei
	.p2align	8
	.type	_Z9initNodesP6BTNodei,@function
_Z9initNodesP6BTNodei:                  ; @_Z9initNodesP6BTNodei
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_4
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v5, 1
	s_mov_b64 s[2:3], 0
	s_waitcnt lgkmcnt(0)
	v_mad_i64_i32 v[2:3], null, 0x610, v1, s[0:1]
	s_clause 0x1
	global_store_b32 v[2:3], v4, off offset:1544
	global_store_b8 v[2:3], v5, off offset:1548
	v_add_co_u32 v0, vcc_lo, 0x200, v2
	v_add_co_ci_u32_e32 v6, vcc_lo, 0, v3, vcc_lo
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v7, vcc_lo, v0, s2
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v6, vcc_lo
	global_store_b32 v[2:3], v4, off
	v_add_co_u32 v2, vcc_lo, v2, 4
	v_mov_b32_e32 v5, v4
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
	s_cmpk_eq_i32 s2, 0x400
	global_store_b64 v[7:8], v[4:5], off
	s_cbranch_scc0 .LBB0_2
; %bb.3:
	v_mov_b32_e32 v0, 0
	v_mad_i64_i32 v[2:3], null, 0x610, v1, s[0:1]
	s_delay_alu instid0(VALU_DEP_2)
	v_mov_b32_e32 v1, v0
	global_store_b64 v[2:3], v[0:1], off offset:1536
.LBB0_4:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9initNodesP6BTNodei
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 9
		.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	_Z9initNodesP6BTNodei, .Lfunc_end0-_Z9initNodesP6BTNodei
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 240
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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	_Z10insertKeysP6BTNodePii ; -- Begin function _Z10insertKeysP6BTNodePii
	.globl	_Z10insertKeysP6BTNodePii
	.p2align	8
	.type	_Z10insertKeysP6BTNodePii,@function
_Z10insertKeysP6BTNodePii:              ; @_Z10insertKeysP6BTNodePii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b32 s3, s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB1_8
; %bb.1:
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b128 s[0:3], s[0:1], 0x0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshrrev_b32_e32 v0, 22, v2
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_nc_u32_e32 v0, v1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_and_b32_e32 v0, 0xfffffc00, v0
	v_sub_nc_u32_e32 v7, v1, v0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_co_u32 v2, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	v_mad_i64_i32 v[0:1], null, 0x610, v7, s[0:1]
	s_mov_b32 s3, 0
	s_mov_b32 s2, exec_lo
	global_load_b32 v4, v[0:1], off offset:1544
	global_load_b32 v9, v[2:3], off
	v_add_co_u32 v2, vcc_lo, 0x608, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v1, vcc_lo
	s_waitcnt vmcnt(1)
	v_cmpx_lt_i32_e32 0, v4
	s_cbranch_execz .LBB1_7
; %bb.2:                                ; %.lr.ph.i.preheader
	v_mov_b32_e32 v6, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v5, v6
	v_lshlrev_b64 v[10:11], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_i64_i32 v[12:13], null, 0x610, v7, v[10:11]
	v_add_co_u32 v7, vcc_lo, s0, v12
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v8, vcc_lo, s1, v13, vcc_lo
                                        ; implicit-def: $sgpr1
.LBB1_3:                                ; %.lr.ph.i
                                        ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v5, -1, v4
	s_or_b32 s1, s1, exec_lo
	s_mov_b32 s4, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[10:11], 2, v[5:6]
	v_add_co_u32 v10, vcc_lo, v0, v10
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v11, vcc_lo, v1, v11, vcc_lo
	global_load_b32 v10, v[10:11], off
	s_waitcnt vmcnt(0)
	v_cmpx_gt_i32_e64 v10, v9
	s_cbranch_execz .LBB1_5
; %bb.4:                                ;   in Loop: Header=BB1_3 Depth=1
	v_cmp_gt_u32_e32 vcc_lo, 2, v4
	global_store_b32 v[7:8], v10, off
	v_add_co_u32 v7, s0, v7, -4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e64 v8, s0, -1, v8, s0
	v_mov_b32_e32 v4, 0
	s_and_not1_b32 s0, s1, exec_lo
	s_and_b32 s1, vcc_lo, exec_lo
	s_or_b32 s1, s0, s1
.LBB1_5:                                ; %Flow
                                        ;   in Loop: Header=BB1_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s4
	v_mov_b32_e32 v10, v4
	v_mov_b32_e32 v4, v5
	s_and_b32 s0, exec_lo, s1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s3, s0, s3
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB1_3
; %bb.6:                                ; %Flow16
	s_or_b32 exec_lo, exec_lo, s3
	v_mov_b32_e32 v4, v10
.LBB1_7:                                ; %Flow17
	s_or_b32 exec_lo, exec_lo, s2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, v0, v4
	v_add_co_ci_u32_e32 v1, vcc_lo, v1, v5, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v9, off
	global_load_b32 v0, v[2:3], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v0, 1, v0
	global_store_b32 v[2:3], v0, off
.LBB1_8:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10insertKeysP6BTNodePii
		.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 14
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z10insertKeysP6BTNodePii, .Lfunc_end1-_Z10insertKeysP6BTNodePii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 480
; NumSgprs: 18
; NumVgprs: 14
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 14
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9initNodesP6BTNodei
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z9initNodesP6BTNodei.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .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:         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:           _Z10insertKeysP6BTNodePii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10insertKeysP6BTNodePii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     14
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
