#include <algorithm>
#include <iostream>
#include <vector>

std::vector<double> add(std::vector<double> inarr1, std::vector<double> inarr2);

void test_integration()
{
    constexpr size_t arr_size = 2 << 24;

    std::cout << "Initializing test arrays...\n";
    std::vector<double> arr1(arr_size);
    std::vector<double> arr2(arr_size);

    for (size_t i = 0; i < arr_size; i++)
    {
        arr1[i] = static_cast<double>(i);
        arr2[i] = static_cast<double>(arr_size - i);
    }

    std::cout << "Calling the kernel wrapper...\n";
    auto result = add(std::move(arr1), std::move(arr2));

    std::cout << "Verifying results...\n";
    if (std::all_of(result.begin(), result.end(),
            [arr_size](double x) { return x == arr_size; }))
    {
        std::cout << "All results were valid.\n";
    }
    else
    {
        std::cout << "At least one result is invalid.\n";
    }
}

int main()
{
    std::cout << "Test CUDA integration\n";
    test_integration();
    std::cout << "Finished testing\n";
    return 0;
}

	.file	"tmpxft_00394f43_00000000-6_test_add_integ.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4266:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4266:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0, @function
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0:
.LFB5014:
	.cfi_startproc
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	testq	%rsi, %rsi
	jne	.L3
	movq	(%rdi), %rax
	movl	$1, %esi
	addq	-24(%rax), %rbx
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_ZNSt9basic_iosIcSt11char_traitsIcEE8setstateESt12_Ios_Iostate@PLT
.L3:
	.cfi_restore_state
	movq	%rsi, %rdi
	movq	%rsi, 8(%rsp)
	call	strlen@PLT
	movq	8(%rsp), %rsi
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	movq	%rax, %rdx
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	.cfi_endproc
.LFE5014:
	.size	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0, .-_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4289:
	.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
.LFE4289:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIdSaIdEED2Ev,"axG",@progbits,_ZNSt6vectorIdSaIdEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIdSaIdEED2Ev
	.type	_ZNSt6vectorIdSaIdEED2Ev, @function
_ZNSt6vectorIdSaIdEED2Ev:
.LFB4600:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L8
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L8:
	ret
	.cfi_endproc
.LFE4600:
	.size	_ZNSt6vectorIdSaIdEED2Ev, .-_ZNSt6vectorIdSaIdEED2Ev
	.weak	_ZNSt6vectorIdSaIdEED1Ev
	.set	_ZNSt6vectorIdSaIdEED1Ev,_ZNSt6vectorIdSaIdEED2Ev
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Initializing test arrays...\n"
.LC2:
	.string	"Calling the kernel wrapper...\n"
.LC3:
	.string	"Verifying results...\n"
.LC5:
	.string	"All results were valid.\n"
.LC6:
	.string	"At least one result is invalid.\n"
	.text
	.globl	_Z16test_integrationv
	.type	_Z16test_integrationv, @function
