// File: gjoni[P]iPot/src/AACE.cpp
// Function: AACE::AACE(AACE::AACE_TYPE, double, int)
AACE::AACE(AACE_TYPE type, double d, int k) :
		h(NULL), J(NULL), dmax(d) {

	char *DATADIR = getenv("TMDOCKDAT");
	if (DATADIR == NULL) {
		printf("Error: environment variable 'TMDOCKDAT' not set\n");
		exit(1);
	}

	const int STRMAX = 1000;
	char gname[STRMAX], tname[STRMAX], aace_name[STRMAX];

	switch (type) {

	case AACE18:
		sprintf(gname, "%s/groups18.dat", DATADIR);
		sprintf(tname, "%s/AACE18/table.%.1fA_k%d", DATADIR, dmax, k);
		sprintf(aace_name, "AACE18_%.1fA_k%d", dmax, k);
		break;

	case AACE167:
		sprintf(gname, "%s/groups167.dat", DATADIR);
		sprintf(tname, "%s/AACE167/table.%.1fA_k%d", DATADIR, dmax, k);
		sprintf(aace_name, "AACE167_%.1fA_k%d", dmax, k);
		break;

	case AACE20:
		sprintf(gname, "%s/groups20.dat", DATADIR);
		sprintf(tname, "%s/AACE20/table.%.1fA_k%d", DATADIR, dmax, k);
		sprintf(aace_name, "AACE20_%.1fA_k%d", dmax, k);
		break;

	case AACE24:
		sprintf(gname, "%s/groups24.dat", DATADIR);
		sprintf(tname, "%s/AACE24/table.%.1fA_k%d", DATADIR, dmax, k);
		sprintf(aace_name, "AACE24_%.1fA_k%d", dmax, k);
		break;

	case AACE33:
		sprintf(gname, "%s/groups33.dat", DATADIR);
		sprintf(tname, "%s/AACE33/table.%.1fA_k%d", DATADIR, dmax, k);
		sprintf(aace_name, "AACE33_%.1fA_k%d", dmax, k);
		break;

	default:
		printf("Error: wrong AACE groups file\n");
		exit(1);
		break;

	}

	ReadGroups(gname);

	Allocate(TYPE_IDX.size());

	ReadCouplings(tname);

	name = aace_name;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc20, %rsp            # imm = 0xC20
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movsd %xmm0, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xc10(%rbp)
callq 0x23320
movq -0xc10(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0xc18(%rbp)
callq 0x23320
movq -0xc10(%rbp), %rdi
movq $0x0, 0x60(%rdi)
movq $0x0, 0x68(%rdi)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, 0x70(%rdi)
addq $0x78, %rdi
movq %rdi, -0xc08(%rbp)
callq 0x33b0
leaq 0x15a03(%rip), %rdi     # 0x36d1c
callq 0x3340
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x21378
leaq 0x159f6(%rip), %rdi     # 0x36d26
xorl %eax, %eax
callq 0x3070
jmp 0x21339
movl $0x1, %edi
callq 0x3330
movq -0xc08(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x3190
movq -0xc18(%rbp), %rdi
callq 0x233b0
movq -0xc10(%rbp), %rdi
callq 0x233b0
jmp 0x21642
movl $0x3e8, -0x38(%rbp)     # imm = 0x3E8
movl -0xc(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0xc20(%rbp)
subl $0x4, %eax
ja 0x215bc
movq -0xc20(%rbp), %rax
leaq 0x13984(%rip), %rcx     # 0x34d28
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x420(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x15998(%rip), %rsi     # 0x36d57
movb $0x0, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0x810(%rbp), %rdi
movq -0x28(%rbp), %rdx
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %ecx
leaq 0x15980(%rip), %rsi     # 0x36d67
movb $0x1, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0xc00(%rbp), %rdi
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %edx
leaq 0x15976(%rip), %rsi     # 0x36d81
movb $0x1, %al
callq 0x30b0
jmp 0x215d6
leaq -0x420(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x15969(%rip), %rsi     # 0x36d92
movb $0x0, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0x810(%rbp), %rdi
movq -0x28(%rbp), %rdx
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %ecx
leaq 0x15952(%rip), %rsi     # 0x36da3
movb $0x1, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0xc00(%rbp), %rdi
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %edx
leaq 0x15949(%rip), %rsi     # 0x36dbe
movb $0x1, %al
callq 0x30b0
jmp 0x215d6
leaq -0x420(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x1593d(%rip), %rsi     # 0x36dd0
movb $0x0, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0x810(%rbp), %rdi
movq -0x28(%rbp), %rdx
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %ecx
leaq 0x15925(%rip), %rsi     # 0x36de0
movb $0x1, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0xc00(%rbp), %rdi
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %edx
leaq 0x1591b(%rip), %rsi     # 0x36dfa
movb $0x1, %al
callq 0x30b0
jmp 0x215d6
leaq -0x420(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x1590e(%rip), %rsi     # 0x36e0b
movb $0x0, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0x810(%rbp), %rdi
movq -0x28(%rbp), %rdx
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %ecx
leaq 0x158f6(%rip), %rsi     # 0x36e1b
movb $0x1, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0xc00(%rbp), %rdi
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %edx
leaq 0x158ec(%rip), %rsi     # 0x36e35
movb $0x1, %al
callq 0x30b0
jmp 0x215d6
leaq -0x420(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x158df(%rip), %rsi     # 0x36e46
movb $0x0, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0x810(%rbp), %rdi
movq -0x28(%rbp), %rdx
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %ecx
leaq 0x158c7(%rip), %rsi     # 0x36e56
movb $0x1, %al
callq 0x30b0
movq -0xc10(%rbp), %rax
leaq -0xc00(%rbp), %rdi
movsd 0x70(%rax), %xmm0
movl -0x1c(%rbp), %edx
leaq 0x158bd(%rip), %rsi     # 0x36e70
movb $0x1, %al
callq 0x30b0
jmp 0x215d6
leaq 0x158be(%rip), %rdi     # 0x36e81
xorl %eax, %eax
callq 0x3070
jmp 0x215cc
movl $0x1, %edi
callq 0x3330
movq -0xc10(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x21650
jmp 0x215eb
movq -0xc10(%rbp), %rdi
addq $0x30, %rdi
callq 0x233d0
movq -0xc10(%rbp), %rdi
movl %eax, %esi
callq 0x20f00
jmp 0x2160b
movq -0xc10(%rbp), %rdi
leaq -0x810(%rbp), %rsi
callq 0x21a50
jmp 0x21620
movq -0xc10(%rbp), %rdi
addq $0x78, %rdi
leaq -0xc00(%rbp), %rsi
callq 0x33a0
jmp 0x21639
addq $0xc20, %rsp            # imm = 0xC20
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x3460
nopl (%rax,%rax)