// File: /workspace/github_cpp_makefile_star2_O3/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 0x5f02
jnp 0x616e
movsd %xmm2, (%rsp)
movapd %xmm1, 0x10(%rsp)
leaq 0x1f16c(%rip), %rsi     # 0x25080
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 0x68e8
leaq 0x1f1a8(%rip), %rsi     # 0x250f0
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 0x68e8
leaq 0x1f1e7(%rip), %rsi     # 0x25160
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 0x68e8
leaq 0x1f226(%rip), %rsi     # 0x251d0
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 0x68e8
xorpd %xmm0, %xmm0
ucomisd 0x10(%rsp), %xmm0
jbe 0x6058
leaq 0x80(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x692e
leaq 0xc8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x692e
leaq 0x80(%rsp), %rdi
leaq 0xc8(%rsp), %rbx
movsd (%rsp), %xmm0
movq %rbx, %rsi
callq 0x64ad
movsd %xmm0, (%rsp)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x6041
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x60ca
leaq 0x90(%rsp), %rax
jmp 0x60bf
leaq 0x68(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x692e
leaq 0xb0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x692e
leaq 0x68(%rsp), %rdi
leaq 0xb0(%rsp), %rbx
movsd (%rsp), %xmm0
movq %rbx, %rsi
callq 0x64ad
movsd %xmm0, (%rsp)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x60b0
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x60ca
leaq 0x78(%rsp), %rax
movq (%rax), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x60e1
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x60f8
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movsd (%rsp), %xmm0
divsd 0x1ef73(%rip), %xmm0    # 0x25078
movsd %xmm0, (%rsp)
movaps 0x10(%rsp), %xmm0
andps 0x1ef1a(%rip), %xmm0    # 0x25030
movaps %xmm0, 0x10(%rsp)
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6132
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 0x6160
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movapd 0x10(%rsp), %xmm0
divsd 0x1ef0a(%rip), %xmm0    # 0x25078
addq $0x150, %rsp            # imm = 0x150
popq %rbx
retq
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x61b0
movq 0x78(%rsp), %rsi
jmp 0x61a3
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x61b0
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x61b0
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x61cc
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x61cc
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x61e8
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x61e8
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6204
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x6204
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x6221
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq %rbx, %rdi
callq 0x5650
nop