// File: /workspace/github_c_makefile_star2_O1/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 0x17f06d(%rip), %rsi    # 0x58424c
leaq 0x17f06d(%rip), %rdx    # 0x584253
leaq 0x28(%rsp), %rdi
callq 0x40c2be
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x17f054(%rip), %rsi    # 0x584254
leaq 0x17f050(%rip), %rdx    # 0x584257
leaq 0x8(%rsp), %rdi
callq 0x40c2be
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x452ba0
leaq 0xe0(%rsp), %rdi
callq 0x40d290
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 0x456f30
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x40e660
movq 0x30(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rcx
callq 0x47e7a0
testl %eax, %eax
je 0x4052c1
movq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
leaq 0x8(%rsp), %rcx
callq 0x47e7a0
testl %eax, %eax
jne 0x40535c
jmp 0x405377
movl $0xc, %edx
movl $0x4, %ecx
leaq 0x2e0(%rsp), %rdi
movq %r15, %rsi
callq 0x47efc0
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 0x40c350
movq %rbp, %rdi
movl $0x48, %esi
callq 0x4010b0
testq %rax, %rax
jne 0x40535c
movl $0x10, %esi
movl $0x1, %edx
movq %r15, %rdi
leaq 0x17fde3(%rip), %rcx    # 0x585117
callq 0x47e960
testl %eax, %eax
je 0x40535a
movl $0x10, %esi
movl $0x1, %edx
movq %r15, %rdi
leaq 0x17f9bc(%rip), %rcx    # 0x584d0d
callq 0x47e960
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 0x453150
leaq 0x68(%rsp), %rdi
callq 0x453500
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4053a7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x40c350
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4053c3
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40c350
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x4053df
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x40c350
movl %ebx, %eax
addq $0x1668, %rsp           # imm = 0x1668
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17ee3b(%rip), %rsi    # 0x584235
leaq 0x2e0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4d98e0
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 0x453500
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x405455
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x40c350
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x405471
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40c350
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x40548d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x40c350
movq %rbx, %rdi
callq 0x4b2aa0