>>108024848
something along the lines of this might be okay:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
constexpr int P_MIN = 32;
constexpr int P_MAX = 126;
constexpr int P_RANGE = (P_MAX - P_MIN) + 1;
#define RAND_PRINTABLE(R) \
({ \
R = rand(); \
R %= P_RANGE; \
R += P_MIN; \
(char)R; \
})
int main()
{
const char target[] = "Hello, world!";
char output[sizeof(target)] = {};
register int r = 0;
register int i = 0;
register unsigned int s = 0;
do
{
srand(s);
if (__builtin_expect(s % 0x100000 == 0, 1))
{
printf("testing seed %x\n", s);
}
#pragma unroll
for (i = 0; i < sizeof(target) - 1; i++)
{
output[i] = RAND_PRINTABLE(r);
if (__builtin_expect(target[i] != output[i], 1))
{
break;
}
if (__builtin_expect(i > (sizeof(target) - 1), 0))
{
puts(output);
}
}
if (__builtin_expect(i == sizeof(target) - 1, 0))
{
printf("found target seed :D %u\n", s);
return 0;
}
} while (++s);
printf("no such seed! ( ._.)\n");
return 1;
}
clang -O3 -std=c23 rand_hello.c && ./a.out