public function alignColumns($align, $a, $b)
 {
     $align->range($a->get_width(), $b->get_width());
     $align->tables($a, $b);
     $align->setRowlike(false);
     $slop = 5;
     $va = $a->getCellView();
     $vb = $b->getCellView();
     $ra_best = 0;
     $rb_best = 0;
     $ct_best = -1;
     $ma_best = null;
     $mb_best = null;
     $ra_header = 0;
     $rb_header = 0;
     $ra_uniques = 0;
     $rb_uniques = 0;
     $_g = 0;
     while ($_g < $slop) {
         $ra = $_g++;
         $_g1 = 0;
         while ($_g1 < $slop) {
             $rb = $_g1++;
             $ma = new haxe_ds_StringMap();
             $mb = new haxe_ds_StringMap();
             $ct = 0;
             $uniques = 0;
             if ($ra < $a->get_height()) {
                 $_g3 = 0;
                 $_g2 = $a->get_width();
                 while ($_g3 < $_g2) {
                     $ca = $_g3++;
                     $key = $va->toString($a->getCell($ca, $ra));
                     if ($ma->exists($key)) {
                         $ma->set($key, -1);
                         $uniques--;
                     } else {
                         $ma->set($key, $ca);
                         $uniques++;
                     }
                     unset($key, $ca);
                 }
                 unset($_g3, $_g2);
                 if ($uniques > $ra_uniques) {
                     $ra_header = $ra;
                     $ra_uniques = $uniques;
                 }
             }
             $uniques = 0;
             if ($rb < $b->get_height()) {
                 $_g31 = 0;
                 $_g21 = $b->get_width();
                 while ($_g31 < $_g21) {
                     $cb = $_g31++;
                     $key1 = $vb->toString($b->getCell($cb, $rb));
                     if ($mb->exists($key1)) {
                         $mb->set($key1, -1);
                         $uniques--;
                     } else {
                         $mb->set($key1, $cb);
                         $uniques++;
                     }
                     unset($key1, $cb);
                 }
                 unset($_g31, $_g21);
                 if ($uniques > $rb_uniques) {
                     $rb_header = $rb;
                     $rb_uniques = $uniques;
                 }
             }
             if (null == $ma) {
                 throw new HException('null iterable');
             }
             $__hx__it = $ma->keys();
             while ($__hx__it->hasNext()) {
                 unset($key2);
                 $key2 = $__hx__it->next();
                 $i0 = $ma->get($key2);
                 $i1 = $mb->get($key2);
                 if ($i1 !== null) {
                     if ($i1 >= 0 && $i0 >= 0) {
                         $ct++;
                     }
                 }
                 unset($i1, $i0);
             }
             if ($ct > $ct_best) {
                 $ct_best = $ct;
                 $ma_best = $ma;
                 $mb_best = $mb;
                 $ra_best = $ra;
                 $rb_best = $rb;
             }
             unset($uniques, $rb, $mb, $ma, $ct);
         }
         unset($_g1);
         unset($ra);
     }
     if ($ma_best === null) {
         if ($a->get_height() > 0 && $b->get_height() === 0) {
             $align->headers(0, -1);
         } else {
             if ($a->get_height() === 0 && $b->get_height() > 0) {
                 $align->headers(-1, 0);
             }
         }
         return;
     }
     if (null == $ma_best) {
         throw new HException('null iterable');
     }
     $__hx__it = $ma_best->keys();
     while ($__hx__it->hasNext()) {
         unset($key3);
         $key3 = $__hx__it->next();
         $i01 = $ma_best->get($key3);
         $i11 = $mb_best->get($key3);
         if ($i01 !== null && $i11 !== null) {
             $align->link($i01, $i11);
         } else {
             if ($i01 !== null) {
                 $align->link($i01, -1);
             } else {
                 if ($i11 !== null) {
                     $align->link(-1, $i11);
                 }
             }
         }
         unset($i11, $i01);
     }
     if (null == $mb_best) {
         throw new HException('null iterable');
     }
     $__hx__it = $mb_best->keys();
     while ($__hx__it->hasNext()) {
         unset($key4);
         $key4 = $__hx__it->next();
         $i02 = $ma_best->get($key4);
         $i12 = $mb_best->get($key4);
         if ($i02 === null && $i12 !== null) {
             $align->link(-1, $i12);
         }
         unset($i12, $i02);
     }
     $align->headers($ra_header, $rb_header);
 }