/*
 * Noopur Maheshwari : 111464061
 * Rahul Rane : 111465246
 */
#include <iostream>
#include <vector>
#include <map>
using namespace std;

extern void *__do_work_cpu(void *data);
extern void *__do_work_gpu(void *data);
extern map<pthread_t, pthread_mutex_t> cpu_lock_map;
extern map<pthread_t, pthread_mutex_t> gpu_lock_map;
extern map<pthread_t, cudaStream_t> stream_map;
vector<pthread_t> cpu_workers;
vector<pthread_t> gpu_workers;

bool __create_cpu_threadpool(int nworkers) {
    cpu_workers.resize(nworkers);
    bool ret = true;
    for (int i=0; i<nworkers; i++) {
        if(pthread_create(&cpu_workers[i], NULL, __do_work_cpu, (void *)(i+1))) {
            cout<<"Failed to create thread for id :"<<i<<endl;
            ret = false;
        } else {
            pthread_mutex_init(&cpu_lock_map[cpu_workers[i]], NULL);
        }
    }
    return ret;
}

bool __create_gpu_threadpool(int nworkers) {
    gpu_workers.resize(nworkers);
    bool ret = true;
    for (int i=0; i<nworkers; i++) {
        if(pthread_create(&gpu_workers[i], NULL, __do_work_gpu, (void *)(i+1))) {
            //cout<<"Failed to create thread for id :"<<i<<endl;
            ret = false;
        } else {
            cudaStreamCreate(&stream_map[gpu_workers[i]]);
            pthread_mutex_init(&gpu_lock_map[gpu_workers[i]], NULL);
        }
    }
    return ret;
}

bool create_threadpool(int nworkers) {
    bool ret;
    ret = __create_cpu_threadpool(nworkers);
    if (!ret) {
        cout<<"Failed to spawn cpu threads"<<endl;
    }

    ret = __create_gpu_threadpool(nworkers);
    if (!ret) {
        //cout<<"Failed to spawn gpu threads"<<endl;
    }

    return ret;
}

void wait_until_done() {
    void *status;
    for(int i=0; i<cpu_workers.size(); i++) {
        if(pthread_join(cpu_workers[i], &status)) {
            cout<<"Failed to join thread for id :"<<i<<endl;
        }
    }
    cout<<"CPU threads finished"<<endl; 
    for(int i=0; i<gpu_workers.size()-1; i++) {
        if(pthread_join(gpu_workers[i], &status)) {
            cout<<"Failed to join thread for id :"<<i<<endl;
        }
    }
    cudaDeviceReset();
    cout<<"GPU threads finished"<<endl;
    return;
}

	.file	"tmpxft_003590de_00000000-6_threadpool.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4418:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4418:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB5350:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE5350:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.text._ZNSt6vectorImSaImEED2Ev,"axG",@progbits,_ZNSt6vectorImSaImEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorImSaImEED2Ev
	.type	_ZNSt6vectorImSaImEED2Ev, @function
_ZNSt6vectorImSaImEED2Ev:
.LFB5339:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L3
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L3:
	ret
	.cfi_endproc
.LFE5339:
	.size	_ZNSt6vectorImSaImEED2Ev, .-_ZNSt6vectorImSaImEED2Ev
	.weak	_ZNSt6vectorImSaImEED1Ev
	.set	_ZNSt6vectorImSaImEED1Ev,_ZNSt6vectorImSaImEED2Ev
	.section	.text._ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_.isra.0,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_,comdat
	.align 2
	.type	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_.isra.0, @function
_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_.isra.0:
.LFB5354:
	.cfi_startproc
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movb	$1, %al
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	8(%rdi), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	16(%rdi), %rbx
.L7:
	testq	%rbx, %rbx
	je	.L15
	cmpq	32(%rbx), %r12
	movq	24(%rbx), %rdx
	movq	%rbx, %rbp
	cmovb	16(%rbx), %rdx
	setb	%al
	movq	%rdx, %rbx
	jmp	.L7
.L15:
	testb	%al, %al
	je	.L13
	cmpq	%rbp, 24(%rdi)
	je	.L11
	movq	%rbp, %rdi
	call	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base@PLT
	jmp	.L10
.L13:
	movq	%rbp, %rax
.L10:
	xorl	%edx, %edx
	cmpq	%r12, 32(%rax)
	cmovnb	%rdx, %rbp
	cmovnb	%rax, %rbx
.L11:
	movq	%rbx, %rax
	movq	%rbp, %rdx
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5354:
	.size	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_.isra.0, .-_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_.isra.0
	.section	.text._ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_.isra.0,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_,comdat
	.align 2
	.type	_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_.isra.0, @function
_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_.isra.0:
.LFB5355:
	.cfi_startproc
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movb	$1, %al
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	8(%rdi), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	16(%rdi), %rbx
.L17:
	testq	%rbx, %rbx
	je	.L25
	cmpq	32(%rbx), %r12
	movq	24(%rbx), %rdx
	movq	%rbx, %rbp
	cmovb	16(%rbx), %rdx
	setb	%al
	movq	%rdx, %rbx
	jmp	.L17
.L25:
	testb	%al, %al
	je	.L23
	cmpq	%rbp, 24(%rdi)
	je	.L21
	movq	%rbp, %rdi
	call	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base@PLT
	jmp	.L20
.L23:
	movq	%rbp, %rax
.L20:
	xorl	%edx, %edx
	cmpq	%r12, 32(%rax)
	cmovnb	%rdx, %rbp
	cmovnb	%rax, %rbx
.L21:
	movq	%rbx, %rax
	movq	%rbp, %rdx
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5355:
	.size	_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_.isra.0, .-_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Failed to join thread for id :"
.LC1:
	.string	"CPU threads finished"
.LC2:
	.string	"GPU threads finished"
	.text
	.globl	_Z15wait_until_donev
	.type	_Z15wait_until_donev, @function
_Z15wait_until_donev:
.LFB4415:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
.L27:
	movq	cpu_workers(%rip), %rdx
	movq	8+cpu_workers(%rip), %rax
	subq	%rdx, %rax
	sarq	$3, %rax
	cmpq	%rax, %rbx
	jnb	.L41
	movq	(%rdx,%rbx,8), %rdi
	movq	%rsp, %rsi
	call	pthread_join@PLT
	testl	%eax, %eax
	je	.L28
	movq	%rbp, %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L28:
	incq	%rbx
	jmp	.L27
.L41:
	leaq	_ZSt4cout(%rip), %rbp
	leaq	.LC1(%rip), %rsi
	xorl	%ebx, %ebx
	movq	%rbp, %rdi
	leaq	.LC0(%rip), %r12
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L30:
	movq	gpu_workers(%rip), %rdx
	movq	8+gpu_workers(%rip), %rax
	subq	%rdx, %rax
	sarq	$3, %rax
	decq	%rax
	cmpq	%rax, %rbx
	jnb	.L42
	movq	(%rdx,%rbx,8), %rdi
	movq	%rsp, %rsi
	call	pthread_join@PLT
	testl	%eax, %eax
	je	.L31
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L31:
	incq	%rbx
	jmp	.L30
.L42:
	call	cudaDeviceReset@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rbp, %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
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L33
	call	__stack_chk_fail@PLT
.L33:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4415:
	.size	_Z15wait_until_donev, .-_Z15wait_until_donev
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4441:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE4441:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_,comdat
	.align 2
	.weak	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_
	.type	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_, @function
_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_:
.LFB5066:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	8(%rdi), %rax
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rsi, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	(%rdx), %rsi
	cmpq	%rax, %rbx
	jne	.L46
	cmpq	$0, 40(%rdi)
	je	.L55
	movq	32(%rdi), %rdx
	cmpq	%rsi, 32(%rdx)
	jnb	.L55
	jmp	.L58
.L46:
	movq	32(%rbx), %rax
	cmpq	%rax, %rsi
	jnb	.L49
	movq	24(%rdi), %rax
	cmpq	%rbx, %rax
	je	.L56
	movq	%rbx, %rdi
	movq	%rsi, 8(%rsp)
	call	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base@PLT
	movq	8(%rsp), %rsi
	movq	%rax, %rdx
	cmpq	%rsi, 32(%rax)
	jnb	.L55
	cmpq	$0, 24(%rdx)
	movq	%rbx, %rax
	jne	.L56
	jmp	.L58
.L49:
	cmpq	%rsi, %rax
	jnb	.L53
	movq	32(%rdi), %rdx
	cmpq	%rbx, %rdx
	jne	.L54
.L58:
	xorl	%eax, %eax
	jmp	.L48
.L54:
	movq	%rbx, %rdi
	movq	%rsi, 8(%rsp)
	call	_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base@PLT
	movq	8(%rsp), %rsi
	cmpq	32(%rax), %rsi
	jnb	.L55
	cmpq	$0, 24(%rbx)
	jne	.L56
	xorl	%eax, %eax
	movq	%rbx, %rdx
	jmp	.L48
.L56:
	movq	%rax, %rdx
	jmp	.L48
.L55:
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%rbp, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_.isra.0
.L53:
	.cfi_restore_state
	movq	%rbx, %rax
	xorl	%edx, %edx
.L48:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5066:
	.size	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_, .-_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_
	.section	.text._ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_,"axG",@progbits,_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_,comdat
	.align 2
	.weak	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	.type	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_, @function
_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_:
.LFB4755:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	8(%rdi), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r13, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 64
	movq	(%rsi), %rdx
	movq	16(%rdi), %rax
.L60:
	testq	%rax, %rax
	je	.L69
	movq	16(%rax), %rcx
	movq	24(%rax), %rsi
	cmpq	%rdx, 32(%rax)
	jnb	.L61
	movq	%rbx, %rax
	movq	%rsi, %rcx
.L61:
	movq	%rax, %rbx
	movq	%rcx, %rax
	jmp	.L60
.L69:
	cmpq	%rbx, %r13
	je	.L63
	cmpq	32(%rbx), %rdx
	jnb	.L64
.L63:
	movl	$80, %edi
	movq	%rbx, %r15
	call	_Znwm@PLT
	movq	(%r12), %r14
	movl	$10, %ecx
	movq	%r15, %rsi
	movq	%rax, %rbx
	leaq	40(%rax), %rdi
	movq	%r14, 32(%rax)
	xorl	%eax, %eax
	leaq	32(%rbx), %rdx
	rep stosl
	movq	%rbp, %rdi
	call	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_
	movq	%rax, %r12
	testq	%rdx, %rdx
	je	.L65
	testq	%rax, %rax
	setne	%dil
	cmpq	%rdx, %r13
	sete	%al
	orb	%al, %dil
	jne	.L66
	cmpq	32(%rdx), %r14
	setb	%dil
.L66:
	movzbl	%dil, %edi
	movq	%r13, %rcx
	movq	%rbx, %rsi
	call	_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_@PLT
	incq	40(%rbp)
	jmp	.L64
.L65:
	movq	%rbx, %rdi
	movl	$80, %esi
	movq	%r12, %rbx
	call	_ZdlPvm@PLT
.L64:
	popq	%rdx
	.cfi_def_cfa_offset 56
	leaq	40(%rbx), %rax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4755:
	.size	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_, .-_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	.section	.text._ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_,comdat
	.align 2
	.weak	_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_
	.type	_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_, @function
_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_:
.LFB5090:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	8(%rdi), %rax
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rsi, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	(%rdx), %rsi
	cmpq	%rax, %rbx
	jne	.L71
	cmpq	$0, 40(%rdi)
	je	.L80
	movq	32(%rdi), %rdx
	cmpq	%rsi, 32(%rdx)
	jnb	.L80
	jmp	.L83
.L71:
	movq	32(%rbx), %rax
	cmpq	%rax, %rsi
	jnb	.L74
	movq	24(%rdi), %rax
	cmpq	%rbx, %rax
	je	.L81
	movq	%rbx, %rdi
	movq	%rsi, 8(%rsp)
	call	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base@PLT
	movq	8(%rsp), %rsi
	movq	%rax, %rdx
	cmpq	%rsi, 32(%rax)
	jnb	.L80
	cmpq	$0, 24(%rdx)
	movq	%rbx, %rax
	jne	.L81
	jmp	.L83
.L74:
	cmpq	%rsi, %rax
	jnb	.L78
	movq	32(%rdi), %rdx
	cmpq	%rbx, %rdx
	jne	.L79
.L83:
	xorl	%eax, %eax
	jmp	.L73
.L79:
	movq	%rbx, %rdi
	movq	%rsi, 8(%rsp)
	call	_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base@PLT
	movq	8(%rsp), %rsi
	cmpq	32(%rax), %rsi
	jnb	.L80
	cmpq	$0, 24(%rbx)
	jne	.L81
	xorl	%eax, %eax
	movq	%rbx, %rdx
	jmp	.L73
.L81:
	movq	%rax, %rdx
	jmp	.L73
.L80:
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%rbp, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_.isra.0
.L78:
	.cfi_restore_state
	movq	%rbx, %rax
	xorl	%edx, %edx
.L73:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5090:
	.size	_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_, .-_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_
	.section	.text._ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_,"axG",@progbits,_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_,comdat
	.weak	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_
	.type	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_, @function
_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_:
.LFB5232:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	testq	%rsi, %rsi
	je	.L84
	xorl	%r8d, %r8d
	leaq	8(%rdi), %rax
	movq	%r8, (%rdi)
	decq	%rsi
	je	.L84
	leaq	(%rax,%rsi,8), %rdx
	movq	%rax, %rcx
.L86:
	cmpq	%rcx, %rdx
	je	.L93
	xorl	%esi, %esi
	addq	$8, %rcx
	movq	%rsi, -8(%rcx)
	jmp	.L86
.L93:
	subq	%rdi, %rdx
	leaq	-8(%rax,%rdx), %rax
.L84:
	ret
	.cfi_endproc
.LFE5232:
	.size	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_, .-_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_
	.section	.rodata._ZNSt6vectorImSaImEE17_M_default_appendEm.str1.1,"aMS",@progbits,1
.LC3:
	.string	"vector::_M_default_append"
	.section	.text._ZNSt6vectorImSaImEE17_M_default_appendEm,"axG",@progbits,_ZNSt6vectorImSaImEE17_M_default_appendEm,comdat
	.align 2
	.weak	_ZNSt6vectorImSaImEE17_M_default_appendEm
	.type	_ZNSt6vectorImSaImEE17_M_default_appendEm, @function
_ZNSt6vectorImSaImEE17_M_default_appendEm:
.LFB4914:
	.cfi_startproc
	endbr64
	testq	%rsi, %rsi
	je	.L108
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	8(%rdi), %rdi
	movq	16(%rbp), %rax
	movq	0(%rbp), %r13
	subq	%rdi, %rax
	sarq	$3, %rax
	cmpq	%rsi, %rax
	jb	.L96
	call	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_
	movq	%rax, 8(%rbp)
	jmp	.L94
