#include "Tools.cuh"

#include <stdexcept>

// TODO: Remove globals in the short future
int*   h_no_sensors;
int*   h_no_hits;
int*   h_sensor_Zs;
int*   h_sensor_hitStarts;
int*   h_sensor_hitNums;
unsigned int* h_hit_IDs;
float* h_hit_Xs;
float* h_hit_Ys;
float* h_hit_Zs;

void setHPointersFromInput(const uint8_t * input, size_t size) {
  const uint8_t * end = input + size;

  h_no_sensors       = (int32_t*)input; input += sizeof(int32_t);
  h_no_hits          = (int32_t*)input; input += sizeof(int32_t);
  h_sensor_Zs        = (int32_t*)input; input += sizeof(int32_t) * *h_no_sensors;
  h_sensor_hitStarts = (int32_t*)input; input += sizeof(int32_t) * *h_no_sensors;
  h_sensor_hitNums   = (int32_t*)input; input += sizeof(int32_t) * *h_no_sensors;
  h_hit_IDs          = (uint32_t*)input; input += sizeof(uint32_t) * *h_no_hits;
  h_hit_Xs           = (float*)  input; input += sizeof(float)   * *h_no_hits;
  h_hit_Ys           = (float*)  input; input += sizeof(float)   * *h_no_hits;
  h_hit_Zs           = (float*)  input; input += sizeof(float)   * *h_no_hits;

  if (input != end)
    throw std::runtime_error("failed to deserialize event");
}

/**
 * Combine all solutions, in the form:
 *
 * int numberOfEvents
 * per event:
 *     int size
 *
 * per event:
 *     char* output
 *
 * @param solutions
 * @param output
 */
void mergeSolutions(const std::vector<std::vector<char> >& solutions, std::vector<char>& output) {
    int numberOfEvents = solutions.size();
    output.resize((numberOfEvents + 1) * sizeof(int));
    char* outputPointer = ((char*) &(output[0]));

    memcpy(outputPointer, &numberOfEvents, sizeof(int));
    outputPointer += sizeof(int);

    int return_size = 0;
    for (int i=0; i<solutions.size(); ++i) {
        // Requires lvalue
        int solutions_size = solutions[i].size();
        return_size += solutions_size;
        memcpy(outputPointer, &solutions_size, sizeof(int));
    }

    // After resizing, the pointer may change, so recalculate
    output.resize(output.size() + return_size);
    outputPointer = ((char*) &(output[0])) + (numberOfEvents + 1) * sizeof(int);

    for (int i=0; i<solutions.size(); ++i) {
        memcpy(outputPointer, &(solutions[i][0]), solutions[i].size());
        outputPointer += solutions[i].size();
    }
}

std::map<std::string, float> calcResults(std::vector<float>& times) {
    // sqrt ( E( (X - m)2) )
    std::map<std::string, float> results;
    float deviation = 0.0f, variance = 0.0f, mean = 0.0f, min = float_max(), max = 0.0f;

    for(auto it = times.begin(); it != times.end(); it++) {
        const float seconds = (*it);
        mean += seconds;
        variance += seconds * seconds;

        if (seconds < min) min = seconds;
        if (seconds > max) max = seconds;
    }

    mean /= times.size();
    variance = (variance / times.size()) - (mean * mean);
    deviation = std::sqrt(variance);

    results["variance"] = variance;
    results["deviation"] = deviation;
    results["mean"] = mean;
    results["min"] = min;
    results["max"] = max;

    return results;
}

float float_max() {
    const int value = 0x7f800000;
    const float* const fvalue = (const float*) &value;
    return *(float*)& fvalue[0];
}

	.file	"tmpxft_0023b2a9_00000000-6_Tools.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4491:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4491:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E.isra.0, @function
_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E.isra.0:
.LFB5367:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 32
.L3:
	testq	%rbx, %rbx
	je	.L7
	movq	24(%rbx), %rdi
	call	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E.isra.0
	leaq	32(%rbx), %rdi
	movq	16(%rbx), %rbp
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%rbx, %rdi
	movl	$72, %esi
	call	_ZdlPvm@PLT
	movq	%rbp, %rbx
	jmp	.L3
.L7:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5367:
	.size	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E.isra.0, .-_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"failed to deserialize event"
	.text
	.globl	_Z21setHPointersFromInputPKhm
	.type	_Z21setHPointersFromInputPKhm, @function
_Z21setHPointersFromInputPKhm:
.LFB4461:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4461
	endbr64
	movslq	(%rdi), %rdx
	leaq	4(%rdi), %rax
	movq	%rdi, h_no_sensors(%rip)
	movq	%rax, h_no_hits(%rip)
	leaq	8(%rdi), %rax
	salq	$2, %rdx
	movq	%rax, h_sensor_Zs(%rip)
	addq	%rdx, %rax
	movq	%rax, h_sensor_hitStarts(%rip)
	addq	%rdx, %rax
	movq	%rax, h_sensor_hitNums(%rip)
	addq	%rdx, %rax
	movslq	4(%rdi), %rdx
	addq	%rsi, %rdi
	movq	%rax, h_hit_IDs(%rip)
	salq	$2, %rdx
	addq	%rdx, %rax
	movq	%rax, h_hit_Xs(%rip)
	addq	%rdx, %rax
	movq	%rax, h_hit_Ys(%rip)
	addq	%rdx, %rax
	movq	%rax, h_hit_Zs(%rip)
	addq	%rdx, %rax
	cmpq	%rax, %rdi
	je	.L8
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$16, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	__cxa_allocate_exception@PLT
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, %rbx
.LEHB0:
	call	_ZNSt13runtime_errorC1EPKc@PLT
.LEHE0:
	movq	_ZNSt13runtime_errorD1Ev@GOTPCREL(%rip), %rdx
	leaq	_ZTISt13runtime_error(%rip), %rsi
	movq	%rbx, %rdi
.LEHB1:
	call	__cxa_throw@PLT
.L11:
	endbr64
	movq	%rax, %rbp
.L10:
	movq	%rbx, %rdi
	call	__cxa_free_exception@PLT
	movq	%rbp, %rdi
	call	_Unwind_Resume@PLT
.LEHE1:
.L8:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE4461:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4461:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4461-.LLSDACSB4461
.LLSDACSB4461:
	.uleb128 .LEHB0-.LFB4461
	.uleb128 .LEHE0-.LEHB0
	.uleb128 .L11-.LFB4461
	.uleb128 0
	.uleb128 .LEHB1-.LFB4461
	.uleb128 .LEHE1-.LEHB1
	.uleb128 0
	.uleb128 0
.LLSDACSE4461:
	.text
	.size	_Z21setHPointersFromInputPKhm, .-_Z21setHPointersFromInputPKhm
	.globl	_Z9float_maxv
	.type	_Z9float_maxv, @function
_Z9float_maxv:
.LFB4488:
	.cfi_startproc
	endbr64
	movss	.LC1(%rip), %xmm0
	ret
	.cfi_endproc
.LFE4488:
	.size	_Z9float_maxv, .-_Z9float_maxv
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4514:
	.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
.LFE4514:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.str1.1,"aMS",@progbits,1
.LC2:
	.string	"basic_string: construction from null is not valid"
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IS3_EEPKcRKS3_,comdat
	.align 2
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_:
.LFB4836:
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	jne	.L19
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	leaq	.LC2(%rip), %rdi
	call	_ZSt19__throw_logic_errorPKc@PLT
.L19:
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	movq	%rsi, %rbp
	call	strlen@PLT
	movq	%rax, (%rsp)
	leaq	0(%rbp,%rax), %r12
	cmpq	$15, %rax
	jbe	.L21
	movq	%rsp, %rsi
	xorl	%edx, %edx
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT
	movq	%rax, (%rbx)
	movq	(%rsp), %rax
	movq	%rax, 16(%rbx)
