// File: gjoni[P]iPot/src/AACE.cpp
// Function: AACE::ReadGroups(char const*)
int AACE::ReadGroups(const char *name) {

	FILE *F = fopen(name, "r");
	if (F == NULL) {
		printf("Error: cannot open %s file\n", name);
		exit(1);
	}

	const int STRMAX = 1000;
	char atom[10], type[10], buf[STRMAX];
	int n = 0;

	while (fgets(buf, STRMAX, F)) {
		if (buf[0] != '#') {
			if (sscanf(buf, "%s %s", atom, type) == 2) {
				std::map<std::string, int>::const_iterator it;
				it = TYPE_IDX.find(type);
				int t;
				if (it == TYPE_IDX.end()) {
					TYPE_IDX[type] = n;
					//printf("%s %d\n", type, n);
					t = n++;
				} else {
					t = it->second;
				}
				ATOM_IDX[atom] = t;
			}
		}
	}
	fclose(F);

	return TYPE_IDX.size();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x540, %rsp            # imm = 0x540
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x4e0(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x134d4(%rip), %rsi     # 0x34b4d
callq 0x3310
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x216a5
movq -0x10(%rbp), %rsi
leaq 0x15840(%rip), %rdi     # 0x36ed4
movb $0x0, %al
callq 0x3070
movl $0x1, %edi
callq 0x3330
movl $0x3e8, -0x1c(%rbp)     # imm = 0x3E8
movl $0x0, -0x424(%rbp)
leaq -0x420(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x3410
cmpq $0x0, %rax
je 0x21a14
movsbl -0x420(%rbp), %eax
cmpl $0x23, %eax
je 0x21a0f
leaq -0x420(%rbp), %rdi
leaq -0x26(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq 0x157f5(%rip), %rsi     # 0x36ef0
movb $0x0, %al
callq 0x3280
cmpl $0x2, %eax
jne 0x21a0d
leaq -0x430(%rbp), %rdi
callq 0x23450
movq -0x4e0(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x4f0(%rbp)
leaq -0x461(%rbp), %rdi
movq %rdi, -0x4e8(%rbp)
callq 0x3470
movq -0x4e8(%rbp), %rdx
leaq -0x460(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x18790
jmp 0x21755
movq -0x4f0(%rbp), %rdi
leaq -0x460(%rbp), %rsi
callq 0x23470
movq %rax, -0x4f8(%rbp)
jmp 0x21771
movq -0x4f8(%rbp), %rax
movq %rax, -0x440(%rbp)
leaq -0x438(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x234a0
movq -0x438(%rbp), %rax
movq %rax, -0x430(%rbp)
leaq -0x460(%rbp), %rdi
callq 0x3190
leaq -0x461(%rbp), %rdi
callq 0x32e0
movq -0x4e0(%rbp), %rdi
addq $0x30, %rdi
callq 0x234f0
movq %rax, -0x488(%rbp)
leaq -0x480(%rbp), %rdi
leaq -0x488(%rbp), %rsi
callq 0x234a0
leaq -0x430(%rbp), %rdi
leaq -0x480(%rbp), %rsi
callq 0x234c0
testb $0x1, %al
jne 0x217fe
jmp 0x2192d
movq -0x4e0(%rbp), %rax
movl -0x424(%rbp), %ecx
movl %ecx, -0x50c(%rbp)
addq $0x30, %rax
movq %rax, -0x508(%rbp)
leaq -0x4a9(%rbp), %rdi
movq %rdi, -0x500(%rbp)
callq 0x3470
movq -0x500(%rbp), %rdx
leaq -0x4a8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x18790
jmp 0x21848
movq -0x508(%rbp), %rdi
leaq -0x4a8(%rbp), %rsi
callq 0x23520
movq %rax, -0x518(%rbp)
jmp 0x21864
movq -0x518(%rbp), %rax
movl -0x50c(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x4a8(%rbp), %rdi
callq 0x3190
leaq -0x4a9(%rbp), %rdi
callq 0x32e0
movl -0x424(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x424(%rbp)
movl %eax, -0x478(%rbp)
jmp 0x21942
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x470(%rbp)
movl %eax, -0x474(%rbp)
jmp 0x218d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x470(%rbp)
movl %eax, -0x474(%rbp)
leaq -0x460(%rbp), %rdi
callq 0x3190
leaq -0x461(%rbp), %rdi
callq 0x32e0
jmp 0x21a36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x470(%rbp)
movl %eax, -0x474(%rbp)
jmp 0x2191c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x470(%rbp)
movl %eax, -0x474(%rbp)
leaq -0x4a8(%rbp), %rdi
callq 0x3190
leaq -0x4a9(%rbp), %rdi
callq 0x32e0
jmp 0x21a36
leaq -0x430(%rbp), %rdi
callq 0x23600
movl 0x20(%rax), %eax
movl %eax, -0x478(%rbp)
movq -0x4e0(%rbp), %rax
movl -0x478(%rbp), %ecx
movl %ecx, -0x52c(%rbp)
movq %rax, -0x528(%rbp)
leaq -0x4d1(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x3470
movq -0x520(%rbp), %rdx
leaq -0x4d0(%rbp), %rdi
leaq -0x26(%rbp), %rsi
callq 0x18790
jmp 0x21988
movq -0x528(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
callq 0x23520
movq %rax, -0x538(%rbp)
jmp 0x219a4
movq -0x538(%rbp), %rax
movl -0x52c(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x4d0(%rbp), %rdi
callq 0x3190
leaq -0x4d1(%rbp), %rdi
callq 0x32e0
jmp 0x21a0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x470(%rbp)
movl %eax, -0x474(%rbp)
jmp 0x219ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x470(%rbp)
movl %eax, -0x474(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x3190
leaq -0x4d1(%rbp), %rdi
callq 0x32e0
jmp 0x21a36
jmp 0x21a0f
jmp 0x216b6
movq -0x18(%rbp), %rdi
callq 0x3290
movq -0x4e0(%rbp), %rdi
addq $0x30, %rdi
callq 0x233d0
addq $0x540, %rsp            # imm = 0x540
popq %rbp
retq
movq -0x470(%rbp), %rdi
callq 0x3460
nopw %cs:(%rax,%rax)