// File: /workspace/github_c_makefile_star2_O2/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 0x1dbf(%rip), %r15      # 0x3058
pushq $0x1
popq %r13
xorl %r12d, %r12d
movl %r12d, %ecx
movl %ecx, %r12d
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1130
movl %r13d, %ecx
cmpl $0x64, %eax
je 0x12a3
cmpl $-0x1, %eax
je 0x12d5
cmpl $0x66, %eax
jne 0x1484
movq 0x3d00(%rip), %rax      # 0x4fd0
movq (%rax), %r14
jmp 0x12a0
testq %r14, %r14
je 0x14fe
movq %r14, %rdi
callq 0x1514
movq %rax, %rbx
movq 0x8(%rax), %r15
testl %r12d, %r12d
je 0x131e
pushq $0x20
popq %r12
leaq 0x1df4(%rip), %r14      # 0x30f1
subq $0x1, %r15
jb 0x1473
movq (%rbx), %rax
movq (%rax,%r12), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1080
addq $0x40, %r12
jmp 0x12fd
leaq -0x1(%r15), %r14
imulq %r15, %r14
shrq %r14
xorl %r13d, %r13d
cmpq $0x2, %r15
cmovbq %r13, %r14
leaq 0x1da6(%rip), %rdi      # 0x30e1
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1080
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq %r14, %r13
je 0x1451
movq %r13, %xmm0
punpckldq 0x1cac(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1cb4(%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 0x1cc3(%rip), %xmm0     # 0x3050
jb 0x1395
sqrtsd %xmm0, %xmm0
jmp 0x139a
callq 0x1160
callq 0x1120
movsd 0x1c89(%rip), %xmm2     # 0x3030
addsd %xmm2, %xmm0
movsd 0x1c85(%rip), %xmm3     # 0x3038
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x1c71(%rip), %xmm0     # 0x3040
movapd (%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x13ec
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x13d4
cvttsd2si %xmm2, %rax
movsd 0x1c4f(%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
jmp 0x134e
leaq 0x1c9e(%rip), %rdi      # 0x30f6
movq %r12, %rsi
xorl %eax, %eax
callq 0x1080
leaq 0x1c97(%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 0x14a6
movq 0x3b50(%rip), %rax      # 0x4fe0
movslq (%rax), %rbx
movl %ebx, %eax
andl $-0x9, %eax
cmpl $0x66, %eax
jne 0x14c4
leaq 0x1bb8(%rip), %rsi      # 0x305c
jmp 0x14e3
movq 0x3b4b(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0x1c00(%rip), %rdi      # 0x30b7
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
jmp 0x14f6
callq 0x1170
movq (%rax), %rax
testb $0x40, 0x1(%rax,%rbx,2)
leaq 0x1bbd(%rip), %rax      # 0x3095
leaq 0x1b9f(%rip), %rsi      # 0x307e
cmoveq %rax, %rsi
movq 0x3b0e(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x10b0
pushq $0x1
popq %rdi
callq 0x1140
movq 0x3af3(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0x1bc0(%rip), %rdi      # 0x30cf
pushq $0x11
jmp 0x14b9
nop