.L21:
	movq	(%rbx), %rdi
	movq	%r12, %rdx
	movq	%rbp, %rsi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	(%rsp), %rax
	movq	(%rbx), %rdx
	movq	%rax, 8(%rbx)
	movb	$0, (%rdx,%rax)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
.L24:
	call	__stack_chk_fail@PLT
.L22:
	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
.LFE4836:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	.set	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.section	.text._ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_,"axG",@progbits,_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_,comdat
	.weak	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	.type	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_, @function
_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_:
.LFB5144:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareERKS4_@PLT
	popq	%rdx
	.cfi_def_cfa_offset 8
	shrl	$31, %eax
	ret
	.cfi_endproc
.LFE5144:
	.size	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_, .-_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	.section	.text._ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_,"axG",@progbits,_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_,comdat
	.align 2
	.weak	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_
	.type	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_, @function
_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_:
.LFB5256:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rsi, %r13
	movb	$1, %al
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	8(%rdi), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%r8
	.cfi_def_cfa_offset 48
	movq	16(%rdi), %rbx
.L28:
	testq	%rbx, %rbx
	je	.L37
	leaq	32(%rbx), %rsi
	movq	%r13, %rdi
	movq	%rbx, %rbp
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	movq	24(%rbx), %rdx
	testb	%al, %al
	cmovne	16(%rbx), %rdx
	movq	%rdx, %rbx
	jmp	.L28
.L37:
	testb	%al, %al
	je	.L33
	cmpq	%rbp, 24(%r12)
	je	.L32
	movq	%rbp, %rdi
	call	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base@PLT
	movq	%rax, %r12
	jmp	.L31
.L33:
	movq	%rbp, %r12
.L31:
	leaq	32(%r12), %rdi
	movq	%r13, %rsi
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	testb	%al, %al
	movl	$0, %eax
	cmove	%rax, %rbp
	cmove	%r12, %rbx
.L32:
	popq	%rcx
	.cfi_def_cfa_offset 40
	movq	%rbx, %rax
	movq	%rbp, %rdx
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5256:
	.size	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_, .-_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_
	.section	.text._ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_,"axG",@progbits,_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_,comdat
	.align 2
	.weak	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_
	.type	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_, @function
_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_:
.LFB5158:
	.cfi_startproc
	endbr64
	leaq	8(%rdi), %rax
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%r9
	.cfi_def_cfa_offset 48
	cmpq	%rax, %rsi
	jne	.L39
	cmpq	$0, 40(%rdi)
	je	.L40
	movq	32(%rdi), %rbx
	movq	%rdx, %rsi
	leaq	32(%rbx), %rdi
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	testb	%al, %al
	je	.L40
	jmp	.L58
.L39:
	leaq	32(%rsi), %rbp
	movq	%rsi, %rbx
	movq	%rdx, %rdi
	movq	%rbp, %rsi
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	testb	%al, %al
	je	.L42
	movq	24(%r13), %rax
	cmpq	%rbx, %rax
	je	.L59
	movq	%rbx, %rdi
	call	_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base@PLT
	movq	%r12, %rsi
	leaq	32(%rax), %rdi
	movq	%rax, %rbp
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	testb	%al, %al
	jne	.L60
.L40:
	popq	%r8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	movq	%r12, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	movq	%r13, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_
.L60:
	.cfi_restore_state
	cmpq	$0, 24(%rbp)
	movq	%rbx, %rax
	jne	.L59
	xorl	%eax, %eax
	movq	%rbp, %rdx
	jmp	.L41
.L42:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	testb	%al, %al
	je	.L45
	movq	32(%r13), %rdx
	xorl	%eax, %eax
	cmpq	%rbx, %rdx
	je	.L41
	movq	%rbx, %rdi
	call	_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base@PLT
	movq	%r12, %rdi
	leaq	32(%rax), %rsi
	movq	%rax, %rbp
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	testb	%al, %al
	je	.L40
	cmpq	$0, 24(%rbx)
	movq	%rbp, %rax
	jne	.L59
