// File: /workspace/github_c_makefile_star2_O0/hughbarney[P]pEmacs/buffer.c
// Function: bfind
BUFFER* bfind (char *bname, int cflag, int bflag)
{
  BUFFER *bp, *sb;
  LINE *lp;

  bp = bheadp;
  while (bp != 0)
    {
      if (strcmp (bname, bp->b_bname) == 0)
	{
	  if ((bp->b_flag & BFTEMP) != 0)
	    {
	      mlwrite ("Cannot select builtin buffer");
	      return (0);
	    }
	  return (bp);
	}
      bp = bp->b_bufp;
    }
  if (cflag != FALSE)
    {
      if ((bp = (BUFFER *) malloc (sizeof (BUFFER))) == NULL)
	return (0);
      if ((lp = lalloc (0)) == NULL)
	{
	  free (bp);
	  return (BUFFER*)0;
	}
      /* find the place in the list to insert this buffer */
      if (bheadp == NULL || strcmp (bheadp->b_bname, bname) > 0)
	{
	  /* insert at the begining */
	  bp->b_bufp = bheadp;
	  bheadp = bp;
	}
      else
	{
	  sb = bheadp;
	  while (sb->b_bufp != 0)
	    {
	      if (strcmp (sb->b_bufp->b_bname, bname) > 0)
		break;
	      sb = sb->b_bufp;
	    }

	  /* and insert it */
	  bp->b_bufp = sb->b_bufp;
	  sb->b_bufp = bp;
	}

      /* and set up the other buffer fields */
      bp->b_active = TRUE;
      bp->b_dotp = lp;
      bp->b_doto = 0;
      bp->b_markp = 0;
      bp->b_marko = 0;
      bp->b_flag = (char)bflag;
      bp->b_nwnd = 0;
      bp->b_linep = lp;
      strncpy (bp->b_fname, "", 1);
      strncpy (bp->b_bname, bname, NBUFN);
      lp->l_fp = lp;
      lp->l_bp = lp;
    }
  return (bp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
leaq 0xd967(%rip), %rax      # 0x10b40
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x3245
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x83, %rsi
callq 0x2180
cmpl $0x0, %eax
jne 0x3238
movq -0x20(%rbp), %rax
movsbl 0x32(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x322b
leaq 0x8e73(%rip), %rdi      # 0xc08a
movb $0x0, %al
callq 0x56d0
movq $0x0, -0x8(%rbp)
jmp 0x33eb
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x33eb
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x31e0
cmpl $0x0, -0x14(%rbp)
je 0x33e3
movl $0x98, %edi
callq 0x21c0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x3270
movq $0x0, -0x8(%rbp)
jmp 0x33eb
xorl %edi, %edi
movb $0x0, %al
callq 0x6b00
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x3299
movq -0x20(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
jmp 0x33eb
leaq 0xd8a0(%rip), %rax      # 0x10b40
cmpq $0x0, (%rax)
je 0x32c5
leaq 0xd893(%rip), %rax      # 0x10b40
movq (%rax), %rdi
addq $0x83, %rdi
movq -0x10(%rbp), %rsi
callq 0x2180
cmpl $0x0, %eax
jle 0x32e6
leaq 0xd874(%rip), %rax      # 0x10b40
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
leaq 0xd85f(%rip), %rax      # 0x10b40
movq %rcx, (%rax)
jmp 0x3342
leaq 0xd853(%rip), %rax      # 0x10b40
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x3329
movq -0x28(%rbp), %rax
movq (%rax), %rdi
addq $0x83, %rdi
movq -0x10(%rbp), %rsi
callq 0x2180
cmpl $0x0, %eax
jle 0x331c
jmp 0x3329
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x32f4
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x30(%rax)
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x20(%rax)
movl -0x18(%rbp), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x32(%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x31(%rax)
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rdi
addq $0x33, %rdi
leaq 0x9530(%rip), %rsi      # 0xc8d9
movl $0x1, %edx
callq 0x2070
movq -0x20(%rbp), %rdi
addq $0x83, %rdi
movq -0x10(%rbp), %rsi
movl $0x10, %edx
callq 0x2070
movq -0x30(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)