// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/processtab/tabparser.c
// Function: parseStave
ASTStave *
parseStave(FILE *in)
    {
    ASTStave *s = newASTStave();
    ASTCourse *c = 0;
    int i, j;
    char ch;
    
    /* parseCourse consumes newline for each line, so if another is found, the stave is finished */
    while ((ch = peekChar(in)) && ch != EOF && ch != '\n')
        {
        c = parseCourse(in);
        if (c == 0) return 0;
                
        /* timing course is the last course in each stave */
        if (strcmp(c->name, "") == 0)
            {
            s->timingCourse = c;
            ch = peekChar(in);
            break;
            }   
        
        /* this is a regular course */
        addASTCourseToASTStave(c, s);              
        }
       
    if (s->timingCourse == 0)
        {
        Fatal("timing course not found in stave\n");
        return 0;
        }  
     
    for (i = 0; i < s->courseCount; i++)
        {
        c = s->courses[i];
        
        /* check measure counts against timing course */
        if (c->measureCount != s->timingCourse->measureCount)
            {
            Fatal("course '%s' has %i measures; timing course has %i measures\n", c->name, c->measureCount, s->timingCourse->measureCount);
            return 0;
            }
            
        /* check measure lengths against timing course */
        for (j = 0; j < c->measureCount; j++)
            {
            if (strlen(c->measures[j]->events) != strlen(s->timingCourse->measures[j]->events))
                {
                Fatal("course '%s' measure has length %i; timing course measure has length %i\n", 
                        c->name, strlen(c->measures[j]->events), strlen(s->timingCourse->measures[j]->events));
                return 0;
                }
            }
        }
    
    /* expect newline or EOF */    
    if (ch != '\n' && ch != EOF)
        {
        /* another course found */  
        if (ch == '|') Fatal("timing course is not the last course in stave\n");
        else Fatal("unexpected '%c'\n", ch);
        return 0;
        }
        
    return s;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
callq 0x3300
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x34c0
movb %al, -0x29(%rbp)
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2a(%rbp)
je 0x37a1
movsbl -0x29(%rbp), %ecx
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0x2a(%rbp)
je 0x37a1
movsbl -0x29(%rbp), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
testb $0x1, %al
jne 0x37aa
jmp 0x380f
movq -0x10(%rbp), %rdi
callq 0x4270
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x37cb
movq $0x0, -0x8(%rbp)
jmp 0x39d7
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x3a16(%rip), %rsi      # 0x71ef
callq 0x10e0
cmpl $0x0, %eax
jne 0x37fd
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
callq 0x34c0
movb %al, -0x29(%rbp)
jmp 0x380f
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4490
jmp 0x376d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x3835
leaq 0x47e9(%rip), %rdi      # 0x800a
movb $0x0, %al
callq 0x63e0
movq $0x0, -0x8(%rbp)
jmp 0x39d7
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x3988
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0x10(%rcx), %eax
je 0x38a7
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x10(%rax), %ecx
leaq 0x4799(%rip), %rdi      # 0x802c
movb $0x0, %al
callq 0x63e0
movq $0x0, -0x8(%rbp)
jmp 0x39d7
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x3978
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rdi
callq 0x1060
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rdi
callq 0x1060
movq %rax, %rcx
movq -0x38(%rbp), %rax
cmpq %rcx, %rax
je 0x3968
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rdi
callq 0x1060
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rdi
callq 0x1060
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rax, %rcx
leaq 0x4711(%rip), %rdi      # 0x8068
movb $0x0, %al
callq 0x63e0
movq $0x0, -0x8(%rbp)
jmp 0x39d7
jmp 0x396a
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x38ae
jmp 0x397a
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x383c
movsbl -0x29(%rbp), %eax
cmpl $0xa, %eax
je 0x39cf
movsbl -0x29(%rbp), %eax
cmpl $-0x1, %eax
je 0x39cf
movsbl -0x29(%rbp), %eax
cmpl $0x7c, %eax
jne 0x39b3
leaq 0x4706(%rip), %rdi      # 0x80b0
movb $0x0, %al
callq 0x63e0
jmp 0x39c5
movsbl -0x29(%rbp), %esi
leaq 0x4721(%rip), %rdi      # 0x80df
movb $0x0, %al
callq 0x63e0
movq $0x0, -0x8(%rbp)
jmp 0x39d7
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)