// File: /workspace/github_c_makefile_star2_O2/asford[P]tmalign/./basic_fun.h
// Function: read_ligand(char*, double**, char*, int*)
int read_ligand(char *filename, double **a, char *seq, int *resno)
{
    int i=0;
    char cstr[100];    
    string line, str;    
    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 )
                    {                                  
                        get_xyz(line, &a[i][0], &a[i][1], &a[i][2], &seq[i], &resno[i]);
                        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);     
    } 
    seq[i]='\0';   
    
    return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x16c8, %rsp           # imm = 0x16C8
movq %rcx, 0x20(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, %rbx
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x17e00b(%rip), %rsi    # 0x58320c
leaq 0x48(%rsp), %rdi
leaq 0x340(%rsp), %rdx
callq 0x40aeca
leaq 0x17dffa(%rip), %rsi    # 0x583214
leaq 0x28(%rsp), %rdi
leaq 0x340(%rsp), %rdx
callq 0x40aeca
leaq 0xc8(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x450f40
leaq 0x140(%rsp), %rdi
callq 0x40c030
testb %al, %al
je 0x405415
xorl %ebp, %ebp
leaq 0xc8(%rsp), %rbx
leaq 0x68(%rsp), %r13
leaq 0x48(%rsp), %r14
movq 0xc8(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xe8(%rsp,%rax)
movl %ebp, %eax
movq %rax, 0x10(%rsp)
jne 0x4053ae
movq %rbx, %rdi
movq %r13, %rsi
callq 0x47d4c0
movq 0x50(%rsp), %rdx
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0x47cb40
testl %eax, %eax
je 0x4052c7
movq 0x30(%rsp), %rdx
movq %r13, %rdi
xorl %esi, %esi
leaq 0x28(%rsp), %rcx
callq 0x47cb40
testl %eax, %eax
jne 0x405268
jmp 0x4053ae
movq %r14, %r12
movq %rbx, %r14
leaq 0x340(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %r15
movq %r13, %rsi
pushq $0xc
popq %rdx
pushq $0x4
popq %rcx
callq 0x47d430
movq 0x340(%rsp), %rsi
leaq 0x2d0(%rsp), %r13
movq %r13, %rdi
callq 0x401080
movq %rbx, %rdi
callq 0x47aa80
movq %r13, %rdi
pushq $0x48
popq %rsi
callq 0x4010b0
testq %rax, %rax
movq %r14, %rbx
movq %r12, %r14
movq %r15, %r13
jne 0x405268
movq %r13, %rdi
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
leaq 0x17ed81(%rip), %rcx    # 0x5840b7
callq 0x47cd00
testl %eax, %eax
je 0x40535c
movq %r13, %rdi
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
leaq 0x17e966(%rip), %rcx    # 0x583cb5
callq 0x47cd00
testl %eax, %eax
jne 0x405268
leaq 0xa8(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x47d210
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rdi
movq (%rax,%rdi,8), %rsi
leaq 0x8(%rsi), %rdx
leaq 0x10(%rsi), %rcx
movq 0x8(%rsp), %rax
leaq (%rax,%rdi), %r8
movq 0x20(%rsp), %rax
leaq (%rax,%rdi,4), %r9
movq %r15, %rdi
callq 0x404994
movq %r15, %rdi
callq 0x47aa80
incl %ebp
jmp 0x405268
leaq 0xc8(%rsp), %rdi
callq 0x4514f0
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, (%rax,%rcx)
leaq 0xc8(%rsp), %rdi
callq 0x4518a0
leaq 0x28(%rsp), %rdi
callq 0x47aa80
leaq 0x48(%rsp), %rdi
callq 0x47aa80
leaq 0x88(%rsp), %rdi
callq 0x47aa80
leaq 0x68(%rsp), %rdi
callq 0x47aa80
movl %ebp, %eax
addq $0x16c8, %rsp           # imm = 0x16C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17ddd9(%rip), %rsi    # 0x5831f5
leaq 0x340(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4d87f0
movq %r14, %rdi
callq 0x404708
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x47aa80
jmp 0x405465
jmp 0x405462
jmp 0x405462
jmp 0x405462
movq %rax, %rbx
jmp 0x405472
movq %rax, %rbx
jmp 0x40547c
movq %rax, %rbx
jmp 0x405486
jmp 0x405462
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x4518a0
leaq 0x28(%rsp), %rdi
callq 0x47aa80
leaq 0x48(%rsp), %rdi
callq 0x47aa80
leaq 0x88(%rsp), %rdi
callq 0x47aa80
leaq 0x68(%rsp), %rdi
callq 0x47aa80
movq %rbx, %rdi
callq 0x4b19b0