// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movq %rsi, %rbx
movl %edi, %ebp
xorl %r14d, %r14d
leaq 0x1bff(%rip), %r15      # 0x3058
movq 0x3b70(%rip), %r13      # 0x4fd0
xorl %r12d, %r12d
movl %r12d, %ecx
movl %ecx, %r12d
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1130
movl $0x1, %ecx
cmpl $0x64, %eax
je 0x1466
cmpl $-0x1, %eax
je 0x1494
cmpl $0x66, %eax
jne 0x1678
movq (%r13), %r14
jmp 0x1463
testq %r14, %r14
je 0x1687
movq %r14, %rdi
callq 0x168c
movq %rax, %rbx
movq 0x8(%rax), %r15
testl %r12d, %r12d
je 0x14e6
testq %r15, %r15
je 0x1667
movl $0x20, %r12d
leaq 0x1c2a(%rip), %r14      # 0x30f1
movq (%rbx), %rax
movq (%rax,%r12), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1080
addq $0x40, %r12
decq %r15
jne 0x14c7
jmp 0x1667
cmpq $0x2, %r15
jae 0x14f1
xorl %r14d, %r14d
jmp 0x151e
movl $0x1, %ecx
movl $0x1, %r14d
movq %r15, %rdx
imulq %rdx, %r14
leaq -0x1(%rdx), %rsi
movq %r14, %rax
xorl %edx, %edx
divq %rcx
incq %rcx
movq %rsi, %rdx
movq %rax, %r14
cmpq $0x3, %rcx
jne 0x14ff
leaq 0x1bbc(%rip), %rdi      # 0x30e1
xorl %r12d, %r12d
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1080
xorl %r15d, %r15d
testq %r14, %r14
je 0x1645
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r13, %xmm0
punpckldq 0x1abc(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1ac4(%rip), %xmm0     # 0x3020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x1ad3(%rip), %xmm0     # 0x3050
jb 0x1585
sqrtsd %xmm0, %xmm0
jmp 0x158a
callq 0x1160
callq 0x1120
movsd 0x1a99(%rip), %xmm2     # 0x3030
addsd %xmm2, %xmm0
movsd 0x1a95(%rip), %xmm3     # 0x3038
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x1a81(%rip), %xmm0     # 0x3040
movapd (%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x15dc
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x15c4
cvttsd2si %xmm2, %rax
movsd 0x1a5f(%rip), %xmm0     # 0x3048
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, %r12
addq %rcx, %r15
incq %r13
cmpq %r14, %r13
jne 0x1547
leaq 0x1aaa(%rip), %rdi      # 0x30f6
movq %r12, %rsi
xorl %eax, %eax
callq 0x1080
leaq 0x1aa3(%rip), %rdi      # 0x3100
movq %r15, %rsi
xorl %eax, %eax
callq 0x1080
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3f, %eax
jne 0x1682
callq 0x1190
callq 0x120d
callq 0x11e8