// File: /workspace/github_cpp_makefile_star2_O1/gjoni[P]iPot/src/Chain.cpp
// Function: Chain::ReadAtomRecord(char*)
AtomRecord Chain::ReadAtomRecord(char* str) {

	AtomRecord A;

	/* complete string to 80 characters */
	char *pch = strpbrk(str, "\n");
	if (pch != NULL && pch - str < 80) {
		while (pch != str + 80) {
			*pch++ = ' ';
		}
		*pch = '\0';
	}

	/*
	 * reading PDB ATOM string in the reverse direction
	 */

	/* Charge on the atom */
	str[80] = '\0';
	strncpy(A.charge, str + 78, 3);

	/* Element symbol, right-justified */
	str[78] = '\0';
	strncpy(A.element, str + 76, 3);

	/* Segment identifier, left-justified */
	str[76] = '\0';
	strncpy(A.segId, str + 72, 5);

	/* Temperature factor */
	str[67] = '\0';
	A.temp = atof(str + 60);

	/* Occupancy */
	str[60] = '\0';
	A.occup = atof(str + 54);

	/* Z coordinate */
	str[54] = '\0';
	A.z = atof(str + 46);

	/* Y coordinate */
	str[46] = '\0';
	A.y = atof(str + 38);

	/* X coordinate */
	str[38] = '\0';
	A.x = atof(str + 30);

	/* Code for insertion of residues */
	A.insCode = str[26];

	/* Residue sequence number */
	str[26] = '\0';
	A.resNum = atoi(str + 22);

	/* Chain identifier */
	A.chainId = str[21];

	/* Residue name */
	str[20] = '\0';
	//strncpy(A.resName, str + 17, 4);
	sscanf(str + 17, "%s", A.resName); /* no spaces in residue name */

	/* Alternate location indicator */
	A.altLoc = str[16];

	/* Atom name */
	str[16] = '\0';
	//strncpy(A.atomName, str + 12, 5);
	sscanf(str + 12, "%s", A.atomName);

	/* Atom serial number */
	str[11] = '\0';
	A.atomNum = atoi(str + 6);

	return A;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
movq %rdx, %rdi
movl $0xa, %esi
callq 0x20e0
testq %rax, %rax
sete %cl
movq %rax, %rdx
subq %r14, %rdx
cmpq $0x50, %rdx
setge %dl
orb %cl, %dl
jne 0xeb36
leaq 0x50(%r14), %r15
cmpq %r15, %rax
je 0xeb2f
movq %r15, %rdx
subq %rax, %rdx
movq %rax, %rdi
movl $0x20, %esi
callq 0x2150
jmp 0xeb32
movq %rax, %r15
movb $0x0, (%r15)
xorl %ebp, %ebp
movb %bpl, 0x50(%r14)
leaq 0x48(%rbx), %rdi
leaq 0x4e(%r14), %rsi
movl $0x3, %edx
callq 0x2120
movb %bpl, 0x4e(%r14)
leaq 0x45(%rbx), %rdi
leaq 0x4c(%r14), %rsi
movl $0x3, %edx
callq 0x2120
movb %bpl, 0x4c(%r14)
leaq 0x40(%rbx), %rdi
leaq 0x48(%r14), %rsi
movl $0x5, %edx
callq 0x2120
movb %bpl, 0x43(%r14)
leaq 0x3c(%r14), %rdi
callq 0x22b0
movsd %xmm0, 0x38(%rbx)
movb %bpl, 0x3c(%r14)
leaq 0x36(%r14), %rdi
callq 0x22b0
movsd %xmm0, 0x30(%rbx)
movb %bpl, 0x36(%r14)
leaq 0x2e(%r14), %rdi
callq 0x22b0
movsd %xmm0, 0x28(%rbx)
movb %bpl, 0x2e(%r14)
leaq 0x26(%r14), %rdi
callq 0x22b0
movsd %xmm0, 0x20(%rbx)
movb %bpl, 0x26(%r14)
leaq 0x1e(%r14), %rdi
callq 0x22b0
movsd %xmm0, 0x18(%rbx)
movb 0x1a(%r14), %al
movb %al, 0x14(%rbx)
movb %bpl, 0x1a(%r14)
leaq 0x16(%r14), %rdi
callq 0x2340
movl %eax, 0x10(%rbx)
movb 0x15(%r14), %al
movb %al, 0xe(%rbx)
movb %bpl, 0x14(%r14)
leaq 0x11(%r14), %rdi
leaq 0xa(%rbx), %rdx
leaq 0xe2c2(%rip), %r15      # 0x1cec7
movq %r15, %rsi
xorl %eax, %eax
callq 0x2200
movb 0x10(%r14), %al
movb %al, 0x9(%rbx)
movb %bpl, 0x10(%r14)
leaq 0xc(%r14), %rdi
leaq 0x4(%rbx), %rdx
movq %r15, %rsi
xorl %eax, %eax
callq 0x2200
movb %bpl, 0xb(%r14)
addq $0x6, %r14
movq %r14, %rdi
callq 0x2340
movl %eax, (%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq