// File: /workspace/github_cpp_makefile_star2_O1/umatin[P]LogarithmicErrorRegression/./src/log_regression.h
// Function: linear_regression create_regression_tournament_selection_recursive<(ERROR_TYPE)1, true, true>(std::vector<double, std::allocator<double>>&, std::vector<int, std::allocator<int>>&, int, int, double&)
linear_regression create_regression_tournament_selection_recursive(std::vector<double>& data, std::vector<int>& tournament, int fr, int to, double & error){
    assert(to - fr >= 2);

    if (to - fr == 2){
        error = 0;
        return fit_line(data, tournament[fr], tournament[to-1]);;
    }
    double errorl = 0;
    linear_regression lr_l = create_regression_tournament_selection_recursive<E,ROUND,BOUNDED>(data, tournament, fr, (fr+to)/2, errorl);

    double errorr = 0;
    linear_regression lr_r = create_regression_tournament_selection_recursive<E,ROUND,BOUNDED>(data, tournament, (fr+to)/2, to, errorr);

    for (int i = (fr+to)/2; i < to; i++){
        errorl += calculate_error_single_element<E,ROUND,BOUNDED> (data, lr_l, tournament[i]);
    }
    for (int i = fr; i < (fr+to)/2; i++){
        errorr += calculate_error_single_element<E,ROUND,BOUNDED> (data, lr_r, tournament[i]);
    }
    if (errorl < errorr){
        error = errorl;
        return lr_l;
    }
    else{
        error = errorr;
        return lr_r;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %ecx, %eax
subl %edx, %eax
cmpl $0x1, %eax
jle 0x8d4e
movl %ecx, %r13d
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x2, %eax
jne 0x8b09
movq $0x0, (%r8)
movslq %edx, %rax
movq (%r15), %rcx
movslq (%rcx,%rax,4), %rax
movslq %r13d, %rdx
movslq -0x4(%rcx,%rdx,4), %rcx
movq (%r14), %rdx
vmovsd (%rdx,%rcx,8), %xmm0
subq %rax, %rcx
vcvtsi2sd %rcx, %xmm1, %xmm1
vmovsd (%rdx,%rax,8), %xmm2
vsubsd %xmm2, %xmm0, %xmm0
vdivsd %xmm0, %xmm1, %xmm0
vcvtsi2sd %eax, %xmm3, %xmm1
vfnmadd231sd %xmm2, %xmm0, %xmm1 # xmm1 = -(xmm0 * xmm2) + xmm1
jmp 0x8d3c
movq %r8, 0x28(%rsp)
xorl %ebx, %ebx
leaq 0x10(%rsp), %r8
movq %rbx, (%r8)
leal (%r13,%rdx), %eax
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
movq %r14, %rdi
movq %r15, %rsi
movq %rdx, 0x20(%rsp)
movl %r12d, %ecx
callq 0x8a99
vmovapd %xmm0, 0x90(%rsp)
vmovapd %xmm1, 0xa0(%rsp)
leaq 0x8(%rsp), %r8
movq %rbx, (%r8)
movq %r14, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r13d, %ecx
callq 0x8a99
vmovapd %xmm0, 0x80(%rsp)
vmovapd %xmm1, 0x70(%rsp)
movslq %r12d, %rbp
cmpl %r13d, %r12d
jge 0x8c2d
movslq %r13d, %r13
movq %rbp, %rbx
movq (%r15), %rax
movslq (%rax,%rbx,4), %rax
movq (%r14), %rcx
movq 0x8(%r14), %rdx
vmovsd (%rcx,%rax,8), %xmm0
vmovapd 0xa0(%rsp), %xmm1
vfmadd132sd 0x90(%rsp), %xmm1, %xmm0 # xmm0 = (xmm0 * mem) + xmm1
subq %rcx, %rdx
shrq $0x3, %rdx
decl %edx
vmovsd %xmm0, 0x68(%rsp)
fldl 0x68(%rsp)
movl %edx, 0x1c(%rsp)
fildl 0x1c(%rsp)
fxch %st(1)
fucomi %st(1), %st
fcmovnbe %st(1), %st
fstp %st(1)
fldz
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
vcvtsi2sd %eax, %xmm2, %xmm0
fstpl 0x60(%rsp)
vroundsd $0x9, 0x60(%rsp), %xmm2, %xmm1
vsubsd %xmm1, %xmm0, %xmm0
vandpd 0x1476(%rip){1to2}, %xmm0, %xmm0 # 0xa070
vmovlpd %xmm0, 0x58(%rsp)
fld1
faddl 0x58(%rsp)
fstpl 0x50(%rsp)
vmovsd 0x50(%rsp), %xmm0
callq 0x2370
vaddsd 0x10(%rsp), %xmm0, %xmm0
vmovsd %xmm0, 0x10(%rsp)
incq %rbx
cmpq %rbx, %r13
jne 0x8b89
movq 0x20(%rsp), %rax
cmpl %eax, %r12d
vmovapd 0x80(%rsp), %xmm2
vmovapd 0x70(%rsp), %xmm3
jle 0x8cf2
movslq %eax, %r12
movq (%r15), %rax
movslq (%rax,%r12,4), %rax
movq (%r14), %rcx
movq 0x8(%r14), %rdx
vmovsd (%rcx,%rax,8), %xmm0
vfmadd213sd %xmm3, %xmm2, %xmm0 # xmm0 = (xmm2 * xmm0) + xmm3
subq %rcx, %rdx
shrq $0x3, %rdx
decl %edx
vmovsd %xmm0, 0x48(%rsp)
fldl 0x48(%rsp)
movl %edx, 0x18(%rsp)
fildl 0x18(%rsp)
fxch %st(1)
fucomi %st(1), %st
fcmovnbe %st(1), %st
fstp %st(1)
fldz
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
vcvtsi2sd %eax, %xmm4, %xmm0
fstpl 0x40(%rsp)
vroundsd $0x9, 0x40(%rsp), %xmm4, %xmm1
vsubsd %xmm1, %xmm0, %xmm0
vandpd 0x13c0(%rip){1to2}, %xmm0, %xmm0 # 0xa070
vmovlpd %xmm0, 0x38(%rsp)
fld1
faddl 0x38(%rsp)
fstpl 0x30(%rsp)
vmovsd 0x30(%rsp), %xmm0
callq 0x2370
vmovapd 0x70(%rsp), %xmm3
vmovapd 0x80(%rsp), %xmm2
vaddsd 0x8(%rsp), %xmm0, %xmm0
vmovsd %xmm0, 0x8(%rsp)
incq %r12
cmpq %r12, %rbp
jne 0x8c4d
vmovsd 0x10(%rsp), %xmm0
vmovsd 0x8(%rsp), %xmm1
vucomisd %xmm0, %xmm1
seta %al
vminsd %xmm1, %xmm0, %xmm0
kmovd %eax, %k1
vmovapd 0x90(%rsp), %xmm1
vmovsd %xmm1, %xmm2, %xmm2 {%k1}
vmovapd 0xa0(%rsp), %xmm1
vmovsd %xmm1, %xmm3, %xmm3 {%k1}
movq 0x28(%rsp), %rax
vmovsd %xmm0, (%rax)
vmovapd %xmm2, %xmm0
vmovapd %xmm3, %xmm1
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1688(%rip), %rdi      # 0xa3dd
leaq 0x168e(%rip), %rsi      # 0xa3ea
leaq 0x169e(%rip), %rcx      # 0xa401
movl $0x2e, %edx
callq 0x2130
nop