+ /* convert 2 block */
+ eBBlock *ebb = iCode2eBBlock (loop);
+ loop = ebb->ech->next;
+
+ ebb->ech->next = NULL; /* mark the end of this chain */
+ if (loop)
+ loop->prev = NULL;
+ ebb->bbnum = *count; /* save this block number */
+ /* put it in the array */
+ ebbs[(*count)++] = ebb;
+
+ /* allocate for the next one. Remember to clear the new */
+ /* pointer at the end, that was created by realloc. */
+
+ ebbs = Safe_realloc (ebbs, (*count + 1) * sizeof (eBBlock **));
+
+ ebbs[*count] = 0;
+
+ /* if this one ends in a goto or a conditional */
+ /* branch then check if the block it is going */
+ /* to already exists, if yes then this could */
+ /* be a loop, add a preheader to the block it */
+ /* goes to if it does not already have one */
+ if (ebbs[(*count) - 1]->ech &&
+ (ebbs[(*count) - 1]->ech->op == GOTO ||
+ ebbs[(*count) - 1]->ech->op == IFX))
+ {
+
+ symbol *label;
+ eBBlock *destBlock;
+
+ if (ebbs[(*count) - 1]->ech->op == GOTO)
+ label = IC_LABEL (ebbs[(*count) - 1]->ech);
+ else if (!(label = IC_TRUE (ebbs[(*count) - 1]->ech)))
+ label = IC_FALSE (ebbs[(*count) - 1]->ech);
+
+ if ((destBlock = eBBWithEntryLabel (ebbs, label, (*count))) &&
+ destBlock->preHeader == NULL &&
+ otherPathsPresent (ebbs, destBlock))
+ {
+
+ symbol *preHeaderLabel = newiTempPreheaderLabel ();
+ int i, j;
+ eBBlock *pBlock;
+
+ /* go thru all block replacing the entryLabel with new label */
+ /* till we reach the block , then we insert a new ebblock */
+ for (i = 0; i < (*count); i++)
+ {
+ if (ebbs[i] == destBlock)
+ break;
+ replaceLabel (ebbs[i], label, preHeaderLabel);
+ }
+
+ (*count)++;
+
+ /* if we have stopped at the block , allocate for an extra one */
+
+ ebbs = Safe_realloc (ebbs, (*count + 1) * sizeof (eBBlock **));
+
+ ebbs[*count] = 0;
+
+ /* then move the block down one count */
+ pBlock = ebbs[j = i];
+ for (i += 1; i < (*count); i++)
+ {
+ eBBlock *xBlock;
+
+ xBlock = ebbs[i];
+ ebbs[i] = pBlock;
+ ebbs[i]->bbnum = i;
+ pBlock = xBlock;
+ }
+
+ destBlock->preHeader = ebbs[j] = neweBBlock ();
+ ebbs[j]->bbnum = j;
+ ebbs[j]->entryLabel = preHeaderLabel;
+ ebbs[j]->sch = ebbs[j]->ech = newiCodeLabelGoto (LABEL, preHeaderLabel);
+ ebbs[j]->sch->lineno = destBlock->sch->lineno;
+ }
+ }