// File: /workspace/github_cpp_makefile_star2_O3/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 0x8ce0
movl %ecx, %r13d
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x2, %eax
jne 0x8a9d
movq $0x0, (%r8)
movslq %edx, %rax
movslq %r13d, %rdx
movq (%r15), %rcx
movq (%r14), %rsi
movslq (%rcx,%rax,4), %rax
movslq -0x4(%rcx,%rdx,4), %rcx
vmovsd (%rsi,%rcx,8), %xmm0
vmovsd (%rsi,%rax,8), %xmm2
subq %rax, %rcx
vcvtsi2sd %rcx, %xmm1, %xmm1
vsubsd %xmm2, %xmm0, %xmm0
vdivsd %xmm0, %xmm1, %xmm0
vcvtsi2sd %eax, %xmm3, %xmm1
vfnmadd231sd %xmm2, %xmm0, %xmm1 # xmm1 = -(xmm0 * xmm2) + xmm1
jmp 0x8cce
leal (%r13,%rdx), %eax
movq %r8, 0x28(%rsp)
leaq 0x10(%rsp), %r8
xorl %ebx, %ebx
movq %rdx, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movl %eax, %r12d
shrl $0x1f, %r12d
movq %rbx, (%r8)
addl %eax, %r12d
sarl %r12d
movl %r12d, %ecx
callq 0x8a2d
leaq 0x8(%rsp), %r8
vmovapd %xmm0, 0x90(%rsp)
vmovapd %xmm1, 0xa0(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r13d, %ecx
movq %rbx, (%r8)
callq 0x8a2d
movslq %r12d, %rbp
vmovapd %xmm0, 0x80(%rsp)
vmovapd %xmm1, 0x70(%rsp)
cmpl %r13d, %r12d
jge 0x8bc1
movslq %r13d, %r13
movq %rbp, %rbx
movq (%r15), %rax
movq (%r14), %rcx
vmovapd 0xa0(%rsp), %xmm1
movq 0x8(%r14), %rdx
movslq (%rax,%rbx,4), %rax
subq %rcx, %rdx
shrq $0x3, %rdx
decl %edx
vmovsd (%rcx,%rax,8), %xmm0
vfmadd132sd 0x90(%rsp), %xmm1, %xmm0 # xmm0 = (xmm0 * mem) + xmm1
vmovsd %xmm0, 0x68(%rsp)
vcvtsi2sd %eax, %xmm2, %xmm0
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)
fstpl 0x60(%rsp)
vroundsd $0x9, 0x60(%rsp), %xmm2, %xmm1
vsubsd %xmm1, %xmm0, %xmm0
vandpd 0x14e2(%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
incq %rbx
vmovsd %xmm0, 0x10(%rsp)
cmpq %rbx, %r13
jne 0x8b1d
movq 0x20(%rsp), %rax
cmpl %eax, %r12d
jle 0x8c75
movslq %eax, %r12
movq (%r15), %rax
movq (%r14), %rcx
vmovapd 0x70(%rsp), %xmm1
movq 0x8(%r14), %rdx
movslq (%rax,%r12,4), %rax
subq %rcx, %rdx
shrq $0x3, %rdx
decl %edx
vmovsd (%rcx,%rax,8), %xmm0
vfmadd132sd 0x80(%rsp), %xmm1, %xmm0 # xmm0 = (xmm0 * mem) + xmm1
vmovsd %xmm0, 0x48(%rsp)
vcvtsi2sd %eax, %xmm2, %xmm0
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)
fstpl 0x40(%rsp)
vroundsd $0x9, 0x40(%rsp), %xmm2, %xmm1
vsubsd %xmm1, %xmm0, %xmm0
vandpd 0x1430(%rip){1to2}, %xmm0, %xmm0 # 0xa070
vmovlpd %xmm0, 0x38(%rsp)
fld1
faddl 0x38(%rsp)
fstpl 0x30(%rsp)
vmovsd 0x30(%rsp), %xmm0
callq 0x2370
vaddsd 0x8(%rsp), %xmm0, %xmm0
incq %r12
vmovsd %xmm0, 0x8(%rsp)
cmpq %r12, %rbp
jne 0x8bd2
jmp 0x8c7b
vmovsd 0x8(%rsp), %xmm0
vmovsd 0x10(%rsp), %xmm1
vmovapd 0x80(%rsp), %xmm2
vmovapd 0x70(%rsp), %xmm3
vucomisd %xmm1, %xmm0
vminsd %xmm0, %xmm1, %xmm0
vmovapd 0x90(%rsp), %xmm1
seta %al
kmovd %eax, %k1
movq 0x28(%rsp), %rax
vmovsd %xmm1, %xmm2, %xmm2 {%k1}
vmovapd 0xa0(%rsp), %xmm1
vmovsd %xmm0, (%rax)
vmovsd %xmm1, %xmm3, %xmm3 {%k1}
vmovapd %xmm2, %xmm0
vmovapd %xmm3, %xmm1
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16b6(%rip), %rdi      # 0xa39d
leaq 0x16bc(%rip), %rsi      # 0xa3aa
leaq 0x16cc(%rip), %rcx      # 0xa3c1
movl $0x2e, %edx
callq 0x2130
nop