.L58:
	xorl	%eax, %eax
	movq	%rbx, %rdx
	jmp	.L41
.L59:
	movq	%rax, %rdx
	jmp	.L41
.L45:
	movq	%rbx, %rax
	xorl	%edx, %edx
.L41:
	popq	%rcx
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5158:
	.size	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_, .-_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_
	.section	.text._ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_,"axG",@progbits,_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_,comdat
	.align 2
	.weak	_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_
	.type	_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_, @function
_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_:
.LFB4838:
	.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
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	8(%rdi), %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	%r12, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 64
	movq	16(%rdi), %r13
.L62:
	testq	%r13, %r13
	je	.L76
	leaq	32(%r13), %rdi
	movq	%r14, %rsi
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	movq	24(%r13), %rdx
	testb	%al, %al
	cmove	16(%r13), %rdx
	cmove	%r13, %rbx
	movq	%rdx, %r13
	jmp	.L62
.L76:
	cmpq	%rbx, %r12
	je	.L65
	leaq	32(%rbx), %rsi
	movq	%r14, %rdi
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
	testb	%al, %al
	je	.L66
.L65:
	movl	$72, %edi
	movq	%rbx, %r15
	call	_Znwm@PLT
	movq	%r14, %rsi
	leaq	32(%rax), %r13
	movq	%rax, %rbx
	movq	%r13, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EOS4_@PLT
	movq	%r15, %rsi
	movq	%r13, %rdx
	movq	%rbp, %rdi
	movl	$0x00000000, 64(%rbx)
	call	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_
	movq	%rax, %r15
	movq	%rdx, %r14
	testq	%rdx, %rdx
	je	.L67
	testq	%rax, %rax
	setne	%al
	cmpq	%rdx, %r12
	sete	%dl
	orb	%dl, %al
	jne	.L68
	leaq	32(%r14), %rsi
	movq	%r13, %rdi
	call	_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_
.L68:
	movzbl	%al, %edi
	movq	%r12, %rcx
	movq	%r14, %rdx
	movq	%rbx, %rsi
	call	_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_@PLT
	incq	40(%rbp)
	jmp	.L66
.L67:
	movq	%r13, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%rbx, %rdi
	movl	$72, %esi
	movq	%r15, %rbx
	call	_ZdlPvm@PLT
