// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x16f8, %rsp           # imm = 0x16F8
movq %rdi, 0x16f0(%rsp)
movl $0x0, 0x16ec(%rsp)
leaq 0x1660(%rsp), %rdi
callq 0x480130
leaq 0x163f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x411ca0
movq 0x48(%rsp), %rdx
leaq 0x186a5b(%rip), %rsi    # 0x58c200
leaq 0x1640(%rsp), %rdi
callq 0x410690
jmp 0x4057b4
leaq 0x163f(%rsp), %rdi
callq 0x411cc0
leaq 0x1607(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x411ca0
movq 0x40(%rsp), %rdx
leaq 0x186a29(%rip), %rsi    # 0x58c208
leaq 0x1608(%rsp), %rdi
callq 0x410690
jmp 0x4057ee
leaq 0x1607(%rsp), %rdi
callq 0x411cc0
movq 0x16f0(%rsp), %rsi
leaq 0x13f8(%rsp), %rdi
movl $0x8, %edx
callq 0x456700
jmp 0x405817
leaq 0x13f8(%rsp), %rdi
callq 0x4528b0
movb %al, 0x3f(%rsp)
jmp 0x40582a
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x405837
jmp 0x405a84
jmp 0x405839
movq 0x13f8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x13f8(%rsp,%rax), %rdi
callq 0x45a830
movb %al, 0x3e(%rsp)
jmp 0x405858
movb 0x3e(%rsp), %al
testb $0x1, %al
jne 0x405865
jmp 0x405a73
leaq 0x13f8(%rsp), %rdi
leaq 0x1660(%rsp), %rsi
callq 0x482c80
jmp 0x40587c
leaq 0x1640(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x480470
movq 0x30(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
movl %eax, %esi
leaq 0x1660(%rsp), %rdi
callq 0x482300
movl %eax, 0x38(%rsp)
jmp 0x4058ad
movl 0x38(%rsp), %eax
cmpl $0x0, %eax
jne 0x405a30
leaq 0x1680(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x13d8(%rsp), %rdi
leaq 0x1660(%rsp), %rsi
movl $0xc, %edx
movl $0x4, %ecx
callq 0x482bf0
jmp 0x4058e8
leaq 0x13d8(%rsp), %rdi
callq 0x481c80
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x401088
leaq 0x13d8(%rsp), %rdi
callq 0x480240
leaq 0x1680(%rsp), %rdi
leaq 0x19d765(%rip), %rsi    # 0x5a3083
callq 0x4010a8
cmpq $0x0, %rax
jne 0x405a2e
leaq 0x18773f(%rip), %rcx    # 0x58d073
leaq 0x1660(%rsp), %rdi
movl $0x10, %esi
movl $0x1, %edx
callq 0x4824c0
movl %eax, 0x24(%rsp)
jmp 0x405951
movl 0x24(%rsp), %eax
cmpl $0x0, %eax
je 0x40598b
leaq 0x18751f(%rip), %rcx    # 0x58ce80
leaq 0x1660(%rsp), %rdi
movl $0x10, %esi
movl $0x1, %edx
callq 0x4824c0
movl %eax, 0x20(%rsp)
jmp 0x40597e
movl 0x20(%rsp), %eax
cmpl $0x0, %eax
jne 0x405a2c
movl 0x16ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x16ec(%rsp)
jmp 0x405a2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1630(%rsp)
movl %eax, 0x162c(%rsp)
leaq 0x163f(%rsp), %rdi
callq 0x411cc0
jmp 0x405b17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1630(%rsp)
movl %eax, 0x162c(%rsp)
leaq 0x1607(%rsp), %rdi
callq 0x411cc0
jmp 0x405b0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1630(%rsp)
movl %eax, 0x162c(%rsp)
jmp 0x405afd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1630(%rsp)
movl %eax, 0x162c(%rsp)
leaq 0x13f8(%rsp), %rdi
callq 0x457060
jmp 0x405afd
jmp 0x405a2e
jmp 0x405a6e
leaq 0x1608(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x480470
movq 0x10(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
movl %eax, %esi
leaq 0x1660(%rsp), %rdi
callq 0x482300
movl %eax, 0x1c(%rsp)
jmp 0x405a61
movl 0x1c(%rsp), %eax
cmpl $0x0, %eax
jne 0x405a6c
jmp 0x405a73
jmp 0x405a6e
jmp 0x405839
leaq 0x13f8(%rsp), %rdi
callq 0x456cb0
jmp 0x405a82
jmp 0x405ab2
movq 0x16f0(%rsp), %rdx
leaq 0x186756(%rip), %rsi    # 0x58c1e9
xorl %eax, %eax
leaq 0x50(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x4e1e10
movq 0x8(%rsp), %rdi
callq 0x404740
jmp 0x405ab0
jmp 0x405ab2
movl 0x16ec(%rsp), %eax
movl %eax, 0x4(%rsp)
leaq 0x13f8(%rsp), %rdi
callq 0x457060
leaq 0x1608(%rsp), %rdi
callq 0x480240
leaq 0x1640(%rsp), %rdi
callq 0x480240
leaq 0x1660(%rsp), %rdi
callq 0x480240
movl 0x4(%rsp), %eax
addq $0x16f8, %rsp           # imm = 0x16F8
retq
leaq 0x1608(%rsp), %rdi
callq 0x480240
leaq 0x1640(%rsp), %rdi
callq 0x480240
leaq 0x1660(%rsp), %rdi
callq 0x480240
movq 0x1630(%rsp), %rdi
callq 0x4bafd0
nopw %cs:(%rax,%rax)