Subject: bug#18500: shuf-reservoir from coreutils 8.22 failing on s390x

From: Philipp Thomas <[email-masked]>
Date: Thu, 18 Sep 2014 15:33:26 +0200

The testsuite of coreutils 8.22 is failing on s390. Can anybody help me
pinpointing the culprit?

Here is the relevant part of the log:

FAIL: tests/misc/shuf-reservoir
===============================

++ initial_cwd_=/home/abuild/rpmbuild/BUILD/coreutils-8.22
++ fail=0
+++ testdir_prefix_
+++ printf gt
++ pfx_=gt
+++ mktempd_ /home/abuild/rpmbuild/BUILD/coreutils-8.22 gt-shuf-reservoir.sh.XXXX
+++ case $# in
+++ destdir_=/home/abuild/rpmbuild/BUILD/coreutils-8.22
+++ template_=gt-shuf-reservoir.sh.XXXX
+++ MAX_TRIES_=4
+++ case $destdir_ in
+++ case $template_ in
++++ unset TMPDIR
+++ d=/home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX
+++ case $d in
+++ test -d /home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX
++++ tr S -
++++ ls -dgo /home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX
+++ perms='drwx------ 2 6 -ep 18 12:02 /home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX'
+++ case $perms in
+++ test 0 = 0
+++ echo /home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX
+++ return
++ test_dir_=/home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX
++ cd /home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX
++ gl_init_sh_nl_='
'
++ IFS=' 	
'
++ for sig_ in 1 2 3 13 15
+++ expr 1 + 128
++ eval 'trap '\''Exit 129'\'' 1'
+++ trap 'Exit 129' 1
++ for sig_ in 1 2 3 13 15
+++ expr 2 + 128
++ eval 'trap '\''Exit 130'\'' 2'
+++ trap 'Exit 130' 2
++ for sig_ in 1 2 3 13 15
+++ expr 3 + 128
++ eval 'trap '\''Exit 131'\'' 3'
+++ trap 'Exit 131' 3
++ for sig_ in 1 2 3 13 15
+++ expr 13 + 128
++ eval 'trap '\''Exit 141'\'' 13'
+++ trap 'Exit 141' 13
++ for sig_ in 1 2 3 13 15
+++ expr 15 + 128
++ eval 'trap '\''Exit 143'\'' 15'
+++ trap 'Exit 143' 15
++ trap remove_tmp_ 0
+ path_prepend_ ./src
+ test 1 '!=' 0
+ path_dir_=./src
+ case $path_dir_ in
+ abs_path_dir_=/home/abuild/rpmbuild/BUILD/coreutils-8.22/./src
+ case $abs_path_dir_ in
+ PATH=/home/abuild/rpmbuild/BUILD/coreutils-8.22/./src:/home/abuild/rpmbuild/BUILD/coreutils-8.22/src:/usr/local/bin:/usr/bin:/bin:/usr/games:/sbin:/usr/sbin
+ create_exe_shims_ /home/abuild/rpmbuild/BUILD/coreutils-8.22/./src
+ case $EXEEXT in
+ return 0
+ shift
+ test 0 '!=' 0
+ export PATH
+ print_ver_ shuf
+ test yes = yes
+ local i
+ for i in '$*'
+ env shuf --version
shuf (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Eggert.
+ expensive_
+ test yes '!=' yes
+ require_valgrind_
+ valgrind --error-exitcode=1 true
+ grep '^#define lint 1' /home/abuild/rpmbuild/BUILD/coreutils-8.22/lib/config.h
+ leaklevel=summary
+ TEST_LINES='0 1 5 1023 1024 1025 3071 3072 3073'
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 0
+ INPUT_LINES=0
+ OUTPUT_LINES=0
+ seq 0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_0_0
==10115== Memcheck, a memory error detector
==10115== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10115== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10115== Command: shuf -n 0 -o out_0_0
==10115== 
--10115-- WARNING: unhandled syscall: 326
--10115-- You may be able to write your own handler.
--10115-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10115-- Nevertheless we consider this a bug.  Please report
--10115-- it at http://valgrind.org/support/bug_reports.html.
==10115== 
==10115== HEAP SUMMARY:
==10115==     in use at exit: 4,176 bytes in 3 blocks
==10115==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10115== 
==10115== LEAK SUMMARY:
==10115==    definitely lost: 24 bytes in 2 blocks
==10115==    indirectly lost: 4,152 bytes in 1 blocks
==10115==      possibly lost: 0 bytes in 0 blocks
==10115==    still reachable: 0 bytes in 0 blocks
==10115==         suppressed: 0 bytes in 0 blocks
==10115== Rerun with --leak-check=full to see details of leaked memory
==10115== 
==10115== For counts of detected and suppressed errors, rerun with: -v
==10115== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 0 -lt 0
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_0_0
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 1
+ INPUT_LINES=0
+ OUTPUT_LINES=1
+ seq 0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_0_1
==10124== Memcheck, a memory error detector
==10124== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10124== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10124== Command: shuf -n 1 -o out_0_1
==10124== 
--10124-- WARNING: unhandled syscall: 326
--10124-- You may be able to write your own handler.
--10124-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10124-- Nevertheless we consider this a bug.  Please report
--10124-- it at http://valgrind.org/support/bug_reports.html.
==10124== 
==10124== HEAP SUMMARY:
==10124==     in use at exit: 4,208 bytes in 3 blocks
==10124==   total heap usage: 5 allocs, 2 frees, 4,252 bytes allocated
==10124== 
==10124== LEAK SUMMARY:
==10124==    definitely lost: 56 bytes in 2 blocks
==10124==    indirectly lost: 4,152 bytes in 1 blocks
==10124==      possibly lost: 0 bytes in 0 blocks
==10124==    still reachable: 0 bytes in 0 blocks
==10124==         suppressed: 0 bytes in 0 blocks
==10124== Rerun with --leak-check=full to see details of leaked memory
==10124== 
==10124== For counts of detected and suppressed errors, rerun with: -v
==10124== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 0 -lt 1
+ EXPECTED_LINES=0
++ grep '^[0-9][0-9]*$' out_0_1
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 5
+ INPUT_LINES=0
+ OUTPUT_LINES=5
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_0_5
==10136== Memcheck, a memory error detector
==10136== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10136== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10136== Command: shuf -n 5 -o out_0_5
==10136== 
+ seq 0
--10136-- WARNING: unhandled syscall: 326
--10136-- You may be able to write your own handler.
--10136-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10136-- Nevertheless we consider this a bug.  Please report
--10136-- it at http://valgrind.org/support/bug_reports.html.
==10136== 
==10136== HEAP SUMMARY:
==10136==     in use at exit: 4,336 bytes in 3 blocks
==10136==   total heap usage: 5 allocs, 2 frees, 4,380 bytes allocated
==10136== 
==10136== LEAK SUMMARY:
==10136==    definitely lost: 184 bytes in 2 blocks
==10136==    indirectly lost: 4,152 bytes in 1 blocks
==10136==      possibly lost: 0 bytes in 0 blocks
==10136==    still reachable: 0 bytes in 0 blocks
==10136==         suppressed: 0 bytes in 0 blocks
==10136== Rerun with --leak-check=full to see details of leaked memory
==10136== 
==10136== For counts of detected and suppressed errors, rerun with: -v
==10136== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 0 -lt 5
+ EXPECTED_LINES=0
++ grep '^[0-9][0-9]*$' out_0_5
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 1023
+ INPUT_LINES=0
+ OUTPUT_LINES=1023
+ seq 0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_0_1023
==10148== Memcheck, a memory error detector
==10148== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10148== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10148== Command: shuf -n 1023 -o out_0_1023
==10148== 
--10148-- WARNING: unhandled syscall: 326
--10148-- You may be able to write your own handler.
--10148-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10148-- Nevertheless we consider this a bug.  Please report
--10148-- it at http://valgrind.org/support/bug_reports.html.
==10148== 
==10148== HEAP SUMMARY:
==10148==     in use at exit: 36,912 bytes in 3 blocks
==10148==   total heap usage: 5 allocs, 2 frees, 36,956 bytes allocated
==10148== 
==10148== LEAK SUMMARY:
==10148==    definitely lost: 32,760 bytes in 2 blocks
==10148==    indirectly lost: 4,152 bytes in 1 blocks
==10148==      possibly lost: 0 bytes in 0 blocks
==10148==    still reachable: 0 bytes in 0 blocks
==10148==         suppressed: 0 bytes in 0 blocks
==10148== Rerun with --leak-check=full to see details of leaked memory
==10148== 
==10148== For counts of detected and suppressed errors, rerun with: -v
==10148== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 0 -lt 1023
+ EXPECTED_LINES=0
++ grep '^[0-9][0-9]*$' out_0_1023
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 1024
+ INPUT_LINES=0
+ OUTPUT_LINES=1024
+ seq 0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_0_1024
==10156== Memcheck, a memory error detector
==10156== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10156== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10156== Command: shuf -n 1024 -o out_0_1024
==10156== 
--10156-- WARNING: unhandled syscall: 326
--10156-- You may be able to write your own handler.
--10156-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10156-- Nevertheless we consider this a bug.  Please report
--10156-- it at http://valgrind.org/support/bug_reports.html.
==10156== 
==10156== HEAP SUMMARY:
==10156==     in use at exit: 36,944 bytes in 3 blocks
==10156==   total heap usage: 5 allocs, 2 frees, 36,988 bytes allocated
==10156== 
==10156== LEAK SUMMARY:
==10156==    definitely lost: 32,792 bytes in 2 blocks
==10156==    indirectly lost: 4,152 bytes in 1 blocks
==10156==      possibly lost: 0 bytes in 0 blocks
==10156==    still reachable: 0 bytes in 0 blocks
==10156==         suppressed: 0 bytes in 0 blocks
==10156== Rerun with --leak-check=full to see details of leaked memory
==10156== 
==10156== For counts of detected and suppressed errors, rerun with: -v
==10156== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 0 -lt 1024
+ EXPECTED_LINES=0
++ grep '^[0-9][0-9]*$' out_0_1024
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 1025
+ INPUT_LINES=0
+ OUTPUT_LINES=1025
+ seq 0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_0_1025
==10164== Memcheck, a memory error detector
==10164== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10164== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10164== Command: shuf -n 1025 -o out_0_1025
==10164== 
--10164-- WARNING: unhandled syscall: 326
--10164-- You may be able to write your own handler.
--10164-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10164-- Nevertheless we consider this a bug.  Please report
--10164-- it at http://valgrind.org/support/bug_reports.html.
==10164== 
==10164== HEAP SUMMARY:
==10164==     in use at exit: 36,944 bytes in 3 blocks
==10164==   total heap usage: 5 allocs, 2 frees, 36,988 bytes allocated
==10164== 
==10164== LEAK SUMMARY:
==10164==    definitely lost: 32,792 bytes in 2 blocks
==10164==    indirectly lost: 4,152 bytes in 1 blocks
==10164==      possibly lost: 0 bytes in 0 blocks
==10164==    still reachable: 0 bytes in 0 blocks
==10164==         suppressed: 0 bytes in 0 blocks
==10164== Rerun with --leak-check=full to see details of leaked memory
==10164== 
==10164== For counts of detected and suppressed errors, rerun with: -v
==10164== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 0 -lt 1025
+ EXPECTED_LINES=0
++ grep '^[0-9][0-9]*$' out_0_1025
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 3071
+ INPUT_LINES=0
+ OUTPUT_LINES=3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_0_3071
+ seq 0
==10173== Memcheck, a memory error detector
==10173== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10173== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10173== Command: shuf -n 3071 -o out_0_3071
==10173== 
--10173-- WARNING: unhandled syscall: 326
--10173-- You may be able to write your own handler.
--10173-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10173-- Nevertheless we consider this a bug.  Please report
--10173-- it at http://valgrind.org/support/bug_reports.html.
==10173== 
==10173== HEAP SUMMARY:
==10173==     in use at exit: 36,944 bytes in 3 blocks
==10173==   total heap usage: 5 allocs, 2 frees, 36,988 bytes allocated
==10173== 
==10173== LEAK SUMMARY:
==10173==    definitely lost: 32,792 bytes in 2 blocks
==10173==    indirectly lost: 4,152 bytes in 1 blocks
==10173==      possibly lost: 0 bytes in 0 blocks
==10173==    still reachable: 0 bytes in 0 blocks
==10173==         suppressed: 0 bytes in 0 blocks
==10173== Rerun with --leak-check=full to see details of leaked memory
==10173== 
==10173== For counts of detected and suppressed errors, rerun with: -v
==10173== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 0 -lt 3071
+ EXPECTED_LINES=0
++ grep '^[0-9][0-9]*$' out_0_3071
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 3072
+ INPUT_LINES=0
+ OUTPUT_LINES=3072
+ seq 0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_0_3072
==10185== Memcheck, a memory error detector
==10185== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10185== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10185== Command: shuf -n 3072 -o out_0_3072
==10185== 
--10185-- WARNING: unhandled syscall: 326
--10185-- You may be able to write your own handler.
--10185-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10185-- Nevertheless we consider this a bug.  Please report
--10185-- it at http://valgrind.org/support/bug_reports.html.
==10185== 
==10185== HEAP SUMMARY:
==10185==     in use at exit: 36,944 bytes in 3 blocks
==10185==   total heap usage: 5 allocs, 2 frees, 36,988 bytes allocated
==10185== 
==10185== LEAK SUMMARY:
==10185==    definitely lost: 32,792 bytes in 2 blocks
==10185==    indirectly lost: 4,152 bytes in 1 blocks
==10185==      possibly lost: 0 bytes in 0 blocks
==10185==    still reachable: 0 bytes in 0 blocks
==10185==         suppressed: 0 bytes in 0 blocks
==10185== Rerun with --leak-check=full to see details of leaked memory
==10185== 
==10185== For counts of detected and suppressed errors, rerun with: -v
==10185== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 0 -lt 3072
+ EXPECTED_LINES=0
++ sort -un
++ grep '^[0-9][0-9]*$' out_0_3072
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 0 3073
+ INPUT_LINES=0
+ OUTPUT_LINES=3073
+ seq 0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_0_3073
==10193== Memcheck, a memory error detector
==10193== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10193== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10193== Command: shuf -n 3073 -o out_0_3073
==10193== 
--10193-- WARNING: unhandled syscall: 326
--10193-- You may be able to write your own handler.
--10193-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10193-- Nevertheless we consider this a bug.  Please report
--10193-- it at http://valgrind.org/support/bug_reports.html.
==10193== 
==10193== HEAP SUMMARY:
==10193==     in use at exit: 36,944 bytes in 3 blocks
==10193==   total heap usage: 5 allocs, 2 frees, 36,988 bytes allocated
==10193== 
==10193== LEAK SUMMARY:
==10193==    definitely lost: 32,792 bytes in 2 blocks
==10193==    indirectly lost: 4,152 bytes in 1 blocks
==10193==      possibly lost: 0 bytes in 0 blocks
==10193==    still reachable: 0 bytes in 0 blocks
==10193==         suppressed: 0 bytes in 0 blocks
==10193== Rerun with --leak-check=full to see details of leaked memory
==10193== 
==10193== For counts of detected and suppressed errors, rerun with: -v
==10193== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 0 -lt 3073
+ EXPECTED_LINES=0
++ sort -un
++ grep '^[0-9][0-9]*$' out_0_3073
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 0
+ INPUT_LINES=1
+ OUTPUT_LINES=0
+ seq 1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_1_0
==10201== Memcheck, a memory error detector
==10201== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10201== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10201== Command: shuf -n 0 -o out_1_0
==10201== 
--10201-- WARNING: unhandled syscall: 326
--10201-- You may be able to write your own handler.
--10201-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10201-- Nevertheless we consider this a bug.  Please report
--10201-- it at http://valgrind.org/support/bug_reports.html.
==10201== 
==10201== HEAP SUMMARY:
==10201==     in use at exit: 4,176 bytes in 3 blocks
==10201==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10201== 
==10201== LEAK SUMMARY:
==10201==    definitely lost: 24 bytes in 2 blocks
==10201==    indirectly lost: 4,152 bytes in 1 blocks
==10201==      possibly lost: 0 bytes in 0 blocks
==10201==    still reachable: 0 bytes in 0 blocks
==10201==         suppressed: 0 bytes in 0 blocks
==10201== Rerun with --leak-check=full to see details of leaked memory
==10201== 
==10201== For counts of detected and suppressed errors, rerun with: -v
==10201== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 1 -lt 0
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1_0
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 1
+ INPUT_LINES=1
+ OUTPUT_LINES=1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_1_1
==10209== Memcheck, a memory error detector
==10209== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10209== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10209== Command: shuf -n 1 -o out_1_1
==10209== 
+ seq 1
--10209-- WARNING: unhandled syscall: 326
--10209-- You may be able to write your own handler.
--10209-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10209-- Nevertheless we consider this a bug.  Please report
--10209-- it at http://valgrind.org/support/bug_reports.html.
1
==10209== 
==10209== HEAP SUMMARY:
==10209==     in use at exit: 37,112 bytes in 5 blocks
==10209==   total heap usage: 8 allocs, 3 frees, 37,188 bytes allocated
==10209== 
==10209== LEAK SUMMARY:
==10209==    definitely lost: 32,832 bytes in 3 blocks
==10209==    indirectly lost: 4,280 bytes in 2 blocks
==10209==      possibly lost: 0 bytes in 0 blocks
==10209==    still reachable: 0 bytes in 0 blocks
==10209==         suppressed: 0 bytes in 0 blocks
==10209== Rerun with --leak-check=full to see details of leaked memory
==10209== 
==10209== For counts of detected and suppressed errors, rerun with: -v
==10209== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 1 -lt 1
++ grep '^[0-9][0-9]*$' out_1_1
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1 OUT_N=1'
shuf-reservoir-sampling failed with IN_N=1 OUT_N=1
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 5
+ INPUT_LINES=1
+ OUTPUT_LINES=5
+ seq 1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_1_5
==10221== Memcheck, a memory error detector
==10221== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10221== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10221== Command: shuf -n 5 -o out_1_5
==10221== 
--10221-- WARNING: unhandled syscall: 326
--10221-- You may be able to write your own handler.
--10221-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10221-- Nevertheless we consider this a bug.  Please report
--10221-- it at http://valgrind.org/support/bug_reports.html.
1
==10221== 
==10221== HEAP SUMMARY:
==10221==     in use at exit: 4,472 bytes in 5 blocks
==10221==   total heap usage: 7 allocs, 2 frees, 4,516 bytes allocated
==10221== 
==10221== LEAK SUMMARY:
==10221==    definitely lost: 192 bytes in 3 blocks
==10221==    indirectly lost: 4,280 bytes in 2 blocks
==10221==      possibly lost: 0 bytes in 0 blocks
==10221==    still reachable: 0 bytes in 0 blocks
==10221==         suppressed: 0 bytes in 0 blocks
==10221== Rerun with --leak-check=full to see details of leaked memory
==10221== 
==10221== For counts of detected and suppressed errors, rerun with: -v
==10221== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 1 -lt 5
+ EXPECTED_LINES=1
++ grep '^[0-9][0-9]*$' out_1_5
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1 OUT_N=5'
shuf-reservoir-sampling failed with IN_N=1 OUT_N=5
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 1023
+ INPUT_LINES=1
+ OUTPUT_LINES=1023
+ seq 1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_1_1023
==10229== Memcheck, a memory error detector
==10229== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10229== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10229== Command: shuf -n 1023 -o out_1_1023
==10229== 
--10229-- WARNING: unhandled syscall: 326
--10229-- You may be able to write your own handler.
--10229-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10229-- Nevertheless we consider this a bug.  Please report
--10229-- it at http://valgrind.org/support/bug_reports.html.
1
==10229== 
==10229== HEAP SUMMARY:
==10229==     in use at exit: 37,048 bytes in 5 blocks
==10229==   total heap usage: 7 allocs, 2 frees, 37,092 bytes allocated
==10229== 
==10229== LEAK SUMMARY:
==10229==    definitely lost: 32,768 bytes in 3 blocks
==10229==    indirectly lost: 4,280 bytes in 2 blocks
==10229==      possibly lost: 0 bytes in 0 blocks
==10229==    still reachable: 0 bytes in 0 blocks
==10229==         suppressed: 0 bytes in 0 blocks
==10229== Rerun with --leak-check=full to see details of leaked memory
==10229== 
==10229== For counts of detected and suppressed errors, rerun with: -v
==10229== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 1 -lt 1023
+ EXPECTED_LINES=1
++ wc -l
++ sort -un
++ grep '^[0-9][0-9]*$' out_1_1023
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1 OUT_N=1023'
shuf-reservoir-sampling failed with IN_N=1 OUT_N=1023
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 1024
+ INPUT_LINES=1
+ OUTPUT_LINES=1024
+ seq 1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_1_1024
==10241== Memcheck, a memory error detector
==10241== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10241== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10241== Command: shuf -n 1024 -o out_1_1024
==10241== 
--10241-- WARNING: unhandled syscall: 326
--10241-- You may be able to write your own handler.
--10241-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10241-- Nevertheless we consider this a bug.  Please report
--10241-- it at http://valgrind.org/support/bug_reports.html.
1
==10241== 
==10241== HEAP SUMMARY:
==10241==     in use at exit: 37,080 bytes in 5 blocks
==10241==   total heap usage: 7 allocs, 2 frees, 37,124 bytes allocated
==10241== 
==10241== LEAK SUMMARY:
==10241==    definitely lost: 32,800 bytes in 3 blocks
==10241==    indirectly lost: 4,280 bytes in 2 blocks
==10241==      possibly lost: 0 bytes in 0 blocks
==10241==    still reachable: 0 bytes in 0 blocks
==10241==         suppressed: 0 bytes in 0 blocks
==10241== Rerun with --leak-check=full to see details of leaked memory
==10241== 
==10241== For counts of detected and suppressed errors, rerun with: -v
==10241== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 1 -lt 1024
+ EXPECTED_LINES=1
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1_1024
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1 OUT_N=1024'
shuf-reservoir-sampling failed with IN_N=1 OUT_N=1024
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 1025
+ INPUT_LINES=1
+ OUTPUT_LINES=1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_1_1025
+ seq 1
==10254== Memcheck, a memory error detector
==10254== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10254== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10254== Command: shuf -n 1025 -o out_1_1025
==10254== 
--10254-- WARNING: unhandled syscall: 326
--10254-- You may be able to write your own handler.
--10254-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10254-- Nevertheless we consider this a bug.  Please report
--10254-- it at http://valgrind.org/support/bug_reports.html.
1
==10254== 
==10254== HEAP SUMMARY:
==10254==     in use at exit: 37,080 bytes in 5 blocks
==10254==   total heap usage: 7 allocs, 2 frees, 37,124 bytes allocated
==10254== 
==10254== LEAK SUMMARY:
==10254==    definitely lost: 32,800 bytes in 3 blocks
==10254==    indirectly lost: 4,280 bytes in 2 blocks
==10254==      possibly lost: 0 bytes in 0 blocks
==10254==    still reachable: 0 bytes in 0 blocks
==10254==         suppressed: 0 bytes in 0 blocks
==10254== Rerun with --leak-check=full to see details of leaked memory
==10254== 
==10254== For counts of detected and suppressed errors, rerun with: -v
==10254== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 1 -lt 1025
+ EXPECTED_LINES=1
++ wc -l
++ sort -un
++ grep '^[0-9][0-9]*$' out_1_1025
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1 OUT_N=1025'
shuf-reservoir-sampling failed with IN_N=1 OUT_N=1025
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 3071
+ INPUT_LINES=1
+ OUTPUT_LINES=3071
+ seq 1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_1_3071
==10262== Memcheck, a memory error detector
==10262== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10262== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10262== Command: shuf -n 3071 -o out_1_3071
==10262== 
--10262-- WARNING: unhandled syscall: 326
--10262-- You may be able to write your own handler.
--10262-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10262-- Nevertheless we consider this a bug.  Please report
--10262-- it at http://valgrind.org/support/bug_reports.html.
1
==10262== 
==10262== HEAP SUMMARY:
==10262==     in use at exit: 37,080 bytes in 5 blocks
==10262==   total heap usage: 7 allocs, 2 frees, 37,124 bytes allocated
==10262== 
==10262== LEAK SUMMARY:
==10262==    definitely lost: 32,800 bytes in 3 blocks
==10262==    indirectly lost: 4,280 bytes in 2 blocks
==10262==      possibly lost: 0 bytes in 0 blocks
==10262==    still reachable: 0 bytes in 0 blocks
==10262==         suppressed: 0 bytes in 0 blocks
==10262== Rerun with --leak-check=full to see details of leaked memory
==10262== 
==10262== For counts of detected and suppressed errors, rerun with: -v
==10262== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 1 -lt 3071
+ EXPECTED_LINES=1
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1_3071
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1 OUT_N=3071'
shuf-reservoir-sampling failed with IN_N=1 OUT_N=3071
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 3072
+ INPUT_LINES=1
+ OUTPUT_LINES=3072
+ seq 1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_1_3072
==10273== Memcheck, a memory error detector
==10273== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10273== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10273== Command: shuf -n 3072 -o out_1_3072
==10273== 
--10273-- WARNING: unhandled syscall: 326
--10273-- You may be able to write your own handler.
--10273-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10273-- Nevertheless we consider this a bug.  Please report
--10273-- it at http://valgrind.org/support/bug_reports.html.
1
==10273== 
==10273== HEAP SUMMARY:
==10273==     in use at exit: 37,080 bytes in 5 blocks
==10273==   total heap usage: 7 allocs, 2 frees, 37,124 bytes allocated
==10273== 
==10273== LEAK SUMMARY:
==10273==    definitely lost: 32,800 bytes in 3 blocks
==10273==    indirectly lost: 4,280 bytes in 2 blocks
==10273==      possibly lost: 0 bytes in 0 blocks
==10273==    still reachable: 0 bytes in 0 blocks
==10273==         suppressed: 0 bytes in 0 blocks
==10273== Rerun with --leak-check=full to see details of leaked memory
==10273== 
==10273== For counts of detected and suppressed errors, rerun with: -v
==10273== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 1 -lt 3072
+ EXPECTED_LINES=1
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1_3072
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1 OUT_N=3072'
shuf-reservoir-sampling failed with IN_N=1 OUT_N=3072
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1 3073
+ INPUT_LINES=1
+ OUTPUT_LINES=3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_1_3073
+ seq 1
==10282== Memcheck, a memory error detector
==10282== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10282== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10282== Command: shuf -n 3073 -o out_1_3073
==10282== 
--10282-- WARNING: unhandled syscall: 326
--10282-- You may be able to write your own handler.
--10282-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10282-- Nevertheless we consider this a bug.  Please report
--10282-- it at http://valgrind.org/support/bug_reports.html.
1
==10282== 
==10282== HEAP SUMMARY:
==10282==     in use at exit: 37,080 bytes in 5 blocks
==10282==   total heap usage: 7 allocs, 2 frees, 37,124 bytes allocated
==10282== 
==10282== LEAK SUMMARY:
==10282==    definitely lost: 32,800 bytes in 3 blocks
==10282==    indirectly lost: 4,280 bytes in 2 blocks
==10282==      possibly lost: 0 bytes in 0 blocks
==10282==    still reachable: 0 bytes in 0 blocks
==10282==         suppressed: 0 bytes in 0 blocks
==10282== Rerun with --leak-check=full to see details of leaked memory
==10282== 
==10282== For counts of detected and suppressed errors, rerun with: -v
==10282== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 1 -lt 3073
+ EXPECTED_LINES=1
++ grep '^[0-9][0-9]*$' out_1_3073
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1 OUT_N=3073'
shuf-reservoir-sampling failed with IN_N=1 OUT_N=3073
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 0
+ INPUT_LINES=5
+ OUTPUT_LINES=0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_5_0
+ seq 5
==10299== Memcheck, a memory error detector
==10299== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10299== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10299== Command: shuf -n 0 -o out_5_0
==10299== 
--10299-- WARNING: unhandled syscall: 326
--10299-- You may be able to write your own handler.
--10299-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10299-- Nevertheless we consider this a bug.  Please report
--10299-- it at http://valgrind.org/support/bug_reports.html.
==10299== 
==10299== HEAP SUMMARY:
==10299==     in use at exit: 4,176 bytes in 3 blocks
==10299==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10299== 
==10299== LEAK SUMMARY:
==10299==    definitely lost: 24 bytes in 2 blocks
==10299==    indirectly lost: 4,152 bytes in 1 blocks
==10299==      possibly lost: 0 bytes in 0 blocks
==10299==    still reachable: 0 bytes in 0 blocks
==10299==         suppressed: 0 bytes in 0 blocks
==10299== Rerun with --leak-check=full to see details of leaked memory
==10299== 
==10299== For counts of detected and suppressed errors, rerun with: -v
==10299== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 5 -lt 0
++ grep '^[0-9][0-9]*$' out_5_0
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 1
+ INPUT_LINES=5
+ OUTPUT_LINES=1
+ seq 5
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_5_1
==10307== Memcheck, a memory error detector
==10307== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10307== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10307== Command: shuf -n 1 -o out_5_1
==10307== 
--10307-- WARNING: unhandled syscall: 326
--10307-- You may be able to write your own handler.
--10307-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10307-- Nevertheless we consider this a bug.  Please report
--10307-- it at http://valgrind.org/support/bug_reports.html.
2
==10307== 
==10307== HEAP SUMMARY:
==10307==     in use at exit: 37,112 bytes in 5 blocks
==10307==   total heap usage: 9 allocs, 4 frees, 37,316 bytes allocated
==10307== 
==10307== LEAK SUMMARY:
==10307==    definitely lost: 32,832 bytes in 3 blocks
==10307==    indirectly lost: 4,280 bytes in 2 blocks
==10307==      possibly lost: 0 bytes in 0 blocks
==10307==    still reachable: 0 bytes in 0 blocks
==10307==         suppressed: 0 bytes in 0 blocks
==10307== Rerun with --leak-check=full to see details of leaked memory
==10307== 
==10307== For counts of detected and suppressed errors, rerun with: -v
==10307== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 5 -lt 1
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_5_1
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=5 OUT_N=1'
shuf-reservoir-sampling failed with IN_N=5 OUT_N=1
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 5
+ INPUT_LINES=5
+ OUTPUT_LINES=5
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_5_5
+ seq 5
==10320== Memcheck, a memory error detector
==10320== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10320== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10320== Command: shuf -n 5 -o out_5_5
==10320== 
--10320-- WARNING: unhandled syscall: 326
--10320-- You may be able to write your own handler.
--10320-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10320-- Nevertheless we consider this a bug.  Please report
--10320-- it at http://valgrind.org/support/bug_reports.html.
4
1
2
3
5
==10320== 
==10320== HEAP SUMMARY:
==10320==     in use at exit: 37,784 bytes in 9 blocks
==10320==   total heap usage: 13 allocs, 4 frees, 38,028 bytes allocated
==10320== 
==10320== LEAK SUMMARY:
==10320==    definitely lost: 32,992 bytes in 3 blocks
==10320==    indirectly lost: 4,792 bytes in 6 blocks
==10320==      possibly lost: 0 bytes in 0 blocks
==10320==    still reachable: 0 bytes in 0 blocks
==10320==         suppressed: 0 bytes in 0 blocks
==10320== Rerun with --leak-check=full to see details of leaked memory
==10320== 
==10320== For counts of detected and suppressed errors, rerun with: -v
==10320== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 5 -lt 5
++ grep '^[0-9][0-9]*$' out_5_5
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=5 OUT_N=5'
shuf-reservoir-sampling failed with IN_N=5 OUT_N=5
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 1023
+ INPUT_LINES=5
+ OUTPUT_LINES=1023
+ seq 5
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_5_1023
==10347== Memcheck, a memory error detector
==10347== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10347== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10347== Command: shuf -n 1023 -o out_5_1023
==10347== 
--10347-- WARNING: unhandled syscall: 326
--10347-- You may be able to write your own handler.
--10347-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10347-- Nevertheless we consider this a bug.  Please report
--10347-- it at http://valgrind.org/support/bug_reports.html.
4
3
2
5
1
==10347== 
==10347== HEAP SUMMARY:
==10347==     in use at exit: 37,592 bytes in 9 blocks
==10347==   total heap usage: 12 allocs, 3 frees, 37,676 bytes allocated
==10347== 
==10347== LEAK SUMMARY:
==10347==    definitely lost: 32,800 bytes in 3 blocks
==10347==    indirectly lost: 4,792 bytes in 6 blocks
==10347==      possibly lost: 0 bytes in 0 blocks
==10347==    still reachable: 0 bytes in 0 blocks
==10347==         suppressed: 0 bytes in 0 blocks
==10347== Rerun with --leak-check=full to see details of leaked memory
==10347== 
==10347== For counts of detected and suppressed errors, rerun with: -v
==10347== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 5 -lt 1023
+ EXPECTED_LINES=5
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_5_1023
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=5 OUT_N=1023'
shuf-reservoir-sampling failed with IN_N=5 OUT_N=1023
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 1024
+ INPUT_LINES=5
+ OUTPUT_LINES=1024
+ seq 5
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_5_1024
==10379== Memcheck, a memory error detector
==10379== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10379== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10379== Command: shuf -n 1024 -o out_5_1024
==10379== 
--10379-- WARNING: unhandled syscall: 326
--10379-- You may be able to write your own handler.
--10379-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10379-- Nevertheless we consider this a bug.  Please report
--10379-- it at http://valgrind.org/support/bug_reports.html.
2
4
1
3
5
==10379== 
==10379== HEAP SUMMARY:
==10379==     in use at exit: 37,624 bytes in 9 blocks
==10379==   total heap usage: 12 allocs, 3 frees, 37,708 bytes allocated
==10379== 
==10379== LEAK SUMMARY:
==10379==    definitely lost: 32,832 bytes in 3 blocks
==10379==    indirectly lost: 4,792 bytes in 6 blocks
==10379==      possibly lost: 0 bytes in 0 blocks
==10379==    still reachable: 0 bytes in 0 blocks
==10379==         suppressed: 0 bytes in 0 blocks
==10379== Rerun with --leak-check=full to see details of leaked memory
==10379== 
==10379== For counts of detected and suppressed errors, rerun with: -v
==10379== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 5 -lt 1024
+ EXPECTED_LINES=5
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_5_1024
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=5 OUT_N=1024'
shuf-reservoir-sampling failed with IN_N=5 OUT_N=1024
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 1025
+ INPUT_LINES=5
+ OUTPUT_LINES=1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_5_1025
+ seq 5
==10387== Memcheck, a memory error detector
==10387== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10387== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10387== Command: shuf -n 1025 -o out_5_1025
==10387== 
--10387-- WARNING: unhandled syscall: 326
--10387-- You may be able to write your own handler.
--10387-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10387-- Nevertheless we consider this a bug.  Please report
--10387-- it at http://valgrind.org/support/bug_reports.html.
5
2
1
3
4
==10387== 
==10387== HEAP SUMMARY:
==10387==     in use at exit: 37,624 bytes in 9 blocks
==10387==   total heap usage: 12 allocs, 3 frees, 37,708 bytes allocated
==10387== 
==10387== LEAK SUMMARY:
==10387==    definitely lost: 32,832 bytes in 3 blocks
==10387==    indirectly lost: 4,792 bytes in 6 blocks
==10387==      possibly lost: 0 bytes in 0 blocks
==10387==    still reachable: 0 bytes in 0 blocks
==10387==         suppressed: 0 bytes in 0 blocks
==10387== Rerun with --leak-check=full to see details of leaked memory
==10387== 
==10387== For counts of detected and suppressed errors, rerun with: -v
==10387== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 5 -lt 1025
+ EXPECTED_LINES=5
++ sort -un
++ grep '^[0-9][0-9]*$' out_5_1025
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=5 OUT_N=1025'
shuf-reservoir-sampling failed with IN_N=5 OUT_N=1025
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 3071
+ INPUT_LINES=5
+ OUTPUT_LINES=3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_5_3071
+ seq 5
==10403== Memcheck, a memory error detector
==10403== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10403== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10403== Command: shuf -n 3071 -o out_5_3071
==10403== 
--10403-- WARNING: unhandled syscall: 326
--10403-- You may be able to write your own handler.
--10403-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10403-- Nevertheless we consider this a bug.  Please report
--10403-- it at http://valgrind.org/support/bug_reports.html.
3
2
1
4
5
==10403== 
==10403== HEAP SUMMARY:
==10403==     in use at exit: 37,624 bytes in 9 blocks
==10403==   total heap usage: 12 allocs, 3 frees, 37,708 bytes allocated
==10403== 
==10403== LEAK SUMMARY:
==10403==    definitely lost: 32,832 bytes in 3 blocks
==10403==    indirectly lost: 4,792 bytes in 6 blocks
==10403==      possibly lost: 0 bytes in 0 blocks
==10403==    still reachable: 0 bytes in 0 blocks
==10403==         suppressed: 0 bytes in 0 blocks
==10403== Rerun with --leak-check=full to see details of leaked memory
==10403== 
==10403== For counts of detected and suppressed errors, rerun with: -v
==10403== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 5 -lt 3071
+ EXPECTED_LINES=5
++ grep '^[0-9][0-9]*$' out_5_3071
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=5 OUT_N=3071'
shuf-reservoir-sampling failed with IN_N=5 OUT_N=3071
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 3072
+ INPUT_LINES=5
+ OUTPUT_LINES=3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_5_3072
+ seq 5
==10411== Memcheck, a memory error detector
==10411== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10411== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10411== Command: shuf -n 3072 -o out_5_3072
==10411== 
--10411-- WARNING: unhandled syscall: 326
--10411-- You may be able to write your own handler.
--10411-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10411-- Nevertheless we consider this a bug.  Please report
--10411-- it at http://valgrind.org/support/bug_reports.html.
1
2
4
5
3
==10411== 
==10411== HEAP SUMMARY:
==10411==     in use at exit: 37,624 bytes in 9 blocks
==10411==   total heap usage: 12 allocs, 3 frees, 37,708 bytes allocated
==10411== 
==10411== LEAK SUMMARY:
==10411==    definitely lost: 32,832 bytes in 3 blocks
==10411==    indirectly lost: 4,792 bytes in 6 blocks
==10411==      possibly lost: 0 bytes in 0 blocks
==10411==    still reachable: 0 bytes in 0 blocks
==10411==         suppressed: 0 bytes in 0 blocks
==10411== Rerun with --leak-check=full to see details of leaked memory
==10411== 
==10411== For counts of detected and suppressed errors, rerun with: -v
==10411== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 5 -lt 3072
+ EXPECTED_LINES=5
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_5_3072
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=5 OUT_N=3072'
shuf-reservoir-sampling failed with IN_N=5 OUT_N=3072
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 5 3073
+ INPUT_LINES=5
+ OUTPUT_LINES=3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_5_3073
+ seq 5
==10419== Memcheck, a memory error detector
==10419== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10419== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10419== Command: shuf -n 3073 -o out_5_3073
==10419== 
--10419-- WARNING: unhandled syscall: 326
--10419-- You may be able to write your own handler.
--10419-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10419-- Nevertheless we consider this a bug.  Please report
--10419-- it at http://valgrind.org/support/bug_reports.html.
4
1
2
5
3
==10419== 
==10419== HEAP SUMMARY:
==10419==     in use at exit: 37,624 bytes in 9 blocks
==10419==   total heap usage: 12 allocs, 3 frees, 37,708 bytes allocated
==10419== 
==10419== LEAK SUMMARY:
==10419==    definitely lost: 32,832 bytes in 3 blocks
==10419==    indirectly lost: 4,792 bytes in 6 blocks
==10419==      possibly lost: 0 bytes in 0 blocks
==10419==    still reachable: 0 bytes in 0 blocks
==10419==         suppressed: 0 bytes in 0 blocks
==10419== Rerun with --leak-check=full to see details of leaked memory
==10419== 
==10419== For counts of detected and suppressed errors, rerun with: -v
==10419== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 5 -lt 3073
+ EXPECTED_LINES=5
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_5_3073
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=5 OUT_N=3073'
shuf-reservoir-sampling failed with IN_N=5 OUT_N=3073
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 0
+ INPUT_LINES=1023
+ OUTPUT_LINES=0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_1023_0
+ seq 1023
==10427== Memcheck, a memory error detector
==10427== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10427== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10427== Command: shuf -n 0 -o out_1023_0
==10427== 
--10427-- WARNING: unhandled syscall: 326
--10427-- You may be able to write your own handler.
--10427-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10427-- Nevertheless we consider this a bug.  Please report
--10427-- it at http://valgrind.org/support/bug_reports.html.
==10427== 
==10427== HEAP SUMMARY:
==10427==     in use at exit: 4,176 bytes in 3 blocks
==10427==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10427== 
==10427== LEAK SUMMARY:
==10427==    definitely lost: 24 bytes in 2 blocks
==10427==    indirectly lost: 4,152 bytes in 1 blocks
==10427==      possibly lost: 0 bytes in 0 blocks
==10427==    still reachable: 0 bytes in 0 blocks
==10427==         suppressed: 0 bytes in 0 blocks
==10427== Rerun with --leak-check=full to see details of leaked memory
==10427== 
==10427== For counts of detected and suppressed errors, rerun with: -v
==10427== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 1023 -lt 0
++ grep '^[0-9][0-9]*$' out_1023_0
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 1
+ INPUT_LINES=1023
+ OUTPUT_LINES=1
+ seq 1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_1023_1
==10439== Memcheck, a memory error detector
==10439== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10439== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10439== Command: shuf -n 1 -o out_1023_1
==10439== 
--10439-- WARNING: unhandled syscall: 326
--10439-- You may be able to write your own handler.
--10439-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10439-- Nevertheless we consider this a bug.  Please report
--10439-- it at http://valgrind.org/support/bug_reports.html.
498
==10439== 
==10439== HEAP SUMMARY:
==10439==     in use at exit: 37,112 bytes in 5 blocks
==10439==   total heap usage: 9 allocs, 4 frees, 37,316 bytes allocated
==10439== 
==10439== LEAK SUMMARY:
==10439==    definitely lost: 32,832 bytes in 3 blocks
==10439==    indirectly lost: 4,280 bytes in 2 blocks
==10439==      possibly lost: 0 bytes in 0 blocks
==10439==    still reachable: 0 bytes in 0 blocks
==10439==         suppressed: 0 bytes in 0 blocks
==10439== Rerun with --leak-check=full to see details of leaked memory
==10439== 
==10439== For counts of detected and suppressed errors, rerun with: -v
==10439== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 1023 -lt 1
++ grep '^[0-9][0-9]*$' out_1023_1
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1023 OUT_N=1'
shuf-reservoir-sampling failed with IN_N=1023 OUT_N=1
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 5
+ INPUT_LINES=1023
+ OUTPUT_LINES=5
+ seq 1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_1023_5
==10447== Memcheck, a memory error detector
==10447== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10447== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10447== Command: shuf -n 5 -o out_1023_5
==10447== 
--10447-- WARNING: unhandled syscall: 326
--10447-- You may be able to write your own handler.
--10447-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10447-- Nevertheless we consider this a bug.  Please report
--10447-- it at http://valgrind.org/support/bug_reports.html.
62
927
921
597
294
==10447== 
==10447== HEAP SUMMARY:
==10447==     in use at exit: 37,784 bytes in 9 blocks
==10447==   total heap usage: 14 allocs, 5 frees, 38,156 bytes allocated
==10447== 
==10447== LEAK SUMMARY:
==10447==    definitely lost: 32,992 bytes in 3 blocks
==10447==    indirectly lost: 4,792 bytes in 6 blocks
==10447==      possibly lost: 0 bytes in 0 blocks
==10447==    still reachable: 0 bytes in 0 blocks
==10447==         suppressed: 0 bytes in 0 blocks
==10447== Rerun with --leak-check=full to see details of leaked memory
==10447== 
==10447== For counts of detected and suppressed errors, rerun with: -v
==10447== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 1023 -lt 5
++ wc -l
++ grep '^[0-9][0-9]*$' out_1023_5
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1023 OUT_N=5'
shuf-reservoir-sampling failed with IN_N=1023 OUT_N=5
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 1023
+ INPUT_LINES=1023
+ OUTPUT_LINES=1023
+ seq 1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_1023_1023
==10455== Memcheck, a memory error detector
==10455== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10455== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10455== Command: shuf -n 1023 -o out_1023_1023
==10455== 
--10455-- WARNING: unhandled syscall: 326
--10455-- You may be able to write your own handler.
--10455-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10455-- Nevertheless we consider this a bug.  Please report
--10455-- it at http://valgrind.org/support/bug_reports.html.
133
677
228
319
923
899
330
693
697
518
921
255
994
429
344
148
514
658
643
700
515
308
524
747
487
938
763
407
572
103
13
878
270
575
20
42
616
628
999
387
933
730
2
584
578
318
541
184
873
422
728
468
379
527
833
181
827
492
655
637
179
622
633
711
392
1017
58
365
937
880
720
629
991
3
414
731
232
93
108
813
51
681
953
15
236
589
756
301
678
403
624
944
109
464
983
904
802
738
1009
718
532
406
612
579
743
101
388
696
447
102
828
22
352
753
639
980
194
59
839
798
374
328
774
556
262
794
898
268
84
565
716
837
222
866
868
705
965
176
36
169
567
310
482
679
432
281
672
223
508
762
954
883
671
46
653
435
956
542
89
287
191
34
909
635
274
264
561
758
325
311
558
348
955
989
382
732
215
727
793
277
258
423
1011
976
154
864
564
63
260
804
475
911
947
861
196
834
611
526
698
416
552
922
525
74
852
865
94
603
702
733
849
91
673
491
997
78
574
97
854
453
654
96
206
498
729
309
941
913
596
951
928
893
592
770
663
581
550
189
1001
79
749
858
151
326
327
201
814
302
493
156
360
969
820
193
791
88
767
563
848
538
130
345
329
829
280
668
907
695
615
473
799
995
597
988
780
535
477
652
808
419
293
940
242
509
405
192
680
992
840
166
1004
973
55
362
935
198
805
61
819
48
122
165
355
433
978
649
202
970
340
251
252
225
336
894
657
662
516
595
254
495
830
776
436
555
887
766
895
985
354
356
609
60
9
703
28
536
265
320
27
942
630
930
361
607
896
1014
958
237
230
399
351
177
617
949
613
200
765
478
682
415
39
446
371
912
809
548
948
709
945
605
842
961
142
146
44
155
289
751
500
4
445
172
442
158
537
381
205
248
227
99
531
803
317
783
396
975
175
457
496
870
760
370
906
1000
855
737
506
346
421
796
549
667
587
918
246
216
777
29
734
217
164
494
625
759
801
841
875
67
118
37
137
708
623
239
1016
570
706
645
903
971
271
366
450
869
691
434
523
285
787
92
461
786
914
257
1018
519
24
378
534
610
788
204
23
836
1007
739
397
604
363
606
946
569
367
33
41
377
1006
998
413
576
685
353
18
481
972
502
512
546
710
100
571
746
284
846
823
476
161
768
742
162
437
908
199
915
474
272
725
195
306
857
817
233
562
375
844
987
410
488
600
418
64
748
385
863
726
924
173
1008
40
21
967
119
291
279
386
167
390
77
646
963
533
145
322
295
740
962
916
722
203
897
296
631
143
669
568
593
126
993
666
665
451
547
807
389
6
57
982
910
602
14
300
782
566
797
187
719
577
31
12
784
129
795
211
152
986
128
881
862
752
636
1022
369
920
68
452
859
511
757
919
557
140
111
153
132
427
789
83
651
676
294
138
220
218
7
934
902
560
510
713
544
87
82
790
845
342
458
761
45
860
1003
183
338
707
229
939
745
741
701
530
950
889
75
171
394
314
448
816
471
244
69
11
444
56
462
117
539
113
872
17
136
197
428
290
443
350
424
253
213
867
52
634
520
815
71
384
5
43
139
53
73
554
882
885
30
1012
50
286
684
900
221
256
81
779
163
449
249
86
19
439
876
315
981
891
278
714
460
877
159
333
8
736
160
10
214
490
832
598
690
627
112
966
964
886
324
26
334
25
513
687
332
470
499
977
822
116
131
778
275
979
528
692
455
185
936
675
245
806
769
313
459
343
586
483
234
393
583
694
190
764
316
207
781
174
517
312
182
383
54
599
404
359
771
480
688
890
339
717
661
409
147
489
642
785
901
521
540
545
323
80
1013
773
454
879
212
467
825
463
735
704
484
104
1020
250
219
831
188
186
135
594
276
124
127
358
269
960
838
331
141
304
1019
660
929
1015
486
638
16
420
905
466
754
32
551
744
178
968
411
850
943
341
818
580
543
588
347
1
504
990
431
149
398
226
871
812
772
98
408
644
400
591
755
874
157
573
123
38
856
282
608
425
585
959
650
824
357
601
553
479
373
426
917
884
243
35
659
288
337
721
273
47
712
590
529
835
826
49
984
647
106
507
72
430
263
456
85
438
1010
472
853
224
121
699
95
62
349
618
683
670
391
259
235
931
632
497
180
957
240
115
321
626
441
559
376
70
800
664
417
307
65
851
150
283
247
750
401
843
932
847
952
440
522
689
641
209
364
715
619
505
297
821
90
168
648
724
76
231
1023
144
469
402
241
299
892
1002
210
1021
674
66
621
303
1005
925
614
368
656
261
412
266
134
723
974
335
927
292
926
620
238
503
114
810
380
107
208
888
120
110
305
501
465
485
811
996
105
775
298
372
125
395
686
170
267
640
792
582
==10455== 
==10455== HEAP SUMMARY:
==10455==     in use at exit: 208,808 bytes in 1,027 blocks
==10455==   total heap usage: 1,031 allocs, 4 frees, 249,772 bytes allocated
==10455== 
==10455== LEAK SUMMARY:
==10455==    definitely lost: 73,712 bytes in 3 blocks
==10455==    indirectly lost: 135,096 bytes in 1,024 blocks
==10455==      possibly lost: 0 bytes in 0 blocks
==10455==    still reachable: 0 bytes in 0 blocks
==10455==         suppressed: 0 bytes in 0 blocks
==10455== Rerun with --leak-check=full to see details of leaked memory
==10455== 
==10455== For counts of detected and suppressed errors, rerun with: -v
==10455== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 1023 -lt 1023
++ grep '^[0-9][0-9]*$' out_1023_1023
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1023 OUT_N=1023'
shuf-reservoir-sampling failed with IN_N=1023 OUT_N=1023
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 1024
+ INPUT_LINES=1023
+ OUTPUT_LINES=1024
+ seq 1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_1023_1024
==10463== Memcheck, a memory error detector
==10463== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10463== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10463== Command: shuf -n 1024 -o out_1023_1024
==10463== 
--10463-- WARNING: unhandled syscall: 326
--10463-- You may be able to write your own handler.
--10463-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10463-- Nevertheless we consider this a bug.  Please report
--10463-- it at http://valgrind.org/support/bug_reports.html.
744
998
706
484
796
590
334
858
346
126
786
371
424
28
44
138
323
846
144
6
16
575
479
487
90
785
771
111
886
923
325
99
349
994
137
898
553
1023
475
758
535
446
530
681
594
621
511
764
451
423
632
67
629
297
814
881
984
3
900
726
224
506
86
939
253
698
697
53
186
242
164
360
200
251
723
755
869
388
233
559
486
196
776
513
763
516
735
189
467
64
851
10
288
866
762
442
946
400
240
971
854
847
195
944
148
903
100
485
844
465
26
793
525
221
208
478
78
33
692
504
877
246
373
612
258
149
874
353
722
460
113
102
684
174
142
896
229
285
658
617
579
185
54
1005
782
133
274
50
4
801
540
784
980
471
935
991
875
282
728
750
902
335
734
704
348
595
1019
252
645
757
560
892
312
24
51
674
792
411
326
876
306
670
415
743
404
40
783
27
207
19
929
459
651
655
983
826
933
578
599
956
721
223
385
448
462
376
234
897
1014
518
316
839
834
714
642
765
880
967
77
696
907
890
686
592
746
835
521
934
585
523
986
175
31
158
45
87
526
230
324
711
904
821
141
89
871
715
118
358
817
804
238
157
852
841
232
392
761
855
172
608
689
22
211
569
798
544
982
167
675
581
368
378
862
891
968
98
527
331
5
480
838
66
184
296
272
290
268
433
396
618
384
351
767
52
213
123
542
737
724
601
257
235
887
545
473
30
444
205
687
508
345
227
905
512
76
634
719
168
607
546
397
458
55
807
794
703
267
961
602
562
341
883
439
109
671
848
461
567
409
12
780
436
275
333
20
464
908
573
775
414
309
46
463
347
941
805
668
1000
996
924
482
614
271
261
495
492
727
507
639
93
588
849
921
214
736
906
830
596
147
445
797
206
318
405
587
647
705
260
156
454
387
769
418
299
628
820
342
354
808
91
873
593
748
11
1022
812
363
310
964
1015
56
977
121
63
777
187
319
47
517
619
305
197
597
466
878
974
483
911
751
548
307
894
571
36
948
255
263
937
701
806
107
269
811
150
62
216
120
59
29
603
627
210
532
800
774
533
245
170
564
244
236
190
426
995
169
417
204
515
966
659
779
430
135
712
32
963
71
557
228
278
928
416
915
819
81
389
922
287
166
1001
119
2
856
128
549
281
110
718
327
802
496
152
398
552
914
8
215
901
145
863
70
104
610
860
191
630
413
143
390
669
160
43
882
510
930
831
114
1020
867
861
836
702
693
653
266
357
336
678
407
364
531
625
577
960
829
356
497
117
199
539
502
931
845
328
938
870
422
888
541
565
554
237
789
367
816
489
600
286
366
613
700
231
292
60
365
720
679
82
37
623
680
842
815
648
981
742
209
916
850
108
72
315
993
664
450
437
652
694
134
753
85
992
555
151
893
773
359
953
637
954
868
431
713
457
311
640
864
247
833
895
943
1013
739
738
429
132
38
452
772
106
682
568
760
708
92
273
589
818
218
372
129
709
909
536
574
14
810
740
7
352
605
225
1018
917
609
188
469
913
177
321
822
563
394
949
688
500
377
264
402
643
226
537
529
576
990
973
425
379
340
361
103
729
644
219
498
279
337
332
561
666
837
586
308
932
381
270
420
926
317
791
781
477
173
947
304
959
624
745
859
239
551
979
766
198
662
1007
534
291
580
583
985
248
641
790
731
289
481
386
262
432
153
193
925
241
1006
635
399
950
277
294
528
79
509
162
499
176
853
293
447
395
302
795
180
202
375
403
192
978
827
182
435
604
1004
23
716
370
408
501
1010
25
101
550
733
493
1008
146
42
125
112
179
1016
591
1017
406
362
383
212
139
685
823
646
105
254
768
21
140
283
840
136
440
250
522
611
936
222
472
421
665
676
976
39
1003
730
606
159
1021
201
957
918
633
656
488
615
391
677
410
57
519
538
115
249
163
503
598
1002
295
940
1
427
857
49
15
699
468
770
631
127
300
825
220
710
94
970
412
732
584
725
972
514
35
824
663
945
620
889
759
75
524
566
558
338
638
65
885
582
455
1009
61
988
987
58
276
453
154
969
17
298
778
203
339
919
879
749
183
97
256
747
243
616
754
672
96
343
952
344
369
962
34
314
695
456
872
657
441
329
490
958
320
927
547
999
380
13
73
355
654
707
443
920
280
69
997
401
1011
955
832
95
965
942
171
303
48
843
265
155
787
131
572
428
975
813
259
491
84
622
124
828
476
130
374
636
178
691
690
322
161
543
116
284
68
74
570
717
650
301
330
799
910
434
350
474
494
660
899
912
661
556
382
438
122
667
741
9
649
41
80
449
313
683
393
626
809
673
470
165
1012
419
83
505
865
752
194
951
884
18
520
181
756
989
88
788
217
803
==10463== 
==10463== HEAP SUMMARY:
==10463==     in use at exit: 176,072 bytes in 1,027 blocks
==10463==   total heap usage: 1,030 allocs, 3 frees, 184,300 bytes allocated
==10463== 
==10463== LEAK SUMMARY:
==10463==    definitely lost: 40,976 bytes in 3 blocks
==10463==    indirectly lost: 135,096 bytes in 1,024 blocks
==10463==      possibly lost: 0 bytes in 0 blocks
==10463==    still reachable: 0 bytes in 0 blocks
==10463==         suppressed: 0 bytes in 0 blocks
==10463== Rerun with --leak-check=full to see details of leaked memory
==10463== 
==10463== For counts of detected and suppressed errors, rerun with: -v
==10463== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 1023 -lt 1024
+ EXPECTED_LINES=1023
++ sort -un
++ grep '^[0-9][0-9]*$' out_1023_1024
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1023 OUT_N=1024'
shuf-reservoir-sampling failed with IN_N=1023 OUT_N=1024
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 1025
+ INPUT_LINES=1023
+ OUTPUT_LINES=1025
+ seq 1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_1023_1025
==10475== Memcheck, a memory error detector
==10475== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10475== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10475== Command: shuf -n 1025 -o out_1023_1025
==10475== 
--10475-- WARNING: unhandled syscall: 326
--10475-- You may be able to write your own handler.
--10475-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10475-- Nevertheless we consider this a bug.  Please report
--10475-- it at http://valgrind.org/support/bug_reports.html.
515
695
182
157
300
795
265
562
976
202
975
32
171
276
298
409
96
110
406
139
808
173
595
236
696
974
1004
321
662
42
731
308
580
929
899
459
898
888
62
225
539
366
26
263
324
395
465
414
461
534
432
74
314
680
643
994
205
642
1
380
1019
332
194
203
55
996
875
868
83
646
373
918
441
627
653
569
824
1009
372
809
399
776
230
968
707
149
271
12
572
946
835
301
852
179
518
923
524
422
29
979
872
964
353
495
679
896
716
727
365
85
766
307
346
292
76
40
151
167
326
514
955
132
953
704
15
750
971
895
988
943
48
885
601
901
473
4
559
161
272
777
208
264
56
543
919
75
837
239
632
8
266
247
706
440
770
20
917
517
509
141
1003
386
553
960
470
223
796
188
134
278
241
224
421
310
856
175
586
830
382
93
659
938
690
849
242
870
108
1014
591
17
914
492
485
691
168
187
593
565
548
79
816
634
322
887
71
106
833
445
23
502
60
234
89
368
90
297
811
519
361
410
381
335
726
523
84
311
362
129
419
530
78
316
318
251
883
840
193
537
102
692
257
426
527
876
754
689
500
113
163
864
317
616
51
949
435
664
863
212
965
674
491
288
417
635
745
480
577
217
669
213
677
985
655
657
760
904
609
45
928
697
545
718
709
723
951
119
670
1007
494
900
43
481
682
892
190
889
150
654
602
621
667
513
874
156
73
120
348
95
721
476
413
867
890
216
453
61
948
922
291
749
174
571
956
717
376
207
463
404
848
111
820
72
458
1020
568
484
959
438
926
832
320
730
628
915
843
37
358
511
784
547
880
286
295
705
508
137
123
958
780
262
472
676
349
209
489
229
237
936
260
394
97
443
238
493
857
800
724
521
467
180
710
10
328
736
590
418
9
285
930
24
351
455
792
728
758
220
47
970
369
400
431
210
177
258
600
166
712
785
541
437
884
1005
672
921
232
339
997
462
995
430
583
957
30
683
794
21
412
969
850
873
429
581
305
694
555
58
673
681
631
735
608
490
1013
630
254
782
231
552
741
398
46
267
982
768
345
684
112
67
109
282
14
549
397
886
1023
934
343
138
913
164
556
998
392
935
972
546
698
450
575
902
222
790
815
910
759
801
911
464
275
477
978
512
105
192
645
633
354
482
757
1022
772
454
640
761
350
155
293
986
762
54
378
980
945
907
756
961
703
370
909
385
133
122
701
906
299
755
865
170
383
92
488
1017
805
195
587
1008
389
344
303
359
665
802
142
596
903
589
529
6
1018
456
804
789
908
269
866
649
540
451
259
118
668
31
147
753
516
5
597
661
878
268
235
558
663
858
68
436
356
64
197
1016
3
660
114
732
807
498
1000
331
894
828
981
496
2
402
787
554
686
333
666
522
615
374
227
641
478
218
610
41
625
162
468
448
779
862
252
505
244
1010
612
1015
617
425
304
487
387
783
240
340
920
469
594
18
656
371
261
152
306
100
678
838
65
987
614
66
699
352
536
11
984
289
309
104
743
427
169
533
153
63
652
535
396
847
853
639
826
86
338
851
773
98
200
624
931
486
557
50
126
446
799
393
564
861
59
80
460
685
962
859
501
592
933
503
561
401
255
1011
127
337
77
28
992
248
671
831
532
199
325
296
447
407
33
778
428
611
284
725
810
844
377
181
507
186
814
977
294
842
651
510
471
720
313
599
91
246
57
700
116
329
675
650
367
449
812
1006
415
525
145
198
253
466
312
342
319
245
479
1002
882
797
228
737
330
52
860
924
897
687
891
49
582
836
103
798
950
622
966
542
363
128
576
196
158
973
347
584
629
774
483
734
746
855
405
713
211
444
818
101
420
189
803
499
829
160
748
39
336
714
13
817
932
121
574
416
636
94
775
172
520
942
823
497
423
219
567
765
620
274
178
827
474
206
940
243
834
786
22
504
273
702
999
107
327
742
176
604
146
588
939
722
390
221
69
140
991
751
603
793
442
551
771
788
82
124
391
364
573
989
143
626
688
990
125
623
279
70
115
871
88
993
767
7
763
954
578
457
36
566
813
87
81
825
183
893
302
452
280
644
357
185
130
841
941
738
214
249
165
375
619
637
506
315
764
605
963
740
148
821
117
355
25
747
131
927
846
839
403
250
526
739
744
277
154
570
528
135
270
648
819
806
693
233
937
791
1021
607
752
384
647
44
822
19
191
854
35
658
531
967
613
877
34
27
869
606
538
159
434
708
638
769
1012
618
952
184
433
879
944
283
711
53
323
341
925
226
729
733
563
201
585
379
215
947
360
881
905
204
579
916
475
144
334
287
781
290
99
715
598
408
411
281
424
544
560
845
983
136
550
388
256
439
38
912
16
719
1001
==10475== 
==10475== HEAP SUMMARY:
==10475==     in use at exit: 176,072 bytes in 1,027 blocks
==10475==   total heap usage: 1,030 allocs, 3 frees, 184,300 bytes allocated
==10475== 
==10475== LEAK SUMMARY:
==10475==    definitely lost: 40,976 bytes in 3 blocks
==10475==    indirectly lost: 135,096 bytes in 1,024 blocks
==10475==      possibly lost: 0 bytes in 0 blocks
==10475==    still reachable: 0 bytes in 0 blocks
==10475==         suppressed: 0 bytes in 0 blocks
==10475== Rerun with --leak-check=full to see details of leaked memory
==10475== 
==10475== For counts of detected and suppressed errors, rerun with: -v
==10475== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 1023 -lt 1025
+ EXPECTED_LINES=1023
++ grep '^[0-9][0-9]*$' out_1023_1025
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1023 OUT_N=1025'
shuf-reservoir-sampling failed with IN_N=1023 OUT_N=1025
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 3071
+ INPUT_LINES=1023
+ OUTPUT_LINES=3071
+ seq 1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_1023_3071
==10485== Memcheck, a memory error detector
==10485== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10485== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10485== Command: shuf -n 3071 -o out_1023_3071
==10485== 
--10485-- WARNING: unhandled syscall: 326
--10485-- You may be able to write your own handler.
--10485-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10485-- Nevertheless we consider this a bug.  Please report
--10485-- it at http://valgrind.org/support/bug_reports.html.
126
246
211
374
498
636
301
474
410
764
722
640
787
799
645
408
905
472
511
679
497
419
801
849
423
931
278
884
37
4
814
706
886
335
985
750
754
114
65
668
591
29
643
220
57
299
297
843
928
411
251
175
418
143
934
915
540
527
282
302
773
387
963
26
179
140
635
303
356
491
46
195
324
774
790
516
167
24
912
424
855
340
487
142
700
609
181
1023
962
736
1004
214
909
475
577
265
812
231
461
740
917
97
200
415
727
429
663
853
1
196
620
435
974
617
987
817
67
359
6
880
986
786
395
852
205
385
861
868
451
263
427
32
346
12
820
621
235
286
692
406
428
397
445
19
634
742
542
827
448
420
249
380
227
371
80
749
219
317
911
869
580
545
587
657
396
719
818
384
983
351
590
283
870
163
357
977
604
658
407
353
655
388
74
113
117
936
88
875
328
517
562
567
85
260
76
794
661
789
899
602
478
193
273
939
753
156
923
321
922
292
306
539
887
721
449
772
506
252
446
412
744
937
766
519
352
532
290
354
995
182
336
996
269
267
589
136
234
204
964
631
876
708
769
879
369
777
493
1013
576
508
628
984
330
355
123
216
903
625
66
103
39
791
8
897
513
919
710
373
687
503
558
394
763
504
170
839
832
739
538
776
488
171
990
862
81
690
308
867
151
36
638
5
933
426
809
198
184
28
771
215
819
560
748
910
1001
725
201
858
548
285
664
639
7
619
935
20
479
730
155
443
537
531
469
874
656
45
705
717
450
42
104
218
362
505
270
945
901
383
906
266
566
544
885
471
255
61
543
806
993
782
541
358
90
3
941
44
35
572
597
788
416
660
815
264
981
840
298
434
393
916
63
391
381
975
495
457
930
932
296
616
716
238
601
217
846
895
890
244
892
110
654
737
810
107
489
133
907
994
802
75
186
672
208
518
778
131
314
280
579
976
866
698
1012
581
135
677
190
767
10
492
134
226
379
583
108
318
729
563
172
714
997
348
582
82
834
16
831
770
697
64
969
530
188
331
95
598
485
594
300
943
399
1019
825
92
653
413
197
389
360
629
768
724
363
551
501
322
494
523
291
795
27
711
232
988
248
533
611
1011
955
608
272
651
78
173
733
626
805
529
599
345
253
183
432
522
741
372
18
804
166
675
979
93
829
961
844
751
998
878
102
857
1005
520
913
946
99
277
453
262
723
944
588
632
775
1015
603
712
130
784
287
241
718
571
11
908
745
693
482
137
850
414
111
689
948
225
30
54
69
627
433
147
669
833
440
375
1018
386
158
154
860
807
678
942
863
826
496
109
458
968
515
378
398
294
835
573
650
305
55
966
245
157
221
605
989
965
164
564
405
342
320
258
757
17
949
34
191
120
982
96
436
696
646
247
307
56
865
556
84
401
115
600
365
316
460
894
547
52
274
189
924
261
980
464
455
14
148
785
709
952
1020
893
127
557
821
851
685
800
607
444
87
507
528
125
47
676
477
681
841
421
561
630
686
72
509
1008
877
813
404
23
623
122
139
971
883
822
431
637
743
659
312
960
2
707
329
128
553
585
400
41
481
144
1006
141
213
614
735
327
284
146
808
953
842
38
592
177
914
483
779
159
872
268
49
673
51
1010
121
713
468
350
402
720
667
1009
83
439
168
254
959
612
94
293
50
367
896
1002
536
1007
304
684
762
180
333
370
565
366
836
199
15
21
500
476
845
187
161
864
152
13
132
364
633
701
206
339
838
525
169
165
417
958
759
347
1014
332
70
534
900
624
555
392
781
854
606
467
674
442
610
119
683
904
129
652
830
228
648
230
595
559
368
1003
856
502
145
999
240
58
349
313
486
116
688
927
694
731
40
873
803
31
222
438
59
236
554
192
586
535
1017
53
463
756
552
647
926
691
510
792
695
940
613
224
62
699
596
202
972
33
898
275
546
760
124
797
967
194
765
593
891
703
279
98
526
704
281
738
780
233
1016
992
570
918
311
682
25
323
160
243
978
185
288
920
149
665
100
441
670
837
257
250
447
902
425
452
466
578
954
828
325
79
662
9
341
470
514
229
957
212
521
101
337
859
728
569
882
22
271
798
758
377
43
584
888
680
973
726
925
344
649
671
162
473
755
319
550
310
991
207
574
480
239
176
734
746
60
118
73
1021
203
823
847
732
315
223
618
549
422
77
276
178
361
615
343
242
490
783
256
1022
575
761
48
848
622
796
138
929
871
1000
456
811
382
881
237
568
409
71
105
106
459
89
112
465
524
702
499
326
715
210
153
970
644
289
950
816
793
68
403
462
641
752
666
209
747
309
376
824
921
642
454
334
947
951
956
484
938
430
174
150
86
91
259
338
295
889
390
437
512
==10485== 
==10485== HEAP SUMMARY:
==10485==     in use at exit: 176,072 bytes in 1,027 blocks
==10485==   total heap usage: 1,030 allocs, 3 frees, 184,300 bytes allocated
==10485== 
==10485== LEAK SUMMARY:
==10485==    definitely lost: 40,976 bytes in 3 blocks
==10485==    indirectly lost: 135,096 bytes in 1,024 blocks
==10485==      possibly lost: 0 bytes in 0 blocks
==10485==    still reachable: 0 bytes in 0 blocks
==10485==         suppressed: 0 bytes in 0 blocks
==10485== Rerun with --leak-check=full to see details of leaked memory
==10485== 
==10485== For counts of detected and suppressed errors, rerun with: -v
==10485== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 1023 -lt 3071
+ EXPECTED_LINES=1023
++ grep '^[0-9][0-9]*$' out_1023_3071
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1023 OUT_N=3071'
shuf-reservoir-sampling failed with IN_N=1023 OUT_N=3071
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 3072
+ INPUT_LINES=1023
+ OUTPUT_LINES=3072
+ seq 1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_1023_3072
==10494== Memcheck, a memory error detector
==10494== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10494== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10494== Command: shuf -n 3072 -o out_1023_3072
==10494== 
--10494-- WARNING: unhandled syscall: 326
--10494-- You may be able to write your own handler.
--10494-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10494-- Nevertheless we consider this a bug.  Please report
--10494-- it at http://valgrind.org/support/bug_reports.html.
860
689
896
663
971
1015
413
577
406
565
688
307
258
742
904
310
408
714
367
33
462
985
49
266
189
159
819
857
773
32
241
942
302
789
23
335
992
146
36
625
267
131
196
943
328
444
272
210
647
384
821
51
677
1014
18
480
377
707
995
834
526
468
560
914
842
112
255
175
303
554
787
236
817
342
398
903
349
756
938
948
142
776
826
429
551
280
811
613
606
708
211
295
659
198
790
357
399
558
344
608
58
833
15
947
936
845
26
361
256
296
40
570
422
851
673
178
115
541
916
510
683
252
810
639
686
701
466
221
339
595
508
501
8
653
250
412
794
848
495
1002
181
103
200
108
325
88
907
887
585
940
998
996
454
588
749
581
594
994
188
185
726
747
562
921
533
27
136
358
561
702
114
155
333
829
313
563
504
48
861
204
143
446
880
930
908
607
414
511
576
838
80
338
950
544
424
583
1016
356
777
926
667
260
331
932
572
670
820
233
662
965
1022
127
57
430
600
537
352
897
165
81
158
407
812
391
294
166
513
630
846
276
760
450
201
505
981
975
288
148
100
482
602
655
161
213
644
465
697
751
931
138
980
674
300
113
283
758
9
311
764
894
243
571
604
240
844
506
312
818
20
648
837
7
354
74
228
546
876
672
553
949
884
925
104
734
902
401
624
212
492
370
279
626
183
631
792
441
905
224
617
485
170
609
231
878
543
850
222
856
671
664
70
835
34
97
219
478
853
477
319
244
574
484
919
281
800
47
494
976
815
137
509
612
669
471
888
392
923
679
301
379
866
439
329
575
315
693
321
591
535
10
489
237
855
89
341
728
909
308
487
1009
218
924
682
704
806
400
393
298
1023
387
522
1017
206
769
978
619
1019
234
52
167
705
147
952
93
783
13
597
549
869
517
259
512
128
420
44
157
717
636
970
479
1003
124
225
814
78
666
917
885
229
883
805
872
53
347
129
500
737
467
539
180
31
935
63
235
360
770
733
96
278
523
265
502
410
552
476
966
287
632
205
678
605
431
753
437
246
731
177
634
343
656
1
130
363
488
766
172
190
738
877
498
886
409
490
427
929
152
750
660
285
145
173
668
144
264
633
1018
791
126
320
238
299
988
449
54
491
863
991
763
245
153
799
614
22
326
665
132
859
723
603
168
867
117
351
732
706
220
292
72
1000
503
676
105
843
864
309
1012
3
599
209
748
197
519
156
305
374
368
661
635
724
346
937
911
559
184
720
739
637
712
700
620
744
140
556
716
545
419
475
369
434
226
458
464
913
12
348
332
291
934
521
569
532
780
703
455
836
239
918
451
71
248
797
698
579
804
755
395
249
735
297
30
438
16
79
350
854
442
775
824
580
411
584
592
435
685
912
192
262
841
323
227
740
839
691
216
389
548
337
418
578
110
134
46
713
83
920
1011
865
610
150
95
203
171
55
77
396
67
690
376
652
270
767
268
290
355
82
1007
765
316
989
405
107
910
187
92
87
421
282
873
417
586
247
898
483
426
2
823
11
761
687
782
746
809
1001
28
463
525
527
847
601
881
874
306
1008
889
564
922
725
59
827
871
193
120
293
915
524
470
327
754
269
62
84
540
759
496
516
373
593
757
378
718
385
650
960
951
623
589
730
531
154
906
933
993
432
402
958
890
274
139
43
692
433
94
486
928
590
891
611
786
968
801
999
774
963
164
254
35
91
536
956
997
359
118
76
121
959
289
699
73
149
710
962
743
657
983
961
972
587
29
1006
979
386
68
207
528
641
944
684
151
568
779
567
345
515
875
428
984
45
6
42
973
460
314
555
39
645
646
709
954
473
520
456
582
722
557
745
304
90
649
195
538
813
382
550
741
499
24
771
825
695
832
457
404
169
436
403
638
125
202
643
781
176
372
415
622
518
1013
86
251
798
5
830
257
507
194
461
322
598
380
651
440
547
900
514
179
383
261
803
416
621
1005
286
615
640
56
566
796
397
69
364
215
542
831
453
795
160
366
497
101
362
945
230
969
481
208
840
284
271
694
729
627
163
1010
340
102
214
828
957
381
390
324
736
242
893
793
232
808
529
785
493
762
1021
275
870
459
964
977
711
642
452
133
365
681
596
987
60
752
768
953
618
445
727
715
85
986
447
75
186
1004
474
330
116
162
217
858
336
448
899
423
534
109
122
895
469
277
14
191
822
675
719
119
182
654
616
879
64
802
106
174
955
628
852
99
135
868
807
862
946
892
696
784
66
967
788
394
927
388
680
1020
141
816
334
375
772
65
50
19
223
990
61
123
939
38
353
4
253
318
41
778
98
901
21
472
849
371
721
982
25
573
317
273
199
17
37
658
882
941
111
530
425
629
263
443
974
==10494== 
==10494== HEAP SUMMARY:
==10494==     in use at exit: 176,072 bytes in 1,027 blocks
==10494==   total heap usage: 1,030 allocs, 3 frees, 184,300 bytes allocated
==10494== 
==10494== LEAK SUMMARY:
==10494==    definitely lost: 40,976 bytes in 3 blocks
==10494==    indirectly lost: 135,096 bytes in 1,024 blocks
==10494==      possibly lost: 0 bytes in 0 blocks
==10494==    still reachable: 0 bytes in 0 blocks
==10494==         suppressed: 0 bytes in 0 blocks
==10494== Rerun with --leak-check=full to see details of leaked memory
==10494== 
==10494== For counts of detected and suppressed errors, rerun with: -v
==10494== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 1023 -lt 3072
+ EXPECTED_LINES=1023
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1023_3072
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1023 OUT_N=3072'
shuf-reservoir-sampling failed with IN_N=1023 OUT_N=3072
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1023 3073
+ INPUT_LINES=1023
+ OUTPUT_LINES=3073
+ seq 1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_1023_3073
==10510== Memcheck, a memory error detector
==10510== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10510== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10510== Command: shuf -n 3073 -o out_1023_3073
==10510== 
--10510-- WARNING: unhandled syscall: 326
--10510-- You may be able to write your own handler.
--10510-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10510-- Nevertheless we consider this a bug.  Please report
--10510-- it at http://valgrind.org/support/bug_reports.html.
363
439
243
252
381
691
268
23
609
322
522
703
980
393
185
948
258
25
786
222
534
564
14
269
331
688
81
981
531
966
330
410
856
196
719
22
152
301
162
92
935
740
357
567
707
779
442
875
419
260
913
505
33
516
588
212
412
118
655
448
536
384
662
736
377
248
895
910
476
526
538
198
361
866
123
68
205
383
431
203
722
284
36
580
435
57
794
61
947
366
991
265
764
462
943
10
506
134
992
854
12
104
1007
227
777
417
595
206
139
99
962
683
1006
250
542
932
1004
785
445
433
374
178
194
752
861
362
396
946
494
354
310
69
822
16
503
1019
909
543
745
107
210
182
150
873
797
1023
593
608
557
382
78
619
470
136
458
489
317
696
725
266
993
17
176
590
184
1022
305
115
343
664
73
485
765
193
627
811
806
302
616
144
221
509
645
541
606
5
646
32
824
360
838
648
610
373
418
316
293
1009
529
831
481
233
773
46
579
994
716
833
63
307
1018
235
38
157
553
490
730
138
872
844
97
429
791
602
154
510
982
647
169
72
281
120
584
495
443
79
53
680
413
49
141
718
483
731
788
488
261
882
408
883
701
969
28
314
171
453
263
714
111
401
259
880
887
1014
290
660
711
26
973
545
380
466
758
159
91
604
300
795
952
119
605
949
500
709
367
327
840
803
241
31
402
292
665
979
578
369
938
700
710
820
603
276
43
654
324
771
66
638
502
180
726
37
850
675
1005
350
518
1013
166
868
798
199
523
836
591
768
869
945
414
642
556
834
352
167
890
678
767
328
498
926
58
566
341
754
744
1010
674
826
1001
898
455
520
514
236
4
894
103
571
901
147
546
129
29
156
825
753
816
741
936
796
552
27
339
459
312
933
770
837
177
835
793
855
942
560
762
430
977
358
908
915
843
862
925
911
387
256
896
183
766
576
626
723
892
232
650
19
998
218
614
56
428
792
54
211
163
319
334
155
750
917
224
918
158
18
724
813
351
717
961
922
499
957
332
658
415
704
273
496
851
690
611
172
288
140
131
860
839
1016
954
669
274
39
468
108
729
225
267
270
337
101
705
956
280
340
780
746
437
640
356
349
47
778
186
454
815
179
329
353
240
1021
620
86
612
600
515
889
127
727
628
570
636
988
130
537
44
345
90
1000
2
434
624
208
391
450
832
597
812
98
592
950
385
963
424
637
246
175
404
684
112
271
682
804
472
906
242
287
504
125
927
528
247
364
95
577
335
974
83
983
55
692
978
708
1015
94
308
13
405
121
519
958
244
615
877
549
277
1
848
849
679
492
630
181
912
484
659
201
587
395
623
406
9
800
755
148
237
572
783
568
594
663
20
673
342
871
1003
617
486
238
122
940
65
257
756
321
965
275
336
400
976
449
254
698
106
959
422
411
209
784
7
781
497
456
558
699
153
379
986
289
416
997
228
562
533
15
223
52
88
67
151
452
1008
1002
189
375
625
823
220
21
548
817
403
799
589
666
694
818
944
931
447
59
964
941
747
720
365
569
561
924
114
51
830
828
607
923
644
295
697
751
713
48
903
653
802
320
64
423
575
573
482
420
888
599
953
681
685
899
313
893
876
814
782
972
805
547
749
987
585
425
480
389
735
278
984
372
582
239
262
202
829
77
478
279
200
446
170
168
881
622
188
272
586
477
677
253
955
598
376
444
204
214
721
304
517
858
309
283
87
904
807
475
790
865
621
934
126
110
618
661
467
392
80
776
190
769
311
346
315
728
440
878
554
473
229
512
318
137
128
702
160
867
601
164
999
551
535
187
635
656
245
732
760
146
348
469
117
71
216
847
789
928
772
285
333
62
344
841
84
1020
921
407
525
827
463
891
298
524
508
297
695
286
970
231
990
3
689
491
6
686
390
386
555
633
197
109
370
801
845
149
563
359
951
989
60
493
461
971
325
282
967
89
421
897
173
70
914
436
100
41
641
734
544
574
613
11
874
294
426
859
737
368
885
672
842
937
388
693
863
74
870
787
985
809
82
487
916
649
326
532
886
397
715
668
743
583
905
513
739
810
451
968
192
687
102
226
634
565
550
174
919
540
378
643
676
234
761
479
230
40
323
251
712
42
907
113
738
213
135
846
8
596
639
920
631
355
471
995
45
939
501
85
930
124
219
398
819
733
394
427
133
215
853
464
409
527
76
371
929
465
900
347
296
195
706
291
581
852
338
539
116
460
1017
996
857
399
960
457
75
255
1012
50
559
438
35
629
217
249
808
432
105
299
821
632
145
530
652
306
757
763
96
264
667
864
441
207
507
34
748
93
1011
975
511
884
143
24
657
775
165
521
742
670
161
671
774
142
474
30
132
902
651
303
879
759
191
==10510== 
==10510== HEAP SUMMARY:
==10510==     in use at exit: 176,072 bytes in 1,027 blocks
==10510==   total heap usage: 1,030 allocs, 3 frees, 184,300 bytes allocated
==10510== 
==10510== LEAK SUMMARY:
==10510==    definitely lost: 40,976 bytes in 3 blocks
==10510==    indirectly lost: 135,096 bytes in 1,024 blocks
==10510==      possibly lost: 0 bytes in 0 blocks
==10510==    still reachable: 0 bytes in 0 blocks
==10510==         suppressed: 0 bytes in 0 blocks
==10510== Rerun with --leak-check=full to see details of leaked memory
==10510== 
==10510== For counts of detected and suppressed errors, rerun with: -v
==10510== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 1023 -lt 3073
+ EXPECTED_LINES=1023
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1023_3073
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1023 OUT_N=3073'
shuf-reservoir-sampling failed with IN_N=1023 OUT_N=3073
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 0
+ INPUT_LINES=1024
+ OUTPUT_LINES=0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_1024_0
+ seq 1024
==10518== Memcheck, a memory error detector
==10518== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10518== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10518== Command: shuf -n 0 -o out_1024_0
==10518== 
--10518-- WARNING: unhandled syscall: 326
--10518-- You may be able to write your own handler.
--10518-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10518-- Nevertheless we consider this a bug.  Please report
--10518-- it at http://valgrind.org/support/bug_reports.html.
==10518== 
==10518== HEAP SUMMARY:
==10518==     in use at exit: 4,176 bytes in 3 blocks
==10518==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10518== 
==10518== LEAK SUMMARY:
==10518==    definitely lost: 24 bytes in 2 blocks
==10518==    indirectly lost: 4,152 bytes in 1 blocks
==10518==      possibly lost: 0 bytes in 0 blocks
==10518==    still reachable: 0 bytes in 0 blocks
==10518==         suppressed: 0 bytes in 0 blocks
==10518== Rerun with --leak-check=full to see details of leaked memory
==10518== 
==10518== For counts of detected and suppressed errors, rerun with: -v
==10518== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 1024 -lt 0
++ grep '^[0-9][0-9]*$' out_1024_0
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 1
+ INPUT_LINES=1024
+ OUTPUT_LINES=1
+ seq 1024
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_1024_1
==10526== Memcheck, a memory error detector
==10526== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10526== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10526== Command: shuf -n 1 -o out_1024_1
==10526== 
--10526-- WARNING: unhandled syscall: 326
--10526-- You may be able to write your own handler.
--10526-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10526-- Nevertheless we consider this a bug.  Please report
--10526-- it at http://valgrind.org/support/bug_reports.html.
95
==10526== 
==10526== HEAP SUMMARY:
==10526==     in use at exit: 37,112 bytes in 5 blocks
==10526==   total heap usage: 9 allocs, 4 frees, 37,316 bytes allocated
==10526== 
==10526== LEAK SUMMARY:
==10526==    definitely lost: 32,832 bytes in 3 blocks
==10526==    indirectly lost: 4,280 bytes in 2 blocks
==10526==      possibly lost: 0 bytes in 0 blocks
==10526==    still reachable: 0 bytes in 0 blocks
==10526==         suppressed: 0 bytes in 0 blocks
==10526== Rerun with --leak-check=full to see details of leaked memory
==10526== 
==10526== For counts of detected and suppressed errors, rerun with: -v
==10526== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 1024 -lt 1
++ grep '^[0-9][0-9]*$' out_1024_1
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1024 OUT_N=1'
shuf-reservoir-sampling failed with IN_N=1024 OUT_N=1
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 5
+ INPUT_LINES=1024
+ OUTPUT_LINES=5
+ seq 1024
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_1024_5
==10534== Memcheck, a memory error detector
==10534== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10534== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10534== Command: shuf -n 5 -o out_1024_5
==10534== 
--10534-- WARNING: unhandled syscall: 326
--10534-- You may be able to write your own handler.
--10534-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10534-- Nevertheless we consider this a bug.  Please report
--10534-- it at http://valgrind.org/support/bug_reports.html.
449
192
621
457
721
==10534== 
==10534== HEAP SUMMARY:
==10534==     in use at exit: 37,784 bytes in 9 blocks
==10534==   total heap usage: 14 allocs, 5 frees, 38,156 bytes allocated
==10534== 
==10534== LEAK SUMMARY:
==10534==    definitely lost: 32,992 bytes in 3 blocks
==10534==    indirectly lost: 4,792 bytes in 6 blocks
==10534==      possibly lost: 0 bytes in 0 blocks
==10534==    still reachable: 0 bytes in 0 blocks
==10534==         suppressed: 0 bytes in 0 blocks
==10534== Rerun with --leak-check=full to see details of leaked memory
==10534== 
==10534== For counts of detected and suppressed errors, rerun with: -v
==10534== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 1024 -lt 5
++ grep '^[0-9][0-9]*$' out_1024_5
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1024 OUT_N=5'
shuf-reservoir-sampling failed with IN_N=1024 OUT_N=5
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 1023
+ INPUT_LINES=1024
+ OUTPUT_LINES=1023
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_1024_1023
+ seq 1024
==10546== Memcheck, a memory error detector
==10546== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10546== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10546== Command: shuf -n 1023 -o out_1024_1023
==10546== 
--10546-- WARNING: unhandled syscall: 326
--10546-- You may be able to write your own handler.
--10546-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10546-- Nevertheless we consider this a bug.  Please report
--10546-- it at http://valgrind.org/support/bug_reports.html.
126
538
465
622
595
259
457
645
862
726
1004
661
75
702
150
136
707
408
571
877
742
454
487
755
739
864
506
444
998
632
407
807
701
347
697
151
848
43
1019
48
195
963
500
782
377
10
360
1023
122
171
708
531
451
399
429
817
896
809
840
1014
672
569
116
98
315
612
636
768
780
1005
914
482
903
458
161
410
32
989
760
893
513
613
391
105
644
842
978
655
366
562
881
803
6
130
651
505
723
442
926
568
415
499
635
581
229
588
395
143
792
211
659
609
262
972
1015
845
615
936
724
402
192
642
826
434
545
996
275
431
270
333
689
23
925
825
298
55
991
786
339
955
796
185
690
761
186
382
1012
350
31
121
264
170
481
181
875
973
858
425
471
619
217
516
284
406
524
473
767
975
412
204
981
118
18
338
403
80
202
249
212
63
850
837
295
575
307
754
540
287
183
846
276
937
1013
437
714
557
137
468
88
28
561
86
302
15
209
301
47
9
715
299
515
856
241
631
634
915
976
579
891
793
322
694
752
942
729
541
774
428
693
1000
61
449
349
776
706
427
127
553
124
806
256
450
422
172
979
821
97
374
886
1024
112
386
1003
257
675
624
417
173
804
486
950
847
698
164
373
884
730
747
935
269
290
869
498
971
405
993
777
247
496
109
368
596
518
265
554
231
549
201
82
90
591
654
50
510
578
248
556
135
314
787
520
148
952
271
894
791
657
737
67
629
54
861
166
115
992
25
33
543
551
906
288
532
227
820
567
293
153
279
771
678
863
445
677
381
69
469
633
898
361
564
630
376
304
221
995
769
594
250
230
330
570
888
205
337
12
480
681
890
93
744
223
528
277
859
233
788
743
663
280
953
669
36
722
501
717
379
397
994
987
3
459
46
546
245
327
927
193
423
750
597
583
255
844
310
40
488
686
144
547
68
519
2
416
550
7
206
225
962
762
932
671
208
544
778
558
106
461
794
167
107
101
274
565
91
494
684
44
466
197
900
910
990
305
928
687
95
325
667
174
385
563
889
387
348
306
625
372
813
447
331
816
725
954
113
24
911
899
648
868
375
924
64
320
240
419
582
14
974
521
357
584
939
390
443
765
607
329
175
533
692
141
180
432
650
790
560
297
638
356
179
1016
785
740
688
131
163
100
58
134
365
267
490
460
711
462
502
703
228
294
184
882
798
87
783
56
639
187
679
593
704
394
668
111
472
215
660
626
968
74
542
145
606
713
539
580
957
344
463
285
199
190
662
119
735
673
680
371
829
263
477
775
652
535
738
104
961
159
758
851
351
749
647
440
26
527
37
342
600
832
343
867
158
484
866
951
830
753
238
41
326
590
4
176
916
917
601
985
398
236
878
71
835
363
332
168
42
346
901
8
261
614
691
871
695
815
577
779
483
511
300
843
766
795
388
51
759
65
530
393
822
736
710
682
433
509
770
929
123
254
17
362
603
162
608
232
354
1011
1001
977
559
525
35
997
401
646
467
479
117
1006
852
242
157
352
336
913
839
983
514
237
311
235
999
99
640
824
53
358
146
396
586
949
699
149
947
982
610
218
438
246
108
94
757
897
885
96
188
685
988
207
214
129
966
719
958
764
523
29
409
286
59
621
324
81
226
712
1009
439
876
308
923
62
921
103
1022
696
414
731
933
773
426
854
946
720
751
273
335
85
984
191
598
880
746
355
497
165
378
224
156
504
964
77
169
969
1018
251
700
160
323
57
5
970
931
495
253
234
313
870
1007
21
194
827
548
945
853
733
474
296
855
413
572
920
370
799
125
526
943
728
384
455
132
718
317
623
721
92
309
908
628
503
860
210
196
152
573
904
20
66
745
73
83
142
489
812
814
872
965
828
222
1002
805
133
909
818
120
418
476
823
887
464
534
312
239
637
676
448
291
430
831
838
364
801
435
359
772
316
756
60
605
944
70
512
508
139
617
140
27
177
938
84
574
78
727
741
732
658
797
19
941
907
763
883
411
45
282
89
334
819
604
198
641
485
808
446
102
182
865
912
811
340
536
260
1017
537
420
649
616
522
13
268
665
922
748
367
599
585
39
611
918
1008
400
424
959
592
734
874
784
552
589
566
529
986
895
436
283
810
478
16
587
664
857
836
203
491
22
666
114
905
380
281
456
244
643
341
392
493
38
627
602
802
49
441
11
34
154
453
919
620
252
200
266
155
79
220
507
781
902
76
369
216
674
517
492
289
709
980
618
421
128
189
716
1
328
404
452
940
243
213
956
147
353
576
72
321
1020
272
834
800
138
292
52
303
873
110
960
470
278
656
475
789
383
930
258
30
967
833
705
948
653
318
555
670
319
841
345
219
1010
879
1021
178
389
849
892
934
==10546== 
==10546== HEAP SUMMARY:
==10546==     in use at exit: 208,808 bytes in 1,027 blocks
==10546==   total heap usage: 1,031 allocs, 4 frees, 249,772 bytes allocated
==10546== 
==10546== LEAK SUMMARY:
==10546==    definitely lost: 73,712 bytes in 3 blocks
==10546==    indirectly lost: 135,096 bytes in 1,024 blocks
==10546==      possibly lost: 0 bytes in 0 blocks
==10546==    still reachable: 0 bytes in 0 blocks
==10546==         suppressed: 0 bytes in 0 blocks
==10546== Rerun with --leak-check=full to see details of leaked memory
==10546== 
==10546== For counts of detected and suppressed errors, rerun with: -v
==10546== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 1024 -lt 1023
++ grep '^[0-9][0-9]*$' out_1024_1023
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1024 OUT_N=1023'
shuf-reservoir-sampling failed with IN_N=1024 OUT_N=1023
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 1024
+ INPUT_LINES=1024
+ OUTPUT_LINES=1024
+ seq 1024
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_1024_1024
==10554== Memcheck, a memory error detector
==10554== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10554== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10554== Command: shuf -n 1024 -o out_1024_1024
==10554== 
--10554-- WARNING: unhandled syscall: 326
--10554-- You may be able to write your own handler.
--10554-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10554-- Nevertheless we consider this a bug.  Please report
--10554-- it at http://valgrind.org/support/bug_reports.html.
848
245
921
469
693
985
977
974
238
778
828
426
268
801
999
850
1019
456
672
236
259
648
900
477
140
334
750
997
650
170
388
5
506
532
598
872
29
895
724
760
505
739
160
809
899
719
423
866
1003
187
385
418
132
524
416
182
677
395
102
309
67
311
197
909
984
53
445
694
608
449
221
319
1008
232
704
793
654
745
535
738
910
242
838
574
220
137
556
560
451
861
621
155
473
978
589
35
251
338
744
737
379
84
742
75
948
655
263
718
697
835
731
903
657
481
154
685
898
142
799
119
766
582
192
217
496
399
390
840
669
858
253
671
463
120
521
961
916
919
244
353
700
94
45
425
291
615
1023
332
989
273
723
798
795
846
813
413
271
954
99
779
25
644
111
348
168
906
222
89
276
666
1014
371
287
605
715
341
77
109
939
992
90
517
126
534
941
513
696
969
18
529
759
127
394
712
896
349
871
351
324
551
641
1011
467
228
533
129
301
681
494
302
512
596
688
787
937
446
403
440
461
152
1001
845
748
198
922
278
601
943
949
879
709
714
928
95
360
178
139
925
767
1018
274
128
788
1022
647
369
88
831
717
50
642
218
732
377
74
683
404
682
384
783
150
815
438
199
863
366
622
585
566
959
3
711
104
804
761
634
502
193
31
618
522
515
1017
741
975
890
670
82
281
8
339
539
162
588
22
791
646
881
231
325
765
947
230
283
784
573
485
68
853
392
854
918
270
987
843
888
923
726
328
1009
343
252
796
206
378
9
241
320
827
557
514
847
59
627
876
686
774
149
950
123
855
314
458
639
454
186
460
173
183
970
692
36
333
995
907
107
537
736
209
464
65
728
15
288
746
577
990
305
811
808
443
34
337
548
754
452
14
497
769
340
926
4
166
401
998
628
106
115
887
935
609
293
1
953
868
584
145
156
510
181
200
526
772
870
701
996
7
569
143
62
275
482
936
571
316
674
1020
208
133
713
442
862
592
459
619
427
355
110
30
279
202
797
412
958
824
1016
13
97
878
561
865
993
310
629
891
729
357
85
643
26
118
474
359
773
691
64
63
581
695
134
1002
814
653
327
153
216
433
1013
885
382
57
60
572
805
519
229
942
1021
892
587
536
914
908
564
91
10
28
659
823
803
161
604
124
211
414
408
322
689
249
817
495
421
381
756
792
373
69
924
138
437
994
304
905
136
661
179
568
80
354
501
810
113
329
321
932
542
419
776
491
78
356
710
98
1012
417
917
869
856
967
44
235
927
420
575
1024
658
820
904
470
620
280
508
130
690
286
43
151
484
623
625
509
595
292
735
212
563
822
702
966
602
607
306
23
361
590
368
826
180
405
1006
108
785
631
579
1010
576
857
971
964
555
121
541
988
6
215
92
789
507
55
177
740
652
593
298
614
205
269
819
902
633
365
479
882
313
295
344
790
350
982
940
786
466
493
16
706
254
122
1005
483
352
504
945
323
315
49
675
630
330
172
96
224
406
849
471
375
194
540
214
527
603
48
635
743
462
76
841
195
487
223
294
393
380
363
233
391
490
303
262
832
580
52
956
489
503
342
684
867
396
516
800
708
73
240
968
114
911
816
806
528
889
880
196
372
549
565
680
409
42
158
913
531
326
962
976
174
20
552
929
864
203
284
93
267
991
781
525
300
226
480
768
176
38
600
920
258
444
852
716
164
66
893
144
873
678
638
753
46
398
219
335
157
544
117
247
720
428
33
830
227
667
553
983
965
875
546
290
210
246
364
499
612
148
986
257
165
794
606
665
751
83
87
100
597
2
952
191
530
190
19
317
559
980
312
188
70
931
771
112
782
250
656
346
752
613
159
171
318
770
141
624
234
523
285
486
570
71
594
27
103
973
960
201
679
376
981
431
545
370
135
277
1004
299
17
755
58
825
538
453
640
912
101
955
37
387
586
289
775
436
946
492
749
833
51
185
429
1000
448
698
764
266
422
915
475
699
520
951
12
818
81
407
705
874
225
957
21
282
617
687
780
424
347
894
472
938
400
550
265
40
248
632
56
397
441
260
11
264
636
367
296
836
930
851
944
616
488
336
256
637
721
308
434
733
886
812
725
543
383
567
105
331
239
243
415
307
663
432
86
578
842
374
883
465
457
722
703
777
163
455
844
184
707
676
32
468
402
61
261
884
668
237
213
39
837
645
518
802
547
450
897
979
411
591
934
79
435
747
839
125
763
439
599
901
410
933
1007
386
47
651
389
762
204
358
554
72
758
146
610
24
673
362
727
478
345
167
664
500
207
498
41
734
662
54
476
189
511
1015
660
972
272
834
297
859
877
583
147
175
730
562
558
169
447
860
829
963
649
131
807
255
611
757
116
430
821
626
==10554== 
==10554== HEAP SUMMARY:
==10554==     in use at exit: 208,976 bytes in 1,028 blocks
==10554==   total heap usage: 1,032 allocs, 4 frees, 249,980 bytes allocated
==10554== 
==10554== LEAK SUMMARY:
==10554==    definitely lost: 73,752 bytes in 3 blocks
==10554==    indirectly lost: 135,224 bytes in 1,025 blocks
==10554==      possibly lost: 0 bytes in 0 blocks
==10554==    still reachable: 0 bytes in 0 blocks
==10554==         suppressed: 0 bytes in 0 blocks
==10554== Rerun with --leak-check=full to see details of leaked memory
==10554== 
==10554== For counts of detected and suppressed errors, rerun with: -v
==10554== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 1024 -lt 1024
++ grep '^[0-9][0-9]*$' out_1024_1024
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1024 OUT_N=1024'
shuf-reservoir-sampling failed with IN_N=1024 OUT_N=1024
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 1025
+ INPUT_LINES=1024
+ OUTPUT_LINES=1025
+ seq 1024
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_1024_1025
==10562== Memcheck, a memory error detector
==10562== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10562== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10562== Command: shuf -n 1025 -o out_1024_1025
==10562== 
--10562-- WARNING: unhandled syscall: 326
--10562-- You may be able to write your own handler.
--10562-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10562-- Nevertheless we consider this a bug.  Please report
--10562-- it at http://valgrind.org/support/bug_reports.html.
465
426
534
30
475
810
296
468
389
878
239
429
254
930
198
732
824
20
435
15
823
948
619
188
421
447
701
765
13
103
924
482
400
799
236
868
629
957
369
245
1008
223
499
360
84
292
259
685
831
1004
744
726
552
715
900
987
759
801
212
733
860
28
141
666
564
104
809
871
670
2
322
202
319
37
1001
529
905
677
976
158
887
424
342
297
492
479
467
628
921
38
110
399
324
36
683
53
877
464
82
862
300
793
323
88
347
22
131
925
912
1018
474
692
893
739
940
649
190
854
374
49
993
768
304
968
713
721
138
154
570
833
231
949
33
43
562
676
289
234
760
848
440
367
177
368
411
712
711
935
1012
267
806
604
291
427
585
735
889
816
855
135
989
626
951
436
47
797
1007
382
364
613
515
566
995
688
176
393
79
129
358
459
543
299
318
295
11
724
955
898
766
404
847
773
143
352
351
958
17
616
72
68
99
533
184
438
754
237
370
853
341
657
240
432
146
980
650
417
561
751
646
904
339
945
23
96
790
729
227
720
101
270
1019
392
914
985
19
108
338
144
69
953
882
63
873
490
345
861
310
911
480
444
706
388
85
153
653
203
575
936
555
428
919
248
731
332
789
776
284
326
445
786
996
218
708
307
746
718
140
171
615
656
222
977
837
357
640
574
456
962
509
819
815
29
73
205
283
1016
213
660
601
709
365
182
781
321
64
687
8
698
442
571
439
155
840
686
333
1024
337
66
402
612
938
377
617
200
554
978
826
838
647
128
217
410
111
590
265
51
587
408
884
387
923
704
693
784
981
257
697
779
123
941
398
723
75
527
121
233
181
449
194
521
363
420
204
622
991
937
894
41
282
431
132
115
65
503
80
876
975
578
348
901
892
545
844
651
50
524
93
684
179
9
161
119
258
655
59
274
842
423
835
174
498
895
278
782
565
569
133
752
864
541
354
361
224
1021
91
109
57
376
932
870
591
707
466
778
330
514
147
142
918
627
379
511
891
127
185
992
21
639
166
327
813
372
634
34
750
829
10
769
700
665
1009
753
573
517
485
635
581
441
528
794
727
201
418
264
52
605
481
897
922
157
828
523
87
272
599
197
551
401
484
191
180
890
559
557
286
652
6
209
7
162
667
12
662
471
947
600
298
335
917
340
792
672
163
763
644
301
680
315
526
560
642
641
463
422
394
114
24
149
243
567
800
986
771
965
92
175
722
486
170
145
383
455
314
582
775
136
536
494
592
433
791
419
235
956
755
558
772
928
18
857
294
313
281
542
164
246
458
452
95
952
403
192
603
416
261
929
624
883
808
1
1020
107
621
767
189
1000
896
654
916
199
253
457
761
538
858
659
346
817
504
279
405
984
35
963
834
998
595
668
637
168
525
86
148
961
608
491
271
120
137
631
172
643
14
27
804
477
1011
55
1023
255
230
762
251
820
906
757
407
593
112
220
214
302
242
173
874
45
512
102
787
505
695
386
867
738
210
48
395
736
798
446
478
71
397
675
807
832
907
730
691
125
988
77
241
725
500
602
317
453
885
425
247
589
375
577
430
777
497
413
934
825
250
610
741
785
846
636
381
124
359
488
580
690
273
964
532
186
303
122
888
703
232
661
26
1017
518
116
705
81
679
747
508
448
843
982
973
249
839
309
632
547
927
269
743
473
859
316
516
796
682
658
795
671
716
770
469
350
607
353
954
974
489
875
983
31
740
58
268
598
530
568
544
821
349
406
193
625
714
260
276
118
390
805
946
931
308
285
344
845
818
414
694
556
501
519
44
950
16
451
277
606
385
3
944
614
719
434
939
25
550
506
117
371
334
54
126
510
969
673
100
548
841
943
1015
970
994
869
343
620
513
225
78
252
160
325
979
67
920
328
942
461
758
663
293
865
586
597
531
717
256
206
356
152
645
584
966
851
5
169
94
311
576
196
61
737
933
830
522
391
113
764
366
195
208
539
520
373
106
880
630
329
749
535
178
689
412
437
454
98
215
266
275
39
320
926
611
915
228
756
774
150
483
866
899
507
207
990
748
1003
669
472
396
40
633
1010
97
822
802
70
863
588
579
76
462
487
1002
803
960
1013
288
814
699
460
618
812
4
183
134
443
226
280
572
594
856
287
384
362
355
216
130
788
42
378
972
60
696
221
734
312
852
187
913
476
540
546
609
910
903
997
583
909
1006
263
674
165
902
780
331
549
648
336
811
159
710
908
881
623
971
290
1014
678
638
967
450
537
238
409
305
56
229
681
495
886
156
702
502
211
563
999
596
745
783
827
470
262
380
849
167
306
139
728
1022
219
74
151
493
244
872
32
1005
89
959
46
105
742
836
496
415
62
83
664
879
553
850
90
==10562== 
==10562== HEAP SUMMARY:
==10562==     in use at exit: 208,976 bytes in 1,028 blocks
==10562==   total heap usage: 1,032 allocs, 4 frees, 249,980 bytes allocated
==10562== 
==10562== LEAK SUMMARY:
==10562==    definitely lost: 73,752 bytes in 3 blocks
==10562==    indirectly lost: 135,224 bytes in 1,025 blocks
==10562==      possibly lost: 0 bytes in 0 blocks
==10562==    still reachable: 0 bytes in 0 blocks
==10562==         suppressed: 0 bytes in 0 blocks
==10562== Rerun with --leak-check=full to see details of leaked memory
==10562== 
==10562== For counts of detected and suppressed errors, rerun with: -v
==10562== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 1024 -lt 1025
+ EXPECTED_LINES=1024
++ grep '^[0-9][0-9]*$' out_1024_1025
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1024 OUT_N=1025'
shuf-reservoir-sampling failed with IN_N=1024 OUT_N=1025
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 3071
+ INPUT_LINES=1024
+ OUTPUT_LINES=3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_1024_3071
==10570== Memcheck, a memory error detector
==10570== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10570== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10570== Command: shuf -n 3071 -o out_1024_3071
==10570== 
+ seq 1024
--10570-- WARNING: unhandled syscall: 326
--10570-- You may be able to write your own handler.
--10570-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10570-- Nevertheless we consider this a bug.  Please report
--10570-- it at http://valgrind.org/support/bug_reports.html.
880
355
216
894
261
46
656
757
270
503
118
550
449
733
377
27
83
435
423
200
71
351
245
506
739
947
683
446
193
608
306
842
312
823
895
372
579
605
212
227
810
571
541
311
1019
759
629
431
968
267
674
184
621
379
776
686
139
28
223
763
9
217
475
378
416
284
201
425
634
86
279
187
18
369
53
349
409
277
679
222
130
510
511
950
999
505
709
840
221
402
161
196
236
893
753
883
303
706
802
687
315
439
155
909
365
765
972
523
447
858
202
269
65
675
642
144
41
14
123
247
740
914
124
817
928
697
76
991
371
789
847
528
924
321
625
558
811
300
162
242
639
539
17
348
21
554
4
438
967
1018
471
555
390
1007
88
813
95
108
667
673
483
473
566
512
170
16
933
708
68
407
254
45
749
698
838
140
1001
530
147
831
815
718
11
688
343
136
955
965
280
353
587
654
830
498
214
613
257
538
186
70
803
235
829
978
534
643
411
997
761
58
898
569
669
905
548
799
782
954
465
638
694
729
551
612
670
884
482
375
152
609
307
451
8
915
878
99
432
800
138
112
945
827
844
109
107
260
434
40
73
657
77
932
405
178
427
126
601
295
129
854
63
936
75
56
354
553
940
1015
798
199
39
383
121
255
692
696
468
935
583
192
487
364
867
959
60
384
428
693
1
135
338
897
552
517
961
620
92
207
357
205
271
500
128
859
496
455
850
941
623
796
358
547
839
127
984
156
735
852
381
282
953
919
514
540
832
710
169
586
335
96
520
385
896
206
171
429
80
90
628
668
795
527
1023
249
345
762
177
907
559
489
42
203
290
1016
163
173
849
23
747
845
771
633
812
442
273
560
394
635
230
197
624
168
574
20
995
382
215
397
414
580
516
52
938
908
341
751
276
157
362
734
685
619
102
774
448
396
603
939
94
985
755
986
329
340
627
711
111
814
497
474
393
952
809
930
51
49
588
644
3
146
869
768
855
781
298
714
780
835
164
1011
975
310
309
48
287
13
618
183
1003
600
651
478
82
640
792
518
988
818
787
486
324
837
370
659
720
91
38
655
145
653
84
158
582
105
316
318
15
805
380
59
724
55
480
182
2
819
949
472
98
495
174
44
347
779
172
599
998
504
754
179
969
1021
725
437
820
994
716
891
960
777
971
501
946
466
399
359
408
334
444
861
72
598
78
982
594
47
744
821
690
224
641
114
841
450
925
445
308
822
477
228
650
934
664
626
877
286
704
35
314
459
463
1020
948
892
296
1006
636
804
564
646
816
981
462
536
34
231
856
630
544
964
565
294
30
208
521
604
469
499
85
232
238
707
421
561
491
148
760
258
983
22
987
937
150
531
263
333
903
879
752
10
863
672
836
313
457
191
400
285
488
631
325
825
336
104
154
328
422
525
389
722
387
342
772
93
37
12
807
502
702
278
100
996
717
218
942
226
64
317
524
719
929
149
467
911
922
881
225
808
265
806
902
786
689
584
746
406
606
508
43
125
899
424
252
529
151
773
801
36
665
745
846
272
248
413
563
452
515
410
234
1024
992
595
134
775
132
607
616
1008
433
542
79
910
283
617
661
204
872
532
62
943
730
575
851
970
211
743
921
5
176
120
54
918
391
29
750
376
350
356
592
913
833
464
977
578
676
403
602
973
573
681
246
198
304
454
122
593
663
882
243
513
388
662
546
395
476
874
367
470
622
791
615
871
848
165
543
153
195
74
860
142
770
332
637
581
917
241
159
876
253
237
131
926
632
137
1022
927
647
976
784
441
857
268
526
302
326
900
262
6
213
481
572
1009
652
66
133
695
239
649
346
562
758
920
188
209
1005
97
490
110
360
738
305
979
956
577
889
966
494
887
870
61
888
361
834
368
89
87
274
113
25
440
1012
256
166
703
951
143
993
794
557
24
764
1013
567
645
591
611
712
264
337
374
682
373
401
175
116
69
50
700
923
461
864
417
352
699
533
691
266
549
767
119
101
797
793
989
1014
843
507
420
181
291
366
141
210
962
220
386
862
299
67
81
944
721
1000
589
853
736
931
990
865
1004
906
748
456
219
363
732
57
419
229
322
519
185
535
769
715
301
331
233
320
115
610
980
522
167
484
885
1010
737
7
19
766
460
866
726
106
974
576
723
31
339
958
323
26
458
568
189
160
275
826
912
890
392
1017
886
597
671
330
783
327
509
731
658
545
180
297
778
713
660
570
251
412
741
344
901
727
404
904
590
430
756
705
492
957
190
244
875
828
701
436
916
289
415
288
963
678
614
292
596
426
868
677
485
293
319
728
418
556
785
117
103
1002
824
648
281
240
790
259
250
33
666
873
398
742
493
537
680
443
453
32
788
684
585
194
479
==10570== 
==10570== HEAP SUMMARY:
==10570==     in use at exit: 208,976 bytes in 1,028 blocks
==10570==   total heap usage: 1,032 allocs, 4 frees, 249,980 bytes allocated
==10570== 
==10570== LEAK SUMMARY:
==10570==    definitely lost: 73,752 bytes in 3 blocks
==10570==    indirectly lost: 135,224 bytes in 1,025 blocks
==10570==      possibly lost: 0 bytes in 0 blocks
==10570==    still reachable: 0 bytes in 0 blocks
==10570==         suppressed: 0 bytes in 0 blocks
==10570== Rerun with --leak-check=full to see details of leaked memory
==10570== 
==10570== For counts of detected and suppressed errors, rerun with: -v
==10570== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 1024 -lt 3071
+ EXPECTED_LINES=1024
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1024_3071
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1024 OUT_N=3071'
shuf-reservoir-sampling failed with IN_N=1024 OUT_N=3071
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 3072
+ INPUT_LINES=1024
+ OUTPUT_LINES=3072
+ seq 1024
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_1024_3072
==10582== Memcheck, a memory error detector
==10582== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10582== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10582== Command: shuf -n 3072 -o out_1024_3072
==10582== 
--10582-- WARNING: unhandled syscall: 326
--10582-- You may be able to write your own handler.
--10582-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10582-- Nevertheless we consider this a bug.  Please report
--10582-- it at http://valgrind.org/support/bug_reports.html.
757
160
232
413
176
262
285
580
18
621
787
760
439
207
231
1013
985
222
336
317
666
217
1016
893
627
552
250
34
975
234
878
139
541
651
255
543
223
820
1009
112
313
296
532
448
898
24
684
602
62
11
598
653
617
939
502
456
873
721
117
308
345
520
316
958
441
496
300
10
926
199
282
125
36
699
805
553
904
762
544
22
923
723
143
947
765
454
533
949
909
622
892
342
465
768
730
331
360
175
280
150
969
542
30
186
679
498
429
424
479
374
504
437
145
26
569
809
334
887
732
391
195
658
354
780
736
677
19
380
121
933
494
944
1000
739
307
302
89
711
383
442
155
576
412
766
836
526
854
979
422
719
72
46
530
274
758
783
583
390
970
945
492
270
249
866
799
366
960
474
782
855
491
501
870
470
674
704
393
375
536
710
752
187
257
973
534
44
527
772
734
630
236
738
319
680
116
927
823
376
105
265
53
218
482
595
676
369
1010
614
246
977
279
671
253
74
379
321
741
806
283
673
48
271
96
980
240
611
335
662
378
453
201
156
505
430
80
184
248
986
315
720
348
163
100
157
931
733
670
221
427
559
899
853
813
657
1
54
839
920
124
457
702
518
104
252
549
244
352
399
626
25
452
402
392
584
815
791
118
269
137
418
188
628
445
632
426
500
1003
341
438
84
136
169
398
769
110
131
92
332
353
495
688
385
957
1020
289
829
649
864
718
162
135
993
225
742
13
288
268
305
210
172
361
848
395
793
954
197
388
276
367
347
93
278
64
521
825
901
556
431
845
129
420
946
712
433
625
746
616
1006
330
672
325
152
12
510
903
320
915
108
879
635
333
459
1018
428
81
97
35
183
415
756
339
166
67
33
921
266
735
817
119
83
373
226
1008
434
729
877
344
563
555
600
612
818
863
132
788
681
304
200
902
989
663
777
1005
603
480
644
31
841
299
1002
41
292
404
377
639
311
932
71
967
568
1017
634
822
1014
930
1007
329
173
1019
508
16
564
885
394
450
728
581
996
90
421
528
675
88
381
994
408
417
562
648
123
487
819
655
607
585
935
153
20
775
323
990
761
748
91
94
151
633
45
972
597
963
359
540
656
455
827
798
60
77
146
115
14
660
290
251
406
794
149
910
753
953
961
466
356
571
613
148
464
42
596
401
891
785
382
476
338
275
224
467
861
472
322
40
846
821
868
488
416
59
259
808
61
1001
883
871
122
230
875
120
32
889
142
85
881
691
63
203
589
709
796
256
995
547
178
328
370
830
999
205
781
211
537
164
219
21
171
888
192
763
557
362
114
358
287
277
447
410
403
73
852
372
678
95
640
295
554
941
950
198
165
109
638
693
386
952
976
929
154
876
599
654
525
803
469
981
449
196
789
652
407
807
843
605
78
281
705
489
57
686
141
515
911
301
75
202
471
411
764
161
179
212
831
368
620
566
623
988
194
894
400
506
538
572
661
9
473
238
647
900
776
912
190
444
350
964
49
76
937
551
987
565
645
717
579
790
237
170
435
107
659
847
940
906
683
485
87
916
731
314
490
258
56
206
458
127
694
636
523
227
326
349
722
66
507
517
832
637
481
774
844
872
531
216
43
297
37
908
624
167
286
15
514
814
869
1011
792
185
767
577
982
665
241
797
745
99
208
956
58
629
984
55
1021
784
650
682
340
838
608
159
168
396
948
740
919
575
133
837
306
462
284
749
522
851
619
594
586
751
858
716
567
423
239
713
590
755
254
389
106
840
942
561
726
884
4
591
130
158
220
1022
483
578
890
539
267
193
610
550
233
364
68
291
1004
574
475
371
724
343
512
862
215
86
859
707
3
928
409
773
962
519
779
228
856
8
273
810
70
795
27
177
706
446
7
174
327
509
50
6
425
310
432
261
39
405
698
346
874
978
303
997
943
263
695
503
828
546
992
79
714
513
486
592
786
477
47
631
82
882
582
209
642
52
497
917
747
951
696
384
897
69
101
618
558
934
860
235
588
1015
959
824
664
867
363
895
842
778
355
414
463
312
309
51
913
811
17
113
102
692
800
918
968
478
134
1023
436
914
667
351
601
484
708
511
865
111
460
214
812
991
180
38
440
499
669
23
905
365
451
886
689
690
833
65
387
834
5
529
1024
771
573
609
461
971
606
880
907
181
98
548
604
668
247
264
770
2
260
397
468
802
974
144
587
966
700
337
750
191
493
896
936
687
743
545
29
835
849
138
229
759
245
443
535
744
685
646
801
298
715
213
204
857
293
243
955
140
804
28
126
727
242
643
826
850
516
922
816
754
998
272
357
983
147
697
938
419
103
703
965
924
1012
294
725
182
318
324
189
615
641
570
524
737
128
925
701
593
560
==10582== 
==10582== HEAP SUMMARY:
==10582==     in use at exit: 208,976 bytes in 1,028 blocks
==10582==   total heap usage: 1,032 allocs, 4 frees, 249,980 bytes allocated
==10582== 
==10582== LEAK SUMMARY:
==10582==    definitely lost: 73,752 bytes in 3 blocks
==10582==    indirectly lost: 135,224 bytes in 1,025 blocks
==10582==      possibly lost: 0 bytes in 0 blocks
==10582==    still reachable: 0 bytes in 0 blocks
==10582==         suppressed: 0 bytes in 0 blocks
==10582== Rerun with --leak-check=full to see details of leaked memory
==10582== 
==10582== For counts of detected and suppressed errors, rerun with: -v
==10582== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 1024 -lt 3072
+ EXPECTED_LINES=1024
++ sort -un
++ grep '^[0-9][0-9]*$' out_1024_3072
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1024 OUT_N=3072'
shuf-reservoir-sampling failed with IN_N=1024 OUT_N=3072
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1024 3073
+ INPUT_LINES=1024
+ OUTPUT_LINES=3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_1024_3073
+ seq 1024
==10593== Memcheck, a memory error detector
==10593== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10593== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10593== Command: shuf -n 3073 -o out_1024_3073
==10593== 
--10593-- WARNING: unhandled syscall: 326
--10593-- You may be able to write your own handler.
--10593-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10593-- Nevertheless we consider this a bug.  Please report
--10593-- it at http://valgrind.org/support/bug_reports.html.
825
297
25
481
173
305
122
183
648
604
411
881
220
728
1018
290
572
228
986
256
764
780
712
39
167
524
877
391
199
581
401
472
508
342
1006
450
1024
106
203
127
717
957
637
386
371
867
75
691
235
444
676
569
760
705
826
6
289
694
846
441
380
150
143
621
879
736
837
834
277
626
973
703
70
627
466
594
430
829
641
970
311
803
977
358
622
887
696
787
307
217
312
367
949
721
413
483
727
385
905
247
227
24
159
140
778
667
909
668
978
445
730
15
820
145
27
361
146
565
583
34
893
647
197
298
734
169
724
295
236
510
747
880
354
40
531
225
670
57
950
456
929
343
741
874
362
329
302
16
577
141
823
544
121
320
238
334
479
675
338
629
213
882
404
503
789
499
458
643
740
770
316
784
914
82
97
74
891
516
719
897
375
487
376
625
600
535
130
975
73
860
593
54
616
608
518
974
933
1011
851
274
737
840
457
679
883
501
673
659
553
725
847
610
558
762
907
234
628
844
888
534
852
100
372
104
64
782
339
137
126
32
824
573
364
917
120
695
318
733
903
263
924
962
598
189
149
523
93
7
639
506
990
123
928
686
437
29
493
451
731
515
619
69
76
614
615
81
185
78
633
484
276
664
504
191
328
956
486
533
327
459
758
41
184
995
293
132
226
757
396
251
512
576
984
416
570
841
742
232
800
656
602
62
420
410
324
833
43
284
912
10
511
249
285
471
595
781
987
261
850
453
452
161
908
287
666
447
162
31
215
690
606
89
765
790
310
683
832
561
642
788
398
158
415
200
267
715
87
542
113
505
474
640
59
170
209
348
968
794
418
684
913
709
636
212
224
965
129
732
680
744
202
345
13
799
904
101
701
876
253
638
434
460
681
609
743
911
393
292
802
827
661
792
817
942
254
890
193
160
389
77
365
48
520
821
783
79
710
896
35
963
804
288
617
206
296
901
922
1008
677
923
582
5
331
153
1002
233
605
26
495
449
346
20
17
586
352
344
282
716
117
801
513
156
86
109
630
936
469
351
856
545
560
861
994
222
644
1022
83
819
435
1010
651
631
259
500
816
335
105
96
229
71
603
562
592
110
568
543
755
431
779
807
219
894
620
660
448
795
812
492
900
979
306
649
478
966
948
280
246
266
446
752
915
94
541
971
830
98
488
1012
599
111
1019
771
972
822
174
428
275
422
654
119
699
325
490
849
775
56
347
753
759
898
945
103
940
767
95
18
281
476
265
927
477
142
323
353
588
761
863
934
597
271
370
786
28
698
426
45
838
194
294
530
2
519
571
49
9
889
359
521
557
918
529
702
750
884
1003
969
549
810
180
768
485
938
591
19
204
985
392
967
906
462
1007
436
408
405
53
163
439
374
749
559
258
525
930
671
157
713
992
997
989
164
390
756
242
417
517
931
835
65
491
547
650
269
218
66
865
706
88
128
154
36
262
443
555
124
980
480
772
999
181
763
916
421
21
286
769
465
264
314
926
414
538
46
939
991
80
988
748
114
427
336
108
536
337
255
272
332
798
279
423
618
944
961
809
552
682
932
575
84
395
14
946
464
1021
51
303
379
90
135
854
836
177
693
875
885
412
115
587
240
406
125
175
983
864
496
341
806
482
689
960
507
237
278
566
107
528
895
378
239
440
814
368
546
943
91
147
388
131
244
722
384
260
468
708
777
954
1016
646
360
317
340
99
382
739
665
245
165
797
1017
720
190
1001
818
3
580
766
152
853
22
182
601
241
139
632
138
144
357
387
870
221
993
919
195
1013
964
208
1009
579
373
685
399
635
855
925
322
319
270
350
349
315
425
574
12
869
498
754
192
662
172
878
467
187
201
751
313
283
72
564
369
793
102
304
429
707
8
902
563
623
805
1020
44
868
55
735
514
981
333
645
176
808
726
998
687
409
858
155
463
424
223
355
308
886
60
257
522
442
711
655
494
438
537
550
718
300
148
85
697
1
1023
67
941
1015
578
613
330
407
873
475
700
899
400
248
842
4
871
186
356
839
168
746
791
196
811
678
461
669
848
607
872
211
299
652
996
243
207
321
692
61
198
52
23
210
473
653
433
658
831
590
657
50
63
951
455
548
502
171
166
33
363
688
1005
540
489
38
178
509
58
611
935
432
252
291
402
230
116
527
937
273
136
859
134
866
1014
921
729
1000
268
383
250
976
397
30
958
952
403
843
723
539
674
188
773
813
301
205
179
37
497
381
419
551
92
470
567
585
133
714
554
745
11
309
947
862
526
815
663
216
68
776
42
955
377
672
584
556
845
857
828
366
785
796
624
920
596
326
774
394
231
1004
454
47
892
112
214
634
589
532
151
118
953
704
612
910
959
982
738
==10593== 
==10593== HEAP SUMMARY:
==10593==     in use at exit: 208,976 bytes in 1,028 blocks
==10593==   total heap usage: 1,032 allocs, 4 frees, 249,980 bytes allocated
==10593== 
==10593== LEAK SUMMARY:
==10593==    definitely lost: 73,752 bytes in 3 blocks
==10593==    indirectly lost: 135,224 bytes in 1,025 blocks
==10593==      possibly lost: 0 bytes in 0 blocks
==10593==    still reachable: 0 bytes in 0 blocks
==10593==         suppressed: 0 bytes in 0 blocks
==10593== Rerun with --leak-check=full to see details of leaked memory
==10593== 
==10593== For counts of detected and suppressed errors, rerun with: -v
==10593== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 1024 -lt 3073
+ EXPECTED_LINES=1024
++ grep '^[0-9][0-9]*$' out_1024_3073
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1024 OUT_N=3073'
shuf-reservoir-sampling failed with IN_N=1024 OUT_N=3073
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 0
+ INPUT_LINES=1025
+ OUTPUT_LINES=0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_1025_0
+ seq 1025
==10609== Memcheck, a memory error detector
==10609== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10609== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10609== Command: shuf -n 0 -o out_1025_0
==10609== 
--10609-- WARNING: unhandled syscall: 326
--10609-- You may be able to write your own handler.
--10609-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10609-- Nevertheless we consider this a bug.  Please report
--10609-- it at http://valgrind.org/support/bug_reports.html.
==10609== 
==10609== HEAP SUMMARY:
==10609==     in use at exit: 4,176 bytes in 3 blocks
==10609==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10609== 
==10609== LEAK SUMMARY:
==10609==    definitely lost: 24 bytes in 2 blocks
==10609==    indirectly lost: 4,152 bytes in 1 blocks
==10609==      possibly lost: 0 bytes in 0 blocks
==10609==    still reachable: 0 bytes in 0 blocks
==10609==         suppressed: 0 bytes in 0 blocks
==10609== Rerun with --leak-check=full to see details of leaked memory
==10609== 
==10609== For counts of detected and suppressed errors, rerun with: -v
==10609== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 1025 -lt 0
++ sort -un
++ grep '^[0-9][0-9]*$' out_1025_0
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 1
+ INPUT_LINES=1025
+ OUTPUT_LINES=1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_1025_1
+ seq 1025
==10618== Memcheck, a memory error detector
==10618== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10618== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10618== Command: shuf -n 1 -o out_1025_1
==10618== 
--10618-- WARNING: unhandled syscall: 326
--10618-- You may be able to write your own handler.
--10618-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10618-- Nevertheless we consider this a bug.  Please report
--10618-- it at http://valgrind.org/support/bug_reports.html.
262
==10618== 
==10618== HEAP SUMMARY:
==10618==     in use at exit: 37,112 bytes in 5 blocks
==10618==   total heap usage: 9 allocs, 4 frees, 37,316 bytes allocated
==10618== 
==10618== LEAK SUMMARY:
==10618==    definitely lost: 32,832 bytes in 3 blocks
==10618==    indirectly lost: 4,280 bytes in 2 blocks
==10618==      possibly lost: 0 bytes in 0 blocks
==10618==    still reachable: 0 bytes in 0 blocks
==10618==         suppressed: 0 bytes in 0 blocks
==10618== Rerun with --leak-check=full to see details of leaked memory
==10618== 
==10618== For counts of detected and suppressed errors, rerun with: -v
==10618== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 1025 -lt 1
++ grep '^[0-9][0-9]*$' out_1025_1
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1025 OUT_N=1'
shuf-reservoir-sampling failed with IN_N=1025 OUT_N=1
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 5
+ INPUT_LINES=1025
+ OUTPUT_LINES=5
+ seq 1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_1025_5
==10627== Memcheck, a memory error detector
==10627== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10627== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10627== Command: shuf -n 5 -o out_1025_5
==10627== 
--10627-- WARNING: unhandled syscall: 326
--10627-- You may be able to write your own handler.
--10627-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10627-- Nevertheless we consider this a bug.  Please report
--10627-- it at http://valgrind.org/support/bug_reports.html.
485
980
953
591
887
==10627== 
==10627== HEAP SUMMARY:
==10627==     in use at exit: 37,784 bytes in 9 blocks
==10627==   total heap usage: 14 allocs, 5 frees, 38,156 bytes allocated
==10627== 
==10627== LEAK SUMMARY:
==10627==    definitely lost: 32,992 bytes in 3 blocks
==10627==    indirectly lost: 4,792 bytes in 6 blocks
==10627==      possibly lost: 0 bytes in 0 blocks
==10627==    still reachable: 0 bytes in 0 blocks
==10627==         suppressed: 0 bytes in 0 blocks
==10627== Rerun with --leak-check=full to see details of leaked memory
==10627== 
==10627== For counts of detected and suppressed errors, rerun with: -v
==10627== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 1025 -lt 5
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1025_5
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1025 OUT_N=5'
shuf-reservoir-sampling failed with IN_N=1025 OUT_N=5
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 1023
+ INPUT_LINES=1025
+ OUTPUT_LINES=1023
+ seq 1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_1025_1023
==10635== Memcheck, a memory error detector
==10635== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10635== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10635== Command: shuf -n 1023 -o out_1025_1023
==10635== 
--10635-- WARNING: unhandled syscall: 326
--10635-- You may be able to write your own handler.
--10635-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10635-- Nevertheless we consider this a bug.  Please report
--10635-- it at http://valgrind.org/support/bug_reports.html.
34
448
555
896
234
170
613
822
1013
562
493
686
159
259
542
669
981
292
961
178
32
407
652
189
425
608
470
658
738
87
536
37
363
244
286
61
333
753
606
935
105
897
516
141
691
77
913
876
969
885
432
496
987
169
354
541
639
625
970
976
722
1011
19
735
528
538
847
844
482
583
932
867
361
947
1023
419
214
114
174
610
387
736
205
139
601
222
278
561
416
571
127
581
395
592
620
894
566
137
82
338
791
94
218
784
359
636
364
126
430
609
74
7
108
875
714
78
224
490
374
326
483
262
921
638
41
487
188
144
1014
225
478
993
775
62
104
96
1009
166
196
207
450
399
226
116
71
477
57
129
748
870
13
160
803
117
505
375
27
99
98
718
348
250
228
687
558
743
904
140
579
353
850
285
360
573
906
310
106
759
328
905
572
33
268
290
198
305
526
964
463
68
800
853
702
284
161
585
839
124
400
733
22
992
723
449
293
729
744
29
252
202
798
785
763
705
95
622
357
235
279
1007
653
15
628
347
383
696
734
480
924
50
52
626
980
150
316
641
550
92
323
715
66
918
817
342
849
1018
267
940
10
472
866
258
617
351
966
879
984
666
435
288
960
675
255
667
684
300
466
709
901
147
330
589
488
236
335
172
945
406
955
187
614
756
73
242
591
527
227
65
44
389
497
76
530
307
549
152
438
336
975
254
688
836
557
429
580
858
319
739
388
532
60
393
988
491
241
165
358
327
134
553
272
539
721
302
337
642
524
322
727
699
967
331
135
23
990
878
694
777
683
574
749
63
457
725
716
423
551
1000
298
881
930
596
420
655
856
706
991
264
428
97
1020
455
776
136
219
908
880
485
997
1005
874
804
345
67
111
816
112
462
838
183
923
195
81
898
962
239
43
633
64
283
999
504
113
998
131
401
1012
630
787
741
782
93
447
813
507
47
662
910
392
185
265
103
502
941
814
458
510
681
823
554
484
370
289
602
36
100
860
994
11
607
301
309
958
417
802
54
560
648
437
452
595
413
20
731
154
845
155
418
938
781
216
501
828
697
818
509
730
586
790
720
238
1004
914
948
710
197
157
788
467
273
664
378
584
786
275
313
752
233
343
296
21
565
811
928
282
465
873
779
974
689
949
56
397
598
412
644
713
318
521
1016
979
869
757
494
692
148
492
69
926
101
522
671
647
810
314
533
138
982
676
402
543
321
143
102
260
173
801
28
544
871
431
382
1010
764
212
243
851
88
461
498
971
848
996
695
2
181
352
146
619
340
1001
842
110
251
12
5
893
334
707
587
403
793
1017
190
933
796
38
534
829
220
794
635
409
765
145
582
53
206
175
294
529
632
291
486
503
890
42
762
299
1002
517
436
611
840
213
597
513
211
978
83
943
995
783
408
9
130
385
892
500
176
865
824
852
368
703
1024
629
577
520
454
325
615
649
766
182
957
746
657
79
755
568
575
959
471
312
249
193
479
708
411
164
80
362
909
86
934
25
311
48
754
107
1022
919
373
495
271
163
230
257
256
231
827
191
758
778
887
1021
120
194
627
332
977
17
376
603
564
31
90
899
795
379
963
886
372
40
204
215
369
315
109
132
476
645
570
768
841
682
537
772
209
774
634
405
704
123
232
133
740
459
685
950
442
821
925
819
276
162
277
927
396
468
902
153
201
156
6
701
864
937
693
770
523
965
247
91
556
903
650
877
631
604
346
210
576
115
304
872
747
985
907
474
186
535
751
1025
1015
371
246
499
377
780
552
861
208
391
659
832
446
637
624
936
761
863
320
809
4
415
643
404
590
506
1008
426
434
618
350
726
344
308
760
525
199
922
1
559
306
386
519
440
287
773
600
248
884
8
422
245
398
149
317
690
39
750
453
728
3
266
678
414
427
912
30
952
612
621
594
451
1006
269
180
605
546
895
677
45
280
700
862
511
616
339
295
843
367
167
424
920
654
261
973
834
915
673
812
217
121
151
26
297
433
807
237
989
799
49
274
270
381
956
443
192
171
1003
14
663
835
59
540
460
623
939
717
825
445
711
184
473
826
481
84
410
46
806
365
944
917
771
563
672
547
815
868
833
651
588
593
223
900
831
668
599
724
456
469
142
168
767
303
660
548
475
177
119
263
58
983
221
512
444
953
35
464
329
986
911
972
439
75
55
179
951
888
531
514
679
366
640
769
421
324
854
341
128
929
857
946
489
515
797
745
85
891
789
200
545
846
380
578
158
792
742
830
349
670
518
665
72
1019
712
240
355
882
394
356
954
680
16
805
118
24
837
732
18
390
125
674
51
567
384
931
229
859
441
889
698
281
203
89
942
968
508
122
820
656
719
569
883
916
808
646
737
70
253
==10635== 
==10635== HEAP SUMMARY:
==10635==     in use at exit: 208,808 bytes in 1,027 blocks
==10635==   total heap usage: 1,031 allocs, 4 frees, 249,772 bytes allocated
==10635== 
==10635== LEAK SUMMARY:
==10635==    definitely lost: 73,712 bytes in 3 blocks
==10635==    indirectly lost: 135,096 bytes in 1,024 blocks
==10635==      possibly lost: 0 bytes in 0 blocks
==10635==    still reachable: 0 bytes in 0 blocks
==10635==         suppressed: 0 bytes in 0 blocks
==10635== Rerun with --leak-check=full to see details of leaked memory
==10635== 
==10635== For counts of detected and suppressed errors, rerun with: -v
==10635== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 1025 -lt 1023
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1025_1023
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1025 OUT_N=1023'
shuf-reservoir-sampling failed with IN_N=1025 OUT_N=1023
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 1024
+ INPUT_LINES=1025
+ OUTPUT_LINES=1024
+ seq 1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_1025_1024
==10646== Memcheck, a memory error detector
==10646== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10646== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10646== Command: shuf -n 1024 -o out_1025_1024
==10646== 
--10646-- WARNING: unhandled syscall: 326
--10646-- You may be able to write your own handler.
--10646-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10646-- Nevertheless we consider this a bug.  Please report
--10646-- it at http://valgrind.org/support/bug_reports.html.
499
364
69
392
762
189
342
911
49
555
467
838
259
63
322
495
123
380
395
796
943
899
444
209
774
560
656
801
535
280
1015
414
533
245
844
116
945
842
646
231
79
312
900
454
633
581
814
6
860
866
77
933
238
874
710
836
143
439
612
219
735
459
381
384
180
688
357
763
920
965
1017
856
23
907
821
91
212
105
806
591
339
600
609
524
412
981
276
43
780
28
704
99
748
26
669
272
658
464
151
699
242
901
655
955
338
430
715
728
483
400
941
983
257
283
611
11
122
278
86
545
81
233
141
966
80
58
225
905
931
718
398
1013
956
893
732
10
878
760
881
135
770
221
435
531
271
304
756
297
986
875
557
967
700
1005
336
202
410
211
885
717
918
526
822
635
946
386
974
1002
963
456
938
1024
360
769
702
676
279
366
884
363
114
691
839
411
544
432
725
601
461
1020
268
75
765
782
300
305
915
576
204
657
419
778
587
1003
101
665
509
8
853
652
117
418
443
192
371
588
260
862
103
970
445
73
243
1010
902
405
631
930
7
408
263
577
255
438
361
924
269
621
738
385
203
949
590
505
12
82
472
487
953
942
295
666
150
664
237
705
39
140
759
104
161
310
877
616
162
994
128
950
74
118
266
176
462
174
1009
252
65
824
234
843
258
859
985
987
102
149
59
793
614
201
207
352
890
1008
727
264
169
1022
571
777
563
463
513
768
453
903
787
598
120
645
335
324
62
440
240
622
520
784
548
515
594
634
44
528
186
663
589
424
158
416
659
460
501
794
22
486
811
90
640
50
980
565
898
56
241
973
803
482
206
755
800
599
133
113
532
1025
265
776
678
383
248
343
797
737
626
167
940
523
223
239
593
374
712
66
89
228
396
977
541
84
137
427
302
195
720
808
687
897
730
896
34
536
19
362
115
952
333
407
446
164
627
618
695
387
679
230
187
542
409
481
1021
308
642
817
330
425
109
110
887
152
740
791
199
382
698
492
530
936
961
40
831
889
53
181
182
323
749
507
35
160
729
261
313
779
511
743
734
401
934
421
929
29
208
932
134
744
783
197
568
97
757
643
559
119
708
1016
926
288
325
247
1014
724
502
171
60
251
686
597
972
619
975
538
518
393
578
919
254
570
403
175
869
142
217
1006
864
583
290
818
641
706
470
377
602
820
71
136
747
958
216
285
606
92
431
124
654
673
155
841
296
226
334
684
5
904
426
707
637
473
1001
672
558
696
610
88
337
894
457
153
543
649
466
886
596
693
319
607
680
250
868
674
865
14
804
130
603
328
70
433
215
170
52
703
564
948
988
2
605
552
311
547
522
908
882
630
742
465
447
27
539
519
177
168
420
892
996
370
788
496
503
504
829
340
173
490
754
855
960
321
668
415
891
546
147
3
661
262
246
968
781
57
344
493
286
567
959
131
306
534
332
751
625
562
68
317
1019
917
990
644
883
851
650
514
537
912
586
478
922
957
469
379
256
549
508
93
475
372
736
799
816
962
671
823
506
969
413
697
488
766
96
573
471
682
55
927
982
423
138
369
406
872
4
711
608
205
185
647
47
48
993
314
33
145
925
992
494
805
64
632
318
798
989
451
1018
556
489
94
923
485
830
604
125
623
692
429
714
351
595
20
144
282
916
417
132
17
232
629
701
1
31
681
474
580
521
825
307
289
273
85
713
320
367
870
761
512
127
617
721
998
190
835
880
991
848
561
37
365
388
834
906
978
845
871
402
662
227
790
146
154
108
46
87
867
235
434
294
653
172
677
984
83
484
32
397
41
356
746
802
795
281
739
441
468
910
913
156
284
477
863
579
67
785
331
857
277
722
316
1011
895
448
368
771
675
267
731
819
376
500
789
194
188
809
437
1000
354
954
873
200
620
909
229
442
694
476
106
670
667
30
358
837
690
1004
299
773
129
566
648
191
249
937
210
772
847
636
292
921
326
198
709
452
13
812
689
879
121
764
25
298
458
15
498
16
353
375
1023
554
767
833
529
455
51
179
999
939
525
861
449
42
450
112
213
852
327
111
159
551
244
157
750
964
928
792
139
828
359
745
126
491
341
165
309
613
436
218
947
345
592
517
849
196
61
45
826
615
585
428
76
716
373
303
404
378
569
628
36
24
997
741
479
72
389
832
572
582
95
214
100
660
1012
815
584
394
349
222
575
971
995
723
876
935
638
399
888
624
497
301
274
846
480
54
752
775
685
253
1007
9
315
193
827
726
293
329
390
183
550
914
719
287
651
78
807
574
850
758
18
683
350
422
166
275
516
540
178
107
355
348
840
854
224
951
858
184
553
979
639
510
270
163
220
148
346
944
786
347
753
98
21
810
391
527
813
291
236
733
976
==10646== 
==10646== HEAP SUMMARY:
==10646==     in use at exit: 208,976 bytes in 1,028 blocks
==10646==   total heap usage: 1,032 allocs, 4 frees, 249,980 bytes allocated
==10646== 
==10646== LEAK SUMMARY:
==10646==    definitely lost: 73,752 bytes in 3 blocks
==10646==    indirectly lost: 135,224 bytes in 1,025 blocks
==10646==      possibly lost: 0 bytes in 0 blocks
==10646==    still reachable: 0 bytes in 0 blocks
==10646==         suppressed: 0 bytes in 0 blocks
==10646== Rerun with --leak-check=full to see details of leaked memory
==10646== 
==10646== For counts of detected and suppressed errors, rerun with: -v
==10646== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 1025 -lt 1024
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1025_1024
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1025 OUT_N=1024'
shuf-reservoir-sampling failed with IN_N=1025 OUT_N=1024
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 1025
+ INPUT_LINES=1025
+ OUTPUT_LINES=1025
+ seq 1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_1025_1025
==10655== Memcheck, a memory error detector
==10655== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10655== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10655== Command: shuf -n 1025 -o out_1025_1025
==10655== 
--10655-- WARNING: unhandled syscall: 326
--10655-- You may be able to write your own handler.
--10655-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10655-- Nevertheless we consider this a bug.  Please report
--10655-- it at http://valgrind.org/support/bug_reports.html.
197
303
757
67
228
170
142
87
571
545
247
556
899
310
547
676
610
977
12
502
265
603
970
904
272
62
306
159
643
20
295
988
803
339
886
346
94
599
335
312
480
322
561
280
550
872
345
117
14
464
499
307
95
408
870
356
557
407
254
697
399
233
8
747
391
444
177
959
719
334
440
121
330
680
165
911
454
534
311
462
69
235
13
814
497
721
1009
598
190
826
793
144
984
938
479
173
667
52
491
766
463
929
81
270
466
24
587
969
59
174
695
483
924
318
678
96
415
724
447
136
832
68
552
19
591
690
742
913
594
960
513
896
563
217
192
149
741
853
436
790
28
195
530
176
637
533
205
940
751
238
51
789
756
856
215
535
405
609
64
416
669
431
819
835
626
568
816
647
785
714
411
128
699
91
748
666
316
355
22
847
806
92
486
271
234
810
266
406
689
942
786
862
838
451
256
861
21
31
267
952
225
893
682
980
694
381
482
912
813
733
85
844
566
801
452
628
48
705
608
278
326
584
443
387
809
554
651
133
817
372
284
341
758
169
72
343
130
78
543
981
328
98
840
470
55
490
126
421
298
519
791
131
489
691
160
612
968
198
737
277
889
459
577
529
602
573
617
157
145
210
107
40
461
635
903
1
640
473
492
681
313
455
294
102
962
910
218
449
900
113
342
333
572
542
777
230
613
465
244
975
536
946
172
716
997
963
722
251
485
880
57
876
83
269
873
47
365
441
309
208
226
467
1020
558
236
883
540
907
82
974
33
973
426
834
398
564
544
448
371
11
765
894
642
812
633
684
827
687
327
354
619
127
209
595
898
976
308
845
565
422
772
110
965
794
428
615
921
818
125
945
718
32
881
927
871
1018
44
683
964
671
204
1023
636
843
592
918
16
287
61
762
874
919
138
88
378
347
951
163
792
182
143
807
15
147
781
332
360
207
524
124
878
624
222
213
775
364
264
58
433
672
453
866
323
576
194
291
108
285
895
943
158
926
29
178
665
389
242
560
258
223
815
958
653
1013
711
761
37
752
726
137
77
476
947
630
257
538
180
864
825
989
865
179
200
352
831
715
250
916
915
140
403
788
953
712
723
783
575
429
262
941
80
522
639
70
63
567
42
478
129
863
45
779
359
487
319
241
995
259
855
297
111
74
1001
746
400
17
475
852
477
971
353
771
305
581
673
65
212
661
621
132
331
745
656
86
875
920
539
281
935
720
837
990
966
583
184
402
736
891
717
420
701
908
654
106
679
821
510
401
116
559
764
290
994
25
546
555
10
171
842
430
706
516
154
263
659
189
760
664
386
882
867
948
957
755
606
424
249
767
820
469
393
923
901
191
36
456
1012
527
887
1022
188
320
623
296
585
582
90
986
729
417
315
488
646
414
822
713
395
885
380
152
753
1024
30
275
841
438
118
725
589
645
914
274
75
528
344
634
156
520
418
3
474
631
153
504
103
770
292
660
620
376
884
151
548
797
768
798
944
503
614
239
410
588
237
472
496
141
860
508
632
99
155
193
800
509
949
383
836
299
507
150
199
795
846
662
854
1017
629
702
7
450
638
738
710
501
649
796
196
363
253
799
1019
848
996
325
808
850
79
437
26
999
627
120
515
301
657
458
104
1021
518
805
698
933
607
240
937
897
686
423
134
811
73
597
744
570
824
663
419
146
906
435
446
390
998
611
202
54
382
1007
778
579
273
707
930
498
293
782
181
23
769
425
432
1014
754
749
397
644
276
670
66
84
1004
231
60
314
4
255
18
413
892
730
89
375
5
525
396
954
434
859
784
362
321
377
1003
600
35
668
517
56
243
460
562
135
495
950
869
553
187
625
286
148
248
506
735
728
1025
471
370
412
909
925
279
361
956
991
369
385
219
336
168
283
186
484
877
928
601
115
804
123
972
122
245
537
1010
409
740
574
232
38
494
392
500
830
731
688
590
641
982
514
9
214
114
618
932
833
978
532
317
1005
229
289
185
774
268
604
593
379
993
992
166
868
652
703
338
1002
183
734
439
983
349
648
743
175
340
53
1008
879
839
905
955
511
851
521
119
368
580
101
700
616
300
902
246
674
221
105
227
49
858
709
357
787
1015
457
750
366
261
34
773
201
763
329
493
934
888
206
985
622
442
373
6
302
857
551
931
692
523
802
374
388
50
890
93
2
337
549
394
304
759
849
569
505
961
162
829
203
650
727
586
1016
216
348
732
675
1000
427
693
696
445
655
739
776
109
46
708
987
282
350
917
367
605
97
823
685
596
164
512
967
828
780
384
526
936
922
100
167
351
1006
704
112
288
404
260
979
324
468
578
677
481
71
220
252
39
211
939
658
139
161
27
224
358
541
1011
41
76
531
43
==10655== 
==10655== HEAP SUMMARY:
==10655==     in use at exit: 209,112 bytes in 1,029 blocks
==10655==   total heap usage: 1,033 allocs, 4 frees, 250,124 bytes allocated
==10655== 
==10655== LEAK SUMMARY:
==10655==    definitely lost: 73,760 bytes in 3 blocks
==10655==    indirectly lost: 135,352 bytes in 1,026 blocks
==10655==      possibly lost: 0 bytes in 0 blocks
==10655==    still reachable: 0 bytes in 0 blocks
==10655==         suppressed: 0 bytes in 0 blocks
==10655== Rerun with --leak-check=full to see details of leaked memory
==10655== 
==10655== For counts of detected and suppressed errors, rerun with: -v
==10655== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 1025 -lt 1025
++ grep '^[0-9][0-9]*$' out_1025_1025
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1025 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1025 OUT_N=1025'
shuf-reservoir-sampling failed with IN_N=1025 OUT_N=1025
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 3071
+ INPUT_LINES=1025
+ OUTPUT_LINES=3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_1025_3071
+ seq 1025
==10663== Memcheck, a memory error detector
==10663== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10663== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10663== Command: shuf -n 3071 -o out_1025_3071
==10663== 
--10663-- WARNING: unhandled syscall: 326
--10663-- You may be able to write your own handler.
--10663-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10663-- Nevertheless we consider this a bug.  Please report
--10663-- it at http://valgrind.org/support/bug_reports.html.
622
459
878
241
631
129
507
849
642
401
776
821
678
352
506
997
519
803
142
778
907
906
790
796
468
299
563
246
636
369
351
891
929
230
799
100
703
202
946
883
704
692
55
25
731
614
542
697
871
766
156
558
798
41
288
897
569
989
714
927
392
982
96
662
745
197
495
1024
116
549
3
335
779
127
361
6
680
827
210
502
515
583
228
37
80
816
221
217
978
422
462
722
480
881
412
869
1022
325
646
804
986
128
772
262
1019
709
848
629
291
137
190
517
183
354
192
544
406
574
640
165
218
667
138
24
133
833
278
1006
180
910
441
265
448
850
865
696
637
718
509
694
198
571
632
767
239
436
771
596
394
874
93
418
409
717
822
267
388
357
390
603
1023
163
655
522
199
372
937
363
918
396
572
404
349
651
95
537
383
965
1017
619
610
584
825
92
478
371
945
994
476
175
18
758
336
36
39
231
512
348
823
245
628
458
612
935
676
812
809
747
674
1016
580
373
347
837
140
439
464
32
323
350
149
68
954
546
452
249
66
990
188
125
940
856
760
687
792
334
255
919
1008
147
579
209
297
503
861
777
564
461
663
734
1012
900
974
526
893
557
56
34
817
818
868
172
424
791
252
50
943
193
123
187
998
657
618
920
885
483
858
890
73
232
781
164
308
331
376
743
741
250
33
531
29
810
247
973
964
283
952
1007
841
48
304
993
566
930
959
591
535
819
281
641
110
226
683
1002
1
324
54
988
77
153
960
652
19
536
101
256
820
497
359
421
465
337
131
568
749
126
607
800
49
593
391
742
493
466
215
318
251
985
723
340
430
413
685
174
274
840
665
560
782
342
727
668
784
457
980
832
735
75
211
266
955
589
144
936
561
843
370
634
983
356
773
1018
69
867
730
609
346
82
16
114
995
844
229
31
189
540
141
902
520
496
872
416
845
379
179
107
984
384
380
285
966
806
485
314
301
693
834
481
21
408
759
836
169
111
310
240
1020
498
677
689
1001
788
835
931
135
953
196
587
921
51
45
454
345
768
403
94
926
117
765
623
860
826
547
487
934
65
947
139
732
1005
961
298
136
366
719
669
925
681
950
327
533
257
724
105
915
277
319
761
565
597
887
122
219
653
302
173
108
971
261
733
992
81
154
87
700
112
113
807
23
538
880
750
389
682
917
178
330
562
811
795
328
504
4
434
70
501
594
72
863
1004
578
329
284
428
527
559
254
201
721
615
866
521
909
996
28
146
160
170
854
238
280
460
576
88
991
748
545
435
1021
463
649
951
208
957
698
365
912
553
979
956
423
999
613
754
518
377
374
904
924
581
414
40
659
738
787
744
451
279
801
914
264
793
420
846
407
705
185
13
85
89
90
362
888
242
311
444
429
316
633
159
455
315
482
118
186
150
473
271
395
236
671
949
7
626
99
397
119
398
445
453
664
166
805
155
541
410
322
882
570
808
713
157
312
595
176
393
484
282
711
896
243
59
770
543
300
9
411
276
268
525
11
715
958
592
716
635
61
121
442
508
911
699
899
684
358
152
599
510
500
708
38
577
740
167
739
1015
1011
270
184
440
756
399
712
446
627
225
20
15
757
554
690
691
204
490
870
22
492
585
605
763
35
205
76
783
969
886
260
729
534
213
456
598
524
248
624
104
620
220
224
293
486
602
797
43
873
313
488
443
604
253
556
643
474
200
60
903
621
97
469
780
258
83
648
1003
551
46
686
876
191
79
289
1009
720
151
367
387
838
317
695
332
616
529
656
148
275
666
864
382
489
386
842
530
514
600
972
938
824
831
707
987
573
53
853
368
44
847
207
967
52
263
661
194
216
385
303
802
710
814
341
528
1000
879
12
109
353
670
343
1025
17
941
57
654
590
472
71
764
675
755
206
171
491
102
660
975
449
884
74
575
702
143
688
737
450
290
467
1014
923
815
47
586
438
630
295
182
402
134
98
968
728
26
638
948
901
913
132
625
828
10
785
415
273
725
962
309
214
877
751
305
908
360
168
647
928
789
425
432
320
567
475
339
746
405
963
84
976
753
30
679
67
1010
203
195
58
617
237
889
106
417
63
306
895
307
419
296
769
14
130
644
181
645
162
2
233
227
78
852
321
124
1013
42
378
286
736
145
829
775
830
437
933
64
762
287
426
774
513
862
650
244
523
970
582
839
539
269
601
27
894
905
120
234
516
375
8
726
223
427
859
381
939
259
555
548
892
477
922
511
333
977
292
338
91
588
611
505
552
673
550
499
222
706
898
355
981
752
326
944
212
5
786
855
158
494
364
658
86
447
103
672
701
294
344
916
115
857
532
813
794
639
471
479
433
62
400
606
851
177
431
470
235
272
608
942
875
932
161
==10663== 
==10663== HEAP SUMMARY:
==10663==     in use at exit: 209,112 bytes in 1,029 blocks
==10663==   total heap usage: 1,033 allocs, 4 frees, 250,124 bytes allocated
==10663== 
==10663== LEAK SUMMARY:
==10663==    definitely lost: 73,760 bytes in 3 blocks
==10663==    indirectly lost: 135,352 bytes in 1,026 blocks
==10663==      possibly lost: 0 bytes in 0 blocks
==10663==    still reachable: 0 bytes in 0 blocks
==10663==         suppressed: 0 bytes in 0 blocks
==10663== Rerun with --leak-check=full to see details of leaked memory
==10663== 
==10663== For counts of detected and suppressed errors, rerun with: -v
==10663== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 1025 -lt 3071
+ EXPECTED_LINES=1025
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1025_3071
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1025 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1025 OUT_N=3071'
shuf-reservoir-sampling failed with IN_N=1025 OUT_N=3071
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 3072
+ INPUT_LINES=1025
+ OUTPUT_LINES=3072
+ seq 1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_1025_3072
==10671== Memcheck, a memory error detector
==10671== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10671== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10671== Command: shuf -n 3072 -o out_1025_3072
==10671== 
--10671-- WARNING: unhandled syscall: 326
--10671-- You may be able to write your own handler.
--10671-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10671-- Nevertheless we consider this a bug.  Please report
--10671-- it at http://valgrind.org/support/bug_reports.html.
881
24
1009
361
1006
659
560
62
978
522
943
582
727
384
167
106
244
475
255
813
459
903
989
92
711
72
808
863
757
737
174
437
605
57
875
502
584
987
890
931
901
358
408
29
175
527
988
512
684
282
821
10
424
915
563
774
34
144
916
4
393
1011
905
139
165
730
515
77
872
378
313
113
932
388
976
323
841
231
418
22
897
89
658
198
15
906
657
608
998
209
910
632
482
677
506
740
789
183
64
288
433
578
16
1016
410
322
36
749
569
835
239
412
641
967
623
126
121
445
90
441
938
800
240
586
1000
221
406
451
570
490
904
992
63
21
870
896
762
469
420
801
581
768
1010
884
44
857
31
19
280
766
146
855
194
27
964
93
12
1013
65
820
652
41
911
691
73
60
577
723
103
45
891
2
525
690
105
294
1017
387
411
794
673
179
734
413
703
74
109
59
1023
736
767
229
798
945
851
400
759
588
622
75
981
536
941
312
773
503
265
572
966
9
708
210
817
260
421
660
202
14
291
854
670
554
379
67
314
568
615
984
858
333
293
32
675
499
529
429
279
795
122
66
661
667
836
303
320
363
225
180
728
689
617
91
845
815
204
23
447
949
627
355
514
811
942
892
513
436
769
272
991
564
1001
750
676
1004
273
687
491
88
501
17
748
747
277
583
912
927
784
816
237
702
220
552
680
597
662
520
97
357
653
735
478
161
843
804
878
268
914
642
547
417
274
663
315
120
678
419
975
256
596
793
508
125
497
754
713
76
809
186
732
189
876
131
399
590
114
249
573
404
591
130
776
825
38
340
640
498
449
616
507
440
318
1003
7
348
746
85
117
699
342
968
251
993
335
958
643
292
869
656
115
707
351
258
25
343
394
155
495
963
523
356
235
473
472
877
859
55
51
873
1022
216
193
481
152
997
104
395
778
1005
347
158
562
425
940
454
606
331
432
362
1025
799
241
706
275
848
1008
305
108
485
332
796
197
539
151
135
278
625
856
456
917
719
619
267
261
195
214
626
479
164
307
518
541
228
725
46
980
295
819
531
961
110
682
867
3
448
446
82
898
792
953
270
611
765
602
862
353
695
849
814
649
696
517
337
715
959
827
321
327
153
81
428
168
13
169
969
559
545
925
484
339
887
761
1021
861
200
594
222
610
383
422
26
977
1024
1018
171
824
521
460
983
620
5
593
341
403
173
840
311
788
483
107
492
805
550
79
546
147
458
832
516
952
304
376
893
217
692
544
325
720
880
477
509
354
853
839
790
865
571
257
587
370
797
971
1020
156
838
669
929
33
830
128
328
50
553
739
697
28
743
397
729
500
882
276
651
467
172
885
637
205
698
826
575
902
828
283
807
350
96
823
726
868
543
289
154
476
455
950
243
127
377
196
900
705
909
1002
298
471
647
718
924
538
184
83
1012
604
999
630
53
954
415
345
129
935
201
474
160
613
334
317
18
785
556
534
724
609
101
264
182
731
373
864
486
386
39
299
206
431
957
87
252
567
763
444
782
886
654
423
710
535
758
11
741
148
803
262
71
666
874
463
934
894
8
655
300
163
561
930
248
203
111
549
219
933
1019
833
742
232
138
974
693
947
557
324
639
185
704
580
308
511
530
391
310
416
40
540
211
374
360
686
526
330
396
907
236
392
191
555
831
895
43
760
716
199
86
442
645
733
133
635
965
181
585
284
269
982
426
551
124
230
920
683
466
908
37
624
56
99
496
98
461
145
688
628
994
822
533
68
58
149
744
213
847
281
923
245
286
385
745
140
344
438
866
936
136
850
722
338
382
985
753
359
346
94
380
791
802
398
224
1007
979
913
326
946
846
170
218
95
607
49
132
548
834
42
254
123
996
579
600
30
922
990
162
452
542
772
247
599
764
787
287
297
528
61
926
430
443
112
150
756
488
944
450
465
468
889
329
409
368
519
439
781
253
806
770
574
20
389
755
316
648
263
188
970
951
612
717
638
618
52
589
871
464
1015
266
192
47
986
54
302
879
414
207
694
860
665
381
636
505
349
271
119
701
434
621
786
644
721
309
402
137
783
565
812
352
921
899
290
70
301
480
601
319
166
306
532
752
78
646
1
918
738
223
679
780
143
829
336
524
956
390
116
208
844
712
157
842
177
178
504
102
685
566
118
751
401
405
576
234
250
190
369
176
714
372
227
709
937
681
134
365
955
558
818
810
995
837
226
962
296
375
771
371
159
948
852
510
919
537
187
779
212
672
939
487
84
238
595
668
671
928
633
629
259
366
493
246
700
141
453
435
69
457
489
285
215
664
650
888
631
48
634
100
242
960
973
674
407
6
775
494
80
35
364
777
598
470
614
972
233
462
142
592
883
427
1014
603
367
==10671== 
==10671== HEAP SUMMARY:
==10671==     in use at exit: 209,112 bytes in 1,029 blocks
==10671==   total heap usage: 1,033 allocs, 4 frees, 250,124 bytes allocated
==10671== 
==10671== LEAK SUMMARY:
==10671==    definitely lost: 73,760 bytes in 3 blocks
==10671==    indirectly lost: 135,352 bytes in 1,026 blocks
==10671==      possibly lost: 0 bytes in 0 blocks
==10671==    still reachable: 0 bytes in 0 blocks
==10671==         suppressed: 0 bytes in 0 blocks
==10671== Rerun with --leak-check=full to see details of leaked memory
==10671== 
==10671== For counts of detected and suppressed errors, rerun with: -v
==10671== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 1025 -lt 3072
+ EXPECTED_LINES=1025
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_1025_3072
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1025 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1025 OUT_N=3072'
shuf-reservoir-sampling failed with IN_N=1025 OUT_N=3072
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 1025 3073
+ INPUT_LINES=1025
+ OUTPUT_LINES=3073
+ seq 1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_1025_3073
==10684== Memcheck, a memory error detector
==10684== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10684== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10684== Command: shuf -n 3073 -o out_1025_3073
==10684== 
--10684-- WARNING: unhandled syscall: 326
--10684-- You may be able to write your own handler.
--10684-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10684-- Nevertheless we consider this a bug.  Please report
--10684-- it at http://valgrind.org/support/bug_reports.html.
803
111
971
578
84
873
11
529
563
949
188
264
318
871
454
490
853
28
969
834
120
453
333
202
52
961
58
101
279
836
223
147
574
915
334
614
102
384
376
735
972
601
85
885
218
878
643
956
959
185
758
682
954
273
955
762
869
937
796
921
378
476
904
579
34
203
140
792
675
247
766
357
306
924
1009
29
652
436
480
555
583
865
394
752
918
149
517
984
98
301
420
841
416
139
94
690
779
467
999
707
86
910
277
494
537
719
556
473
332
405
523
793
809
542
392
60
417
593
50
270
81
920
524
276
941
554
236
249
191
76
723
636
35
293
934
731
837
724
886
584
893
617
23
387
548
573
63
634
890
603
874
718
715
182
970
671
259
435
74
342
822
594
624
688
525
78
922
1023
720
131
42
754
638
567
821
448
6
450
485
351
990
736
272
477
645
186
224
399
686
1005
12
982
338
705
644
309
71
105
73
960
898
377
285
36
344
855
1015
973
717
784
622
87
514
838
231
767
917
156
950
730
558
738
847
1006
571
1013
373
511
848
945
962
722
143
489
646
534
230
864
587
611
3
166
812
287
903
365
782
692
466
586
829
975
354
238
275
948
897
958
228
498
449
804
371
412
260
964
751
457
308
324
345
995
499
95
364
696
642
22
670
484
1018
492
325
385
488
881
195
783
674
923
659
110
455
51
456
14
813
911
30
10
463
44
125
933
372
527
82
953
190
891
55
729
651
15
572
553
227
346
470
445
653
366
312
253
92
307
657
258
339
26
817
359
781
8
204
474
104
243
323
827
350
561
765
798
936
663
951
619
683
946
1007
993
716
1011
533
852
808
882
1022
252
290
137
820
286
61
639
668
315
1025
748
710
689
242
734
700
824
699
887
884
161
208
181
994
515
531
744
428
459
41
544
217
505
991
913
322
870
328
539
900
520
232
452
745
1001
402
861
130
506
501
681
776
530
414
637
854
437
177
434
1002
591
532
746
481
442
303
968
831
706
1004
401
138
229
980
352
292
443
883
550
194
133
545
158
321
909
500
458
167
607
410
519
432
254
398
193
540
680
957
625
851
627
908
778
310
263
842
802
123
557
981
620
1024
316
892
180
747
175
17
330
608
209
773
977
43
173
660
633
760
96
772
320
214
77
479
331
935
444
408
148
219
974
799
701
282
32
347
815
825
806
317
919
47
70
113
543
319
599
13
687
570
577
57
889
508
978
566
162
21
171
440
313
737
305
702
446
67
106
172
756
294
18
25
413
38
176
486
165
213
858
439
183
629
856
56
72
576
433
521
876
302
538
863
801
80
482
299
200
97
1010
704
46
493
136
212
860
658
966
239
826
894
460
155
580
996
899
581
246
48
400
888
132
491
788
605
367
753
775
93
769
535
90
109
740
604
749
355
381
983
632
794
835
516
507
1016
509
818
248
725
785
390
154
666
640
713
647
879
787
241
667
867
541
257
19
269
233
281
551
859
814
655
750
721
728
268
66
906
103
673
353
843
828
595
1014
220
100
672
616
472
510
929
857
27
612
343
703
830
780
207
421
216
266
64
547
189
469
609
151
391
475
678
998
150
65
669
274
164
711
311
649
179
901
423
91
146
288
811
875
522
289
590
99
914
997
187
774
630
877
691
992
9
589
732
205
251
967
169
210
261
676
546
895
596
115
786
631
661
797
679
600
938
397
360
24
363
126
810
45
733
845
739
928
1021
326
153
988
757
963
641
789
927
349
404
536
447
989
464
37
427
407
483
575
374
932
280
329
677
771
336
1000
662
866
296
805
340
564
1020
341
940
777
698
694
770
807
406
196
588
168
127
49
791
54
134
386
4
184
388
297
849
361
117
409
53
528
221
33
39
358
823
943
62
549
613
685
68
708
985
987
585
441
665
839
5
907
598
610
395
379
20
763
192
160
755
31
471
947
278
295
112
850
16
559
327
880
197
833
418
431
129
902
503
314
403
271
225
159
163
979
761
526
478
709
939
912
618
267
383
986
697
628
430
862
635
597
291
424
121
114
157
199
89
615
726
1
502
2
819
790
832
868
438
504
425
178
83
226
124
362
170
656
426
816
356
496
512
896
592
389
250
495
375
262
119
465
844
846
684
952
905
198
370
382
419
122
741
201
693
650
234
222
135
368
800
931
759
621
1017
451
1003
916
304
840
582
256
518
742
1019
144
107
235
142
714
654
206
255
284
1012
606
461
602
565
108
560
240
1008
237
411
513
648
396
429
926
59
422
795
79
768
118
298
380
265
244
40
487
337
462
925
152
393
930
283
69
552
562
128
743
965
976
764
348
88
211
568
141
626
75
415
623
300
468
245
942
335
944
369
145
569
695
727
712
215
664
116
872
7
174
497
==10684== 
==10684== HEAP SUMMARY:
==10684==     in use at exit: 209,112 bytes in 1,029 blocks
==10684==   total heap usage: 1,033 allocs, 4 frees, 250,124 bytes allocated
==10684== 
==10684== LEAK SUMMARY:
==10684==    definitely lost: 73,760 bytes in 3 blocks
==10684==    indirectly lost: 135,352 bytes in 1,026 blocks
==10684==      possibly lost: 0 bytes in 0 blocks
==10684==    still reachable: 0 bytes in 0 blocks
==10684==         suppressed: 0 bytes in 0 blocks
==10684== Rerun with --leak-check=full to see details of leaked memory
==10684== 
==10684== For counts of detected and suppressed errors, rerun with: -v
==10684== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 1025 -lt 3073
+ EXPECTED_LINES=1025
++ sort -un
++ grep '^[0-9][0-9]*$' out_1025_3073
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1025 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=1025 OUT_N=3073'
shuf-reservoir-sampling failed with IN_N=1025 OUT_N=3073
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 0
+ INPUT_LINES=3071
+ OUTPUT_LINES=0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_3071_0
+ seq 3071
==10692== Memcheck, a memory error detector
==10692== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10692== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10692== Command: shuf -n 0 -o out_3071_0
==10692== 
--10692-- WARNING: unhandled syscall: 326
--10692-- You may be able to write your own handler.
--10692-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10692-- Nevertheless we consider this a bug.  Please report
--10692-- it at http://valgrind.org/support/bug_reports.html.
==10692== 
==10692== HEAP SUMMARY:
==10692==     in use at exit: 4,176 bytes in 3 blocks
==10692==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10692== 
==10692== LEAK SUMMARY:
==10692==    definitely lost: 24 bytes in 2 blocks
==10692==    indirectly lost: 4,152 bytes in 1 blocks
==10692==      possibly lost: 0 bytes in 0 blocks
==10692==    still reachable: 0 bytes in 0 blocks
==10692==         suppressed: 0 bytes in 0 blocks
==10692== Rerun with --leak-check=full to see details of leaked memory
==10692== 
==10692== For counts of detected and suppressed errors, rerun with: -v
==10692== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 3071 -lt 0
++ wc -l
++ grep '^[0-9][0-9]*$' out_3071_0
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 1
+ INPUT_LINES=3071
+ OUTPUT_LINES=1
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_3071_1
+ seq 3071
==10708== Memcheck, a memory error detector
==10708== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10708== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10708== Command: shuf -n 1 -o out_3071_1
==10708== 
--10708-- WARNING: unhandled syscall: 326
--10708-- You may be able to write your own handler.
--10708-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10708-- Nevertheless we consider this a bug.  Please report
--10708-- it at http://valgrind.org/support/bug_reports.html.
1528
==10708== 
==10708== HEAP SUMMARY:
==10708==     in use at exit: 37,112 bytes in 5 blocks
==10708==   total heap usage: 9 allocs, 4 frees, 37,316 bytes allocated
==10708== 
==10708== LEAK SUMMARY:
==10708==    definitely lost: 32,832 bytes in 3 blocks
==10708==    indirectly lost: 4,280 bytes in 2 blocks
==10708==      possibly lost: 0 bytes in 0 blocks
==10708==    still reachable: 0 bytes in 0 blocks
==10708==         suppressed: 0 bytes in 0 blocks
==10708== Rerun with --leak-check=full to see details of leaked memory
==10708== 
==10708== For counts of detected and suppressed errors, rerun with: -v
==10708== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 3071 -lt 1
++ grep '^[0-9][0-9]*$' out_3071_1
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3071 OUT_N=1'
shuf-reservoir-sampling failed with IN_N=3071 OUT_N=1
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 5
+ INPUT_LINES=3071
+ OUTPUT_LINES=5
+ seq 3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_3071_5
==10716== Memcheck, a memory error detector
==10716== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10716== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10716== Command: shuf -n 5 -o out_3071_5
==10716== 
--10716-- WARNING: unhandled syscall: 326
--10716-- You may be able to write your own handler.
--10716-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10716-- Nevertheless we consider this a bug.  Please report
--10716-- it at http://valgrind.org/support/bug_reports.html.
2836
2204
1663
2807
2105
==10716== 
==10716== HEAP SUMMARY:
==10716==     in use at exit: 37,784 bytes in 9 blocks
==10716==   total heap usage: 14 allocs, 5 frees, 38,156 bytes allocated
==10716== 
==10716== LEAK SUMMARY:
==10716==    definitely lost: 32,992 bytes in 3 blocks
==10716==    indirectly lost: 4,792 bytes in 6 blocks
==10716==      possibly lost: 0 bytes in 0 blocks
==10716==    still reachable: 0 bytes in 0 blocks
==10716==         suppressed: 0 bytes in 0 blocks
==10716== Rerun with --leak-check=full to see details of leaked memory
==10716== 
==10716== For counts of detected and suppressed errors, rerun with: -v
==10716== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 3071 -lt 5
++ grep '^[0-9][0-9]*$' out_3071_5
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3071 OUT_N=5'
shuf-reservoir-sampling failed with IN_N=3071 OUT_N=5
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 1023
+ INPUT_LINES=3071
+ OUTPUT_LINES=1023
+ seq 3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_3071_1023
==10724== Memcheck, a memory error detector
==10724== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10724== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10724== Command: shuf -n 1023 -o out_3071_1023
==10724== 
--10724-- WARNING: unhandled syscall: 326
--10724-- You may be able to write your own handler.
--10724-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10724-- Nevertheless we consider this a bug.  Please report
--10724-- it at http://valgrind.org/support/bug_reports.html.
696
1672
1537
3009
1634
121
2664
1532
2327
2371
2102
2094
2362
1845
370
1895
35
25
2066
2020
2412
8
1157
1331
474
2675
2492
576
610
1758
1457
1567
289
10
1541
1967
564
2798
2333
1086
1326
310
1105
1222
1822
1465
1134
105
1168
1764
2370
2963
2857
1985
1576
2252
366
1107
2596
2868
1491
3046
729
1484
108
165
3062
1843
994
1521
2708
701
2305
2913
2691
690
688
2417
969
499
85
1565
519
753
958
867
1117
3030
996
1757
1893
2513
407
1226
1513
563
2901
1705
3037
410
277
799
1633
2612
1379
882
507
1718
2786
417
2660
1007
1033
19
58
888
1908
1556
2232
67
369
37
2689
936
2610
2800
614
2381
784
98
2543
1422
254
1081
2219
1792
595
965
1261
2515
1015
2091
2039
897
193
2156
911
1734
2890
1813
2569
659
580
1447
2879
2654
2350
1180
96
2043
2860
2451
2508
217
2019
1354
1679
119
2080
2042
2259
145
1070
1340
814
2441
2460
2924
2607
616
1620
167
1366
890
2825
1383
984
2894
266
2998
1664
1840
2558
1401
2875
1999
2104
902
875
2731
386
1192
2012
505
1682
1373
1821
1600
2076
454
2902
1463
2402
2257
2437
263
1995
917
2567
981
2002
599
206
1451
2725
2491
581
2280
1038
79
295
2603
2903
2344
2023
2656
1820
2068
436
1806
122
622
1299
664
547
951
199
747
2351
213
2054
3008
2703
3034
2765
1166
1591
1680
1249
843
1872
2858
274
2994
1043
578
483
385
241
1912
1012
2132
2693
2331
1492
2171
1272
820
2519
3016
2655
3025
2235
829
2128
333
666
1193
1594
2001
2195
3011
2199
797
846
2142
1236
1615
802
1873
487
1221
1356
787
1376
2608
2103
2062
546
2392
288
1550
2588
1888
2365
53
837
2184
656
2057
2027
2617
2794
2776
635
2409
1330
276
713
1415
1177
2045
1906
807
643
2510
2111
2086
785
605
438
1916
1952
922
634
307
338
404
2378
1750
1798
262
989
1178
308
1543
1416
2811
2914
774
2940
2502
73
854
551
1603
1495
109
2859
2186
1721
2843
452
1384
229
2036
1552
2565
211
1782
2477
728
2161
1413
2120
600
363
2191
1430
862
481
61
2560
2130
64
1020
1826
334
1488
88
1997
2278
2319
2010
1219
1142
347
2536
3007
1327
847
3002
2615
1831
1474
1318
831
1887
2470
272
1056
201
2842
1559
1852
909
2742
2281
2631
42
2577
1078
2764
2083
977
869
1271
2792
2208
1926
2487
2116
1238
1062
1427
1028
2756
2013
1899
1612
1761
926
2737
1579
2506
2424
2148
679
1793
2069
2668
124
77
2435
1284
1623
1592
2677
1554
2877
29
1748
2977
327
344
1832
49
2605
2554
626
1409
2827
1023
421
1667
11
2041
2911
778
1179
1163
1581
261
2625
2823
3054
2133
1599
2833
189
1668
1650
1475
2968
416
1941
116
552
645
1573
709
1441
406
1857
1087
1408
2909
1088
522
629
929
1953
2527
2150
1307
2698
1954
512
3063
1896
1524
352
2728
94
2768
2203
2846
1167
1146
1213
1909
2882
2096
1209
511
387
1385
2967
2268
1159
1791
248
2719
967
284
2808
2284
1147
542
3015
2619
913
1917
392
1751
2679
1656
565
633
1258
2425
1208
1858
1032
209
1527
968
1200
700
2206
800
2445
2290
418
2637
793
1368
451
1112
1907
2475
491
916
1453
1141
1263
342
173
2047
1104
1802
221
533
1067
2312
704
210
2008
446
1943
2540
1496
1834
1374
1643
339
1264
2274
1006
1246
2813
1628
2947
771
1811
794
154
2316
2255
2652
561
2450
2628
1041
851
640
1426
202
2497
1295
2303
170
516
517
1136
1632
1606
735
118
1252
615
2659
675
178
1472
1867
538
175
628
114
2376
55
1506
197
801
825
2434
1691
330
1934
647
2422
1231
2614
1807
544
1365
1317
2531
1436
2152
183
1360
2458
2216
2375
1276
220
2995
1267
1115
2105
676
763
1939
1640
2979
737
918
1522
95
567
2938
2174
2146
1255
1392
868
1322
1962
2692
2551
2680
2974
312
2448
1673
1381
3061
1630
1921
2182
788
493
301
1582
2750
393
931
810
467
3066
2959
250
2471
1338
244
2796
2718
1461
1139
2242
2613
1022
489
1637
1665
3028
683
1727
2886
2431
1514
2746
2711
1823
997
1375
1768
162
1993
783
2944
1485
1084
2078
1161
764
2810
1919
2928
216
225
142
2181
2651
2428
2021
2624
158
2745
2037
2647
2667
1817
509
434
270
1853
2528
2092
1164
1646
2495
1064
153
256
2966
2233
1969
947
2384
1804
1244
2113
2129
1278
2079
2795
1624
899
751
2217
823
2897
1471
1609
697
589
2538
2850
492
934
2722
1799
2699
2965
853
1121
127
2153
661
440
815
962
883
2926
1590
2418
623
1885
2729
415
1445
1601
898
1929
1589
1608
2661
776
2388
1835
2556
1786
84
1182
2635
1240
1464
2215
1205
379
2246
644
2462
755
2222
1407
402
115
2407
500
2566
359
2870
2611
2761
2529
191
1787
2952
1419
497
205
956
1933
302
2221
1900
358
717
2486
2880
560
2405
1201
83
2609
1036
2262
819
1346
2665
1370
1270
2743
906
194
361
120
2526
669
1509
1936
566
602
2709
1054
885
1683
2007
1310
1789
2479
502
3039
20
1520
1342
2397
2532
1185
1198
2332
758
2231
549
1197
329
2915
2991
1069
1670
1469
2836
190
218
3032
1292
2552
518
2500
331
2646
2077
2821
2315
525
1287
1239
722
1614
377
3029
2760
1586
2247
1097
1555
2473
2747
2339
1439
2920
1224
1833
2829
1977
326
667
1130
562
247
72
896
912
353
2320
1435
1724
325
278
177
668
2446
2921
1598
3005
1583
1137
1572
2
575
1051
2541
863
1878
1765
2971
1390
459
2387
1362
648
2865
2135
2685
2851
1661
107
2847
464
==10724== 
==10724== HEAP SUMMARY:
==10724==     in use at exit: 208,808 bytes in 1,027 blocks
==10724==   total heap usage: 1,032 allocs, 5 frees, 249,900 bytes allocated
==10724== 
==10724== LEAK SUMMARY:
==10724==    definitely lost: 73,712 bytes in 3 blocks
==10724==    indirectly lost: 135,096 bytes in 1,024 blocks
==10724==      possibly lost: 0 bytes in 0 blocks
==10724==    still reachable: 0 bytes in 0 blocks
==10724==         suppressed: 0 bytes in 0 blocks
==10724== Rerun with --leak-check=full to see details of leaked memory
==10724== 
==10724== For counts of detected and suppressed errors, rerun with: -v
==10724== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 3071 -lt 1023
++ grep '^[0-9][0-9]*$' out_3071_1023
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3071 OUT_N=1023'
shuf-reservoir-sampling failed with IN_N=3071 OUT_N=1023
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 1024
+ INPUT_LINES=3071
+ OUTPUT_LINES=1024
+ seq 3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_3071_1024
==10732== Memcheck, a memory error detector
==10732== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10732== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10732== Command: shuf -n 1024 -o out_3071_1024
==10732== 
--10732-- WARNING: unhandled syscall: 326
--10732-- You may be able to write your own handler.
--10732-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10732-- Nevertheless we consider this a bug.  Please report
--10732-- it at http://valgrind.org/support/bug_reports.html.
871
2650
822
3071
2929
1457
1150
2835
2365
1292
1054
1263
2255
1310
265
349
2109
420
2081
543
1413
2134
124
236
851
2139
35
475
1781
820
2039
1889
583
1684
2270
537
1183
459
1173
115
2600
648
211
2176
1340
1353
2935
1561
2246
2178
1271
2064
1858
836
1770
2066
1433
2179
1665
3030
1095
204
1644
2016
1027
2505
185
1546
3022
691
1065
1636
2431
2789
2818
11
1235
1693
1217
886
371
1094
1389
2317
894
989
1533
315
1014
846
854
2453
2751
552
1363
249
688
1810
1528
445
184
2006
1017
867
801
2263
2982
240
2100
1013
1631
2087
1435
859
3007
1149
1179
1474
597
2279
82
1944
327
2522
2694
500
1755
2579
799
805
461
2078
1383
196
2473
3012
2274
1795
1213
1045
877
1211
2862
436
13
447
2640
1624
876
2063
536
638
1931
1939
37
1750
2595
939
561
89
1811
1579
2726
1172
967
2296
2196
1380
1901
1388
38
2131
1133
1924
1214
944
1347
2846
716
1756
1198
1948
2030
2998
932
1686
2703
2421
2711
1387
1364
2901
1911
1480
2941
2329
1786
1835
76
350
192
1063
3005
2474
330
1089
1521
75
1853
294
230
49
1800
742
208
2415
975
747
159
2206
2508
278
1265
1654
161
2792
2622
2154
1268
477
2333
2741
2687
544
2439
2657
1886
2038
2638
870
1262
1006
258
1317
1936
2851
1962
758
251
1469
2397
2516
1129
2933
2330
640
1536
2708
78
376
2249
2496
1448
1779
1307
1519
1680
452
2436
2025
1773
2083
660
1440
462
2144
2663
560
2388
1346
2151
2422
1959
34
212
1269
2008
1564
234
2328
3021
2252
314
1248
93
1663
534
2159
1837
2338
2943
2565
1005
2057
182
1920
535
1442
254
2660
2900
1506
1891
3061
1771
1300
1997
2140
1185
1449
2932
340
2227
1748
232
2680
2121
998
396
2578
2125
1196
2842
1194
3067
1071
2429
2257
2586
245
2994
2377
2724
1912
2973
1675
713
2494
958
2051
205
816
1819
2050
325
872
1438
2885
2857
1950
737
829
2975
529
753
2649
2760
791
382
2602
458
1685
497
2824
411
920
1666
88
1490
1443
1395
809
80
972
2964
3051
587
1118
1354
1487
1574
2035
1584
937
2709
1825
1707
2250
567
443
959
705
1191
1551
2469
1151
976
551
2607
2269
2398
2807
923
1432
2718
2524
644
2465
2871
26
2442
2332
2492
994
2836
749
1138
1499
494
2720
1233
2133
864
2732
596
2817
586
1861
960
1513
422
2168
740
1638
243
602
2367
2742
1583
1103
1872
2340
2424
2963
2253
645
715
3035
558
3064
2647
2645
286
2136
2750
962
2102
1618
2132
274
1772
480
2519
1783
1431
2558
503
2361
174
1408
601
824
2145
390
1577
1278
2396
2231
2856
2609
189
738
2175
3066
1978
2031
2103
2309
1893
213
1960
2352
754
2896
2864
2201
1702
2683
282
3065
2075
1682
1719
397
1740
2406
2399
1511
1284
1277
2619
2947
917
2208
160
1022
406
2247
2290
1181
144
2834
2542
2493
832
1472
2552
2238
373
1890
1272
1302
2537
1460
2981
2785
1988
2838
1503
572
1983
418
2728
2768
2545
3025
1411
1190
1182
807
2914
979
2756
1461
2682
1391
2634
2829
48
2460
903
148
1554
860
339
1694
966
2659
695
582
1355
856
1787
433
2037
2065
1100
318
2674
305
1313
2610
2810
1757
1507
300
2803
2041
925
2491
2137
911
2656
545
506
1497
2497
1327
2930
27
303
2921
2150
772
1721
884
853
169
1892
2666
2848
1595
2455
421
2484
623
87
1910
1368
2446
1477
2937
331
127
1291
2867
487
355
768
1747
343
2873
1958
218
2221
633
842
896
2849
650
1207
1404
154
1949
1031
676
2337
1515
1593
2529
1662
1016
2902
2108
2094
1114
2489
3028
843
1471
2095
1859
1609
712
2874
1649
214
2786
2758
2202
1505
210
734
1102
1914
2582
1112
381
2978
354
138
693
2230
880
2950
2015
670
1121
47
2345
2521
3020
1001
1926
172
107
136
1070
469
2437
2628
1608
971
201
1592
669
837
3050
634
2359
36
2033
1323
1153
1807
2584
1244
2007
1573
408
2199
1021
918
2686
329
2587
900
2796
2115
835
227
1199
158
786
2695
1610
2576
1376
782
2571
1646
81
1919
698
1992
186
1336
2869
1158
225
1378
2799
1286
1979
173
1799
2004
2266
2509
248
1828
1127
2797
1791
2673
652
1993
2604
709
85
441
2161
156
2319
1078
1961
532
2170
1689
2028
1090
1713
517
2958
752
272
3010
152
736
2244
3015
2471
2146
2761
2488
909
957
2617
2044
2357
1541
1678
2228
2787
1699
2284
1260
1312
2875
564
1099
424
1033
328
2734
2993
1560
523
465
1489
3009
895
655
1372
2725
1285
1373
3011
2755
931
1539
2514
1656
207
2053
1871
2335
2164
2464
39
2462
2014
2654
2152
12
1003
2501
2651
2561
1237
1903
463
984
484
813
515
1038
2069
1257
1416
2847
739
598
1204
1187
653
1691
2653
2816
2625
2934
193
2304
2392
2318
132
360
2644
1344
1201
69
1156
985
1818
2423
2341
1987
592
1957
2985
2426
717
3006
2091
1356
66
308
2024
2212
668
2174
2369
2952
520
1780
1744
2402
2714
1706
261
2908
1718
901
1165
2163
2347
910
292
908
2286
2946
3013
474
2205
2675
2360
1091
2084
2821
18
365
2969
902
233
2504
2692
1716
1840
605
223
2350
3041
1623
1015
190
1326
58
538
827
2957
1422
2989
1517
1696
150
1322
1701
393
177
1314
464
356
968
986
1311
512
2372
1223
1092
2197
1074
2420
687
1580
2639
1427
2373
2534
2384
2590
1671
1059
2195
627
310
1332
2721
2466
3069
922
1396
2225
1730
874
104
1224
1582
1049
1514
195
1501
3063
1657
2822
1991
2468
1040
1758
1064
2380
179
1020
2280
890
==10732== 
==10732== HEAP SUMMARY:
==10732==     in use at exit: 208,976 bytes in 1,028 blocks
==10732==   total heap usage: 1,033 allocs, 5 frees, 250,108 bytes allocated
==10732== 
==10732== LEAK SUMMARY:
==10732==    definitely lost: 73,752 bytes in 3 blocks
==10732==    indirectly lost: 135,224 bytes in 1,025 blocks
==10732==      possibly lost: 0 bytes in 0 blocks
==10732==    still reachable: 0 bytes in 0 blocks
==10732==         suppressed: 0 bytes in 0 blocks
==10732== Rerun with --leak-check=full to see details of leaked memory
==10732== 
==10732== For counts of detected and suppressed errors, rerun with: -v
==10732== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 3071 -lt 1024
++ grep '^[0-9][0-9]*$' out_3071_1024
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3071 OUT_N=1024'
shuf-reservoir-sampling failed with IN_N=3071 OUT_N=1024
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 1025
+ INPUT_LINES=3071
+ OUTPUT_LINES=1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_3071_1025
==10744== Memcheck, a memory error detector
==10744== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10744== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10744== Command: shuf -n 1025 -o out_3071_1025
==10744== 
+ seq 3071
--10744-- WARNING: unhandled syscall: 326
--10744-- You may be able to write your own handler.
--10744-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10744-- Nevertheless we consider this a bug.  Please report
--10744-- it at http://valgrind.org/support/bug_reports.html.
1106
2802
1266
1980
363
1191
729
910
1690
2470
821
2367
1414
977
2570
2772
1387
2255
315
2006
754
2757
1843
1541
1201
775
2138
1384
219
1522
2505
2103
210
38
1793
591
1734
434
1799
809
1069
713
569
1988
1885
1023
1616
953
1175
3071
703
2494
2351
2371
2112
1960
2520
1805
1199
1049
661
1241
1914
532
1694
276
475
2074
2476
2087
1917
126
291
285
471
89
1712
2482
641
474
888
2876
229
1077
331
816
2107
2252
2145
62
1348
779
718
420
2630
1035
2173
2290
2961
1073
1134
2410
1501
1238
146
2465
286
627
1567
745
1928
799
2003
1403
2734
1152
408
278
119
3066
1777
2413
1425
938
2988
1831
1486
1681
1218
269
2358
2397
37
710
1145
2672
1745
2994
695
1159
1010
1926
2352
505
2576
380
2241
595
638
1927
1593
1929
2439
1351
1488
2828
1435
2517
50
2854
2154
513
1183
1802
1716
560
14
2996
2815
1002
1249
884
2909
1955
2050
3020
2662
1502
2033
442
829
2890
2773
1733
2893
1182
1599
2564
2745
2881
215
2213
2957
1521
1721
1853
2848
2349
2830
2696
1876
2759
200
2648
1461
1604
326
2335
773
55
1647
430
504
643
370
2237
2419
238
1133
2531
2882
2735
1605
444
599
287
2403
392
2012
572
3043
1217
2805
583
789
2970
2481
1393
794
1459
2187
413
2857
1844
2493
295
48
1757
649
3067
1991
1819
1197
990
589
864
730
2955
42
120
553
441
96
1363
2042
1889
2519
2597
1092
1828
1825
162
224
1048
1364
330
501
1820
3034
1586
1678
2822
820
2644
174
1136
12
2992
2182
1362
715
1746
1961
2620
908
2380
1618
672
631
2498
2487
614
2510
2686
2728
1786
1797
2883
2399
1046
1239
376
2250
321
2202
793
1368
2029
358
2293
1311
940
1628
2283
412
1776
1864
845
2959
2246
2148
1209
93
170
1685
1965
1653
1067
2723
2051
2424
2769
147
966
1165
433
3040
843
1514
2060
342
1264
2245
1545
692
1147
2731
3019
3032
901
1977
1925
274
1464
2198
2037
1518
620
2935
1381
2704
2724
2729
787
1346
814
490
2681
98
2364
1356
296
428
2377
3047
1291
1508
1303
2052
1087
2794
1867
2354
2088
1924
902
898
1099
446
2332
2220
807
2958
365
2836
808
801
1783
3028
11
1923
646
2554
271
1505
724
1656
1412
2918
690
3006
1180
1708
1983
414
867
535
891
1627
1566
1096
2227
1947
2613
2770
2717
1898
738
2574
1419
346
275
527
1784
858
915
495
1650
1595
1491
573
2637
279
2774
1276
158
3068
91
416
1533
2323
931
2453
606
2900
2658
2197
894
1375
2548
343
1468
542
2322
1350
2880
1525
2641
584
2859
2726
608
2132
2671
778
1771
1765
1389
613
1743
863
464
1263
2286
1242
804
2913
3023
1952
1633
1275
1817
624
1978
2999
2707
2606
2161
2525
1258
2642
2624
609
2793
2295
293
2799
2582
2110
2129
2951
2504
2552
1887
2640
1714
846
211
2085
154
2567
2748
1347
2982
1104
1421
2204
1865
2298
1135
2021
1277
395
198
341
1327
1059
1008
928
975
2201
1578
781
58
2094
86
2677
2414
1893
1394
94
460
1738
1897
2143
2985
1097
2529
1037
2365
149
378
425
1717
2715
2643
2562
1655
1664
2801
2214
541
1065
36
367
199
561
633
1236
82
2447
919
699
1623
389
2057
2746
731
1810
2225
2530
1353
1722
2118
1032
1858
733
2396
2894
26
1742
570
1295
2622
2927
1179
1382
437
985
514
1108
1881
2946
1731
1005
2327
3061
196
403
1051
2190
63
993
2990
76
417
182
1402
2897
1206
1788
77
1498
1448
1332
1753
1321
2436
2832
2566
2059
1913
1696
1970
1497
2889
1644
400
1
750
1724
484
1684
836
1039
467
1949
1198
1027
337
264
1903
2954
2725
2659
2416
2747
1322
502
2919
2443
2765
2573
1489
125
2435
1850
1215
2281
1161
1629
873
290
2188
936
1278
1470
443
2667
2017
651
3017
25
2803
2556
1225
1835
544
2066
2949
2800
920
2754
454
870
1966
968
708
850
2328
2655
1728
1009
1354
2418
2431
2753
188
2357
1411
336
1080
1109
1936
812
2555
511
2317
2098
1849
1707
1940
206
2113
1640
2713
2130
30
2226
2239
2164
43
503
2276
317
2710
2551
2928
585
2860
1319
2256
2067
3069
2702
1701
1636
1572
418
2849
3029
883
2036
841
1665
1273
382
2362
397
1709
2495
2203
854
2370
2315
621
223
1045
986
2153
233
1405
2502
536
169
822
1011
2234
2392
1021
2249
2539
356
1427
3062
720
1216
1174
2288
547
2432
1931
1836
507
2776
468
927
137
1143
2454
2870
21
2784
2600
240
1450
2009
33
2898
802
925
1205
1659
3036
2986
2140
230
1431
2285
1315
2268
1090
2633
1941
1812
2737
2840
2595
2627
2049
260
1188
2007
1268
1365
2296
673
2916
202
861
2511
674
1764
1233
3014
746
2569
1444
157
1349
2376
2944
2904
2535
2329
598
141
3012
2575
480
972
1485
1212
1410
357
1937
647
401
1422
32
2300
588
151
2039
2833
3022
2693
2537
2450
2079
1895
554
2207
477
1231
772
2272
85
725
2835
1781
1976
142
657
2344
306
2185
2572
1516
869
1673
1334
421
1785
684
1841
463
305
2326
1877
2174
381
2016
1608
2423
1487
1314
1492
2586
2762
1326
2661
625
851
2628
2165
963
2336
1407
1568
2304
311
136
1948
92
3004
2228
1214
2084
2209
1562
2523
2318
1302
2808
2751
2178
637
2911
2382
1845
1675
2428
1121
2787
2599
435
1128
324
714
2412
1943
1718
28
1583
2619
509
1330
2593
348
2983
810
3055
2343
1842
2394
51
1642
2070
1083
579
391
3001
2689
2491
1624
981
1166
1123
2557
355
2384
722
2338
988
721
2812
2907
398
1606
1054
2111
771
457
2995
==10744== 
==10744== HEAP SUMMARY:
==10744==     in use at exit: 209,112 bytes in 1,029 blocks
==10744==   total heap usage: 1,034 allocs, 5 frees, 250,252 bytes allocated
==10744== 
==10744== LEAK SUMMARY:
==10744==    definitely lost: 73,760 bytes in 3 blocks
==10744==    indirectly lost: 135,352 bytes in 1,026 blocks
==10744==      possibly lost: 0 bytes in 0 blocks
==10744==    still reachable: 0 bytes in 0 blocks
==10744==         suppressed: 0 bytes in 0 blocks
==10744== Rerun with --leak-check=full to see details of leaked memory
==10744== 
==10744== For counts of detected and suppressed errors, rerun with: -v
==10744== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 3071 -lt 1025
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_3071_1025
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1025 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3071 OUT_N=1025'
shuf-reservoir-sampling failed with IN_N=3071 OUT_N=1025
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 3071
+ INPUT_LINES=3071
+ OUTPUT_LINES=3071
+ seq 3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_3071_3071
==10752== Memcheck, a memory error detector
==10752== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10752== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10752== Command: shuf -n 3071 -o out_3071_3071
==10752== 
--10752-- WARNING: unhandled syscall: 326
--10752-- You may be able to write your own handler.
--10752-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10752-- Nevertheless we consider this a bug.  Please report
--10752-- it at http://valgrind.org/support/bug_reports.html.
331
3057
223
2723
100
139
1132
2471
966
2276
1193
1088
1455
2804
1365
102
1872
1420
352
2611
554
2964
2498
1989
1140
1043
2706
3024
2998
282
1931
2031
1812
2397
1310
556
2079
457
2643
1849
2316
1987
1548
2481
582
2116
399
377
1576
1666
3015
507
1829
1489
2246
1289
2282
1967
2943
1997
2630
884
1353
1717
2994
2531
1713
2032
2954
1716
342
2694
2962
918
777
304
1774
2166
1714
1549
1165
2416
1994
2593
1247
2562
2195
1541
1351
2346
1269
1643
2418
3009
1
391
2447
1721
1486
1291
1200
1223
1126
2558
1596
637
2660
602
239
476
1819
2802
551
2068
896
1547
844
2076
3048
726
2616
2914
2731
1808
1250
2004
2709
1089
2392
2730
23
806
2151
1311
2410
646
1590
1148
2160
1693
221
941
26
2625
2263
2169
1900
479
1724
1978
1687
2086
332
2831
2023
1686
130
91
1914
982
925
755
2521
1432
2949
853
1362
1898
1627
2570
814
3022
166
1722
74
2157
1961
724
3002
3042
1969
2258
1846
535
2538
2639
2969
2717
2150
1793
1152
2317
2264
1267
493
339
226
1128
1041
2844
1677
376
1346
2710
201
626
957
379
684
2330
2292
119
145
1635
1870
49
1881
419
1387
1457
947
656
1274
592
302
898
463
607
1105
2854
456
2861
768
1895
3025
1335
2041
208
1408
740
2965
709
2939
2938
2696
2501
2177
438
2298
610
61
654
38
2479
2453
484
1112
2123
2067
2141
2945
347
1557
2009
516
694
2533
1013
840
2090
383
1352
1618
883
461
1673
2019
1661
2917
429
448
1727
1861
2892
2149
1669
34
436
1562
2110
1409
1674
2765
2219
1975
1304
471
416
1205
1962
3066
698
2782
2261
2089
2341
2767
2753
1820
1506
851
1233
1024
1999
498
1168
2333
202
1571
1690
250
2396
1575
2295
2256
95
2583
2835
2458
1241
2488
512
1266
1498
2373
2286
2199
1728
2230
650
1092
746
797
2548
1018
2868
552
2301
1624
1319
1816
2812
2442
266
1014
882
1671
2474
932
1093
902
2634
230
2808
2404
662
2779
1141
1099
3005
32
2142
1582
1527
2664
514
1876
1173
2042
663
2398
2968
1956
2144
2137
967
1328
574
2451
935
3010
2923
1830
510
2018
2097
1069
505
1383
1952
1195
1081
262
1943
1791
1783
108
445
2741
126
2698
466
1211
1781
2637
1008
3036
716
1863
2030
540
1515
3033
2682
2133
2424
94
1838
52
1926
62
177
2795
1664
3053
136
1228
2522
45
1789
2742
688
403
1275
1047
1573
446
199
1297
231
991
833
1240
1414
1456
1985
1502
2870
195
855
981
2644
2322
2818
278
1216
986
398
2099
42
850
2055
1294
1163
1196
1940
529
2832
1801
2400
1285
810
1614
713
3004
1734
2999
2059
317
828
2296
2244
1309
2002
2176
359
2544
2629
228
128
943
2635
1825
697
2421
2550
430
1894
15
2155
2826
2247
2382
1125
3014
2668
2415
385
2657
912
950
976
2124
1523
2869
2919
426
2435
2152
500
270
613
2003
638
1520
2364
1796
2120
2218
2863
330
384
1244
84
1487
460
1507
936
2960
2528
1904
819
520
2740
1102
2756
2851
272
344
2805
437
1731
2278
375
2075
2007
1316
1685
534
1171
1574
1644
1949
2017
830
2736
2811
2037
931
1945
2505
2202
1651
629
1733
2513
2661
1460
1607
345
2186
1478
731
2573
664
1283
1602
1059
2287
2820
2559
2796
579
2927
642
611
1393
244
147
2145
2772
341
1116
1817
760
2127
916
1570
2628
268
894
3040
478
820
2114
453
1513
1603
2632
14
2337
2241
628
1150
1098
2577
2933
2699
779
1382
1151
2672
2025
303
2608
1042
2058
1697
2979
711
769
682
2508
37
267
33
2161
683
2033
1183
1587
1606
2622
2614
2101
2359
299
938
822
432
1404
2675
502
1306
2784
2896
942
2819
73
2092
919
2666
1120
2517
1363
417
676
993
2678
2502
634
1427
1373
900
322
1773
817
805
1257
411
2647
482
1494
249
424
1935
1376
1991
1896
1078
1663
454
433
775
85
2532
2578
115
1097
1113
3071
273
2963
132
2618
899
165
1004
2275
217
1869
738
2463
2213
2770
434
863
2880
1891
1958
1918
2016
6
3027
3039
2459
1739
53
1094
1954
30
603
2829
2627
1398
870
928
2369
2262
1430
2503
2986
2395
921
155
751
1254
2375
674
1691
407
2321
129
1941
1001
2609
1153
1290
2827
1834
1788
729
1337
1953
2748
997
2966
1755
1982
402
1197
787
1109
485
1087
1084
2485
2640
1083
2084
1156
2830
974
1512
357
2399
2746
2064
1778
710
728
2000
519
2184
2111
1841
704
2430
2411
2006
1056
1946
1063
3023
284
905
2484
179
586
669
1463
1483
93
3031
1154
1179
2934
1327
2834
2469
2582
2597
88
245
1437
2592
730
1307
2546
29
872
1322
1831
349
869
2990
799
2245
1966
1178
2353
1738
2838
2131
1732
617
3060
793
961
104
2734
1726
1905
816
2809
1657
739
1210
1988
972
2953
387
1296
866
2600
1242
2793
427
1251
1031
1782
771
1445
2993
2516
491
948
645
2687
2462
1654
515
1177
2207
2887
2388
1046
1399
636
169
1680
1951
1331
723
109
1641
2121
1761
2439
952
1874
2083
1743
2801
1667
3063
1169
1911
812
706
1459
1804
3041
1219
1326
2977
356
2029
90
984
2799
807
258
1354
865
276
719
1634
2327
238
2294
1564
1586
1981
1704
1020
708
2107
1405
2738
2568
1803
2565
1612
146
2136
2402
2267
1533
1381
1258
951
1029
2426
175
1096
1854
1915
3001
468
1775
1678
47
686
831
472
2510
280
2497
2879
1435
259
2604
2889
1873
2492
2297
1560
2951
1681
1960
89
541
1683
2813
1349
2299
1524
1325
1005
759
2103
225
1921
1647
2605
277
2956
2908
1462
210
171
824
1792
1453
536
1689
1136
681
2651
2761
2021
1850
1753
2339
2378
1034
2567
1835
181
2095
1400
2040
388
2872
1845
1389
621
2034
1529
2541
1555
1868
1578
1826
293
2910
2684
1847
2773
1360
2182
1374
1313
2290
395
2855
2496
2581
2467
490
2113
1103
1534
396
348
1660
754
1748
2349
1785
1458
1067
792
2967
923
1759
2972
1287
2890
2406
1862
1546
1249
2902
118
700
2942
2760
567
2413
1371
1375
1497
939
314
2265
845
596
499
2514
2641
173
1425
2427
2260
172
778
1600
1334
2407
365
264
3007
2289
962
3043
2106
1300
907
955
1495
218
1217
727
2119
1384
1797
232
2561
1394
10
459
2104
2995
2066
340
1522
2432
1429
2309
2024
1950
50
2526
1265
408
2735
934
3026
1248
1611
2357
2680
2403
2274
1938
733
826
319
2446
2589
2325
362
1370
1442
2560
121
203
378
605
1329
1676
1665
2743
116
1011
2212
2074
1577
2542
2745
2183
675
2690
2617
1601
2530
2913
2771
197
1771
1806
2056
745
2250
2958
2096
1467
1277
2673
2300
1903
1833
380
1750
757
206
3055
449
2685
2302
1355
2135
782
821
192
1175
1814
1174
2014
1023
157
1648
1101
2026
1166
2928
2983
555
803
2130
1108
2893
1021
1503
1229
2476
2118
9
1377
1220
1554
68
1336
2374
2875
2909
1617
989
975
59
827
1212
475
615
1917
2360
13
897
2649
537
2126
1933
2386
1333
1543
2716
1440
2518
1434
988
1996
39
3067
1884
1658
2750
1471
744
2901
3003
911
358
2340
1299
2601
1802
633
1433
1080
2555
1129
346
57
1070
776
343
1890
3038
1633
1551
600
630
3035
1779
2623
2425
889
2445
1314
8
1919
2062
1187
1800
103
1892
2491
2926
141
1033
1007
1581
570
2707
296
2946
964
612
2147
2918
1907
2947
1438
205
3008
1139
1237
2198
622
593
588
2843
2904
2165
414
1057
1209
560
2586
135
168
412
2270
1230
1662
1207
2602
587
1824
1684
2285
1263
1572
800
1167
2237
142
27
2566
2393
1718
707
335
1342
2461
400
2180
2833
1569
1805
382
2071
608
2117
1133
1356
1813
2005
1901
2073
998
2367
2810
1636
2839
734
2715
780
953
2487
2046
292
689
2093
2840
1864
2615
422
1447
2443
144
3068
2225
2320
1190
2050
2323
1857
1155
2280
985
2744
764
2486
1022
1115
2975
767
687
929
291
791
2825
1855
1672
2109
3028
216
1877
1719
2876
1091
901
2853
1770
1264
176
1143
2992
1256
474
229
895
651
1466
1925
2922
2394
2656
253
242
531
1016
2959
521
620
196
2537
1936
2335
211
3011
2658
1730
2718
87
1639
2072
2781
1236
1632
1213
2659
1234
1048
914
1899
1253
559
2543
547
2436
960
1396
392
1027
2704
922
2737
187
1137
274
2329
316
2057
2695
1656
1984
2557
2757
1902
188
2311
3020
2493
1243
2423
1886
2940
1566
2915
1537
2515
667
518
3019
1320
623
3016
1920
1395
2679
1226
1821
435
1117
2428
1787
888
1500
678
2249
2038
106
2648
2613
1599
2266
2764
1158
150
2787
3049
3061
390
2228
670
65
1122
2204
892
1986
2115
2457
992
318
2200
35
56
64
854
2798
423
841
2158
1135
1723
2010
881
1288
2043
1594
1051
1707
581
1379
2794
2814
2248
2535
721
1715
2456
1852
2112
2697
2070
1944
1832
2720
1556
138
1474
1976
1765
959
848
2763
2596
2049
66
590
1980
2665
2293
2569
1610
2534
2997
1871
1568
920
2719
2226
2899
3047
1709
2209
546
1518
2191
597
1741
1074
2179
2941
2336
796
2681
368
860
616
2273
1955
1172
1452
1930
3064
696
1613
350
2701
837
1948
2642
2728
1990
2087
699
1312
1343
2366
11
1235
1231
1386
1696
254
2654
1450
324
542
178
1972
2727
174
309
2725
462
1036
1712
2769
2448
2468
756
2188
1330
2125
5
1449
904
2211
1828
2708
2015
2310
1827
2950
2464
2437
2579
849
1519
2193
2881
789
543
2815
1867
442
1280
1218
1746
1878
2338
625
748
958
76
2610
2856
1630
1339
260
956
1298
152
1276
2645
1579
1626
788
72
2987
594
1735
44
1281
287
2389
2372
2156
2279
1769
2850
999
2669
2243
856
235
2128
151
1552
2478
2414
1768
1875
878
1688
2236
410
295
813
1378
1492
122
795
1906
1865
874
1963
51
241
2232
184
2379
619
1887
3050
1883
671
79
2272
1754
1934
481
528
92
2726
2607
1431
2210
1000
215
290
60
1840
397
3062
1095
389
2984
2500
1411
2921
112
758
386
1426
363
413
565
1118
1615
1740
2598
677
336
1390
2044
1123
77
2553
2027
770
1659
2551
2768
2882
283
2556
12
2140
2841
886
160
1749
990
2239
750
71
2132
712
1815
1032
1836
2688
2906
1345
86
2470
2419
647
2440
40
2980
945
2564
1350
632
1772
2088
2525
2894
16
1206
1367
1071
1756
2288
2181
1880
1111
2877
1303
207
1295
1508
598
2511
2143
256
2454
2509
1916
1790
351
2590
2355
763
159
2930
2148
1006
835
2671
2786
861
1584
2455
2051
1510
2714
1888
2102
406
818
1476
691
2175
2683
2251
566
1419
2591
1655
2807
1100
1927
2871
2846
2465
2961
1604
469
24
1751
640
28
1777
2483
1843
2168
2384
237
1588
450
2420
1279
1701
1392
1385
234
1580
1631
255
1595
1668
614
2361
182
360
1064
1536
1199
1675
1851
2495
2797
781
2172
601
1889
1270
1929
21
1086
2094
99
2828
19
1214
354
1157
1539
458
279
1496
2383
149
798
367
2377
2936
994
1261
1060
2052
20
1558
2703
980
1646
405
2621
1744
2154
180
885
595
890
585
880
2163
428
2803
470
1747
1725
501
2214
1144
1224
1882
1705
2035
1443
1308
497
1184
306
1488
1974
2739
1271
220
599
305
1619
2898
1192
2480
2362
875
2705
635
2778
488
1514
1066
2271
1076
1451
2358
949
1505
2571
2762
1702
2507
477
163
2903
2862
1609
1413
1348
2022
643
752
2345
1711
2077
741
2506
825
1703
906
2178
2224
1767
1162
1259
1795
2512
522
857
511
2233
2466
693
219
1422
2343
1401
1321
703
1811
747
3059
1252
743
1324
492
2108
111
843
1859
1682
1305
2692
1038
2888
2308
558
81
2817
2422
2662
657
261
2791
2489
666
1082
1052
1050
2976
1621
2342
1589
1642
1858
832
2866
269
120
2048
2849
2356
2381
2475
2352
2452
1397
153
2315
2449
1278
2574
1970
1189
1823
1992
887
2624
2238
2867
1937
2944
333
1344
2444
455
2700
589
550
194
549
2937
134
695
859
2935
969
1138
530
2724
1035
2153
1015
214
2405
137
862
1995
1638
1317
251
717
2711
661
2061
2223
3056
315
1957
1942
373
2139
1807
839
968
1965
2674
2477
2713
401
2307
243
3006
2547
143
2580
908
2587
766
2319
2190
1061
4
2482
31
532
524
1794
1477
1977
1003
648
3070
627
125
749
876
2970
2194
2391
161
2925
2082
1959
2552
2331
1640
1893
353
1698
563
1361
2924
983
2886
2371
2438
2584
1842
1737
2932
1412
3046
1301
2790
591
2146
307
1468
2197
963
2305
786
1736
2304
1292
425
1017
329
701
1479
2234
940
1444
338
1194
2122
1058
48
1542
3012
55
2920
1176
1282
2060
864
2667
2702
2081
2973
1416
83
2931
2883
2752
364
2729
1485
2847
1012
1073
1637
545
658
503
1424
2857
631
2434
1075
783
334
2085
553
2585
2721
371
289
2650
2677
979
2196
2594
2433
275
2164
2749
2385
577
200
1745
2722
2595
2105
404
1608
2171
2712
1516
1499
1417
834
2217
1757
2747
2971
2008
1561
2988
573
973
692
1160
1202
1227
2865
164
2603
3021
18
418
1866
170
2252
1107
311
2365
2078
2253
308
467
909
809
2907
1809
415
394
2284
659
3034
879
1039
409
1567
1090
2916
1544
2549
1232
761
2991
294
301
933
1885
2957
1545
1030
1752
297
1124
2895
924
2572
2900
2221
285
1221
1798
41
673
2638
1764
1180
561
668
1848
2036
679
2344
2774
2328
2054
2982
156
877
2655
325
2860
639
1694
970
672
815
2626
2192
7
2693
131
1591
2387
2216
2063
1428
1710
1912
2259
1268
1246
222
2324
2732
2069
562
2974
2100
2599
584
604
2759
2170
829
3018
1402
2539
1465
946
1415
483
133
1758
113
1368
2174
1784
2777
97
2981
1284
1341
753
2823
977
3065
660
1653
690
1592
2775
374
2800
655
140
2098
2758
2952
1145
443
328
506
3
2240
2663
1106
326
785
722
1491
2858
2473
1448
1009
1818
2268
1924
2380
441
2885
1201
2012
2816
2441
2631
2189
312
1650
1358
2028
2563
1161
715
538
1629
1766
1559
1482
2134
836
927
2334
494
1620
1763
337
2201
224
75
63
583
1501
1531
2676
1968
762
1853
1134
263
665
288
2220
871
204
3045
82
2368
903
465
78
2281
1131
965
236
1679
2254
1860
2652
58
369
1407
286
496
2789
2874
2989
1464
381
1708
718
2733
2864
1198
1964
2001
1598
265
2318
252
2283
1369
891
2348
247
2494
2905
1318
320
1922
3000
1188
2303
1260
1204
1338
1856
98
1605
802
2911
2450
1472
1208
1403
1110
523
578
257
1692
2792
1521
2891
2978
1583
2350
987
736
473
124
70
732
1493
2242
17
158
1315
2588
2575
1147
1222
811
1699
1649
1065
43
2836
525
3069
624
784
198
2490
2837
123
2409
1142
1540
1652
1623
452
327
1979
680
867
2376
1149
2039
937
1104
209
1645
2873
1454
3051
355
569
1517
2859
2173
189
644
2545
1481
1055
1286
1971
652
1550
618
1475
1897
2878
1923
572
1446
1585
838
2401
575
2929
893
641
420
2185
548
1364
183
1410
2536
801
2231
571
557
80
2255
2686
1191
1203
2235
2354
2766
2417
1164
504
847
1947
1973
190
2162
127
1616
1040
1130
954
1928
1563
1181
1469
576
2045
2751
2912
1025
1810
1255
361
2783
2408
2053
2314
2091
2554
486
2306
702
606
439
1146
1983
978
720
67
580
2080
1597
1366
1799
246
735
46
2788
2326
913
464
1695
22
1053
1700
539
2842
2776
2821
737
323
2431
2332
2472
310
495
1670
1535
2955
370
2277
2754
995
3029
765
2884
1332
3017
774
2806
3058
1484
513
773
1625
1037
101
1525
790
705
1002
54
2351
1622
1347
1509
154
772
1473
444
1044
2013
1762
2499
1910
1418
944
2620
213
1461
185
804
2227
1245
2257
930
2429
480
2633
868
2011
1372
2780
300
2996
96
526
1553
2412
1406
2653
2187
2948
808
186
2897
2363
910
110
2845
2291
117
321
2504
227
451
2269
1182
1340
1239
366
2460
1026
533
1939
1532
298
2390
3054
2313
1844
167
1530
1526
2
1480
2529
431
1045
1302
271
1436
742
1528
2215
3052
714
1159
1072
2612
1470
915
1538
1993
487
25
858
926
971
2167
2159
2312
2689
1720
440
1742
2222
1729
544
1909
148
1998
3044
1388
36
233
2370
917
2129
852
1913
517
2606
2755
2208
1049
2523
447
508
2524
1215
725
996
1186
421
1028
846
1170
1421
162
2852
2619
1511
842
1293
1706
313
3037
1490
1114
2822
1380
794
193
2576
1776
873
1010
1262
1357
240
1077
107
1837
1441
1391
1786
1504
69
1423
2520
114
509
1822
2636
649
2519
393
2691
2206
2138
1185
3030
1062
1839
2065
1127
1439
527
2347
1593
1085
2047
1628
1932
105
489
191
1565
1019
2229
1359
1272
2527
2824
568
3032
609
2670
1068
1908
3013
1121
823
2540
685
1119
1054
372
1760
1780
1879
564
2203
1323
212
653
2785
2848
2985
281
248
1079
1273
1225
2205
2646
2020
1238
==10752== 
==10752== HEAP SUMMARY:
==10752==     in use at exit: 520,136 bytes in 3,075 blocks
==10752==   total heap usage: 3,080 allocs, 5 frees, 643,052 bytes allocated
==10752== 
==10752== LEAK SUMMARY:
==10752==    definitely lost: 122,896 bytes in 3 blocks
==10752==    indirectly lost: 397,240 bytes in 3,072 blocks
==10752==      possibly lost: 0 bytes in 0 blocks
==10752==    still reachable: 0 bytes in 0 blocks
==10752==         suppressed: 0 bytes in 0 blocks
==10752== Rerun with --leak-check=full to see details of leaked memory
==10752== 
==10752== For counts of detected and suppressed errors, rerun with: -v
==10752== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 3071 -lt 3071
++ grep '^[0-9][0-9]*$' out_3071_3071
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3071 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3071 OUT_N=3071'
shuf-reservoir-sampling failed with IN_N=3071 OUT_N=3071
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 3072
+ INPUT_LINES=3071
+ OUTPUT_LINES=3072
+ seq 3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_3071_3072
==10786== Memcheck, a memory error detector
==10786== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10786== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10786== Command: shuf -n 3072 -o out_3071_3072
==10786== 
--10786-- WARNING: unhandled syscall: 326
--10786-- You may be able to write your own handler.
--10786-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10786-- Nevertheless we consider this a bug.  Please report
--10786-- it at http://valgrind.org/support/bug_reports.html.
1346
425
248
1722
1182
3030
574
305
1594
1755
2213
1697
176
1310
2175
2469
281
1675
263
142
2676
2252
36
2500
2931
2774
890
2897
2516
3002
1958
287
2069
2343
1765
2823
1455
399
2205
2264
737
783
2786
1175
2941
1298
408
2050
2137
901
2449
480
472
714
1627
1335
2696
1257
863
310
1111
498
2167
3019
2914
2192
509
817
1305
2600
157
2788
2342
2138
1975
2229
3054
934
2916
1957
845
430
1841
2961
3040
628
1936
995
2411
1009
875
1411
1990
63
922
558
1254
548
791
2305
1686
1802
2481
1527
1724
380
861
2487
2977
657
1283
2757
1079
1582
1764
2385
2083
1439
3028
2807
378
2202
131
71
622
1180
811
2126
536
3048
1774
1363
2041
1130
1702
2090
1092
1488
2607
1867
1804
2952
831
1613
1331
2231
1847
1798
981
2935
2338
2747
2621
955
1785
3033
2300
2226
298
1883
1029
2153
475
1688
1904
2105
1967
1247
104
2207
818
1260
1899
12
1083
1864
1418
788
2284
2243
1474
610
2425
1483
857
2360
2702
2224
1970
2409
2043
273
1993
1736
910
1033
2084
1020
1961
223
2754
1578
265
518
1541
2618
2272
1231
2054
763
2098
2419
3044
217
2276
1631
2074
1670
1550
2114
2023
2890
795
85
84
2400
2517
2963
2581
779
1526
1659
1768
1968
147
1263
478
647
1012
562
1815
1369
1509
1910
1908
377
1082
991
1193
2708
1595
1663
457
487
2341
658
145
2191
2417
871
712
1508
2448
3046
1677
1078
1023
2112
1144
390
1485
1913
1307
313
1059
2915
1835
2289
1038
2508
134
1781
2278
144
2907
1043
2075
616
34
828
32
505
1838
75
2154
920
681
406
905
1017
250
2947
2438
2524
40
95
2000
2203
2086
621
2590
2862
711
2080
2066
454
137
2973
2863
2628
2355
344
1419
511
2979
1666
2163
2322
1525
1377
2557
1164
241
2107
2794
2567
387
1637
3023
1328
3032
3050
183
2333
2416
1674
2447
2956
718
211
1706
2713
2182
1830
2560
2848
1343
1922
2805
2970
2775
1056
304
1694
605
2572
3052
347
2381
516
1852
2429
427
2016
2039
1459
2647
1545
229
1734
1077
2366
999
2981
720
2406
1190
2750
2575
401
1796
2142
1630
1139
389
2857
246
214
1843
701
2544
2478
2222
168
2021
2072
1211
2959
2474
340
2422
1999
529
969
565
370
2444
2168
1138
1158
1811
3013
2434
2470
1516
1282
1745
2906
447
1979
2686
2435
1682
2948
653
92
1803
2186
1625
180
294
2025
2522
2117
1153
2921
576
719
1944
539
786
1316
332
2017
2058
1179
2609
264
1903
2351
2085
1859
953
2701
2488
2394
1943
1345
1519
2733
1397
1405
423
1750
1438
2804
2045
43
1806
675
2046
698
182
2345
446
2753
123
1387
776
2108
2210
456
2721
238
858
1937
987
3020
1208
1882
2007
2671
270
768
1955
1213
14
2776
1454
1753
1232
2978
1380
251
413
1797
527
2888
245
2539
172
1916
2423
2535
1117
2028
815
996
1779
542
2563
1628
2324
1361
2156
2646
396
97
1423
2408
1109
1952
551
2397
2386
2645
432
1467
697
2032
1497
619
1928
1400
895
9
450
1580
1596
1911
1308
825
2201
2215
1995
1048
1256
407
2396
2999
645
31
2766
634
1149
741
947
189
3042
1287
386
473
1174
2336
1352
283
2949
2304
1623
2627
54
2570
1046
232
404
2657
1655
2220
648
1548
2873
64
1110
262
979
1976
2673
885
2530
2752
1441
2578
897
2768
2651
1661
1965
2908
1619
1562
2319
2593
702
1275
317
316
2614
114
2323
3004
2346
1099
1146
1592
1234
2492
1749
977
1933
2870
2060
1669
2699
2241
1162
3029
2594
1680
951
1872
2367
2180
2865
2059
1707
3041
1074
2147
2477
1487
855
2273
3064
2008
676
1145
1168
2736
226
321
731
1195
3036
3060
1001
1752
2654
514
2149
2801
2317
1571
1366
1856
2620
460
1805
1399
1620
2636
930
1848
1598
1444
2606
1057
935
2692
2927
1921
1653
2314
738
2120
215
3024
2501
2782
2734
2605
132
578
2616
2722
1173
1093
2623
2837
2936
2787
2329
1962
2298
452
1301
1215
573
3056
1564
2718
2490
1157
1090
703
1333
2152
1465
1295
1590
769
1135
2790
372
2922
2092
2113
909
3015
2471
864
2177
247
2473
801
2495
2020
274
829
626
2024
612
1259
1506
255
1049
2468
1229
603
2362
440
492
1427
2283
2262
799
2855
2540
2049
349
2624
463
1154
1013
933
2253
1959
1792
2957
952
1606
2515
1503
119
213
2950
1728
691
1973
82
717
1248
2281
1807
1528
1951
2005
2071
15
1885
2155
2198
1834
821
1337
2700
227
2141
109
384
1494
51
2432
2443
1757
957
1813
395
1640
1068
2426
2592
931
1120
1466
2602
1826
1974
1896
2831
1302
485
224
2172
1473
837
759
2328
146
286
1579
1122
1040
2814
1567
1194
925
1983
678
453
2529
1850
2843
2995
2377
490
1353
2309
2364
2667
892
2856
2871
1914
3059
1684
1395
798
164
2761
411
194
1027
1277
2100
1500
61
850
2840
2548
1498
2836
443
1915
2626
67
879
2937
1618
1701
2929
531
2655
2764
1201
2119
1715
1375
1478
866
2810
2985
1998
1809
2561
2613
1412
740
503
44
100
1086
78
150
2629
1909
2402
1072
1121
296
2271
1518
421
2672
2034
1358
57
1433
1511
927
1690
2374
2514
747
1719
291
639
358
2151
1828
2265
1126
2302
898
2886
683
1054
178
1565
841
2412
2004
729
1800
1514
2230
1931
2217
2297
2911
1535
108
2466
819
126
1453
2505
1206
2106
3066
2586
1360
1359
1650
1284
169
1784
186
2770
1546
2920
373
2525
1989
641
400
1421
2853
724
2288
1524
1051
1729
429
361
2670
2633
1185
1351
26
2293
2933
68
838
354
2176
1744
2584
744
962
1992
1081
2924
2150
293
2519
2483
1507
1036
921
2809
2310
3065
2354
2576
874
2765
546
2711
2880
2196
1886
1754
2827
2211
642
152
106
235
297
2811
171
802
2679
307
3058
1087
1740
1293
1513
2580
2353
1417
1608
244
633
225
1492
381
149
2178
1664
1737
635
199
125
1435
218
2712
1880
2556
2833
2344
2077
748
664
746
2784
606
803
2943
1871
2596
519
2571
2749
2070
1447
2164
1839
2649
2932
992
253
1772
202
1570
1203
2068
2461
1656
179
2095
2275
1245
1394
958
1695
1945
2347
942
49
774
2161
148
853
781
948
1006
1137
1230
590
2619
1531
725
2102
1047
757
535
735
271
1602
2088
2133
2847
438
2730
2173
2795
2019
2451
2361
2480
2044
2875
2748
2845
980
1446
1413
1484
1332
2683
1291
1207
2410
2919
484
1818
2240
239
919
2250
1708
2446
570
1184
2565
312
1667
694
1266
2944
2465
2339
3034
667
2617
2717
1037
1062
766
1362
2751
2816
743
2209
1759
1763
672
2242
2282
2013
1766
2591
690
2093
200
2510
156
767
2047
99
1676
1907
2740
6
1319
449
1906
2716
2053
753
926
1088
2705
1237
961
881
1971
1980
1342
609
1893
300
2368
2266
1309
2479
2940
2011
868
2489
1610
1568
2842
534
1981
1063
185
2518
1714
2189
2892
869
601
1926
2287
847
568
1032
88
2502
208
2143
1098
496
2441
181
2078
1311
1058
1240
1381
2421
1253
1486
1668
1816
2988
466
1986
1898
2735
1222
115
1607
1747
1476
437
1812
1176
1320
537
130
2125
2218
1510
2030
2698
2442
2777
2684
459
52
1004
974
341
630
846
521
101
1865
2819
2714
2898
2307
2656
2356
1039
141
1448
1574
862
167
1964
184
2962
651
2096
1445
2552
488
914
1437
1888
1272
2511
2269
359
614
2414
1183
1559
2118
319
2638
1227
2115
1873
597
989
257
70
3037
1902
1246
524
631
1651
915
1939
369
1210
367
794
1938
471
1801
3
1558
2494
1323
777
2193
684
1892
1575
1626
2531
1727
1357
1348
1327
3012
517
2879
1776
455
3051
1292
2806
2632
2709
2076
1306
1199
1475
2256
335
2200
2756
1870
1495
81
689
1658
62
278
2232
140
1101
976
90
1614
2583
1645
764
2727
254
545
2358
902
1612
1717
2370
87
2938
1956
2246
2383
700
249
1638
1402
2388
2357
571
2854
1644
978
1233
997
1204
1994
2547
1025
3039
1634
632
1534
280
1219
2553
362
2376
510
1874
2542
1250
2731
420
112
2737
66
607
1529
3016
2851
1932
1894
1673
1470
206
1732
2334
1239
1267
2644
2889
2825
350
289
2124
1080
1504
1647
1549
2664
515
1743
1141
1875
1312
896
2904
1449
1334
2325
2913
86
2675
267
2789
1988
2954
1280
2249
105
174
2352
2315
1324
2280
1793
2063
2558
533
2129
1
205
1420
2695
666
2537
1452
2373
1920
2706
820
431
1761
972
2234
2579
1542
1108
2677
1948
2091
2830
1551
435
1104
816
2111
654
2604
192
2974
328
2703
292
581
2550
2549
2018
129
2759
1646
1271
499
2762
1354
589
203
1477
353
2728
1692
990
1045
277
1587
424
2903
1469
93
2828
842
560
351
830
1243
2308
2116
1597
1150
2982
593
2452
1273
1116
1350
325
154
163
985
2332
2277
1114
2239
412
7
2350
295
1258
1007
322
2918
1643
1329
1463
2087
1321
827
2681
1705
1060
889
699
1683
1406
276
2450
1123
1322
3031
2390
716
2534
2185
1425
1819
1235
2279
1837
290
2401
29
1428
2311
1878
2993
465
2026
2745
1076
679
2348
1489
1553
2359
1103
1862
2885
2248
117
602
1197
1268
2509
2874
1773
1925
327
780
2327
1404
501
2923
1071
1125
24
2901
116
1822
37
2427
2928
1304
840
1365
1134
1560
433
1621
595
2237
1392
1601
77
600
2482
547
2015
1639
495
2568
275
1064
2905
787
1315
1615
1443
4
16
166
832
1770
2688
2048
554
564
899
451
2597
1151
575
135
592
1106
1704
197
1084
949
1887
2630
397
331
2912
582
1450
1522
1593
1891
617
393
656
2002
1735
552
1370
1281
900
2040
1665
50
2439
1738
2815
993
2195
2939
1384
2791
1836
1997
2658
1739
844
1300
2725
734
1373
1842
670
306
710
1041
944
2642
323
1741
3011
2520
1403
2079
941
155
41
856
1629
2064
1849
2378
1451
643
1289
2418
1855
1181
2094
2267
2896
1471
48
458
2504
161
497
904
726
1984
470
960
1767
3063
2994
1339
366
365
2991
2274
584
419
2723
932
1100
269
486
1556
2967
1285
2850
3006
797
143
2144
2148
391
2545
2643
1075
2491
543
2513
1756
1591
615
2883
502
2081
118
686
3035
770
1414
2793
2507
2135
854
2763
1563
28
2955
17
2772
1969
823
2802
2437
2966
285
1600
483
2382
476
337
604
2882
338
1624
1364
1094
1408
2834
2528
21
784
2398
2157
762
1115
1155
2365
355
673
1742
1851
2440
2715
1844
1061
906
2472
2523
491
2964
771
79
165
2055
173
807
160
1953
1712
1713
778
2971
880
2223
1030
2813
1652
1166
2822
188
2778
2170
2844
596
1490
445
804
1220
1941
2611
2536
2286
392
2146
1681
1118
1589
1532
782
525
2562
3003
207
3038
1163
849
2428
2983
1019
754
1221
1869
1294
839
1169
1821
1780
315
2650
507
256
877
1746
2295
2255
394
2238
308
2006
2595
46
2980
1191
2497
954
1336
1442
1276
261
1662
1731
912
1262
2331
1224
417
1132
1860
2321
585
1133
444
580
288
591
3008
33
2188
2691
730
2798
20
1520
2263
652
870
1073
195
311
739
559
2666
1679
18
1066
409
2082
2783
2380
2258
2052
936
2496
1436
2031
121
1996
1457
198
2601
1338
2212
773
1430
760
2486
3000
260
2803
1672
2506
1982
1543
266
96
732
314
2951
2009
1963
59
2622
1241
572
567
1278
83
2615
1432
2261
1900
625
1960
138
2389
796
299
887
937
1733
2538
1214
1482
706
2839
73
2313
2687
2758
965
1863
2894
2872
3014
1290
2121
162
2551
945
2436
2849
2719
916
727
494
2337
1573
561
151
2527
1269
2887
1641
2363
2216
1458
2780
1462
2574
334
1131
1129
385
1096
1265
1067
1795
2668
1089
713
959
1216
103
2290
3017
1055
2852
3027
2099
2259
1642
13
2022
2165
876
439
677
2485
220
1218
2972
668
352
2303
2187
884
1950
2221
878
988
1794
2930
1424
1923
1196
671
2808
3005
2640
1177
376
2895
1493
201
2208
1536
177
594
1977
414
1810
1015
2379
3010
1172
1249
1583
1501
1723
2893
2197
577
1700
222
2942
943
1633
685
2335
772
1917
2946
2194
3071
1924
2104
2467
2533
1368
1028
2665
1318
755
1530
2158
1654
228
309
809
1817
588
1636
2268
1431
1940
2181
2067
1929
2876
756
1317
1905
2299
2206
1499
360
2042
2953
371
984
2869
252
1751
2608
1026
324
939
2399
2131
705
998
422
1389
2
1251
2498
1935
2462
2746
704
1942
1288
2349
860
1912
2779
968
2110
1696
418
1035
240
1112
891
929
2564
1566
824
2433
1255
204
1678
742
2244
1884
5
1022
556
1561
2858
462
2824
196
2061
873
2065
1407
1460
624
692
468
474
2744
3061
504
356
513
1434
586
1762
2838
1142
348
120
620
1890
790
3057
1165
1919
2431
3047
660
2589
2976
723
1161
1523
3009
482
2493
1699
2247
1198
2010
665
1533
410
649
1374
608
918
808
2174
541
1388
708
22
2861
428
402
2521
1540
469
882
1748
1791
1840
30
2035
1156
973
2864
461
477
2726
1422
2635
1502
553
2960
1861
2884
212
1876
1845
2648
1299
2598
680
1635
2405
2306
1160
1709
721
94
2214
923
279
1585
1648
89
2457
2634
2878
637
2555
924
1691
745
1097
522
1716
715
1897
2159
231
1105
69
851
374
1790
187
611
2792
1024
2781
242
1379
2755
1274
1947
623
2720
1581
813
2588
1326
986
2707
2660
2101
326
2997
1209
1611
2693
2821
128
911
2371
1102
2097
1703
1657
1689
1866
696
946
2122
2392
2554
2003
500
834
1189
2767
655
2499
532
695
2404
23
2817
1429
2204
970
2455
11
2532
1833
1050
27
127
2190
1603
1171
1461
230
122
3068
618
722
793
2566
1946
1391
1170
1113
2179
1069
1480
2171
917
2984
1426
2785
2236
2771
1832
53
1297
822
2460
661
2663
569
2987
1095
1148
1769
736
272
693
523
2251
243
669
1517
687
1808
1010
1136
1930
1985
1409
1167
2340
833
709
800
2587
640
113
1617
1569
1143
301
1052
1225
563
1949
750
210
1576
663
434
382
1376
1344
964
2235
1390
752
1393
508
2051
1325
2245
644
867
2835
2375
1966
526
1858
3067
2769
2559
336
792
2225
540
2610
1588
2162
1228
1192
2697
883
1242
956
1200
751
2859
1187
2909
1978
1188
2881
268
512
2464
2820
1018
1760
1577
39
1538
2459
2742
3001
682
2062
2128
357
966
662
1031
1889
1846
544
1238
236
216
1537
259
2998
2685
2639
1472
1552
1820
1829
638
835
2773
613
1356
1014
10
2841
2407
1814
2917
2832
3018
2900
812
1954
415
761
2014
2652
2415
2456
72
975
2166
1396
1217
1927
1410
1016
557
3070
2033
928
2902
2036
1934
728
2089
1464
1521
383
940
65
190
963
1401
2926
2704
2760
2860
2160
2866
1491
1372
58
1895
139
379
1693
2109
2145
320
3045
1178
1261
886
1415
1202
343
1825
2958
388
2732
2710
2826
2678
2625
1991
2257
888
221
2659
1021
1789
971
1011
1124
2301
549
2512
258
2403
1152
1005
153
1782
489
2569
1002
1244
646
493
950
1726
2330
2503
2599
1279
80
1718
1270
2637
627
2653
520
35
2027
2320
1479
2631
1085
98
467
528
1584
110
1053
1481
2582
448
1223
1382
2797
2925
159
191
1456
219
3025
1186
1505
60
2800
2965
2910
136
2260
1303
579
2057
318
1586
2689
3062
1371
599
983
363
1252
805
872
1003
1330
2458
1671
441
1544
339
3069
3007
2603
234
674
814
1725
2682
2384
2056
2662
1042
1649
3049
416
2729
1698
1008
2199
2454
1788
852
2846
133
1616
1783
1632
2680
2183
233
2430
2818
836
2741
2669
1205
2140
91
479
1854
789
2484
2103
1236
170
2029
810
1128
1091
1554
1367
2184
2641
1824
1660
506
2369
102
2169
209
1987
1685
2073
2577
2476
1349
913
2526
56
530
302
1385
1877
1778
826
2724
1605
2139
1034
1831
1468
330
659
2975
1286
749
1720
1159
2420
2739
1868
1065
2372
1440
2012
3026
1557
2233
1721
346
74
1340
2294
1730
2424
785
1555
1347
1515
436
1853
1000
1119
1416
333
2990
364
2393
629
2799
894
426
1901
2738
2546
1512
1572
2134
1147
329
650
636
2992
2227
2868
1314
2475
303
3022
907
3021
1355
1496
2285
1609
2127
2899
555
938
2934
2292
843
903
2541
2986
848
2038
284
1264
405
2130
583
1972
1787
2453
908
2812
550
1823
967
566
2969
1758
8
2463
2612
2326
2829
76
375
1386
3053
1212
2228
1879
1777
47
1622
1918
2891
2877
1881
775
2543
1070
1857
1226
2318
1827
2316
1599
1687
2254
538
2136
2996
1107
994
2674
25
2989
1799
1341
733
398
1296
111
1313
2219
859
1710
765
707
42
2391
893
282
2413
2312
1044
2387
1539
2291
193
1775
2945
2690
175
3055
345
1604
107
2585
1547
758
982
2395
124
481
1127
237
2573
688
1711
342
2968
45
1383
2037
1398
403
464
55
2001
2296
2694
806
3043
442
368
2270
587
19
1378
2661
598
2796
1140
158
2445
1786
2867
865
2743
2123
1771
38
2132
==10786== 
==10786== HEAP SUMMARY:
==10786==     in use at exit: 520,136 bytes in 3,075 blocks
==10786==   total heap usage: 3,080 allocs, 5 frees, 643,052 bytes allocated
==10786== 
==10786== LEAK SUMMARY:
==10786==    definitely lost: 122,896 bytes in 3 blocks
==10786==    indirectly lost: 397,240 bytes in 3,072 blocks
==10786==      possibly lost: 0 bytes in 0 blocks
==10786==    still reachable: 0 bytes in 0 blocks
==10786==         suppressed: 0 bytes in 0 blocks
==10786== Rerun with --leak-check=full to see details of leaked memory
==10786== 
==10786== For counts of detected and suppressed errors, rerun with: -v
==10786== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 3071 -lt 3072
+ EXPECTED_LINES=3071
++ sort -un
++ grep '^[0-9][0-9]*$' out_3071_3072
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3071 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3071 OUT_N=3072'
shuf-reservoir-sampling failed with IN_N=3071 OUT_N=3072
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3071 3073
+ INPUT_LINES=3071
+ OUTPUT_LINES=3073
+ seq 3071
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_3071_3073
==10817== Memcheck, a memory error detector
==10817== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10817== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10817== Command: shuf -n 3073 -o out_3071_3073
==10817== 
--10817-- WARNING: unhandled syscall: 326
--10817-- You may be able to write your own handler.
--10817-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10817-- Nevertheless we consider this a bug.  Please report
--10817-- it at http://valgrind.org/support/bug_reports.html.
1231
149
549
952
1181
1272
3010
2114
1719
1730
316
2044
2995
2705
2453
70
1504
965
2865
2327
2195
548
571
1309
922
790
1894
999
2764
601
1271
82
2530
2725
2646
2591
384
6
527
1823
1985
1377
2160
1697
768
2487
276
1375
1608
1310
2542
2267
598
1601
1765
1416
2727
2643
3042
2531
1278
808
2250
1518
2342
382
775
242
203
1031
1792
3068
715
1100
1622
2027
2940
71
509
2465
2933
2288
1767
3062
1234
1837
2354
1835
2005
2078
980
578
1307
2894
12
559
1954
1125
1596
1489
243
824
1342
823
2728
250
1678
2022
2947
201
1777
859
3057
1839
2991
792
2916
1108
1177
1224
132
463
2913
2767
1527
2712
703
2180
81
322
415
558
2464
1225
336
2570
1254
515
2215
1716
2985
1788
646
2093
8
2887
1726
2245
1573
2065
1152
3014
1562
1241
538
2056
1901
2350
3018
2426
2778
2545
2287
1333
271
2962
1045
1541
639
2336
739
1115
3009
2954
2361
1179
1136
1294
982
2975
2922
2623
2925
1754
565
1825
2467
1915
452
1329
433
2230
1168
2811
1069
2461
239
764
2533
2455
2369
2183
1212
3040
2808
530
1655
2076
1926
1542
1968
2511
397
2055
1049
750
2909
1996
3011
1132
1699
1866
1843
1529
657
2184
2608
76
2862
253
1813
2147
2906
338
2447
2407
556
880
126
1192
1829
345
892
475
422
1017
1646
2075
190
1807
1340
3023
98
1595
2313
102
2276
2722
1939
41
1067
260
347
1024
949
1636
2492
292
778
448
456
375
2463
2086
2182
815
2101
643
2378
2355
1055
1922
611
1167
2475
2084
2110
2648
963
1422
469
2673
1480
591
395
193
912
5
732
802
2952
1899
2253
2351
2451
896
2172
1620
1757
7
1486
2105
436
2993
2544
2402
1974
47
958
933
455
2321
360
191
609
484
69
2381
2258
2243
1540
1364
1299
1014
721
1537
541
620
1104
2904
2561
976
1534
2118
308
1744
444
2741
1530
1852
773
1855
2034
2375
2812
521
1753
1267
1548
975
534
1870
1702
1448
3005
1927
2820
2671
1255
1062
284
2676
77
1407
154
2842
33
2736
2535
2285
2085
2379
2491
612
1503
2665
2229
116
638
79
370
1953
2603
1885
39
1355
2584
2844
1928
1434
1338
1321
1139
1598
2316
2760
1286
2279
358
2150
2769
1011
1889
1281
2620
2660
1920
812
2951
934
86
269
46
1164
1380
575
2617
143
1235
1890
1764
1266
2688
1193
1290
1362
1976
173
400
722
2057
889
2635
937
97
2762
2720
1602
759
3013
3037
1080
2328
478
1190
2757
1729
803
385
445
161
2206
738
1707
723
1154
1822
524
2950
870
1810
767
2170
1826
2716
2597
2111
2120
2362
1667
923
273
1068
2714
3033
1657
1582
2490
2289
65
410
1902
1106
2801
2416
2679
1783
852
194
2304
1117
1379
240
1604
2100
533
1445
2094
25
2399
1650
2555
661
3071
1178
659
1557
996
1924
14
582
1936
1129
2986
1828
1947
1468
1046
2359
2651
1146
2637
1122
1247
2376
1244
1270
217
2550
2263
1303
49
2697
3060
3016
1161
1413
3039
2658
1937
1938
136
2102
2522
1685
855
2632
696
439
818
683
635
979
103
2970
1441
2485
2216
779
1383
2081
187
819
1438
1428
172
2786
1295
2534
1644
1170
2370
1497
83
585
2058
2698
404
712
1556
213
656
2431
398
1994
2930
2493
897
2198
746
1347
1564
1942
879
2616
2489
1859
2895
1549
1102
209
2382
826
2710
366
1341
1023
2374
334
1450
1363
1394
1423
175
1680
2360
649
2667
935
1514
317
2618
2188
2958
691
2755
2030
2882
1776
2167
2874
1665
394
1130
2653
2345
2016
305
174
2881
2855
2996
697
2774
1507
848
671
510
1848
2528
251
989
1400
1643
2779
2972
1487
971
1673
801
2478
1898
684
3006
1232
868
2739
1883
2392
1772
1784
1893
2199
1175
3056
1327
1698
406
1482
2675
771
1558
830
1700
641
825
2860
2598
2795
674
40
43
516
1205
3050
884
605
75
2828
1663
1081
1142
2391
2190
3031
832
1884
2565
805
2964
2681
2941
908
2692
1210
2337
1861
2297
2286
1656
1366
2944
576
811
1492
1746
3066
2125
2174
3041
1283
1488
2827
2761
1173
2394
371
278
1360
1709
1803
2146
1688
1033
2856
1552
2087
390
2144
2605
2427
237
1350
414
755
842
259
440
2445
1358
1911
2696
2372
514
2804
111
1626
1568
2142
704
164
1009
2994
1675
1457
2750
1806
2847
1199
2348
2430
171
967
2255
2732
19
837
2152
327
754
2837
1659
660
2754
1145
2068
1040
1782
1745
2373
2878
2196
2484
2642
1006
137
1099
1312
1550
851
1253
2108
2251
1791
951
2966
546
1708
1982
2758
1627
352
2659
2028
109
725
2025
2398
1641
1670
1315
233
265
2039
567
3061
483
555
91
2885
95
2501
1433
1135
2194
2619
435
1761
2377
678
311
3007
782
1943
917
2926
1097
223
1021
1197
2912
793
1275
1577
1871
1833
1029
1371
17
2483
622
2134
2599
921
2353
224
1846
1521
1090
330
1505
2953
1547
2222
2988
2654
323
743
628
427
2277
1513
647
2628
2805
2061
324
2834
2176
1269
2
513
653
2738
1101
369
343
2682
1087
2225
1613
1501
2066
495
45
267
2367
1217
2001
2166
2980
2606
1831
1403
2452
332
302
2470
2234
2968
13
1180
88
420
814
543
1804
329
1980
459
1208
1264
2446
978
411
10
682
1016
1676
2004
2363
1236
2507
2562
1918
1092
2138
409
1491
73
1047
1160
985
498
2106
1443
188
675
128
37
2107
1251
1951
1686
1201
2706
246
2089
380
1027
471
1592
1300
489
1600
1929
2119
1481
1
1012
1485
517
2858
1471
728
234
2753
1694
1368
1989
2596
681
342
2305
1409
1515
508
2976
687
84
2473
2644
930
2187
2008
2352
147
2042
564
1369
2270
3020
1455
1775
1510
1461
349
2707
2417
572
1133
673
836
1522
470
2520
78
1386
2737
2315
1172
2629
2141
1948
2307
784
112
777
122
416
2851
408
2497
2735
1593
1749
2829
843
2073
1571
2640
2849
1043
597
1535
283
569
1228
1494
962
2295
1834
196
2563
2252
560
473
1296
1144
367
1405
2488
1119
2510
1605
1907
1739
1421
944
3024
854
1763
1188
2236
1322
289
11
152
795
1463
2928
658
2680
393
994
379
2775
1153
2861
1638
141
1740
3048
140
2432
2556
2239
756
1781
584
2574
2156
1661
1425
2581
1211
1748
1904
2462
2274
2969
3069
1470
2344
2133
587
2294
718
2650
1121
59
2476
2140
873
629
2611
26
107
2910
1629
202
1999
2815
1672
579
2627
28
2242
2684
2244
3030
2043
1285
3034
1814
928
426
2541
2711
2818
920
1508
1752
1262
1966
950
840
2165
290
92
2207
762
247
413
926
1793
561
2317
2580
27
1054
2571
670
1956
1703
365
2079
3022
357
2051
58
820
2624
64
940
96
1770
2726
1252
248
2594
1196
1318
216
2670
1291
200
16
2347
688
547
1585
1578
1185
2423
787
89
488
2846
562
1538
1581
2226
1631
817
2917
2568
2117
1071
2482
178
421
1967
279
1137
2173
1000
1116
1093
895
1684
2264
1691
1632
507
2438
1128
2723
845
2529
871
1388
2645
3021
1056
2689
791
2469
877
769
2816
1157
1398
3036
2466
431
1334
346
505
434
1960
2576
386
2009
1560
1648
50
1382
867
1260
1451
901
1891
3059
185
983
863
2903
2177
1682
942
593
2625
1414
2715
2481
1789
1209
839
2303
118
2019
1279
1908
2730
2340
2564
2870
1034
2802
2371
2765
2979
2015
2088
326
557
876
2241
309
1039
2748
2298
3000
1022
1531
537
1637
2932
315
1316
244
953
1297
2526
1010
2238
1372
1182
2224
494
1711
2893
2071
1704
1124
2468
280
650
2703
139
1176
2072
1469
634
1018
1817
858
1874
2609
1879
734
577
1733
1058
604
113
1245
3025
2500
2864
765
1545
2884
2096
835
2364
320
2782
945
293
2388
1856
2421
2314
506
2033
607
2064
2037
886
1004
2127
1998
153
574
2301
23
1946
22
1830
176
753
1955
2495
2593
2109
2365
458
966
2687
888
881
1599
1851
2090
1013
990
1809
1725
630
2742
1887
245
1574
690
2577
2300
80
1165
443
1572
56
1539
2322
1957
1079
1361
1474
1950
1863
1623
30
1344
2814
477
680
592
1625
1896
2103
291
2310
1042
381
1384
2590
425
1490
2817
450
1630
3065
736
2434
668
2693
2791
1800
1576
2638
1563
2790
519
2282
1881
3049
1964
2035
144
1738
706
66
2525
2924
2848
2480
15
270
1959
2213
1553
872
2892
2694
2232
1147
138
1096
1969
2927
1276
913
163
2202
1718
1242
1162
1992
1476
1880
1892
1189
532
1654
205
751
170
856
1462
1512
3012
2218
9
1073
1905
864
493
2425
453
1479
1449
2724
954
55
328
155
2838
2137
627
373
2875
222
1105
1019
2299
2729
2626
2987
563
2813
2896
1114
2772
645
523
2936
2898
1044
1427
2990
331
1690
737
1930
2415
1418
2077
148
2393
1302
184
1417
2418
1365
2747
2217
772
2572
2601
2171
1609
797
663
183
1944
2309
2867
2164
520
2437
1612
2408
2965
2983
619
988
2872
2333
717
1517
254
1805
145
236
199
742
2516
2822
939
959
167
1668
1148
1958
2677
929
615
1466
2853
2448
460
1026
846
2115
1987
1326
894
1516
1586
2984
1696
1758
1187
1785
692
2752
1359
2863
2763
60
2513
1037
1639
1934
2868
2803
219
2339
2153
18
1053
2471
285
2777
893
2474
2292
2905
2794
995
482
1311
2585
2395
1820
1370
714
115
2773
121
1743
2349
42
502
1219
2686
831
2639
2971
1084
2143
1195
388
1916
1858
766
1257
580
1293
1940
1183
2192
2387
2112
1277
666
2524
2325
2063
2921
1063
2412
3043
590
2406
1808
1250
2311
1319
1635
277
1554
114
525
257
857
1204
1750
501
2404
105
3045
2211
730
3058
2825
991
3027
2792
186
664
2290
1436
1103
157
220
1760
2228
2743
573
616
727
1790
1506
2784
1496
1914
1126
1724
900
387
110
2521
1886
883
2266
608
2835
1442
2888
1426
865
2191
212
2052
486
710
1357
500
2948
2405
304
2683
189
828
2518
100
610
68
2023
1120
2841
599
1796
294
2268
52
299
672
667
1979
648
693
333
2554
274
2154
1138
497
221
1832
2900
788
2018
3047
2433
485
919
2209
2403
402
2557
53
1575
2776
1614
2346
2149
457
511
781
396
3064
829
241
1734
307
1878
462
1402
2997
539
899
2749
1993
642
2200
1238
1983
1484
1642
2012
2502
1569
169
2261
1624
2709
1465
2923
2389
2397
1354
1086
1978
2038
389
961
204
215
946
2937
3055
124
898
1304
2806
2048
1473
2428
2254
1824
168
2708
2248
2981
2612
417
2396
698
2092
3019
2662
297
2214
2284
1597
2798
679
1616
2265
474
544
119
407
1214
535
2666
747
735
2231
2007
2588
1094
1059
2163
2329
2186
1580
2566
2699
1337
1373
51
1239
1323
1674
87
2069
528
2931
282
1525
1615
2719
2793
1780
566
2320
1419
740
1159
2121
1840
2583
758
1633
2771
2201
1233
2685
61
437
423
1647
798
3054
2734
1057
2579
2296
1429
2477
748
232
827
3052
724
2074
2204
850
669
1875
479
1741
1681
1551
780
745
468
1431
1346
446
1799
314
810
583
1048
2006
2514
1206
904
197
503
2914
2291
1410
2852
392
2032
2113
165
1720
552
1619
594
789
2830
760
992
38
268
2278
1287
1931
655
2050
339
1988
1411
2126
1912
2283
1566
1594
1965
2450
1123
2701
182
2661
2901
1041
424
2443
442
2831
1110
368
2385
554
861
2014
869
21
1070
984
744
2302
2472
968
2159
2449
2508
1140
1621
977
2949
844
2479
1256
1298
3004
2017
2649
2540
542
1972
3046
2383
2505
2866
158
993
1111
252
2221
263
2175
1158
1997
1906
2281
225
796
2091
363
2049
340
1446
231
1376
2331
1194
353
1543
2168
633
1727
2123
2031
2162
214
2341
2024
2879
1472
699
1288
419
1617
2506
1289
1634
192
1404
786
1735
2306
1706
1502
2669
807
770
2780
2539
1794
1198
1509
1555
1477
2657
1903
1710
1458
927
1864
1317
1579
2668
337
207
1207
104
2040
637
1802
1786
2902
2745
123
1007
1118
1169
3008
2000
2219
700
2460
44
614
2704
1258
57
885
2496
2259
931
32
625
1399
2982
405
129
461
1292
151
2586
956
2573
785
2323
1324
2080
997
1171
166
1374
2054
1447
1453
2592
1747
2519
2744
1570
1995
2053
351
1664
1430
2208
159
2003
1335
2845
2413
2897
911
1652
719
2532
1098
910
303
2380
1774
2130
1526
1328
1064
1452
85
651
1075
1971
499
2312
344
1218
454
1273
229
2517
2797
1015
3070
1737
973
1759
1762
1713
1589
101
3015
2246
261
596
1591
2718
2358
1320
1587
378
359
287
1755
2020
1389
1523
972
318
589
1872
134
2424
2567
2998
20
617
695
383
1607
2960
146
2695
1085
1151
2641
2783
418
2538
1645
1671
1853
1216
1827
2908
281
2357
1261
1520
1669
1923
783
694
2178
1107
1460
1913
1721
2169
106
2880
1640
1440
2768
1712
2546
518
2026
720
476
2269
943
2010
312
335
1990
1732
177
1683
550
428
1220
2575
2839
2578
1223
1888
262
631
1150
2067
2429
1941
2800
1325
1714
1356
2136
1689
1536
1610
2873
1020
644
195
133
2740
964
1728
491
1332
2419
1395
1060
800
2663
376
602
1483
2622
1844
266
757
1230
2989
1705
2999
2821
1498
1050
29
2047
729
2185
2059
1945
2139
1722
2308
3035
761
618
2935
1742
2256
1415
2319
3063
1229
210
391
1078
1873
969
2368
150
2335
531
1533
1051
1991
581
2041
2664
1567
1723
1919
1467
705
1701
2343
298
2911
3003
1611
733
1841
1367
1191
2099
1109
1962
2459
2390
2293
874
2826
1464
2189
882
288
2589
181
1653
586
1314
2652
2440
916
1213
3032
806
2515
2457
936
490
902
48
1544
1444
3
120
918
1028
117
1401
2280
179
2915
2422
466
2558
74
1203
354
2690
3044
626
906
35
1660
2273
249
1163
588
512
711
1082
321
1313
355
125
1850
1766
2788
1246
1200
847
2891
1439
1935
1933
2503
2655
2781
296
2104
915
2807
2135
2919
1836
2886
2045
480
1932
960
2840
226
1618
2943
1500
2240
2945
2967
809
374
2889
1495
1565
2946
1847
2220
702
2062
1263
464
301
1345
2918
2456
2029
1679
1909
1301
2439
218
1876
430
1065
947
2070
272
364
54
522
1227
67
662
356
2850
1088
350
2787
2318
1977
568
3017
2876
2262
2435
2731
1408
878
2002
1127
487
2559
1284
2151
1032
1606
1351
361
1420
1519
235
1331
2700
1628
2582
1437
1134
613
1076
1131
208
467
1882
432
2678
941
1454
1348
108
1910
447
1692
981
1259
545
1773
1274
1952
2549
1561
2095
2600
1280
1868
1963
2330
3053
1248
890
2098
2551
1970
1343
2939
93
686
227
99
860
2854
2537
1511
1406
570
2498
472
1900
623
2060
676
1393
2131
2203
600
932
438
2227
2978
1308
24
206
3028
1095
1156
987
211
822
1736
341
909
1392
1798
1381
90
2789
914
2454
891
2257
606
2560
2260
1005
2974
1184
429
2674
2409
1030
2414
1221
2613
799
399
2810
862
2132
1819
1666
2552
1895
1390
1475
2766
2523
31
1222
162
1662
2527
2955
1003
63
310
1524
3029
372
838
540
553
1349
465
957
1036
1816
1695
1867
2129
833
2859
1083
821
2569
449
2819
127
1025
2271
1305
1860
1240
1008
403
2366
2275
1074
1769
685
2124
2636
2116
624
887
2082
2543
1917
603
2249
726
1897
275
1973
1459
4
834
1339
866
2647
1353
300
1677
230
2973
255
62
2963
1237
2442
1378
1113
377
2746
1768
2785
228
2824
905
2036
1949
1795
2401
2444
986
1412
1035
1306
2959
2857
2799
2400
1651
1731
2410
1815
749
256
903
1052
1432
621
2883
1869
2011
794
1268
2702
348
2197
2386
2823
2890
401
1649
1226
2977
2155
2961
1141
2595
2899
752
2713
2717
2942
2504
709
1202
1072
2097
595
2436
955
970
1330
529
319
1986
142
362
526
2630
2957
492
313
1559
1693
551
3002
2157
1061
640
2158
2356
774
131
654
1391
2733
1590
2843
2205
1352
1588
2441
1838
1603
1812
2869
441
708
2934
286
816
536
1215
853
875
1801
2691
1865
665
306
2602
841
2621
974
130
1975
1385
1091
3026
72
1077
776
1282
1877
258
1854
3038
2992
2338
2210
1584
1174
2759
1456
1265
1787
948
1336
2634
1818
1797
1546
2832
741
180
2610
1435
1001
2938
2046
94
1396
2871
1771
716
2833
1961
713
2411
1842
1756
1921
652
2756
1186
2920
1038
1715
2193
849
2458
2384
3001
1387
1089
2486
677
2509
813
938
2181
1424
2512
1751
925
2237
2907
2604
1811
2631
1166
1397
2548
2272
1149
1687
2587
2013
1143
2334
1925
1857
496
2614
160
707
2179
2161
1821
34
481
1658
689
1499
924
1845
1779
2877
2148
998
1984
1249
36
1155
2223
2656
2672
636
1532
2420
1849
2021
2083
1243
1478
2235
1778
2145
2499
1002
504
2607
1981
295
156
2122
1862
731
2553
1583
2836
763
2326
907
2247
1493
264
1112
2751
2809
3067
198
2796
2332
701
2615
2324
412
2233
2212
2547
2956
2128
1717
804
3051
135
2633
2770
325
2721
238
451
632
1066
1528
2536
2929
2494
==10817== 
==10817== HEAP SUMMARY:
==10817==     in use at exit: 520,136 bytes in 3,075 blocks
==10817==   total heap usage: 3,080 allocs, 5 frees, 643,052 bytes allocated
==10817== 
==10817== LEAK SUMMARY:
==10817==    definitely lost: 122,896 bytes in 3 blocks
==10817==    indirectly lost: 397,240 bytes in 3,072 blocks
==10817==      possibly lost: 0 bytes in 0 blocks
==10817==    still reachable: 0 bytes in 0 blocks
==10817==         suppressed: 0 bytes in 0 blocks
==10817== Rerun with --leak-check=full to see details of leaked memory
==10817== 
==10817== For counts of detected and suppressed errors, rerun with: -v
==10817== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 3071 -lt 3073
+ EXPECTED_LINES=3071
++ grep '^[0-9][0-9]*$' out_3071_3073
++ wc -l
++ sort -un
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3071 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3071 OUT_N=3073'
shuf-reservoir-sampling failed with IN_N=3071 OUT_N=3073
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 0
+ INPUT_LINES=3072
+ OUTPUT_LINES=0
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_3072_0
+ seq 3072
==10894== Memcheck, a memory error detector
==10894== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10894== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10894== Command: shuf -n 0 -o out_3072_0
==10894== 
--10894-- WARNING: unhandled syscall: 326
--10894-- You may be able to write your own handler.
--10894-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10894-- Nevertheless we consider this a bug.  Please report
--10894-- it at http://valgrind.org/support/bug_reports.html.
==10894== 
==10894== HEAP SUMMARY:
==10894==     in use at exit: 4,176 bytes in 3 blocks
==10894==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10894== 
==10894== LEAK SUMMARY:
==10894==    definitely lost: 24 bytes in 2 blocks
==10894==    indirectly lost: 4,152 bytes in 1 blocks
==10894==      possibly lost: 0 bytes in 0 blocks
==10894==    still reachable: 0 bytes in 0 blocks
==10894==         suppressed: 0 bytes in 0 blocks
==10894== Rerun with --leak-check=full to see details of leaked memory
==10894== 
==10894== For counts of detected and suppressed errors, rerun with: -v
==10894== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 3072 -lt 0
++ sort -un
++ grep '^[0-9][0-9]*$' out_3072_0
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 1
+ INPUT_LINES=3072
+ OUTPUT_LINES=1
+ seq 3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_3072_1
==10902== Memcheck, a memory error detector
==10902== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10902== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10902== Command: shuf -n 1 -o out_3072_1
==10902== 
--10902-- WARNING: unhandled syscall: 326
--10902-- You may be able to write your own handler.
--10902-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10902-- Nevertheless we consider this a bug.  Please report
--10902-- it at http://valgrind.org/support/bug_reports.html.
75
==10902== 
==10902== HEAP SUMMARY:
==10902==     in use at exit: 37,112 bytes in 5 blocks
==10902==   total heap usage: 9 allocs, 4 frees, 37,316 bytes allocated
==10902== 
==10902== LEAK SUMMARY:
==10902==    definitely lost: 32,832 bytes in 3 blocks
==10902==    indirectly lost: 4,280 bytes in 2 blocks
==10902==      possibly lost: 0 bytes in 0 blocks
==10902==    still reachable: 0 bytes in 0 blocks
==10902==         suppressed: 0 bytes in 0 blocks
==10902== Rerun with --leak-check=full to see details of leaked memory
==10902== 
==10902== For counts of detected and suppressed errors, rerun with: -v
==10902== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 3072 -lt 1
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_3072_1
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3072 OUT_N=1'
shuf-reservoir-sampling failed with IN_N=3072 OUT_N=1
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 5
+ INPUT_LINES=3072
+ OUTPUT_LINES=5
+ seq 3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_3072_5
==10917== Memcheck, a memory error detector
==10917== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10917== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10917== Command: shuf -n 5 -o out_3072_5
==10917== 
--10917-- WARNING: unhandled syscall: 326
--10917-- You may be able to write your own handler.
--10917-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10917-- Nevertheless we consider this a bug.  Please report
--10917-- it at http://valgrind.org/support/bug_reports.html.
2538
879
2974
1700
2935
==10917== 
==10917== HEAP SUMMARY:
==10917==     in use at exit: 37,784 bytes in 9 blocks
==10917==   total heap usage: 14 allocs, 5 frees, 38,156 bytes allocated
==10917== 
==10917== LEAK SUMMARY:
==10917==    definitely lost: 32,992 bytes in 3 blocks
==10917==    indirectly lost: 4,792 bytes in 6 blocks
==10917==      possibly lost: 0 bytes in 0 blocks
==10917==    still reachable: 0 bytes in 0 blocks
==10917==         suppressed: 0 bytes in 0 blocks
==10917== Rerun with --leak-check=full to see details of leaked memory
==10917== 
==10917== For counts of detected and suppressed errors, rerun with: -v
==10917== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 3072 -lt 5
++ grep '^[0-9][0-9]*$' out_3072_5
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3072 OUT_N=5'
shuf-reservoir-sampling failed with IN_N=3072 OUT_N=5
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 1023
+ INPUT_LINES=3072
+ OUTPUT_LINES=1023
+ seq 3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_3072_1023
==10926== Memcheck, a memory error detector
==10926== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10926== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10926== Command: shuf -n 1023 -o out_3072_1023
==10926== 
--10926-- WARNING: unhandled syscall: 326
--10926-- You may be able to write your own handler.
--10926-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10926-- Nevertheless we consider this a bug.  Please report
--10926-- it at http://valgrind.org/support/bug_reports.html.
2306
45
886
1755
1008
1088
2475
681
672
1243
332
2557
1983
3020
381
497
1016
857
2371
1114
2946
277
2186
2990
1486
2966
189
749
591
2976
2041
1425
3016
1207
1504
617
2725
297
2170
2327
2387
1613
1559
1411
610
791
968
1750
99
1523
853
2221
7
2024
1672
2826
1775
1199
2615
1233
683
668
2954
2691
2918
2030
1172
2476
1092
28
2855
570
1614
280
3065
1186
2835
2569
19
1903
1329
2197
762
731
1871
2192
1164
1039
13
408
1138
2502
2559
1336
3015
1636
795
563
2730
2880
2632
1123
1420
2683
1601
1985
1699
2525
2314
1622
2965
2931
2430
1517
3054
956
2269
17
2912
478
909
3056
389
1580
1916
1880
2460
1681
468
126
1417
1087
1627
320
1966
2824
930
2226
2059
2695
3011
2322
2886
38
473
2857
2065
1292
521
2443
51
2618
2375
2140
1566
871
1581
2789
2543
358
1709
2382
1360
1334
1773
2929
1634
1060
500
3036
2602
3071
194
354
1539
1458
1568
664
2194
2487
347
2096
2553
777
1407
2551
1436
1229
2304
2694
1650
2703
397
2927
627
1947
1078
2968
489
2911
1606
1408
452
1406
2744
2100
2685
152
1204
239
342
130
2941
1289
2358
2039
2048
2139
76
2534
2858
893
2456
170
195
1426
2779
2406
2548
1818
31
1887
514
794
2684
1604
30
639
1560
782
475
3019
1578
102
319
2546
2071
722
2881
2746
1545
451
1498
562
2838
1359
2649
1182
175
1449
1571
2368
205
2753
255
1514
46
1908
1926
1840
310
2343
2148
1167
2934
314
150
1959
1237
121
1061
1554
334
1716
2782
1927
973
1820
1505
1142
117
631
599
1976
2520
1144
1827
69
2648
2063
1241
1432
2790
955
2106
1153
2936
1898
2839
1633
1778
2594
2896
640
192
532
2868
2820
2514
2690
585
1311
934
2244
1230
1382
718
2669
1701
1470
2070
783
225
1000
1030
3023
1531
2772
50
2103
1660
125
536
528
1010
2042
456
2817
2741
1851
906
1205
2426
764
463
998
2299
2220
1392
1158
1557
1130
2696
2344
2061
914
153
3051
747
555
5
1033
2410
337
80
1685
882
104
1267
1572
1268
1954
1125
1189
2243
23
58
1767
2587
757
505
1070
2407
1763
1178
980
2757
1096
2165
792
1034
2501
496
493
2116
1390
2433
2797
1765
2495
993
1191
1453
2242
2448
885
2634
1315
2413
1159
1641
643
1853
232
2885
1342
918
863
233
2238
1437
1271
913
2544
1180
1551
2659
1351
2473
569
1279
1690
1693
1774
653
1277
908
883
411
2160
2894
1764
878
2733
534
1806
2110
2737
437
1484
1192
2349
2550
2601
990
2723
124
34
1875
2586
2060
1278
366
531
1062
313
1226
752
1487
845
2381
72
398
2609
900
2671
2438
831
763
336
482
1868
618
448
2597
2680
2251
1704
1188
1303
516
368
1930
2759
440
1398
2459
1644
602
2122
741
2401
947
2624
1537
467
2468
1222
1782
1751
260
2022
3059
2962
133
1904
2567
1979
1836
1260
1264
2232
1740
2009
2668
171
2905
825
2940
518
95
1185
2831
2963
992
240
1728
1691
1019
2563
2391
2718
1131
2385
862
761
2485
1791
589
2129
1384
2928
1058
715
3062
647
2568
2985
1692
1354
1675
446
2938
2284
1245
924
1160
750
2787
303
1301
1809
696
1833
2068
2250
2814
2408
252
566
1478
1401
898
2190
2442
1769
1357
2913
960
2620
2561
2972
1577
2697
2809
1416
2478
2447
1864
204
348
978
2870
1508
2836
1998
386
1309
1196
1324
2184
1669
606
758
943
537
840
167
2152
1299
984
815
616
1798
1147
1263
426
725
2932
1496
78
1657
995
161
2215
549
477
1295
2596
940
2198
234
551
2255
2325
1479
2158
2464
1240
756
1297
2162
2398
2981
3066
1828
2001
1587
1265
2864
213
803
481
2877
903
2507
1980
611
453
2570
1748
2556
2319
1938
1046
1729
644
2582
431
2678
1404
967
2722
1003
2969
2188
738
81
869
2321
766
851
1497
430
774
114
2378
850
1262
1759
1409
513
2906
2834
1964
2384
3000
623
2483
2092
1391
298
1312
2994
526
1161
2558
1276
308
2245
1796
186
79
238
2452
950
1323
2909
2971
2942
592
2490
2667
44
2177
2351
1501
2365
2145
2786
1889
2914
1493
2417
997
2955
2747
2813
1970
2419
1317
2865
2532
1973
3034
1362
2902
90
2756
1549
1781
1829
217
1195
111
1387
2623
1638
1835
2712
2376
2528
498
2119
709
1890
1732
977
2263
2533
1941
1893
2706
2118
2282
1197
32
2884
402
1473
2057
1332
3048
1208
216
2499
1112
2798
2883
2539
2707
2937
1648
1201
2277
2541
1141
486
988
680
1952
2823
94
999
321
416
843
2560
732
414
807
550
1696
1760
1403
235
1352
2254
1516
2975
2090
1999
1950
1256
1124
836
2923
2595
460
1573
786
2239
856
2964
1543
1012
769
2424
2285
1026
1367
2480
290
1834
737
1608
1455
2416
2210
2223
2628
466
1708
2549
1795
1385
574
2662
2693
346
704
2843
1816
2029
119
3043
708
964
748
1747
166
2404
88
936
1852
1168
2383
3025
1618
697
1068
887
1151
661
2302
2745
1599
2732
979
1021
2882
2253
510
2503
245
357
754
1036
507
2278
2044
2441
1249
1485
2457
2329
565
2472
2317
1942
861
1846
2933
2948
1651
1155
1561
1220
443
2137
1431
2721
2565
1102
2571
2510
1793
1892
465
2326
517
1602
937
1655
2775
184
1358
1134
309
1814
62
2205
2414
2324
165
2995
1723
2771
3004
1090
1661
4
2960
2062
3001
206
2736
740
54
3003
1203
1108
1808
1193
1761
1565
2142
2316
345
724
612
185
1794
2984
369
2352
2379
2360
2764
2200
581
2467
824
598
1187
2636
1668
3069
135
2356
1206
379
143
2677
2104
1327
299
1081
1353
377
942
2161
1074
==10926== 
==10926== HEAP SUMMARY:
==10926==     in use at exit: 208,808 bytes in 1,027 blocks
==10926==   total heap usage: 1,032 allocs, 5 frees, 249,900 bytes allocated
==10926== 
==10926== LEAK SUMMARY:
==10926==    definitely lost: 73,712 bytes in 3 blocks
==10926==    indirectly lost: 135,096 bytes in 1,024 blocks
==10926==      possibly lost: 0 bytes in 0 blocks
==10926==    still reachable: 0 bytes in 0 blocks
==10926==         suppressed: 0 bytes in 0 blocks
==10926== Rerun with --leak-check=full to see details of leaked memory
==10926== 
==10926== For counts of detected and suppressed errors, rerun with: -v
==10926== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 3072 -lt 1023
++ sort -un
++ grep '^[0-9][0-9]*$' out_3072_1023
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3072 OUT_N=1023'
shuf-reservoir-sampling failed with IN_N=3072 OUT_N=1023
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 1024
+ INPUT_LINES=3072
+ OUTPUT_LINES=1024
+ seq 3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_3072_1024
==10934== Memcheck, a memory error detector
==10934== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10934== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10934== Command: shuf -n 1024 -o out_3072_1024
==10934== 
--10934-- WARNING: unhandled syscall: 326
--10934-- You may be able to write your own handler.
--10934-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10934-- Nevertheless we consider this a bug.  Please report
--10934-- it at http://valgrind.org/support/bug_reports.html.
2121
2516
2572
2902
444
1036
1255
1868
2626
1536
2752
2265
1563
457
515
2011
239
1366
2678
2148
1214
287
1642
924
2003
3006
83
2059
647
1828
594
1493
2428
720
2533
797
1224
1380
1014
1785
1827
2138
3043
865
1201
2508
557
516
1955
1985
2063
451
1850
807
988
1338
1497
2817
2076
1442
2864
976
640
2778
947
1529
750
1237
521
1931
33
2304
778
1648
1038
917
1906
735
2569
665
450
1068
1223
1741
730
2046
2218
116
2604
2150
2820
2283
2203
1994
2622
1653
1282
403
2449
991
2650
2061
1861
495
172
2775
1889
219
2482
1974
228
779
3029
2425
2018
463
1297
343
1463
1867
252
2240
2197
369
2354
1961
1238
1491
64
1761
2446
1894
1796
1539
2795
1809
191
236
434
1518
878
1781
1274
1171
1804
109
2478
345
1322
2527
2456
325
2208
1075
480
2257
2889
1987
1916
2041
1140
1530
2981
2855
2958
388
2590
632
2402
2919
583
1197
2324
3051
565
2793
462
798
1843
330
119
2144
1162
1336
885
1708
1249
2751
1078
1486
101
2698
1123
706
782
2300
2910
1609
1305
2105
1071
1120
221
318
359
2439
1001
2178
1807
1298
719
3027
2713
2979
2183
962
333
1314
100
2336
371
789
3028
875
2574
3033
738
927
651
432
25
28
2554
1441
1215
1630
624
1698
1496
2102
1880
2405
1485
1431
1872
586
2434
378
185
2371
1587
844
741
2578
2663
167
30
2080
2875
2799
728
2950
175
1573
2395
2632
914
1046
3055
2504
1794
1598
70
913
1866
1928
232
1026
2907
2541
487
224
1752
2459
1595
2662
66
681
1617
2249
662
2333
3050
2096
2789
1875
972
1489
10
857
1064
2983
220
601
1401
1281
1418
1949
2129
1717
2236
1732
2386
776
2925
222
605
1562
2004
2306
1623
118
571
237
334
906
2599
1727
194
476
652
2564
920
840
1290
2571
2971
1952
2042
2133
418
177
658
96
2899
2186
742
2989
1665
2187
2270
1830
3059
1467
268
2518
248
2951
3024
1448
843
2099
1610
1834
1707
1643
2982
2335
129
1055
2807
187
1508
1041
131
1321
2462
2688
1323
1852
2841
2934
2092
1247
1464
319
1325
2263
1482
2606
1663
1706
1449
1545
2060
2450
395
957
2132
2233
572
1841
2029
2438
363
1798
328
3001
1578
854
578
347
2044
121
435
2948
1450
340
1504
2246
2714
2179
754
2230
2920
2329
1684
1389
2900
655
210
3023
1728
1929
1683
3062
963
2724
122
2921
705
1658
1379
2264
1177
1879
1740
2022
1990
1155
2214
1567
503
1950
294
2227
493
1891
408
1421
2098
2639
1780
648
2201
152
260
584
1507
478
2075
226
3054
2665
1466
1470
2941
1278
552
2932
702
310
1886
1532
2311
2912
1703
2341
1453
110
3061
676
1231
140
968
558
2524
1178
2464
2241
868
2344
2106
2212
916
307
229
2298
3040
1878
2887
1770
349
1667
1397
2822
1146
2537
932
608
1029
1187
1010
90
362
814
2819
746
2957
20
788
95
1963
1991
257
2497
2964
2231
898
2110
974
2836
1047
2597
3007
2245
1204
1773
562
1750
1657
2407
1279
1901
2783
1391
1993
2595
1259
2146
2376
2169
209
1292
2547
2337
80
1280
942
2387
822
1515
2565
247
218
542
1371
2859
987
2715
1283
206
2013
998
1962
2372
1040
168
593
2913
3017
2077
2494
2610
3009
548
862
2579
969
2380
178
344
3025
415
1923
2802
2525
2020
1764
1166
909
1009
1768
1161
1771
2716
299
2357
2505
1236
208
174
852
1452
2052
1405
2310
1956
1302
1870
1180
1561
938
851
3037
16
2542
890
1481
2430
786
290
547
3020
2551
784
535
1738
82
1458
1484
2868
2699
1419
293
2779
196
1818
2323
2651
238
2643
2886
677
994
592
1871
983
1619
2432
877
1616
2103
1585
2252
2480
2782
660
2131
134
2415
1753
2228
273
1148
2770
267
490
2843
2676
2759
3042
745
1893
346
2317
1392
3057
1342
2853
2513
1835
2481
2567
390
2745
1057
588
1984
1833
2561
1846
2164
1709
2852
1428
482
1847
1059
2623
2014
575
675
2211
620
1724
2200
2461
1091
1198
1149
1945
1704
292
2441
2469
1943
1569
1273
522
1865
901
1678
1124
1600
2511
375
806
1998
1008
2835
1913
1113
1983
14
2657
795
1081
944
2666
1647
2559
2429
1570
367
1793
1592
2334
1316
315
951
610
2765
2374
2972
285
2296
2182
2993
2708
1544
879
895
3038
1579
1823
2466
1072
1000
973
711
709
19
2123
2413
2750
2942
3022
507
1779
1551
2796
956
1568
1729
3002
2130
1039
1671
2116
3056
2583
1370
2766
1181
2669
2193
1767
1208
3072
3041
1396
2961
1736
2083
2974
2342
553
710
436
114
2273
1885
350
611
205
2054
2399
2332
1114
3030
1344
2617
765
2115
1721
1919
907
582
2922
2917
491
2069
1627
354
1646
1329
2937
2294
2423
2672
381
2001
943
400
2908
2506
2928
2085
2994
147
2221
272
3016
2873
2776
2661
2280
2966
977
223
445
154
89
1030
466
1221
190
874
102
442
414
626
1494
2154
1158
3060
2086
2191
2938
2124
551
23
356
2730
1061
2706
3004
1250
2985
1103
1352
2216
955
181
1027
263
2196
2545
1378
1348
1137
142
2550
1651
441
2784
2272
2455
2644
1930
197
1251
2589
2476
1261
2805
284
2159
2453
38
2701
1803
2087
2857
633
2612
45
2091
1136
2167
2320
368
332
846
1295
1819
1153
53
1135
2331
2521
1746
734
2608
1801
303
21
2350
1227
2361
2492
1786
9
2546
1560
2391
145
2869
2145
1583
2874
2325
538
513
1953
1537
796
1669
1571
254
1414
2675
899
76
2861
1011
1132
2443
1074
663
912
492
2756
227
1979
2303
2418
2702
1099
1151
2156
1510
1760
1121
2205
2584
75
3066
1355
57
1256
1743
1588
==10934== 
==10934== HEAP SUMMARY:
==10934==     in use at exit: 208,976 bytes in 1,028 blocks
==10934==   total heap usage: 1,033 allocs, 5 frees, 250,108 bytes allocated
==10934== 
==10934== LEAK SUMMARY:
==10934==    definitely lost: 73,752 bytes in 3 blocks
==10934==    indirectly lost: 135,224 bytes in 1,025 blocks
==10934==      possibly lost: 0 bytes in 0 blocks
==10934==    still reachable: 0 bytes in 0 blocks
==10934==         suppressed: 0 bytes in 0 blocks
==10934== Rerun with --leak-check=full to see details of leaked memory
==10934== 
==10934== For counts of detected and suppressed errors, rerun with: -v
==10934== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 3072 -lt 1024
++ grep '^[0-9][0-9]*$' out_3072_1024
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3072 OUT_N=1024'
shuf-reservoir-sampling failed with IN_N=3072 OUT_N=1024
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 1025
+ INPUT_LINES=3072
+ OUTPUT_LINES=1025
+ seq 3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_3072_1025
==10942== Memcheck, a memory error detector
==10942== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10942== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10942== Command: shuf -n 1025 -o out_3072_1025
==10942== 
--10942-- WARNING: unhandled syscall: 326
--10942-- You may be able to write your own handler.
--10942-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10942-- Nevertheless we consider this a bug.  Please report
--10942-- it at http://valgrind.org/support/bug_reports.html.
1038
356
2304
2459
457
2535
774
1227
2825
720
2970
827
2665
2670
954
1589
1539
1244
2708
1978
88
1344
1586
704
1537
2130
1815
2520
270
2088
2153
2290
1654
1500
925
2421
2026
2949
1727
942
3029
2301
822
2410
1695
1840
696
2350
292
2415
1831
685
1871
864
2242
2874
361
1471
1918
923
2736
1192
2279
3043
1574
1400
1056
1438
1224
567
1278
2779
2337
1405
678
512
2556
4
2217
2379
2264
2841
566
1880
2112
180
111
272
20
727
1485
600
1847
3000
391
2966
583
717
821
2678
2218
2348
2030
2748
1858
371
2927
2752
2926
735
2476
750
254
2093
384
621
620
396
1644
668
1512
783
1547
2715
2298
2302
1354
222
21
833
2862
2375
890
824
2897
757
1666
2712
1282
2311
1110
2848
840
2594
407
2878
123
2226
1201
540
1174
2059
1884
1184
736
2428
1432
2835
1385
1281
2589
2944
2999
337
786
2053
2149
286
639
2212
1237
752
1718
2717
2245
196
1821
3062
2605
2985
2019
3023
2816
2696
1483
3016
1890
1034
2500
141
2517
1466
978
1231
557
1573
1983
92
1392
773
843
2849
1006
1122
1513
2608
2346
2762
2032
1229
998
1480
2240
162
658
122
989
1215
2836
2238
1285
1179
1922
2330
2713
2810
1956
2258
1076
949
2851
2612
3005
2426
2464
961
2549
2045
2729
2980
2352
2395
2074
2457
1623
99
2377
2842
468
2642
2963
2876
2901
1459
2558
1543
1576
81
2767
2058
2817
2225
2434
2305
1877
1346
2946
32
34
1965
721
2738
1101
283
2534
615
883
1841
1048
494
1309
2788
1846
1661
980
646
588
1200
2044
1446
745
2057
2115
2855
884
3059
1054
442
449
1009
2537
1416
2111
2011
758
1066
710
97
269
2719
2094
2845
751
41
2663
3035
1488
48
435
1308
777
1353
386
2532
2945
443
200
425
604
1073
1331
1826
1188
1436
2592
2953
1669
1431
305
173
1835
2172
3037
555
1453
522
1696
2938
2320
248
1347
948
2006
1760
1039
633
2336
2543
1332
2819
2773
2206
2080
466
423
2192
2125
183
2131
2159
2438
1886
2930
560
939
2237
1569
2442
2638
2582
57
1294
488
2487
331
2195
2447
1790
1934
2374
544
802
2648
2492
210
2770
464
661
1458
1323
1697
1085
3042
1937
1202
1002
2837
2444
886
1541
2089
2560
1836
2610
2737
943
214
892
1240
1269
365
663
613
3008
2253
1771
208
1372
1324
648
2511
2669
524
778
2843
2700
296
1602
2607
1156
1883
896
1134
1866
1443
1943
1442
3061
346
450
3041
3033
2720
760
1295
944
2022
1701
1118
2934
2031
2904
2000
291
2802
1925
906
2065
1298
2046
2771
236
623
258
2493
2070
1693
2937
308
299
2983
1715
835
198
1012
1077
960
1736
131
1712
297
595
1245
528
1542
300
2119
675
1801
237
326
2883
66
440
2697
2390
1373
1314
1371
472
49
44
1929
1225
2587
3056
176
2877
784
1588
118
1578
2668
2190
1772
2485
452
301
2256
672
1911
1742
1465
19
698
1166
1252
2790
2846
381
1355
1499
568
322
635
764
1833
2880
1349
1804
436
664
2254
1138
1981
531
135
2273
1746
1445
586
311
1262
3052
523
211
2701
2101
649
2501
161
1806
1555
617
53
2530
924
1702
2187
877
2639
520
152
2730
1832
2814
2921
3066
817
2036
743
2171
569
2674
2316
2202
289
2887
1757
718
1690
871
2604
2781
2095
26
705
2204
1722
1151
2568
1088
1940
2654
747
2145
1961
1495
1642
1532
38
801
862
2121
611
2786
2263
3070
1334
865
221
1621
1108
495
819
445
11
643
1641
1585
1954
1549
277
749
2917
1259
1739
1953
2060
278
1970
1082
1766
1698
1086
1714
1705
1362
878
1435
738
1198
2631
2497
2329
2915
2341
3022
941
1390
448
1114
1930
2324
3006
1247
3051
1869
1035
1477
1531
109
1437
2241
3015
1663
2858
419
1664
467
1640
2801
1236
1004
2899
2448
1424
366
1219
1744
1501
1861
90
641
1567
1852
1583
490
1685
212
550
2673
234
1931
1425
451
2023
1763
35
1720
1423
2782
1895
2326
1591
134
3057
175
1157
744
1378
2383
2
580
128
2649
2552
2920
348
530
2021
2113
2853
1280
1031
96
577
2436
2082
2988
1617
2166
1706
2576
2091
927
2406
1116
2588
2804
2261
261
514
667
325
307
3009
507
2764
429
2657
2857
2542
2124
1779
1788
1603
1419
711
250
2766
2376
403
2435
917
1418
816
1910
2173
2468
1837
2714
2162
574
117
1781
579
1519
967
413
2759
2266
79
1612
268
1105
2211
137
535
188
2935
1267
832
2179
1885
625
1186
2076
434
1206
2090
2353
59
2809
1597
1364
69
1912
1575
2455
2739
2821
2623
1509
904
110
1972
2698
1677
1319
618
3002
2243
2152
3025
2231
275
1923
2402
1131
1855
826
1559
459
1939
2163
400
662
461
7
599
1909
108
1870
994
1785
2954
1415
1680
1997
908
427
2989
2051
120
1770
785
614
2881
1897
1071
1394
1976
1397
798
163
1609
742
624
1059
847
94
660
780
1618
598
2996
1430
2039
323
1384
294
2360
61
1768
2559
264
959
3010
1393
2331
3060
556
187
2174
1080
2141
899
1343
542
78
1948
378
1139
2170
575
267
1518
857
1160
2775
1241
1538
1251
2956
1607
5
2726
2422
701
2751
2962
1717
1789
1284
3049
1687
142
928
2968
2469
2355
1625
82
2826
2458
616
2818
651
2692
1820
907
1743
474
1230
1448
593
1544
831
1178
2906
2820
1920
653
2462
1856
2664
645
1107
772
55
314
1498
2533
420
2098
3036
1074
881
2933
73
1584
352
1755
2416
2451
2831
2185
147
767
2470
2294
532
818
1964
2049
1003
1876
30
2205
1268
2981
491
1825
405
1962
770
1774
1147
1220
1363
1540
2488
2591
525
==10942== 
==10942== HEAP SUMMARY:
==10942==     in use at exit: 209,112 bytes in 1,029 blocks
==10942==   total heap usage: 1,034 allocs, 5 frees, 250,252 bytes allocated
==10942== 
==10942== LEAK SUMMARY:
==10942==    definitely lost: 73,760 bytes in 3 blocks
==10942==    indirectly lost: 135,352 bytes in 1,026 blocks
==10942==      possibly lost: 0 bytes in 0 blocks
==10942==    still reachable: 0 bytes in 0 blocks
==10942==         suppressed: 0 bytes in 0 blocks
==10942== Rerun with --leak-check=full to see details of leaked memory
==10942== 
==10942== For counts of detected and suppressed errors, rerun with: -v
==10942== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 3072 -lt 1025
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_3072_1025
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1025 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3072 OUT_N=1025'
shuf-reservoir-sampling failed with IN_N=3072 OUT_N=1025
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 3071
+ INPUT_LINES=3072
+ OUTPUT_LINES=3071
+ seq 3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_3072_3071
==10950== Memcheck, a memory error detector
==10950== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10950== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10950== Command: shuf -n 3071 -o out_3072_3071
==10950== 
--10950-- WARNING: unhandled syscall: 326
--10950-- You may be able to write your own handler.
--10950-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10950-- Nevertheless we consider this a bug.  Please report
--10950-- it at http://valgrind.org/support/bug_reports.html.
1444
2802
1482
2208
1554
1796
2409
1260
2005
1203
3047
42
1385
605
2557
1937
2448
828
2821
2289
1800
2674
244
845
2143
124
100
2846
1619
1465
2116
557
2961
1311
1354
2507
517
1729
1344
429
61
2795
919
900
258
2932
1514
1116
116
1230
853
814
8
1835
2981
1614
2010
2978
1556
2059
235
2637
1532
2428
2757
574
1642
1637
1306
113
367
626
1401
968
1047
1692
290
544
150
779
1710
2167
1076
348
1592
1873
739
34
553
23
531
2070
543
2877
1605
71
502
1984
884
1258
443
1426
2950
808
2239
1100
2189
2018
2745
1005
208
1121
393
2244
211
1703
1000
2808
1590
2648
476
16
1548
2943
690
1766
2253
694
2277
494
1174
2342
2640
2653
497
504
2139
2606
2845
1054
1776
1923
282
1952
2586
2438
1196
2310
2233
1072
19
1084
121
1406
380
807
1021
1296
270
1106
2156
1180
306
2339
381
2615
1912
2781
2457
529
1189
2964
1366
1142
1014
2045
2667
1527
1190
217
2440
79
2025
1462
1645
411
2078
620
2993
2999
2125
2842
355
327
2816
1627
1159
2827
2370
2083
2136
1265
1163
1458
954
545
230
1042
712
1122
247
2331
2414
1331
595
271
2850
2281
891
749
1546
1143
2060
2641
1171
979
2814
2410
555
2647
199
1410
2397
532
2893
1315
47
1723
1938
2241
2613
1156
1604
2668
1516
2187
1178
1797
1845
695
2461
649
2336
232
2946
524
165
1949
1405
2381
301
2520
262
2970
2155
2269
329
1881
112
458
1370
1124
108
1008
96
1587
2535
1020
439
1597
1154
593
1247
2251
1133
1308
1435
2621
302
2122
1494
2172
2325
453
793
2486
2021
1022
105
2035
2503
2894
2772
1904
942
2688
2890
1838
816
1740
538
819
1649
2511
212
1660
2779
1500
2329
2358
2650
1358
1205
2449
2545
3025
1930
2698
2322
1558
1850
1339
1289
445
2515
1898
2607
1141
3001
2063
3039
1662
1445
1058
3054
2091
1400
773
464
1559
1573
2454
1540
878
1448
768
2967
498
2619
137
99
1945
2782
852
1461
2219
740
2495
1371
2509
1349
1982
1225
1929
1333
492
1045
2068
2157
579
2767
3006
738
1829
523
1843
1485
90
798
1975
490
373
1352
602
295
97
689
1884
755
2602
1375
2777
1323
1888
945
1684
661
2854
418
558
1566
1804
1794
2949
1166
2692
564
2611
1091
20
2786
890
1369
855
250
2130
167
1864
2327
542
590
992
129
1499
882
573
1135
1040
2969
2959
2282
2368
216
1693
1398
1153
2681
2857
2100
2691
1735
59
296
2785
2117
1809
2907
1322
2140
1034
1134
2419
1204
2576
2855
1568
2330
1257
2430
744
2079
2570
1753
2552
1934
398
1816
1023
1409
560
2446
2039
2266
2286
1051
1248
1653
1408
2245
2238
1946
2630
2634
2142
3015
256
2600
1001
1973
2559
2568
2499
427
2360
2934
2480
74
1395
35
668
653
799
2192
503
2132
672
1690
188
53
2341
2631
1362
39
628
1356
1807
2626
1836
1752
664
1643
2492
2357
1220
1440
700
2038
608
84
2728
2026
2210
1640
132
1264
322
2158
2235
372
2534
1720
182
1233
130
57
2700
1747
554
716
849
512
1624
394
1487
746
2297
428
2686
896
1353
1087
133
1256
2478
141
2876
1452
730
75
1655
65
205
1709
1377
222
582
40
1958
2670
475
719
552
1974
1505
2537
356
921
842
2701
1731
1394
12
315
944
2806
2797
831
1944
1236
1508
1768
215
2020
56
2769
1860
880
2848
1889
1879
1696
335
1652
1161
2073
1064
1068
1459
743
2882
1812
70
797
566
1338
1111
2418
2867
962
2884
634
312
2386
2103
1539
15
2718
1125
2652
1389
1080
1075
843
154
914
2683
1474
2526
2514
1551
2138
175
1859
313
616
1391
621
2053
1086
414
210
1238
147
3050
2790
1657
1328
2353
2287
612
2669
14
771
818
1895
509
2649
1360
2488
2220
2809
4
1814
2258
2345
2467
662
2841
66
157
860
1608
2447
2150
273
1878
285
1218
1656
1903
345
1301
501
2923
982
781
2985
903
2813
419
841
525
609
2232
1176
2205
2521
522
2940
195
1464
1115
22
1003
342
1824
1128
468
1641
785
1418
276
2378
1090
1874
610
2242
469
623
148
1479
37
1771
1863
1207
569
2006
1762
556
2547
2135
1688
378
1351
2459
1862
1187
1327
2738
1105
2198
1423
249
2574
641
2875
996
812
389
1924
2593
1926
2508
1278
2405
1585
1886
2168
2887
1434
1469
1330
2870
711
2004
911
592
2695
2275
611
328
1271
1550
1598
2517
2624
2803
491
907
3058
1292
31
2207
2391
183
1496
1718
1488
323
2587
1651
1213
2246
1290
1666
2826
218
451
718
1999
2075
431
1387
3014
2844
678
192
2445
93
1186
1939
1269
2400
1160
85
2011
2333
550
1216
1941
2177
1276
1617
2862
1767
563
2710
272
2774
1267
2761
3043
2544
1492
1997
2764
2090
614
2879
2975
951
483
1397
2082
710
1822
1894
2076
1654
2431
1959
1927
591
834
1454
1498
1210
2475
565
2019
1348
2752
2114
3010
303
1841
2121
707
1561
2029
1961
233
2346
1815
1607
1711
606
1066
2531
673
2285
213
990
1634
3035
1437
1438
2610
1341
2819
625
3052
2881
334
2000
2451
1139
1507
1298
1083
2355
959
507
1510
1736
2564
298
1773
758
1748
360
2672
413
1586
1947
1419
1805
2941
1319
2363
2805
1227
1965
3070
2633
1388
1033
604
974
2518
1844
2184
932
577
763
294
2853
106
2582
26
1621
3002
1931
1182
1872
2193
774
861
2089
1157
2664
1181
1650
2074
403
2830
561
1357
2384
2373
310
737
913
1855
1172
2424
331
526
2616
1717
2939
937
1439
347
2604
1169
2442
2473
722
2058
2579
1706
3020
1588
2947
1994
2836
1792
2093
2931
2612
1212
1297
1818
1077
135
240
2988
2124
2052
2444
472
1145
782
2661
2817
2838
1404
500
1472
3022
2834
879
3
675
326
2066
3004
1628
1987
62
1902
351
2237
374
2929
928
1117
533
513
1896
1325
2892
1480
330
2902
1943
60
1244
2789
1079
2497
2118
366
753
1661
2200
2643
637
1803
1917
146
2217
2793
692
825
2261
2296
541
2524
789
971
925
2149
1229
1476
2248
3051
2343
1783
92
2015
2250
1107
482
752
1095
559
1785
379
1270
465
172
2316
180
371
2033
1787
2992
350
123
308
225
159
2953
2912
2926
2274
2636
926
361
679
1053
311
268
186
1579
2403
309
511
633
1470
2178
2504
2684
747
3023
1515
343
1108
1866
966
87
446
670
2223
2533
2452
1442
866
2227
599
1544
2768
2393
1368
1288
499
2673
2458
1114
899
2024
736
1564
1199
1989
780
1209
795
973
2694
869
941
2562
2374
2380
2359
2007
1625
1240
727
1481
2896
2215
3040
677
2682
63
2350
714
333
2320
2085
1689
2240
1243
1957
3038
1421
2868
1324
3046
1094
1867
2530
2989
1037
2197
1144
2212
349
765
3017
1983
1012
1562
1477
238
721
486
471
776
975
325
2146
1422
2601
1954
480
2847
387
2840
1639
1436
862
1638
1834
2265
2047
438
2658
2259
1892
1411
98
1849
1350
1335
2519
2837
2107
756
1273
396
943
2190
1018
1520
750
1609
421
576
46
685
696
1491
155
2977
1468
2272
3041
1502
1893
783
289
603
1150
1734
1737
1635
2421
2256
1577
2589
151
681
388
454
1575
1183
2042
452
286
1528
1245
1346
27
585
1955
2859
2234
978
1402
1283
223
2106
2471
1239
2951
1531
405
1329
2972
2863
967
1966
2201
1309
2502
277
52
2885
1102
2271
2487
2590
644
2351
2119
2255
873
1846
1610
1770
1978
837
2542
1840
219
839
2371
2290
691
725
340
3065
1759
2597
1374
406
2529
709
2299
1473
2313
2716
2577
1826
1303
115
1749
2229
2706
2734
281
2952
2
354
2516
76
1885
460
3000
423
1537
2435
1365
2214
1676
3016
1848
200
2278
687
976
2527
385
1664
1543
109
1126
572
826
162
2165
530
1772
1226
2916
1744
324
2898
2551
2880
562
2115
239
2614
772
2249
2744
1052
221
703
1173
1345
2389
1214
1152
2675
3036
1132
2717
1868
2137
447
2938
152
515
1149
2927
2663
1373
1972
1933
751
1206
651
1195
3048
2775
267
168
95
1790
3072
291
2639
275
2829
2536
917
1567
1571
2921
1372
2860
936
2399
970
3061
2496
648
2104
25
2872
2618
1913
2304
1407
2436
5
1504
2433
2302
770
1680
1821
1858
1130
3021
1742
1056
548
2009
2016
2500
1320
847
958
2928
2567
1287
1730
2914
2228
2204
1968
1347
1242
2086
2984
1049
400
2987
1443
666
1221
338
1789
134
1582
2489
49
473
2017
594
2008
1695
983
514
30
344
635
1988
1386
624
811
583
457
2721
1980
2174
1622
1155
202
1
1513
299
1905
2321
1882
2974
128
2980
895
1687
1788
1981
119
1784
1390
131
715
2490
1626
3037
2279
2216
2126
1177
72
1683
89
1534
702
764
804
1765
1922
949
2906
1775
184
1191
1118
408
2134
139
2966
762
489
6
1916
1119
2065
1950
2383
485
2957
1263
2883
2324
2638
33
3057
73
809
1219
1995
1964
1099
2398
2120
1633
2462
1971
78
2318
166
888
2037
1364
1865
2222
196
1782
2858
1241
1457
2704
821
2434
754
575
676
2548
17
436
1854
519
437
1613
902
2546
1856
2852
2666
883
1811
2098
2505
587
1899
1754
1447
1336
916
2588
1602
940
920
3055
1932
189
2608
2474
1484
284
1120
2915
2685
401
2188
2225
2622
2112
1471
643
2369
627
1441
1757
319
931
2181
1831
2077
1918
1596
2427
867
2243
1648
2131
731
905
2361
1249
2312
1428
2491
2054
1151
2963
412
442
430
444
193
359
2169
1167
1420
580
2199
724
395
1810
404
1875
2202
214
2968
2936
1208
2935
288
955
745
1547
2522
1883
2247
2726
1743
203
815
927
935
2338
11
2753
101
2632
10
2308
1313
1138
2948
1672
2709
1497
2711
234
2013
1777
1061
1808
2221
2128
2382
2861
1572
1953
1581
1681
227
778
487
1295
840
622
787
987
32
875
164
2300
1228
761
1004
2991
2730
110
2301
3018
2566
1774
1495
2727
1304
2206
915
601
864
2001
1799
2625
1342
274
102
3059
2352
1589
757
1007
111
424
1211
1714
144
1361
2605
885
383
1631
2955
1704
1897
1837
2642
3062
1025
336
2707
422
656
1870
784
307
2662
2392
1780
1158
2783
41
1600
2003
686
3012
191
1595
1460
467
1942
2690
2791
868
1632
2917
1876
362
2705
3011
1266
2585
596
358
3008
1890
2159
2262
835
1378
2712
3049
2756
597
1101
2493
2298
278
1070
863
2479
1700
1063
939
2402
1127
760
2609
2810
2784
1852
2166
2888
1031
3045
2372
1993
568
2654
1976
463
2456
2812
1979
2787
693
1013
1928
171
1618
2027
2904
2127
1475
2291
647
459
181
1062
759
2056
1646
2780
506
21
961
535
245
2771
2973
984
2900
2583
645
2347
2185
2388
402
197
1670
2724
2599
2387
2036
2213
1901
242
228
766
2689
1713
1996
1259
1880
732
2561
2396
1793
1906
125
2954
1839
1725
1006
1456
1857
655
642
1184
3064
705
1970
2268
2097
357
2161
2818
2918
2170
2945
1665
683
2476
2294
969
2263
2196
1659
2919
2723
2441
1466
1251
2749
1234
1043
1379
2965
1517
2740
2575
600
838
1998
2512
1819
264
713
104
1910
708
337
332
539
1925
2560
1795
1977
2014
2553
857
1697
1310
3013
1545
1016
946
1281
292
2549
127
2270
1224
2748
341
581
2541
2762
701
2878
930
1940
176
2960
1367
854
817
1553
2173
352
1274
654
2319
1490
2032
1392
1756
1909
629
977
434
2760
2485
263
140
1763
1170
952
2538
1813
886
699
1525
767
2905
2555
1781
733
2425
2729
2678
3026
2099
2788
477
1825
67
1024
1425
2958
3031
18
1724
2315
1010
261
2747
1430
3009
1019
160
1088
1067
1165
2455
484
2864
2163
2677
2051
947
179
2645
1073
435
1745
2742
440
1658
1647
2061
420
1503
2105
805
570
1669
865
1786
1722
1969
1029
2040
2439
2102
3056
887
1380
688
1237
1594
1712
2715
253
981
859
2908
2807
1069
77
1842
24
320
684
54
2466
908
1828
2979
1317
156
1282
1671
2095
2034
259
206
618
1393
1535
3003
1741
2910
415
2385
726
1343
2676
2413
508
1032
607
391
1565
1039
1050
69
1584
2463
1716
3042
55
1701
964
2180
1530
2986
190
956
1449
386
1967
2925
142
297
950
1081
1255
2283
2151
1384
2750
1231
1293
1678
279
1140
1089
2453
801
173
1728
1921
2572
1911
1616
1533
2995
2736
1427
1179
3007
2334
363
748
2799
1686
2472
136
551
1506
791
769
1699
1698
339
2218
2354
2759
2494
1129
2671
1920
1847
185
2365
1705
1188
493
2920
2071
2578
2708
2186
2596
2252
632
802
441
910
1414
2328
392
1048
2971
521
1708
2595
1707
1085
80
2659
86
2573
316
38
2796
2236
1801
64
1529
1424
1109
998
1017
45
528
665
2824
488
830
823
2725
2465
598
1755
2154
2293
375
1733
2822
844
1960
287
2406
663
1576
516
832
2483
177
1536
28
83
2933
2823
2699
1827
2484
1991
2628
588
2956
505
2886
3053
615
1137
630
792
2153
652
2323
2869
2563
44
1817
1583
209
1501
1318
43
2922
806
1871
613
2901
3068
2770
547
2067
2160
1059
2776
906
1719
143
972
650
2470
1667
698
2303
1538
1557
2703
2804
2175
2108
3060
1570
170
1820
877
2080
2743
2679
248
321
1691
846
2209
777
2623
255
1623
2055
1185
881
2510
2646
2305
2550
1202
3032
1433
2722
909
617
2755
1396
734
407
2203
178
1685
1376
91
631
953
669
1215
1948
2962
2656
1193
520
2443
2696
892
1679
3071
2629
1363
1262
2911
2367
540
2702
1284
2758
36
1415
2532
986
2408
1429
2539
2182
870
2362
2081
1990
2429
449
960
1253
2811
1593
254
2264
2930
2101
1316
1560
3027
1217
2571
1887
2735
1194
2903
2543
2092
2580
790
1074
1919
2498
257
1201
1044
2982
1746
2794
2133
2087
2404
1524
1286
659
2416
3067
2191
2693
2164
2731
2317
1915
2513
1041
1663
2909
2739
1668
639
1601
260
269
231
2426
1112
876
2523
527
2148
1578
2565
1727
1751
893
1542
1093
1512
963
496
2110
2260
2501
2603
1168
536
2733
2891
534
2937
1521
1337
1254
2226
2765
50
1760
1552
934
1986
2873
1131
1877
1092
988
858
2835
2041
640
2183
2680
1113
236
1302
2057
1511
1739
680
2375
965
619
304
822
2998
2713
2924
3034
1110
589
1232
1620
741
2598
2944
827
2732
1035
2231
384
474
2843
163
1071
985
1985
933
1455
1636
161
2348
2839
2913
107
432
923
2144
2798
1726
2152
2831
1307
2340
1963
924
2697
1417
3069
2644
243
397
409
735
2113
153
1103
2050
2737
29
2528
786
2432
1340
2069
1275
1294
800
1962
1030
2022
417
2687
13
149
775
2482
1136
2763
2295
2401
901
2660
1285
1606
2990
9
2141
1235
1036
1009
2030
370
1673
1015
3029
1611
2540
546
671
1675
2162
1399
2377
1383
365
2194
1055
2825
1321
450
187
3066
1682
1011
2379
2390
118
2620
848
94
426
697
7
3030
1198
2874
1299
1431
1359
2326
682
1272
2584
466
994
856
1104
549
1750
353
1162
280
660
2062
813
293
2288
1305
1280
897
567
836
1432
3044
1078
1097
229
1802
2012
1300
1446
2851
991
742
2422
1416
728
226
2766
2292
2469
1268
2094
1715
999
918
1246
117
904
2043
1851
1175
2800
1853
578
241
2746
638
2129
390
103
717
1026
2481
1355
1956
2335
2311
2866
518
1450
1192
510
410
1833
851
2337
1574
317
1314
1279
2395
1509
993
2307
1677
2714
2145
1522
2267
265
1694
2254
889
1526
1907
704
2412
1992
2046
1057
1028
912
2356
369
1549
1413
796
1798
1038
145
495
246
314
2994
3024
636
2856
657
1629
2651
2720
455
2211
174
1830
1381
300
1164
2871
1046
1252
2306
1096
1630
586
1463
2617
2627
2023
1758
448
425
723
377
3033
2450
399
2309
120
1486
283
1580
1334
1936
2741
1123
829
2591
667
2376
929
126
2976
2280
1403
1523
201
1778
2751
2171
2556
1489
2176
2394
138
706
2284
252
2581
1615
2344
833
2815
2889
1738
194
318
266
2592
2833
658
433
2179
2778
2665
2407
82
584
1555
2554
2477
1914
2364
346
2028
68
382
2468
1519
980
1603
2754
2224
2655
2996
1451
376
874
1082
114
898
1764
1612
1002
2273
2464
1779
2088
48
2460
1806
2111
871
3063
2031
2506
2257
1732
2997
1823
2828
2657
1332
1197
2332
2719
1148
2349
2801
1200
850
646
1312
1261
220
1222
1541
989
3005
894
1869
81
478
938
1569
2899
1908
2366
997
2635
1591
1065
207
571
1147
1769
1900
2525
1644
2849
2109
2072
2195
416
2558
2569
810
2423
237
481
224
2983
368
1599
788
995
2048
479
1146
2897
2064
729
1702
2792
462
2276
2415
1382
948
794
1861
2411
1935
2420
1223
1761
957
674
1098
824
2865
872
1674
537
169
122
1060
1027
3019
803
2417
720
1951
364
2147
1832
1478
1721
2820
470
1563
51
2942
198
1467
461
2049
1412
1518
1493
305
1791
204
1291
1277
1453
2594
2002
1891
2832
1250
922
2123
58
1483
2084
251
158
88
2230
2096
2044
1326
2773
456
2895
820
2437
3028
==10950== 
==10950== HEAP SUMMARY:
==10950==     in use at exit: 520,136 bytes in 3,075 blocks
==10950==   total heap usage: 3,080 allocs, 5 frees, 643,052 bytes allocated
==10950== 
==10950== LEAK SUMMARY:
==10950==    definitely lost: 122,896 bytes in 3 blocks
==10950==    indirectly lost: 397,240 bytes in 3,072 blocks
==10950==      possibly lost: 0 bytes in 0 blocks
==10950==    still reachable: 0 bytes in 0 blocks
==10950==         suppressed: 0 bytes in 0 blocks
==10950== Rerun with --leak-check=full to see details of leaked memory
==10950== 
==10950== For counts of detected and suppressed errors, rerun with: -v
==10950== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 3072 -lt 3071
++ grep '^[0-9][0-9]*$' out_3072_3071
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3071 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3072 OUT_N=3071'
shuf-reservoir-sampling failed with IN_N=3072 OUT_N=3071
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 3072
+ INPUT_LINES=3072
+ OUTPUT_LINES=3072
+ seq 3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_3072_3072
==10963== Memcheck, a memory error detector
==10963== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10963== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10963== Command: shuf -n 3072 -o out_3072_3072
==10963== 
--10963-- WARNING: unhandled syscall: 326
--10963-- You may be able to write your own handler.
--10963-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10963-- Nevertheless we consider this a bug.  Please report
--10963-- it at http://valgrind.org/support/bug_reports.html.
1292
1338
175
990
2694
1241
66
1420
3022
76
2532
210
2993
458
1940
960
1814
249
4
47
453
2097
1436
2981
26
2835
2526
2741
295
2069
2457
2707
1878
2114
1882
135
12
1788
1344
412
1023
1097
1330
578
2924
840
2907
163
2198
1703
1183
2943
1178
964
1205
1751
757
2458
855
1404
971
1576
1209
1590
684
2848
1530
2374
1409
2787
379
2012
915
864
2972
2990
1383
593
2210
710
1373
2052
532
2559
1392
1197
1358
2629
116
1303
73
2869
2213
2478
2677
2215
2063
1228
2006
553
2015
496
1126
1296
711
2238
1327
24
2071
1629
2049
778
821
2930
947
1479
3006
1654
1226
215
652
1331
2813
2885
377
474
673
2222
1494
1277
482
1253
989
2118
2167
1896
2480
1324
290
1898
1020
2799
2523
2084
1264
2445
1781
2378
2341
766
2647
2792
222
411
2847
1967
630
646
1227
1911
1801
368
170
871
703
996
1161
1806
1083
1745
1222
2992
211
2151
463
1618
2431
2479
2313
2082
2258
1466
383
988
696
2952
2660
2010
975
2582
2347
302
2580
1104
1224
2846
1390
433
144
1574
2172
2784
2067
1810
1688
1239
444
2522
2840
2905
2874
930
2890
713
1319
1675
304
1091
2913
742
1829
1044
1947
17
2482
2323
1938
937
1704
372
2894
380
1922
2515
1782
1519
184
2969
1580
1893
1776
2299
301
514
577
1286
331
2978
88
931
2249
1571
2773
426
3059
2975
786
2860
2854
928
2211
1560
1685
1045
1167
244
2760
20
1639
2964
1831
1164
1771
2744
2601
2014
2841
1906
1107
2495
507
1792
2066
325
299
926
1903
1371
1848
2620
1203
1114
633
2579
894
64
2184
755
1417
180
806
2290
1912
1297
1433
2715
438
2871
2635
1310
1720
1510
510
2255
1031
333
2740
1170
298
2130
898
2748
1301
1165
1821
2177
637
882
108
195
672
1820
2340
1795
1585
286
536
2519
1088
2730
1798
2447
1635
2865
1440
1135
901
1518
410
1908
1888
2564
2038
982
189
2751
98
81
953
483
266
2667
2503
96
1492
734
1769
437
1337
254
1999
2237
2831
2269
1900
2224
2310
955
1993
359
508
539
1892
487
316
1567
1994
1334
1817
2780
1399
2284
1683
791
1168
245
1551
360
1963
2020
1199
2344
2861
748
416
385
715
2035
2266
2506
2829
1902
900
2537
2569
1702
224
695
2546
1604
2520
1512
1018
262
60
2524
2955
895
1261
913
397
511
2002
1758
1038
2839
165
1230
468
33
2205
725
1859
865
347
2843
2179
330
2279
3061
1857
702
1375
2504
2100
1965
2819
2602
2756
1819
2761
935
2490
751
318
2591
1484
1522
231
2171
10
699
969
787
1853
261
1268
1637
92
94
1478
1489
2154
419
870
2217
2444
1616
881
101
2710
1754
1486
622
72
396
518
2565
3038
1557
3023
471
562
2343
1033
750
1740
204
832
480
1115
1412
2460
1889
922
1490
843
1187
2610
3039
2225
46
2498
1393
911
2857
2181
375
1660
2937
954
473
3010
574
2036
2442
965
1680
1150
1936
2161
1613
2946
1309
1549
2424
3026
1678
1099
950
2798
2618
3012
71
2370
984
678
1100
1990
223
1506
850
3014
2727
1125
2230
485
1273
1668
1459
1351
2168
2423
1886
1385
891
1272
61
1804
2500
549
706
1442
2005
32
1609
2095
2128
1118
1929
1395
1000
2554
1435
146
740
2162
2352
701
603
2745
1306
2320
1323
1721
833
148
80
2173
941
2362
1001
2662
2555
2844
233
1247
716
455
545
2240
115
2153
2324
1780
2127
1437
2392
2485
84
552
2090
460
1204
2876
1473
1851
172
3046
906
2630
2605
406
658
2904
2941
1231
2419
729
1952
587
42
525
2910
415
1753
2491
580
1625
1387
242
712
2543
332
390
3057
386
2308
512
1089
2746
2492
584
857
1520
225
2766
875
962
1981
3019
185
2150
2080
1712
2474
130
1572
2157
2518
798
993
305
2501
1021
2403
2298
2685
155
1587
1610
2738
1225
103
2767
2743
1019
1207
634
1345
138
1728
2723
320
1714
1214
1124
529
1143
2411
1584
1800
544
3056
1252
1837
1108
1362
2372
2477
3049
1094
1918
1935
2045
1767
2932
2879
2768
1729
2285
54
2693
1274
283
2355
1707
1189
2207
1813
1976
1816
2152
1133
2108
2560
198
369
1313
2295
503
615
1413
1843
1621
1196
413
3058
1084
2048
1312
177
1434
475
744
648
1594
1979
428
126
770
1949
127
1497
681
1845
2592
2494
991
1553
885
1282
1210
1811
2247
1455
844
1246
799
523
2116
1279
866
719
1359
1260
1280
2195
1846
1499
3060
2440
596
2906
2625
887
1096
1160
2276
816
626
959
1661
3021
668
1176
2188
1504
2827
3067
1320
1920
1750
1457
1074
1980
160
657
402
598
2454
1950
1003
384
2302
849
872
1011
2899
1711
2028
3051
2673
243
1379
2074
250
1548
2124
3028
1451
2753
1382
1690
1730
775
387
2584
3050
585
2263
1731
287
1366
2688
3017
2909
258
867
2720
2915
2583
1513
604
743
2252
2414
550
707
1840
1267
1064
1667
667
2396
1785
2809
142
251
2223
1545
2160
1079
2533
934
1134
771
367
297
940
275
2781
1649
1035
2598
858
3047
29
2257
2877
836
374
1185
2271
1784
595
1825
985
310
2695
1381
535
2822
356
2420
2156
1058
2884
285
3069
1419
1398
851
14
1599
1491
1606
2027
1132
1424
579
431
3016
436
1890
1877
2275
1063
1939
2903
1907
1159
987
859
1742
111
334
1858
1428
754
1049
831
1054
3008
1305
2062
1790
2438
756
1989
2032
735
216
1500
2449
2548
938
1913
2197
2947
2094
183
2333
2301
1915
1815
1691
1061
2241
640
722
516
2483
2317
862
1961
746
721
2651
461
1977
817
923
248
2134
1475
345
2747
1946
642
835
1928
905
1259
18
1652
1964
2778
2338
1065
2129
1899
2244
1960
1596
694
1017
2115
139
1870
267
2105
1648
312
30
2008
3032
1155
2220
2863
1060
1046
2980
2398
1787
1589
2182
852
2851
961
466
1429
2597
1832
2936
2397
1093
1316
1789
381
1573
2345
1602
1966
1869
349
526
2816
190
802
1066
727
2201
2155
2897
1605
2268
2112
1086
74
2009
2531
1797
2920
610
2687
105
2599
1472
2977
2776
2790
586
880
2216
927
2262
919
464
2131
1633
567
1446
2833
2416
2944
2227
752
2669
2135
370
1407
3037
1059
1852
1002
2513
1068
2235
1175
1308
2908
39
2713
1944
2836
239
2922
1113
2400
2292
3066
1601
158
476
1414
2765
282
2055
1718
908
797
1483
853
273
714
15
1117
2705
2808
1833
591
1129
837
904
2578
1315
1737
2572
2133
614
2083
2007
2701
1673
1998
2390
534
1426
2834
1340
2350
2358
2663
1029
1627
2165
1955
1075
769
117
2091
2319
1951
91
772
1644
44
2675
2888
2512
554
2643
834
1764
1969
2870
784
841
1182
2280
519
2571
389
401
2619
948
635
556
1925
2030
1040
2174
435
1868
194
161
2517
2698
2132
346
1388
337
1540
264
557
693
2450
524
2631
1701
720
2566
423
1873
2726
2855
2931
2852
494
2243
382
1757
1812
2342
1298
2287
361
1256
2283
1662
2325
1271
3054
2039
2828
1762
943
759
505
1583
484
780
23
1828
1879
2914
270
2354
1839
420
342
1201
709
2534
1432
2199
2143
2348
2508
1157
2488
220
1863
1270
207
2463
2467
2056
1119
399
2351
2940
121
1830
2867
2802
499
2613
3003
1942
878
1156
3040
723
1037
2864
1724
2678
803
1410
663
2665
477
1251
2037
2192
1051
247
173
291
3024
226
2187
2046
2568
517
822
785
1406
2254
2719
2353
2655
691
432
1734
2902
807
1321
565
276
1559
1611
765
1982
317
1568
1342
1240
447
537
58
6
2557
2750
1152
1620
125
3002
214
1425
650
202
2448
2603
2464
2144
883
1092
1956
1523
1215
2185
2064
1954
1370
2417
527
2259
641
521
1865
2549
3072
1255
1670
1622
884
2866
2530
1566
1521
2963
2570
2455
323
2061
2718
2054
724
2406
644
253
2293
1763
2300
2812
1004
2926
2234
717
1447
1195
2586
2949
1269
2193
1803
1480
351
354
2379
974
95
2755
235
522
2974
430
1746
1030
2525
1779
3000
408
2825
1289
492
2077
945
2208
2297
1655
692
2627
860
2758
2950
1534
263
2617
914
2873
2081
429
814
2228
2724
2315
221
2585
571
1245
2752
1552
1638
2811
1448
1053
1343
2296
829
1076
241
313
2815
2183
1458
824
2624
1290
1978
1992
2958
2612
2690
208
1212
3029
612
687
2717
3065
1653
2666
2058
51
3048
1867
1080
470
540
546
2042
85
2148
394
2288
1543
2469
2274
1677
819
1719
1699
2594
2935
2092
1743
2033
1937
38
2200
1517
939
59
2004
501
400
456
1050
1249
897
319
486
2953
2789
952
2426
1022
2186
2654
1275
2265
128
2502
1072
1211
1650
1694
293
2615
656
2194
1179
2451
90
1598
1363
1503
1439
1957
1563
1128
2487
1120
269
1357
793
308
268
3068
726
2916
1628
1202
1532
1122
1110
1927
1856
655
1217
1904
2845
2683
920
2043
1220
893
3005
1974
326
564
2948
2689
1302
490
3053
2772
2872
35
2791
1741
2331
2019
237
2405
2312
2706
520
3063
493
877
1317
1822
1418
1874
705
1184
1144
205
1930
2239
22
2967
1623
1372
1645
2270
2895
2703
808
3035
2642
169
1684
2911
2329
1564
2264
1624
9
2649
152
2121
1300
489
2575
666
625
2998
2011
446
3031
1304
1541
2436
1262
53
899
2371
2850
1826
868
1632
601
232
998
1933
1875
1307
86
45
2875
1153
1103
967
2332
944
41
1098
2749
1095
1723
2832
916
2041
1962
2204
357
2576
2971
2514
1485
1536
1169
1198
2989
2928
838
1861
2113
2273
327
1793
1926
2145
1586
1577
2142
110
281
2736
1005
1461
2141
3055
1191
2316
1048
1360
2691
933
649
1774
1765
2607
1238
2178
440
393
488
2817
2970
576
294
2797
1294
1453
2611
57
1181
889
1430
1291
2025
542
2303
1028
2122
2507
2364
2541
78
2346
1221
2226
2711
1642
3071
2098
992
2407
2311
2983
2918
2608
1502
737
1659
2
1615
2821
1443
1052
1137
1634
1827
1213
869
27
1194
2587
670
2731
200
1671
664
2856
141
704
2079
2516
3009
1243
500
1672
1887
350
3001
136
2481
848
547
1311
2938
2545
2339
1057
1318
1528
2779
530
1258
2472
2901
309
424
1656
1322
1752
1396
812
983
628
2086
2702
890
1367
388
1389
761
677
1636
2739
815
2770
2389
119
1232
924
1864
2837
2868
796
1880
1525
425
1732
2590
2804
1464
328
958
227
1036
2166
590
2882
1171
1325
2231
1123
391
513
2774
2203
1482
747
1006
2395
414
322
2164
278
2511
1314
980
2382
645
123
467
1172
1862
2973
1218
1818
206
481
2476
1905
783
1354
106
676
669
378
2456
1695
1592
63
1697
2985
67
1791
609
1514
2709
560
2109
2528
279
462
187
1996
2399
1465
1934
1755
1676
2561
2281
2388
1368
810
2409
2219
515
2126
2368
956
2823
2987
36
2446
2997
2939
680
613
159
133
951
2496
2614
741
847
1431
1105
1529
2544
790
68
903
1208
2634
2176
2965
2326
311
1847
2801
1008
1844
443
555
1082
1941
1488
1726
1991
2394
1136
2716
1376
1909
409
2539
1216
528
1131
2652
1477
921
1102
638
1894
2334
197
2391
2410
1154
2979
2361
1471
1237
209
1679
2567
2484
1361
405
2880
3004
1570
2221
1142
156
1526
1055
2733
2232
1127
662
1983
79
1641
442
341
191
2556
1415
2606
2886
2073
1924
1657
830
256
804
1278
1995
1824
1614
2381
2256
257
730
2968
324
1444
2282
682
89
2668
688
2088
2022
936
2671
1427
2452
616
732
506
1364
2305
2366
1579
77
1146
738
1696
1987
3043
1760
376
196
1687
43
1346
2786
1192
548
1112
192
2505
690
112
929
2380
1747
1285
2322
118
2233
1223
336
2335
65
631
1533
1689
963
114
49
2493
1854
1234
1836
910
2465
792
1841
2961
2782
1871
272
1600
1973
2001
2945
568
1744
805
34
1147
2050
1698
2149
213
2623
674
1405
2552
2737
2021
1759
1542
1452
1027
2461
1923
2657
2309
343
733
2057
1505
1972
1173
665
3033
627
1569
2628
21
999
5
2443
2272
2927
2120
846
1799
978
3025
2357
3030
2644
366
2110
2581
2648
134
13
143
2653
685
2805
643
162
1248
2700
1511
1109
497
575
1177
979
1897
1997
1770
1539
1403
450
457
37
2933
995
2026
1885
2422
2432
1193
1281
617
2771
365
1958
2337
619
1809
1423
1581
1881
2433
2169
2489
1970
1975
2538
421
167
599
3018
647
2680
2794
2415
174
1449
2521
1493
1968
1608
2862
238
2328
1988
75
773
1039
1665
2111
3011
736
1087
2604
1749
597
1200
203
1626
2373
2117
7
1985
339
1794
2089
87
2093
252
1658
700
2453
1287
1808
594
828
2959
2365
303
1266
2085
1438
774
236
1722
104
2917
2267
2024
618
1717
1349
1544
265
1550
188
2013
1352
2103
2384
2376
2159
2849
2314
2574
1402
2883
2375
602
441
1229
407
300
566
909
2236
186
654
1014
124
2656
2291
1876
2393
581
395
827
289
1007
1547
1460
1353
2734
811
3
1236
624
2147
145
2684
2659
2475
1158
973
1855
363
150
661
2278
2367
2699
1293
1783
782
2664
1916
2588
230
2558
2962
2527
234
338
845
2251
569
1495
825
2636
1350
636
454
2138
2551
2106
795
3052
2966
8
2639
1619
543
1380
902
1077
498
199
606
274
1071
2923
533
2912
2034
986
976
839
465
459
504
2017
1276
246
1748
1562
2306
1329
50
879
1595
1391
1062
166
1651
1708
1716
1556
1174
2757
329
1932
3020
531
608
1106
1326
284
2529
2697
2887
813
854
1339
2960
1669
99
794
1524
1056
762
25
2986
2892
2102
2330
2430
70
2229
2788
120
863
3034
1481
1422
745
856
1299
182
212
2441
495
259
2462
2982
1713
600
2593
2096
2996
2785
176
2645
449
2956
364
2891
1986
801
1555
2536
2253
1945
2674
2900
760
1163
2721
2437
2609
102
348
1474
2542
1263
2107
2427
1010
2125
2510
2793
1041
2140
558
1257
572
1597
164
2806
1565
2163
1487
1834
2633
2123
1180
1593
3007
2190
2759
277
315
1554
2196
2853
62
2248
2468
679
2878
1866
1140
2137
427
2250
1288
907
1706
1643
445
2076
2896
122
2999
1921
561
3041
1498
2402
1507
1591
2459
2289
1283
977
1700
1333
2286
1663
83
2078
779
1441
689
2473
2988
1468
659
131
1067
1575
340
418
1527
1130
218
2072
2360
621
1348
3070
314
1607
886
2658
2732
2044
2661
1365
820
966
2321
789
2260
1121
439
129
491
1332
697
776
2820
1069
2954
1805
2307
321
479
573
2428
758
2202
1111
56
69
2632
52
100
1450
1496
1244
1295
1883
1725
1895
1233
2616
280
2563
1775
1043
1901
1328
764
1727
1032
1397
2000
1151
398
157
1025
307
1386
918
2573
632
181
422
1777
3027
1416
2889
2681
1686
1646
502
3015
1872
2387
683
149
48
605
2175
296
2824
1265
2434
2714
168
1710
2670
2068
660
551
1467
818
620
2682
2242
563
1537
2712
1692
2304
1016
1085
1516
2214
2470
1578
2136
1914
2672
1959
1374
19
994
1630
728
3064
1681
2562
55
2535
2261
639
671
1145
2650
1561
2984
1772
2435
1335
2735
2540
1835
2838
1535
2728
1462
2404
1394
1735
2070
2696
132
2051
2349
2803
358
2595
2589
2209
1515
1190
2814
2929
1761
178
874
2218
392
1024
942
151
2925
2995
2764
1356
2686
1012
777
686
2158
1254
2003
3042
873
3045
1538
97
1284
2692
417
1884
1401
1768
968
1786
1709
1
335
1047
2754
2881
588
2976
2377
2499
140
1015
2363
2170
201
113
1603
2206
2412
40
2429
2425
292
589
888
1948
2842
2139
469
541
2600
2471
1377
1336
2622
1617
288
109
809
2818
1026
2212
1917
957
1953
2796
1773
31
1162
800
2722
1733
2101
2919
1891
2408
3013
1739
623
2830
2898
2180
1186
2418
2934
2497
147
1910
2245
653
2369
2386
1508
1546
583
1971
2704
2059
1631
2336
2807
2800
1013
1469
153
861
2777
1612
2031
1188
949
1823
2246
219
1849
1341
2921
2957
1141
946
3062
1558
1919
2191
2596
2018
1476
1081
2859
1860
1078
1463
306
753
763
559
1073
2783
1009
1647
981
1693
403
1347
1411
352
1842
2413
2762
1501
355
3036
2994
478
2047
842
2383
1101
452
1369
1139
448
2104
2119
823
82
826
2509
1400
768
217
1166
892
1705
373
2401
972
2294
353
2991
1445
698
362
2858
2547
137
1715
2277
2640
781
1738
1408
2327
1943
154
739
2769
2775
107
1531
2795
2553
2189
1242
607
1766
1042
1588
2637
2729
675
2646
2577
2359
1070
2040
1802
240
917
1470
1807
1116
1138
1149
1235
2099
2893
179
1838
1355
451
2439
1206
229
1756
1850
509
2763
538
2951
193
1456
2466
2679
2826
171
592
2676
2421
1682
1034
912
1666
2023
629
228
2810
570
1582
2087
472
2016
260
2356
1148
2638
708
651
2708
876
28
434
404
896
1984
718
1090
2742
2318
1640
2053
788
970
2621
1931
1378
2725
1509
2641
932
11
1384
1778
767
2486
2146
2385
1421
2029
2626
93
1250
582
731
2060
1219
1796
371
997
2550
925
16
1454
1736
1674
2942
2065
611
3044
271
1664
2075
344
749
255
==10963== 
==10963== HEAP SUMMARY:
==10963==     in use at exit: 553,040 bytes in 3,076 blocks
==10963==   total heap usage: 3,082 allocs, 6 frees, 774,268 bytes allocated
==10963== 
==10963== LEAK SUMMARY:
==10963==    definitely lost: 155,672 bytes in 3 blocks
==10963==    indirectly lost: 397,368 bytes in 3,073 blocks
==10963==      possibly lost: 0 bytes in 0 blocks
==10963==    still reachable: 0 bytes in 0 blocks
==10963==         suppressed: 0 bytes in 0 blocks
==10963== Rerun with --leak-check=full to see details of leaked memory
==10963== 
==10963== For counts of detected and suppressed errors, rerun with: -v
==10963== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 3072 -lt 3072
++ grep '^[0-9][0-9]*$' out_3072_3072
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3072 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3072 OUT_N=3072'
shuf-reservoir-sampling failed with IN_N=3072 OUT_N=3072
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3072 3073
+ INPUT_LINES=3072
+ OUTPUT_LINES=3073
+ seq 3072
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_3072_3073
==10971== Memcheck, a memory error detector
==10971== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10971== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10971== Command: shuf -n 3073 -o out_3072_3073
==10971== 
--10971-- WARNING: unhandled syscall: 326
--10971-- You may be able to write your own handler.
--10971-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10971-- Nevertheless we consider this a bug.  Please report
--10971-- it at http://valgrind.org/support/bug_reports.html.
2292
1518
1619
2244
1959
1868
2559
1192
2743
3054
2578
1942
1920
2044
977
1105
1266
876
2614
964
2756
3068
1120
88
694
818
339
2490
1874
2091
919
803
2501
450
1483
2167
2086
2648
804
3048
1056
1002
1154
473
2851
2351
1565
1579
27
2880
259
183
2072
693
514
1103
333
25
2165
17
1078
1448
1550
276
1032
2449
143
1881
2985
488
1303
2517
2748
60
598
1820
2222
248
13
2830
1336
1294
1028
2276
2963
1862
1163
105
2284
1238
1385
1114
2526
2642
650
702
1101
426
1343
1621
239
731
2335
2553
2737
1243
9
1556
2513
400
1703
1326
194
3009
188
701
923
2216
1855
1092
479
440
2478
1232
91
296
271
543
224
1504
281
1812
1742
485
343
2417
748
1921
3017
915
2285
2969
6
3042
1728
85
1954
2858
2897
1510
2121
2042
2608
856
1279
1511
2203
2582
1437
354
2027
2452
1395
621
2644
2161
900
781
1045
2107
612
556
603
1588
983
3010
464
2876
126
463
1829
2377
526
2841
1190
1200
2277
1220
215
1542
2506
1825
3
2926
1228
1427
2891
1643
2147
2632
138
610
780
2034
1495
238
2717
1371
1217
2120
1532
3055
2317
3066
2384
1657
773
1023
304
2136
1075
2265
2884
520
1289
534
1880
2848
43
1173
1591
265
758
112
1082
160
1691
1718
1805
2189
1187
2131
2269
3026
2316
401
2676
4
1377
2997
2746
2683
1467
1389
716
887
1301
709
2144
3058
2903
1223
121
1211
1540
1315
410
721
815
3035
2408
1029
2186
2619
185
2122
1473
3037
1613
1661
898
2994
2720
703
1687
101
2098
1084
2610
192
2954
2180
2066
2200
1110
1376
2515
2356
2472
648
1439
1416
1767
2868
997
1538
2138
2162
751
1934
3057
532
56
1605
1564
2726
1268
2405
1324
2432
1816
1065
1781
573
2805
2414
2882
628
1652
2565
1191
1273
1520
490
808
766
217
212
275
604
2511
2095
2341
229
1354
1253
135
1641
866
553
778
1838
1148
1627
2885
1607
2661
950
1831
1310
684
58
2089
423
2627
1137
1406
1584
901
2103
2272
979
1089
2636
908
794
2647
1694
269
2724
1650
2658
2438
2137
94
1884
1842
2145
921
3008
355
525
90
2875
2548
2879
2983
1826
51
861
1895
186
2225
1749
752
2827
223
1461
482
1678
542
1000
1247
2060
332
1054
213
2889
68
1497
996
2009
2327
2289
454
1434
2416
2256
659
2856
2975
1390
2738
206
419
2230
408
338
1447
1572
2680
1136
2747
2298
1213
590
1053
2061
1899
2202
1534
1702
2150
1212
2372
2821
507
2425
230
759
1947
1291
1498
1207
1329
158
295
2291
1681
342
1442
2010
1531
1634
2677
1312
2914
431
1271
911
445
128
2638
1401
2656
368
460
2703
397
1055
1488
2334
654
1129
966
1729
2837
2892
163
1539
326
451
1770
455
1009
2460
755
3031
2261
2869
2365
2058
142
1991
2886
505
45
1909
2056
1417
162
1492
1195
953
117
1107
1038
1363
80
1668
2675
1320
1939
2867
241
2494
1553
2508
630
652
1755
156
2574
2267
1945
92
1901
662
509
1250
1813
2413
2853
956
302
839
356
906
719
2002
609
564
1918
1430
2551
1348
1575
2345
637
2986
2154
2755
1625
2510
2956
2655
2812
1408
944
305
941
111
3044
3072
1647
115
75
2770
1688
216
1074
653
607
2254
2128
1001
2799
1689
2901
2596
916
1115
159
1978
545
2140
2714
32
1168
74
596
284
2221
2287
1814
1499
2704
444
2800
1433
2554
1106
2942
1560
629
2569
2028
2917
2159
2546
2832
2132
2157
2519
417
1112
1091
420
2922
2406
2468
1995
1345
1130
2621
2698
2382
341
1481
116
3050
676
733
182
1410
1886
3014
2453
835
1639
764
1072
1121
589
632
3030
57
929
1357
1165
1457
1290
149
2630
70
2766
2319
879
2558
84
2862
1697
2809
1793
1133
2399
2718
1549
2706
2238
2430
3069
325
1586
37
1672
1677
1768
2525
1142
1916
753
2982
2194
2302
959
22
1131
467
2336
2764
2049
515
1835
1466
1885
2657
2482
2109
3062
2055
2231
2179
461
1958
580
904
588
1366
2712
2902
934
571
409
1083
1391
1946
300
2758
2826
909
2757
24
796
2199
2487
567
3023
578
2944
2456
61
406
2745
1903
1501
2393
1593
878
2062
2807
1902
133
424
696
1923
429
642
1817
884
87
2354
1776
1104
1316
1362
2496
1732
1073
885
2280
504
2581
2877
1785
157
2053
2260
7
2057
1471
1047
2435
1889
1426
1574
2682
2428
155
2687
2108
2964
1581
1365
2118
1582
1496
848
2688
576
569
614
11
2631
1156
2840
2666
2653
3036
365
2090
2988
172
46
2650
1778
2127
518
1849
1508
971
369
2390
313
1119
1454
199
2663
261
535
510
73
12
2368
842
1327
2410
2268
290
1188
2674
475
2547
943
2852
1513
834
2561
1866
1686
1369
2810
1364
1199
2163
1779
681
2905
1046
2968
714
1629
2855
1169
2466
436
1646
130
2278
2765
1262
2197
661
2046
2283
1722
2370
2422
1011
1309
323
2212
2236
2733
1771
110
2175
1870
2928
2768
947
1904
2750
288
552
2977
1124
1463
1524
1897
2105
583
2391
631
137
1783
2932
2178
2263
2106
2492
363
891
2495
243
1125
1263
707
1743
2697
3005
476
2196
465
1094
806
1468
776
1821
2300
1210
2018
1342
2223
2839
2205
1167
3040
1420
2475
1541
2833
399
1307
2248
2850
917
1602
1171
961
1919
1
1277
1221
328
559
2571
1224
616
2080
472
769
833
2363
3043
2153
2623
1070
600
432
1241
2700
1568
2699
320
2176
1144
912
574
2400
1772
843
601
2722
1201
1950
665
2011
722
946
2935
2939
2047
3011
1387
516
1810
2293
1375
277
2235
1699
2041
394
164
2570
370
1361
2933
965
2536
763
2069
1828
2067
2330
945
1010
2032
2719
2193
2190
1659
811
36
585
2444
1044
1848
2681
1803
988
1888
775
711
2626
65
1155
1403
2033
663
2762
1592
2299
1113
347
3064
1087
2169
2735
692
2102
2708
2329
2352
2395
705
484
471
1667
664
2038
35
1551
2611
2068
2085
1819
1019
66
2774
2695
1017
2311
2500
1707
2135
1790
1006
2208
2070
2004
1658
2894
2177
1589
19
2078
1256
886
1424
937
2295
453
3053
2113
2407
922
1407
2469
1682
2773
2585
795
2286
2198
1968
1015
297
801
34
374
2727
874
2023
2398
2824
506
1355
274
1536
1841
1692
242
106
2093
1617
1892
1715
575
1370
847
1296
1035
2201
1861
926
494
849
2381
2874
1197
1765
859
611
334
975
1257
1754
1166
270
717
2702
503
2521
1962
2019
54
1932
349
1162
414
381
2314
2170
3046
584
2878
246
820
517
1852
2818
2974
686
2119
2544
2606
364
925
2271
563
2645
990
1965
272
786
524
2847
1143
2590
2294
1383
202
214
910
2516
1012
2971
1030
1071
1751
2253
311
1670
2288
2537
33
1929
880
1352
1523
358
1203
2112
2245
52
2386
984
727
2966
1178
31
2036
372
283
1451
1529
1020
1784
1847
2076
340
1014
935
1126
540
2252
1824
2051
955
3013
841
1616
2752
639
2573
770
785
1367
119
2392
895
1558
2849
2918
293
1283
1796
279
3065
2039
2166
1622
62
1839
263
1933
2670
994
2434
2353
1717
1606
2984
615
2779
309
1747
1233
896
2972
1780
2715
2099
1987
877
1964
2616
178
3007
2602
2732
3022
1873
2237
10
2545
958
1969
2652
280
1915
2705
2502
1587
2672
726
2433
853
1879
2094
1259
2374
1555
2111
1138
1872
2696
2725
1766
2257
1255
792
2669
1337
570
2331
2825
2467
500
2040
883
2913
1227
2919
2017
1399
1402
28
533
1057
846
254
1476
3051
1618
2097
903
1428
1278
1626
2629
287
522
512
362
2673
2895
1267
360
760
1535
23
2823
1470
2005
1293
2782
2306
673
1663
438
2646
840
1656
690
1235
337
2215
1208
2952
100
181
1955
2904
2716
2993
658
1282
823
1875
1700
2160
2229
2741
2783
398
812
1836
1421
1393
99
627
2461
2534
972
1937
2129
1487
1288
64
872
2693
2524
967
1313
2079
1655
987
53
2633
2951
2564
1443
712
2584
1569
907
577
1066
2077
1378
774
1088
2665
2962
1016
2767
1719
1799
294
837
2938
144
108
2240
913
1413
1858
2960
789
2213
2710
98
2217
1669
487
1926
1152
227
1807
1941
2206
1972
2912
2448
783
2842
1907
2187
1720
247
725
385
1204
2786
2185
3028
1245
791
2075
1908
1438
2749
638
854
2462
1493
644
2781
228
1517
2707
124
377
1502
1435
1193
998
2556
1140
375
548
1711
2550
2158
2309
677
123
344
2685
1272
1604
1596
2612
48
2662
1275
26
478
2989
2798
1938
197
307
2454
1794
2796
2899
824
511
2337
1096
2332
1244
882
1570
231
2604
2815
1611
933
1837
174
2424
2936
191
657
1218
1696
95
1713
1704
1384
2579
2635
2447
1734
826
2402
2923
715
148
308
232
1927
2906
1135
1882
2389
3041
2378
1637
402
2348
2999
2797
452
547
39
1031
666
1422
221
233
1475
991
2082
310
1674
2385
851
3029
211
1642
2931
830
1763
165
2790
2210
2396
2792
930
413
2361
2978
1172
2141
2388
2713
1462
1823
89
1338
767
1516
1654
268
948
2426
2784
2303
2064
2115
622
1460
1905
1632
2013
2081
2451
1843
141
732
1791
218
1999
2445
1554
579
1548
2533
2671
255
78
1983
102
441
2446
2549
2801
2371
2586
3033
2514
2701
2484
447
2836
537
2649
2723
1350
171
180
1405
2793
2950
1216
3070
2232
30
816
2744
2959
134
1739
889
2577
2183
729
421
1967
2528
1214
1069
1533
1076
1332
1472
2730
2123
1943
2403
1474
1237
2441
636
109
1398
1051
1333
2088
1061
1660
2813
1317
1086
1356
1802
1234
2074
1567
920
348
1134
982
2987
623
2759
1818
2811
2227
862
1246
2957
1893
2304
1465
391
2324
2788
756
2338
321
2184
1840
1353
2172
2761
2863
1064
2624
480
2459
2124
2594
739
1883
474
2864
2320
2816
173
819
1062
2778
289
2679
521
2871
655
245
1801
797
2572
2125
2873
1597
1429
2835
643
845
1469
2084
2734
790
1432
1013
825
2394
2900
645
449
1631
1576
38
1287
2822
2575
2096
2025
306
2473
2560
1733
456
1040
978
1180
1738
383
1205
1737
2357
466
2597
1545
1608
1382
1097
495
1050
2483
2953
2000
273
425
1117
523
1609
1239
1769
219
720
1260
2503
1748
1741
1753
1788
2791
2142
1411
462
2151
2420
240
2881
855
1970
2242
1295
1894
608
1736
1240
69
1913
198
1583
292
2164
2024
1887
336
15
1252
282
674
2865
3006
832
799
1928
1185
2485
1599
1248
2308
1961
2643
2498
2423
617
2470
1651
2605
2664
687
1782
1286
104
2995
1494
2970
730
2401
457
2843
1930
351
2439
905
1157
2110
1099
322
1251
2771
1860
2580
1392
1653
594
1544
2457
1830
2854
2794
1998
606
1261
671
1761
1018
2104
1595
1614
2591
1490
1864
113
357
2667
1635
29
2920
699
1141
519
2777
852
1759
2740
624
713
1412
2312
1098
380
1285
146
1832
1757
2116
2948
749
1851
2617
140
366
735
1160
2134
1491
892
1484
167
20
256
1522
3004
2694
718
2347
2980
1322
888
951
864
1526
491
2763
2192
2443
2563
430
1714
1021
1876
2998
2576
1306
1960
1662
86
2593
483
1079
2949
3019
2520
2660
2195
2729
1705
312
2996
531
2360
2139
278
2654
1330
258
1347
1675
492
2820
2499
1853
1090
118
2568
743
745
1638
1952
869
640
1486
2497
3056
403
1706
415
1331
1844
2588
1996
446
1298
2909
2318
844
2929
708
1159
1519
2753
867
2313
2073
1414
1478
204
679
893
496
83
147
3024
168
2243
1898
79
1940
1170
122
1077
373
203
1308
378
2355
2961
2149
1977
747
807
2598
1701
678
1744
1834
2
1957
1684
1557
772
1731
924
1373
541
788
3018
641
793
193
3015
2092
2246
2020
1302
352
433
539
1183
962
1081
260
3038
434
899
1760
565
2358
316
551
2373
8
976
1673
970
2258
931
331
196
1798
395
2628
427
396
675
1339
2343
1610
1441
1067
244
1100
2607
1723
1925
1963
1150
1981
1328
1633
1198
2751
736
2599
2168
1900
3003
2870
120
5
954
327
161
620
754
2296
1580
382
688
863
2012
3059
805
728
1953
235
253
1944
47
691
2065
1979
3032
404
151
873
393
1578
1822
1049
1209
1680
298
2251
2742
2479
2418
2509
498
1230
502
914
2721
1792
2861
1762
303
1878
554
821
902
1423
468
1304
2344
587
234
2429
2829
1379
2785
2898
1444
2512
942
836
2893
765
2552
1341
2100
529
1033
939
493
2955
82
1123
1034
2133
591
3049
723
1676
1404
1249
1258
136
1181
1037
800
179
1292
2259
2339
2739
1804
2117
2369
625
1948
2845
1971
1042
1360
2290
346
1318
1236
2007
1789
1027
2967
207
329
1685
2155
2934
1482
1603
2052
1859
2639
2806
2981
1184
2787
2188
2804
443
166
1186
2775
1080
2143
549
2437
1374
1226
1896
251
2504
499
660
2557
2282
968
2930
829
2146
670
2465
1716
1935
831
195
2819
437
1153
530
992
2174
1344
2375
2171
1547
2583
2539
1512
544
2890
2415
390
145
1118
2450
536
1174
40
685
695
1396
1740
1594
1746
1615
1986
2795
42
562
1358
761
1750
2412
236
422
2063
868
744
1202
1219
1725
1648
561
2262
689
435
981
1911
2772
2711
2045
2937
1906
1409
1222
1455
2275
2054
291
2455
1709
1850
1752
1845
1992
324
2209
1993
2048
1146
2270
1039
656
928
809
132
651
2736
1561
458
2297
2927
2464
2618
1891
501
384
2620
2659
2846
129
1623
2834
527
448
890
1147
1068
865
798
1194
668
2802
1552
1914
1775
21
1811
2507
2965
2214
459
2087
2173
940
828
226
1514
757
957
697
2589
1815
1988
960
1085
2204
1922
2529
1730
1111
927
1809
1276
2668
1161
1149
2383
1489
938
1314
1445
963
1758
2234
528
2915
497
1419
2409
813
81
602
633
3060
205
2404
1936
2380
1158
618
2477
1175
2888
2543
2218
3020
1453
669
481
153
1024
771
1003
2958
952
1340
2030
387
187
2342
1480
2689
667
568
881
2595
2249
2518
225
2838
742
2686
2333
1980
2924
152
682
1446
77
2031
2211
2220
2731
1976
175
738
2340
1335
2480
2776
1305
2538
1624
1912
301
2440
286
1877
680
170
1122
1566
3067
838
2769
802
2493
1644
1636
2207
2322
439
2946
3063
2601
1910
267
683
489
264
1577
1800
1397
1601
18
2542
2973
700
974
538
2615
1485
371
2491
1721
1380
3047
97
1630
379
2152
989
2634
1176
3039
918
1321
2925
646
208
1527
1177
55
2397
2976
1456
317
3000
2014
392
314
2148
252
2567
14
698
1620
2219
2530
330
787
1695
190
2233
986
1145
220
1856
2637
1388
2022
1649
1598
2603
1573
2522
1311
2592
2021
1325
555
1058
647
3052
1464
2411
1394
1048
2421
1745
1415
897
2266
2831
1139
858
2255
407
2562
2359
2182
2130
762
2943
1270
2419
2887
2307
2859
1698
1022
3027
1521
131
2808
2990
2940
3061
389
593
572
2427
2250
2247
1708
2431
1503
150
210
1867
2540
1683
1116
592
1528
1431
1537
209
782
262
1924
3025
416
2274
2622
2126
850
513
605
1004
2692
222
2947
710
740
1506
1786
1459
1585
1179
1109
1833
814
2264
2828
1036
114
1665
1774
2321
176
1956
1808
184
1372
1712
1764
1628
315
2191
1854
2991
1052
2476
2436
557
299
2367
619
2181
76
2866
2992
1984
2625
1215
154
2488
2523
2587
1559
936
1151
1931
2489
1869
2678
1974
1600
1890
560
1351
2541
2008
127
871
177
2979
1095
706
1917
2379
1440
1949
470
405
1386
1093
477
784
1666
2872
1505
810
2754
2814
2535
3045
779
1640
2006
875
1690
442
1710
1756
3021
586
1990
2600
1863
418
1997
1043
949
508
59
2366
1507
546
1787
1543
1857
1966
827
746
1671
2156
1590
2315
1562
2301
1509
1264
2059
107
1846
1008
2228
1500
1985
486
768
2328
1319
2910
16
2709
2029
1346
1951
2071
2844
2279
737
1679
995
1450
2728
41
613
2505
2555
257
1300
649
2016
969
550
2691
1189
860
1436
1127
582
2474
250
350
1349
2566
993
2323
2651
1196
1007
1425
1806
1773
93
1297
2226
1280
2857
412
1265
985
1449
2326
2043
1726
2471
1727
1182
1865
2789
469
249
1563
44
2050
201
237
2860
777
1231
2376
1515
1797
724
1479
2817
2224
1284
597
2945
189
1795
3002
932
672
1975
1458
1060
1254
857
1269
3012
599
2362
388
1132
2780
1645
581
2001
1973
1664
2281
1982
2640
2532
1827
2641
973
1323
1206
67
1059
2346
3001
1281
1724
2239
595
1525
2921
2241
361
980
1381
1005
1225
2101
2387
2026
2003
1777
125
2941
2916
1989
2015
1400
2690
1274
103
2035
1368
3016
200
72
49
2442
1025
96
894
626
2609
266
2325
558
2684
1693
1128
3034
2907
817
2760
704
2481
870
2310
285
741
139
2883
319
2083
1994
1026
750
1871
2486
63
2531
359
1299
1477
411
169
3071
1359
428
376
2613
1546
734
1108
2349
1242
2463
1530
367
634
386
1452
2911
318
2803
2527
2350
822
50
999
635
2896
1102
2037
2114
1063
1229
1334
2305
1571
2364
71
1164
335
353
1612
1418
2458
2273
566
2908
1735
1041
345
==10971== 
==10971== HEAP SUMMARY:
==10971==     in use at exit: 553,040 bytes in 3,076 blocks
==10971==   total heap usage: 3,082 allocs, 6 frees, 774,268 bytes allocated
==10971== 
==10971== LEAK SUMMARY:
==10971==    definitely lost: 155,672 bytes in 3 blocks
==10971==    indirectly lost: 397,368 bytes in 3,073 blocks
==10971==      possibly lost: 0 bytes in 0 blocks
==10971==    still reachable: 0 bytes in 0 blocks
==10971==         suppressed: 0 bytes in 0 blocks
==10971== Rerun with --leak-check=full to see details of leaked memory
==10971== 
==10971== For counts of detected and suppressed errors, rerun with: -v
==10971== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 3072 -lt 3073
+ EXPECTED_LINES=3072
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_3072_3073
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3072 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3072 OUT_N=3073'
shuf-reservoir-sampling failed with IN_N=3072 OUT_N=3073
+ for IN_N in '$TEST_LINES'
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 0
+ INPUT_LINES=3073
+ OUTPUT_LINES=0
+ seq 3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 0 -o out_3073_0
==10979== Memcheck, a memory error detector
==10979== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10979== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10979== Command: shuf -n 0 -o out_3073_0
==10979== 
--10979-- WARNING: unhandled syscall: 326
--10979-- You may be able to write your own handler.
--10979-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10979-- Nevertheless we consider this a bug.  Please report
--10979-- it at http://valgrind.org/support/bug_reports.html.
==10979== 
==10979== HEAP SUMMARY:
==10979==     in use at exit: 4,176 bytes in 3 blocks
==10979==   total heap usage: 5 allocs, 2 frees, 4,220 bytes allocated
==10979== 
==10979== LEAK SUMMARY:
==10979==    definitely lost: 24 bytes in 2 blocks
==10979==    indirectly lost: 4,152 bytes in 1 blocks
==10979==      possibly lost: 0 bytes in 0 blocks
==10979==    still reachable: 0 bytes in 0 blocks
==10979==         suppressed: 0 bytes in 0 blocks
==10979== Rerun with --leak-check=full to see details of leaked memory
==10979== 
==10979== For counts of detected and suppressed errors, rerun with: -v
==10979== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=0
+ test 3073 -lt 0
++ grep '^[0-9][0-9]*$' out_3073_0
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 1
+ INPUT_LINES=3073
+ OUTPUT_LINES=1
+ seq 3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1 -o out_3073_1
==10990== Memcheck, a memory error detector
==10990== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10990== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10990== Command: shuf -n 1 -o out_3073_1
==10990== 
--10990-- WARNING: unhandled syscall: 326
--10990-- You may be able to write your own handler.
--10990-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10990-- Nevertheless we consider this a bug.  Please report
--10990-- it at http://valgrind.org/support/bug_reports.html.
686
==10990== 
==10990== HEAP SUMMARY:
==10990==     in use at exit: 37,112 bytes in 5 blocks
==10990==   total heap usage: 9 allocs, 4 frees, 37,316 bytes allocated
==10990== 
==10990== LEAK SUMMARY:
==10990==    definitely lost: 32,832 bytes in 3 blocks
==10990==    indirectly lost: 4,280 bytes in 2 blocks
==10990==      possibly lost: 0 bytes in 0 blocks
==10990==    still reachable: 0 bytes in 0 blocks
==10990==         suppressed: 0 bytes in 0 blocks
==10990== Rerun with --leak-check=full to see details of leaked memory
==10990== 
==10990== For counts of detected and suppressed errors, rerun with: -v
==10990== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1
+ test 3073 -lt 1
++ grep '^[0-9][0-9]*$' out_3073_1
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3073 OUT_N=1'
shuf-reservoir-sampling failed with IN_N=3073 OUT_N=1
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 5
+ INPUT_LINES=3073
+ OUTPUT_LINES=5
+ seq 3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 5 -o out_3073_5
==11002== Memcheck, a memory error detector
==11002== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11002== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==11002== Command: shuf -n 5 -o out_3073_5
==11002== 
--11002-- WARNING: unhandled syscall: 326
--11002-- You may be able to write your own handler.
--11002-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--11002-- Nevertheless we consider this a bug.  Please report
--11002-- it at http://valgrind.org/support/bug_reports.html.
1174
3018
605
2795
920
==11002== 
==11002== HEAP SUMMARY:
==11002==     in use at exit: 37,784 bytes in 9 blocks
==11002==   total heap usage: 14 allocs, 5 frees, 38,156 bytes allocated
==11002== 
==11002== LEAK SUMMARY:
==11002==    definitely lost: 32,992 bytes in 3 blocks
==11002==    indirectly lost: 4,792 bytes in 6 blocks
==11002==      possibly lost: 0 bytes in 0 blocks
==11002==    still reachable: 0 bytes in 0 blocks
==11002==         suppressed: 0 bytes in 0 blocks
==11002== Rerun with --leak-check=full to see details of leaked memory
==11002== 
==11002== For counts of detected and suppressed errors, rerun with: -v
==11002== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=5
+ test 3073 -lt 5
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_3073_5
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 5 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3073 OUT_N=5'
shuf-reservoir-sampling failed with IN_N=3073 OUT_N=5
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 1023
+ INPUT_LINES=3073
+ OUTPUT_LINES=1023
+ seq 3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1023 -o out_3073_1023
==11011== Memcheck, a memory error detector
==11011== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11011== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==11011== Command: shuf -n 1023 -o out_3073_1023
==11011== 
--11011-- WARNING: unhandled syscall: 326
--11011-- You may be able to write your own handler.
--11011-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--11011-- Nevertheless we consider this a bug.  Please report
--11011-- it at http://valgrind.org/support/bug_reports.html.
2279
1259
691
1612
3029
1484
251
1029
493
1730
1912
717
2543
2277
1890
519
49
1038
1578
588
2133
2726
3056
2453
1086
1114
2343
2840
2274
2430
2725
2976
859
394
456
2067
2051
609
2198
1780
1187
1631
1808
269
1487
421
1805
2660
1559
2686
1975
1085
1745
2147
114
1449
424
2245
2654
338
1557
802
1296
342
2865
2486
677
2784
1874
2980
2369
955
1225
2739
989
2403
2101
2123
1706
2722
876
2643
2676
1942
113
256
2611
477
804
1494
3013
1328
1242
3064
290
821
1251
1601
851
2836
2089
2554
1711
1731
2779
497
1078
1986
914
1870
1840
2542
750
1902
2032
2815
12
1382
197
1426
2489
2434
1062
981
760
467
547
710
2636
2742
2933
1000
349
2072
289
352
1624
2623
849
2581
2841
1678
1617
2171
1891
226
1343
331
2588
855
969
3003
1361
1400
2455
460
1248
949
1629
2637
1695
1394
1363
1409
2640
2404
2382
1123
2360
2092
504
2772
918
2227
2820
563
582
817
2621
2604
2961
3033
62
1504
2809
902
444
2085
938
904
446
2146
2003
1093
544
538
2835
991
1399
1506
2257
514
136
1144
1279
2367
1553
344
1383
1671
178
712
1647
511
2262
1704
811
2698
1370
3034
771
2327
1276
614
2467
2960
2472
534
2662
1205
2834
2633
2082
482
2084
1592
703
229
1696
943
728
2642
2544
2165
2468
941
2435
436
1208
1322
903
2965
2594
1097
764
1606
3035
2536
1207
1945
518
2175
2107
68
353
2103
739
387
2083
1231
1883
372
675
1331
188
2584
2953
1031
463
255
1528
2033
1089
411
105
696
1419
1100
2678
768
1914
1757
1135
638
1830
3010
1876
502
1072
1474
312
2744
378
2624
2574
906
2233
2934
87
1471
2153
440
2207
1710
1765
1342
2700
2760
210
2276
1546
324
1160
565
137
5
788
2823
195
1585
1981
1988
427
702
1538
2391
1014
1650
117
1770
2755
2750
2800
2311
1332
613
2405
1228
810
346
2548
2533
1486
2068
2292
2144
2520
1561
1789
3036
1799
207
529
726
1948
369
1740
2052
618
2877
481
942
2169
80
2591
2476
2730
2119
1692
2790
2848
2629
191
2028
2571
2667
1580
1982
2539
2121
409
1371
56
2494
386
1784
414
571
1230
1937
1044
2962
2157
1105
238
288
1076
951
2062
1347
1272
1121
2931
1280
1934
1947
753
2416
2375
2474
1116
714
2151
1463
2985
1162
2610
2054
2379
722
23
2851
1572
522
2250
701
2211
1920
2680
2000
1387
293
1277
1428
1261
1657
3054
883
1053
2221
1344
1679
1588
2915
300
2889
2421
1611
2029
2963
1795
1198
1703
1535
1362
2845
2577
684
398
1074
2197
279
2831
458
406
1662
2012
2764
146
1854
2804
2308
2898
2139
321
576
379
1245
908
1200
1576
1558
168
145
2728
115
2514
165
540
383
242
245
2275
608
2819
1503
1223
61
1792
1479
1926
261
1754
1282
1972
2663
2330
2450
1436
3022
29
1984
1403
1689
2938
2048
1305
825
924
187
2390
1712
600
2209
1774
659
2113
841
329
896
2098
2114
809
723
1397
1377
2352
413
2703
2731
1768
2707
4
2871
2565
2087
287
1796
577
1051
2332
2981
128
2097
2015
2538
2344
2142
589
278
148
1325
1357
816
142
2213
1422
1954
2553
82
2077
106
2631
2682
410
2215
1813
2498
1104
1203
2321
1501
1686
297
1250
2630
2547
147
1742
2805
1165
1823
180
2234
2270
1722
2471
2130
2912
857
88
1909
1531
1327
1330
1809
2004
706
1037
2445
2397
1533
3012
2383
993
2549
457
615
1232
1999
573
273
2608
2807
1806
2830
2530
527
1569
1851
2050
1132
1281
952
1153
189
560
209
1146
1605
1752
698
510
299
1530
408
2586
1685
112
2240
975
1907
1960
2671
2988
501
1359
1445
6
746
104
2975
38
1034
2743
1955
2659
2763
2440
751
2569
1451
1699
603
1697
1929
85
2348
474
1493
1257
2479
1056
1527
1892
2488
956
1273
3
430
1911
803
2888
1406
619
1721
867
756
45
3066
79
1898
782
2967
2839
2860
1825
2592
1444
249
1741
1683
819
665
647
2217
1846
766
971
2372
1365
1747
1736
2665
1837
1287
1302
2803
1068
94
1340
752
1705
1197
1708
791
599
765
990
2849
2777
2011
2958
3048
1728
1023
742
781
1591
1386
958
2283
419
175
1026
1961
2641
155
2895
13
2060
266
2296
2766
1224
2152
758
1356
736
1885
1101
2331
1613
2606
797
296
2112
2475
897
2799
221
2765
1424
2789
2451
2522
869
2466
3068
934
2791
884
921
2971
2353
86
2861
1311
1247
2537
2232
1634
2645
1875
1950
2769
121
2526
1727
2689
900
2768
2527
2738
909
720
2673
1152
612
1483
807
1052
2995
1392
503
1070
2970
623
2759
1061
574
2561
555
1065
3000
798
2010
2088
1417
2517
1433
1833
384
2269
738
374
1579
812
852
794
2948
2387
2419
2685
2266
1944
535
1963
2513
8
715
417
1915
1075
1725
1512
1329
2059
1894
1783
1872
1147
1801
2376
2461
1294
73
2852
1246
277
3016
1249
2506
1462
193
42
3071
602
1255
2173
2917
1905
1263
711
970
1720
1110
1593
818
1174
874
1265
2716
1495
2120
215
690
2206
1467
1567
2558
2310
1177
2596
773
1293
1941
2843
1668
1548
1992
2824
1541
893
2081
2733
2465
360
1906
1547
2258
2906
1412
330
3065
2873
1913
2825
3018
1904
2041
888
3044
976
2315
1270
1001
828
1018
516
1889
2869
2380
2259
1316
754
1004
2333
1744
1536
2989
1980
2192
2203
959
2712
673
131
1080
1306
3001
2256
1269
2756
2239
2997
1522
1713
1649
1115
1618
190
2288
2188
2454
2911
2116
2859
2622
2747
2918
318
2838
1859
1490
1442
2013
605
1935
2493
1288
1996
2473
1477
1746
621
977
1057
2956
649
2870
2293
2991
==11011== 
==11011== HEAP SUMMARY:
==11011==     in use at exit: 208,808 bytes in 1,027 blocks
==11011==   total heap usage: 1,032 allocs, 5 frees, 249,900 bytes allocated
==11011== 
==11011== LEAK SUMMARY:
==11011==    definitely lost: 73,712 bytes in 3 blocks
==11011==    indirectly lost: 135,096 bytes in 1,024 blocks
==11011==      possibly lost: 0 bytes in 0 blocks
==11011==    still reachable: 0 bytes in 0 blocks
==11011==         suppressed: 0 bytes in 0 blocks
==11011== Rerun with --leak-check=full to see details of leaked memory
==11011== 
==11011== For counts of detected and suppressed errors, rerun with: -v
==11011== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1023
+ test 3073 -lt 1023
++ sort -un
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1023 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3073 OUT_N=1023'
shuf-reservoir-sampling failed with IN_N=3073 OUT_N=1023
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 1024
+ INPUT_LINES=3073
+ OUTPUT_LINES=1024
+ seq 3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1024 -o out_3073_1024
==11020== Memcheck, a memory error detector
==11020== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11020== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==11020== Command: shuf -n 1024 -o out_3073_1024
==11020== 
--11020-- WARNING: unhandled syscall: 326
--11020-- You may be able to write your own handler.
--11020-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--11020-- Nevertheless we consider this a bug.  Please report
--11020-- it at http://valgrind.org/support/bug_reports.html.
437
335
407
1839
967
824
112
884
841
2927
1170
1529
1217
1033
659
193
900
1006
2652
1330
713
737
2140
1400
1407
2091
303
599
107
1703
757
2524
2032
770
2123
2150
2895
2760
2074
2298
2349
1938
1848
1970
386
197
2197
1753
1242
1275
594
1309
2216
1180
1090
2174
584
1274
966
1447
68
1469
2234
1841
2608
2755
436
1412
2122
2817
920
1733
1173
1186
367
781
2191
1437
2480
451
385
2657
1355
1263
328
40
2993
1845
1314
1065
2302
1618
148
1842
13
494
741
1008
1952
1349
1455
1882
2141
686
2236
1171
129
1877
1832
1886
726
1544
826
717
1115
720
20
1977
1694
429
2769
1821
265
1140
1417
740
21
365
2965
2533
97
542
2598
1606
2272
2585
614
2183
1794
1510
569
1927
1764
2843
353
1717
2481
709
44
1210
817
338
2621
2987
1864
852
1684
3022
912
1119
1415
559
2009
445
2562
2853
435
1948
1855
369
1956
984
1932
383
940
2311
2392
1786
2527
165
1543
1830
45
2829
2212
225
714
1890
2905
2073
1690
759
2741
123
450
120
255
2712
221
2713
1646
379
2345
2645
2898
1527
2250
222
1626
997
2856
743
310
2225
2665
2826
287
2194
2439
531
592
143
1760
88
2089
1268
247
733
1118
651
1054
2851
261
1342
314
424
1454
2000
1814
1341
1331
3006
226
480
1632
331
2529
524
2822
396
1908
1163
923
801
2022
2108
1586
2425
1317
752
2615
501
38
1244
1049
1565
1517
3053
2455
2614
1246
1321
1046
2121
237
2871
2731
530
1943
2119
1399
1290
502
1371
2909
2327
2783
1810
2747
477
2797
2068
358
504
2886
2901
2882
1093
2051
1398
71
1754
1442
2456
1868
1366
1411
347
761
1021
2647
2328
1403
2573
216
475
2457
1260
1051
927
2415
1148
1816
2413
1
2207
2042
926
24
2057
1691
1044
2721
969
2247
2743
2729
1562
1697
2331
1470
419
1570
1254
500
838
158
1491
2192
1954
390
1392
90
2003
1574
156
911
589
84
874
1474
2334
1929
2734
2476
1052
2782
1603
278
854
333
236
102
1905
2942
1759
1775
2169
2337
2238
1513
1303
1700
1511
1577
913
1477
1678
1318
1961
1255
1397
2928
418
60
2625
2840
1390
181
661
995
2088
2697
1551
3013
257
1024
27
1190
2878
1487
2572
882
1870
896
544
2863
1508
1542
389
823
3069
496
2278
2641
990
1334
1602
1980
1909
2201
2933
573
1199
2113
677
2893
2424
853
1362
1152
426
2384
2803
233
2144
2078
3062
1926
639
585
395
872
2946
2879
150
53
1005
433
1353
2419
289
2110
2756
2688
2617
54
2874
86
3072
9
2139
1767
2507
95
978
2686
1993
2768
1726
1292
74
11
1751
793
693
1902
1934
1007
543
957
1664
1739
609
1666
2240
1609
1449
132
441
774
147
1649
1645
827
2787
499
1498
938
715
2825
3009
813
845
2002
464
2814
1867
2021
2530
481
1583
3035
1077
290
2658
1322
2109
550
2219
1480
925
991
2055
2314
76
2663
131
1708
2550
2821
55
1945
2168
2143
2561
2373
615
1892
1616
2462
1423
1682
482
2677
564
1904
174
373
2364
203
2377
1524
2228
1663
1634
1652
299
2038
1540
2133
1043
2765
2370
2574
1035
2065
1220
381
251
2700
2142
397
2383
1539
2274
1493
1097
2818
2757
2566
2720
1107
1580
1284
130
1072
2599
1319
2953
279
731
1885
1704
2526
1316
1622
2244
1584
797
789
167
636
1370
2944
503
470
999
1989
1394
378
687
447
2914
1509
1526
637
488
546
1878
3014
675
1050
1962
2667
305
1800
886
1790
814
1677
392
510
2362
2930
1401
571
301
2786
909
2961
1460
1637
1844
810
2811
2394
858
1973
1719
691
245
2475
1157
1451
2085
105
1482
219
2733
432
654
725
847
2992
1154
2511
2452
1778
1133
56
787
982
516
2634
1888
1002
2360
324
710
371
153
1121
521
889
2581
1279
745
2118
541
1967
2644
2824
1566
2559
1738
2048
3026
2184
2509
2111
2374
2592
2633
357
93
2342
253
182
246
822
2297
1205
64
837
2899
319
1955
602
489
880
1156
2771
2167
916
2100
1852
1105
103
1045
2131
932
2090
2916
907
1880
2624
2308
514
655
462
443
2891
260
1117
1655
851
199
684
1990
2603
2693
1095
2369
772
409
472
2531
540
2681
1145
2254
2053
1747
755
1438
2541
2616
1505
1056
1419
1114
1846
2631
2748
2251
2588
2642
634
649
1896
1085
2998
1922
391
1731
2972
698
2505
302
2371
2607
1216
1326
2163
2288
1132
3033
1774
2098
879
1141
734
3048
891
1027
3001
2305
2332
1060
1383
2794
1519
1351
785
1225
640
1025
688
2699
2855
1873
2943
699
2453
2058
2321
1755
2083
2758
2682
1061
1078
2447
562
2553
2303
795
2773
1240
2838
1439
1293
2406
3037
185
1711
987
1064
2796
2395
2204
1084
3049
704
172
1184
590
195
1478
2955
862
945
979
2980
628
2862
2767
1169
2988
2161
2125
2701
1629
2974
2569
2918
816
1581
2264
67
1784
1776
658
1136
2069
234
667
1750
399
457
607
534
1595
1076
2411
2268
43
2674
749
1101
2333
2470
1766
2036
1856
2745
656
668
101
2158
973
2054
747
1066
768
893
1742
70
648
307
1340
1859
1464
762
42
601
1207
1554
1530
2135
1798
1434
360
1556
2687
1546
2705
1557
2281
2976
1209
145
1894
2322
1861
2837
1235
535
800
1174
346
376
808
2213
377
773
2890
1059
2147
2075
583
1699
812
2831
730
1995
1338
2589
2830
1797
3029
1548
2060
836
2070
2784
1092
2597
975
2604
2361
1660
361
2842
1273
133
3047
479
1094
92
176
695
1596
1889
2160
905
1272
2023
1264
1237
2832
217
1587
1689
262
2565
127
2348
1620
109
753
2136
493
==11020== 
==11020== HEAP SUMMARY:
==11020==     in use at exit: 208,976 bytes in 1,028 blocks
==11020==   total heap usage: 1,033 allocs, 5 frees, 250,108 bytes allocated
==11020== 
==11020== LEAK SUMMARY:
==11020==    definitely lost: 73,752 bytes in 3 blocks
==11020==    indirectly lost: 135,224 bytes in 1,025 blocks
==11020==      possibly lost: 0 bytes in 0 blocks
==11020==    still reachable: 0 bytes in 0 blocks
==11020==         suppressed: 0 bytes in 0 blocks
==11020== Rerun with --leak-check=full to see details of leaked memory
==11020== 
==11020== For counts of detected and suppressed errors, rerun with: -v
==11020== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1024
+ test 3073 -lt 1024
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_3073_1024
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1024 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3073 OUT_N=1024'
shuf-reservoir-sampling failed with IN_N=3073 OUT_N=1024
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 1025
+ INPUT_LINES=3073
+ OUTPUT_LINES=1025
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 1025 -o out_3073_1025
+ seq 3073
==11035== Memcheck, a memory error detector
==11035== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11035== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==11035== Command: shuf -n 1025 -o out_3073_1025
==11035== 
--11035-- WARNING: unhandled syscall: 326
--11035-- You may be able to write your own handler.
--11035-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--11035-- Nevertheless we consider this a bug.  Please report
--11035-- it at http://valgrind.org/support/bug_reports.html.
367
325
2514
1295
1033
2864
2485
1598
1458
743
2677
1494
1543
1600
1214
3039
519
2748
314
243
2165
978
2495
888
516
214
2928
2985
1802
776
2726
2272
55
1348
380
2730
766
852
2285
1024
1707
1062
2999
2710
1212
2071
2743
2781
2233
2126
241
1499
1235
1222
2413
2612
164
1052
1788
677
2687
2548
1816
321
2786
2434
1673
2307
2896
204
2670
1708
560
1384
768
377
2281
1583
467
2344
2443
2239
2220
2392
290
264
1790
254
645
1437
647
1654
851
1459
2049
2907
1645
1400
2550
1890
78
420
2044
1333
1521
513
59
1984
2181
2706
1200
1574
1607
2067
994
1194
706
1321
459
1395
2576
1166
2558
1301
1013
1560
2693
1431
3024
2059
360
1509
551
289
1483
2569
1085
1061
703
1579
2765
1198
1414
2152
248
413
639
1682
774
2912
738
1905
2007
2941
954
3064
1332
1256
2534
82
1725
2212
2879
693
1834
1589
1575
137
1092
2011
721
2828
2256
785
2639
562
1581
2950
2736
299
338
1577
1266
2780
315
2373
1884
2857
1139
1783
844
238
2458
643
1396
1699
2802
222
2015
1382
1088
2048
1522
1234
1274
346
1218
1277
530
1365
2428
2531
2415
2909
1892
1462
1685
45
671
818
2720
2539
1907
609
181
365
1476
1116
1018
1325
847
232
701
2952
1225
2528
2500
1750
2986
1123
2123
1664
2169
1878
2226
121
31
398
2242
930
324
2767
2356
2660
1163
102
68
2977
152
198
2190
23
1353
2243
2309
1469
1953
919
820
1840
2487
775
2757
1659
528
3066
1153
1609
2729
1254
960
2080
981
600
2938
9
2785
1747
2782
2870
1960
2644
132
484
2996
486
195
1646
1895
951
1534
898
877
1076
2376
1980
931
2878
1460
1315
184
1702
1946
2064
2871
1489
2089
359
1119
2738
444
1804
991
1882
1141
83
2316
2282
2547
2055
362
1647
65
60
1434
1388
2849
2788
682
3010
1377
1243
855
2151
154
1312
816
1667
1189
2471
2915
2280
2329
1435
2629
2000
2337
2218
310
2254
526
586
2685
1003
1087
2552
2634
1422
2674
2696
1078
733
1004
366
1850
1216
2178
1794
610
2219
1467
131
1668
1426
893
2656
1098
2461
3028
2432
1930
1389
1030
1206
1742
2467
2662
896
1340
1506
179
2383
1903
2449
395
2472
2973
881
1889
2904
1057
2217
2291
74
2703
25
793
1968
906
1669
2426
2075
1888
1006
2920
2745
1696
1852
759
2003
2704
1576
1642
1773
897
842
1404
734
1610
499
133
2881
962
1937
1811
2005
2107
549
2565
2433
2691
224
235
2363
757
300
2617
2400
612
723
2352
921
2106
2171
613
627
2303
571
2842
1370
1456
2163
2032
2837
328
3003
1932
1676
2230
2412
2553
660
2245
2299
388
36
2323
1780
1976
2741
582
2274
2515
1569
2507
1767
2887
1029
533
2917
1599
2397
501
2465
1022
39
1693
1248
2082
976
2506
469
758
2001
1869
1867
1481
853
2410
2807
2559
428
1916
3063
2237
617
1187
99
1341
1271
32
2646
2969
745
1335
436
1323
311
2580
518
700
2228
1727
1653
2752
256
391
2894
2
2079
918
2637
1752
284
1313
463
789
2622
943
298
795
2028
740
1442
836
415
1585
2375
2248
1847
1288
2698
2295
50
641
543
2643
744
2984
849
952
1763
1282
2101
2334
2116
2859
2588
2045
1874
2499
803
3060
887
2820
419
2068
1269
762
944
2792
1683
1643
2268
2944
278
271
2683
1740
2427
770
1190
1157
2389
1520
2520
779
2605
403
2989
1338
2695
2025
1255
51
2619
2512
148
2812
1628
750
2600
304
2498
3045
185
1893
2841
119
1101
2933
736
806
1985
1705
2860
2658
5
138
792
52
1009
2772
891
1921
2892
971
1879
1858
614
1710
1484
552
547
1793
1147
3026
2753
2919
2626
2960
2069
2182
2653
688
1755
2311
334
2764
1525
1186
1686
1237
200
716
2328
1862
2320
2158
69
2424
2838
280
2414
2924
2809
189
2238
1132
1648
2721
1613
424
1872
1818
2359
3031
1774
282
835
421
1949
619
1100
2250
1247
1415
1411
2240
128
1488
556
913
18
1909
1021
2793
287
1526
3005
2555
307
1055
1086
2343
2408
126
1751
2982
1102
2770
3052
175
106
1362
949
76
262
100
1508
3036
356
2162
2174
1432
2061
1447
666
167
1233
2987
1908
668
1038
371
2371
883
632
1939
2327
84
1891
477
1174
1387
594
350
2650
2214
2714
714
2571
258
2203
2094
1451
698
1548
376
1717
1970
2884
446
3057
326
1902
525
2801
1276
905
2930
1753
724
423
1963
2160
1227
1069
605
353
449
705
112
2125
2570
923
2975
3030
2742
482
1838
1881
1109
658
159
2850
2955
1541
2492
2394
2686
890
679
542
62
550
2122
1934
2970
616
2566
1099
1428
263
2827
1318
1927
1346
1329
2709
1238
1514
7
735
140
2927
2304
684
2099
2338
1650
2589
1133
2131
2654
2084
433
2326
270
160
442
354
130
1498
2491
1082
2737
884
1183
2573
375
1122
2386
1735
637
615
2331
1911
234
1973
457
319
381
103
2086
755
1063
349
2494
748
791
1375
2700
1733
322
611
2716
1016
2466
889
1681
854
2946
1803
1604
191
2308
872
1614
313
2183
2448
2054
1961
2074
1290
2943
1378
1419
574
1495
369
1715
1178
1286
2811
1466
2888
838
1924
2697
2081
2367
2066
1015
1093
2947
1910
537
1026
1859
2377
122
2362
406
1777
427
1661
2723
927
502
71
3013
786
1253
824
2993
2232
689
1125
2664
438
1047
2556
3021
394
576
1155
2997
857
2899
2088
2846
400
1260
1523
1630
1211
1191
212
2462
2926
1478
1694
1112
778
2549
975
692
1072
2140
16
1814
2831
1762
941
1978
2699
1126
341
363
1265
1464
642
790
115
1376
293
2421
2594
1950
1714
1657
1219
2399
==11035== 
==11035== HEAP SUMMARY:
==11035==     in use at exit: 209,112 bytes in 1,029 blocks
==11035==   total heap usage: 1,034 allocs, 5 frees, 250,252 bytes allocated
==11035== 
==11035== LEAK SUMMARY:
==11035==    definitely lost: 73,760 bytes in 3 blocks
==11035==    indirectly lost: 135,352 bytes in 1,026 blocks
==11035==      possibly lost: 0 bytes in 0 blocks
==11035==    still reachable: 0 bytes in 0 blocks
==11035==         suppressed: 0 bytes in 0 blocks
==11035== Rerun with --leak-check=full to see details of leaked memory
==11035== 
==11035== For counts of detected and suppressed errors, rerun with: -v
==11035== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=1025
+ test 3073 -lt 1025
++ sort -un
++ grep '^[0-9][0-9]*$' out_3073_1025
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 1025 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3073 OUT_N=1025'
shuf-reservoir-sampling failed with IN_N=3073 OUT_N=1025
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 3071
+ INPUT_LINES=3073
+ OUTPUT_LINES=3071
+ seq 3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3071 -o out_3073_3071
==11043== Memcheck, a memory error detector
==11043== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11043== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==11043== Command: shuf -n 3071 -o out_3073_3071
==11043== 
--11043-- WARNING: unhandled syscall: 326
--11043-- You may be able to write your own handler.
--11043-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--11043-- Nevertheless we consider this a bug.  Please report
--11043-- it at http://valgrind.org/support/bug_reports.html.
3009
180
2528
2509
2866
1348
22
2829
1635
2683
2372
1017
1806
1324
452
2668
2110
140
1089
2852
528
993
2166
1771
3048
2687
886
1357
1127
1326
800
2324
1061
2590
765
978
1253
2890
205
807
2739
2486
1209
1720
2887
391
2053
1672
2824
2587
339
105
190
2275
1134
3016
2424
2964
1456
1149
520
2603
546
1180
1561
2278
3059
433
488
1634
2665
1669
299
3055
1410
2639
2072
2843
1546
2967
2681
256
320
815
744
1521
1297
878
1398
2041
2231
2024
62
2226
2974
213
483
1994
1312
903
2173
2002
12
543
1045
1529
1411
2655
119
1445
2798
2940
1871
959
784
1218
836
1423
1311
560
770
523
1825
1360
635
27
932
3065
521
928
856
865
2981
1845
2303
1731
963
2656
2626
318
1035
1142
149
1698
2920
1947
2564
1313
2801
3024
1900
1391
2116
898
990
122
2634
1471
1654
1280
752
1540
1025
1475
224
1109
34
2425
624
2178
1071
2807
384
486
2034
2348
2563
1936
2478
1987
410
2645
203
2301
2066
1857
1751
2385
2071
731
1707
3069
2680
1618
2143
2833
470
131
2799
2264
1255
1379
2923
2781
1479
2268
124
587
185
580
1346
946
991
2678
2120
1905
682
1779
916
1917
2883
2185
1680
2167
2759
2452
1500
250
2732
104
1840
54
3011
2310
2783
169
1491
889
1920
1103
1670
1075
42
873
757
1469
957
1024
2363
1333
1790
545
2774
254
1512
1449
333
3007
1628
2762
3073
297
1129
1143
2825
3001
2615
2788
639
2338
285
1235
2109
2370
1433
2806
2755
2240
531
1170
2125
287
2819
1531
1522
404
1581
1458
2241
2145
1755
1474
2868
2848
1543
1018
173
326
2600
305
380
930
937
894
2353
1432
2996
1589
2397
1740
2051
989
2188
537
2642
2146
2108
1234
293
879
2737
361
515
1551
776
1051
1527
2597
1997
2556
934
2576
346
2472
151
1427
2853
275
2653
573
329
858
2513
1993
2493
232
1770
435
441
1675
281
411
2581
2880
491
2818
2731
101
2735
476
588
1278
2846
2849
1060
2978
602
1332
2828
2061
2968
1632
2080
399
1605
2575
1125
850
1101
1939
2896
2316
355
1224
1565
2186
1792
368
2592
92
781
1462
1289
2932
743
2104
2062
1037
244
2068
3039
202
2208
1258
2077
97
341
2202
372
1345
110
1221
2987
1055
620
788
212
2876
511
41
1643
1315
1206
421
2540
759
2365
1452
2078
2813
2477
388
1496
2081
1497
950
1776
2307
1150
2935
2038
1985
425
26
473
1144
249
2623
789
1834
912
223
1559
444
1940
2990
114
1981
2701
2184
2228
201
1310
774
200
2014
2001
59
1567
1323
524
694
2246
78
952
1227
2075
1722
999
2389
1207
2794
1457
1619
3061
1480
1922
1622
106
63
365
1889
2088
2287
2473
2040
1558
1062
1723
1963
591
1891
1205
363
2657
2136
628
818
259
619
2635
917
2495
684
216
1487
2017
2465
1548
32
1319
925
1040
2354
855
2122
1542
44
2445
1502
1483
2270
1789
1767
1430
554
24
1116
2252
1466
263
2289
2476
1079
1277
499
1599
2921
880
3043
2523
2884
1949
703
1298
2035
2437
651
150
1894
16
1564
7
984
892
2021
740
769
748
1352
577
386
2697
1164
2733
2025
1503
3049
762
737
229
2392
1014
58
1899
958
1021
2011
2608
18
440
1627
2347
2708
1657
2999
845
566
2577
117
2529
2512
2096
1283
412
108
2671
1732
1691
988
1892
67
1686
301
193
2918
2579
923
1785
1703
89
2939
1835
1772
1830
260
806
375
549
965
1354
242
3029
548
707
2601
884
1868
2822
1441
221
1823
2391
2039
2244
1902
2358
2618
1105
436
1612
705
2651
478
2742
1145
246
2296
1856
2044
867
176
338
231
871
2658
2271
2148
814
767
698
1832
1435
2736
1926
1013
667
2004
165
2753
2399
2605
1601
1069
1477
2729
2595
2236
317
1176
2469
2468
1302
39
2675
1837
2537
2937
2229
1220
2718
641
2346
2892
1421
1190
2042
2909
2013
23
1415
785
2666
1020
1633
1829
1102
2224
2016
3053
144
208
2709
933
741
1237
1716
2692
1272
1714
2127
623
2382
1118
1419
2593
3068
2052
900
1276
626
2238
1534
2489
821
1065
3012
841
2906
80
2559
344
693
248
797
30
2750
1991
2991
1030
2305
701
1375
1972
2274
431
84
389
2795
362
910
1501
962
2079
2961
1861
1746
3041
240
2785
977
829
415
1685
2364
3028
1532
2412
271
2444
1629
392
1572
1304
1921
1873
112
601
2449
1903
2749
742
1350
1513
901
1213
1507
1453
258
69
1499
987
1515
2812
33
2027
2309
3025
532
1759
593
2285
1294
1090
1687
70
2823
2172
443
237
634
1
2432
95
2613
1557
268
2471
1645
2816
1944
1295
2751
1516
109
1250
1380
2369
1851
1268
1824
2112
1547
536
479
764
2158
1470
1248
2565
585
1831
2702
1990
2337
1587
390
31
2566
512
3020
1677
1538
1847
1591
1359
816
40
739
1665
1010
2431
255
1695
1198
773
1762
1489
192
1676
79
1068
1130
1872
235
732
1022
1299
490
2281
663
2138
1519
1957
454
1165
25
553
1907
19
1562
1146
1828
2984
2438
2878
697
332
725
103
1928
1363
1796
2694
2376
1385
2499
2588
2555
1273
579
1362
2938
2734
2162
402
1378
2617
2113
656
1465
1730
187
1481
1167
2335
2429
631
630
170
763
2903
351
714
2505
2005
1566
1797
107
1303
2265
1948
2861
64
1613
653
2282
1576
45
2594
2149
671
876
711
2076
2067
2949
501
1251
1616
2539
1318
1898
547
1067
2942
2858
3035
2686
654
1275
1818
2398
1653
1401
1642
1911
81
724
367
2250
729
2221
2524
1974
839
2374
1484
609
1964
369
36
2640
1859
188
1617
1488
416
485
158
2815
2020
2129
2857
621
576
2090
1292
1979
2793
754
2792
981
2384
1364
2993
1955
1033
1992
1598
882
810
640
3066
450
803
2098
1655
138
1147
2092
2015
820
225
823
1734
1803
2413
87
1864
1437
902
1736
2684
534
1761
2922
91
969
437
405
2904
1893
2356
1777
782
234
1570
2345
1774
2256
230
1849
137
2205
700
2741
220
1444
1745
1178
666
595
2754
1100
716
1034
1764
1737
1966
1817
1381
1878
517
2111
2943
1649
1775
2998
2960
2258
1239
401
1463
1159
2924
1595
1614
2830
625
1935
438
98
2873
2091
133
2176
2395
2320
57
611
1741
442
643
2
1193
924
1242
2386
1933
1624
616
720
1092
376
1942
2381
906
2845
3006
2121
300
1204
1699
2659
125
207
2761
2131
2217
1760
1181
887
184
2696
678
919
2482
4
1574
615
1989
2147
1644
2879
637
728
851
2177
2842
1096
1028
178
2085
1057
1744
1400
121
2118
787
1673
316
2361
971
2714
93
2767
2094
1367
1608
86
2514
465
552
572
2726
2500
824
233
2607
2463
1081
2155
504
429
1182
283
2730
649
793
2558
2086
1260
330
373
1203
1439
2543
3051
2483
2099
695
72
648
2443
970
1733
191
432
2780
2492
2994
264
2877
2277
1915
979
1114
2163
239
2456
796
2897
755
1729
2826
1631
1843
1504
2573
464
863
1008
1048
2047
1197
1626
2406
2474
1264
1780
1257
1711
1855
55
1293
2366
1396
1742
1925
1719
2230
1738
1897
3019
2602
2522
46
1106
1171
1681
1003
2685
658
335
1666
2817
2144
1322
3004
551
1844
1243
2074
2834
2115
1778
2033
1794
143
455
1727
73
139
749
2496
2171
680
1270
2498
1196
2485
1710
2019
594
2379
2980
2609
2582
911
43
2679
1195
2586
2899
418
2570
2102
567
842
1049
2204
1420
307
243
2636
614
2460
1495
688
2632
1958
709
2965
1812
868
2706
115
974
2057
514
1309
1536
2517
2341
1552
1679
913
838
2891
1179
2839
2049
1999
3017
2313
1111
2417
1184
2652
2554
82
1397
3023
2267
689
189
1819
507
2698
1607
1087
446
422
2532
461
1073
1122
1808
994
1656
802
472
1464
1086
3070
2773
1604
3027
1339
343
1802
530
2352
1271
269
2199
2669
182
1015
1019
831
840
175
396
3057
914
646
2288
154
1678
2677
669
1514
1056
1023
1046
753
1846
3072
347
1800
679
277
1215
938
1119
2448
257
1402
1426
2649
1910
1651
3042
2725
768
1036
2095
1229
2154
466
1412
2501
1340
1384
955
453
1602
348
1329
2198
2140
2087
1583
3034
1307
2836
1141
1094
944
1214
642
691
1579
1341
1429
843
2889
1370
1671
949
2103
1316
251
2159
1290
2045
1647
2744
172
885
527
1718
495
778
2247
2928
282
1523
1285
304
726
2362
238
998
935
309
2768
1160
1217
1854
1281
696
370
1553
2663
2538
179
2638
2925
718
1652
1403
2263
1356
2627
204
1054
2557
1877
2447
2546
10
2487
2948
834
1447
1715
509
2624
126
1603
194
1236
1660
1325
132
699
2902
2840
795
539
1486
1533
449
3071
1838
2262
1135
1418
2123
1609
1287
2752
2467
2804
1305
1684
2860
1406
2864
2459
1539
2165
2182
1152
2950
617
2959
17
596
296
533
76
2869
1757
1954
424
1783
1274
1749
1230
308
181
1798
1810
1058
1799
2314
1506
2667
1509
846
1128
1530
2380
746
733
1763
2286
2764
2670
1327
1706
6
2462
2914
3064
1726
2809
1593
1863
60
908
8
2183
311
1428
430
2970
427
1813
1066
1809
357
1210
2239
1590
997
2533
2789
558
1212
2715
1848
1050
2519
1269
2620
2403
2233
1927
1586
2654
660
518
2507
1175
2643
2259
1694
2769
1938
2551
342
652
664
2222
1786
857
1978
525
1544
2350
3045
2330
2031
2625
687
1950
2151
881
37
360
854
198
1405
2572
2311
2631
927
2821
337
657
1650
1416
2022
1241
710
2910
65
51
2908
475
1641
1582
1394
2082
2054
1916
2633
215
468
1136
581
569
2491
2502
1343
2907
1858
1265
662
2791
2302
267
761
1183
1219
1946
1525
2130
1460
1815
1735
3018
1668
129
276
3033
586
604
738
2194
954
1674
1983
1839
692
161
127
2048
2986
2622
508
825
676
603
417
214
471
439
943
1126
2292
310
383
519
2988
1697
2580
1063
1517
1836
2518
673
702
2441
2693
2977
1185
1334
779
1446
134
2195
2777
303
2553
2606
2280
2026
1351
1080
1156
996
780
2434
1841
606
1112
1259
2695
506
1473
2128
1201
1417
535
457
2719
2854
1084
1189
319
647
1372
2895
1639
1511
1476
2329
1168
1007
1132
2030
3037
2779
2203
2713
2814
2966
747
2421
2064
2648
2831
1001
1342
168
1392
3054
2272
397
1139
2273
408
2488
1881
49
2484
102
1929
2979
2661
197
2682
2220
3067
1169
100
292
2757
1291
2628
315
2549
1240
942
90
3060
2929
1747
1115
1282
2911
1914
2401
157
1296
1245
1980
1254
1573
3008
893
2490
83
2357
2728
526
1876
1120
21
2283
915
2820
2786
2870
2616
1696
2454
1833
1261
414
2983
760
152
1279
2046
2905
2881
819
2261
2294
2083
336
1366
582
832
340
1138
2243
1580
469
1875
1791
2321
730
2972
325
859
400
1078
833
2410
864
801
3030
1535
1485
2152
2442
280
1752
830
645
1148
777
29
1098
493
1188
1440
2298
1555
1353
2404
2212
674
1000
1773
1968
1577
2349
986
2541
374
359
2510
771
1754
2426
1976
1263
2355
1494
1194
822
2336
1409
1097
2841
1967
1347
2458
2197
2919
1887
2989
1941
2589
2850
2257
2160
1478
2953
1768
130
2470
261
896
2720
2344
2164
2213
948
745
522
395
2506
809
1155
2248
1266
2504
164
2227
14
385
1880
211
2201
2544
1630
1882
2497
2562
1827
420
1286
1931
2758
2494
2058
2156
2552
2746
2318
622
1560
2611
1386
650
2279
1959
2319
941
3044
690
1659
1161
2142
960
2420
1814
349
1620
1042
1459
1336
382
2745
378
945
2254
2018
1545
2339
2219
1804
331
2778
1308
655
1578
1317
2894
1909
52
1820
1690
2716
727
805
3046
1822
1945
758
2782
1074
2503
1374
289
722
1373
1389
2610
1330
1358
2650
686
2689
1443
2119
2043
113
2676
1918
681
247
2175
2810
1528
550
1191
922
1795
2427
837
2036
2646
1895
2290
2916
2805
1157
2360
1173
1093
2003
394
1059
2455
1267
559
790
659
808
2351
118
274
1321
1493
2179
1621
1091
1717
1044
734
1879
1961
2433
1154
869
1850
2242
592
1524
28
489
1016
381
222
228
2124
1314
775
2461
1667
2571
772
589
2089
481
2508
1434
2073
1610
2135
632
1702
568
2161
940
284
877
2915
38
314
2340
1784
2711
1244
398
423
1117
1438
366
2917
2323
413
266
2411
2105
1594
2200
68
939
2827
1490
2867
480
1153
409
1123
503
94
2673
897
2946
904
2466
496
2008
2327
2567
1662
2700
544
2284
2790
2958
1006
2644
2418
1960
2723
584
575
992
750
2756
1200
2388
47
141
2585
1867
2126
1252
2591
3036
1563
1177
445
3038
627
2419
2956
860
1361
2100
2885
811
2927
195
1986
1365
1043
1223
1482
1526
1901
2971
1853
245
1750
590
1002
872
2875
2707
1431
598
210
1556
2196
2249
1335
136
2954
155
2797
1468
460
2430
2705
1700
2312
804
1661
74
1811
1505
2237
2874
2012
354
2032
1041
2325
1826
253
2760
783
1288
1549
1076
1338
1908
1301
2621
936
393
1870
2985
2535
2378
1424
2000
2037
2187
2976
1600
61
1801
2050
1965
1300
1371
2604
1937
1454
2293
1975
1793
561
2941
2629
2322
458
2863
976
1436
717
2872
1388
1451
848
929
835
2306
1472
2808
2851
813
1874
99
1969
1906
1072
1575
2009
888
2516
2664
578
2901
2457
2710
2766
1998
661
505
2525
3032
2192
665
2569
1108
1890
1982
20
2913
931
294
1592
1805
2331
2561
35
2402
563
3063
1977
2023
1088
467
3010
2775
160
2069
2453
1222
111
456
116
498
2898
2141
1520
2093
2190
2690
2855
964
2647
448
2674
2771
2520
2029
1442
2326
975
751
961
2882
715
312
2180
1739
555
2612
2545
1769
1640
895
2191
2232
2214
1233
358
1393
1211
1510
2150
1554
2560
2055
1971
1166
120
2428
982
1104
217
677
1663
2266
313
3014
1408
2660
135
11
1238
2511
177
605
1377
494
171
672
852
1085
3013
1331
3026
2063
2772
334
252
262
2342
1919
542
2169
167
1467
2740
2260
426
1995
1728
2995
2475
1414
510
2721
2333
967
2308
1422
2886
2672
2218
1026
1888
324
2763
2930
419
1782
2835
2859
1077
2304
2568
377
1137
1009
844
529
2373
2738
883
1174
2862
2059
1247
1637
953
153
209
236
817
1664
2796
5
2982
826
2170
2770
2007
1110
2747
2992
2765
2888
541
3031
1692
186
735
985
500
607
2207
3050
1912
2153
995
1866
2439
2451
2269
2446
2383
2480
2952
1172
459
66
2962
574
1450
1682
1140
1005
2371
1956
371
2944
853
2139
3056
2748
1962
2440
2423
1070
2010
3000
356
1932
564
1052
2479
1721
899
1765
1407
1368
1053
2334
1355
2390
1376
2174
1095
1569
1996
1199
905
291
56
502
1029
613
48
794
1705
3015
1158
920
1952
1187
2871
2574
474
2743
2963
2947
2548
1344
1124
3040
2527
273
403
870
2703
218
2137
265
2699
907
278
926
1011
874
2134
968
629
50
2255
2409
2838
2234
3003
2712
2367
174
2414
2724
272
712
77
1724
1383
2209
1884
2276
1636
513
1192
2837
434
1615
2856
3
156
2394
302
2359
1099
53
1930
321
1588
148
2415
2619
2408
352
2802
484
562
1683
1787
1701
799
2727
1748
1712
1032
1349
1973
1031
2315
2060
1448
861
2975
1743
983
2300
2973
1571
583
516
15
2436
636
875
298
2945
2097
708
2530
2387
2934
88
1004
1246
600
1984
2800
406
571
2803
1461
1455
1807
1883
2328
1766
2253
123
145
1518
612
791
1107
3002
1508
2189
1970
1151
918
1704
2193
972
540
2598
1611
2931
2933
891
2691
3005
1228
2106
721
2206
675
1320
2450
1951
2630
1382
3062
1753
447
951
2776
353
1039
2847
2515
379
2114
2534
2215
241
1541
2157
1262
13
1369
3047
1623
183
736
1038
2641
2210
862
1550
1113
1646
2407
2521
1328
1256
1821
477
1756
2464
1568
2299
2599
1606
1924
2028
290
1404
159
1082
1869
1163
565
599
1133
1781
849
1596
2844
2596
668
2416
2056
2936
2133
1399
1498
827
1658
1249
556
2317
2368
2584
828
713
756
1121
2235
723
2084
973
1862
786
2969
85
2550
2547
618
2614
1625
557
2997
1913
2951
638
2132
1131
2107
866
2223
966
610
1202
2006
1709
75
1648
1413
1923
812
719
792
463
2393
1860
1186
947
2400
1337
2832
166
2637
1886
1865
2422
492
2435
227
1027
487
1584
206
1162
345
2297
2251
1284
1988
387
1226
1842
1387
2526
128
1788
1708
2225
428
295
1425
1492
2101
1688
2295
2717
1896
462
1232
2787
1064
644
1934
2722
2070
1597
219
1208
1953
2926
909
199
1231
2688
2405
798
270
1904
2811
497
597
683
706
766
921
2211
323
482
96
2065
1047
1816
2168
2481
2955
2117
1852
1012
2912
162
322
226
1713
1758
2245
142
847
1083
279
2784
538
2893
670
1306
2396
570
407
1885
2531
3052
2291
1216
980
328
2332
2536
288
2865
71
2583
306
2542
327
1943
956
146
2343
364
2181
633
2578
3022
2704
1693
147
685
2216
890
2662
608
1395
350
9
196
1225
2375
704
1638
286
2900
1390
3058
1537
3021
2377
163
1585
1725
2957
==11043== 
==11043== HEAP SUMMARY:
==11043==     in use at exit: 520,136 bytes in 3,075 blocks
==11043==   total heap usage: 3,080 allocs, 5 frees, 643,052 bytes allocated
==11043== 
==11043== LEAK SUMMARY:
==11043==    definitely lost: 122,896 bytes in 3 blocks
==11043==    indirectly lost: 397,240 bytes in 3,072 blocks
==11043==      possibly lost: 0 bytes in 0 blocks
==11043==    still reachable: 0 bytes in 0 blocks
==11043==         suppressed: 0 bytes in 0 blocks
==11043== Rerun with --leak-check=full to see details of leaked memory
==11043== 
==11043== For counts of detected and suppressed errors, rerun with: -v
==11043== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3071
+ test 3073 -lt 3071
++ sort -un
++ grep '^[0-9][0-9]*$' out_3073_3071
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3071 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3073 OUT_N=3071'
shuf-reservoir-sampling failed with IN_N=3073 OUT_N=3071
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 3072
+ INPUT_LINES=3073
+ OUTPUT_LINES=3072
+ seq 3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3072 -o out_3073_3072
==11051== Memcheck, a memory error detector
==11051== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11051== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==11051== Command: shuf -n 3072 -o out_3073_3072
==11051== 
--11051-- WARNING: unhandled syscall: 326
--11051-- You may be able to write your own handler.
--11051-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--11051-- Nevertheless we consider this a bug.  Please report
--11051-- it at http://valgrind.org/support/bug_reports.html.
550
2557
3051
919
378
2336
1783
1472
980
487
138
2940
285
2713
1404
845
775
3044
103
345
412
577
1340
826
4
1768
2018
1560
2083
2926
818
1308
459
230
737
1432
2028
730
618
1316
721
2841
584
1586
2241
1573
897
268
2556
418
1639
2816
266
2618
1559
260
2233
3036
245
1516
2344
2030
2978
1130
167
1887
2200
1997
21
456
2422
94
1932
3047
2741
1468
632
2116
2484
1395
8
938
2682
971
1605
411
583
2622
936
1506
1144
707
1321
2705
408
1648
726
315
973
1901
2188
2237
999
2538
2406
3052
1012
1495
203
1937
2828
3070
76
346
603
629
1011
1413
2938
2490
1959
2649
1621
927
733
1608
2380
1239
316
1549
1740
1660
169
2320
2606
515
675
1206
1715
1736
2055
883
2132
1352
929
474
2476
842
649
205
1090
1700
1979
2144
2289
2572
571
745
1839
1953
1571
1905
862
25
2985
1611
1010
1343
143
1576
2767
1112
303
2045
1763
208
537
2290
2138
2748
690
1797
2079
2793
373
2779
560
3013
80
1351
2862
838
2185
106
1134
2207
2373
2360
2254
684
1174
596
2949
193
704
2224
1849
1193
252
719
97
355
2122
1298
1940
243
331
224
614
1163
2559
492
1947
2950
1336
2689
600
234
2603
302
110
930
1486
2783
361
1089
2324
327
1564
2967
1208
1227
246
807
1348
1211
1195
1943
740
367
2433
1268
1569
836
944
2840
947
1779
2306
2845
993
2384
2558
2073
1814
2478
2082
1716
1928
405
60
1437
1015
3037
3022
2635
2446
1148
2246
523
2387
2637
2131
2602
1770
2165
2727
78
1906
137
2924
2889
2325
186
661
2375
872
2611
1742
1254
1946
1626
2721
332
2494
750
2215
1976
1359
542
2814
2908
1233
2784
70
1454
1521
350
2524
3035
2888
1261
293
36
756
3049
2988
1439
1188
546
1394
1387
54
2839
122
1420
2197
2800
2032
2498
175
2512
1470
1282
2050
522
2176
320
1718
1800
891
2376
2718
848
1721
1991
2288
541
2379
1292
2734
689
859
1602
58
1009
347
152
2355
2607
457
1431
1071
1744
267
1904
178
43
3040
455
88
1614
1776
2666
2811
371
1880
819
2838
2904
2434
1558
2214
935
622
204
987
1382
1023
2536
397
1864
2043
1944
449
686
1156
2090
2421
1568
2041
1655
1286
2385
2898
295
115
2398
2242
1350
145
813
1386
2366
1851
2157
1476
364
2660
2115
5
1285
1707
2533
1331
2745
2939
1183
2761
3065
524
941
793
876
2267
1083
1701
2955
297
900
2238
444
1512
469
870
1324
2868
1970
1977
2719
573
3043
428
2826
2608
352
1186
2065
2001
131
1251
1695
871
1262
1861
617
2746
538
2833
1982
1842
1380
3057
3001
2164
2567
2228
2444
773
1088
752
763
616
2842
1368
2971
254
1752
1491
1277
1236
2410
2774
1868
289
158
710
780
1375
1965
1975
2726
610
1717
1167
127
1473
1667
429
530
687
638
2160
809
2801
206
2191
1504
2189
77
2139
1620
1969
1787
430
235
2151
825
2163
997
2121
475
977
2744
1747
990
2294
13
17
633
1661
2995
747
908
2128
1809
2913
1879
886
1584
2782
71
95
2469
404
949
668
162
983
957
2989
896
2756
29
1874
1858
1017
2409
2937
2270
434
1753
1278
725
1920
2007
34
1596
384
892
1318
1207
2508
959
1042
1638
1907
1008
1228
1575
594
1706
1625
2154
2965
2807
402
2824
150
1793
3014
1881
89
1917
2870
520
1155
1948
1035
1100
2414
2677
3016
2303
1416
1633
2155
1161
677
2462
368
477
2331
2496
2273
2692
801
1367
2683
216
323
2077
48
2576
2529
2125
620
1553
2634
536
1149
443
151
2548
213
2552
251
625
2503
2885
1021
1841
480
855
1820
136
985
380
2220
898
778
1517
946
2944
1771
766
185
2549
1406
2796
811
1196
1287
1746
2998
1545
2068
2281
2364
1477
369
1872
445
1215
1886
1085
1893
2835
1213
2305
2020
2037
1671
711
1915
2470
104
2311
2175
2849
1813
1428
2287
2555
1173
1971
1055
1327
144
673
392
2039
2872
2361
108
479
2597
1443
2056
1983
1426
2896
98
2388
462
2370
2110
1234
2617
1150
164
1315
2169
1064
2945
1852
1020
1647
797
2127
2703
1191
2451
393
2312
1092
1684
1651
2837
2571
3046
2657
374
2785
580
1379
2130
2886
1402
2456
1891
2429
1845
2319
2178
1628
370
595
951
1120
1423
1446
1265
1449
543
2636
1108
1501
2763
1657
2014
647
2038
1631
2648
2969
1145
680
1334
391
326
1673
586
2777
20
795
1458
674
3
2869
1158
2141
2174
2846
407
1889
2799
2897
991
561
2519
2262
2393
1589
464
605
1342
2074
1669
1414
116
1640
2450
23
1249
1627
1260
1284
2672
2521
1066
2481
2620
2504
1253
1209
2629
435
554
2260
1410
799
2676
2034
679
1157
2982
2919
2316
2912
1778
2463
1488
841
2595
287
2313
2201
130
105
1837
2419
823
1704
1693
2010
126
851
1929
301
2580
1964
2513
1610
657
1533
321
1641
166
1117
1201
1850
2980
1930
1968
2791
2108
2631
453
1078
1616
1354
2737
1349
2679
1325
1178
2545
1391
471
113
2615
3000
525
2427
1827
1548
2248
2553
1272
258
1461
2105
1067
2630
1159
2960
2015
2593
419
2823
2277
1341
2684
1539
2359
514
2678
2979
1867
377
2861
39
2149
2764
798
968
278
2736
1346
1384
460
2265
119
2408
1931
496
1922
1210
2802
1765
188
1309
2467
1825
1378
2013
738
2511
2075
769
1696
2674
2244
2239
2532
2145
375
334
751
1519
558
2981
1595
612
2809
1070
329
1460
1203
879
2766
1762
857
555
1279
2170
1086
2751
2161
2523
965
3012
1992
582
1786
1679
2285
2086
2432
1135
482
1240
2906
2269
697
1805
720
1300
2973
1389
1076
1511
1935
734
1242
1004
1311
2831
3062
1095
1878
2345
648
519
948
1645
1466
2349
1125
1425
2435
1293
915
493
2645
1131
41
2124
1604
1165
934
839
796
2668
1127
2582
2022
3073
559
2438
2351
2227
774
1790
746
3007
1550
1918
967
1597
2012
2428
2111
1189
1523
2383
2158
2058
2725
2403
1900
2208
2753
3032
262
385
2296
507
1798
1666
2704
1301
850
925
1812
2488
170
2452
2585
51
572
566
718
664
589
1141
1001
1247
1949
299
1857
2873
651
549
212
2295
2661
824
1676
3063
2035
1824
2685
2968
1250
1154
1339
1419
1734
1664
2268
1160
1069
667
2192
1829
1644
2530
149
806
1855
484
2256
118
1609
994
358
199
2194
1875
66
755
1708
1713
535
1691
509
447
2247
2616
2447
1784
427
2907
1505
1109
1407
2147
2621
992
2198
1264
2720
1674
1689
9
861
1528
508
478
2724
2770
789
290
1451
2670
1456
2084
1199
1526
854
2947
590
2332
1942
398
2856
2323
2252
1540
1014
557
1927
1073
2223
1241
1690
1973
1373
335
2152
1051
1681
275
2396
2326
2903
1027
1848
2240
2990
2526
2458
2070
2109
446
2236
263
1938
389
834
640
2033
2453
1672
2579
2443
2477
676
2400
2226
305
1471
1025
2395
820
2101
2255
292
1524
2442
2757
174
6
1129
2598
2879
2368
1592
1345
2411
1218
1152
979
592
2671
1294
2333
1079
1364
2195
1018
2923
2321
1668
2722
2786
1297
1802
37
1356
242
431
1441
280
176
1474
1016
623
1502
2663
1585
1252
1304
2914
2999
424
1303
2729
2997
937
2539
531
1259
2547
1832
1817
2863
641
2693
660
2142
966
928
1484
691
786
670
2203
2253
147
168
2066
528
2977
2381
1190
511
981
286
1735
1869
1822
1054
233
866
2586
2698
1132
226
1525
2808
2851
880
1579
42
654
2021
2102
1022
156
2653
1854
1452
61
2890
2909
2565
2537
708
3038
2181
1223
562
2825
1846
237
1463
2017
2309
2404
1273
1580
1552
1865
635
181
639
135
2499
1043
1498
912
1939
141
1162
2067
974
869
863
1833
274
1871
101
1399
270
609
1710
338
712
1310
265
2640
1577
2542
743
2946
619
390
30
2747
581
2389
2974
1405
2993
1430
1412
2417
2025
1185
1919
1258
533
1093
1263
767
1863
1360
2850
2210
2798
1128
1147
2230
1424
2959
626
2633
1544
2952
2810
49
953
1219
1421
2347
1987
3027
2570
2790
73
884
2202
2691
1377
2483
2743
1465
1101
139
3021
1030
2186
1396
1612
2314
2550
1925
314
64
1172
500
1232
995
1448
1950
2162
2688
1049
2439
630
656
1643
760
1281
2515
2596
1299
2695
227
438
713
790
757
1485
2266
709
642
606
2701
1877
198
2204
749
2092
3054
1623
2292
2754
2954
351
853
903
1570
3061
762
703
133
1995
2382
1563
1911
2087
588
905
2575
2060
539
1755
400
1328
229
1317
1598
2707
2953
2805
3071
2911
35
1761
1529
1894
942
52
1221
1455
776
2459
1899
1453
1283
2561
924
2527
123
2830
2732
1357
2554
1607
597
2762
360
923
2675
1789
2401
44
46
1926
1836
922
1411
681
1381
349
279
381
2601
356
304
1487
2881
2815
1756
1489
1777
1957
933
2016
3033
1530
1988
2460
621
1057
1226
1665
1050
1758
1941
312
1457
255
827
1990
432
2895
2418
16
1555
1111
1483
2566
1986
2883
2531
182
916
728
2935
2568
2159
2681
1280
2584
724
3053
84
2263
372
2061
2107
3029
1006
2662
1114
1041
2991
506
231
2134
2307
2466
1003
2327
1562
154
830
298
1507
1409
885
516
2272
2528
2264
28
701
376
1624
843
1116
2612
1433
2702
2480
2405
1256
2765
2183
2996
2129
264
1068
2304
1729
1972
228
1118
3023
1764
2803
1910
1136
2088
172
173
1601
961
1749
598
342
2482
918
984
187
3002
2733
2308
2625
1440
2857
585
669
910
3059
2044
2758
646
1581
1372
2525
1459
2468
1652
426
653
1115
1923
341
2920
2788
1397
294
563
2315
1773
1702
3034
2049
2742
683
1745
911
744
2148
2271
2497
768
1096
501
2471
1818
100
2573
1637
2792
1725
1642
2278
599
211
15
134
1467
2081
2948
2583
1811
513
2963
1767
473
1766
978
31
2091
1417
239
578
2714
1870
1326
569
2975
822
2686
109
470
909
2002
2943
982
1685
2042
1103
2518
3060
717
1591
2577
631
1561
1588
1370
920
2878
2179
128
1176
1945
878
1170
1072
120
914
1775
2697
1122
3039
2352
153
325
1220
1723
7
1048
2880
92
939
722
521
1843
160
2740
1374
1121
1810
18
3010
2441
2004
2642
2057
1146
225
467
210
505
551
2509
759
2397
1094
1058
1542
2346
107
2535
2569
1355
2106
2392
2455
483
2302
1312
1617
2064
283
448
1107
1748
56
1980
723
2153
1567
2643
57
2700
921
694
11
1687
2420
2166
2544
363
85
190
2436
2957
783
2986
1670
1541
976
702
2235
867
1952
1365
1422
3058
829
2813
2300
1270
2853
2209
2412
1583
2027
1138
865
2251
601
1494
1333
386
422
1557
1804
2899
1662
1291
1124
215
1862
881
1438
931
1840
192
742
1808
1222
2342
72
3015
1955
1536
1574
700
2852
1202
777
2624
2818
3066
1924
895
1204
645
2966
1344
2098
1322
1594
2930
784
2005
2492
652
276
644
1442
1999
313
1337
698
1996
1224
1077
2749
2348
2738
366
2284
1434
2341
2942
1383
420
1709
1061
2069
1478
579
821
634
1823
3025
888
1760
2887
2860
2964
1275
2541
2299
2257
218
184
1246
489
472
3068
1338
815
3028
1682
1369
926
1622
2961
1044
770
1913
950
2391
1974
628
157
1063
2437
758
2245
794
2514
2031
2416
1032
62
1985
1618
74
1200
764
1565
553
779
2918
1896
771
202
2654
1266
1727
111
2003
3048
195
1332
406
112
1587
2019
2367
817
2190
337
1960
932
2000
2587
50
324
2987
282
1578
1490
608
1815
828
340
840
451
1720
1500
2877
735
2475
207
249
1133
2487
1143
96
1847
2282
2627
1371
2374
988
2709
2696
1699
2893
627
1791
2357
2711
1166
2699
2006
1184
2279
963
986
241
1921
382
1074
2690
2638
899
442
3055
1509
1179
1821
14
2534
2855
271
1543
2613
2641
1951
2917
2293
1785
194
1556
2972
1782
2213
2225
2371
417
125
2780
2413
2970
2063
901
217
53
964
1859
3004
1479
2864
727
2578
736
2884
1492
129
2892
1750
132
2297
2024
1401
1181
1075
1772
1358
1898
1884
2574
3031
454
1496
1305
1966
2340
2114
3026
2599
236
220
2992
2787
2854
146
2390
1892
2243
1513
2168
1912
2510
1
2286
1319
2706
671
452
2486
2900
272
1806
2337
209
2029
1537
1045
2036
2759
1205
1031
2901
2464
2291
2844
343
989
1091
658
2369
2665
1445
159
2137
972
396
1028
440
2167
1194
1902
191
1615
2218
1000
2605
2426
2234
1123
2933
1958
2328
2094
308
2221
1005
2867
705
1403
180
1385
2259
2472
1302
2415
2931
2182
2581
1954
2501
3020
281
3056
688
1989
663
2517
2473
552
10
2773
201
1646
1831
2187
1177
2506
1105
12
142
250
1993
2921
2301
1450
2078
2647
2562
40
310
1714
1630
1703
696
1296
1060
357
1347
2843
1680
261
121
570
2902
1276
548
450
1039
27
494
2760
2173
433
1739
952
956
1759
787
2335
1447
1978
79
67
846
2023
1866
2983
2932
306
2343
1098
2445
1834
2822
2072
2832
82
1722
1888
1119
1363
2184
3024
2491
1392
476
2516
659
2217
2834
1603
1388
2656
1168
311
1481
875
2011
2440
1038
792
998
2339
1711
2358
3011
636
219
1099
504
2905
602
556
1534
1981
1288
2461
1885
741
1636
2479
2258
568
1769
65
2172
3072
359
791
1998
637
1497
685
1738
2874
1408
2768
238
1113
844
785
2730
624
1650
567
808
1730
1856
319
2652
486
485
1053
1062
831
2135
1429
545
2177
3018
1844
1175
257
1572
354
2076
1059
409
2495
889
1531
1366
1686
1527
1724
2664
858
1828
2457
678
1688
253
1741
2772
1566
2180
1046
1237
2350
2628
2821
2283
1427
1731
179
2099
847
2085
1065
197
753
410
2739
2750
2560
1732
3006
63
458
399
2026
2322
1164
330
2280
715
2752
1212
26
1267
2275
604
2875
1659
1019
436
2910
240
491
803
1503
732
2871
1599
1590
318
772
2680
2522
1510
2394
1514
1600
90
1110
1056
804
574
1751
1171
1329
788
148
526
1984
1967
907
1217
960
291
2362
576
2769
1593
2755
1214
1909
611
2639
2858
2052
2540
223
3009
2093
1582
1634
1677
1520
2250
2071
1835
2140
1230
3050
2232
2781
874
2206
1801
877
1794
1697
2193
2715
805
1554
2120
996
1436
437
2591
1047
288
2543
2775
3067
24
1705
2646
2876
214
2916
2619
2089
2962
695
812
2866
2778
2231
2485
962
2604
890
1493
662
945
2922
1499
3030
189
421
244
2009
902
19
1678
2600
2146
2407
2096
1883
2059
1737
163
1398
527
2941
309
1390
2609
2717
2493
2658
2363
1034
2474
2143
413
575
461
1619
2817
672
2008
171
1037
200
387
1142
75
2994
2489
852
1361
856
2667
2794
613
1400
2673
1082
339
1482
2632
2735
1140
499
1137
2053
2047
2100
22
868
1013
1306
2797
2353
1353
1255
2820
860
2112
655
2592
2520
365
587
1551
2934
954
761
2430
1733
1726
591
754
2216
1295
1719
1803
59
564
2399
1469
1908
3008
1087
2062
277
2103
117
2310
1754
2104
2847
1393
1257
1694
1036
904
1052
2590
544
2716
1040
1102
2123
607
1153
1962
1248
248
1838
247
124
2804
488
1080
666
269
2614
837
2097
693
1613
2795
3069
643
2171
816
1522
1307
2431
2196
1515
3005
887
1320
502
2731
1508
114
3045
913
259
344
1290
1547
2205
729
2274
2589
2564
2644
2710
615
1649
955
2
2424
2728
2500
1243
3003
969
1418
353
498
2454
893
2378
1104
1882
1271
2507
1663
1658
1415
832
650
196
1187
32
1933
91
849
93
1007
529
1780
1635
2334
2329
47
1462
221
1244
328
2465
1895
540
1903
1830
894
833
2318
1994
2812
716
1269
1480
1330
379
414
1198
1029
2365
2423
714
2712
468
69
2505
593
2338
2771
1182
3017
1097
1781
2040
1546
401
1225
1235
333
1033
1606
2330
1656
2626
1698
183
1876
1535
1807
68
532
781
2882
1963
2859
495
943
1860
1890
2951
2080
2386
2806
2650
765
1238
1653
2610
1151
307
2377
2317
1335
835
2708
1126
1231
2827
161
55
800
1084
2048
441
2502
1362
155
1180
2119
2594
2133
2095
1106
2212
2819
222
2354
1916
425
510
970
1245
2976
300
1914
882
2928
1795
518
336
2448
140
1464
2936
1956
565
1712
975
86
731
2669
1024
3064
362
1796
2136
917
383
2848
416
1197
2199
2776
439
45
481
1289
2894
1313
864
1819
1654
2372
2298
2156
2984
2117
906
2118
1435
2356
1444
2276
1629
1376
1632
3041
2836
2126
810
1792
2865
1961
1274
232
2051
1728
388
1538
1139
802
102
1816
2829
3042
1081
87
2219
1774
748
739
2551
1323
83
2546
682
1532
1192
1934
2054
317
958
665
2261
503
2659
348
38
2211
322
395
1314
1757
547
1873
394
1002
517
1692
415
1853
1799
2915
273
1518
2449
2958
1826
2563
692
2687
1683
423
2249
2425
81
534
2402
2588
497
1026
2891
2150
940
1743
3019
782
463
2929
1169
699
2694
1229
165
256
99
177
466
814
2046
2623
2655
465
2229
706
512
2956
2723
1897
2651
1788
1675
296
2222
33
284
490
2925
1216
2113
2789
2927
1475
873
1936
==11051== 
==11051== HEAP SUMMARY:
==11051==     in use at exit: 553,040 bytes in 3,076 blocks
==11051==   total heap usage: 3,082 allocs, 6 frees, 774,268 bytes allocated
==11051== 
==11051== LEAK SUMMARY:
==11051==    definitely lost: 155,672 bytes in 3 blocks
==11051==    indirectly lost: 397,368 bytes in 3,073 blocks
==11051==      possibly lost: 0 bytes in 0 blocks
==11051==    still reachable: 0 bytes in 0 blocks
==11051==         suppressed: 0 bytes in 0 blocks
==11051== Rerun with --leak-check=full to see details of leaked memory
==11051== 
==11051== For counts of detected and suppressed errors, rerun with: -v
==11051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3072
+ test 3073 -lt 3072
++ sort -un
++ grep '^[0-9][0-9]*$' out_3073_3072
++ wc -l
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3072 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3073 OUT_N=3072'
shuf-reservoir-sampling failed with IN_N=3073 OUT_N=3072
+ for OUT_N in '$TEST_LINES'
+ run_shuf_n 3073 3073
+ INPUT_LINES=3073
+ OUTPUT_LINES=3073
+ seq 3073
+ valgrind --leak-check=summary --error-exitcode=1 shuf -n 3073 -o out_3073_3073
==11062== Memcheck, a memory error detector
==11062== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11062== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==11062== Command: shuf -n 3073 -o out_3073_3073
==11062== 
--11062-- WARNING: unhandled syscall: 326
--11062-- You may be able to write your own handler.
--11062-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--11062-- Nevertheless we consider this a bug.  Please report
--11062-- it at http://valgrind.org/support/bug_reports.html.
388
1757
2332
1900
2162
2006
293
2252
2391
590
2936
462
2154
1084
714
474
1961
546
1583
458
207
139
1491
1313
1439
2087
1403
1151
896
2560
2492
1884
488
2677
2680
889
2340
2107
2612
1804
550
1362
1705
209
2946
2917
2017
2134
2674
2437
864
2701
929
1673
1284
594
2249
925
2743
1417
1733
977
255
1553
1807
1108
2213
2086
510
2601
690
2214
63
1850
2516
2536
819
2189
1201
1328
592
2375
1097
1253
227
2571
2976
2076
776
1430
1855
340
2819
602
1506
2447
2204
437
76
1415
444
2430
1776
2788
2021
2253
577
234
2395
2500
1468
1006
2741
1844
1061
1523
1199
582
2356
1432
5
2153
2188
2525
401
10
1310
2163
2715
1101
1051
2747
1263
471
1055
2496
2016
1964
2398
2584
882
2416
1547
835
1649
2818
1443
1112
38
2965
2644
658
53
1838
2295
2699
1153
1268
2675
1516
2248
2520
87
2125
1777
757
2011
1976
1300
1525
2422
910
2184
680
2510
384
2387
2269
465
498
2658
1957
1470
1128
1198
1810
956
2118
2386
2574
515
1329
95
361
1841
2630
2901
811
216
2077
2824
213
2461
2955
868
2622
2346
2072
451
311
966
2921
2846
232
294
2342
1319
1643
1485
907
2963
992
3026
1552
1680
3024
1980
480
1835
875
1536
57
1181
1745
1228
1032
2972
1311
1116
2003
196
2786
114
1917
2380
438
2655
3014
9
125
946
2212
2498
1744
180
1817
2798
2595
3013
1477
1312
171
2593
2553
1223
1688
152
2137
2200
2679
642
2117
170
1038
1364
1374
3021
802
2964
1801
4
2174
1457
715
332
529
1180
1521
985
883
1493
2418
539
1431
2666
3032
2182
1694
885
1121
414
1123
215
390
2568
2768
815
1939
2047
623
21
2890
2826
2100
2703
1127
242
2325
1749
2626
2146
2534
2239
2628
1542
2575
1462
880
2542
351
1778
2440
1974
2891
1239
2489
2004
588
1424
1891
753
940
879
708
2651
198
1330
665
2313
128
1134
1630
1907
1120
1001
1359
1279
2339
1623
212
348
2026
1527
2843
190
389
1046
869
1195
2458
2435
2952
832
1170
919
363
627
2482
1671
499
1773
1482
268
1577
2519
2132
1144
760
1534
965
1094
2167
2922
2685
1036
1590
656
2800
428
2055
2349
2513
2589
2123
2572
1033
1444
1990
987
2602
435
778
2459
2617
2993
1896
220
271
1981
167
1718
3033
1514
1648
1782
2293
2597
450
2116
239
2538
670
1619
360
2758
1517
711
27
2673
1114
568
47
2495
742
2549
1540
3047
668
2306
729
2565
96
349
2974
34
2187
1275
1498
971
74
2324
2639
1455
1792
1256
2210
771
1475
2404
1204
2871
1020
2588
506
2647
1000
3058
697
1115
326
754
522
1712
2041
2704
2228
2982
838
1522
2037
1828
2165
1467
596
1588
3018
376
578
1229
2219
500
3019
149
1338
3029
264
2348
2772
1190
1250
223
2950
75
1868
217
1171
2060
1363
265
777
1301
1174
1558
2341
153
1898
2234
3022
2344
2889
1860
1994
839
1550
2524
2383
1874
1035
1028
1695
1399
302
1425
1715
1742
2298
253
892
1575
3040
233
2615
951
2334
2369
1202
2947
1563
518
347
2180
507
2693
2559
866
2096
900
878
873
1391
1532
2854
315
46
2462
2610
1959
83
961
573
1584
1011
84
411
2577
1156
1579
143
2576
1109
1561
2983
455
1632
2935
1436
2222
312
80
478
475
2133
2720
1248
847
2294
741
2643
439
2381
3000
1387
159
1626
1137
1802
530
2336
1722
132
2347
68
2310
1104
244
1927
1296
990
1093
952
1147
2124
1236
1829
2566
1611
473
1702
346
724
2053
267
492
648
723
211
2856
2266
1901
28
3070
2733
2540
3065
1082
651
331
2027
1863
1244
2402
2541
2987
145
3034
2250
2687
2716
2681
2635
2464
2991
1060
1631
1594
316
672
1226
993
1489
1963
3012
2646
2203
2551
818
1305
865
1356
922
45
1483
2861
1237
2914
2942
2159
2695
1322
1726
622
979
2828
633
1812
470
717
314
829
2528
373
2509
3002
1820
1735
2940
2869
661
2129
1478
16
1037
545
2837
1335
2318
828
2690
200
2709
2563
2932
206
1442
2392
2875
2281
862
407
903
2414
1783
2114
2147
1653
620
1073
728
2817
1889
853
1188
1728
2810
2208
245
1767
194
2198
667
1720
2303
2046
2335
2211
2882
2755
804
1029
452
1997
2721
2034
1708
1546
2049
6
1076
840
542
2057
1003
1571
3054
1798
1559
747
767
721
2718
1852
2270
1074
1499
2847
2330
1975
1666
915
1811
2164
1647
1659
2870
188
2311
1816
436
1388
2469
2192
1179
1290
1110
1600
1628
1721
3004
2729
66
1876
1321
1087
2161
352
1950
1316
2573
2895
537
1183
766
1887
2001
2714
1931
2191
1837
556
933
696
2970
2322
524
277
635
118
1591
2708
1843
1775
1518
2669
1738
600
1099
1124
534
2158
817
11
984
1756
1385
655
2023
1474
224
800
1318
99
1369
2449
2073
1830
2264
445
2603
1945
456
2343
1350
2650
881
1139
1797
2463
887
2301
1578
891
2423
2079
2793
1255
2061
1287
2543
318
2455
182
238
2194
219
423
2777
1821
377
1332
35
705
2085
1606
370
884
2064
2518
1948
2790
2175
1687
191
2408
1672
1025
521
963
329
94
1656
23
762
599
2609
2552
2240
509
1005
2850
1826
2951
730
2460
1716
807
1118
2323
1225
2148
1441
1423
820
1822
1218
908
2717
161
1440
3016
3060
1211
969
2981
958
3063
2350
1146
2333
2279
273
2508
504
1408
1209
2759
1743
2031
2401
2379
536
1161
1266
2511
2033
738
2767
2474
1163
1449
1466
1873
1869
928
781
386
2202
2844
61
2487
2320
257
2614
160
1045
1453
909
808
17
1770
1530
2424
3039
1102
429
1464
2654
308
2608
1790
1421
1217
365
1982
410
783
1360
1624
1655
1059
531
1456
1786
497
1929
1854
1259
809
1187
1501
3043
2796
2832
870
1448
2360
2902
432
279
2517
2104
150
706
2795
773
2103
486
1703
2457
43
1086
2466
746
1317
973
1916
1684
295
140
201
611
2760
1682
1307
2439
1381
2090
1805
1760
2587
2505
632
1023
2206
2640
2236
1420
2337
100
3035
342
379
2857
2913
548
941
824
740
2684
975
2631
1302
2780
1562
805
1021
1736
2013
446
1946
1566
2877
3056
2905
2429
2307
2018
2366
694
942
2260
2378
1320
786
2130
574
629
59
2245
2606
2216
2105
2773
82
1222
1337
1479
2874
595
877
461
2095
654
2591
1572
2851
2135
2363
120
366
2671
459
3038
2977
624
2784
419
994
1106
610
368
2067
443
2012
275
98
2233
2106
823
876
2241
1487
1314
1189
1138
1205
673
745
2840
2839
2980
259
2918
926
2499
1238
1610
2753
2045
1368
502
1242
962
756
2098
291
144
157
1919
526
2990
1833
345
236
1969
2906
2169
662
541
736
1882
2258
503
1355
650
1191
2712
2038
3044
830
1747
147
1152
415
2697
416
935
2054
508
320
2792
37
660
2259
2225
886
2331
2009
652
772
42
1832
30
392
1160
825
359
1515
2160
1030
2934
645
1100
2481
1172
2051
3049
2599
77
433
1774
2237
1241
1050
735
2925
1159
1870
691
2924
62
2689
1386
283
358
1909
1904
1334
1535
1135
91
2122
177
932
663
3015
2653
768
165
126
1954
1814
1987
33
2683
2527
218
425
1352
1944
2254
986
306
1092
2063
3009
2166
1343
1281
982
1013
1926
1111
2022
1434
1560
2702
3
2288
2555
179
1554
2451
2238
793
115
2029
3052
25
41
1289
1651
1422
1692
2858
1789
1978
924
2694
1113
737
1788
616
1497
367
2975
700
105
109
73
2486
276
70
284
49
2692
110
2907
2782
1845
1679
2706
2247
1058
2201
2433
2686
2407
1979
1564
1165
1768
229
1282
1642
2578
2367
2019
97
2121
945
290
472
796
67
1288
1794
852
1064
913
1208
647
204
2275
1537
262
2583
2923
810
996
3001
955
2885
298
939
1984
704
514
2590
1589
1344
685
2232
1418
664
1419
1581
1062
770
258
1186
587
323
2005
634
2770
1806
424
2229
1930
2607
193
837
1262
328
2419
64
305
1380
788
927
547
1215
1500
678
1407
1719
1342
89
2860
2374
1041
1592
3053
434
2389
1971
1809
2811
1766
1861
117
3062
1674
1194
2453
1044
2475
1175
78
2791
1908
744
1646
2833
1070
1857
860
483
901
2393
702
1216
981
460
1409
1780
335
225
836
561
1952
1818
2746
569
2676
406
2849
1258
2802
1433
2771
2080
1699
2532
1819
799
2399
1958
52
197
989
2138
2570
2876
2415
850
784
3072
1157
1416
1555
2637
1254
790
2242
1249
1998
1942
2688
2638
181
957
2757
549
1762
2140
581
1727
1638
1017
2227
282
3057
1717
1379
2450
1753
1710
394
2530
1800
978
1031
2108
2287
960
2912
1371
2927
403
1366
774
1543
1009
1604
2357
2141
2879
123
579
980
246
129
266
2928
2737
797
1582
613
1897
2569
2448
2089
572
2896
1639
2417
1839
1764
106
54
1480
2102
2059
636
2672
1761
1429
2088
1048
1519
2221
2058
1427
1707
964
1251
1526
1989
558
1693
1662
243
1130
785
2351
1105
586
2382
1737
2292
1894
1007
2179
382
813
1494
812
1556
871
516
2807
1293
1700
2441
2099
1934
2074
2289
2550
393
2728
69
1587
1271
307
2142
1178
252
859
1143
1234
2579
2251
1616
2405
528
589
131
2805
523
2030
2745
2529
731
2315
1471
39
2564
2485
1851
2015
135
1490
1528
1197
1748
1660
364
1136
1367
2066
1899
834
31
396
2434
158
1609
2309
1512
2000
583
2713
851
2845
2660
2825
1306
362
1570
560
1040
1879
3067
2384
1696
1567
2938
2988
1847
1943
733
902
1315
608
2766
29
967
640
1454
920
2750
2656
597
2396
2507
1995
893
2707
1384
1968
185
107
2504
2859
1771
155
1677
334
1010
2642
350
260
261
1098
1725
1650
1831
2664
2267
1210
1644
639
2662
339
1383
1428
1438
1049
2050
431
2157
787
2724
1667
2764
1401
2353
826
953
2616
2866
1348
2641
1635
274
214
701
2774
1345
162
2996
1140
178
174
485
2881
1080
2514
1922
2926
1117
1732
1008
441
2385
758
447
2326
538
827
1389
1665
2931
752
1796
2864
2586
576
535
2776
2562
93
2465
2092
2506
496
1731
24
7
2411
814
374
1396
296
108
638
3010
564
653
998
1580
1357
2623
356
20
2809
489
1872
1670
872
2979
2598
2830
121
2494
1220
304
3037
2044
2035
1885
2989
3061
1906
682
1627
512
1016
1004
1286
3069
1524
739
398
2093
606
457
228
2749
899
2997
2304
1193
1991
1713
2317
2920
2648
1063
2150
897
250
1859
2789
248
176
3066
1447
169
1645
949
1085
343
2600
2042
249
2173
2246
2596
2145
716
722
1711
1691
1853
1612
2039
2567
1347
1273
2412
1921
511
1668
2277
1072
2814
2835
2723
2244
1787
2268
1661
1595
1985
1669
2052
775
751
695
2368
1026
2361
1823
281
1799
164
557
1905
1925
1676
1641
1164
795
2503
1078
1967
630
2992
464
1245
3020
2682
454
1511
111
559
477
65
2629
2172
2698
2127
551
1270
598
615
1260
643
2070
1973
1119
2815
2813
1378
222
1155
2887
292
806
2456
1148
2967
2751
1395
1739
544
1664
769
2711
2620
2752
405
517
2968
494
1858
646
1019
612
895
2852
297
2144
1932
1213
718
208
2078
709
2014
2081
1840
2278
2190
3051
2082
3042
857
2420
1132
2613
1827
2812
1261
1599
417
1507
404
353
792
299
2960
1207
1272
395
422
2491
1593
14
1460
1405
845
2480
628
698
1437
1598
566
1231
849
344
2787
303
580
254
1724
2668
707
1354
1107
874
2973
1625
1539
720
256
2497
934
1569
2838
2370
631
2352
2094
1983
1996
15
1912
2493
527
1955
136
1880
1295
355
1549
1913
1938
2624
1280
2502
1309
1463
1597
2421
2822
2444
954
319
2785
71
2848
1353
2806
1920
1413
2305
1410
1675
1022
3008
2966
1492
1538
1285
2742
2181
2065
1283
3027
1918
3068
644
794
1012
1663
1176
1294
2953
3003
1779
1125
1461
2394
2473
1601
1224
618
2183
1278
2376
369
2678
968
2836
130
50
168
727
1376
2359
2958
2880
2291
959
761
2476
1142
1867
2823
894
2633
2841
13
1928
2827
154
821
1763
563
2377
2831
2691
3030
337
1956
133
505
943
2761
2136
2627
1325
1813
2873
2409
1167
285
1068
525
2312
764
1533
2556
1227
90
554
1751
2794
1937
1520
2984
192
2328
409
2731
2112
2113
625
1910
841
2797
189
1895
2177
699
2665
659
354
1714
1267
1341
798
692
2477
1935
1529
1886
2744
533
1446
1158
2727
2365
1333
1067
2537
1972
2956
1924
2634
2314
570
2207
138
997
378
1370
1888
1484
2816
2621
2853
397
2126
288
1452
309
2110
1893
3017
2490
313
1704
734
1936
2533
2280
1654
1685
333
1349
2131
1585
1496
2220
1071
1605
1866
976
2427
669
938
2775
2710
912
2557
173
1903
2186
1951
2024
3031
1277
301
1545
2734
2998
1390
1689
2594
2544
1808
2478
950
2778
2781
2218
2470
1131
2872
905
1089
2230
240
1299
619
187
102
1652
2199
2834
2649
26
2548
418
1340
247
2878
317
2283
2472
3048
263
427
1875
2892
2431
2176
2765
2899
917
2300
2916
151
1754
1746
2619
713
2091
1077
1091
2111
375
2512
688
1459
2725
763
2645
1622
241
2403
300
2531
1196
562
637
116
2235
552
426
1923
833
495
2296
2930
479
2652
816
310
2097
1
575
463
2904
1450
2329
532
2390
1232
280
2413
1233
137
1002
1149
2285
1949
2425
51
22
1465
822
2151
3025
1683
780
1510
230
755
1095
92
2986
1056
55
843
1372
2868
1243
278
2605
1752
1548
2730
593
621
493
1965
1706
2883
1947
1658
1890
519
693
1402
1476
412
765
863
604
2256
2193
2581
2010
2128
614
1988
1505
1230
2808
336
402
686
2231
1856
2522
1246
453
86
1986
2255
948
2224
2893
605
911
371
914
2205
1608
2101
1634
2929
81
2362
2700
1629
2272
2937
1445
1640
88
2290
2971
801
861
2999
357
1122
2592
1824
156
2273
3073
2657
2756
2002
103
1375
1382
2632
1678
487
2120
1203
858
2919
448
2345
970
122
555
1849
2069
991
1162
1257
231
1451
12
2948
2754
1219
607
2604
1324
2820
2008
591
1126
2149
1240
1326
2722
844
683
1346
2316
2040
2265
2400
2446
1769
3005
689
677
2625
543
1331
221
1079
1298
995
484
134
1264
2804
657
3028
2705
3071
2515
2043
2007
226
1377
2738
2226
2978
391
1977
1970
327
703
119
1404
3036
127
2696
1393
1765
1603
2719
748
449
974
1303
1940
1027
1723
1141
1292
1047
2501
430
2732
85
540
183
2056
553
687
237
2479
888
1613
210
906
1551
2257
1034
2442
1392
1154
2276
324
2962
671
1339
286
2083
1637
1793
3059
842
202
603
2735
1269
585
325
341
1586
2939
1999
1088
184
1992
1690
2523
1336
2178
2302
2217
676
2274
626
641
2799
2119
617
1397
163
1750
2438
1557
1621
1412
1150
2071
2580
2915
2388
1574
2748
1166
1740
1274
195
898
944
166
1411
490
2865
1508
719
846
172
1024
1758
2855
2271
2358
2321
1145
2888
2286
1057
904
2661
36
679
381
999
1481
2156
1182
937
2284
1784
1414
2783
2155
467
1065
1081
1531
2195
749
584
1327
732
2521
1069
1878
725
2558
2196
2197
2957
1304
1054
146
1596
1865
1636
2171
3055
3046
1015
44
58
18
2484
2945
1993
1573
1096
1066
2028
2373
372
1075
2483
1795
601
2546
1043
988
972
1544
56
287
101
420
2109
2769
856
2663
2659
142
1701
1394
1221
3011
79
3007
2985
1486
2909
1730
203
421
1960
2263
567
684
1620
2900
2910
383
199
2338
2884
469
1902
1803
491
3050
1962
1133
867
1815
1435
112
1881
481
2941
235
2526
2933
1090
2801
1351
1871
1966
513
831
1426
2842
270
2428
681
1173
104
1741
1864
789
2032
1406
321
1308
2299
2954
675
916
400
387
2115
1185
609
2168
2959
1576
1842
1247
2084
2636
1252
1759
2995
2545
890
1834
1129
2535
2667
2
803
380
1892
983
3006
712
141
1883
1709
1915
289
1785
2432
2829
385
2944
1214
2897
649
2170
175
2547
1018
2327
2223
148
1488
1265
1177
1052
2994
1513
2908
2554
565
1618
674
1681
918
1503
1953
2185
2262
1614
1734
930
1602
2036
1473
1657
1039
2261
2740
1200
2410
2471
520
1565
113
2372
501
1291
186
1933
1686
1791
1781
2282
1836
1469
1846
2762
19
2969
3023
2803
1504
2143
2297
408
2539
571
2949
2779
1495
1276
1502
1914
2445
1083
1911
482
2582
1192
2075
2243
2209
2025
1458
72
1168
205
2862
1541
947
466
936
2426
2397
2821
1698
1235
1184
2585
2371
442
1323
1617
1862
931
1042
322
40
1941
440
2961
2726
1297
1398
1053
2670
1615
2739
2215
1772
1358
1361
272
124
2319
2763
476
2894
468
1633
60
750
1509
2561
759
1206
2911
48
1825
2736
2468
2355
1697
2308
791
2068
2886
2152
726
2048
1848
1373
743
848
666
2898
2436
710
2943
2139
854
782
251
2364
921
855
1729
338
3041
1568
1365
2903
2618
779
1014
1400
1103
3064
2867
2020
8
1212
2443
1169
1472
1755
32
1607
2452
2406
2611
2863
2454
1877
2488
269
2062
923
2354
2467
413
3045
330
399
==11062== 
==11062== HEAP SUMMARY:
==11062==     in use at exit: 553,176 bytes in 3,077 blocks
==11062==   total heap usage: 3,083 allocs, 6 frees, 774,412 bytes allocated
==11062== 
==11062== LEAK SUMMARY:
==11062==    definitely lost: 155,680 bytes in 3 blocks
==11062==    indirectly lost: 397,496 bytes in 3,074 blocks
==11062==      possibly lost: 0 bytes in 0 blocks
==11062==    still reachable: 0 bytes in 0 blocks
==11062==         suppressed: 0 bytes in 0 blocks
==11062== Rerun with --leak-check=full to see details of leaked memory
==11062== 
==11062== For counts of detected and suppressed errors, rerun with: -v
==11062== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ EXPECTED_LINES=3073
+ test 3073 -lt 3073
++ sort -un
++ wc -l
++ grep '^[0-9][0-9]*$' out_3073_3073
+ GOOD_LINES=0
++ wc -l
+ LINES=0
+ test 3073 -eq 0
+ return 1
+ fail=1
+ echo 'shuf-reservoir-sampling failed with IN_N=3073 OUT_N=3073'
shuf-reservoir-sampling failed with IN_N=3073 OUT_N=3073
+ Exit 1
+ set +e
+ exit 1
+ exit 1
+ remove_tmp_
+ __st=1
+ cleanup_
+ :
+ cd /home/abuild/rpmbuild/BUILD/coreutils-8.22
+ chmod -R u+rwx /home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX
+ rm -rf /home/abuild/rpmbuild/BUILD/coreutils-8.22/gt-shuf-reservoir.sh.JBvX
+ exit 1