#define RCC_BASE       0x40021000U
#define GPIOA_BASE     0x50000000U // Correct base address for GPIOA

// Offsets for relevant registers
#define RCC_IOPENR     (*(volatile uint32_t *)(RCC_BASE + 0x34))
#define GPIOA_MODER    (*(volatile uint32_t *)(GPIOA_BASE + 0x00))
#define GPIOA_PUPDR    (*(volatile uint32_t *)(GPIOA_BASE + 0x0C))
#define GPIOA_IDR      (*(volatile uint32_t *)(GPIOA_BASE + 0x10))
#define GPIOA_ODR      (*(volatile uint32_t *)(GPIOA_BASE + 0x14))

#define PIN5           5 // Pin number for PA5
#define PIN4           4 // Pin number for PA4

int main(void) {
    RCC_IOPENR |= (1 << 0);
    GPIOA_MODER &= ~(3 << (PIN5 * 2));
    GPIOA_MODER &= ~(3 << (PIN4 * 2));
    GPIOA_MODER |= (1 << (PIN4 * 2));
    GPIOA_PUPDR &= ~(3 << (PIN5 * 2));
    GPIOA_PUPDR |= (1 << (PIN5 * 2));
    while (1) {
        if (!(GPIOA_IDR & (1 << PIN5))) { 
            GPIOA_ODR |= (1 << PIN4); 
        } else { 
            GPIOA_ODR &= ~(1 << PIN4);
        }
    }

    return 0;
}