// File: /workspace/github_cpp_makefile_star2_O1/istellartech[P]OpenTsiolkovsky/src/air.cpp
// Function: Air::coef_density_variance(double, double)
double Air::coef_density_variance(double altitude, double input_percent){
    // altitude : [m]
    // percent : [%](-100 ~ 100), enter 0 when nominal air density
    // @output coefficient of density variance : [-1.0 ~ 1.0]
    // cf. U.S. standard atmosphere PART2 Atmospheric Model 2.1.4 Density Variations
    if (input_percent == 0){
        return 0;
    }
    //vector<double> minus_x = {-12.8, -7.9, -1.3, -14.3, -15.9, -18.6, -32.1, -38.6, -50.0, -55.3, -65.0, -68.1, -76.7, -42.2};
    vector<double> minus_x = {21.6, 7.4, -1.3, -14.3, -15.9, -18.6, -32.1, -38.6, -50.0, -55.3, -65.0, -68.1, -76.7, -42.2};
    vector<double> minus_y = {1010, 4300, 8030, 10220, 16360, 20300, 26220, 29950, 40250, 50110, 59970, 70270, 80140, 90220};
    //vector<double> plus_x = {21.6, 7.4, 1.5, 5.3, 26.7, 20.2, 14.3, 18.2, 33.6, 47.4, 59.5, 72.2, 58.7, 41.4};
    vector<double> plus_x = {-12.8, -7.9, 1.5, 5.3, 26.7, 20.2, 14.3, 18.2, 33.6, 47.4, 59.5, 72.2, 58.7, 41.4};
    vector<double> plus_y = {1230, 4300, 8030, 10000, 16360, 20300, 26220, 29950, 40250, 50110, 59970, 70270, 80360, 90880};
    double percent_of_density_with_alt;
    if (input_percent < 0){
        percent_of_density_with_alt = linear_interp1_from_y(altitude, minus_x, minus_y);
    } else {
        percent_of_density_with_alt = linear_interp1_from_y(altitude, plus_x, plus_y);
    }
    return percent_of_density_with_alt / 100 * abs(input_percent) / 100;
}

// Assembly:
pushq %rbx
subq $0x150, %rsp            # imm = 0x150
movapd %xmm0, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x5f6e
jnp 0x61da
movsd %xmm2, (%rsp)
movapd %xmm1, 0x10(%rsp)
leaq 0x210c0(%rip), %rsi     # 0x27040
leaq 0xe0(%rsp), %rax
movl $0xe, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rcx
movl $0xe, %edx
movq %rax, %rsi
callq 0x6996
leaq 0x210fc(%rip), %rsi     # 0x270b0
leaq 0xe0(%rsp), %rax
movl $0xe, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rcx
movl $0xe, %edx
movq %rax, %rsi
callq 0x6996
leaq 0x2113b(%rip), %rsi     # 0x27120
leaq 0xe0(%rsp), %rax
movl $0xe, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rcx
movl $0xe, %edx
movq %rax, %rsi
callq 0x6996
leaq 0x2117a(%rip), %rsi     # 0x27190
leaq 0xe0(%rsp), %rax
movl $0xe, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0xe, %edx
movq %rax, %rsi
callq 0x6996
xorpd %xmm0, %xmm0
ucomisd 0x10(%rsp), %xmm0
jbe 0x60c4
leaq 0x80(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x69dc
leaq 0xc8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x69dc
leaq 0x80(%rsp), %rdi
leaq 0xc8(%rsp), %rbx
movsd (%rsp), %xmm0
movq %rbx, %rsi
callq 0x6519
movsd %xmm0, (%rsp)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x60ad
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x6136
leaq 0x90(%rsp), %rax
jmp 0x612b
leaq 0x68(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x69dc
leaq 0xb0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x69dc
leaq 0x68(%rsp), %rdi
leaq 0xb0(%rsp), %rbx
movsd (%rsp), %xmm0
movq %rbx, %rsi
callq 0x6519
movsd %xmm0, (%rsp)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x611c
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x6136
leaq 0x78(%rsp), %rax
movq (%rax), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x614d
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x6164
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movsd (%rsp), %xmm0
divsd 0x20ea7(%rip), %xmm0    # 0x27018
movsd %xmm0, (%rsp)
movaps 0x10(%rsp), %xmm0
andps 0x20eae(%rip), %xmm0    # 0x27030
movaps %xmm0, 0x10(%rsp)
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x619e
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movapd 0x10(%rsp), %xmm0
mulsd (%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x61cc
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movapd 0x10(%rsp), %xmm0
divsd 0x20e3e(%rip), %xmm0    # 0x27018
addq $0x150, %rsp            # imm = 0x150
popq %rbx
retq
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x621c
movq 0x78(%rsp), %rsi
jmp 0x620f
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x621c
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x621c
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x6238
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x6238
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x6254
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x6254
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6270
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x6270
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x628d
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq %rbx, %rdi
callq 0x5650
nop