// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movq %rsi, %r14
movl %edi, %ebx
movl $0x1, %r12d
cmpl $0x2, %edi
jl 0x16c0
movl $0x1, %r12d
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x16c0
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x1639
leaq 0x2(%rsi), %rdi
jmp 0x163e
movq 0x8(%r14,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x72, %eax
jle 0x1661
cmpl $0x73, %eax
je 0x1672
cmpl $0x74, %eax
jne 0x168b
callq 0x1170
movl %eax, 0x4aa8(%rip)      # 0x6104
movb $0x1, %r15b
jmp 0x16a5
cmpl $0x63, %eax
jne 0x1681
movl $0x0, 0x4a90(%rip)      # 0x6100
jmp 0x167c
movl $0x1, 0x4aa8(%rip)      # 0x6124
xorl %r15d, %r15d
jmp 0x16a5
cmpl $0x68, %eax
jne 0x1694
jmp 0x1fb8
cmpl $0x76, %eax
je 0x1f9a
xorl %r15d, %r15d
leaq 0x1d56(%rip), %rdi      # 0x33f4
xorl %eax, %eax
callq 0x2470
testb %r13b, %r13b
sete %al
andb %r15b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
cmpl %ebx, %r12d
jl 0x161a
subl %r12d, %ebx
jle 0x173c
leaq 0x196a(%rip), %rdi      # 0x3036
leaq 0x1971(%rip), %rsi      # 0x3044
callq 0x250a
movq %rax, %r15
movl %ebx, 0x4a3f(%rip)      # 0x6120
cmpl $0x6, %ebx
jb 0x1703
leaq 0x1959(%rip), %rdi      # 0x3046
movl $0x5, %esi
xorl %eax, %eax
callq 0x2470
movl 0x4a21(%rip), %ebx      # 0x6120
testl %ebx, %ebx
jle 0x1737
movslq %r12d, %rcx
movl %ebx, %eax
leaq (%r14,%rcx,8), %rcx
leaq 0x4a4d(%rip), %rdx      # 0x6160
xorl %esi, %esi
leaq 0x4a14(%rip), %rdi      # 0x6130
movq (%rcx,%rsi), %r8
movq %r8, (%rsi,%rdi)
movl $0x0, (%rdx)
addq $0x8, %rsi
addq $0x4, %rdx
decq %rax
jne 0x171c
movq %r15, %r12
jmp 0x1769
movq (%r14), %rsi
leaq 0x18cb(%rip), %rdi      # 0x3011
xorl %eax, %eax
callq 0x2470
leaq 0x18e2(%rip), %rdi      # 0x3036
leaq 0x18e9(%rip), %rsi      # 0x3044
callq 0x250a
movq %rax, %r12
movl %ebx, 0x49b7(%rip)      # 0x6120
leaq 0x1a2c(%rip), %rdi      # 0x319c
movl $0x13, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
leaq 0x1a27(%rip), %rdi      # 0x31b0
movl $0x14, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
leaq 0x1a23(%rip), %rdi      # 0x31c5
movl $0x14, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
leaq 0x1a1f(%rip), %rdi      # 0x31da
movl $0x2d, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
leaq 0x1a34(%rip), %rdi      # 0x3208
movl $0x30, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movl $0xa, %edi
movq %r12, %rsi
callq 0x10c0
leaq 0x1a3f(%rip), %rdi      # 0x3239
movl $0x3c, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
leaq 0x1a63(%rip), %rdi      # 0x3276
movl $0x1f, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
leaq 0x1a6a(%rip), %rdi      # 0x3296
movl $0x20, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movl $0xa, %edi
movq %r12, %rsi
callq 0x10c0
leaq 0x1a65(%rip), %rdi      # 0x32b7
movl $0x1b, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movl $0xa, %edi
movq %r12, %rsi
callq 0x10c0
leaq 0x1a5b(%rip), %rdi      # 0x32d3
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
leaq 0x1a47(%rip), %rdi      # 0x32d8
movl $0x7, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
leaq 0x1a36(%rip), %rdi      # 0x32e0
movl $0x6, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
cmpl $0x0, 0x485d(%rip)      # 0x6120
jle 0x18fc
leaq 0x4864(%rip), %r15      # 0x6130
leaq 0x1a14(%rip), %rbx      # 0x32e7
xorl %r14d, %r14d
incq %r14
movq (%r15), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movl %r14d, %edx
xorl %eax, %eax
callq 0x10e0
movslq 0x482d(%rip), %rax      # 0x6120
addq $0x8, %r15
cmpq %rax, %r14
jl 0x18d6
movl $0xa, %edi
movq %r12, %rsi
callq 0x10c0
leaq 0x1a08(%rip), %rdi      # 0x3318
movl $0x10, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movl $0xa, %edi
movq %r12, %rsi
callq 0x10c0
leaq 0x19f3(%rip), %rdi      # 0x3329
movl $0x17, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movl $0xa, %edi
movq %r12, %rsi
callq 0x10c0
leaq 0x19e5(%rip), %rdi      # 0x3341
movl $0x22, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movl $0xa, %edi
movq %r12, -0x38(%rbp)
movq %r12, %rsi
callq 0x10c0
leaq -0x240(%rbp), %rbx
leaq 0x1718(%rip), %r14      # 0x30a5
movl $0x0, -0x2c(%rbp)
leaq 0x16ce(%rip), %rdi      # 0x3069
movl -0x2c(%rbp), %esi
xorl %eax, %eax
callq 0x1090
cmpl $0x0, 0x4774(%rip)      # 0x6120
jle 0x1a33
leaq 0x4777(%rip), %r12      # 0x6130
leaq 0x47a0(%rip), %r13      # 0x6160
xorl %r15d, %r15d
incq %r15
cmpl $0x0, 0x4757(%rip)      # 0x6124
movq (%r12), %rdx
movl (%r13), %ecx
je 0x19e6
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1090
jmp 0x1a1f
leaq 0x1690(%rip), %rdi      # 0x307d
movl %r15d, %esi
xorl %eax, %eax
callq 0x1090
movq (%r12), %rdx
movl (%r13), %ecx
movq %rbx, %rdi
leaq 0x168a(%rip), %rsi      # 0x3093
leaq 0x1691(%rip), %r8       # 0x30a1
xorl %eax, %eax
callq 0x1180
movq %rbx, %rdi
callq 0x1080
movslq 0x46fa(%rip), %rax      # 0x6120
addq $0x4, %r13
addq $0x8, %r12
cmpq %rax, %r15
jl 0x19c3
leaq 0x1679(%rip), %rdi      # 0x30b3
xorl %eax, %eax
callq 0x1090
movq 0x4590(%rip), %rax      # 0x5fd8
movq (%rax), %rdi
callq 0x22a8
movq %rax, %r15
movzbl (%rax), %r12d
leaq 0x1(%rax), %rdi
cmpl $0x65, %r12d
jg 0x1ac9
cmpl $0x3c, %r12d
je 0x1b08
cmpl $0x62, %r12d
jne 0x1aee
movb (%rdi), %r13b
testb %r13b, %r13b
jne 0x1aff
cmpl $0x0, -0x2c(%rbp)
je 0x1d7b
leaq 0x1ac2(%rip), %rdi      # 0x3550
callq 0x1050
movslq 0x4686(%rip), %rax      # 0x6120
testq %rax, %rax
leaq 0x46bc(%rip), %rsi      # 0x6160
jle 0x1ac1
shlq $0x2, %rax
xorl %ecx, %ecx
movl (%rcx,%rsi), %edx
testl %edx, %edx
jle 0x1ab8
decl %edx
movl %edx, (%rcx,%rsi)
addq $0x4, %rcx
cmpq %rcx, %rax
jne 0x1aac
decl -0x2c(%rbp)
jmp 0x1994
cmpl $0x66, %r12d
je 0x1af3
cmpl $0x72, %r12d
jne 0x1aee
movb (%rdi), %r13b
testb %r13b, %r13b
jne 0x1aff
leaq 0x1aa4(%rip), %rdi      # 0x3588
callq 0x1050
jmp 0x1994
movb (%rdi), %r13b
jmp 0x1aff
movb (%rdi), %r13b
testb %r13b, %r13b
je 0x1ca1
movq %r15, %rdi
cmpb $0x3c, %r13b
jne 0x1b53
callq 0x1170
testl %eax, %eax
jle 0x1bac
cmpl 0x4605(%rip), %eax      # 0x6120
jg 0x1bac
leal -0x1(%rax), %r12d
leaq 0x4634(%rip), %rcx      # 0x6160
cmpl $0x0, (%rcx,%r12,4)
jle 0x1bac
leaq 0x157c(%rip), %rdi      # 0x30b6
movl %eax, %esi
xorl %eax, %eax
callq 0x1090
leaq 0x4616(%rip), %rax      # 0x6160
decl (%rax,%r12,4)
jmp 0x1994
cmpb $0x3e, %r12b
setne %al
cmpb $0x3e, %r13b
setne %cl
testb %cl, %al
jne 0x1bc2
xorl %eax, %eax
cmpb $0x3e, %r12b
sete %al
movq %r15, %rdi
addq %rax, %rdi
callq 0x1170
testl %eax, %eax
jle 0x1bac
movl %eax, %r12d
cmpl 0x459a(%rip), %eax      # 0x6120
jg 0x1bac
leaq 0x1566(%rip), %rdi      # 0x30f5
movl %r12d, %esi
xorl %eax, %eax
callq 0x1090
decl %r12d
leaq 0x45bd(%rip), %rax      # 0x6160
incl (%rax,%r12,4)
jmp 0x1994
leaq 0x152b(%rip), %rdi      # 0x30de
movq %r15, %rsi
xorl %eax, %eax
callq 0x1090
jmp 0x1994
callq 0x11b0
testb %r13b, %r13b
jne 0x1ce3
movsbq %r12b, %rcx
movq (%rax), %rax
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
je 0x1ce3
movq %r15, %rdi
callq 0x1170
movl %eax, %r15d
testl %eax, %eax
setle %cl
movl 0x4524(%rip), %eax      # 0x6120
cmpl %eax, %r15d
setg %dl
orb %cl, %dl
leaq 0x4555(%rip), %r12      # 0x6160
movq 0x43c6(%rip), %r13      # 0x5fd8
jne 0x1c86
leaq 0x1505(%rip), %rdi      # 0x3120
movl %r15d, %esi
xorl %eax, %eax
callq 0x1090
movq (%r13), %rdi
callq 0x2399
cmpl $0x0, 0x44cb(%rip)      # 0x6100
leaq 0x150c(%rip), %rax      # 0x3148
je 0x1c55
leaq 0x14f1(%rip), %rdi      # 0x3136
xorl %eax, %eax
callq 0x1090
movq (%r13), %rdi
callq 0x2399
movslq -0x2c(%rbp), %rcx
leaq 0x4d00(%rip), %rdx      # 0x6960
movq %rax, (%rdx,%rcx,8)
leaq 0x5cf5(%rip), %rax      # 0x7960
movl %r15d, (%rax,%rcx,4)
decl %r15d
movl (%r12,%r15,4), %eax
leaq 0x64e3(%rip), %rdx      # 0x8160
movl %eax, (%rdx,%rcx,4)
movl 0x449a(%rip), %eax      # 0x6120
testl %eax, %eax
jle 0x1cdb
movl %eax, %eax
shlq $0x2, %rax
xorl %ecx, %ecx
incl (%rcx,%r12)
addq $0x4, %rcx
cmpq %rcx, %rax
jne 0x1c92
jmp 0x1cdb
leaq 0x1890(%rip), %rdi      # 0x3538
callq 0x1050
movslq 0x446c(%rip), %rax      # 0x6120
testq %rax, %rax
leaq 0x44a2(%rip), %rsi      # 0x6160
jle 0x1cdb
shlq $0x2, %rax
xorl %ecx, %ecx
movl (%rcx,%rsi), %edx
testl %edx, %edx
jle 0x1cd2
incl %edx
movl %edx, (%rcx,%rsi)
addq $0x4, %rcx
cmpq %rcx, %rax
jne 0x1cc6
incl -0x2c(%rbp)
jmp 0x1994
cmpb $0x71, %r12b
je 0x1d8c
leaq 0x145d(%rip), %rdi      # 0x3151
movq %r15, %rsi
xorl %eax, %eax
callq 0x1090
leaq 0x1709(%rip), %rdi      # 0x340e
callq 0x1050
leaq 0x170b(%rip), %rdi      # 0x341c
callq 0x1050
leaq 0x170c(%rip), %rdi      # 0x3429
callq 0x1050
leaq 0x171f(%rip), %rdi      # 0x3448
callq 0x1050
leaq 0x173a(%rip), %rdi      # 0x346f
callq 0x1050
leaq 0x1756(%rip), %rdi      # 0x3497
callq 0x1050
leaq 0x1775(%rip), %rdi      # 0x34c2
callq 0x1050
leaq 0x1795(%rip), %rdi      # 0x34ee
callq 0x1050
leaq 0x17aa(%rip), %rdi      # 0x350f
callq 0x1050
leaq 0x17c0(%rip), %rdi      # 0x3531
callq 0x1050
jmp 0x1994
leaq 0x17e7(%rip), %rdi      # 0x3569
callq 0x1050
jmp 0x198d
movq 0x439d(%rip), %rcx      # 0x6130
leaq 0x13d2(%rip), %rdx      # 0x316c
leaq -0x440(%rbp), %rbx
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10a0
leaq 0x13bf(%rip), %rdi      # 0x3176
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1090
movl $0x0, 0x6b95(%rip)      # 0x8960
leaq 0x18ba(%rip), %rsi      # 0x368c
movq %rbx, %rdi
callq 0x1150
testq %rax, %rax
je 0x1e49
movq %rax, %rbx
leaq 0x1904(%rip), %rsi      # 0x36ed
leaq -0x40(%rbp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x1e49
leaq 0x6b66(%rip), %r12      # 0x8970
leaq 0x18dc(%rip), %r14      # 0x36ed
leaq -0x40(%rbp), %r15
movsd -0x40(%rbp), %xmm0
movslq 0x6b3f(%rip), %rax      # 0x8960
movsd %xmm0, (%r12,%rax,8)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1040
incl 0x6b23(%rip)            # 0x8960
movq %rbx, %rdi
callq 0x10f0
testl %eax, %eax
je 0x1e15
leaq 0x1552(%rip), %r15      # 0x33a2
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r12d, %r12d
leaq 0x4b01(%rip), %rax      # 0x6960
movq (%r14,%rax), %r13
testq %r13, %r13
je 0x1f0a
movq %r13, %rdi
callq 0x1070
cmpq $0x2, %rax
jb 0x1e8f
movq -0x38(%rbp), %rdi
leaq 0x14df(%rip), %rsi      # 0x3364
movq %r13, %rdx
xorl %eax, %eax
callq 0x10e0
movslq 0x6aca(%rip), %rax      # 0x8960
cmpq %rax, %r12
jge 0x1ebf
leaq 0x6ace(%rip), %rax      # 0x8970
movsd (%r14,%rax), %xmm0
movq -0x38(%rbp), %r13
movq %r13, %rdi
leaq 0x14b8(%rip), %rsi      # 0x336e
movb $0x1, %al
callq 0x10e0
jmp 0x1edc
movl $0x13, %esi
movl $0x1, %edx
leaq 0x14be(%rip), %rdi      # 0x338e
movq -0x38(%rbp), %r13
movq %r13, %rcx
callq 0x11a0
leaq 0x5a7d(%rip), %rax      # 0x7960
movl (%rbx,%rax), %edx
leaq 0x6273(%rip), %rax      # 0x8160
movl (%rbx,%rax), %ecx
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10e0
movl $0xa, %edi
movq %r13, %rsi
callq 0x10c0
incq %r12
addq $0x8, %r14
addq $0x4, %rbx
cmpq $0x1000, %r14           # imm = 0x1000
jne 0x1e58
leaq 0x1492(%rip), %rdi      # 0x33bb
movl $0x13, %esi
movl $0x1, %edx
movq -0x38(%rbp), %rbx
movq %rbx, %rcx
callq 0x11a0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10c0
leaq 0x147c(%rip), %rdi      # 0x33cf
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
leaq 0x1472(%rip), %rdi      # 0x33de
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
movq %rbx, %rdi
callq 0x1060
xorl %eax, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x414f(%rip), %rsi      # 0x60f0
movq 0x4150(%rip), %rdx      # 0x60f8
leaq 0x1436(%rip), %rdi      # 0x33e5
xorl %eax, %eax
callq 0x1090
jmp 0x2018
leaq 0x15d6(%rip), %rdi      # 0x3595
callq 0x1050
leaq 0x15d9(%rip), %rdi      # 0x35a4
callq 0x1050
leaq 0x15f9(%rip), %rdi      # 0x35d0
callq 0x1050
leaq 0x15fe(%rip), %rdi      # 0x35e1
callq 0x1050
leaq 0x1618(%rip), %rdi      # 0x3607
callq 0x1050
leaq 0x1649(%rip), %rdi      # 0x3644
callq 0x1050
leaq 0x1663(%rip), %rdi      # 0x366a
callq 0x1050
leaq 0x167b(%rip), %rdi      # 0x368e
callq 0x1050
xorl %edi, %edi
callq 0x1190
nop