// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/DAStrim.c
// Function: find_walls
static Wall *find_walls(int novl, Event *queue, int *anum, int *dnum)
{ static int   nmax = 0;

  Wall        *aptr, *dptr;
  static Wall *wall = NULL;

  int          ntip;
  static int  *adds = NULL;
  static int  *dels;

  if (novl == 0)
    return (NULL);

  if (novl > nmax)
    { nmax = novl*1.2 + 1000; 
      wall = (Wall *) Realloc(wall,sizeof(Wall)*2*(nmax/MIN_PNT),"Reallocating wall vector");
      adds = (int *)  Realloc(adds,sizeof(int)*2*nmax,"Reallocating add+del vectors");
      if (wall == NULL || adds == NULL)
        exit (1);
      dels = adds + nmax;
    }

  //  Make separate arrays of add and del tips (LFT and RGT events) in sorted order in
  //    which to seek "walls".

  { int i, j, x;

    i = x = 0;                      //  A bit tricky: less than novl tips due to CTR events
    for (j = 0; x < novl; j++)      //   that don't generate tips, so analyze events until
      if (queue[j].type == CTR)     //   have counted all LA's.  Furthermore adds and dels
        x += 1;                     //   are sorted because queue is sorted.
      else if (queue[j].type == LFT)
        { x += 1;
          adds[i++] = queue[j].pos;
        }
    ntip = i;

    i = 0;
    for (j = 0; i < ntip; j++)
      if (queue[j].type == RGT)
        dels[i++] = queue[j].pos;
  }

  //  Find LFT walls and RGT walls in [walls,aptr) and [aptr,dptr)

  aptr = wall_detector(adds,0,ntip,wall);
  dptr = wall_detector(dels,0,ntip,aptr);

  //  For each wall, determine the coverage of its base with a merged traversal
  //    of the adds and dels arrays

  { Wall *a, *d;
    int   i, j, x;

    x = 0;
    a = wall;
    d = aptr;;
    i = j = 0;
    while (j < ntip)
      if (i < ntip && adds[i] < dels[j])
        { if (a->beg == i)
            a->cov = x;
          else if (a->end == i+1)
            { a += 1;
              if (a >= aptr)
                a -= 1;
            }
          x += 1;
          i += 1;
        }
      else
        { if (d->beg == j)
            d->cov = x - d->cnt;
          else if (d->end == j+1)
            { d += 1;
              if (d >= dptr)
                d -= 1;
            }
          x -= 1;
          j += 1;
        }
  }
  
  //  Sneaky, switch beg/end from an index into the adds or dels array, to the actually
  //    coordinate of the event.

  { Wall *a;

    for (a = wall; a < aptr; a++)
      { a->beg = adds[a->beg];
        a->end = adds[a->end-1];
      }
    for (a = aptr; a < dptr; a++)
      { a->beg = dels[a->beg];
        a->end = dels[a->end-1];
      }
  }

  *anum = aptr-wall;
  *dnum = dptr-aptr;
  return (wall);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x77ba
movq $0x0, -0x8(%rbp)
jmp 0x7ba3
movl -0xc(%rbp), %eax
cmpl 0x29e6d(%rip), %eax     # 0x31630
jle 0x787e
cvtsi2sdl -0xc(%rbp), %xmm0
movsd 0x2484a(%rip), %xmm1    # 0x2c020
mulsd %xmm1, %xmm0
movsd 0x24856(%rip), %xmm1    # 0x2c038
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x29e40(%rip)     # 0x31630
movq 0x29e41(%rip), %rdi     # 0x31638
movl 0x29e33(%rip), %eax     # 0x31630
movl $0x5, %ecx
cltd
idivl %ecx
movslq %eax, %rsi
shlq $0x5, %rsi
leaq 0x24fb1(%rip), %rdx     # 0x2c7c4
callq 0x20050
movq %rax, 0x29e19(%rip)     # 0x31638
movq 0x29e1a(%rip), %rdi     # 0x31640
movslq 0x29e03(%rip), %rsi     # 0x31630
shlq $0x3, %rsi
leaq 0x24fa5(%rip), %rdx     # 0x2c7dd
callq 0x20050
movq %rax, 0x29dfc(%rip)     # 0x31640
cmpq $0x0, 0x29dec(%rip)     # 0x31638
je 0x7858
cmpq $0x0, 0x29dea(%rip)     # 0x31640
jne 0x7862
movl $0x1, %edi
callq 0x22a0
movq 0x29dd7(%rip), %rax     # 0x31640
movslq 0x29dc0(%rip), %rcx     # 0x31630
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x29dca(%rip)     # 0x31648
movl $0x0, -0x48(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x48(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x78fe
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpl $0x3, (%rax,%rcx,8)
jne 0x78b4
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x78f1
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,8)
jne 0x78ef
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %edx
movq 0x29d62(%rip), %rax     # 0x31640
movl -0x40(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x40(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x78f1
jmp 0x78f3
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7893
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x7959
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpl $0x5, (%rax,%rcx,8)
jne 0x794c
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %edx
movq 0x29d0d(%rip), %rax     # 0x31648
movl -0x40(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x40(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x794e
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7912
movq 0x29ce0(%rip), %rdi     # 0x31640
movl -0x3c(%rbp), %edx
movq 0x29cce(%rip), %rcx     # 0x31638
xorl %esi, %esi
callq 0x7bb0
movq %rax, -0x30(%rbp)
movq 0x29ccc(%rip), %rdi     # 0x31648
movl -0x3c(%rbp), %edx
movq -0x30(%rbp), %rcx
xorl %esi, %esi
callq 0x7bb0
movq %rax, -0x38(%rbp)
movl $0x0, -0x64(%rbp)
movq 0x29c9c(%rip), %rax     # 0x31638
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x7aba
movl -0x5c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x7a4e
movq 0x29c6b(%rip), %rax     # 0x31640
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x29c65(%rip), %rcx     # 0x31648
movslq -0x60(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x7a4e
movq -0x50(%rbp), %rax
movl (%rax), %eax
cmpl -0x5c(%rbp), %eax
jne 0x7a03
movl -0x64(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x7a3a
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movl -0x5c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x7a38
movq -0x50(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0x7a36
movq -0x50(%rbp), %rax
addq $-0x10, %rax
movq %rax, -0x50(%rbp)
jmp 0x7a38
jmp 0x7a3a
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x7ab5
movq -0x58(%rbp), %rax
movl (%rax), %eax
cmpl -0x60(%rbp), %eax
jne 0x7a6c
movl -0x64(%rbp), %ecx
movq -0x58(%rbp), %rax
subl 0x8(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x7aa3
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
movl -0x60(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x7aa1
movq -0x58(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x7a9f
movq -0x58(%rbp), %rax
addq $-0x10, %rax
movq %rax, -0x58(%rbp)
jmp 0x7aa1
jmp 0x7aa3
movl -0x64(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x79b6
movq 0x29b77(%rip), %rax     # 0x31638
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x7b12
movq 0x29b6a(%rip), %rax     # 0x31640
movq -0x70(%rbp), %rcx
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x70(%rbp), %rax
movl %ecx, (%rax)
movq 0x29b53(%rip), %rax     # 0x31640
movq -0x70(%rbp), %rcx
movl 0x4(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x70(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x70(%rbp)
jmp 0x7ac5
movq -0x30(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x7b67
movq 0x29b1d(%rip), %rax     # 0x31648
movq -0x70(%rbp), %rcx
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x70(%rbp), %rax
movl %ecx, (%rax)
movq 0x29b06(%rip), %rax     # 0x31648
movq -0x70(%rbp), %rcx
movl 0x4(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x70(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x70(%rbp)
jmp 0x7b1a
movq -0x30(%rbp), %rax
movq 0x29ac6(%rip), %rcx     # 0x31638
subq %rcx, %rax
sarq $0x4, %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
sarq $0x4, %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq 0x29a99(%rip), %rax     # 0x31638
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)