// File: chfeder[P]turbulence_generator/./TurbGen.h
// Function: TurbGen::init_single_realisation(double, double const*, double, double, double, int, double, double, double, double, int)
int init_single_realisation(
        const double ndim, const double L[3], const double k_min, const double k_mid, const double k_max,
        const int spect_form, const double power_law_exp, const double power_law_exp_2, const double angles_exp,
        const double sol_weight, const int random_seed) {
        // ******************************************************
        // Initialise the turbulence generator for a single turbulent realisation, e.g., for producing
        // turbulent initial conditions, with parameters specified as inputs to the function; see descriptions below.
        // ******************************************************
        if (verbose > 1) TurbGen_printf(FuncSig(__func__)+"entering.\n");
        // set internal parameters
        this->ndim = ndim;
        this->L[X] = L[X]; // Length of box in x; used for wavenumber conversion below
        this->L[Y] = L[Y]; // Length of box in y
        this->L[Z] = L[Z]; // Length of box in z
        this->kmin = (k_min-DBL_EPSILON) * 2*M_PI / L[X]; // Minimum wavenumber <~  k_min * 2pi / Lx
        this->kmax = (k_max+DBL_EPSILON) * 2*M_PI / L[X]; // Maximum wavenumber >~  k_max * 2pi / Lx
        this->kmid = (k_mid+DBL_EPSILON) * 2*M_PI / L[X]; // Middle  wavenumber >~  k_mid * 2pi / Lx (only if spect_form = 2, i.e., power law; for 2nd PL section in [kmid, kmax])
        this->spect_form = spect_form; // (0: band/rectangle/constant, 1: paraboloid, 2: power law)
        this->power_law_exp = power_law_exp; // power-law amplitude exponent (only if spect_form = 2, i.e., power law)
        this->power_law_exp_2 = power_law_exp_2; // power-law amplitude exponent 2 (only if spect_form = 2, i.e., power law; for 2nd PL section in [kmid, kmax])
        this->angles_exp = angles_exp; // angles exponent (only if spect_form = 2, i.e., power law)
        this->sol_weight = sol_weight; // solenoidal weight (0: compressive, 0.5: natural mix, 1.0: solenoidal)
        this->random_seed = random_seed; // set random seed for this realisation
        seed = this->random_seed; // set random seed for this realisation
        OUvar = 1.0; // Ornstein-Uhlenbeck variance
        // the returned turbulent field needs to be re-normalised outside this call, so we just set these to 1
        for (unsigned int d = 0; d < 3; d++) ampl_factor[d] = 1.0; // amplitude factor
        if (verbose) TurbGen_printf("===============================================================================\n");
        // set derived parameters
        set_number_of_components();
        set_solenoidal_weight_normalisation();
        // initialise modes
        init_modes();
        // initialise random phases
        OU_noise_init();
        // calculate solenoidal and compressive coefficients (aka, akb) from OUphases
        get_decomposition_coeffs();
        // print info
        if (verbose) print_info("single_realisation");
        if (verbose) TurbGen_printf("===============================================================================\n");
        if (verbose > 1) TurbGen_printf(FuncSig(__func__)+"exiting.\n");
        return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movsd %xmm1, -0x20(%rbp)
movsd %xmm2, -0x28(%rbp)
movsd %xmm3, -0x30(%rbp)
movl %edx, -0x34(%rbp)
movsd %xmm4, -0x40(%rbp)
movsd %xmm5, -0x48(%rbp)
movsd %xmm6, -0x50(%rbp)
movsd %xmm7, -0x58(%rbp)
movl %ecx, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
cmpl $0x1, (%rax)
jle 0x13b9f
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x3560
movq -0x1c8(%rbp), %rdx
leaq 0x27a7(%rip), %rsi      # 0x1623d
leaq -0xc0(%rbp), %rdi
callq 0x4620
jmp 0x13aa4
movq -0x1c0(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0x9b50
jmp 0x13ac0
leaq 0x1994(%rip), %rdx      # 0x1545b
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x9b00
jmp 0x13ad9
movq -0x1c0(%rbp), %rdi
xorl %eax, %eax
leaq -0x80(%rbp), %rsi
callq 0x99f0
jmp 0x13aed
leaq -0x80(%rbp), %rdi
callq 0x31e0
leaq -0xa0(%rbp), %rdi
callq 0x31e0
leaq -0xc0(%rbp), %rdi
callq 0x31e0
leaq -0xc1(%rbp), %rdi
callq 0x3350
jmp 0x13b9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x13b8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x13b82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x13b76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31e0
leaq -0xa0(%rbp), %rdi
callq 0x31e0
leaq -0xc0(%rbp), %rdi
callq 0x31e0
leaq -0xc1(%rbp), %rdi
callq 0x3350
jmp 0x140cd
movq -0x1c0(%rbp), %rax
movsd -0x10(%rbp), %xmm0
movsd %xmm0, 0x158(%rax)
movq -0x18(%rbp), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x178(%rax)
movq -0x18(%rbp), %rcx
movsd 0x8(%rcx), %xmm0
movsd %xmm0, 0x180(%rax)
movq -0x18(%rbp), %rcx
movsd 0x10(%rcx), %xmm0
movsd %xmm0, 0x188(%rax)
movsd -0x20(%rbp), %xmm0
movsd 0x146e(%rip), %xmm1     # 0x15060
subsd %xmm1, %xmm0
movsd 0x1432(%rip), %xmm1     # 0x15030
mulsd %xmm1, %xmm0
movsd 0x144e(%rip), %xmm1     # 0x15058
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rcx
divsd (%rcx), %xmm0
movsd %xmm0, 0x1b8(%rax)
movsd 0x143a(%rip), %xmm0     # 0x15060
addsd -0x30(%rbp), %xmm0
movsd 0x13fd(%rip), %xmm1     # 0x15030
mulsd %xmm1, %xmm0
movsd 0x1419(%rip), %xmm1     # 0x15058
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rcx
divsd (%rcx), %xmm0
movsd %xmm0, 0x1c0(%rax)
movsd 0x1405(%rip), %xmm0     # 0x15060
addsd -0x28(%rbp), %xmm0
movsd 0x13c8(%rip), %xmm1     # 0x15030
mulsd %xmm1, %xmm0
movsd 0x13e4(%rip), %xmm1     # 0x15058
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rcx
divsd (%rcx), %xmm0
movsd %xmm0, 0x1c8(%rax)
movl -0x34(%rbp), %ecx
movl %ecx, 0x16c(%rax)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, 0x1e0(%rax)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, 0x1e8(%rax)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, 0x1f0(%rax)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, 0x1d0(%rax)
movl -0x5c(%rbp), %ecx
movl %ecx, 0x164(%rax)
movl 0x164(%rax), %ecx
movl %ecx, 0x168(%rax)
movsd 0x1336(%rip), %xmm0     # 0x15018
movsd %xmm0, 0x1b0(%rax)
movl $0x0, -0xd8(%rbp)
cmpl $0x3, -0xd8(%rbp)
jae 0x13d2c
movq -0x1c0(%rbp), %rax
movl -0xd8(%rbp), %ecx
movsd 0x1306(%rip), %xmm0     # 0x15018
movsd %xmm0, 0x1f8(%rax,%rcx,8)
movl -0xd8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd8(%rbp)
jmp 0x13cf4
movq -0x1c0(%rbp), %rax
cmpl $0x0, (%rax)
je 0x13ddf
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x3560
movq -0x1d0(%rbp), %rdx
leaq 0x17c1(%rip), %rsi      # 0x1551e
leaq -0xf8(%rbp), %rdi
callq 0x4620
jmp 0x13d6b
movq -0x1c0(%rbp), %rdi
xorl %eax, %eax
leaq -0xf8(%rbp), %rsi
callq 0x99f0
jmp 0x13d82
leaq -0xf8(%rbp), %rdi
callq 0x31e0
leaq -0xf9(%rbp), %rdi
callq 0x3350
jmp 0x13ddf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x13dce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x31e0
leaq -0xf9(%rbp), %rdi
callq 0x3350
jmp 0x140cd
movq -0x1c0(%rbp), %rdi
callq 0xad70
movq -0x1c0(%rbp), %rdi
callq 0xb8c0
movq -0x1c0(%rbp), %rdi
callq 0xb9a0
movq -0x1c0(%rbp), %rdi
callq 0xd250
movq -0x1c0(%rbp), %rdi
callq 0xd360
movq -0x1c0(%rbp), %rax
cmpl $0x0, (%rax)
je 0x13ecc
leaq -0x121(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x3560
movq -0x1d8(%rbp), %rdx
leaq 0x23f6(%rip), %rsi      # 0x16242
leaq -0x120(%rbp), %rdi
callq 0x4620
jmp 0x13e5a
movq -0x1c0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xde00
jmp 0x13e6f
leaq -0x120(%rbp), %rdi
callq 0x31e0
leaq -0x121(%rbp), %rdi
callq 0x3350
jmp 0x13ecc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x13ebb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x31e0
leaq -0x121(%rbp), %rdi
callq 0x3350
jmp 0x140cd
movq -0x1c0(%rbp), %rax
cmpl $0x0, (%rax)
je 0x13f7f
leaq -0x149(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x3560
movq -0x1e0(%rbp), %rdx
leaq 0x1621(%rip), %rsi      # 0x1551e
leaq -0x148(%rbp), %rdi
callq 0x4620
jmp 0x13f0b
movq -0x1c0(%rbp), %rdi
xorl %eax, %eax
leaq -0x148(%rbp), %rsi
callq 0x99f0
jmp 0x13f22
leaq -0x148(%rbp), %rdi
callq 0x31e0
leaq -0x149(%rbp), %rdi
callq 0x3350
jmp 0x13f7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x13f6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x31e0
leaq -0x149(%rbp), %rdi
callq 0x3350
jmp 0x140cd
movq -0x1c0(%rbp), %rax
cmpl $0x1, (%rax)
jle 0x140c2
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x3560
movq -0x1e8(%rbp), %rdx
leaq 0x228d(%rip), %rsi      # 0x1623d
leaq -0x1b0(%rbp), %rdi
callq 0x4620
jmp 0x13fbe
movq -0x1c0(%rbp), %rsi
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
callq 0x9b50
jmp 0x13fda
leaq 0x1648(%rip), %rdx      # 0x15629
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x9b00
jmp 0x13ff6
movq -0x1c0(%rbp), %rdi
xorl %eax, %eax
leaq -0x170(%rbp), %rsi
callq 0x99f0
jmp 0x1400d
leaq -0x170(%rbp), %rdi
callq 0x31e0
leaq -0x190(%rbp), %rdi
callq 0x31e0
leaq -0x1b0(%rbp), %rdi
callq 0x31e0
leaq -0x1b1(%rbp), %rdi
callq 0x3350
jmp 0x140c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x140b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x140a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x1409c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x31e0
leaq -0x190(%rbp), %rdi
callq 0x31e0
leaq -0x1b0(%rbp), %rdi
callq 0x31e0
leaq -0x1b1(%rbp), %rdi
callq 0x3350
jmp 0x140cd
xorl %eax, %eax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x3550
nopl (%rax)