Files
isaac-port/generated-src/formatted_text.cpp
T
shweetandClaude Opus 5.5 3ce74c6e2d Reconstruction layout: generated-src/ (generated) and src/ (curated), CMake, the first takeover: RNG
The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function
defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body.
src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read
from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT,
from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra).
structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:10:23 -05:00

640 lines
21 KiB
C++

#include "classes.h"
// 00a55b70
FormattedText::FormattedText(undefined1 *param_1)
{
byte *in_ECX;
undefined1 local_20 [4];
undefined4 local_1c;
undefined2 local_18;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
undefined1 *linesEnd;
puStack_c = &LAB_00b12810;
local_10 = ExceptionList;
ExceptionList = &local_10;
*in_ECX = 0;
in_ECX[4] = 0;
in_ECX[5] = 0;
in_ECX[6] = 0;
in_ECX[7] = 0;
in_ECX[8] = 0;
in_ECX[9] = 0;
in_ECX[10] = 0;
in_ECX[0xb] = 0;
in_ECX[0xc] = 0;
in_ECX[0xd] = 0;
in_ECX[0xe] = 0;
in_ECX[0xf] = 0;
local_8 = 0;
local_20[0] = *param_1;
local_1c = *GHIDRA_CAST<undefined4 *>((param_1 + 4));
local_18 = *GHIDRA_CAST<undefined2 *>((param_1 + 8));
*in_ECX = *in_ECX | 1;
linesEnd = *GHIDRA_CAST<undefined1 **>((in_ECX + 8));
if (linesEnd == *GHIDRA_CAST<undefined1 **>((in_ECX + 0xc))) {
std::vector<FormattedTextLine>::_Emplace_reallocate(linesEnd,local_20);
}
else {
*linesEnd = local_20[0];
*GHIDRA_CAST<undefined4 *>((linesEnd + 4)) = local_1c;
*GHIDRA_CAST<undefined2 *>((linesEnd + 8)) = local_18;
*GHIDRA_CAST<int *>((in_ECX + 8)) = *GHIDRA_CAST<int *>((in_ECX + 8)) + 0xc;
}
ExceptionList = local_10;
return;
}
// 00a55c40
void FormattedText::set(byte *text, void *measureContext, int maxLength, float scale, byte isCopySegments)
{
int *outLines;
int iVar1;
void *segmentCopy;
int segmentsByteSize;
void *local_1c;
float local_18;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
local_8 = 0xffffffff;
puStack_c = &LAB_00b1283d;
local_10 = ExceptionList;
ExceptionList = &local_10;
std::vector<12byte>::clear(__security_cookie ^ GHIDRA_INT(register0x00000010) - 4U);
local_1c = measureContext;
local_18 = scale;
outLines = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 4));
local_8 = 0;
parse(text,maxLength,outLines,FUN_00a56750,&local_1c);
local_8 = 0xffffffff;
if (isCopySegments == 0) {
*GHIDRA_CAST<byte *>(this) = *GHIDRA_CAST<byte *>(this) | 1;
ExceptionList = local_10;
return;
}
_isCopySegments = 0;
*GHIDRA_CAST<byte *>(this) = *GHIDRA_CAST<byte *>(this) & 0xfe;
segmentsByteSize = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 8)) - *outLines;
iVar1 = segmentsByteSize >> 0x1f;
if (segmentsByteSize / 0xc + iVar1 != iVar1) {
measureContext = (void *)0x0;
do {
iVar1 = *outLines;
segmentCopy = operator_new_tracked(GHIDRA_UINT(*GHIDRA_CAST<ushort *>((GHIDRA_CAST<char *>(measureContext) + iVar1 + 8))));
memcpy(segmentCopy,*(void **)(GHIDRA_CAST<char *>(measureContext) + iVar1 + 4),
GHIDRA_UINT(*GHIDRA_CAST<ushort *>((GHIDRA_CAST<char *>(measureContext) + iVar1 + 8))));
*(void **)(GHIDRA_CAST<char *>(measureContext) + iVar1 + 4) = segmentCopy;
_isCopySegments = _isCopySegments + 1;
measureContext = (void *)(GHIDRA_INT(measureContext) + 0xc);
} while (_isCopySegments < GHIDRA_UINT(((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 8)) - *outLines) / 0xc)));
}
ExceptionList = local_10;
return;
}
// 00a55e20
void * FormattedText::operator_assign(void *other)
{
void *textCopy;
byte flags;
int runsBytes;
int iVar1;
int runOffset;
int *runs;
flags = *GHIDRA_CAST<byte *>(other);
runs = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 4));
*GHIDRA_CAST<byte *>(this) = flags;
if (runs != GHIDRA_CAST<int *>((GHIDRA_INT(other) + 4))) {
std::vector<12byte>::assign(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(other) + 4)),*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 8)),other);
flags = *GHIDRA_CAST<byte *>(this);
}
if ((flags & 1) == 0) {
runsBytes = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 8)) - *runs;
other = (void *)0x0;
iVar1 = runsBytes >> 0x1f;
if (runsBytes / 0xc + iVar1 != iVar1) {
runOffset = 0;
do {
iVar1 = *runs + runOffset;
textCopy = operator_new_tracked(GHIDRA_UINT(*GHIDRA_CAST<ushort *>((iVar1 + 8))));
memcpy(textCopy,*(void **)(iVar1 + 4),GHIDRA_UINT(*GHIDRA_CAST<ushort *>((iVar1 + 8))));
*(void **)(iVar1 + 4) = textCopy;
other = (void *)(GHIDRA_INT(other) + 1);
runOffset = runOffset + 0xc;
} while (other < (void *)((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 8)) - *runs) / 0xc));
return this;
}
}
return this;
}
// 00a55ef0
void FormattedText::split_lines(byte *text, void *lines)
{
byte *pbVar1;
uint uVar2;
undefined1 *linesEnd;
byte scanChar;
int charCount;
byte *pbVar3;
byte ch;
byte *pbVar4;
byte *pbVar5;
byte *pbVar6;
undefined1 *linesCapacityEnd;
undefined1 line [4];
byte *lineText;
short lineLength;
byte *textStart;
int textLength;
byte *local_10;
void *linesLocal;
byte *local_8;
charCount = 0;
textLength = 0;
pbVar3 = text;
if (*text != 0) {
do {
pbVar3 = pbVar3 + 1;
charCount = charCount + 1;
} while (*pbVar3 != 0);
textLength = charCount;
}
textStart = text;
linesLocal = lines;
do {
ch = *text;
pbVar3 = text;
lineText = text;
local_8 = text;
if (ch != 0) {
pbVar4 = text;
scanChar = ch;
do {
if (scanChar == 10) {
pbVar5 = pbVar4;
pbVar6 = pbVar4;
local_10 = pbVar4;
goto LAB_00a55f66;
}
scanChar = pbVar4[1];
pbVar4 = pbVar4 + 1;
} while (scanChar != 0);
}
pbVar6 = GHIDRA_CAST<byte *>(0x0);
local_10 = GHIDRA_CAST<byte *>(0x0);
pbVar4 = GHIDRA_CAST<byte *>(0x0);
pbVar5 = GHIDRA_CAST<byte *>(0x0);
while (ch != 0) {
LAB_00a55f66:
uVar2 = 0;
while (ch == (&DAT_00b65584)[uVar2]) {
uVar2 = uVar2 + 1;
if (1 < uVar2) {
uVar2 = GHIDRA_UINT((pbVar5 != GHIDRA_CAST<byte *>(0x0)));
if ((pbVar3 == GHIDRA_CAST<byte *>(0x0)) || (pbVar5 <= pbVar3)) goto LAB_00a55fb8;
uVar2 = 2;
linesCapacityEnd = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(linesLocal) + 8));
linesEnd = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(linesLocal) + 4));
goto LAB_00a55fcb;
}
}
pbVar1 = pbVar3 + 1;
pbVar3 = pbVar3 + 1;
ch = *pbVar1;
}
if (pbVar4 == GHIDRA_CAST<byte *>(0x0)) {
pbVar6 = GHIDRA_CAST<byte *>(0x0);
}
uVar2 = GHIDRA_UINT((local_10 != GHIDRA_CAST<byte *>(0x0)));
pbVar5 = pbVar6;
LAB_00a55fb8:
pbVar3 = pbVar5;
linesCapacityEnd = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(linesLocal) + 8));
linesEnd = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(linesLocal) + 4));
if (pbVar3 == GHIDRA_CAST<byte *>(0x0)) {
lineLength = (short)textLength + ((short)textStart - (short)text);
line[0] = 0;
if (linesEnd == linesCapacityEnd) {
std::vector<FormattedTextLine>::_Emplace_reallocate(linesEnd,line);
return;
}
*GHIDRA_CAST<byte **>((linesEnd + 4)) = text;
*linesEnd = 0;
*GHIDRA_CAST<short *>((linesEnd + 8)) = lineLength;
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(linesLocal) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(linesLocal) + 4)) + 0xc;
return;
}
LAB_00a55fcb:
lineLength = (short)pbVar3 - (short)text;
line[0] = 0;
if (linesEnd == linesCapacityEnd) {
std::vector<FormattedTextLine>::_Emplace_reallocate(linesEnd,line);
text = pbVar3 + uVar2;
}
else {
*linesEnd = 0;
*GHIDRA_CAST<byte **>((linesEnd + 4)) = text;
*GHIDRA_CAST<short *>((linesEnd + 8)) = lineLength;
text = pbVar3 + uVar2;
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(linesLocal) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(linesLocal) + 4)) + 0xc;
}
} while( true );
}
// 00a56060
void FormattedText::split_lines_utf16(short *text, void *outLines)
{
short *psVar1;
int lengthCount;
uint uVar2;
undefined1 *linesEnd;
short scanChar;
short currentChar;
undefined1 *linesCapacity;
short *lineEnd;
undefined1 newLine [4];
short *newLineText;
undefined2 newLineLength;
short *textStart;
int textLength;
short *local_18;
short *local_14;
short *newlinePos;
short *local_c;
void *outLinesLocal;
lengthCount = 0;
textLength = 0;
psVar1 = text;
if (*text != 0) {
do {
psVar1 = psVar1 + 1;
lengthCount = lengthCount + 1;
} while (*psVar1 != 0);
textLength = lengthCount;
}
textStart = text;
outLinesLocal = outLines;
do {
currentChar = *text;
newLineText = text;
local_c = text;
if (currentChar != 0) {
newlinePos = text;
scanChar = currentChar;
do {
if (scanChar == 10) goto LAB_00a560e3;
scanChar = newlinePos[1];
newlinePos = newlinePos + 1;
} while (scanChar != 0);
}
newlinePos = GHIDRA_CAST<short *>(0x0);
if (currentChar != 0) {
LAB_00a560e3:
psVar1 = text;
do {
uVar2 = 0;
while (currentChar == (char)(&DAT_00b65584)[uVar2]) {
uVar2 = uVar2 + 1;
if (1 < uVar2) {
uVar2 = GHIDRA_UINT((newlinePos != GHIDRA_CAST<short *>(0x0)));
lineEnd = newlinePos;
if ((psVar1 == GHIDRA_CAST<short *>(0x0)) || (newlinePos <= psVar1)) goto LAB_00a5614b;
uVar2 = 2;
linesCapacity = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(outLinesLocal) + 8));
linesEnd = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(outLinesLocal) + 4));
goto LAB_00a56158;
}
}
currentChar = psVar1[1];
psVar1 = psVar1 + 1;
} while (currentChar != 0);
}
lineEnd = newlinePos;
if (newlinePos == GHIDRA_CAST<short *>(0x0)) {
lineEnd = GHIDRA_CAST<short *>(0x0);
}
uVar2 = GHIDRA_UINT((newlinePos != GHIDRA_CAST<short *>(0x0)));
LAB_00a5614b:
psVar1 = lineEnd;
linesCapacity = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(outLinesLocal) + 8));
linesEnd = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(outLinesLocal) + 4));
if (psVar1 == GHIDRA_CAST<short *>(0x0)) {
newLine[0] = 0;
newLineLength = (undefined2)((textLength * 2 - GHIDRA_INT(text)) + GHIDRA_INT(textStart) >> 1);
if (linesEnd == linesCapacity) {
local_18 = newlinePos;
local_14 = newlinePos;
std::vector<FormattedTextLine>::_Emplace_reallocate(linesEnd,newLine);
return;
}
*GHIDRA_CAST<short **>((linesEnd + 4)) = text;
*linesEnd = 0;
*GHIDRA_CAST<undefined2 *>((linesEnd + 8)) = newLineLength;
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLinesLocal) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLinesLocal) + 4)) + 0xc;
return;
}
LAB_00a56158:
newLine[0] = 0;
newLineLength = (undefined2)(GHIDRA_INT(psVar1) - GHIDRA_INT(text) >> 1);
if (linesEnd == linesCapacity) {
local_18 = newlinePos;
local_14 = newlinePos;
std::vector<FormattedTextLine>::_Emplace_reallocate(linesEnd,newLine);
text = psVar1 + uVar2;
}
else {
*GHIDRA_CAST<short **>((linesEnd + 4)) = text;
text = psVar1 + uVar2;
*linesEnd = 0;
*GHIDRA_CAST<undefined2 *>((linesEnd + 8)) = newLineLength;
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLinesLocal) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLinesLocal) + 4)) + 0xc;
}
} while( true );
}
// 00a56350
void FormattedText::parse(byte *text, uint maxWidth, void *outLines, void *measureFn, void *userData)
{
byte bVar1;
byte *pbVar2;
void *pvVar3;
uint uVar4;
char delimChar;
qword *allocCounter;
byte *pbVar5;
uint uVar6;
byte *pbVar7;
int iVar8;
byte *pbVar9;
byte lineFlags [4];
byte *lineStart;
short lineLength;
undefined1 pendingLineFlags [4];
byte *pendingLineStart;
short pendingLineLength;
int spaceWidth;
uint local_34;
uint wordBufCapacity;
byte *textEnd;
void *wordBuf;
uint local_24;
uint maxWidthLocal;
byte *curLineStart;
byte *cursor;
byte isNewline;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
qword allocatedBytes;
undefined1 *lineSlot;
puStack_c = &LAB_00b1286d;
local_10 = ExceptionList;
ExceptionList = &local_10;
local_8 = 0;
iVar8 = 0;
bVar1 = *text;
pbVar9 = text;
while (bVar1 != 0) {
pbVar9 = pbVar9 + 1;
iVar8 = iVar8 + 1;
bVar1 = *pbVar9;
}
textEnd = text + iVar8;
wordBufCapacity = 0x40;
local_24 = 0;
maxWidthLocal = maxWidth;
curLineStart = text;
cursor = text;
spaceWidth = (*measureFn)(&DAT_00b656ec,1,userData,
__security_cookie ^ GHIDRA_UINT((pendingLineFlags + 0x40)));
wordBuf = operator_new_tracked(0x40);
if (text < textEnd) {
do {
pbVar9 = cursor;
bVar1 = *text;
uVar6 = GHIDRA_UINT(bVar1) << 8;
isNewline = 0;
if (bVar1 != 0) {
uVar6 = GHIDRA_UINT(CONCAT11(bVar1,bVar1));
pbVar5 = text;
do {
if ((char)uVar6 == ' ') goto LAB_00a56414;
pbVar7 = pbVar5 + 1;
uVar6 = CONCAT31((int3)(uVar6 >> 8),*pbVar7);
pbVar5 = pbVar5 + 1;
} while (*pbVar7 != 0);
}
pbVar5 = GHIDRA_CAST<byte *>(0x0);
if ((char)(uVar6 >> 8) != '\0') {
LAB_00a56414:
uVar6 = CONCAT31((int3)(uVar6 >> 8),(char)(uVar6 >> 8));
pbVar7 = text;
do {
if ((char)uVar6 == '\n') goto LAB_00a56436;
pbVar2 = pbVar7 + 1;
uVar6 = CONCAT31((int3)(uVar6 >> 8),*pbVar2);
pbVar7 = pbVar7 + 1;
} while (*pbVar2 != 0);
}
pbVar7 = GHIDRA_CAST<byte *>(0x0);
if ((char)(uVar6 >> 8) != '\0') {
LAB_00a56436:
uVar6 = CONCAT31((int3)(uVar6 >> 8),(char)(uVar6 >> 8));
do {
uVar4 = 0;
while ((char)uVar6 == (&DAT_00b65584)[uVar4]) {
uVar4 = uVar4 + 1;
if (1 < uVar4) goto LAB_00a5645c;
}
pbVar2 = text + 1;
uVar6 = CONCAT31((int3)(uVar6 >> 8),*pbVar2);
text = text + 1;
} while (*pbVar2 != 0);
}
text = GHIDRA_CAST<byte *>(0x0);
LAB_00a5645c:
if ((pbVar7 != GHIDRA_CAST<byte *>(0x0)) && (pbVar7 < pbVar5)) {
pbVar5 = pbVar7;
}
if ((text != GHIDRA_CAST<byte *>(0x0)) && (text < pbVar5)) {
pbVar5 = text;
}
pbVar7 = textEnd;
if (pbVar5 != GHIDRA_CAST<byte *>(0x0)) {
pbVar7 = pbVar5;
}
delimChar = (char)(uVar6 >> 8);
if (delimChar == '\n') {
uVar6 = 1;
isNewline = 1;
}
else if ((delimChar == '\\') && (cursor[1] == 0x6e)) {
uVar6 = 2;
isNewline = 1;
}
else {
uVar6 = GHIDRA_INT(pbVar7) - GHIDRA_INT(cursor);
}
if (wordBufCapacity <= uVar6) {
if (wordBuf != (void *)0x0) {
if (g_mainHeap == (void *)0x0) {
allocCounter = &g_allocatedBytesNoHeap;
}
else {
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(wordBuf) + -4));
allocatedBytes = *allocCounter;
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar4));
free(GHIDRA_CAST<uint *>((GHIDRA_INT(wordBuf) + -4)));
local_8 = local_8 & 0xffffff00;
}
wordBufCapacity = uVar6 + 1;
wordBuf = operator_new_tracked(wordBufCapacity);
}
pvVar3 = wordBuf;
memcpy(wordBuf,pbVar9,uVar6);
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(pvVar3) + uVar6)) = 0;
local_34 = (*measureFn)(pvVar3,uVar6,userData);
pbVar9 = cursor;
uVar4 = CONCAT11(isNewline,isNewline) ^ 1;
pbVar5 = cursor + (uVar4 & 0xff) + uVar6;
if ((maxWidthLocal < local_24 + local_34) || (isNewline != 0)) {
if (local_24 == 0) {
cursor = pbVar5;
}
else {
pendingLineFlags[0] = 0;
pendingLineLength = ((short)cursor - ((ushort)uVar4 & 0xff)) - (short)curLineStart;
pendingLineStart = curLineStart;
lineSlot = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(outLines) + 4));
if (lineSlot == *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(outLines) + 8))) {
cursor = pbVar5;
std::vector<FormattedTextLine>::_Emplace_reallocate(lineSlot,pendingLineFlags);
}
else {
*lineSlot = 0;
*GHIDRA_CAST<byte **>((lineSlot + 4)) = curLineStart;
*GHIDRA_CAST<short *>((lineSlot + 8)) = pendingLineLength;
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLines) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLines) + 4)) + 0xc;
cursor = pbVar5;
}
uVar4 = GHIDRA_UINT(isNewline) << 8;
curLineStart = pbVar9;
if (isNewline != 0) {
curLineStart = cursor;
}
}
pbVar9 = curLineStart;
local_24 = local_34;
if ((char)(uVar4 >> 8) != '\0') {
local_24 = 0;
}
if (maxWidthLocal < local_24) {
if (uVar6 == 0xffffffff) {
bVar1 = *curLineStart;
pbVar5 = curLineStart;
while (bVar1 != 0) {
pbVar5 = pbVar5 + 1;
bVar1 = *pbVar5;
}
}
else {
pbVar5 = curLineStart + uVar6;
}
local_34 = (*measureFn)(&DAT_00b6d4f8,1,userData);
do {
if (pbVar5 <= curLineStart) break;
pbVar7 = curLineStart;
if (local_34 < maxWidthLocal) {
local_24 = GHIDRA_INT(pbVar9) - GHIDRA_INT(curLineStart);
do {
if (pbVar5 <= pbVar7) break;
if (pbVar9 < pbVar5) {
local_24 = local_24 + 1;
pbVar7 = pbVar9 + 1;
}
else {
pbVar7 = pbVar9;
}
iVar8 = (*measureFn)(curLineStart,local_24,userData);
pbVar9 = pbVar7;
} while (iVar8 + local_34 < maxWidthLocal);
if (pbVar7 == curLineStart) goto LAB_00a5663d;
}
else {
LAB_00a5663d:
pbVar7 = pbVar7 + 1;
}
local_24 = GHIDRA_INT(pbVar7) - GHIDRA_INT(curLineStart);
lineLength = (short)local_24;
pbVar2 = *GHIDRA_CAST<byte **>((GHIDRA_CAST<char *>(outLines) + 4));
lineFlags[0] = -(pbVar7 < pbVar5) & 2;
lineStart = curLineStart;
if (pbVar2 == *GHIDRA_CAST<byte **>((GHIDRA_CAST<char *>(outLines) + 8))) {
std::vector<FormattedTextLine>::_Emplace_reallocate(pbVar2,lineFlags);
}
else {
*pbVar2 = lineFlags[0];
*GHIDRA_CAST<byte **>((pbVar2 + 4)) = curLineStart;
*GHIDRA_CAST<short *>((pbVar2 + 8)) = lineLength;
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLines) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLines) + 4)) + 0xc;
}
curLineStart = pbVar7;
local_24 = (*measureFn)(pbVar7,GHIDRA_INT(pbVar5) - GHIDRA_INT(pbVar7),userData);
} while (maxWidthLocal < local_24);
}
}
else {
local_24 = local_24 + spaceWidth + local_34;
cursor = pbVar5;
}
text = cursor;
} while (cursor < textEnd);
text = curLineStart;
}
pvVar3 = wordBuf;
if (0 < GHIDRA_INT(textEnd) - GHIDRA_INT(text)) {
lineLength = (short)textEnd - (short)text;
lineFlags[0] = 0;
lineSlot = *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(outLines) + 4));
lineStart = text;
if (lineSlot == *GHIDRA_CAST<undefined1 **>((GHIDRA_CAST<char *>(outLines) + 8))) {
std::vector<FormattedTextLine>::_Emplace_reallocate(lineSlot,lineFlags);
}
else {
*lineSlot = 0;
*GHIDRA_CAST<byte **>((lineSlot + 4)) = text;
*GHIDRA_CAST<short *>((lineSlot + 8)) = lineLength;
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLines) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outLines) + 4)) + 0xc;
}
}
if (pvVar3 != (void *)0x0) {
if (g_mainHeap == (void *)0x0) {
allocCounter = &g_allocatedBytesNoHeap;
}
else {
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
uVar6 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pvVar3) + -4));
allocatedBytes = *allocCounter;
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar6;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar6));
free((void *)(GHIDRA_INT(pvVar3) + -4));
}
ExceptionList = local_10;
return;
}