```python
def max_subarray_product(arr):
    if not arr:
        return 0

    # Initialize trackers for the max/min product of subarrays ending at the current position
    max_ending_here = arr[0]
    min_ending_here = arr[0]
    
    # Initialize the overall maximum product found so far
    max_product = arr[0]

    # Iterate through the array starting from the second element
    for i in range(1, len(arr)):
        num = arr[i]
        
        # A negative number can flip the max and min products.
        # We need to store the previous max_ending_here to calculate the new min_ending_here correctly.
        prev_max_ending_here = max_ending_here
        
        # The new maximum product ending at the current position can be:
        # 1. The number itself (starting a new subarray).
        # 2. The number multiplied by the previous maximum product.
        # 3. The number multiplied by the previous minimum product (if num is negative).
        max_ending_here = max(num, num * prev_max_ending_here, num * min_ending_here)
        
        # Similarly, update the minimum product ending at the current position.
        min_ending_here = min(num, num * prev_max_ending_here, num * min_ending_here)
        
        # Update the overall maximum product if the new max ending here is greater.
        max_product = max(max_product, max_ending_here)
        
    return max_product
```