.L66:
	popq	%rdx
	.cfi_def_cfa_offset 56
	leaq	64(%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
.LFE4838:
	.size	_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_, .-_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_
	.section	.rodata.str1.1
.LC4:
	.string	"variance"
.LC5:
	.string	"deviation"
.LC6:
	.string	"mean"
.LC7:
	.string	"min"
.LC8:
	.string	"max"
	.text
	.globl	_Z11calcResultsB5cxx11RSt6vectorIfSaIfEE
	.type	_Z11calcResultsB5cxx11RSt6vectorIfSaIfEE, @function
_Z11calcResultsB5cxx11RSt6vectorIfSaIfEE:
.LFB4463:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4463
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	xorps	%xmm2, %xmm2
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movaps	%xmm2, %xmm1
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movss	.LC1(%rip), %xmm5
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	xorl	%eax, %eax
	movq	%rdx, 16(%rdi)
	movq	(%rsi), %rdx
	movl	$0x00000000, 8(%rsp)
	movl	%eax, 8(%rdi)
	leaq	8(%rdi), %rax
	movq	%rcx, 40(%rdi)
	movq	8(%rsi), %rcx
	movq	%rax, 24(%rdi)
	movq	%rax, 32(%rdi)
	movq	%rdx, %rax
	movss	%xmm5, 4(%rsp)
.L78:
	cmpq	%rcx, %rax
	je	.L102
	movss	(%rax), %xmm0
	addq	$4, %rax
	movaps	%xmm0, %xmm3
	movaps	%xmm0, %xmm4
	addss	%xmm0, %xmm2
	mulss	%xmm0, %xmm3
	minss	4(%rsp), %xmm4
	maxss	8(%rsp), %xmm0
	movss	%xmm4, 4(%rsp)
	movss	%xmm0, 8(%rsp)
	addss	%xmm3, %xmm1
	jmp	.L78
.L102:
	subq	%rdx, %rax
	sarq	$2, %rax
	js	.L82
	cvtsi2ssq	%rax, %xmm0
	jmp	.L83
.L82:
	movq	%rax, %rdx
	andl	$1, %eax
	shrq	%rdx
	orq	%rax, %rdx
	cvtsi2ssq	%rdx, %xmm0
	addss	%xmm0, %xmm0
.L83:
	divss	%xmm0, %xmm2
	leaq	23(%rsp), %r13
	leaq	24(%rsp), %r12
	divss	%xmm0, %xmm1
	movaps	%xmm2, %xmm0
	movss	%xmm2, 12(%rsp)
	mulss	%xmm2, %xmm0
	subss	%xmm0, %xmm1
	movaps	%xmm1, %xmm0
	movd	%xmm1, %ebx
	call	sqrtf@PLT
	movq	%r13, %rdx
	leaq	.LC4(%rip), %rsi
	movq	%r12, %rdi
	movd	%xmm0, %r14d
.LEHB2:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE2:
	movq	%r12, %rsi
	movq	%rbp, %rdi
.LEHB3:
	call	_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_
.LEHE3:
	movl	%ebx, (%rax)
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%r13, %rdx
	leaq	.LC5(%rip), %rsi
	movq	%r12, %rdi
.LEHB4:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE4:
	movq	%r12, %rsi
	movq	%rbp, %rdi
.LEHB5:
	call	_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_
.LEHE5:
	movl	%r14d, (%rax)
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%r13, %rdx
	leaq	.LC6(%rip), %rsi
	movq	%r12, %rdi
.LEHB6:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE6:
	movq	%r12, %rsi
	movq	%rbp, %rdi
.LEHB7:
	call	_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_
.LEHE7:
	movss	12(%rsp), %xmm7
	movq	%r12, %rdi
	movss	%xmm7, (%rax)
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%r13, %rdx
	leaq	.LC7(%rip), %rsi
	movq	%r12, %rdi
.LEHB8:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE8:
	movq	%r12, %rsi
	movq	%rbp, %rdi
.LEHB9:
	call	_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_
.LEHE9:
	movss	4(%rsp), %xmm4
	movq	%r12, %rdi
	movss	%xmm4, (%rax)
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%r13, %rdx
	leaq	.LC8(%rip), %rsi
	movq	%r12, %rdi
.LEHB10:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE10:
	movq	%r12, %rsi
	movq	%rbp, %rdi
.LEHB11:
	call	_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEfSt4lessIS5_ESaISt4pairIKS5_fEEEixEOS5_
.LEHE11:
	movss	8(%rsp), %xmm5
	movq	%r12, %rdi
	movss	%xmm5, (%rax)
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L91
	jmp	.L99
.L93:
	endbr64
	jmp	.L101
.L95:
	endbr64
	jmp	.L101
.L96:
	endbr64
	jmp	.L101
.L97:
	endbr64
	jmp	.L101
.L98:
	endbr64
.L101:
	movq	%rax, %rbx
.L89:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L85
.L94:
	endbr64
	movq	%rax, %rbx
.L85:
	movq	16(%rbp), %rdi
	call	_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_fESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E.isra.0
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L99
	movq	%rbx, %rdi
.LEHB12:
	call	_Unwind_Resume@PLT
.LEHE12:
.L99:
	call	__stack_chk_fail@PLT
.L91:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	movq	%rbp, %rax
	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
.LFE4463:
	.section	.gcc_except_table
.LLSDA4463:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4463-.LLSDACSB4463
.LLSDACSB4463:
	.uleb128 .LEHB2-.LFB4463
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L94-.LFB4463
	.uleb128 0
	.uleb128 .LEHB3-.LFB4463
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L93-.LFB4463
	.uleb128 0
	.uleb128 .LEHB4-.LFB4463
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L94-.LFB4463
	.uleb128 0
	.uleb128 .LEHB5-.LFB4463
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L95-.LFB4463
	.uleb128 0
	.uleb128 .LEHB6-.LFB4463
	.uleb128 .LEHE6-.LEHB6
	.uleb128 .L94-.LFB4463
	.uleb128 0
	.uleb128 .LEHB7-.LFB4463
	.uleb128 .LEHE7-.LEHB7
	.uleb128 .L96-.LFB4463
	.uleb128 0
	.uleb128 .LEHB8-.LFB4463
	.uleb128 .LEHE8-.LEHB8
	.uleb128 .L94-.LFB4463
	.uleb128 0
	.uleb128 .LEHB9-.LFB4463
	.uleb128 .LEHE9-.LEHB9
	.uleb128 .L97-.LFB4463
	.uleb128 0
	.uleb128 .LEHB10-.LFB4463
	.uleb128 .LEHE10-.LEHB10
	.uleb128 .L94-.LFB4463
	.uleb128 0
	.uleb128 .LEHB11-.LFB4463
	.uleb128 .LEHE11-.LEHB11
	.uleb128 .L98-.LFB4463
	.uleb128 0
	.uleb128 .LEHB12-.LFB4463
	.uleb128 .LEHE12-.LEHB12
	.uleb128 0
	.uleb128 0
.LLSDACSE4463:
	.text
	.size	_Z11calcResultsB5cxx11RSt6vectorIfSaIfEE, .-_Z11calcResultsB5cxx11RSt6vectorIfSaIfEE
	.section	.text._ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_,"axG",@progbits,_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_,comdat
	.weak	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_
	.type	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_, @function
_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_:
.LFB5290:
	.cfi_startproc
	endbr64
	movq	%rdi, %rdx
	testq	%rsi, %rsi
	je	.L104
	movb	$0, (%rdi)
	leaq	1(%rdi), %r8
	cmpq	$1, %rsi
	je	.L105
	leaq	-1(%rsi), %rcx
	xorl	%eax, %eax
	movq	%r8, %rdi
	addq	%rsi, %rdx
	rep stosb
	jmp	.L104
.L105:
	movq	%r8, %rdx
.L104:
	movq	%rdx, %rax
	ret
	.cfi_endproc
.LFE5290:
	.size	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_, .-_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_
	.section	.rodata._ZNSt6vectorIcSaIcEE17_M_default_appendEm.str1.1,"aMS",@progbits,1
.LC9:
	.string	"vector::_M_default_append"
	.section	.text._ZNSt6vectorIcSaIcEE17_M_default_appendEm,"axG",@progbits,_ZNSt6vectorIcSaIcEE17_M_default_appendEm,comdat
	.align 2
	.weak	_ZNSt6vectorIcSaIcEE17_M_default_appendEm
	.type	_ZNSt6vectorIcSaIcEE17_M_default_appendEm, @function
_ZNSt6vectorIcSaIcEE17_M_default_appendEm:
.LFB4991:
	.cfi_startproc
	endbr64
	testq	%rsi, %rsi
	je	.L123
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 64
	movq	8(%rdi), %rdi
	movq	16(%r14), %rax
	movq	(%r14), %r15
	subq	%rdi, %rax
	cmpq	%rsi, %rax
	jb	.L111
	call	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_
	movq	%rax, 8(%r14)
	jmp	.L109
.L111:
	movabsq	$9223372036854775807, %rax
	subq	%r15, %rdi
	subq	%rdi, %rax
	movq	%rdi, %rbp
	cmpq	%rsi, %rax
	jnb	.L112
	leaq	.LC9(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L112:
	movabsq	$9223372036854775807, %rax
	cmpq	%rdi, %rsi
	movq	%rdi, %r13
	cmovnb	%rsi, %r13
	addq	%rdi, %r13
	cmpq	%rax, %r13
	cmova	%rax, %r13
	movq	%r13, %rdi
	call	_Znwm@PLT
	movq	%rbx, %rsi
	leaq	(%rax,%rbp), %rdi
	movq	%rax, %r12
	call	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPcmEET_S3_T0_
	testq	%rbp, %rbp
	je	.L113
	movq	%rbp, %rdx
	movq	%r15, %rsi
	movq	%r12, %rdi
	call	memmove@PLT
	jmp	.L114
.L113:
	testq	%r15, %r15
	je	.L115
.L114:
	movq	16(%r14), %rsi
	movq	%r15, %rdi
	subq	%r15, %rsi
	call	_ZdlPvm@PLT
.L115:
	addq	%rbp, %rbx
	movq	%r12, (%r14)
	addq	%r12, %rbx
	addq	%r13, %r12
	movq	%rbx, 8(%r14)
	movq	%r12, 16(%r14)
.L109:
	popq	%rax
	.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
.L123:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE4991:
	.size	_ZNSt6vectorIcSaIcEE17_M_default_appendEm, .-_ZNSt6vectorIcSaIcEE17_M_default_appendEm
	.section	.text._ZNSt6vectorIcSaIcEE6resizeEm,"axG",@progbits,_ZNSt6vectorIcSaIcEE6resizeEm,comdat
	.align 2
	.weak	_ZNSt6vectorIcSaIcEE6resizeEm
	.type	_ZNSt6vectorIcSaIcEE6resizeEm, @function
_ZNSt6vectorIcSaIcEE6resizeEm:
.LFB4815:
	.cfi_startproc
	endbr64
	movq	8(%rdi), %rcx
	movq	(%rdi), %rax
	movq	%rcx, %rdx
	subq	%rax, %rdx
	cmpq	%rsi, %rdx
	jnb	.L127
	subq	%rdx, %rsi
	jmp	_ZNSt6vectorIcSaIcEE17_M_default_appendEm
.L127:
	cmpq	%rdx, %rsi
	jnb	.L126
	addq	%rsi, %rax
	cmpq	%rcx, %rax
	je	.L126
	movq	%rax, 8(%rdi)
.L126:
	ret
	.cfi_endproc
.LFE4815:
	.size	_ZNSt6vectorIcSaIcEE6resizeEm, .-_ZNSt6vectorIcSaIcEE6resizeEm
	.text
	.globl	_Z14mergeSolutionsRKSt6vectorIS_IcSaIcEESaIS1_EERS1_
	.type	_Z14mergeSolutionsRKSt6vectorIS_IcSaIcEESaIS1_EERS1_, @function
_Z14mergeSolutionsRKSt6vectorIS_IcSaIcEESaIS1_EERS1_:
.LFB4462:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movabsq	$-6148914691236517205, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	8(%rdi), %r13
	subq	(%rdi), %r13
	movq	%r12, %rdi
	sarq	$3, %r13
	imulq	%r14, %r13
	leal	1(%r13), %ebx
	movslq	%ebx, %rbx
	salq	$2, %rbx
	movq	%rbx, %rsi
	call	_ZNSt6vectorIcSaIcEE6resizeEm
	movq	(%r12), %rdi
	xorl	%esi, %esi
	xorl	%edx, %edx
	movl	%r13d, (%rdi)
.L130:
	movq	0(%rbp), %rcx
	movq	8(%rbp), %rax
	subq	%rcx, %rax
	sarq	$3, %rax
	imulq	%r14, %rax
	cmpq	%rax, %rsi
	jnb	.L135
	imulq	$24, %rsi, %rax
	incq	%rsi
	addq	%rax, %rcx
	movq	8(%rcx), %rax
	subq	(%rcx), %rax
	movl	%eax, 4(%rdi)
	addl	%eax, %edx
	jmp	.L130
.L135:
	movq	8(%r12), %rsi
	movslq	%edx, %rdx
	subq	(%r12), %rsi
	movq	%r12, %rdi
	addq	%rdx, %rsi
	call	_ZNSt6vectorIcSaIcEE6resizeEm
	addq	(%r12), %rbx
	xorl	%r8d, %r8d
	movabsq	$-6148914691236517205, %r9
.L132:
	movq	0(%rbp), %rdx
	movq	8(%rbp), %rax
	subq	%rdx, %rax
	sarq	$3, %rax
	imulq	%r9, %rax
	cmpq	%rax, %r8
	jnb	.L136
	imulq	$24, %r8, %r10
	movq	%rbx, %rdi
	incq	%r8
	leaq	(%rdx,%r10), %rax
	movq	(%rax), %rsi
	movq	8(%rax), %rcx
	subq	%rsi, %rcx
	rep movsb
	addq	0(%rbp), %r10
	addq	8(%r10), %rbx
	subq	(%r10), %rbx
	jmp	.L132
.L136:
	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
.LFE4462:
	.size	_Z14mergeSolutionsRKSt6vectorIS_IcSaIcEESaIS1_EERS1_, .-_Z14mergeSolutionsRKSt6vectorIS_IcSaIcEESaIS1_EERS1_
	.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	h_hit_Zs
	.bss
	.align 8
	.type	h_hit_Zs, @object
	.size	h_hit_Zs, 8
h_hit_Zs:
	.zero	8
	.globl	h_hit_Ys
	.align 8
	.type	h_hit_Ys, @object
	.size	h_hit_Ys, 8
h_hit_Ys:
	.zero	8
	.globl	h_hit_Xs
	.align 8
	.type	h_hit_Xs, @object
	.size	h_hit_Xs, 8
h_hit_Xs:
	.zero	8
	.globl	h_hit_IDs
	.align 8
	.type	h_hit_IDs, @object
	.size	h_hit_IDs, 8
h_hit_IDs:
	.zero	8
	.globl	h_sensor_hitNums
	.align 8
	.type	h_sensor_hitNums, @object
	.size	h_sensor_hitNums, 8
h_sensor_hitNums:
	.zero	8
	.globl	h_sensor_hitStarts
	.align 8
	.type	h_sensor_hitStarts, @object
	.size	h_sensor_hitStarts, 8
h_sensor_hitStarts:
	.zero	8
	.globl	h_sensor_Zs
	.align 8
	.type	h_sensor_Zs, @object
	.size	h_sensor_Zs, 8
h_sensor_Zs:
	.zero	8
	.globl	h_no_hits
	.align 8
	.type	h_no_hits, @object
	.size	h_no_hits, 8
h_no_hits:
	.zero	8
	.globl	h_no_sensors
	.align 8
	.type	h_no_sensors, @object
	.size	h_no_sensors, 8
h_no_sensors:
	.zero	8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	2139095040
	.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:

#ifndef TOOLS
#define TOOLS 1

#include "hip/hip_runtime.h"

#include <cstring>
#include <iostream>
#include <vector>
#include <sstream>
#include <map>
#include <cmath>
#include <stdint.h>

#define cudaCheck(stmt) {                                    \
    hipError_t err = stmt;                                  \
    if (err != hipSuccess){                                 \
        std::cerr << "Failed to run " << #stmt << std::endl; \
        std::cerr << hipGetErrorString(err) << std::endl;   \
        return err;                                          \
    }                                                        \
}

template <class T>
std::string toString(T t) {
    std::stringstream ss;
    std::string s;
    ss << t;
    ss >> s;
    return s;
}

void setHPointersFromInput(const uint8_t * input, size_t size);
void mergeSolutions(const std::vector<std::vector<char> >& solutions, std::vector<char>& output);

std::map<std::string, float> calcResults(std::vector<float>& times);
float float_max();

#endif

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

                                        # End of file scope inline assembly
	.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 __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
