// File: Luthaf[P]zeopp/networkio.cc
// Function: get_formula[abi:cxx11](ATOM_NETWORK const*)
string get_formula(ATOM_NETWORK const *const cell)
{
    vector<string> atomtypes;
    map<string,int>  typecount;

    for (vector<ATOM>::const_iterator it=cell->atoms.begin(); it!=cell->atoms.end(); ++it){
        if (find(atomtypes.begin(), atomtypes.end(), it->type) != atomtypes.end()){
            ++(typecount[it->type]);
        }
        else{
            atomtypes.push_back(it->type);
            typecount[it->type] = 1;
        }
    }
    string formula;
    for (map<string,int>::iterator it=typecount.begin(); it!=typecount.end(); ++it){
        formula.append(it->first);
        stringstream ss;
        ss << it->second;
        formula.append(ss.str());
    }
    return formula;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x268(%rbp)
movq %rdi, %rax
movq %rax, -0x260(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x59240
leaq -0x58(%rbp), %rdi
callq 0x46e20
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
callq 0x59670
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
callq 0x596e0
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x596a0
testb $0x1, %al
jne 0x55124
jmp 0x55242
leaq -0x28(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x597a0
movq -0x278(%rbp), %rdi
movq %rax, -0x78(%rbp)
callq 0x597d0
movq %rax, -0x80(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x59800
movq %rax, %rdx
addq $0x40, %rdx
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x59750
movq %rax, -0x270(%rbp)
jmp 0x5516e
movq -0x270(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x597d0
movq %rax, -0x98(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x59710
testb $0x1, %al
jne 0x5519f
jmp 0x551e8
leaq -0x60(%rbp), %rdi
callq 0x59800
movq %rax, %rsi
addq $0x40, %rsi
leaq -0x58(%rbp), %rdi
callq 0x59820
movq %rax, -0x280(%rbp)
jmp 0x551c1
movq -0x280(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x55232
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x553d8
leaq -0x60(%rbp), %rdi
callq 0x59800
movq %rax, %rsi
addq $0x40, %rsi
leaq -0x28(%rbp), %rdi
callq 0x59330
jmp 0x55203
leaq -0x60(%rbp), %rdi
callq 0x59800
movq %rax, %rsi
addq $0x40, %rsi
leaq -0x58(%rbp), %rdi
callq 0x59820
movq %rax, -0x288(%rbp)
jmp 0x55225
movq -0x288(%rbp), %rax
movl $0x1, (%rax)
jmp 0x55234
leaq -0x60(%rbp), %rdi
callq 0x59900
jmp 0x550fa
movq -0x268(%rbp), %rdi
movb $0x0, -0x99(%rbp)
callq 0x5720
leaq -0x58(%rbp), %rdi
callq 0x59920
movq %rax, -0xa8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x47770
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x59950
testb $0x1, %al
jne 0x55291
jmp 0x5538e
leaq -0xa8(%rbp), %rdi
callq 0x477a0
movq -0x268(%rbp), %rdi
movq %rax, %rsi
callq 0x59d0
jmp 0x552ae
leaq -0x238(%rbp), %rdi
callq 0x5370
jmp 0x552bc
leaq -0x228(%rbp), %rax
movq %rax, -0x290(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x477a0
movq -0x290(%rbp), %rdi
movl 0x20(%rax), %esi
callq 0x58d0
jmp 0x552e7
leaq -0x258(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x5530
jmp 0x552fc
movq -0x268(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x59d0
jmp 0x55311
leaq -0x258(%rbp), %rdi
callq 0x5300
leaq -0x238(%rbp), %rdi
callq 0x53c0
leaq -0xa8(%rbp), %rdi
callq 0x59980
jmp 0x55265
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x553cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x55380
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x5300
leaq -0x238(%rbp), %rdi
callq 0x53c0
jmp 0x553cc
movb $0x1, -0x99(%rbp)
testb $0x1, -0x99(%rbp)
jne 0x553aa
movq -0x268(%rbp), %rdi
callq 0x5300
leaq -0x58(%rbp), %rdi
callq 0x46e40
leaq -0x28(%rbp), %rdi
callq 0x59290
movq -0x260(%rbp), %rax
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
movq -0x268(%rbp), %rdi
callq 0x5300
leaq -0x58(%rbp), %rdi
callq 0x46e40
leaq -0x28(%rbp), %rdi
callq 0x59290
movq -0x88(%rbp), %rdi
callq 0x58f0
nopw %cs:(%rax,%rax)