// File: /workspace/github_c_makefile_star2_O0/mmayer[P]pcal/src/pcalutil.c
// Function: get_pcal_line
int get_pcal_line (FILE *fp, char *buf, int *pline)
{
   register char *cp;
   register int c, c2;
   int in_comment;   /* comments: from '#' to end-of-line */
   char tmpbuf[LINSIZ];   /* temporary buffer to accumulate line */

   cp = tmpbuf;
   *buf = '\0';   /* in case of premature EOF */
   
   do {
      in_comment = FALSE;
      while ((c = getc(fp)) != '\n' && c != EOF) {
         if (c == COMMENT_CHAR) in_comment = TRUE;
         
         if (isspace(c)) c = ' ';   /* whitespace => blank */
         
         /* ignore comments and leading white space */
         if (in_comment || (cp == tmpbuf && c == ' ')) continue;
         
         /* only handle escape newlines and '#' here; other escapes are now
            handled by cvt_escape() or loadwords() (q.v.)
         */
         if (c == '\\') {
            if ((c2 = getc(fp)) == EOF) return FALSE;

            if (c2 == '\n') {
               c = ' ';
               (*pline)++;
            }
            else if (c2 == COMMENT_CHAR) c = '#';
            else ungetc(c2, fp);
         }
         
         /* 
            Crudely prevent buffer overflow to prevent exploit by malicious
            calendar input file.
         */
         if ((cp - tmpbuf) < (LINSIZ - 1)) *cp++ = c;
         else return FALSE;
      }

      if (c == EOF) {
         /* 
            15 Dec 2007: 

            Prior to the 4.11.0 release, the code just returned 'FALSE' here,
            with no other test being performed.

            That was causing a bug whereby the last line of a configuration
            file was silently ignored if it ended without a 'line feed' (ASCII
            10 character).

            Adding a test, as done below, to see if anything is in the line
            buffer (before deciding to return 'FALSE') fixes this bug.

         */
         if ((cp - tmpbuf) == 0) return FALSE;    /* no more input lines */
      }

      (*pline)++;   /* bump line number */
      
   } while (cp == tmpbuf);   /* ignore empty lines */

   *cp = '\0';
   cvt_escape(buf, tmpbuf);   /* convert escape sequences */
   return TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x240(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rdi
callq 0x52d0
movl %eax, %ecx
movl %ecx, -0x2c(%rbp)
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x241(%rbp)
je 0xd368
cmpl $-0x1, -0x2c(%rbp)
setne %al
movb %al, -0x241(%rbp)
movb -0x241(%rbp), %al
testb $0x1, %al
jne 0xd377
jmp 0xd45e
cmpl $0x23, -0x2c(%rbp)
jne 0xd384
movl $0x1, -0x34(%rbp)
callq 0x52e0
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0xd3a5
movl $0x20, -0x2c(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0xd3c1
movq -0x28(%rbp), %rax
leaq -0x240(%rbp), %rcx
cmpq %rcx, %rax
jne 0xd3c6
cmpl $0x20, -0x2c(%rbp)
jne 0xd3c6
jmp 0xd340
cmpl $0x5c, -0x2c(%rbp)
jne 0xd422
movq -0x10(%rbp), %rdi
callq 0x52d0
movl %eax, -0x30(%rbp)
cmpl $-0x1, %eax
jne 0xd3e9
movl $0x0, -0x4(%rbp)
jmp 0xd4c0
cmpl $0xa, -0x30(%rbp)
jne 0xd403
movl $0x20, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0xd420
cmpl $0x23, -0x30(%rbp)
jne 0xd412
movl $0x23, -0x2c(%rbp)
jmp 0xd41e
movl -0x30(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x5210
jmp 0xd420
jmp 0xd422
movq -0x28(%rbp), %rax
leaq -0x240(%rbp), %rcx
subq %rcx, %rax
cmpq $0x1ff, %rax            # imm = 0x1FF
jge 0xd450
movl -0x2c(%rbp), %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0xd459
movl $0x0, -0x4(%rbp)
jmp 0xd4c0
jmp 0xd340
cmpl $-0x1, -0x2c(%rbp)
jne 0xd483
movq -0x28(%rbp), %rax
leaq -0x240(%rbp), %rcx
subq %rcx, %rax
cmpq $0x0, %rax
jne 0xd481
movl $0x0, -0x4(%rbp)
jmp 0xd4c0
jmp 0xd483
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
leaq -0x240(%rbp), %rcx
cmpq %rcx, %rax
je 0xd339
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0xcb30
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopl (%rax)