// File: /workspace/github_c_makefile_star2_O3/asford[P]tmalign/./basic_fun.h
// Function: get_ligand_len(char*)
int get_ligand_len(char *filename)
{
    int i=0;
    char cstr[100];    
    string line;    
    string atom ("HETATM "); 
    string finish ("END"); 
    
    
    ifstream fin (filename);
    if (fin.is_open())
    {
        while ( fin.good() )
        {
            getline(fin, line);
            if(line.compare(0, atom.length(), atom)==0)
            {
                strcpy(cstr, (line.substr(12, 4)).c_str()); 
                   
                if(!strstr(cstr, "H"))
                {
                    if( line.compare(16, 1, " ")==0 ||\
                        line.compare(16, 1, "A")==0 )
                    {
                        i++;
                    }
                }                  
            }
            else if(line.compare(0, finish.length(), finish)==0) 
            {
                break;
            }          
        }
        fin.close();
    }
    else
    {
		char message[5000];
		sprintf(message, "Can not open file: %s\n", filename);
        PrintErrorAndQuit(message);
    } 
    
    return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1668, %rsp           # imm = 0x1668
movq %rdi, %rbx
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x17f05d(%rip), %rsi    # 0x58423c
leaq 0x17f05d(%rip), %rdx    # 0x584243
leaq 0x28(%rsp), %rdi
callq 0x40c558
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x17f044(%rip), %rsi    # 0x584244
leaq 0x17f040(%rip), %rdx    # 0x584247
leaq 0x8(%rsp), %rdi
callq 0x40c558
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x452e40
leaq 0xe0(%rsp), %rdi
callq 0x40d530
testb %al, %al
je 0x4053f3
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rax
xorl %ebx, %ebx
cmpl $0x0, 0x88(%rsp,%rax)
jne 0x405377
leaq (%rsp,%rax), %rdi
addq $0x68, %rdi
xorl %ebx, %ebx
leaq 0x68(%rsp), %r14
leaq 0x48(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x270(%rsp), %rbp
movl $0xa, %esi
callq 0x4571d0
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x40e900
movq 0x30(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rcx
callq 0x47ea40
testl %eax, %eax
je 0x4052c1
movq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
leaq 0x8(%rsp), %rcx
callq 0x47ea40
testl %eax, %eax
jne 0x40535c
jmp 0x405377
movl $0xc, %edx
movl $0x4, %ecx
leaq 0x2e0(%rsp), %rdi
movq %r15, %rsi
callq 0x47f260
movq 0x2e0(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x401080
leaq 0x2f0(%rsp), %rax
cmpq %rax, %r13
je 0x40530e
movq 0x2f0(%rsp), %rsi
incq %rsi
movq %r13, %rdi
callq 0x40c5f0
movq %rbp, %rdi
movl $0x48, %esi
callq 0x4010b0
testq %rax, %rax
jne 0x40535c
movl $0x10, %esi
movl $0x1, %edx
movq %r15, %rdi
leaq 0x17fdb3(%rip), %rcx    # 0x5850e7
callq 0x47ec00
testl %eax, %eax
je 0x40535a
movl $0x10, %esi
movl $0x1, %edx
movq %r15, %rdi
leaq 0x17f994(%rip), %rcx    # 0x584ce5
callq 0x47ec00
testl %eax, %eax
jne 0x40535c
incl %ebx
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0x68, %rdi
cmpl $0x0, 0x20(%rdi)
je 0x405272
leaq 0x68(%rsp), %rdi
callq 0x4533f0
leaq 0x68(%rsp), %rdi
callq 0x4537a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4053a7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x40c5f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4053c3
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40c5f0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x4053df
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x40c5f0
movl %ebx, %eax
addq $0x1668, %rsp           # imm = 0x1668
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17ee2b(%rip), %rsi    # 0x584225
leaq 0x2e0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4d9b80
movq %r14, %rdi
callq 0x404708
jmp 0x40542c
jmp 0x40542c
movq %rax, %rbx
jmp 0x405439
movq %rax, %rbx
jmp 0x405455
movq %rax, %rbx
jmp 0x405471
jmp 0x40542c
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4537a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x405455
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x40c5f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x405471
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40c5f0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x40548d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x40c5f0
movq %rbx, %rdi
callq 0x4b2d40