Since the IRC is silent on addressing unsafe or dangerous buildings not related to permitted work, then the IEBC is what you use to determine if it is safe, unsafe or dangerous for the occupants and their visitors.
IEBC 2018
[A] 102.4.1 Conflicts.
Where conflicts occur between provisions of this code and referenced codes and standards, the provisions of this code shall apply.
[A] 102.4.2 Conflicting provisions.
Where the extent of the reference to a referenced code or standard includes subject matter that is within the scope of this code, the provisions of this code, as applicable, shall take precedence over the provisions in the referenced code or standard.
[A] BUILDING. Any structure utilized or intended for supporting or sheltering any occupancy.
[A] EXISTING BUILDING. A building erected prior to the date of adoption of the appropriate code, or one for which a legal building permit has been issued.
[A] EXISTING STRUCTURE. A structure erected prior to the date of adoption of the appropriate code, or one for which a legal building permit has been issued.
[BS] DANGEROUS. Any building, structure or portion thereof that meets any of the conditions described below shall be deemed dangerous:
1. The building or structure has collapsed, has partially collapsed, has moved off its foundation, or lacks the necessary support of the ground.
2. There exists a significant risk of collapse, detachment or dislodgement of any portion, member, appurtenance or ornamentation of the building or structure under service loads.