// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movl %ecx, %eax
subl %edx, %eax
cmpl $0x1, %eax
jle 0x7c7c
movl %ecx, %r13d
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x2, %eax
jne 0x7b5c
andq $0x0, (%r8)
movslq %r12d, %rax
movq %r14, %rdi
movq (%r15), %rcx
movslq (%rcx,%rax,4), %rsi
movslq %r13d, %rax
movslq -0x4(%rcx,%rax,4), %rdx
callq 0x7e61
jmp 0x7c6d
movq %r8, 0x18(%rsp)
leaq 0x10(%rsp), %r8
leal (%r13,%r12), %eax
andq $0x0, (%r8)
pushq $0x2
popq %rcx
cltd
movq %r14, %rdi
movq %r15, %rsi
idivl %ecx
movl %r12d, %edx
movl %eax, %ecx
movl %eax, %ebp
callq 0x7b0d
leaq 0x8(%rsp), %r8
vmovapd %xmm0, 0x20(%rsp)
vmovapd %xmm1, 0x30(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movl %r13d, %ecx
andq $0x0, (%r8)
callq 0x7b0d
movslq %ebp, %rbx
movslq %r13d, %r13
vmovapd %xmm0, 0x40(%rsp)
vmovapd %xmm1, 0x50(%rsp)
movq %rbx, %rbp
cmpq %r13, %rbp
jge 0x7bf7
movq (%r15), %rax
vmovapd 0x20(%rsp), %xmm0
vmovaps 0x30(%rsp), %xmm1
movq %r14, %rdi
movl (%rax,%rbp,4), %esi
callq 0x7e89
vaddsd 0x10(%rsp), %xmm0, %xmm0
vmovapd 0x50(%rsp), %xmm1
incq %rbp
vmovsd %xmm0, 0x10(%rsp)
jmp 0x7bc1
movslq %r12d, %r12
vmovapd 0x40(%rsp), %xmm0
cmpq %rbx, %r12
jge 0x7c2b
movq (%r15), %rax
movq %r14, %rdi
movl (%rax,%r12,4), %esi
callq 0x7e89
vaddsd 0x8(%rsp), %xmm0, %xmm0
vmovapd 0x50(%rsp), %xmm1
incq %r12
vmovsd %xmm0, 0x8(%rsp)
jmp 0x7bfa
vmovsd 0x10(%rsp), %xmm0
vmovsd 0x8(%rsp), %xmm2
vmovapd 0x20(%rsp), %xmm3
vmovapd 0x30(%rsp), %xmm4
vucomisd %xmm0, %xmm2
vminsd %xmm2, %xmm0, %xmm2
vmovapd 0x40(%rsp), %xmm0
seta %al
kmovd %eax, %k1
movq 0x18(%rsp), %rax
vmovsd %xmm3, %xmm0, %xmm0 {%k1}
vmovsd %xmm4, %xmm1, %xmm1 {%k1}
vmovsd %xmm2, (%rax)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16a6(%rip), %rdi      # 0x9329
leaq 0x16ac(%rip), %rsi      # 0x9336
leaq 0x16bc(%rip), %rcx      # 0x934d
pushq $0x2e
popq %rdx
callq 0x2110
nop