// File: /workspace/github_c_makefile_star2_O2/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)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x17e25f(%rip), %rsi    # 0x58320c
leaq 0x28(%rsp), %rdi
leaq 0x2e0(%rsp), %rdx
callq 0x40aeca
leaq 0x17e24e(%rip), %rsi    # 0x583214
leaq 0x8(%rsp), %rdi
leaq 0x2e0(%rsp), %rdx
callq 0x40aeca
leaq 0x68(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x450f40
leaq 0xe0(%rsp), %rdi
callq 0x40c030
testb %al, %al
je 0x405146
movq $0x0, (%rsp)
leaq 0x68(%rsp), %r14
leaq 0x48(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x2e0(%rsp), %r13
leaq 0x270(%rsp), %rbp
leaq 0x8(%rsp), %rbx
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x88(%rsp,%rax)
jne 0x4050fe
movq %r14, %rdi
movq %r15, %rsi
callq 0x47d4c0
movq 0x30(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rcx
callq 0x47cb40
testl %eax, %eax
je 0x40507c
movq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %rbx, %rcx
callq 0x47cb40
testl %eax, %eax
jne 0x405029
jmp 0x4050fe
movq %r13, %rdi
movq %r15, %rsi
pushq $0xc
popq %rdx
pushq $0x4
popq %rcx
callq 0x47d430
movq 0x2e0(%rsp), %rsi
movq %rbp, %rdi
callq 0x401080
movq %r13, %rdi
callq 0x47aa80
movq %rbp, %rdi
pushq $0x48
popq %rsi
callq 0x4010b0
testq %rax, %rax
jne 0x405029
movq %r15, %rdi
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
leaq 0x17efee(%rip), %rcx    # 0x5840b7
callq 0x47cd00
testl %eax, %eax
je 0x4050ef
movq %r15, %rdi
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
leaq 0x17ebd3(%rip), %rcx    # 0x583cb5
callq 0x47cd00
testl %eax, %eax
jne 0x405029
movq (%rsp), %rax
incl %eax
movq %rax, (%rsp)
jmp 0x405029
leaq 0x68(%rsp), %rdi
callq 0x4514f0
leaq 0x68(%rsp), %rdi
callq 0x4518a0
leaq 0x8(%rsp), %rdi
callq 0x47aa80
leaq 0x28(%rsp), %rdi
callq 0x47aa80
leaq 0x48(%rsp), %rdi
callq 0x47aa80
movq (%rsp), %rax
addq $0x1668, %rsp           # imm = 0x1668
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17e0a8(%rip), %rsi    # 0x5831f5
leaq 0x2e0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4d87f0
movq %r14, %rdi
callq 0x404708
jmp 0x40517f
jmp 0x40517f
movq %rax, %rbx
jmp 0x40518c
movq %rax, %rbx
jmp 0x405196
movq %rax, %rbx
jmp 0x4051a0
jmp 0x40517f
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4518a0
leaq 0x8(%rsp), %rdi
callq 0x47aa80
leaq 0x28(%rsp), %rdi
callq 0x47aa80
leaq 0x48(%rsp), %rdi
callq 0x47aa80
movq %rbx, %rdi
callq 0x4b19b0