#!/bin/sh
# DF-5706 rig: extract the pristine memcchr body from the read-only kernel
# tree.  Lines 36..117 (function comment through closing brace) are taken
# byte-identical; the kernel-only includes at :30-34 are replaced by
# shim/prelude.h (force-included / prepended by build.sh).
#
# Usage: extract.sh <kernel-memcchr.c> <out-body.c>
set -e
: "${1:?usage: extract.sh <kernel memcchr.c> <out.c>}"
: "${2:?usage: extract.sh <kernel memcchr.c> <out.c>}"
sed -n '36,117p' "$1" > "$2"
echo "extracted $(wc -l < "$2") lines (memcchr.c:36-117) -> $2"
