// File: /workspace/github_cpp_makefile_star2_O1/ekg[P]tsvtools/samplelines.cpp
// Function: main
int main (int argc, char** argv) {

    if (argc < 2) {
        cerr << "usage: " << argv[0] << " -r sample_rate" << endl
             << "samples lines from stdin at sample_rate rate" << endl
             << "specify -H to always print header line" << endl;
        exit(1);
    }

    double sample_rate = 1.0;
    bool header = false;

    while (true) {
        static struct option long_options[] =
        {  
            {"header", no_argument, 0, 'H'},
            {"rate",   required_argument, 0, 'r'},

        };
        int option_index = 0;

        int c = getopt_long (argc, argv, "Hr:", long_options, &option_index);

          if (c == -1)
            break;

          switch (c) {
            case 0:
            /* If this option set a flag, do nothing else now. */
            if (long_options[option_index].flag != 0)
              break;
            printf ("option %s", long_options[option_index].name);
            if (optarg)
              printf (" with arg %s", optarg);
            printf ("\n");
            break;

          case 'H':
            header = true;
            break;

          case 'r':
            sample_rate = atof(optarg);
            break;

          default:
            abort();
            break;

        }
    }


    // seed prng with random bits from /dev/random
    fstream random;
    random.open("/dev/random", fstream::in);
    int seed;
    random.get((char*) &seed, sizeof(int));
    random.close();

    init_genrand(seed);

    string line;
    getline(cin, line);
    if (header) {
        cout << line << endl;
    }
    getline(cin, line);

    while (!line.empty()) {
        cout << line << endl;
        if (genrand_real1() < sample_rate) {
            cout << line << endl;
        }
        getline(cin, line);
    }

    return 0;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rsi, %rbx
cmpl $0x2, %edi
jl 0x19f3
movl %edi, %ebp
movsd 0x9c9(%rip), %xmm0      # 0x2068
movsd %xmm0, 0x30(%rsp)
movl $0x0, 0x8(%rsp)
leaq 0xa2f(%rip), %r14       # 0x20e3
leaq 0x2a35(%rip), %r15      # 0x40f0
leaq 0x38(%rsp), %r12
movl $0x0, 0x38(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x1160
cmpl $0x47, %eax
jg 0x173e
cmpl $-0x1, %eax
je 0x1763
testl %eax, %eax
jne 0x19ee
movslq 0x38(%rsp), %rax
shlq $0x5, %rax
movb $0x1, %r13b
cmpq $0x0, 0x10(%rax,%r15)
jne 0x1771
addq %r15, %rax
movq (%rax), %rsi
leaq 0x9d9(%rip), %rdi       # 0x20e7
xorl %eax, %eax
callq 0x1040
movq 0x289c(%rip), %rax      # 0x3fb8
movq (%rax), %rsi
testq %rsi, %rsi
je 0x1732
leaq 0x9c6(%rip), %rdi       # 0x20f1
xorl %eax, %eax
callq 0x1040
movl $0xa, %edi
callq 0x1140
jmp 0x1771
cmpl $0x48, %eax
je 0x1768
cmpl $0x72, %eax
jne 0x19ee
movq 0x2865(%rip), %rax      # 0x3fb8
movq (%rax), %rdi
callq 0x1130
movsd %xmm0, 0x30(%rsp)
jmp 0x176e
xorl %r13d, %r13d
jmp 0x1771
movb $0x1, %al
movl %eax, 0x8(%rsp)
movb $0x1, %r13b
testb %r13b, %r13b
jne 0x16c0
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x1110
leaq 0x970(%rip), %rsi       # 0x20fe
movq %rbx, %rdi
movl $0x8, %edx
callq 0x10c0
movq 0x38(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %ecx
leaq 0x38(%rsp), %rdi
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
callq 0x10a0
leaq 0x38(%rsp), %rdi
callq 0x1050
movl 0xc(%rsp), %eax
movq %rax, 0x2983(%rip)      # 0x4160
movl $0x1, %ecx
leaq 0x2977(%rip), %rdx      # 0x4160
movq %rax, %rsi
shrq $0x1e, %rsi
xorl %eax, %esi
imull $0x6c078965, %esi, %eax # imm = 0x6C078965
addl %ecx, %eax
movq %rax, (%rdx,%rcx,8)
incq %rcx
cmpq $0x270, %rcx            # imm = 0x270
jne 0x17e9
movl $0x270, 0x28cc(%rip)    # imm = 0x270
leaq 0x20(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
movq 0x27a8(%rip), %rdi      # 0x3fd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %edx
movq 0x278d(%rip), %rbx      # 0x3fd8
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x1180
testb $0x1, 0x8(%rsp)
je 0x189f
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x2758(%rip), %rdi      # 0x3fc8
callq 0x1100
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %edx
movq 0x271b(%rip), %rbx      # 0x3fd8
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x1180
movq 0x26f7(%rip), %r14      # 0x3fc8
leaq 0x10(%rsp), %r15
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
je 0x19b8
movq %r14, %rdi
callq 0x1100
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
callq 0x1413
movq %rax, %xmm0
punpckldq 0x6e3(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x6eb(%rip), %xmm0      # 0x2020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x6f7(%rip), %xmm1      # 0x2040
movsd 0x30(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1991
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rdi
callq 0x1100
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1180
jmp 0x18d6
cmpq %rbp, %rsi
je 0x19d0
movq 0x20(%rsp), %rax
incq %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x10f0
leaq 0x38(%rsp), %rdi
callq 0x1060
xorl %eax, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1080
movq 0x25f6(%rip), %rdi      # 0x3ff0
leaq 0x66f(%rip), %rsi       # 0x2070
callq 0x10e0
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x10e0
leaq 0x660(%rip), %rsi       # 0x2078
movq %rax, %rdi
callq 0x10e0
movq %rax, %rdi
callq 0x1070
leaq 0x659(%rip), %rsi       # 0x2088
movq %rax, %rdi
callq 0x10e0
movq %rax, %rdi
callq 0x1070
leaq 0x66f(%rip), %rsi       # 0x20b5
movq %rax, %rdi
callq 0x10e0
movq %rax, %rdi
callq 0x1070
movl $0x1, %edi
callq 0x1120
jmp 0x1a62
movq %rax, %rbx
jmp 0x1a83
jmp 0x1a69
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x1a83
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x10f0
leaq 0x38(%rsp), %rdi
callq 0x1060
movq %rbx, %rdi
callq 0x1170