    float_type sup_inf = b_sup*c_inf;
    float_type sup_sup = b_sup*c_sup;
 
-   float_type min1 = min(inf_inf, inf_sup);
-   float_type min2 = min(sup_inf, sup_sup);
-
-   *a_inf = min(min1, min2);
-
-   float_type max1 = max(inf_inf, inf_sup);
-   float_type max2 = max(sup_inf, sup_sup);
-
-   *a_sup = max(max1, max2);
+   if(inf_inf < inf_sup)
+   {
+       if(sup_inf < sup_sup)
+       {
+           if(inf_inf < sup_inf)
+           {
+               *a_inf = inf_inf;
+           }
+           else
+           {
+               *a_inf = sup_inf;
+           }
+
+           if(inf_sup < sup_sup)
+           {
+               *a_sup = sup_sup;
+           }
+           else
+           {
+               *a_sup = inf_sup;
+           }
+       }
+       else
+       {
+           if(inf_inf < sup_sup)
+           {
+               *a_inf = inf_inf;
+           }
+           else
+           {
+               *a_inf = sup_sup;
+           }
+
+           if(inf_sup < sup_inf)
+           {
+               *a_sup = sup_inf;
+           }
+           else
+           {
+               *a_sup = inf_sup;
+           }
+       }
+   }
+   else
+   {
+       if(sup_inf < sup_sup)
+       {
+           if(inf_sup < sup_inf)
+           {
+               *a_inf = inf_sup;
+           }
+           else
+           {
+               *a_inf = sup_inf;
+           }
+
+           if(inf_inf < sup_sup)
+           {
+               *a_sup = sup_sup;
+           }
+           else
+           {
+               *a_sup = inf_inf;
+           }
+       }
+       else
+       {
+           if(inf_sup < sup_sup)
+           {
+               *a_inf = inf_sup;
+           }
+           else
+           {
+               *a_inf = sup_sup;
+           }
+
+           if(inf_inf < sup_inf)
+           {
+               *a_sup = sup_inf;
+           }
+           else
+           {
+               *a_sup = inf_inf;
+           }
+       }
+   }
 }
 
 

            inf_coeff[a] = 0.0;
            sup_coeff[a] = 0.0;
            float_type tmp1, tmp2;
            elina_double_interval_mul(&tmp1, &tmp2, old_inf_coeff, old_sup_coeff, 0, ub);

            atomicAdd(&inf_cst[n], tmp2);
            atomicAdd(&sup_cst[n], tmp2);


                size_t mat_out = local_n*length_x*length_y*output_size_z + j;

                elina_double_interval_mul2(&tmp1, &tmp2, inf_coeff[mat_out], sup_coeff[mat_out], input_inf[i], input_sup[i]);

                res_sup = res_sup + tmp2;
            }
