// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/tests/test_gcups.c
// Function: main
int main(int argc, char **argv)
{
    unsigned long i = 0;
    size_t seq_count = 10;
    size_t limit = 0;
    parasail_sequences_t *sequences = NULL;
    char *filename = NULL;
    int c = 0;
    int distribution = 0;

    while ((c = getopt(argc, argv, "f:d")) != -1) {
        switch (c) {
            case 'd':
                distribution = 1;
                break;
            case 'f':
                filename = optarg;
                break;
            case '?':
                if (optopt == 'f' || optopt == 'n') {
                    fprintf(stderr,
                            "Option -%c requires an argument.\n",
                            optopt);
                }
                else if (isprint(optopt)) {
                    fprintf(stderr, "Unknown option `-%c'.\n",
                            optopt);
                }
                else {
                    fprintf(stderr,
                            "Unknown option character `\\x%x'.\n",
                            optopt);
                }
                exit(1);
            default:
                fprintf(stderr, "default case in getopt\n");
                exit(1);
        }
    }

    if (filename) {
        sequences = parasail_sequences_from_file(filename);
        seq_count = sequences->l;
    }
    else {
        fprintf(stderr, "missing filename\n");
        exit(1);
    }

    if (distribution) {
        for (i=0; i<seq_count; ++i) {
            printf("%lu\n", (unsigned long)sequences->seqs[i].seq.l);
        }
    }
    else {
        limit = binomial_coefficient(seq_count, 2);
        printf("%lu choose 2 is %lu\n",
                (unsigned long)seq_count, (unsigned long)limit);

        {
            unsigned long a=0;
            unsigned long b=1;
            unsigned long work=0;
            unsigned long columns=0;
            for (i=0; i<limit; ++i) {
                k_combination2(i, &a, &b);
                work += sequences->seqs[a].seq.l*sequences->seqs[b].seq.l;
                columns += sequences->seqs[b].seq.l;
            }
            printf("work=%lu\n", work);
            printf("columns=%lu\n", columns);
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
xorl %r14d, %r14d
leaq 0x1bda(%rip), %r15      # 0x3030
movq 0x3b73(%rip), %r12      # 0x4fd0
xorl %r13d, %r13d
movl %r13d, %ecx
movl %ecx, %r13d
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1130
movl $0x1, %ecx
cmpl $0x64, %eax
je 0x1463
cmpl $-0x1, %eax
je 0x1491
cmpl $0x66, %eax
jne 0x163a
movq (%r12), %r14
jmp 0x1460
testq %r14, %r14
je 0x1649
movq %r14, %rdi
callq 0x1650
movq %rax, %rbx
movq 0x8(%rax), %r12
testl %r13d, %r13d
je 0x14e3
testq %r12, %r12
je 0x1629
movl $0x20, %r15d
leaq 0x1c05(%rip), %r14      # 0x30c9
movq (%rbx), %rax
movq (%rax,%r15), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1080
addq $0x40, %r15
decq %r12
jne 0x14c4
jmp 0x1629
leaq -0x1(%r12), %r14
imulq %r12, %r14
shrq %r14
xorl %r15d, %r15d
cmpq $0x2, %r12
cmovbq %r15, %r14
leaq 0x1bb8(%rip), %rdi      # 0x30b9
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1080
movl $0x0, %r12d
testq %r14, %r14
je 0x1607
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %r13d, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %r13, %xmm0
movsd %xmm0, (%rsp)
addsd %xmm0, %xmm0
ucomisd 0x1ae9(%rip), %xmm0     # 0x3028
jb 0x1547
sqrtsd %xmm0, %xmm0
jmp 0x154c
callq 0x1160
callq 0x1120
movsd 0x1aaf(%rip), %xmm2     # 0x3008
addsd %xmm2, %xmm0
movsd 0x1aab(%rip), %xmm3     # 0x3010
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x1a97(%rip), %xmm0     # 0x3018
movsd (%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x159e
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x1586
cvttsd2si %xmm2, %rax
movsd 0x1a75(%rip), %xmm0     # 0x3020
subsd %xmm0, %xmm2
cvttsd2si %xmm2, %rcx
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
orq %rax, %rdx
cvttsd2si %xmm1, %rax
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rax, %rsi
sarq $0x3f, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq (%rbx), %rax
shlq $0x6, %rdx
shlq $0x6, %rsi
movq 0x20(%rax,%rsi), %rcx
movq 0x20(%rax,%rdx), %rax
imulq %rcx, %rax
addq %rax, %r15
addq %rcx, %r12
incq %r13
cmpq %r14, %r13
jne 0x1526
leaq 0x1ac0(%rip), %rdi      # 0x30ce
movq %r15, %rsi
xorl %eax, %eax
callq 0x1080
leaq 0x1ab9(%rip), %rdi      # 0x30d8
movq %r12, %rsi
xorl %eax, %eax
callq 0x1080
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3f, %eax
jne 0x1644
callq 0x1190
callq 0x120d
callq 0x11e8
nop