// File: /workspace/github_cpp_makefile_star2_O1/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 0x127b6
leaq 0x18(%r14), %rdi
movq %rdi, -0x50(%rbp)
callq 0x127b6
leaq 0x30(%r14), %rdi
movq %rdi, -0x70(%rbp)
callq 0x127b6
movq %r14, -0x48(%rbp)
leaq 0x50(%r14), %rdi
movq %rdi, -0x68(%rbp)
callq 0x127b6
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 0x7869(%rip), %rsi      # 0x25040
leaq -0x60(%rbp), %rdi
callq 0xcb52
leaq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0x1dd9e
leaq 0x784d(%rip), %rsi      # 0x25043
leaq -0x60(%rbp), %rdi
callq 0xcb52
leaq -0x128(%rbp), %rdi
movq %rax, %rsi
callq 0x1dd9e
leaq 0x7831(%rip), %rsi      # 0x25046
leaq -0x60(%rbp), %rdi
callq 0xcb52
leaq -0x110(%rbp), %rdi
movq %rax, %rsi
callq 0x1dd9e
leaq 0x7814(%rip), %rsi      # 0x25048
leaq -0x60(%rbp), %rdi
callq 0xcb52
movq %rax, %rdi
callq 0xccc4
movsd %xmm0, -0xc8(%rbp)
leaq 0x77fa(%rip), %rsi      # 0x2504e
leaq -0x60(%rbp), %rdi
callq 0xcb52
movq %rax, %rdi
callq 0xccc4
movsd %xmm0, -0xc0(%rbp)
leaq -0xf8(%rbp), %r14
movq %r14, %rdi
callq 0x1ddb6
movq %rax, %rbx
movq %r14, %rdi
xorl %esi, %esi
callq 0x18374
movq %rax, %rdi
xorl %esi, %esi
callq 0x114b6
movq %rax, %rdi
callq 0x124ac
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 0x1dab9
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 0x18374
movq %rax, %rdi
xorl %esi, %esi
callq 0x114b6
movq %rax, %rdi
movq %r12, %rsi
callq 0x15cb4
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 0x18374
movq %rax, %rdi
xorl %esi, %esi
callq 0x114b6
movq %rax, %rdi
movq %r12, %rsi
callq 0x15cb4
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 0x18374
movq %rax, %rdi
xorl %esi, %esi
callq 0x114b6
movq %rax, %rdi
movq %r12, %rsi
callq 0x15cb4
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 0x1d97b
cmpl $0x0, -0x40(%rbp)
jle 0x1dbb5
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 0x1ddd6
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 0x1ddd6
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 0x1ddd6
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 0x1ddd6
incq %rbx
cmpq %rbx, -0x40(%rbp)
jne 0x1daeb
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 0x182f0
leaq -0x128(%rbp), %rdi
callq 0x182f0
leaq -0xf8(%rbp), %rdi
callq 0x182f0
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 0x1dca9
movq %rax, %r13
leaq -0x88(%rbp), %rdi
callq 0x5a80
jmp 0x1dcb5
movq %rax, %r13
leaq -0xb8(%rbp), %rdi
callq 0x5a80
jmp 0x1dcc1
movq %rax, %r13
leaq -0xa0(%rbp), %rdi
callq 0x5a80
jmp 0x1dccd
movq %rax, %r13
leaq -0x148(%rbp), %rdi
callq 0x41a0
jmp 0x1dcfa
movq %rax, %r13
jmp 0x1dcfa
jmp 0x1dc80
movq %rax, %r13
jmp 0x1dccd
movq %rax, %r13
jmp 0x1dcd9
movq %rax, %r13
jmp 0x1dce5
movq %rax, %r13
jmp 0x1dcf1
jmp 0x1dc9a
jmp 0x1dc9a
jmp 0x1dc9a
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 0x182f0
leaq -0x128(%rbp), %rdi
callq 0x182f0
leaq -0xf8(%rbp), %rdi
callq 0x182f0
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