164{
  165    register int    k;
  166#ifndef K6OPT
  167    register int lambda;
  168#endif
  171 
  175 
  176    
  177
  179 
  180    for (k = 0; k <= 39; k++) {
  184    }
  185 
  186    temp = 0;
  187    if (
dmax == 0) scal = 0;
 
  188    else {
  191    }
  192 
  193    if (temp > 6) scal = 0;
  194    else scal = 6 - temp;
  195 
  196    assert(scal >= 0);
  197 
  198    
  199
  200 
  201    for (k = 0; k <= 39; k++) wt[k] = 
SASR( 
d[k], scal );
 
  202 
  203    
  204
  205# ifdef K6OPT
  206    L_max = k6maxcc(wt,dp,&
Nc);
 
  207#   else
  208    L_max = 0;
  210 
  211    for (lambda = 40; lambda <= 120; lambda++) {
  212 
  213# undef STEP
  214#       define STEP(k)  (longword)wt[k] * dp[k - lambda]
  215 
  217 
  218        L_result  = 
STEP(0)  ; L_result += 
STEP(1) ;
 
  219        L_result += 
STEP(2)  ; L_result += 
STEP(3) ;
 
  220        L_result += 
STEP(4)  ; L_result += 
STEP(5)  ;
 
  221        L_result += 
STEP(6)  ; L_result += 
STEP(7)  ;
 
  222        L_result += 
STEP(8)  ; L_result += 
STEP(9)  ;
 
  223        L_result += 
STEP(10) ; L_result += 
STEP(11) ;
 
  224        L_result += 
STEP(12) ; L_result += 
STEP(13) ;
 
  225        L_result += 
STEP(14) ; L_result += 
STEP(15) ;
 
  226        L_result += 
STEP(16) ; L_result += 
STEP(17) ;
 
  227        L_result += 
STEP(18) ; L_result += 
STEP(19) ;
 
  228        L_result += 
STEP(20) ; L_result += 
STEP(21) ;
 
  229        L_result += 
STEP(22) ; L_result += 
STEP(23) ;
 
  230        L_result += 
STEP(24) ; L_result += 
STEP(25) ;
 
  231        L_result += 
STEP(26) ; L_result += 
STEP(27) ;
 
  232        L_result += 
STEP(28) ; L_result += 
STEP(29) ;
 
  233        L_result += 
STEP(30) ; L_result += 
STEP(31) ;
 
  234        L_result += 
STEP(32) ; L_result += 
STEP(33) ;
 
  235        L_result += 
STEP(34) ; L_result += 
STEP(35) ;
 
  236        L_result += 
STEP(36) ; L_result += 
STEP(37) ;
 
  237        L_result += 
STEP(38) ; L_result += 
STEP(39) ;
 
  238 
  239        if (L_result > L_max) {
  240 
  242            L_max = L_result;
  243        }
  244    }
  245#   endif
  247 
  248    L_max <<= 1;
  249 
  250    
  251
  252    assert(scal <= 100 && scal >=  -100);
  253    L_max = L_max >> (6 - scal);    
  254 
  255    assert( Nc <= 120 && Nc >= 40);
  256 
  257    
  258
  259
  260    L_power = 0;
  261    for (k = 0; k <= 39; k++) {
  262 
  264 
  265        L_temp   = 
SASR( dp[k - 
Nc], 3 );
 
  266        L_power += L_temp * L_temp;
  267    }
  268    L_power <<= 1;  
  269 
  270    
  271
  272 
  273    if (L_max <= 0)  {
  274        *bc_out = 0;
  275        return;
  276    }
  277    if (L_max >= L_power) {
  278        *bc_out = 3;
  279        return;
  280    }
  281 
  282    temp = gsm_norm( L_power );
  283 
  284    R = (
word)
SASR( L_max   << temp, 16 );
 
  286 
  287    
  288
  289 
  290    
  291
  292
  295}