// File: /workspace/github_c_makefile_star2_O3/pipde[P]deos-songlib/utils/processtab/tabparser.c
// Function: parseCourse
ASTCourse *
parseCourse(FILE *in)
    {
    ASTCourse *c = newASTCourse();
    ASTMeasure *m;
    char ch;
    char buffer[AST_COURSE_NAME_LENGTH_MAX];
    int index = 0;
    
    /* expect and consume first pipe character */
    ch = fgetc(in);
    if (ch != '|')
        {
        Fatal("expected '|', found '%c'\n", ch);
        return 0;
        }
    
    while ((ch = fgetc(in)) && ch != '|')
        {
            if (index == AST_COURSE_NAME_LENGTH_MAX - 1)
                {
                Fatal("course name cannot be longer than %i characters\n", AST_COURSE_NAME_LENGTH_MAX - 1);
                return 0;
                }
            if (ch == EOF)
                {
                Fatal("unexpected EOF reading course name\n");
                return 0;
                }
            if (ch == '\n')
                {
                Fatal("unexpected newline reading course name\n");
                return 0;
                }

            buffer[index++] = ch;
        }
        
    buffer[index] = '\0';
    c->name = trimWhiteSpace(buffer);
    
    /* loop over measures */
    while ((ch = peekChar(in)) && ch != EOF && ch != '\n')
        {
        m = parseMeasure(in);
        if (m == 0) return 0;
        
        addASTMeasureToASTCourse(m, c);              
        }
    
    /* expect newline or EOF, and consume newline */
    if (ch == '\n') fgetc(in);
    else if (ch != EOF)
        {
        Fatal("unexpected '%c'\n", ch);
        return 0;
        }
     
    return c;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %r14
movl $0x18, %edi
callq 0x5257
movq %rax, %rbx
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
movq %r14, %rdi
callq 0x10e0
shll $0x18, %eax
cmpl $0x7c000000, %eax       # imm = 0x7C000000
jne 0x37e9
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x10e0
movl %eax, %ecx
shll $0x18, %ecx
je 0x3803
cmpl $0x7c000000, %ecx       # imm = 0x7C000000
je 0x3803
cmpq $0xff, %r15
je 0x38aa
cmpl $0xa000000, %ecx        # imm = 0xA000000
je 0x38bd
cmpl $0xff000000, %ecx       # imm = 0xFF000000
je 0x38c6
movb %al, (%rsp,%r15)
incq %r15
jmp 0x37a4
sarl $0x18, %eax
leaq 0x38dc(%rip), %rdi      # 0x70cf
xorl %ebx, %ebx
movl %eax, %esi
xorl %eax, %eax
callq 0x5138
jmp 0x38f4
movb $0x0, (%rsp,%r15)
movq %rsp, %rdi
callq 0x34b8
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x10e0
movl %eax, %r15d
movsbl %r15b, %ebp
movl %ebp, %edi
movq %r14, %rsi
callq 0x1160
testb %r15b, %r15b
je 0x38d8
movzbl %r15b, %eax
cmpl $0xa, %eax
je 0x38e8
cmpl $0xff, %eax
je 0x38f4
movq %r14, %rdi
callq 0x3907
testq %rax, %rax
je 0x38f2
movq %rax, %r15
movq 0x8(%rbx), %r12
movl 0x10(%rbx), %eax
leal 0x8(,%rax,8), %edi
callq 0x5257
movq %rax, 0x8(%rbx)
movslq 0x10(%rbx), %rcx
testq %rcx, %rcx
jle 0x389b
xorl %eax, %eax
movq (%r12,%rax,8), %rdx
movq 0x8(%rbx), %rsi
movq %rdx, (%rsi,%rax,8)
incq %rax
cmpq %rax, %rcx
jne 0x3883
movq 0x8(%rbx), %rax
movq %r15, (%rax,%rcx,8)
leal 0x1(%rcx), %eax
movl %eax, 0x10(%rbx)
jmp 0x3813
leaq 0x3838(%rip), %rdi      # 0x70e9
xorl %ebx, %ebx
movl $0xff, %esi
jmp 0x37f7
leaq 0x387a(%rip), %rdi      # 0x713e
jmp 0x38cd
leaq 0x384d(%rip), %rdi      # 0x711a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x5138
jmp 0x38f4
leaq 0x37df(%rip), %rdi      # 0x70be
xorl %ebx, %ebx
movl %ebp, %esi
jmp 0x37f7
movq %r14, %rdi
callq 0x10e0
jmp 0x38f4
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq