// File: /workspace/github_cpp_makefile_star2_O3/TBody[P]atomicpp/atomicpp/SD1DData.cpp
// Function: atomicpp::SD1DData::SD1DData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, double)
SD1DData::SD1DData(const std::string& expt_results_json, double impurity_fraction_input){

	json data_dict = retrieveFromJSON(expt_results_json);

	impurity_fraction = impurity_fraction_input;

	// # Retrieve (normalised values)
	std::vector<std::vector<std::vector< std::vector<double> > >> extract_Ne = data_dict["Ne"];
	std::vector<std::vector<std::vector< std::vector<double> > >> extract_Nn = data_dict["Nn"];
	std::vector<std::vector<std::vector< std::vector<double> > >> extract_P  = data_dict["P"];

	// // # Retrieve normalisation factors
	double Nnorm = data_dict["Nnorm"];
	double Tnorm = data_dict["Tnorm"];
	// // # Converts N into m^-3, T into eV 

	// Attributes
	// std::vector<double> density;
	// std::vector<double> temperature;
	// std::vector<double> neutral_fraction;
	// double impurity_fraction;
	// std::vector<double> impurity_density;
	
	// Extract the 'y' dimensions, at the final time index
	// Dimensions are [t, x, y, z]
	//                [0, 1, 2, 3]
	int final_time_index = extract_Ne.size() - 1;
	int data_length = extract_Ne[0][0].size();
	
	std::vector<double> shaped_Ne(data_length);
	std::vector<double> shaped_Nn(data_length);
	std::vector<double> shaped_P(data_length);
	std::vector<double> shaped_T(data_length);

	for(int i=0; i< data_length; ++i){
  		shaped_Ne[i] = extract_Ne[final_time_index][0][i][0];
  		shaped_Nn[i] = extract_Nn[final_time_index][0][i][0];
  		shaped_P[i] = extract_P[final_time_index][0][i][0];
		// # P = 2*Ne*Te => Te = P/(2*Ne)
  		shaped_T[i] = shaped_P[i]/(2*shaped_Ne[i]);
	}
	// Verified list copy was identical for Ne
	// N.b. the loops above and below are essentially identical 
	// ways of assigning elements into a std::vector. However, since the 
	// std::vectors below are defined at classdef their length is not
	// initialised, so using push_back method instead.
	
	for(int i=0; i<data_length; ++i){
  		density.push_back(Nnorm * shaped_Ne[i]);
  		temperature.push_back(Tnorm * shaped_T[i]);
  		neutral_fraction.push_back(shaped_Nn[i]/shaped_Ne[i]);
  		impurity_density.push_back(impurity_fraction * density[i]);
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movsd %xmm0, -0x30(%rbp)
movq %rsi, %rbx
movq %rdi, %r14
callq 0x12776
leaq 0x18(%r14), %rdi
movq %rdi, -0x50(%rbp)
callq 0x12776
leaq 0x30(%r14), %rdi
movq %rdi, -0x70(%rbp)
callq 0x12776
movq %r14, -0x48(%rbp)
leaq 0x50(%r14), %rdi
movq %rdi, -0x68(%rbp)
callq 0x12776
leaq -0x148(%rbp), %rdi
movq %rbx, %rsi
callq 0x4480
leaq -0x60(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x5c50
leaq -0x148(%rbp), %rdi
callq 0x41a0
movq -0x48(%rbp), %rax
movsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x48(%rax)
leaq 0x7925(%rip), %rsi      # 0x25040
leaq -0x60(%rbp), %rdi
callq 0xcad2
leaq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0x1dce2
leaq 0x7909(%rip), %rsi      # 0x25043
leaq -0x60(%rbp), %rdi
callq 0xcad2
leaq -0x128(%rbp), %rdi
movq %rax, %rsi
callq 0x1dce2
leaq 0x78ed(%rip), %rsi      # 0x25046
leaq -0x60(%rbp), %rdi
callq 0xcad2
leaq -0x110(%rbp), %rdi
movq %rax, %rsi
callq 0x1dce2
leaq 0x78d0(%rip), %rsi      # 0x25048
leaq -0x60(%rbp), %rdi
callq 0xcad2
movq %rax, %rdi
callq 0xcc46
movsd %xmm0, -0xc8(%rbp)
leaq 0x78b6(%rip), %rsi      # 0x2504e
leaq -0x60(%rbp), %rdi
callq 0xcad2
movq %rax, %rdi
callq 0xcc46
movsd %xmm0, -0xc0(%rbp)
leaq -0xf8(%rbp), %r14
movq %r14, %rdi
callq 0x1dcfa
movq %rax, %rbx
movq %r14, %rdi
xorl %esi, %esi
callq 0x18356
movq %rax, %rdi
xorl %esi, %esi
callq 0x1145a
movq %rax, %rdi
callq 0x1246c
movq %rax, -0x40(%rbp)
movslq %eax, %r14
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
callq 0x533c
leaq -0xe0(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5346
leaq -0xa0(%rbp), %rdi
callq 0x5a80
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
callq 0x533c
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5346
leaq -0xb8(%rbp), %rdi
callq 0x5a80
leaq -0x88(%rbp), %r15
movq %r15, %rdi
callq 0x533c
leaq -0xb8(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5346
leaq -0x88(%rbp), %rdi
callq 0x5a80
leaq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0x533c
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5346
leaq -0x38(%rbp), %rdi
callq 0x5a80
cmpl $0x0, -0x40(%rbp)
jle 0x1daf9
decl %ebx
movslq %ebx, %r15
movq -0x40(%rbp), %r13
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
xorl %r12d, %r12d
leaq -0xe0(%rbp), %rbx
leaq -0xb8(%rbp), %r14
leaq -0xf8(%rbp), %rdi
movq %r15, %rsi
callq 0x18356
movq %rax, %rdi
xorl %esi, %esi
callq 0x1145a
movq %rax, %rdi
movq %r12, %rsi
callq 0x15c9c
movq %rax, %rdi
xorl %esi, %esi
callq 0x539c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x539c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x128(%rbp), %rdi
movq %r15, %rsi
callq 0x18356
movq %rax, %rdi
xorl %esi, %esi
callq 0x1145a
movq %rax, %rdi
movq %r12, %rsi
callq 0x15c9c
movq %rax, %rdi
xorl %esi, %esi
callq 0x539c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0xa0(%rbp), %rdi
movq %r12, %rsi
callq 0x539c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x110(%rbp), %rdi
movq %r15, %rsi
callq 0x18356
movq %rax, %rdi
xorl %esi, %esi
callq 0x1145a
movq %rax, %rdi
movq %r12, %rsi
callq 0x15c9c
movq %rax, %rdi
xorl %esi, %esi
callq 0x539c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x539c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %r14, %rdi
movq %r12, %rsi
callq 0x539c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x539c
movsd (%rax), %xmm0
addsd %xmm0, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
leaq -0x88(%rbp), %rdi
movq %r12, %rsi
callq 0x539c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
incq %r12
cmpq %r12, %r13
jne 0x1d8bf
cmpl $0x0, -0x40(%rbp)
jle 0x1daf9
movq -0x40(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0x40(%rbp)
xorl %ebx, %ebx
leaq -0xe0(%rbp), %r14
leaq -0x38(%rbp), %r15
leaq -0x88(%rbp), %r12
leaq -0xa0(%rbp), %r13
movq %r14, %rdi
movq %rbx, %rsi
callq 0x539c
movsd (%rax), %xmm0
mulsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x1dd1a
movq %r12, %rdi
movq %rbx, %rsi
callq 0x539c
movsd (%rax), %xmm0
mulsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0x1dd1a
movq %r13, %rdi
movq %rbx, %rsi
callq 0x539c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x539c
movsd -0x30(%rbp), %xmm0
divsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x1dd1a
movq -0x48(%rbp), %rax
movsd 0x48(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x539c
movsd -0x30(%rbp), %xmm0
mulsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x68(%rbp), %rdi
movq %r15, %rsi
callq 0x1dd1a
incq %rbx
cmpq %rbx, -0x40(%rbp)
jne 0x1da2f
leaq -0x88(%rbp), %rdi
callq 0x53c6
leaq -0xb8(%rbp), %rdi
callq 0x53c6
leaq -0xa0(%rbp), %rdi
callq 0x53c6
leaq -0xe0(%rbp), %rdi
callq 0x53c6
leaq -0x110(%rbp), %rdi
callq 0x182d2
leaq -0x128(%rbp), %rdi
callq 0x182d2
leaq -0xf8(%rbp), %rdi
callq 0x182d2
leaq -0x60(%rbp), %rdi
callq 0x5e92
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r13
leaq -0x38(%rbp), %rdi
callq 0x5a80
jmp 0x1dbed
movq %rax, %r13
leaq -0x88(%rbp), %rdi
callq 0x5a80
jmp 0x1dbf9
movq %rax, %r13
leaq -0xb8(%rbp), %rdi
callq 0x5a80
jmp 0x1dc05
movq %rax, %r13
leaq -0xa0(%rbp), %rdi
callq 0x5a80
jmp 0x1dc11
movq %rax, %r13
leaq -0x148(%rbp), %rdi
callq 0x41a0
jmp 0x1dc3e
movq %rax, %r13
jmp 0x1dc3e
jmp 0x1dbc4
movq %rax, %r13
jmp 0x1dc11
movq %rax, %r13
jmp 0x1dc1d
movq %rax, %r13
jmp 0x1dc29
movq %rax, %r13
jmp 0x1dc35
jmp 0x1dbde
jmp 0x1dbde
jmp 0x1dbde
movq %rax, %r13
leaq -0x88(%rbp), %rdi
callq 0x53c6
leaq -0xb8(%rbp), %rdi
callq 0x53c6
leaq -0xa0(%rbp), %rdi
callq 0x53c6
leaq -0xe0(%rbp), %rdi
callq 0x53c6
leaq -0x110(%rbp), %rdi
callq 0x182d2
leaq -0x128(%rbp), %rdi
callq 0x182d2
leaq -0xf8(%rbp), %rdi
callq 0x182d2
leaq -0x60(%rbp), %rdi
callq 0x5e92
movq -0x68(%rbp), %rdi
callq 0x53c6
movq -0x70(%rbp), %rdi
callq 0x53c6
movq -0x50(%rbp), %rdi
callq 0x53c6
movq -0x48(%rbp), %rdi
callq 0x53c6
movq %r13, %rdi
callq 0x45a0