// File: /workspace/github_c_makefile_star2_O0/JimKent[P]linearSat/linearSat/linearSat.c
// Function: findNeighborhoodFromReads
struct monomerRef *findNeighborhoodFromReads(struct monomer *center)
/* Find if possible one monomer to either side of center */
{
struct slRef *readRef;
struct monomerRef *before = NULL, *after = NULL;

/* Loop through reads hoping to find a case where center is flanked by two monomers in
 * same read.   As a fallback, keep track of a monomer before and a monomer after in
 * any read. */
for (readRef = center->readList; readRef != NULL; readRef = readRef->next)
    {
    struct alphaRead *read = readRef->val;
    int readSize = slCount(read->list);
    int centerIx = monomerRefIx(read->list, center);
    if (readSize >= 3 && centerIx > 0 && centerIx < readSize-1)
	 {
	 before = slElementFromIx(read->list, centerIx-1);
	 after = slElementFromIx(read->list, centerIx+1);
	 break;
	 }
    else if (readSize >= 2)
         {
	 if (centerIx == 0)
	     after = slElementFromIx(read->list, centerIx+1);
	 else
	     before = slElementFromIx(read->list, centerIx-1);
	 }
    }

/* Make up list from end to start. */
struct monomerRef *retList = NULL, *monoRef;
if (after)
    {
    AllocVar(monoRef);
    monoRef->val = after->val;
    slAddHead(&retList, monoRef);
    }
AllocVar(monoRef);
monoRef->val = center;
slAddHead(&retList, monoRef);
if (before)
    {
    AllocVar(monoRef);
    monoRef->val = before->val;
    slAddHead(&retList, monoRef);
    }
return retList;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4c8e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x78f0
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x4b10
movl %eax, -0x30(%rbp)
cmpl $0x3, -0x2c(%rbp)
jl 0x4c3c
cmpl $0x0, -0x30(%rbp)
jle 0x4c3c
movl -0x30(%rbp), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x4c3c
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x30(%rbp), %esi
subl $0x1, %esi
callq 0x7930
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x30(%rbp), %esi
addl $0x1, %esi
callq 0x7930
movq %rax, -0x20(%rbp)
jmp 0x4c8e
cmpl $0x2, -0x2c(%rbp)
jl 0x4c7a
cmpl $0x0, -0x30(%rbp)
jne 0x4c61
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x30(%rbp), %esi
addl $0x1, %esi
callq 0x7930
movq %rax, -0x20(%rbp)
jmp 0x4c78
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x30(%rbp), %esi
subl $0x1, %esi
callq 0x7930
movq %rax, -0x18(%rbp)
jmp 0x4c7a
jmp 0x4c7c
jmp 0x4c7e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x4bb8
movq $0x0, -0x38(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4cc8
movl $0x10, %edi
callq 0x152f0
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x39e0
movl $0x10, %edi
callq 0x152f0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x39e0
cmpq $0x0, -0x18(%rbp)
je 0x4d21
movl $0x10, %edi
callq 0x152f0
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x39e0
movq -0x38(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)