_Z16test_integrationv:
.LFB4252:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4252
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	_ZSt4cout(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	addq	$-128, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
.LEHB0:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0
	movl	$268435456, %edi
	call	_Znwm@PLT
.LEHE0:
	leaq	268435456(%rax), %r13
	movq	%rax, (%rsp)
	movq	%rax, %rbx
	movq	%r13, 16(%rsp)
	movq	$0x000000000, (%rax)
	xorl	%eax, %eax
.L11:
	addq	$8, %rax
	cmpq	$268435456, %rax
	je	.L63
	movq	$0x000000000, (%rbx,%rax)
	jmp	.L11
.L63:
	xorl	%ecx, %ecx
	movl	$268435456, %edi
	movq	%r13, 8(%rsp)
	movq	%rcx, 32(%rsp)
	movq	%rcx, 40(%rsp)
.LEHB1:
	call	_Znwm@PLT
.LEHE1:
	leaq	268435456(%rax), %r14
	movq	%rax, 24(%rsp)
	movq	%rax, %rbp
	movq	%r14, 40(%rsp)
	movq	$0x000000000, (%rax)
	xorl	%eax, %eax
.L13:
	addq	$8, %rax
	cmpq	$268435456, %rax
	je	.L64
	movq	$0x000000000, 0(%rbp,%rax)
	jmp	.L13
.L64:
	movq	%r14, 32(%rsp)
	xorl	%eax, %eax
	movl	$33554432, %ecx
.L15:
	cvtsi2sdq	%rax, %xmm0
	movq	%rcx, %rdx
	subq	%rax, %rdx
	movsd	%xmm0, (%rbx,%rax,8)
	cvtsi2sdq	%rdx, %xmm0
	movsd	%xmm0, 0(%rbp,%rax,8)
	incq	%rax
	cmpq	$33554432, %rax
	jne	.L15
	leaq	.LC2(%rip), %rsi
	movq	%r12, %rdi
.LEHB2:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0
.LEHE2:
	xorl	%edx, %edx
	movq	%rbp, 96(%rsp)
	leaq	48(%rsp), %rbp
	xorl	%eax, %eax
	movq	%r14, 104(%rsp)
	movq	%rbp, %rdi
	movq	%r14, 112(%rsp)
	leaq	72(%rsp), %r14
	movq	%r13, 80(%rsp)
	movq	%r14, %rsi
	movq	%r13, 88(%rsp)
	leaq	96(%rsp), %r13
	movq	%rdx, 16(%rsp)
	movq	%rdx, 8(%rsp)
	movq	%rdx, (%rsp)
	movq	%r13, %rdx
	movq	%rax, 40(%rsp)
	movq	%rax, 32(%rsp)
	movq	%rax, 24(%rsp)
	movq	%rbx, 72(%rsp)
.LEHB3:
	call	_Z3addSt6vectorIdSaIdEES1_@PLT
.LEHE3:
	movq	%r14, %rdi
	call	_ZNSt6vectorIdSaIdEED1Ev
	movq	%r13, %rdi
	call	_ZNSt6vectorIdSaIdEED1Ev
	leaq	.LC3(%rip), %rsi
	movq	%r12, %rdi
.LEHB4:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdx
	movsd	.LC4(%rip), %xmm0
	movq	%rsi, %rcx
	subq	%rdx, %rcx
	sarq	$5, %rcx
.L16:
	movq	%rdx, %rax
	testq	%rcx, %rcx
	jle	.L65
	ucomisd	(%rdx), %xmm0
	jp	.L17
	jne	.L17
	ucomisd	8(%rdx), %xmm0
	jp	.L46
	je	.L19
.L46:
	leaq	8(%rdx), %rax
	jmp	.L17
.L19:
	ucomisd	16(%rdx), %xmm0
	jp	.L47
	je	.L21
.L47:
	leaq	16(%rdx), %rax
	jmp	.L17
.L21:
	addq	$32, %rdx
	ucomisd	-8(%rdx), %xmm0
	jp	.L48
	je	.L23
.L48:
	addq	$24, %rax
	jmp	.L17
.L23:
	decq	%rcx
	jmp	.L16
.L65:
	movq	%rsi, %rdx
	subq	%rax, %rdx
	cmpq	$16, %rdx
	je	.L26
	cmpq	$24, %rdx
	je	.L27
	cmpq	$8, %rdx
	je	.L28
	jmp	.L29
.L27:
	movsd	.LC4(%rip), %xmm0
	ucomisd	(%rax), %xmm0
	jp	.L17
	jne	.L17
	addq	$8, %rax
.L26:
	movsd	.LC4(%rip), %xmm0
	ucomisd	(%rax), %xmm0
	jp	.L17
	jne	.L17
	addq	$8, %rax
.L28:
	movsd	.LC4(%rip), %xmm0
	ucomisd	(%rax), %xmm0
	jp	.L17
	je	.L29
.L17:
	cmpq	%rsi, %rax
	jne	.L33
.L29:
	leaq	.LC5(%rip), %rsi
.L61:
	movq	%r12, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0
.LEHE4:
	movq	%rbp, %rdi
	call	_ZNSt6vectorIdSaIdEED1Ev
	leaq	24(%rsp), %rdi
	call	_ZNSt6vectorIdSaIdEED1Ev
	movq	%rsp, %rdi
	call	_ZNSt6vectorIdSaIdEED1Ev
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L40
	jmp	.L58
.L33:
	leaq	.LC6(%rip), %rsi
	jmp	.L61
.L43:
	endbr64
	movq	%rax, %rbx
.L35:
	movq	%r14, %rdi
	call	_ZNSt6vectorIdSaIdEED1Ev
	movq	%r13, %rdi
	jmp	.L62
.L44:
	endbr64
	movq	%rax, %rbx
.L37:
	movq	%rbp, %rdi
.L62:
	call	_ZNSt6vectorIdSaIdEED1Ev
	jmp	.L36
.L42:
	endbr64
	movq	%rax, %rbx
.L36:
	leaq	24(%rsp), %rdi
	call	_ZNSt6vectorIdSaIdEED1Ev
	jmp	.L38
.L41:
	endbr64
	movq	%rax, %rbx
.L38:
	movq	%rsp, %rdi
	call	_ZNSt6vectorIdSaIdEED1Ev
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L58
	movq	%rbx, %rdi
.LEHB5:
	call	_Unwind_Resume@PLT
.LEHE5:
.L58:
	call	__stack_chk_fail@PLT
.L40:
	subq	$-128, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4252:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4252:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4252-.LLSDACSB4252
.LLSDACSB4252:
	.uleb128 .LEHB0-.LFB4252
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4252
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L41-.LFB4252
	.uleb128 0
	.uleb128 .LEHB2-.LFB4252
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L42-.LFB4252
	.uleb128 0
	.uleb128 .LEHB3-.LFB4252
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L43-.LFB4252
	.uleb128 0
	.uleb128 .LEHB4-.LFB4252
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L44-.LFB4252
	.uleb128 0
	.uleb128 .LEHB5-.LFB4252
	.uleb128 .LEHE5-.LEHB5
	.uleb128 0
	.uleb128 0
.LLSDACSE4252:
	.text
	.size	_Z16test_integrationv, .-_Z16test_integrationv
	.section	.rodata.str1.1
.LC7:
	.string	"Test CUDA integration\n"
.LC8:
	.string	"Finished testing\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4263:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZSt4cout(%rip), %rbx
	leaq	.LC7(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0
	call	_Z16test_integrationv
	movq	%rbx, %rdi
	leaq	.LC8(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.isra.0
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4263:
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC4:
	.long	0
	.long	1098907648
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <algorithm>
#include <iostream>
#include <vector>

std::vector<double> add(std::vector<double> inarr1, std::vector<double> inarr2);

void test_integration()
{
    constexpr size_t arr_size = 2 << 24;

    std::cout << "Initializing test arrays...\n";
    std::vector<double> arr1(arr_size);
    std::vector<double> arr2(arr_size);

    for (size_t i = 0; i < arr_size; i++)
    {
        arr1[i] = static_cast<double>(i);
        arr2[i] = static_cast<double>(arr_size - i);
    }

    std::cout << "Calling the kernel wrapper...\n";
    auto result = add(std::move(arr1), std::move(arr2));

    std::cout << "Verifying results...\n";
    if (std::all_of(result.begin(), result.end(),
            [arr_size](double x) { return x == arr_size; }))
    {
        std::cout << "All results were valid.\n";
    }
    else
    {
        std::cout << "At least one result is invalid.\n";
    }
}

int main()
{
    std::cout << "Test CUDA integration\n";
    test_integration();
    std::cout << "Finished testing\n";
    return 0;
}

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

                                        # End of file scope inline assembly
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z16test_integrationv
.LCPI0_0:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI0_1:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI0_2:
	.quad	0x4180000000000000              # double 33554432
	.text
	.globl	_Z16test_integrationv
	.type	_Z16test_integrationv,@function
_Z16test_integrationv:                  # @_Z16test_integrationv
.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
	subq	$72, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$28, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$268435456, %edi                # imm = 0x10000000
	callq	_Znwm
	movq	%rax, %rbx
	movl	$268435456, %edx                # imm = 0x10000000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
.Ltmp0:
	movl	$268435456, %edi                # imm = 0x10000000
	callq	_Znwm
.Ltmp1:
# %bb.1:
	movq	%rax, %r14
	movq	%rbx, %r15
	addq	$268435456, %r15                # imm = 0x10000000
	xorl	%r12d, %r12d
	movl	$268435456, %edx                # imm = 0x10000000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$33554432, %eax                 # imm = 0x2000000
	movdqa	.LCPI0_0(%rip), %xmm0           # xmm0 = [1127219200,1160773632,0,0]
	movapd	.LCPI0_1(%rip), %xmm1           # xmm1 = [4.503599627370496E+15,1.9342813113834067E+25]
.LBB0_2:                                # =>This Inner Loop Header: Depth=1
	movq	%r12, %xmm2
	punpckldq	%xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
	subpd	%xmm1, %xmm2
	movapd	%xmm2, %xmm3
	unpckhpd	%xmm2, %xmm3                    # xmm3 = xmm3[1],xmm2[1]
	addsd	%xmm2, %xmm3
	movsd	%xmm3, (%rbx,%r12,8)
	movq	%rax, %xmm2
	punpckldq	%xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
	subpd	%xmm1, %xmm2
	movapd	%xmm2, %xmm3
	unpckhpd	%xmm2, %xmm3                    # xmm3 = xmm3[1],xmm2[1]
	addsd	%xmm2, %xmm3
	movsd	%xmm3, (%r14,%r12,8)
	incq	%r12
	decq	%rax
	jne	.LBB0_2
# %bb.3:
.Ltmp3:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$30, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp4:
# %bb.4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movq	%r14, %rax
	addq	$268435456, %rax                # imm = 0x10000000
	leaq	48(%rsp), %rsi
	movq	%rbx, (%rsi)
	movq	%r15, 8(%rsi)
	movq	%r15, 16(%rsi)
	leaq	24(%rsp), %rdx
	movq	%r14, (%rdx)
	movq	%rax, 8(%rdx)
	movq	%rax, 16(%rdx)
.Ltmp6:
	movq	%rsp, %rdi
	callq	_Z3addSt6vectorIdSaIdEES1_
.Ltmp7:
# %bb.5:
	movq	24(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_7
# %bb.6:
	callq	_ZdlPv
.LBB0_7:                                # %_ZNSt6vectorIdSaIdEED2Ev.exit
	movq	48(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_9
# %bb.8:
	callq	_ZdlPv
.LBB0_9:                                # %_ZNSt6vectorIdSaIdEED2Ev.exit20
.Ltmp9:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$21, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp10:
# %bb.10:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit21
	movq	(%rsp), %rdx
	movq	8(%rsp), %rax
	movq	%rax, %rdi
	subq	%rdx, %rdi
	movq	%rdi, %rsi
	sarq	$5, %rsi
	testq	%rsi, %rsi
	jle	.LBB0_11
# %bb.12:                               # %.lr.ph.preheader.i.i.i.i
	andq	$-32, %rdi
	movq	%rdi, %rcx
	addq	%rdx, %rcx
	incq	%rsi
	addq	$16, %rdx
	movsd	.LCPI0_2(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB0_13:                               # %.lr.ph.i.i.i.i
                                        # =>This Inner Loop Header: Depth=1
	movsd	-16(%rdx), %xmm1                # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	jne	.LBB0_35
	jp	.LBB0_35
# %bb.14:                               #   in Loop: Header=BB0_13 Depth=1
	movsd	-8(%rdx), %xmm1                 # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	jne	.LBB0_34
	jp	.LBB0_34
# %bb.15:                               #   in Loop: Header=BB0_13 Depth=1
	movsd	(%rdx), %xmm1                   # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	jne	.LBB0_36
	jp	.LBB0_36
# %bb.16:                               #   in Loop: Header=BB0_13 Depth=1
	movsd	8(%rdx), %xmm1                  # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	jne	.LBB0_33
	jp	.LBB0_33
# %bb.17:                               #   in Loop: Header=BB0_13 Depth=1
	decq	%rsi
	addq	$32, %rdx
	cmpq	$1, %rsi
	jg	.LBB0_13
# %bb.18:                               # %._crit_edge.loopexit.i.i.i.i
	movq	%rax, %rdi
	subq	%rcx, %rdi
	jmp	.LBB0_19
.LBB0_11:
	movq	%rdx, %rcx
.LBB0_19:                               # %._crit_edge.i.i.i.i
	sarq	$3, %rdi
	cmpq	$1, %rdi
	je	.LBB0_27
# %bb.20:                               # %._crit_edge.i.i.i.i
	cmpq	$2, %rdi
	je	.LBB0_25
# %bb.21:                               # %._crit_edge.i.i.i.i
	cmpq	$3, %rdi
	jne	.LBB0_28
# %bb.22:
	movsd	(%rcx), %xmm0                   # xmm0 = mem[0],zero
	ucomisd	.LCPI0_2(%rip), %xmm0
	jne	.LBB0_23
	jp	.LBB0_23
# %bb.24:
	addq	$8, %rcx
.LBB0_25:
	movsd	(%rcx), %xmm0                   # xmm0 = mem[0],zero
	ucomisd	.LCPI0_2(%rip), %xmm0
	jne	.LBB0_23
	jnp	.LBB0_26
.LBB0_23:
	movq	%rcx, %rdx
	jmp	.LBB0_36
.LBB0_35:                               # %.loopexit.loopexit
	addq	$-16, %rdx
	jmp	.LBB0_36
.LBB0_34:                               # %.loopexit.loopexit.split.loop.exit87
	addq	$-8, %rdx
	jmp	.LBB0_36
.LBB0_33:                               # %.loopexit.loopexit.split.loop.exit
	addq	$8, %rdx
	jmp	.LBB0_36
.LBB0_26:
	addq	$8, %rcx
.LBB0_27:
	movsd	(%rcx), %xmm0                   # xmm0 = mem[0],zero
	ucomisd	.LCPI0_2(%rip), %xmm0
	movq	%rcx, %rdx
	jne	.LBB0_36
	jnp	.LBB0_28
.LBB0_36:                               # %.loopexit
	cmpq	%rax, %rdx
	je	.LBB0_28
# %bb.37:
	movl	$32, %edx
	movl	$.L.str.4, %esi
	jmp	.LBB0_29
.LBB0_28:                               # %.thread
	movl	$24, %edx
	movl	$.L.str.3, %esi
.LBB0_29:                               # %.invoke
.Ltmp11:
	movl	$_ZSt4cout, %edi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp12:
# %bb.30:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit22
	movq	(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_32
# %bb.31:
	callq	_ZdlPv
.LBB0_32:                               # %_ZNSt6vectorIdSaIdEED2Ev.exit35
	addq	$72, %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
.LBB0_38:
	.cfi_def_cfa_offset 112
.Ltmp8:
	movq	%rax, %r15
	movq	24(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB0_40
# %bb.39:
	callq	_ZdlPv
.LBB0_40:                               # %_ZNSt6vectorIdSaIdEED2Ev.exit24
	movq	48(%rsp), %rdi
	jmp	.LBB0_41
.LBB0_43:
.Ltmp5:
	movq	%rax, %r15
	movq	%r14, %rdi
	callq	_ZdlPv
	jmp	.LBB0_45
.LBB0_44:
.Ltmp2:
	movq	%rax, %r15
.LBB0_45:
	movq	%rbx, %rdi
	jmp	.LBB0_46
.LBB0_42:
.Ltmp13:
	movq	%rax, %r15
	movq	(%rsp), %rdi
.LBB0_41:                               # %_ZNSt6vectorIdSaIdEED2Ev.exit24
	testq	%rdi, %rdi
	je	.LBB0_47
.LBB0_46:                               # %_ZNSt6vectorIdSaIdEED2Ev.exit39
	callq	_ZdlPv
.LBB0_47:                               # %_ZNSt6vectorIdSaIdEED2Ev.exit39
	movq	%r15, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end0:
	.size	_Z16test_integrationv, .Lfunc_end0-_Z16test_integrationv
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table0:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp3-.Ltmp1                  #   Call between .Ltmp1 and .Ltmp3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 5 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 6 <<
	.uleb128 .Ltmp12-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp12
	.uleb128 .Ltmp13-.Lfunc_begin0          #     jumps to .Ltmp13
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp12-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Lfunc_end0-.Ltmp12            #   Call between .Ltmp12 and .Lfunc_end0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	callq	_Z16test_integrationv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorl	%eax, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Initializing test arrays...\n"
	.size	.L.str, 29

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Calling the kernel wrapper...\n"
	.size	.L.str.1, 31

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Verifying results...\n"
	.size	.L.str.2, 22

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"All results were valid.\n"
	.size	.L.str.3, 25

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"At least one result is invalid.\n"
	.size	.L.str.4, 33

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Test CUDA integration\n"
	.size	.L.str.5, 23

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Finished testing\n"
	.size	.L.str.6, 18

	.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 __gxx_personality_v0
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _ZSt4cout
	.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
