// File: /workspace/github_c_makefile_star2_O1/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 0x4c71
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 0x37a2
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x10e0
movl %eax, %ecx
shll $0x18, %ecx
je 0x37bc
cmpl $0x7c000000, %ecx       # imm = 0x7C000000
je 0x37bc
cmpq $0xff, %r15
je 0x385f
cmpl $0xa000000, %ecx        # imm = 0xA000000
je 0x3872
cmpl $0xff000000, %ecx       # imm = 0xFF000000
je 0x387b
movb %al, (%rsp,%r15)
incq %r15
jmp 0x375d
sarl $0x18, %eax
leaq 0x2923(%rip), %rdi      # 0x60cf
xorl %ebx, %ebx
movl %eax, %esi
xorl %eax, %eax
callq 0x4b44
jmp 0x38ab
movb $0x0, (%rsp,%r15)
movq %rsp, %rdi
callq 0x3471
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x10e0
movl %eax, %ebp
movsbl %bpl, %edi
movq %r14, %rsi
callq 0x1160
testb %bpl, %bpl
je 0x388d
movzbl %bpl, %eax
cmpl $0xa, %eax
je 0x389f
cmpl $0xff, %eax
je 0x38ab
movq %r14, %rdi
callq 0x38be
testq %rax, %rax
je 0x38a9
movq %rax, %r15
movq 0x8(%rbx), %r12
movl 0x10(%rbx), %eax
leal 0x8(,%rax,8), %edi
callq 0x4c71
movq %rax, 0x8(%rbx)
movslq 0x10(%rbx), %rax
testq %rax, %rax
jle 0x384d
xorl %ecx, %ecx
movq (%r12,%rcx,8), %rdx
movq 0x8(%rbx), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x3839
movq 0x8(%rbx), %rcx
movq %r15, (%rcx,%rax,8)
incl %eax
movl %eax, 0x10(%rbx)
jmp 0x37cc
leaq 0x2883(%rip), %rdi      # 0x60e9
xorl %ebx, %ebx
movl $0xff, %esi
jmp 0x37b0
leaq 0x28c5(%rip), %rdi      # 0x613e
jmp 0x3882
leaq 0x2898(%rip), %rdi      # 0x611a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4b44
jmp 0x38ab
movsbl %bpl, %esi
leaq 0x2826(%rip), %rdi      # 0x60be
xorl %ebx, %ebx
jmp 0x37b0
movq %r14, %rdi
callq 0x10e0
jmp 0x38ab
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq