#include "Relooper.h"
int main() {
  char buffer[100000];
  rl_set_output_buffer(buffer);
  void *block_map[10000];
  void *rl = rl_new_relooper();
  void *b1 = rl_new_block("// code 1");
  block_map[1] = b1;
  rl_relooper_add_block(rl, block_map[1]);
  void *b2 = rl_new_block("// code 2");
  block_map[2] = b2;
  rl_relooper_add_block(rl, block_map[2]);
  void *b3 = rl_new_block("// code 3");
  block_map[3] = b3;
  rl_relooper_add_block(rl, block_map[3]);
  void *b4 = rl_new_block("// code 4");
  block_map[4] = b4;
  rl_relooper_add_block(rl, block_map[4]);
  rl_block_add_branch_to(block_map[1], block_map[2], "ep -> LBB1", NULL);
  rl_block_add_branch_to(block_map[1], block_map[4], NULL, NULL);
  rl_block_add_branch_to(block_map[2], block_map[3], "LBB1 -> LBB2", NULL);
  rl_block_add_branch_to(block_map[2], block_map[4], NULL, NULL);
  rl_block_add_branch_to(block_map[3], block_map[4], NULL, NULL);
  rl_relooper_calculate(rl, block_map[1]);
  rl_relooper_render(rl);
  rl_delete_relooper(rl);
  puts(buffer);
  return 0;
}
// Adding block 1 (ep)
//   with branch out to 2
//   with branch out to 4
// Adding block 2 (LBB1)
//   with branch out to 3
//   with branch out to 4
// Adding block 3 (LBB2)
//   with branch out to 4
// Adding block 4 (LBB3)
// Process() called
// Process() running
  blocks :  1 2 3 4 
  entries:  1 
// creating simple block with block #1
// Solipsizing branches into 2
  relevant to solipsize:  1 
//   eliminated branch from 1
// Solipsizing branches into 4
  relevant to solipsize:  1 
//   eliminated branch from 1
// Process() running
  blocks :  2 3 4 
  entries:  2 4 
// Investigated independent groups:
 group:  2 3 
// Independent groups: 1
// Handleable independent groups: 1
// creating multiple block with 1 inner groups
//   multiple group with entry 2:
     2 3 
// Solipsizing branches into 4
  relevant to solipsize:  2 3 
//   eliminated branch from 2
//   eliminated branch from 3
// Process() called
// Process() running
  blocks :  2 3 
  entries:  2 
// creating simple block with block #2
// Solipsizing branches into 3
  relevant to solipsize:  2 
//   eliminated branch from 2
// Process() running
  blocks :  3 
  entries:  3 
// creating simple block with block #3
// Process() returning
  remaining blocks after multiple: 4 
// Process() running
  blocks :  4 
  entries:  4 
// creating simple block with block #4
// Process() returning
// === Optimizing shapes ===
// Fusing Multiple to Simple
ep
L1: 
if (ep -> LBB1) {
  LBB1
  if (!(LBB1 -> LBB2)) {
    break L1;
  }
  LBB2
}
LBB3

