// File: istellartech[P]OpenTsiolkovsky/src/air.cpp
// Function: linear_interp1_from_y(double, std::vector<double, std::allocator<double>>, std::vector<double, std::allocator<double>>)
double linear_interp1_from_y(double y, vector<double> x_array, vector<double> y_array){
    // linear interpolattion with same number of x_array and y_array from y-axis
    // not extrapolation, It has the same value as the outermost point.
    // @params y: y component of the data you want to obtain
    // @params x_array The x component of the original data
    // @params y_array The x component of the original data
    // @return x(double) interpolated value
    double x = 0.0;
    double alpha = 0.0;
    for (int i = 0; i < y_array.size()-1; i++) {
        if (y >= y_array[i] && y < y_array[i+1]) {
            alpha = (y - y_array[i]) / (y_array[i+1] - y_array[i]);
            x = x_array[i] + alpha * (x_array[i+1] - x_array[i]);
        }
    }
    if (y < y_array[0]) {
        x = x_array[0];
    }else if (y >= y_array.back()){
        x = x_array.back();
    }
    return x;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x40(%rbp)
movq %rsi, -0x38(%rbp)
movsd %xmm0, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rdi
movslq -0x2c(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x8620
movq %rax, %rcx
movq -0x48(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x7cd3
movq -0x38(%rbp), %rdi
movsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movslq -0x2c(%rbp), %rsi
callq 0x8600
movsd -0x50(%rbp), %xmm0
ucomisd (%rax), %xmm0
jb 0x7cc3
movq -0x38(%rbp), %rdi
movsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x8600
movsd -0x58(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7cc3
movq -0x38(%rbp), %rdi
movsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movslq -0x2c(%rbp), %rsi
callq 0x8600
movsd -0x88(%rbp), %xmm0
movq -0x38(%rbp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x8600
movq -0x38(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movslq -0x2c(%rbp), %rsi
callq 0x8600
movsd -0x80(%rbp), %xmm1
movsd -0x78(%rbp), %xmm0
movq -0x40(%rbp), %rdi
subsd (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movslq -0x2c(%rbp), %rsi
callq 0x8600
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x8600
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movslq -0x2c(%rbp), %rsi
callq 0x8600
movsd -0x70(%rbp), %xmm2
movsd -0x68(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
subsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x7cc5
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7b77
movq -0x38(%rbp), %rdi
movsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x8600
movsd -0x90(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7d17
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8600
movsd (%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x7d4f
movq -0x38(%rbp), %rdi
movsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
callq 0x8640
movsd -0x98(%rbp), %xmm0
ucomisd (%rax), %xmm0
jb 0x7d4d
movq -0x40(%rbp), %rdi
callq 0x8640
movsd (%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x7d4f
movsd -0x20(%rbp), %xmm0
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)