// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/phrases/phrases.c
// Function: main
int
main(int argc,char **argv)
    {
    int i;
    int argIndex = 1;
    int phrase;
    FILE *out;
    char buffer[512];

    argIndex = processOptions(argc,argv);

    if (argc-argIndex < 1)
        Fatal("usage: %s BASENAME_1 BASENAME_2 ...\n",argv[0]);

    out = OpenFile("vocals-temp.c","w");

    banksize = argc - argIndex;
    if (banksize > BANK_CAPACITY)
        Fatal("a maximum of %d takes are allowed\n",BANK_CAPACITY);

    for (i = 0; i < banksize; ++i)
         {
         banks[i] = argv[i+argIndex];
         indices[i] = 0;
         }

    prelude(out,banks[0]);

    phrase = 0;
    while (1)
        {
        printf("Phrase %d choices:\n",phrase);
        for (i = 0; i < banksize; ++i)
            {
            if (!Silent)
                {
                printf("%d: playing %s%d.rra\n",i+1,banks[i],indices[i]);
                sprintf(buffer,"rplay %s%d.%s",banks[i],indices[i],Mode);
                system(buffer);
                }
            else
                printf("%d: %s%d.rra\n",i+1,banks[i],indices[i]);
            }
        char *command;
        printf("> ");
        command = readToken(stdin);
        if (*command == 'r' && command[1] == '\0')
            {
            printf("repeating...\n");
            }
        else if (*command == 'b' && command[1] == '\0')
            {
            if (phrase == 0)
                printf("already at the first phrase...\n");
            else
                {
                printf("backing up one phrase...\n");
                for (i = 0; i < banksize; ++i)
                    if (indices[i] > 0)
                        indices[i] -= 1;
                --phrase;
                }
            }
        else if (*command == 'f' && command[1] == '\0')
            {
            printf("skipping this phrase...\n");
            for (i = 0; i < banksize; ++i)
                if (indices[i] > 0)
                    indices[i] += 1;
            ++phrase;
            }
        else if (*command == '<' || command[1] == '<')
            {
            int i = *command == '<'? atoi(command+1) : atoi(command);
            if (i > 0 && i <= banksize && indices[i-1] > 0)
                {
                printf("shifting version %d back one phrase...\n",i);
                indices[i-1] -= 1;
                }
            else
                printf("command %s ignored...\n",command);
            }
        else if (*command == '>' || command[1] == '>')
            {
            int i = *command == '>'? atoi(command+1) : atoi(command);
            if (i > 0 && i <= banksize)
                {
                printf("shifting version %d forward one phrase...\n",i);
                indices[i-1] += 1;
                }
            else
                printf("command %s ignored...\n",command);
            }
        else if (isdigit(*command) && command[1] == '\0')
            {
            int take = atoi(command);
            if (take > 0 && take <= banksize)
                {
                printf("selecting version %d\n",take);
                /* clear the newline */
                readLine(stdin);
                if (Comments)
                    {
                    printf("enter a comment: ");
                    comments[phrase] = readLine(stdin);
                    }
                else
                    comments[phrase] = "a phrase";
                takes[phrase] = take;
                notes[phrase] = indices[take-1];
                }
            for (i = 0; i < banksize; ++i)
                indices[i] += 1;
            ++phrase;
            }
        else if (*command == 'q')
            break;
        else
            {
            printf("command %s not understood\n",command);
            printf("commands are:\n");
            printf("   q    quit\n");
            printf("   r    repeat the last phrase\n");
            printf("   b    go back to the previous phrase\n");
            printf("   f    skip forward to the next phrase\n");
            printf("   >N   shift version N forward one phrase\n");
            printf("   <N   shift version N backward one phrase\n");
            printf("   1    choose the first version\n");
            printf("   2    choose the second version\n");
            printf("   ...\n");
            }
        }

    readTimings(banks[0]);
    middle(out);
    coda(out);

    fclose(out);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x1a00
movl %eax, -0x18(%rbp)
movl -0x8(%rbp), %eax
subl -0x18(%rbp), %eax
cmpl $0x1, %eax
jge 0x12df
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x1d89(%rip), %rdi      # 0x3061
movb $0x0, %al
callq 0x28a0
leaq 0x1da0(%rip), %rdi      # 0x3086
leaq 0x1da7(%rip), %rsi      # 0x3094
callq 0x29f0
movq %rax, -0x28(%rbp)
movl -0x8(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, 0x4dfe(%rip)      # 0x6100
cmpl $0x5, 0x4df7(%rip)      # 0x6100
jle 0x131e
leaq 0x1d84(%rip), %rdi      # 0x3096
movl $0x5, %esi
movb $0x0, %al
callq 0x28a0
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x4dd2(%rip), %eax      # 0x6100
jge 0x136d
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movslq -0x14(%rbp), %rcx
leaq 0x4dc4(%rip), %rax      # 0x6110
movq %rdx, (%rax,%rcx,8)
movslq -0x14(%rbp), %rcx
leaq 0x4de5(%rip), %rax      # 0x6140
movl $0x0, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1325
movq -0x28(%rbp), %rdi
movq 0x4d98(%rip), %rsi      # 0x6110
callq 0x1bf0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %esi
leaq 0x1d2b(%rip), %rdi      # 0x30b9
movb $0x0, %al
callq 0x1080
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x4d5b(%rip), %eax      # 0x6100
jge 0x146d
cmpl $0x0, 0x4d52(%rip)      # 0x6104
jne 0x142c
movl -0x14(%rbp), %esi
addl $0x1, %esi
movslq -0x14(%rbp), %rcx
leaq 0x4d4b(%rip), %rax      # 0x6110
movq (%rax,%rcx,8), %rdx
movslq -0x14(%rbp), %rcx
leaq 0x4d6c(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %ecx
leaq 0x1cef(%rip), %rdi      # 0x30cd
movb $0x0, %al
callq 0x1080
leaq -0x230(%rbp), %rdi
movslq -0x14(%rbp), %rcx
leaq 0x4d19(%rip), %rax      # 0x6110
movq (%rax,%rcx,8), %rdx
movslq -0x14(%rbp), %rcx
leaq 0x4d3a(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %ecx
leaq 0x1cd3(%rip), %rsi      # 0x30e3
leaq 0x1cda(%rip), %r8       # 0x30f1
movb $0x0, %al
callq 0x1160
leaq -0x230(%rbp), %rdi
callq 0x1070
jmp 0x145d
movl -0x14(%rbp), %esi
addl $0x1, %esi
movslq -0x14(%rbp), %rcx
leaq 0x4cd3(%rip), %rax      # 0x6110
movq (%rax,%rcx,8), %rdx
movslq -0x14(%rbp), %rcx
leaq 0x4cf4(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %ecx
leaq 0x1c9f(%rip), %rdi      # 0x30f5
movb $0x0, %al
callq 0x1080
jmp 0x145f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x139c
leaq 0x1c8f(%rip), %rdi      # 0x3103
movb $0x0, %al
callq 0x1080
movq 0x4b56(%rip), %rax      # 0x5fd8
movq (%rax), %rdi
callq 0x2600
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
jne 0x14c3
movq -0x238(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x14c3
leaq 0x1c4f(%rip), %rdi      # 0x3106
movb $0x0, %al
callq 0x1080
jmp 0x19c4
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x62, %eax
jne 0x1563
movq -0x238(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x1563
cmpl $0x0, -0x1c(%rbp)
jne 0x14fc
leaq 0x1c21(%rip), %rdi      # 0x3114
movb $0x0, %al
callq 0x1080
jmp 0x155e
leaq 0x1c31(%rip), %rdi      # 0x3134
movb $0x0, %al
callq 0x1080
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x4be6(%rip), %eax      # 0x6100
jge 0x1555
movslq -0x14(%rbp), %rcx
leaq 0x4c19(%rip), %rax      # 0x6140
cmpl $0x0, (%rax,%rcx,4)
jle 0x1548
movslq -0x14(%rbp), %rcx
leaq 0x4c08(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %edx
subl $0x1, %edx
leaq 0x4bfb(%rip), %rax      # 0x6140
movl %edx, (%rax,%rcx,4)
jmp 0x154a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1511
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x19c2
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x66, %eax
jne 0x15e9
movq -0x238(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x15e9
leaq 0x1bc5(%rip), %rdi      # 0x314e
movb $0x0, %al
callq 0x1080
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x4b60(%rip), %eax      # 0x6100
jge 0x15db
movslq -0x14(%rbp), %rcx
leaq 0x4b93(%rip), %rax      # 0x6140
cmpl $0x0, (%rax,%rcx,4)
jle 0x15ce
movslq -0x14(%rbp), %rcx
leaq 0x4b82(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x4b75(%rip), %rax      # 0x6140
movl %edx, (%rax,%rcx,4)
jmp 0x15d0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1597
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x19c0
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3c, %eax
je 0x160c
movq -0x238(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3c, %eax
jne 0x16d4
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3c, %eax
jne 0x1633
movq -0x238(%rbp), %rdi
addq $0x1, %rdi
callq 0x1150
movl %eax, -0x248(%rbp)
jmp 0x1645
movq -0x238(%rbp), %rdi
callq 0x1150
movl %eax, -0x248(%rbp)
movl -0x248(%rbp), %eax
movl %eax, -0x23c(%rbp)
cmpl $0x0, -0x23c(%rbp)
jle 0x16ba
movl -0x23c(%rbp), %eax
cmpl 0x4a9a(%rip), %eax      # 0x6100
jg 0x16ba
movl -0x23c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x4ac5(%rip), %rax      # 0x6140
cmpl $0x0, (%rax,%rcx,4)
jle 0x16ba
movl -0x23c(%rbp), %esi
leaq 0x1ad9(%rip), %rdi      # 0x3167
movb $0x0, %al
callq 0x1080
movl -0x23c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x4a98(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %edx
subl $0x1, %edx
leaq 0x4a8b(%rip), %rax      # 0x6140
movl %edx, (%rax,%rcx,4)
jmp 0x16cf
movq -0x238(%rbp), %rsi
leaq 0x1ac7(%rip), %rdi      # 0x318f
movb $0x0, %al
callq 0x1080
jmp 0x19be
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
je 0x16f7
movq -0x238(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3e, %eax
jne 0x17a6
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x171e
movq -0x238(%rbp), %rdi
addq $0x1, %rdi
callq 0x1150
movl %eax, -0x24c(%rbp)
jmp 0x1730
movq -0x238(%rbp), %rdi
callq 0x1150
movl %eax, -0x24c(%rbp)
movl -0x24c(%rbp), %eax
movl %eax, -0x240(%rbp)
cmpl $0x0, -0x240(%rbp)
jle 0x178c
movl -0x240(%rbp), %eax
cmpl 0x49af(%rip), %eax      # 0x6100
jg 0x178c
movl -0x240(%rbp), %esi
leaq 0x1a46(%rip), %rdi      # 0x31a6
movb $0x0, %al
callq 0x1080
movl -0x240(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x49c6(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x49b9(%rip), %rax      # 0x6140
movl %edx, (%rax,%rcx,4)
jmp 0x17a1
movq -0x238(%rbp), %rsi
leaq 0x19f5(%rip), %rdi      # 0x318f
movb $0x0, %al
callq 0x1080
jmp 0x19bc
callq 0x1180
movq (%rax), %rax
movq -0x238(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x1903
movq -0x238(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x1903
movq -0x238(%rbp), %rdi
callq 0x1150
movl %eax, -0x244(%rbp)
cmpl $0x0, -0x244(%rbp)
jle 0x18bd
movl -0x244(%rbp), %eax
cmpl 0x48f4(%rip), %eax      # 0x6100
jg 0x18bd
movl -0x244(%rbp), %esi
leaq 0x19b2(%rip), %rdi      # 0x31d1
movb $0x0, %al
callq 0x1080
movq 0x47ab(%rip), %rax      # 0x5fd8
movq (%rax), %rdi
callq 0x2710
cmpl $0x0, 0x48ac(%rip)      # 0x60e8
je 0x186f
leaq 0x19a2(%rip), %rdi      # 0x31e7
movb $0x0, %al
callq 0x1080
movq 0x4785(%rip), %rax      # 0x5fd8
movq (%rax), %rdi
callq 0x2710
movq %rax, %rdx
movslq -0x1c(%rbp), %rcx
leaq 0x50d7(%rip), %rax      # 0x6940
movq %rdx, (%rax,%rcx,8)
jmp 0x1885
movslq -0x1c(%rbp), %rcx
leaq 0x50c6(%rip), %rax      # 0x6940
leaq 0x1978(%rip), %rdx      # 0x31f9
movq %rdx, (%rax,%rcx,8)
movl -0x244(%rbp), %edx
movslq -0x1c(%rbp), %rcx
leaq 0x60aa(%rip), %rax      # 0x7940
movl %edx, (%rax,%rcx,4)
movl -0x244(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x4894(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %edx
movslq -0x1c(%rbp), %rcx
leaq 0x6886(%rip), %rax      # 0x8140
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x4833(%rip), %eax      # 0x6100
jge 0x18f5
movslq -0x14(%rbp), %rcx
leaq 0x4866(%rip), %rax      # 0x6140
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x4859(%rip), %rax      # 0x6140
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x18c4
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x19ba
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x71, %eax
jne 0x1917
jmp 0x19c9
movq -0x238(%rbp), %rsi
leaq 0x18dd(%rip), %rdi      # 0x3202
movb $0x0, %al
callq 0x1080
leaq 0x18ea(%rip), %rdi      # 0x321d
movb $0x0, %al
callq 0x1080
leaq 0x18eb(%rip), %rdi      # 0x322c
movb $0x0, %al
callq 0x1080
leaq 0x18eb(%rip), %rdi      # 0x323a
movb $0x0, %al
callq 0x1080
leaq 0x18fd(%rip), %rdi      # 0x325a
movb $0x0, %al
callq 0x1080
leaq 0x1917(%rip), %rdi      # 0x3282
movb $0x0, %al
callq 0x1080
leaq 0x1932(%rip), %rdi      # 0x32ab
movb $0x0, %al
callq 0x1080
leaq 0x1950(%rip), %rdi      # 0x32d7
movb $0x0, %al
callq 0x1080
leaq 0x196f(%rip), %rdi      # 0x3304
movb $0x0, %al
callq 0x1080
leaq 0x1983(%rip), %rdi      # 0x3326
movb $0x0, %al
callq 0x1080
leaq 0x1998(%rip), %rdi      # 0x3349
movb $0x0, %al
callq 0x1080
jmp 0x19ba
jmp 0x19bc
jmp 0x19be
jmp 0x19c0
jmp 0x19c2
jmp 0x19c4
jmp 0x1384
movq 0x4740(%rip), %rdi      # 0x6110
callq 0x1de0
movq -0x28(%rbp), %rdi
callq 0x1ec0
movq -0x28(%rbp), %rdi
callq 0x1fd0
movq -0x28(%rbp), %rdi
callq 0x1050
xorl %eax, %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopl (%rax,%rax)