int make_friends(const char *name1, const char *name2, User *head) {
    User* curr1 = find_user(name1, head);
    User* curr2 = find_user(name2, head);

    // check if user exists
    if (curr1 == NULL || curr2 == NULL){
        return 4;
    }

    // check if the same user is passed in twice
    if (curr1 == curr2){
        return 3;
    }


    // check for number of friends for each user
    int count1 = 0;
    for(int i = 0; i < MAX_FRIENDS; i++){
        if (curr1->friends[i] != NULL){
            count1 += 1;

            // check if the two users are already friends
            if (curr1->friends[i] == curr2)
            {
                return 1;
            }
        }
    }
    int count2 = 0;
    for(int i = 0; i<MAX_FRIENDS;i++){
        if (curr2->friends[i] != NULL){
            count2 += 1;

            // check if the two users are already friends
            if (curr2->friends[i] == curr1)
            {
                return 1;
            }
        }
    }
    
    if (count1 >= MAX_FRIENDS || count2 >= MAX_FRIENDS){
        return 2;
    }

    
    
    int i1 = 0;
    int i2 = 0;
    
    while (i1 < MAX_FRIENDS || i2 < MAX_FRIENDS){
        if (curr1->friends[i1] != NULL){
            i1++;
        }
        else{
            curr1->friends[i1] = curr2;
        }
    
        if (curr2->friends[i2] != NULL){
            i2++;
        }
        else{
            curr2->friends[i2] = curr1;
        }

        if (curr1->friends[i1] != NULL && curr2->friends[i2] != NULL){
            break;
        }
    }
    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.
 */