.L96:
	movabsq	$1152921504606846975, %rax
	movq	%rdi, %rdx
	subq	%r13, %rdx
	movq	%rdx, %r15
	sarq	$3, %r15
	subq	%r15, %rax
	cmpq	%rsi, %rax
	jnb	.L97
	leaq	.LC3(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L97:
	cmpq	%r15, %rsi
	movq	%r15, %r14
	movq	%rdx, 8(%rsp)
	movabsq	$1152921504606846975, %rax
	cmovnb	%rsi, %r14
	addq	%r15, %r14
	cmpq	%rax, %r14
	cmova	%rax, %r14
	salq	$3, %r14
	movq	%r14, %rdi
	call	_Znwm@PLT
	movq	8(%rsp), %rdx
	movq	%rbx, %rsi
	movq	%rax, %r12
	leaq	(%rax,%rdx), %rdi
	call	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPmmEET_S3_T0_
	movq	8(%rsp), %rdx
	testq	%rdx, %rdx
	je	.L98
	movq	%r13, %rsi
	movq	%r12, %rdi
	call	memmove@PLT
	jmp	.L99
.L98:
	testq	%r13, %r13
	je	.L100
.L99:
	movq	16(%rbp), %rsi
	movq	%r13, %rdi
	subq	%r13, %rsi
	call	_ZdlPvm@PLT
.L100:
	addq	%r15, %rbx
	movq	%r12, 0(%rbp)
	leaq	(%r12,%rbx,8), %rax
	addq	%r14, %r12
	movq	%rax, 8(%rbp)
	movq	%r12, 16(%rbp)
.L94:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L108:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE4914:
	.size	_ZNSt6vectorImSaImEE17_M_default_appendEm, .-_ZNSt6vectorImSaImEE17_M_default_appendEm
	.section	.text._ZNSt6vectorImSaImEE6resizeEm,"axG",@progbits,_ZNSt6vectorImSaImEE6resizeEm,comdat
	.align 2
	.weak	_ZNSt6vectorImSaImEE6resizeEm
	.type	_ZNSt6vectorImSaImEE6resizeEm, @function
_ZNSt6vectorImSaImEE6resizeEm:
.LFB4750:
	.cfi_startproc
	endbr64
	movq	8(%rdi), %rdx
	movq	(%rdi), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	sarq	$3, %rax
	cmpq	%rsi, %rax
	jnb	.L112
	subq	%rax, %rsi
	jmp	_ZNSt6vectorImSaImEE17_M_default_appendEm
.L112:
	cmpq	%rax, %rsi
	jnb	.L111
	leaq	(%rcx,%rsi,8), %rax
	cmpq	%rdx, %rax
	je	.L111
	movq	%rax, 8(%rdi)
.L111:
	ret
	.cfi_endproc
.LFE4750:
	.size	_ZNSt6vectorImSaImEE6resizeEm, .-_ZNSt6vectorImSaImEE6resizeEm
	.section	.rodata.str1.1
.LC4:
	.string	"Failed to create thread for id :"
	.text
	.globl	_Z23__create_cpu_threadpooli
	.type	_Z23__create_cpu_threadpooli, @function
_Z23__create_cpu_threadpooli:
.LFB4412:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movb	$1, %r13b
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	cpu_workers(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 64
	call	_ZNSt6vectorImSaImEE6resizeEm
.L115:
	cmpl	%ebx, %ebp
	jle	.L120
	movq	(%r12), %rdi
	leaq	1(%rbx), %r14
	movq	_Z13__do_work_cpuPv@GOTPCREL(%rip), %rdx
	xorl	%esi, %esi
	leaq	0(,%rbx,8), %r15
	movq	%r14, %rcx
	addq	%r15, %rdi
	call	pthread_create@PLT
	testl	%eax, %eax
	je	.L116
	leaq	.LC4(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	xorl	%r13d, %r13d
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L117
.L116:
	movq	(%r12), %rsi
	leaq	cpu_lock_map(%rip), %rdi
	addq	%r15, %rsi
	call	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	pthread_mutex_init@PLT
.L117:
	movq	%r14, %rbx
	jmp	.L115
.L120:
	popq	%rdx
	.cfi_def_cfa_offset 56
	movl	%r13d, %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
.LFE4412:
	.size	_Z23__create_cpu_threadpooli, .-_Z23__create_cpu_threadpooli
	.globl	_Z23__create_gpu_threadpooli
	.type	_Z23__create_gpu_threadpooli, @function
_Z23__create_gpu_threadpooli:
.LFB4413:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movb	$1, %r14b
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	8+stream_map(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	gpu_workers(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	call	_ZNSt6vectorImSaImEE6resizeEm
.L122:
	cmpl	%ebx, %ebp
	jle	.L135
	movq	(%r12), %rdi
	leaq	1(%rbx), %rax
	movq	_Z13__do_work_gpuPv@GOTPCREL(%rip), %rdx
	xorl	%esi, %esi
	salq	$3, %rbx
	movq	%rax, %rcx
	movq	%rax, 8(%rsp)
	addq	%rbx, %rdi
	call	pthread_create@PLT
	testl	%eax, %eax
	jne	.L133
	movq	(%r12), %rdx
	movq	16+stream_map(%rip), %rax
	movq	%r13, %r15
	addq	%rbx, %rdx
	movq	(%rdx), %rcx
.L124:
	testq	%rax, %rax
	je	.L136
	movq	16(%rax), %rsi
	movq	24(%rax), %rdi
	cmpq	%rcx, 32(%rax)
	jnb	.L125
	movq	%r15, %rax
	movq	%rdi, %rsi
.L125:
	movq	%rax, %r15
	movq	%rsi, %rax
	jmp	.L124
.L136:
	cmpq	%r13, %r15
	je	.L127
	cmpq	32(%r15), %rcx
	jnb	.L128
.L127:
	movl	$48, %edi
	movq	%rdx, 16(%rsp)
	movq	%r15, 24(%rsp)
	call	_Znwm@PLT
	movq	16(%rsp), %rdx
	movq	24(%rsp), %rsi
	leaq	stream_map(%rip), %rdi
	movq	%rax, %r15
	movq	(%rdx), %rcx
	leaq	32(%r15), %rdx
	movq	%rcx, 32(%rax)
	xorl	%eax, %eax
	movq	%rax, 40(%r15)
	movq	%rcx, 16(%rsp)
	call	_ZNSt8_Rb_treeImSt4pairIKmP11CUstream_stESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_
	testq	%rdx, %rdx
	je	.L129
	cmpq	%r13, %rdx
	movq	16(%rsp), %rcx
	sete	%dil
	testq	%rax, %rax
	setne	%al
	orb	%al, %dil
	jne	.L130
	cmpq	32(%rdx), %rcx
	setb	%dil
.L130:
	movzbl	%dil, %edi
	movq	%r13, %rcx
	movq	%r15, %rsi
	call	_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_@PLT
	incq	40+stream_map(%rip)
	jmp	.L128
.L129:
	movq	%r15, %rdi
	movl	$48, %esi
	movq	%rax, 16(%rsp)
	call	_ZdlPvm@PLT
	movq	16(%rsp), %r15
.L128:
	leaq	40(%r15), %rdi
	call	cudaStreamCreate@PLT
	addq	(%r12), %rbx
	leaq	gpu_lock_map(%rip), %rdi
	movq	%rbx, %rsi
	call	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	pthread_mutex_init@PLT
	jmp	.L123
.L133:
	xorl	%r14d, %r14d
.L123:
	movq	8(%rsp), %rbx
	jmp	.L122
.L135:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	movl	%r14d, %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
.LFE4413:
	.size	_Z23__create_gpu_threadpooli, .-_Z23__create_gpu_threadpooli
	.section	.rodata.str1.1
.LC5:
	.string	"Failed to spawn cpu threads"
	.text
	.globl	_Z17create_threadpooli
	.type	_Z17create_threadpooli, @function
_Z17create_threadpooli:
.LFB4414:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	%edi, %ebx
	call	_Z23__create_cpu_threadpooli
	testb	%al, %al
	jne	.L138
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %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
.L138:
	movl	%ebx, %edi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_Z23__create_gpu_threadpooli
	.cfi_endproc
.LFE4414:
	.size	_Z17create_threadpooli, .-_Z17create_threadpooli
	.section	.text.startup
	.type	_GLOBAL__sub_I_cpu_workers, @function
_GLOBAL__sub_I_cpu_workers:
.LFB5341:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%edx, %edx
	leaq	__dso_handle(%rip), %rbp
	leaq	cpu_workers(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	_ZNSt6vectorImSaImEED1Ev(%rip), %rbx
	pushq	%rax
	.cfi_def_cfa_offset 32
	movq	%rbx, %rdi
	movq	%rdx, cpu_workers(%rip)
	movq	%rdx, 8+cpu_workers(%rip)
	movq	%rdx, 16+cpu_workers(%rip)
	movq	%rbp, %rdx
	call	__cxa_atexit@PLT
	xorl	%ecx, %ecx
	movq	%rbp, %rdx
	movq	%rbx, %rdi
	movq	%rcx, gpu_workers(%rip)
	leaq	gpu_workers(%rip), %rsi
	movq	%rcx, 8+gpu_workers(%rip)
	movq	%rcx, 16+gpu_workers(%rip)
	popq	%r8
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	__cxa_atexit@PLT
	.cfi_endproc
.LFE5341:
	.size	_GLOBAL__sub_I_cpu_workers, .-_GLOBAL__sub_I_cpu_workers
	.section	.init_array
	.align 8
	.quad	_GLOBAL__sub_I_cpu_workers
	.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
	.globl	gpu_workers
	.bss
	.align 16
	.type	gpu_workers, @object
	.size	gpu_workers, 24
gpu_workers:
	.zero	24
	.globl	cpu_workers
	.align 16
	.type	cpu_workers, @object
	.size	cpu_workers, 24
cpu_workers:
	.zero	24
	.hidden	__dso_handle
	.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:

/*
 * Noopur Maheshwari : 111464061
 * Rahul Rane : 111465246
 */

#include <hip/hip_runtime.h>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

extern void *__do_work_cpu(void *data);
extern void *__do_work_gpu(void *data);
extern map<pthread_t, pthread_mutex_t> cpu_lock_map;
extern map<pthread_t, pthread_mutex_t> gpu_lock_map;
extern map<pthread_t, hipStream_t> stream_map;
vector<pthread_t> cpu_workers;
vector<pthread_t> gpu_workers;

bool __create_cpu_threadpool(int nworkers) {
    cpu_workers.resize(nworkers);
    bool ret = true;
    for (int i=0; i<nworkers; i++) {
        if(pthread_create(&cpu_workers[i], NULL, __do_work_cpu, (void *)(i+1))) {
            cout<<"Failed to create thread for id :"<<i<<endl;
            ret = false;
        } else {
            pthread_mutex_init(&cpu_lock_map[cpu_workers[i]], NULL);
        }
    }
    return ret;
}

bool __create_gpu_threadpool(int nworkers) {
    gpu_workers.resize(nworkers);
    bool ret = true;
    for (int i=0; i<nworkers; i++) {
        if(pthread_create(&gpu_workers[i], NULL, __do_work_gpu, (void *)(i+1))) {
            //cout<<"Failed to create thread for id :"<<i<<endl;
            ret = false;
        } else {
            hipStreamCreate(&stream_map[gpu_workers[i]]);
            pthread_mutex_init(&gpu_lock_map[gpu_workers[i]], NULL);
        }
    }
    return ret;
}

bool create_threadpool(int nworkers) {
    bool ret;
    ret = __create_cpu_threadpool(nworkers);
    if (!ret) {
        cout<<"Failed to spawn cpu threads"<<endl;
    }

    ret = __create_gpu_threadpool(nworkers);
    if (!ret) {
        //cout<<"Failed to spawn gpu threads"<<endl;
    }

    return ret;
}

void wait_until_done() {
    void *status;
    for(int i=0; i<cpu_workers.size(); i++) {
        if(pthread_join(cpu_workers[i], &status)) {
            cout<<"Failed to join thread for id :"<<i<<endl;
        }
    }
    cout<<"CPU threads finished"<<endl; 
    for(int i=0; i<gpu_workers.size()-1; i++) {
        if(pthread_join(gpu_workers[i], &status)) {
            cout<<"Failed to join thread for id :"<<i<<endl;
        }
    }
    hipDeviceReset();
    cout<<"GPU threads finished"<<endl;
    return;
}

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

                                        # End of file scope inline assembly
	.section	.text._ZNSt6vectorImSaImEED2Ev,"axG",@progbits,_ZNSt6vectorImSaImEED2Ev,comdat
	.weak	_ZNSt6vectorImSaImEED2Ev        # -- Begin function _ZNSt6vectorImSaImEED2Ev
	.p2align	1, 0x90
	.type	_ZNSt6vectorImSaImEED2Ev,@function
_ZNSt6vectorImSaImEED2Ev:               # @_ZNSt6vectorImSaImEED2Ev
	.cfi_startproc
# %bb.0:
	movq	(%rdi), %rdi
	testq	%rdi, %rdi
	jne	_ZdlPv                          # TAILCALL
# %bb.1:                                # %_ZNSt12_Vector_baseImSaImEED2Ev.exit
	retq
.Lfunc_end0:
	.size	_ZNSt6vectorImSaImEED2Ev, .Lfunc_end0-_ZNSt6vectorImSaImEED2Ev
	.cfi_endproc
                                        # -- End function
	.text
	.globl	_Z23__create_cpu_threadpooli    # -- Begin function _Z23__create_cpu_threadpooli
	.type	_Z23__create_cpu_threadpooli,@function
_Z23__create_cpu_threadpooli:           # @_Z23__create_cpu_threadpooli
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edi, %ebx
	movslq	%edi, %r14
	movl	$cpu_workers, %edi
	movq	%r14, %rsi
	callq	_ZNSt6vectorImSaImEE6resizeEm
	testl	%r14d, %r14d
	jle	.LBB1_1
# %bb.4:                                # %.lr.ph.preheader
	movl	%ebx, %r15d
	shlq	$3, %r15
	movb	$1, %r14b
	xorl	%r12d, %r12d
	movl	$1, %ebx
	xorl	%ebp, %ebp
.LBB1_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	cpu_workers(%rip), %rdi
	addq	%r12, %rdi
	movl	$_Z13__do_work_cpuPv, %edx
	xorl	%esi, %esi
	movq	%rbx, %rcx
	callq	pthread_create
	testl	%eax, %eax
	je	.LBB1_7
# %bb.6:                                #   in Loop: Header=BB1_5 Depth=1
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$32, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%ebp, %esi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%r14d, %r14d
	jmp	.LBB1_8
.LBB1_7:                                #   in Loop: Header=BB1_5 Depth=1
	movq	cpu_workers(%rip), %rsi
	addq	%r12, %rsi
	movl	$cpu_lock_map, %edi
	callq	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	pthread_mutex_init
.LBB1_8:                                #   in Loop: Header=BB1_5 Depth=1
	incl	%ebp
	addq	$8, %r12
	incq	%rbx
	cmpq	%r12, %r15
	jne	.LBB1_5
# %bb.2:                                # %._crit_edge.loopexit
	andb	$1, %r14b
	jmp	.LBB1_3
.LBB1_1:
	movb	$1, %r14b
.LBB1_3:                                # %._crit_edge
	movl	%r14d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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	_Z23__create_cpu_threadpooli, .Lfunc_end1-_Z23__create_cpu_threadpooli
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorImSaImEE6resizeEm,"axG",@progbits,_ZNSt6vectorImSaImEE6resizeEm,comdat
	.weak	_ZNSt6vectorImSaImEE6resizeEm   # -- Begin function _ZNSt6vectorImSaImEE6resizeEm
	.p2align	1, 0x90
	.type	_ZNSt6vectorImSaImEE6resizeEm,@function
_ZNSt6vectorImSaImEE6resizeEm:          # @_ZNSt6vectorImSaImEE6resizeEm
	.cfi_startproc
# %bb.0:
	movq	(%rdi), %rdx
	movq	8(%rdi), %rcx
	movq	%rcx, %r8
	subq	%rdx, %r8
	sarq	$3, %r8
	movq	%rsi, %rax
	subq	%r8, %rax
	jbe	.LBB2_1
# %bb.5:
	movq	%rax, %rsi
	jmp	_ZNSt6vectorImSaImEE17_M_default_appendEm # TAILCALL
.LBB2_1:
	jae	.LBB2_4
# %bb.2:
	leaq	(%rdx,%rsi,8), %rax
	cmpq	%rax, %rcx
	je	.LBB2_4
# %bb.3:
	movq	%rax, 8(%rdi)
.LBB2_4:                                # %_ZNSt6vectorImSaImEE15_M_erase_at_endEPm.exit
	retq
.Lfunc_end2:
	.size	_ZNSt6vectorImSaImEE6resizeEm, .Lfunc_end2-_ZNSt6vectorImSaImEE6resizeEm
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_,"axG",@progbits,_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_,comdat
	.weak	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_ # -- Begin function _ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	.p2align	1, 0x90
	.type	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_,@function
_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_: # @_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	.cfi_startproc
# %bb.0:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%rsi, %rdx
	movq	16(%rdi), %r8
	leaq	8(%rdi), %rsi
	testq	%r8, %r8
	je	.LBB3_5
# %bb.1:                                # %.lr.ph.i.i.i
	movq	(%rdx), %rcx
	movq	%rsi, %rax
.LBB3_2:                                # =>This Inner Loop Header: Depth=1
	xorl	%r9d, %r9d
	cmpq	%rcx, 32(%r8)
	setb	%r9b
	cmovaeq	%r8, %rax
	movq	16(%r8,%r9,8), %r8
	testq	%r8, %r8
	jne	.LBB3_2
# %bb.3:                                # %_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEE11lower_boundERS4_.exit
	cmpq	%rsi, %rax
	je	.LBB3_5
# %bb.4:
	movq	%rax, %rsi
	cmpq	32(%rax), %rcx
	jae	.LBB3_6
.LBB3_5:                                # %.critedge
	leaq	16(%rsp), %rcx
	movq	%rdx, (%rcx)
	leaq	15(%rsp), %r8
	movl	$_ZSt19piecewise_construct, %edx
	callq	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_
.LBB3_6:
	addq	$40, %rax
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_, .Lfunc_end3-_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	.cfi_endproc
                                        # -- End function
	.text
	.globl	_Z23__create_gpu_threadpooli    # -- Begin function _Z23__create_gpu_threadpooli
	.type	_Z23__create_gpu_threadpooli,@function
_Z23__create_gpu_threadpooli:           # @_Z23__create_gpu_threadpooli
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edi, %ebx
	movslq	%edi, %r14
	movl	$gpu_workers, %edi
	movq	%r14, %rsi
	callq	_ZNSt6vectorImSaImEE6resizeEm
	testl	%r14d, %r14d
	jle	.LBB4_1
# %bb.4:                                # %.lr.ph.preheader
	movl	%ebx, %r15d
	shlq	$3, %r15
	movb	$1, %bpl
	movl	$1, %ebx
	xorl	%r12d, %r12d
.LBB4_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	gpu_workers(%rip), %rdi
	addq	%r12, %rdi
	xorl	%r14d, %r14d
	movl	$_Z13__do_work_gpuPv, %edx
	xorl	%esi, %esi
	movq	%rbx, %rcx
	callq	pthread_create
	testl	%eax, %eax
	jne	.LBB4_7
# %bb.6:                                #   in Loop: Header=BB4_5 Depth=1
	movq	gpu_workers(%rip), %rsi
	addq	%r12, %rsi
	movl	$stream_map, %edi
	callq	_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_
	movq	%rax, %rdi
	callq	hipStreamCreate
	movq	gpu_workers(%rip), %rsi
	addq	%r12, %rsi
	movl	$gpu_lock_map, %edi
	callq	_ZNSt3mapIm15pthread_mutex_tSt4lessImESaISt4pairIKmS0_EEEixERS4_
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	pthread_mutex_init
	movl	%ebp, %r14d
.LBB4_7:                                #   in Loop: Header=BB4_5 Depth=1
	addq	$8, %r12
	incq	%rbx
	movl	%r14d, %ebp
	cmpq	%r12, %r15
	jne	.LBB4_5
# %bb.2:                                # %._crit_edge.loopexit
	andb	$1, %r14b
	jmp	.LBB4_3
.LBB4_1:
	movb	$1, %r14b
.LBB4_3:                                # %._crit_edge
	movl	%r14d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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	_Z23__create_gpu_threadpooli, .Lfunc_end4-_Z23__create_gpu_threadpooli
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_,"axG",@progbits,_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_,comdat
	.weak	_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_ # -- Begin function _ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_
	.p2align	1, 0x90
	.type	_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_,@function
_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_: # @_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_
	.cfi_startproc
# %bb.0:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%rsi, %rdx
	movq	16(%rdi), %r8
	leaq	8(%rdi), %rsi
	testq	%r8, %r8
	je	.LBB5_5
# %bb.1:                                # %.lr.ph.i.i.i
	movq	(%rdx), %rcx
	movq	%rsi, %rax
.LBB5_2:                                # =>This Inner Loop Header: Depth=1
	xorl	%r9d, %r9d
	cmpq	%rcx, 32(%r8)
	setb	%r9b
	cmovaeq	%r8, %rax
	movq	16(%r8,%r9,8), %r8
	testq	%r8, %r8
	jne	.LBB5_2
# %bb.3:                                # %_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEE11lower_boundERS5_.exit
	cmpq	%rsi, %rax
	je	.LBB5_5
# %bb.4:
	movq	%rax, %rsi
	cmpq	32(%rax), %rcx
	jae	.LBB5_6
.LBB5_5:                                # %.critedge
	leaq	16(%rsp), %rcx
	movq	%rdx, (%rcx)
	leaq	15(%rsp), %r8
	movl	$_ZSt19piecewise_construct, %edx
	callq	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_
.LBB5_6:
	addq	$40, %rax
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_, .Lfunc_end5-_ZNSt3mapImP12ihipStream_tSt4lessImESaISt4pairIKmS1_EEEixERS5_
	.cfi_endproc
                                        # -- End function
	.text
	.globl	_Z17create_threadpooli          # -- Begin function _Z17create_threadpooli
	.type	_Z17create_threadpooli,@function
_Z17create_threadpooli:                 # @_Z17create_threadpooli
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	%edi, %ebx
	callq	_Z23__create_cpu_threadpooli
	testb	%al, %al
	jne	.LBB6_2
# %bb.1:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$27, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB6_2:
	movl	%ebx, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_Z23__create_gpu_threadpooli    # TAILCALL
.Lfunc_end6:
	.size	_Z17create_threadpooli, .Lfunc_end6-_Z17create_threadpooli
	.cfi_endproc
                                        # -- End function
	.globl	_Z15wait_until_donev            # -- Begin function _Z15wait_until_donev
	.type	_Z15wait_until_donev,@function
_Z15wait_until_donev:                   # @_Z15wait_until_donev
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	cpu_workers(%rip), %rax
	cmpq	%rax, cpu_workers+8(%rip)
	je	.LBB7_5
# %bb.1:                                # %.lr.ph.preheader
	xorl	%ebx, %ebx
	movq	%rsp, %r14
.LBB7_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rax,%rbx,8), %rdi
	movq	%r14, %rsi
	callq	pthread_join
	testl	%eax, %eax
	je	.LBB7_4
# %bb.3:                                #   in Loop: Header=BB7_2 Depth=1
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$30, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	callq	_ZNSolsEi
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r15, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB7_4:                                #   in Loop: Header=BB7_2 Depth=1
	incq	%rbx
	movq	cpu_workers+8(%rip), %rcx
	movq	cpu_workers(%rip), %rax
	subq	%rax, %rcx
	sarq	$3, %rcx
	cmpq	%rbx, %rcx
	ja	.LBB7_2
.LBB7_5:                                # %._crit_edge
	movl	$_ZSt4cout, %r12d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$20, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	gpu_workers+8(%rip), %rcx
	movq	gpu_workers(%rip), %rax
	subq	%rax, %rcx
	cmpq	$8, %rcx
	je	.LBB7_10
# %bb.6:                                # %.lr.ph15.preheader
	xorl	%ebx, %ebx
	movq	%rsp, %r14
.LBB7_7:                                # %.lr.ph15
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rax,%rbx,8), %rdi
	movq	%r14, %rsi
	callq	pthread_join
	testl	%eax, %eax
	je	.LBB7_9
# %bb.8:                                #   in Loop: Header=BB7_7 Depth=1
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$30, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	callq	_ZNSolsEi
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r15, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB7_9:                                #   in Loop: Header=BB7_7 Depth=1
	incq	%rbx
	movq	gpu_workers+8(%rip), %rcx
	movq	gpu_workers(%rip), %rax
	subq	%rax, %rcx
	sarq	$3, %rcx
	decq	%rcx
	cmpq	%rbx, %rcx
	ja	.LBB7_7
.LBB7_10:                               # %._crit_edge16
	callq	hipDeviceReset
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$20, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	_Z15wait_until_donev, .Lfunc_end7-_Z15wait_until_donev
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorImSaImEE17_M_default_appendEm,"axG",@progbits,_ZNSt6vectorImSaImEE17_M_default_appendEm,comdat
	.weak	_ZNSt6vectorImSaImEE17_M_default_appendEm # -- Begin function _ZNSt6vectorImSaImEE17_M_default_appendEm
	.p2align	1, 0x90
	.type	_ZNSt6vectorImSaImEE17_M_default_appendEm,@function
_ZNSt6vectorImSaImEE17_M_default_appendEm: # @_ZNSt6vectorImSaImEE17_M_default_appendEm
	.cfi_startproc
# %bb.0:
	testq	%rsi, %rsi
	je	.LBB8_16
# %bb.1:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	movq	%rdi, %rbx
	movq	8(%rdi), %r15
	movq	16(%rdi), %rax
	subq	%r15, %rax
	sarq	$3, %rax
	cmpq	%rsi, %rax
	jae	.LBB8_2
# %bb.5:
	movq	(%rbx), %r12
	subq	%r12, %r15
	movq	%r15, %r13
	sarq	$3, %r13
	movl	$.L.str.6, %edx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_ZNKSt6vectorImSaImEE12_M_check_lenEmPKc
	testq	%rax, %rax
	movq	%rax, (%rsp)                    # 8-byte Spill
	je	.LBB8_6
# %bb.7:
	movq	%rbx, %rdi
	movq	%rax, %rsi
	xorl	%edx, %edx
	callq	_ZNSt15__new_allocatorImE8allocateEmPKv
	movq	%rax, %rbp
	jmp	.LBB8_8
.LBB8_2:
	movq	$0, (%r15)
	leaq	8(%r15), %rdi
	cmpq	$1, %r14
	je	.LBB8_4
# %bb.3:                                # %_ZSt6fill_nIPmmmET_S1_T0_RKT1_.exit.loopexit.i.i.i
	leaq	-8(,%r14,8), %rdx
	xorl	%esi, %esi
	callq	memset@PLT
	leaq	(%r15,%r14,8), %rdi
.LBB8_4:                                # %_ZSt27__uninitialized_default_n_aIPmmmET_S1_T0_RSaIT1_E.exit
	movq	%rdi, 8(%rbx)
	jmp	.LBB8_15
.LBB8_6:
	xorl	%ebp, %ebp
.LBB8_8:
	leaq	(,%r13,8), %r13
	addq	%rbp, %r13
	movq	$0, (%r13)
	cmpq	$1, %r14
	je	.LBB8_10
# %bb.9:                                # %_ZSt6fill_nIPmmmET_S1_T0_RKT1_.exit.loopexit.i.i.i30
	leaq	8(%r13), %rdi
	leaq	-8(,%r14,8), %rdx
	xorl	%esi, %esi
	callq	memset@PLT
.LBB8_10:                               # %_ZSt27__uninitialized_default_n_aIPmmmET_S1_T0_RSaIT1_E.exit32
	testq	%r15, %r15
	jle	.LBB8_12
# %bb.11:
	movq	%rbp, %rdi
	movq	%r12, %rsi
	movq	%r15, %rdx
	callq	memmove@PLT
.LBB8_12:                               # %_ZNSt6vectorImSaImEE11_S_relocateEPmS2_S2_RS0_.exit
	testq	%r12, %r12
	je	.LBB8_14
# %bb.13:
	movq	%r12, %rdi
	callq	_ZdlPv
.LBB8_14:                               # %_ZNSt12_Vector_baseImSaImEE13_M_deallocateEPmm.exit35
	movq	%rbp, (%rbx)
	leaq	(,%r14,8), %rax
	addq	%r13, %rax
	movq	%rax, 8(%rbx)
	movq	(%rsp), %rax                    # 8-byte Reload
	leaq	(,%rax,8), %rax
	addq	%rbp, %rax
	movq	%rax, 16(%rbx)
.LBB8_15:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB8_16:
	retq
.Lfunc_end8:
	.size	_ZNSt6vectorImSaImEE17_M_default_appendEm, .Lfunc_end8-_ZNSt6vectorImSaImEE17_M_default_appendEm
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNKSt6vectorImSaImEE12_M_check_lenEmPKc,"axG",@progbits,_ZNKSt6vectorImSaImEE12_M_check_lenEmPKc,comdat
	.weak	_ZNKSt6vectorImSaImEE12_M_check_lenEmPKc # -- Begin function _ZNKSt6vectorImSaImEE12_M_check_lenEmPKc
	.p2align	1, 0x90
	.type	_ZNKSt6vectorImSaImEE12_M_check_lenEmPKc,@function
_ZNKSt6vectorImSaImEE12_M_check_lenEmPKc: # @_ZNKSt6vectorImSaImEE12_M_check_lenEmPKc
	.cfi_startproc
# %bb.0:
	movabsq	$1152921504606846975, %rcx      # imm = 0xFFFFFFFFFFFFFFF
	movq	8(%rdi), %r8
	subq	(%rdi), %r8
	sarq	$3, %r8
	movq	%rcx, %rax
	subq	%r8, %rax
	cmpq	%rsi, %rax
	jb	.LBB9_2
# %bb.1:
	cmpq	%rsi, %r8
	cmovaq	%r8, %rsi
	leaq	(%rsi,%r8), %rax
	cmpq	%rcx, %rax
	cmovaeq	%rcx, %rax
	addq	%r8, %rsi
	cmovbq	%rcx, %rax
	retq
.LBB9_2:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdx, %rdi
	callq	_ZSt20__throw_length_errorPKc
.Lfunc_end9:
	.size	_ZNKSt6vectorImSaImEE12_M_check_lenEmPKc, .Lfunc_end9-_ZNKSt6vectorImSaImEE12_M_check_lenEmPKc
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt15__new_allocatorImE8allocateEmPKv,"axG",@progbits,_ZNSt15__new_allocatorImE8allocateEmPKv,comdat
	.weak	_ZNSt15__new_allocatorImE8allocateEmPKv # -- Begin function _ZNSt15__new_allocatorImE8allocateEmPKv
	.p2align	1, 0x90
	.type	_ZNSt15__new_allocatorImE8allocateEmPKv,@function
_ZNSt15__new_allocatorImE8allocateEmPKv: # @_ZNSt15__new_allocatorImE8allocateEmPKv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rax
	shrq	$60, %rax
	jne	.LBB10_1
# %bb.3:
	shlq	$3, %rsi
	movq	%rsi, %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Znwm                           # TAILCALL
.LBB10_1:
	.cfi_def_cfa_offset 16
	shrq	$61, %rsi
	je	.LBB10_2
# %bb.4:
	callq	_ZSt28__throw_bad_array_new_lengthv
.LBB10_2:
	callq	_ZSt17__throw_bad_allocv
.Lfunc_end10:
	.size	_ZNSt15__new_allocatorImE8allocateEmPKv, .Lfunc_end10-_ZNSt15__new_allocatorImE8allocateEmPKv
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_,comdat
	.weak	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_ # -- Begin function _ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_
	.p2align	1, 0x90
	.type	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_,@function
_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_: # @_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rcx, %r15
	movq	%rsi, %r12
	movq	%rdi, %r14
	movl	$80, %edi
	callq	_Znwm
	movq	%rax, %rbx
	leaq	32(%rax), %rdx
	movq	(%r15), %rax
	movq	(%rax), %rax
	movq	%rax, 32(%rbx)
	xorps	%xmm0, %xmm0
	movups	%xmm0, 40(%rbx)
	movups	%xmm0, 56(%rbx)
	movq	$0, 72(%rbx)
.Ltmp0:
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_
.Ltmp1:
# %bb.1:
	movq	%rax, %r15
	testq	%rdx, %rdx
	je	.LBB11_5
# %bb.2:
.Ltmp2:
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%rbx, %rcx
	callq	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E
.Ltmp3:
# %bb.3:
	movq	%rax, %r15
	jmp	.LBB11_6
.LBB11_5:                               # %_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE10_Auto_node9_M_insertES0_IPSt18_Rb_tree_node_baseSC_E.exit
	movq	%rbx, %rdi
	callq	_ZdlPv
.LBB11_6:                               # %_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE10_Auto_nodeD2Ev.exit9
	movq	%r15, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB11_4:                               # %_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE10_Auto_nodeD2Ev.exit
	.cfi_def_cfa_offset 48
.Ltmp4:
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end11:
	.size	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_, .Lfunc_end11-_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_
	.cfi_endproc
	.section	.gcc_except_table._ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_,"aG",@progbits,_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESE_IJEEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_,comdat
	.p2align	2, 0x0
GCC_except_table11:
.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 .Ltmp3-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp3
	.uleb128 .Ltmp4-.Lfunc_begin0           #     jumps to .Ltmp4
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Lfunc_end11-.Ltmp3            #   Call between .Ltmp3 and .Lfunc_end11
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_,comdat
	.weak	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_ # -- Begin function _ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_
	.p2align	1, 0x90
	.type	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_,@function
_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_: # @_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rdi, %r15
	leaq	8(%rdi), %rax
	cmpq	%rsi, %rax
	je	.LBB12_1
# %bb.4:
	movq	%rsi, %rbx
	movq	(%r14), %r12
	movq	32(%rsi), %rax
	cmpq	%rax, %r12
	jae	.LBB12_9
# %bb.5:
	cmpq	%rbx, 24(%r15)
	je	.LBB12_6
# %bb.7:
	movq	%rbx, %rdi
	callq	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base
	cmpq	%r12, 32(%rax)
	jae	.LBB12_14
# %bb.8:
	movq	%rax, %rcx
	movq	24(%rax), %rax
	testq	%rax, %rax
	cmovneq	%rbx, %rax
	cmoveq	%rcx, %rbx
	jmp	.LBB12_15
.LBB12_1:
	cmpq	$0, 40(%r15)
	je	.LBB12_14
# %bb.2:
	movq	32(%r15), %rbx
	movq	32(%rbx), %rax
	cmpq	(%r14), %rax
	jae	.LBB12_14
	jmp	.LBB12_3
.LBB12_9:
	jbe	.LBB12_10
# %bb.11:
	cmpq	%rbx, 32(%r15)
	je	.LBB12_3
# %bb.12:
	movq	%rbx, %rdi
	callq	_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base
	cmpq	32(%rax), %r12
	jae	.LBB12_14
# %bb.13:
	movq	%rax, %rcx
	movq	24(%rbx), %rax
	testq	%rax, %rax
	cmovneq	%rcx, %rax
	cmovneq	%rcx, %rbx
	jmp	.LBB12_15
.LBB12_14:
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_
	movq	%rdx, %rbx
	jmp	.LBB12_15
.LBB12_3:
	xorl	%eax, %eax
	jmp	.LBB12_15
.LBB12_10:
	movq	%rbx, %rax
	xorl	%ebx, %ebx
	jmp	.LBB12_15
.LBB12_6:
	movq	%rbx, %rax
.LBB12_15:
	movq	%rbx, %rdx
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end12:
	.size	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_, .Lfunc_end12-_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS1_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_,comdat
	.weak	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_ # -- Begin function _ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_
	.p2align	1, 0x90
	.type	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_,@function
_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_: # @_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %r14
	movq	16(%rdi), %rax
	testq	%rax, %rax
	je	.LBB13_1
# %bb.2:                                # %.lr.ph
	movq	(%r14), %rcx
.LBB13_3:                               # =>This Inner Loop Header: Depth=1
	movq	%rax, %rbx
	movq	32(%rax), %rdx
	xorl	%eax, %eax
	cmpq	%rdx, %rcx
	setae	%al
	movq	16(%rbx,%rax,8), %rax
	testq	%rax, %rax
	jne	.LBB13_3
# %bb.4:                                # %._crit_edge
	movq	%rbx, %rax
	cmpq	%rdx, %rcx
	jb	.LBB13_5
	jmp	.LBB13_8
.LBB13_1:
	leaq	8(%rdi), %rbx
.LBB13_5:                               # %._crit_edge.thread
	cmpq	24(%rdi), %rbx
	je	.LBB13_6
# %bb.7:
	movq	%rbx, %rdi
	callq	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base
.LBB13_8:
	movq	32(%rax), %rcx
	xorl	%edx, %edx
	cmpq	(%r14), %rcx
	cmovbq	%rdx, %rax
	cmovaeq	%rdx, %rbx
	jmp	.LBB13_9
.LBB13_6:
	xorl	%eax, %eax
.LBB13_9:
	movq	%rbx, %rdx
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end13:
	.size	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_, .Lfunc_end13-_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE24_M_get_insert_unique_posERS1_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E,comdat
	.weak	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E # -- Begin function _ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E
	.p2align	1, 0x90
	.type	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E,@function
_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E: # @_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rcx, %rbx
	movq	%rdi, %r14
	leaq	8(%rdi), %rcx
	movb	$1, %al
	testq	%rsi, %rsi
	jne	.LBB14_3
# %bb.1:
	cmpq	%rdx, %rcx
	je	.LBB14_3
# %bb.2:
	movq	32(%rbx), %rax
	cmpq	32(%rdx), %rax
	setb	%al
.LBB14_3:
	movzbl	%al, %edi
	movq	%rbx, %rsi
	callq	_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_
	incq	40(%r14)
	movq	%rbx, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end14:
	.size	_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E, .Lfunc_end14-_ZNSt8_Rb_treeImSt4pairIKm15pthread_mutex_tESt10_Select1stIS3_ESt4lessImESaIS3_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSB_PSt13_Rb_tree_nodeIS3_E
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_,comdat
	.weak	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_ # -- Begin function _ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_
	.p2align	1, 0x90
	.type	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_,@function
_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_: # @_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rcx, %r15
	movq	%rsi, %r12
	movq	%rdi, %r14
	movl	$48, %edi
	callq	_Znwm
	movq	%rax, %rbx
	leaq	32(%rax), %rdx
	movq	(%r15), %rax
	movq	(%rax), %rax
	movq	%rax, 32(%rbx)
	movq	$0, 40(%rbx)
.Ltmp5:
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_
.Ltmp6:
# %bb.1:
	movq	%rax, %r15
	testq	%rdx, %rdx
	je	.LBB15_5
# %bb.2:
.Ltmp7:
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%rbx, %rcx
	callq	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E
.Ltmp8:
# %bb.3:
	movq	%rax, %r15
	jmp	.LBB15_6
.LBB15_5:                               # %_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE10_Auto_node9_M_insertES0_IPSt18_Rb_tree_node_baseSD_E.exit
	movq	%rbx, %rdi
	callq	_ZdlPv
.LBB15_6:                               # %_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE10_Auto_nodeD2Ev.exit9
	movq	%r15, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB15_4:                               # %_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE10_Auto_nodeD2Ev.exit
	.cfi_def_cfa_offset 48
.Ltmp9:
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end15:
	.size	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_, .Lfunc_end15-_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_
	.cfi_endproc
	.section	.gcc_except_table._ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_,"aG",@progbits,_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESF_IJEEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_,comdat
	.p2align	2, 0x0
GCC_except_table15:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Lfunc_begin1-.Lfunc_begin1    # >> Call Site 1 <<
	.uleb128 .Ltmp5-.Lfunc_begin1           #   Call between .Lfunc_begin1 and .Ltmp5
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp5-.Lfunc_begin1           # >> Call Site 2 <<
	.uleb128 .Ltmp8-.Ltmp5                  #   Call between .Ltmp5 and .Ltmp8
	.uleb128 .Ltmp9-.Lfunc_begin1           #     jumps to .Ltmp9
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin1           # >> Call Site 3 <<
	.uleb128 .Lfunc_end15-.Ltmp8            #   Call between .Ltmp8 and .Lfunc_end15
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end1:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_,comdat
	.weak	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_ # -- Begin function _ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_
	.p2align	1, 0x90
	.type	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_,@function
_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_: # @_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rdi, %r15
	leaq	8(%rdi), %rax
	cmpq	%rsi, %rax
	je	.LBB16_1
# %bb.4:
	movq	%rsi, %rbx
	movq	(%r14), %r12
	movq	32(%rsi), %rax
	cmpq	%rax, %r12
	jae	.LBB16_9
# %bb.5:
	cmpq	%rbx, 24(%r15)
	je	.LBB16_6
# %bb.7:
	movq	%rbx, %rdi
	callq	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base
	cmpq	%r12, 32(%rax)
	jae	.LBB16_14
# %bb.8:
	movq	%rax, %rcx
	movq	24(%rax), %rax
	testq	%rax, %rax
	cmovneq	%rbx, %rax
	cmoveq	%rcx, %rbx
	jmp	.LBB16_15
.LBB16_1:
	cmpq	$0, 40(%r15)
	je	.LBB16_14
# %bb.2:
	movq	32(%r15), %rbx
	movq	32(%rbx), %rax
	cmpq	(%r14), %rax
	jae	.LBB16_14
	jmp	.LBB16_3
.LBB16_9:
	jbe	.LBB16_10
# %bb.11:
	cmpq	%rbx, 32(%r15)
	je	.LBB16_3
# %bb.12:
	movq	%rbx, %rdi
	callq	_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base
	cmpq	32(%rax), %r12
	jae	.LBB16_14
# %bb.13:
	movq	%rax, %rcx
	movq	24(%rbx), %rax
	testq	%rax, %rax
	cmovneq	%rcx, %rax
	cmovneq	%rcx, %rbx
	jmp	.LBB16_15
.LBB16_14:
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_
	movq	%rdx, %rbx
	jmp	.LBB16_15
.LBB16_3:
	xorl	%eax, %eax
	jmp	.LBB16_15
.LBB16_10:
	movq	%rbx, %rax
	xorl	%ebx, %ebx
	jmp	.LBB16_15
.LBB16_6:
	movq	%rbx, %rax
.LBB16_15:
	movq	%rbx, %rdx
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end16:
	.size	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_, .Lfunc_end16-_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_,comdat
	.weak	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_ # -- Begin function _ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_
	.p2align	1, 0x90
	.type	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_,@function
_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_: # @_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %r14
	movq	16(%rdi), %rax
	testq	%rax, %rax
	je	.LBB17_1
# %bb.2:                                # %.lr.ph
	movq	(%r14), %rcx
.LBB17_3:                               # =>This Inner Loop Header: Depth=1
	movq	%rax, %rbx
	movq	32(%rax), %rdx
	xorl	%eax, %eax
	cmpq	%rdx, %rcx
	setae	%al
	movq	16(%rbx,%rax,8), %rax
	testq	%rax, %rax
	jne	.LBB17_3
# %bb.4:                                # %._crit_edge
	movq	%rbx, %rax
	cmpq	%rdx, %rcx
	jb	.LBB17_5
	jmp	.LBB17_8
.LBB17_1:
	leaq	8(%rdi), %rbx
.LBB17_5:                               # %._crit_edge.thread
	cmpq	24(%rdi), %rbx
	je	.LBB17_6
# %bb.7:
	movq	%rbx, %rdi
	callq	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base
.LBB17_8:
	movq	32(%rax), %rcx
	xorl	%edx, %edx
	cmpq	(%r14), %rcx
	cmovbq	%rdx, %rax
	cmovaeq	%rdx, %rbx
	jmp	.LBB17_9
.LBB17_6:
	xorl	%eax, %eax
.LBB17_9:
	movq	%rbx, %rdx
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end17:
	.size	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_, .Lfunc_end17-_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE24_M_get_insert_unique_posERS1_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E,"axG",@progbits,_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E,comdat
	.weak	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E # -- Begin function _ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E
	.p2align	1, 0x90
	.type	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E,@function
_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E: # @_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rcx, %rbx
	movq	%rdi, %r14
	leaq	8(%rdi), %rcx
	movb	$1, %al
	testq	%rsi, %rsi
	jne	.LBB18_3
# %bb.1:
	cmpq	%rdx, %rcx
	je	.LBB18_3
# %bb.2:
	movq	32(%rbx), %rax
	cmpq	32(%rdx), %rax
	setb	%al
.LBB18_3:
	movzbl	%al, %edi
	movq	%rbx, %rsi
	callq	_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_
	incq	40(%r14)
	movq	%rbx, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end18:
	.size	_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E, .Lfunc_end18-_ZNSt8_Rb_treeImSt4pairIKmP12ihipStream_tESt10_Select1stIS4_ESt4lessImESaIS4_EE14_M_insert_nodeEPSt18_Rb_tree_node_baseSC_PSt13_Rb_tree_nodeIS4_E
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _GLOBAL__sub_I_threadpool.hip
.LCPI19_0:
	.zero	16
	.section	.text.startup,"ax",@progbits
	.type	_GLOBAL__sub_I_threadpool.hip,@function
_GLOBAL__sub_I_threadpool.hip:          # @_GLOBAL__sub_I_threadpool.hip
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	xorps	%xmm0, %xmm0
	movups	%xmm0, cpu_workers(%rip)
	xorl	%ebx, %ebx
	movq	%rbx, cpu_workers+16(%rip)
	movl	$_ZNSt6vectorImSaImEED2Ev, %edi
	movl	$cpu_workers, %esi
	movl	$__dso_handle, %edx
	callq	__cxa_atexit
	xorps	%xmm0, %xmm0
	movups	%xmm0, gpu_workers(%rip)
	movq	%rbx, gpu_workers+16(%rip)
	movl	$_ZNSt6vectorImSaImEED2Ev, %edi
	movl	$gpu_workers, %esi
	movl	$__dso_handle, %edx
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	__cxa_atexit                    # TAILCALL
.Lfunc_end19:
	.size	_GLOBAL__sub_I_threadpool.hip, .Lfunc_end19-_GLOBAL__sub_I_threadpool.hip
	.cfi_endproc
                                        # -- End function
	.type	cpu_workers,@object             # @cpu_workers
	.bss
	.globl	cpu_workers
	.p2align	3, 0x0
cpu_workers:
	.zero	24
	.size	cpu_workers, 24

	.hidden	__dso_handle
	.type	gpu_workers,@object             # @gpu_workers
	.globl	gpu_workers
	.p2align	3, 0x0
gpu_workers:
	.zero	24
	.size	gpu_workers, 24

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Failed to create thread for id :"
	.size	.L.str, 33

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Failed to spawn cpu threads"
	.size	.L.str.2, 28

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Failed to join thread for id :"
	.size	.L.str.3, 31

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"CPU threads finished"
	.size	.L.str.4, 21

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"GPU threads finished"
	.size	.L.str.5, 21

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"vector::_M_default_append"
	.size	.L.str.6, 26

	.type	_ZSt19piecewise_construct,@object # @_ZSt19piecewise_construct
	.section	.rodata._ZSt19piecewise_construct,"aG",@progbits,_ZSt19piecewise_construct,comdat
	.weak	_ZSt19piecewise_construct
_ZSt19piecewise_construct:
	.zero	1
	.size	_ZSt19piecewise_construct, 1

	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	_GLOBAL__sub_I_threadpool.hip
	.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 _Z13__do_work_cpuPv
	.addrsig_sym _Z13__do_work_gpuPv
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym _GLOBAL__sub_I_threadpool.hip
	.addrsig_sym _Unwind_Resume
	.addrsig_sym cpu_workers
	.addrsig_sym __dso_handle
	.addrsig_sym gpu_workers
	.addrsig_sym _ZSt4cout
	.addrsig_sym cpu_lock_map
	.addrsig_sym stream_map
	.addrsig_sym gpu_lock_map
	.addrsig_sym _ZSt19piecewise_construct
	.addrsig_sym __hip_cuid_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
