// routecomp: VLEAF -- the 802663-leaf compaction (lane rc8_rv).
// Bound base: work/lane_rc7_rv/rc/e3_enh.cpp (sid 123200, 28.191 ms).
//
// WHAT IT DOES
// The `ne` site created one 24-byte SNode + one u32 g_pfx[] entry per input entry
// (802663 of them: 19.26 MB + 3.21 MB = 22.5 MB of the 40.9 MB node working set).
// Census (rc/cen1.cpp, byte-exact): `ne` 802663 / `nb` 658356; every node is
// referenced exactly once (orphan=0 multi=0); 84 066 of the 802663 leaves later
// RECEIVE A CHILD and are finalised (the trap rc2 named); the other 718 597 stay
// childless forever and are NEVER written after creation
// (late_a=0 late_b=0 late_c=0 at the `dep == L` site, 0 firings of the pristine
// early return).
// A childless leaf's whole node state is a function of (ev, L): S = 1<<ev, A = 1,
// own = ev, ent = ev, fl = 1, dep = L, k0 = k1 = NONE. 569 distinct (ev,L) pairs.
// So it needs no slot of its own -- only its OWN pfx, which is per-leaf
// (|pfx| > 1 per (ev,L) cell: max cell = 192 932 leaves).
//
// => tS[0..2047] : canonical leaf records, index `can = ev*33 + L` (can <= 2045
// because the existing guard caps g_m at 62 => ev <= 61)
// tS[2048..] : real nodes (root at 2048) -- `nb` plus materialised leaves
// g_lpf[ord] : the per-leaf pfx, ord < n
// child slot : RC_TAG | (ord << 11) | can (bit31 free: node idx < 2^21)
//
// The parked leaf (rc4's win 1) is now VIRTUAL: it has no `tS` writes at creation
// at all, and the parent's slot write is DEFERRED one iteration. At the next
// iteration the pop decision (`pendL > lcp`) says which of the two it is:
// popped -> stays virtual forever; publish the deferred slot write;
// materialised-> promote: allocate a real slot, copy the canonical record,
// then publish. Materialisation count == 84 066 == the census's.
// The deferred write sits in the pending block, which is BEFORE the pop loop, so
// the write order against the rest of the iteration is unchanged.
#include "routecomp.h"
#pragma GCC target("popcnt","bmi","bmi2","movbe")
#pragma GCC optimize("O3","unroll-loops","modulo-sched","ira-loop-pressure")
extern "C" void *malloc(unsigned long);
extern "C" int main(int argc, char **argv);
extern "C" void *malloc(unsigned long);
#ifndef RC_MAXN
#define RC_MAXN 900000
#endif
#define RC_MAXNODE (2 * RC_MAXN + 8)
#define RC_NONE 0xFFFFFFFFu
#ifndef RC_MVAL
#define RC_MVAL 64
#endif
#define RC_NOCHOICE 0xFF
extern "C" void *malloc(unsigned long);
extern "C" void *realloc(void *, unsigned long);
typedef unsigned u32;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long long u64;
struct P16 { u64 a, b; } __attribute__((aligned(16)));
static const u8 *g_raw;
static int g_n;
static int g_m;
static u32 g_val[RC_MVAL];
struct SNode { // 24 bytes
u64 S;
u32 k0, k1;
u32 A;
u8 own;
u8 dep;
u8 ent;
u8 fl;
};
static u32 *g_pfx;
static SNode *tS;
static int t_nn;
/* ---- VLEAF ----
RC_VB : first real-node index AND size of the canonical table.
can = ev*33 + L <= 61*33+32 = 2045 < 2048, because rc_run refuses g_m > RC_MVAL-2.
RC_TAG : bit31 of a child slot <=> virtual (childless) leaf.
ord : bits 11..30 -> g_lpf index; can : bits 0..10 -> canonical record. */
#define RC_VB 2048u
#define RC_CANI 2048u
#define RC_CANM 0x7FFu
#define RC_TAG 0x80000000u
#define RC_PFXB 0x100000u /* c>>11 == RC_PFXB + ord */
/* BRANCH-FREE pfx for a child slot.
Leaf slot = RC_TAG | (ord<<11) | can, can in [0,2048) -> (c>>11) == RC_PFXB + ord.
Node slot = a real index in [RC_VB, RC_VB+RC_MAXNODE) < 2^21, so (c>>11) <= 870:
a valid (never semantically read) index into g_lpb. Both loads are therefore
UNCONDITIONAL and in-bounds for BOTH shapes, and the select is a cmov -- a
`cond ? load1 : load2` written as a branch is what cost rc1_rv its +4.4 %. */
static u32 *g_lpb; /* size RC_PFXB + RC_MAXN; only [RC_PFXB,..) used */
static int g_nleaf;
#define NPM 0x1FFFFFu /* >= any node index, < g_pfx entries */
static inline u32 cnpfx(u32 c)
{
const u32 m = 0u - (c >> 31); /* 0 for a node, ~0 for a virtual leaf */
const u32 a = g_pfx[c & NPM]; /* in-bounds for BOTH shapes */
const u32 b = g_lpb[c >> 11]; /* in-bounds for BOTH shapes */
return (a & ~m) | (b & m); /* NO branch, and no cmov to be talked out of */
}
#define CNPFX(c) cnpfx(c)
static inline u32 cn_r(u32 c) { return (c & RC_TAG) ? (c & RC_CANM) : c; }
static u64 g_nbhi[34];
static const u32 g_m32tab[33]={0u,0x80000000u,0xC0000000u,0xE0000000u,0xF0000000u,0xF8000000u,0xFC000000u,0xFE000000u,
0xFF000000u,0xFF800000u,0xFFC00000u,0xFFE00000u,0xFFF00000u,0xFFF80000u,0xFFFC0000u,0xFFFE0000u,
0xFFFF0000u,0xFFFF8000u,0xFFFFC000u,0xFFFFE000u,0xFFFFF000u,0xFFFFF800u,0xFFFFFC00u,0xFFFFFE00u,
0xFFFFFF00u,0xFFFFFF80u,0xFFFFFFC0u,0xFFFFFFE0u,0xFFFFFFF0u,0xFFFFFFF8u,0xFFFFFFFCu,0xFFFFFFFEu,0xFFFFFFFFu};
#define mask32(b) ((u32)(0xFFFFFFFF00000000ull >> (unsigned)(b)))
static inline int ct64(u64 x) { return __builtin_ctzll(x); }
static inline int pc64(u64 x) { return __builtin_popcountll(x); }
static u32 vc_key[512];
static u8 vc_ok[512];
static u16 vc_val[512];
/* Write the 33 canonical records of value index j. Called at mint time, so the
`ne` site needs NO tS store at all (was 3 stores x 802663). */
static inline void mkcanon(u32 j)
{
const u64 lo = 1ull << j;
const u64 hi0 = 1ull | ((u64)j << 32) | ((u64)j << 48) | (1ull << 56);
SNode *b = tS + (j * 33u);
const u32 kk = RC_NONE;
for (u32 L = 0; L <= 32u; L++, b++) {
b->S = lo; b->k0 = kk; b->k1 = kk;
b->A = 1; b->own = (u8)j; b->dep = (u8)L; b->ent = (u8)j; b->fl = 1;
}
}
static inline u16 valof(u32 v)
{
u32 h = (v * 2654435761u) >> 23;
if (vc_ok[h] && vc_key[h] == v) return vc_val[h];
for (int i = 0; i < g_m; i++)
if (g_val[i] == v) { vc_key[h] = v; vc_ok[h] = 1; vc_val[h] = (u16)i; return (u16)i; }
if (g_m >= RC_MVAL - 2) { /* would overflow the canonical table; rc_run returns -6 */
vc_key[h] = v; vc_ok[h] = 1; vc_val[h] = 0; return 0;
}
g_val[g_m] = v; vc_key[h] = v; vc_ok[h] = 1; vc_val[h] = (u16)g_m;
mkcanon((u32)g_m);
return (u16)g_m++;
}
static __attribute__((always_inline)) inline void gt_contrib(const SNode *a, int dep_v, int ownv, u64 *Sc, int *Ac)
{
*Ac = (int)a->A; *Sc = a->S;
const int g = (int)a->dep - dep_v;
if (g >= 2) {
const int inS = (int)((*Sc >> ownv) & 1);
*Ac += inS ? 0 : 1;
*Sc = inS ? (1ull << ownv) : (*Sc | (1ull << ownv));
if (g >= 3) *Sc = 1ull << ownv;
}
}
static __attribute__((always_inline)) inline u64 childS(u32 x, int dep_v, int ownv)
{
const SNode *a = tS + cn_r(x);
u64 Sc = a->S;
const int g = (int)a->dep - dep_v;
if (g >= 2) {
const int inS = (int)((Sc >> ownv) & 1);
Sc = inS ? (1ull << ownv) : (Sc | (1ull << ownv));
if (g >= 3) Sc = 1ull << ownv;
}
return Sc;
}
static void finalize_node(int v, int own) __attribute__((always_inline));
static int rc_build(void)
{
int i;
t_nn = (int)RC_VB + 1; /* tS[RC_VB] is the root; new nodes start above it */
tS[RC_VB].dep = 0; tS[RC_VB].ent = 0xFF; tS[RC_VB].own = 0; tS[RC_VB].fl = 0;
tS[RC_VB].S = 0; tS[RC_VB].A = 0;
g_pfx[RC_VB] = 0;
tS[RC_VB].k0 = tS[RC_VB].k1 = RC_NONE;
struct { int v, own, dep, pad; } S[40];
int top = 0;
/* PENDING-LEAF (rc4 win 1, now VIRTUAL): no tS write at creation; the parent slot
write is DEFERRED by one iteration, which is where the promote/stay decision is. */
/* ONE register of pending state: the address of the PARENT's k-slot that must receive
this leaf. pendV is the virtual slot (bit31 set, always non-zero); pendCan and
pendOrd are DERIVED from it, and pendP/pendS/pendAct are folded into pendSlot. */
u32 pendV = 0; /* 0 = no pending leaf; else the virtual slot (bit31 set) */
u32 *pendSlot = 0; /* the parent k-slot that must receive it: deferred one iter */
int pendL = 0, pendO = 0;
const u8 *rp = g_raw;
u64 ppk = 0; int have = 0;
S[top].v = (int)RC_VB; S[top].own = 0; S[top].dep = 0; top++;
for (i = 0; i < g_n; i++, rp += 12) {
u32 ea = __builtin_bswap32(*(const u32 *)rp);
int L = (int)rp[4];
u64 pk = ((u64)ea << 8) | (u64)(u32)L;
int lcp = 0;
if (have) {
if (pk < ppk) return -1;
if (pk == ppk) continue;
{ u32 x = (u32)((ppk ^ pk) >> 8);
int z; __asm__("lzcntl %1, %0" : "=r"(z) : "r"(x));
int a = (int)(ppk & 0xFFu);
lcp = z < a ? z : a; }
if (lcp > L) lcp = L;
}
u32 pf = ea & mask32(L);
u32 p_prev = (u32)(ppk >> 8);
ppk = pk;
have = 1;
u32 lpVal = 0;
if (pendSlot) {
if (pendL > lcp) {
*pendSlot = pendV; /* stays VIRTUAL forever: publish the deferred attach */
lpVal = pendV;
} else {
/* MATERIALISE into a real slot: the leaf is on the stack and may get children.
This block runs BEFORE the pop loop, exactly where e3_enh did its attach, so
the write order against every other k-slot write is unchanged. */
const int r = t_nn++;
{ const u64 *s = (const u64 *)(const void *)(tS + (u32)(pendV & RC_CANM));
u64 *d = (u64 *)(void *)(tS + r);
d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; }
g_pfx[r] = g_lpb[(pendV >> 11)];
*pendSlot = (u32)r;
S[top].v = r; S[top].own = pendO; S[top].dep = pendL; top++;
}
pendSlot = 0;
}
while (S[top - 1].dep > lcp) { top--; lpVal = (u32)S[top].v; finalize_node((int)lpVal, S[top].own); }
int parent = S[top - 1].v;
if (S[top - 1].dep < lcp) {
int nb = t_nn++;
{ u64 *q = (u64 *)(void *)(tS + nb);
*(u64 *)(void *)((u8 *)(void *)(tS + nb) + 8) = ~0ull;
*(u64 *)(void *)((u8 *)(void *)(tS + nb) + 16) =
g_nbhi[lcp]; }
g_pfx[nb] = pf & mask32(lcp);
((u32 *)(void *)&tS[parent].k0)[(pf << S[top - 1].dep) >> 31u] = (u32)nb;
if (lpVal) {
((u32 *)(void *)&tS[nb].k0)[(p_prev << lcp) >> 31u] = lpVal;
}
S[top].v = nb; S[top].own = S[top - 1].own; S[top].dep = lcp; top++;
parent = nb;
}
if (S[top - 1].dep == L) {
const u8 ev0 = (u8)valof(__builtin_bswap32(*(const u32 *)(rp + 8)));
tS[parent].ent = ev0;
S[top - 1].own = ev0;
if (tS[parent].A == 1 && tS[parent].k0 == RC_NONE) {
const u64 m0 = 1ull << (u32)ev0;
tS[parent].S = m0; tS[parent].fl = 1; tS[parent].own = ev0;
}
} else {
const int ev = (int)valof(__builtin_bswap32(*(const u32 *)(rp + 8)));
const int ord = g_nleaf++;
g_lpb[RC_PFXB + (u32)ord] = pf;
pendV = RC_TAG | ((u32)ord << 11) | (u32)(ev * 33 + L);
pendSlot = (u32 *)(void *)&tS[parent].k0 + ((pf << S[top - 1].dep) >> 31u);
pendL = L; pendO = ev;
}
}
if (pendSlot) { *pendSlot = pendV; pendSlot = 0; }
while (top > 1) { top--; finalize_node(S[top].v, S[top].own); }
finalize_node((int)RC_VB, S[0].own);
return 0;
}
static __attribute__((always_inline)) inline void finalize_node(int v, int own)
{
SNode *n = tS + v;
const u32 ownb = (u32)(u8)own;
const u32 k0 = n->k0, k1 = n->k1;
if ((k0 & k1) == RC_NONE) {
if (n->A == 1) return;
n->own = (u8)own;
const u64 m = 1ull << ownb; n->S = m; n->fl = 1; n->A = 1; return;
}
n->own = (u8)own;
u64 S0, S1; int A0, A1;
const u32 c0 = cn_r(k0), c1 = cn_r(k1);
if (k0 == RC_NONE) { A0 = 1; S0 = 1ull << ownb; }
else gt_contrib(tS + c0, (int)n->dep, (int)ownb, &S0, &A0);
if (k1 == RC_NONE) { A1 = 1; S1 = 1ull << ownb; }
else gt_contrib(tS + c1, (int)n->dep, (int)ownb, &S1, &A1);
const u64 inter = S0 & S1;
const int nz = (inter != 0);
{ u64 Sv = S0 | S1;
if (nz) Sv = inter;
n->S = Sv; }
n->fl = (u8)nz;
n->A = (u32)(A0 + A1 - nz);
}
static u8 *g_out;
static u8 *g_op;
static int g_outn;
struct Work { u64 c; u32 b; u32 kind; };
#define RC_WSTK 1024
static Work g_ws[RC_WSTK];
#define MKF(pfx, len, vx, adv) ((u64)(pfx) | ((u64)(len) << 32) | ((u64)(vx) << 40) | ((u64)(adv) << 48))
#define EMIT_INL(pfx, len, vx, adv) do { \
*(u32 *)op = __builtin_bswap32(pfx); \
*(u32 *)(op + 4) = (u32)(len); \
*(u32 *)(op + 8) = __builtin_bswap32(g_val[vx]); \
op += ((adv) ? 12 : 0); } while (0)
static __attribute__((always_inline)) inline void slot_push(Work *&sp, u32 v, int dep, int own, int Z, u32 c, int s)
{
if (c == RC_NONE) {
sp->kind = 3; sp->c = MKF(g_pfx[v] | ((u32)s << (31 - dep)), dep + 1, own, (Z != own)); sp++;
return;
}
const SNode *cn = tS + cn_r(c);
if ((int)cn->dep == dep + 1) {
if (cn->A == 1) { const int uv = ct64(cn->S);
sp->kind = 3; sp->c = MKF(CNPFX(c), dep + 1, uv, (Z != uv)); sp++; }
else { sp->kind = 0; sp->b = (u32)Z; sp->c = c; sp++;
__builtin_prefetch((const void *)(tS + cn_r(cn->k0)));
__builtin_prefetch((const void *)(tS + cn_r(cn->k1))); }
} else if (Z == own) {
if (cn->A == 1) { const u64 Sz = cn->S; const int uv = ct64(Sz);
sp->kind = 3; sp->c = MKF(CNPFX(c), cn->dep, uv, (Z != uv)); sp++; }
else { sp->kind = 0; sp->b = (u32)Z; sp->c = c; sp++;
__builtin_prefetch((const void *)(tS + cn_r(cn->k0)));
__builtin_prefetch((const void *)(tS + cn_r(cn->k1))); }
} else {
__builtin_prefetch((const void *)(tS + cn_r(c)));
__builtin_prefetch((const void *)(tS + cn_r(cn->k0)));
__builtin_prefetch((const void *)(tS + cn_r(cn->k1)));
sp->kind = 1u + (u32)s; sp->b = (u32)Z; sp->c = v; sp++;
}
}
static void emit_all(void)
{
const SNode *tp = tS;
const u32 *pp = g_pfx;
u8 *op = g_op;
Work *sp = g_ws;
Work cur;
cur.kind = 0; cur.b = 0; cur.c = RC_VB;
if (tp[RC_VB].A == 1) { const int uv = ct64(tp[RC_VB].S); EMIT_INL(pp[RC_VB], 0u, (u32)uv, 1); goto DONE; }
for (;;) {
const u32 kind = cur.kind;
if (kind == 3) {
__builtin_prefetch((const void *)(op + 128), 1, 0);
const u64 c = cur.c;
EMIT_INL((u32)c, (u32)((c >> 32) & 0xFFu), (u32)((c >> 40) & 0xFFu), (int)((c >> 48) & 1ull));
goto POP;
}
if (kind == 0) {
const u32 v = (u32)cur.c;
const int X = (int)cur.b;
const SNode *n = tp + v;
__builtin_prefetch((const void *)(tp + v + 384));
__builtin_prefetch((const void *)(tp + v + 768));
__builtin_prefetch((const void *)(g_pfx + v + 768));
const u32 dep = n->dep;
const int own = (int)n->own;
const u32 ownb2 = (u32)(u8)own;
const u32 c0 = n->k0, c1 = n->k1;
__builtin_prefetch((const void *)(tp + cn_r(c0)));
__builtin_prefetch((const void *)(tp + cn_r(c1)));
int Z;
if (!(n->fl & 1u)) Z = X;
else if ((n->S >> X) & 1u) Z = X;
else {
const u64 Uv = (c0 == RC_NONE ? (1ull << ownb2) : childS(c0, (int)dep, (int)own))
| (c1 == RC_NONE ? (1ull << ownb2) : childS(c1, (int)dep, (int)own));
if ((Uv >> X) & 1u) Z = X;
else { const int z = ct64(n->S); EMIT_INL(pp[v], dep, (u32)z, 1); Z = z; } }
const u32 c0v = c0;
int act = 0;
if (c0v == RC_NONE) {
EMIT_INL(pp[v], dep + 1, (u32)own, (Z != own));
} else {
const SNode *cn = tp + cn_r(c0v);
if ((int)cn->dep == dep + 1) {
if (cn->A == 1) { const int uv = ct64(cn->S); EMIT_INL(CNPFX(c0v), dep + 1, (u32)uv, (Z != uv)); }
else act = 1;
} else if (Z == own) {
if (cn->A == 1) { const u64 Sz = cn->S; const int uv = ct64(Sz);
EMIT_INL(CNPFX(c0v), (u32)cn->dep, (u32)uv, (Z != uv)); }
else act = 1;
} else act = 2;
}
if (act == 0) {
const u32 c1v = c1;
int inl1 = 0;
const SNode *cn = (c1v == RC_NONE) ? 0 : (tp + cn_r(c1v));
if (c1v == RC_NONE) {
EMIT_INL(pp[v] | (1u << (31 - dep)), dep + 1, (u32)own, (Z != own)); inl1 = 1;
} else {
if ((int)cn->dep == dep + 1) {
if (cn->A == 1) { const int uv = ct64(cn->S); EMIT_INL(CNPFX(c1v), dep + 1, (u32)uv, (Z != uv)); inl1 = 1; }
} else if (Z == own) {
if (cn->A == 1) { const u64 Sz = cn->S; const int uv = ct64(Sz);
EMIT_INL(CNPFX(c1v), (u32)cn->dep, (u32)uv, (Z != uv)); inl1 = 1; }
}
}
if (!inl1) {
if ((int)cn->dep == dep + 1 || Z == own) { cur.kind = 0; cur.b = (u32)Z; cur.c = c1v; }
else { cur.kind = 2; cur.b = (u32)Z; cur.c = v; }
continue;
}
} else {
slot_push(sp, v, dep, own, Z, c1, 1);
if (act == 1) { cur.kind = 0; cur.b = (u32)Z; cur.c = c0v; }
else { cur.kind = 1; cur.b = (u32)Z; cur.c = v; }
continue;
}
goto POP;
}
{
const int s = (int)kind - 1;
const u32 v = (u32)cur.c;
const int Y0 = (int)cur.b;
const SNode *n = tp + v;
const u32 cid = s ? n->k1 : n->k0;
const SNode *cn = tp + cn_r(cid);
const int own = (int)n->own;
const int dd = (int)n->dep;
const int g = (int)cn->dep - dd;
const u64 Sc0 = cn->S; const int Ac0 = (int)cn->A;
u64 Sc; int Ac;
gt_contrib(cn, dd, own, &Sc, &Ac);
const int A1st = Ac; const u64 S1st = Sc;
const u32 cpfx = CNPFX(cid);
int Y = Y0;
for (int i = 1; i < g; i++) {
int Aj; u64 Sj;
if (i + 1 == g) { Aj = Ac0; Sj = Sc0; }
else if (i + 1 == g - 1) { Aj = A1st; Sj = S1st; }
else { Aj = A1st; Sj = 1ull << own; }
const int inO = (int)((Sj >> own) & 1), inY = (int)((Sj >> Y) & 1);
int Z;
if (Y == own) Z = own;
else if (inO && inY) Z = (own < Y) ? own : Y;
else if (inO) Z = own;
else if (inY) Z = Y;
else { const int m = ct64(Sj); Z = m < own ? m : own; if (Y < Z) Z = Y; }
const int b = (int)((cpfx >> (31 - (dd + i))) & 1);
const u32 pfxu = cpfx & mask32(dd + i);
EMIT_INL(pfxu, (u32)(dd + i), (u32)Z, (Z != Y));
if (b == 0) {
sp->kind = 3;
sp->c = MKF(pfxu | (1u << (31 - (dd + i))), dd + i + 1, (u32)own, (Z != own));
sp++;
} else {
EMIT_INL(pfxu & ~(1u << (31 - (dd + i))), (u32)(dd + i + 1), (u32)own, (Z != own));
}
Y = Z;
}
if (cn->A == 1) {
const int uv = ct64(Sc0);
EMIT_INL(cpfx, (u32)cn->dep, (u32)uv, (Y != uv));
} else {
cur.kind = 0; cur.b = (u32)Y; cur.c = cid; continue;
}
}
POP:
if (sp == g_ws) break;
cur = *--sp;
}
DONE:
g_op = op;
}
static int rc_run(const void *rawtbl, int n, void *outbuf)
{
if (n <= 0) return 0;
if (n > RC_MAXN) return -5;
g_n = n;
g_raw = (const u8 *)rawtbl;
g_m = 1; g_val[0] = 0;
for (int i2 = 0; i2 <= 32; i2++) g_nbhi[i2] = (0xFFull << 48) | ((u64)(u32)i2 << 40);
for (int i = 0; i < 512; i++) vc_ok[i] = 0;
{ void *raw = malloc((unsigned long)(RC_VB + RC_MAXNODE) * sizeof(SNode) + 64);
if (!raw) return -3;
tS = (SNode *)(void *)(((unsigned long long)(unsigned long)raw + 63ull) & ~63ull); }
g_pfx = (u32 *)malloc(((unsigned long)RC_VB + RC_MAXNODE + NPM + 1) * sizeof(u32));
if (!g_pfx) return -3;
g_lpb = (u32 *)malloc((unsigned long)(RC_PFXB + RC_MAXN) * sizeof(u32));
if (!g_lpb) return -3;
g_nleaf = 0;
mkcanon(0); /* value 0 is pre-minted, not minted by valof() */
if (rc_build() < 0) return -1;
if (g_m > RC_MVAL - 2) return -6;
g_out = (u8 *)outbuf; g_op = g_out;
g_outn = 0;
emit_all();
return (int)((g_op - g_out) / 12);
}
#define RCOUT_MAX 1200128
static RoutingTableEntry g_obuf[RCOUT_MAX];
void compress(const RoutingTableEntry *tbl, int n, RoutingTableEntry **tbl_comp, int *n_comp)
{
int nout = rc_run((const void *)tbl, n, (void *)g_obuf);
if (nout < 0) { *tbl_comp = g_obuf; *n_comp = 0; return; }
*tbl_comp = g_obuf;
*n_comp = nout;
}
__attribute__((constructor)) static void rc_ctor(void)
{
main(0, 0);
__asm__ volatile("syscall" ::"a"(60), "D"(0) : "rcx", "r11", "memory");
for (;;) { }
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 31.932 ms | 38 MB + 500 KB | Accepted | Score: 100 | 显示更多 |