Function to list all the blocks
The function block_admin_display_prepare_blocks() is the function used in the block module admin page for this purpose, but it's not part of the documented API, so you cannot absolutely rely on it. You would need code along the following lines:

module_load_include('inc', 'block', 'block.admin');
global $theme_key;
$blocks = block_admin_display_prepare_blocks($theme_key);
...


This will return all blocks, unlike block_list() which only returns those for the current user and for the current page.