
int make_friends(const char *name1, const char *name2, User *head) {
    User *user1 = NULL;
    User *user2 = NULL;
    int friend_count1 = 0;
    int friend_count2 = 0;

    // Find the two users with the given names
    User *current = head;
    while (current != NULL) {
        if (strcmp(current->name, name1) == 0) {
            user1 = current;
        } if (strcmp(current->name, name2) == 0) { 
            user2 = current;
        }
        if (user1 != NULL && user2 != NULL) {
            break;
        }
    }

    // Check if at least one user does not exist and return 4 if so is true
    if (user1 == NULL || user2 == NULL) {
        return 4;
    }

    // Check if the same user is passed in twice and return 3 if so is true
    if (user1 == user2) { 
        return 3;
    }

    // Create marker to be used to check if already friends
    int marker = 0;
    // Check if the two users are already friends and return 1 if so is true
    for (int i = 0; i < MAX_FRIENDS; i++) {
        if (user1->friends[i] == user2) {
            marker = 1;
        }
        if (user2->friends[i] == user1) {
            marker = 1;
        }
        if (user1->friends[i] == NULL) {
            friend_count1++;
        }
        if (user2->friends[i] == NULL) {
            friend_count2++;
        }
    }

    // Check if at least one user has MAX_FRIENDS friends
    if (friend_count1 == 0 || friend_count2 == 0) {
        return 2;
    }

    // Return 1 if users are already friends and none of the other error return statements apply
    if (marker == 1) return 1;

    // Make the two users friends with each other
    user1->friends[MAX_FRIENDS - friend_count1] = user2;
    user2->friends[MAX_FRIENDS - friend_count2] = user1;
    return 0;
}
/*
 * Make two users friends with each other.  This is symmetric - a pointer to
 * each user must be stored in the 'friends' array of the other.
 *
 * New friends must be added in the first empty spot in the 'friends' array.
 *
 * Return:
 *   - 0 on success.
 *   - 1 if the two users are already friends.
 *   - 2 if the users are not already friends, but at least one already has
 *     MAX_FRIENDS friends.
 *   - 3 if the same user is passed in twice.
 *   - 4 if at least one user does not exist.
 *
 * Do not modify either user if the result is a failure.
 * NOTE: If multiple errors apply, return the *largest* error code that applies.
 */