             first = true;
         }
 
-        std::swap(a, b);
-        std::swap(mirror_1_a, mirror_1_b);
-        std::swap(mirror_2_a, mirror_2_b);
+        swap(a, b);
+        swap(mirror_1_a, mirror_1_b);
+        swap(mirror_2_a, mirror_2_b);
 
         i = 0;
         startl = 0;

    cudaMalloc((void**) &res->input_lexpr, num_pixels*sizeof(expr_t*));
    cudaMalloc((void**) &res->input_uexpr, num_pixels*sizeof(expr_t*));

    double* tmp_weights = (double*) malloc(expr_size*sizeof(double));
    size_t* tmp_dim = (size_t*) malloc(expr_size*sizeof(size_t));

    for(size_t i = 0; i < num_pixels; i++)
    {
        for(size_t j = 0; j < expr_size; j++)
        {
            tmp_weights[j] = lexpr_weights[i*expr_size + j];
            tmp_dim[j] = lexpr_dim[i*expr_size + j];
        }

        expr_t* lexpr = create_sparse_expr(tmp_weights, lexpr_cst[i], tmp_dim, expr_size);
        sort_sparse_expr(lexpr);
        copy_sparse_expr_host_to_device_expr(res->input_lexpr, i, lexpr);
        free_expr(lexpr);

        for(size_t j = 0; j < expr_size; j++)
        {
            tmp_weights[j] = uexpr_weights[i*expr_size + j];
            tmp_dim[j] = uexpr_dim[i*expr_size + j];
        }

        expr_t* uexpr = create_sparse_expr(tmp_weights, uexpr_cst[i], tmp_dim, expr_size);
        sort_sparse_expr(uexpr);
        copy_sparse_expr_host_to_device_expr(res->input_uexpr, i, uexpr);
        free_expr(uexpr);
    }

    free(tmp_weights);
    free(tmp_dim);

    return abstract0_of_fppoly(man, res);
}

    else
    {
        // if a points to the temporaries created in merge_sort, swap, then memcpy from b to a, then free the temporaries
        swap(a, b);
        swap(mirror_1_a, mirror_1_b);
        swap(mirror_2_a, mirror_2_b);

        memcpy(a, b, length*sizeof(size_t));
        memcpy(mirror_1_a, mirror_1_b, length*sizeof(double));
