How to assign roles in my own registration form I know about assigning roles and permission in DRUPAL admin login where admin can add user and even add new roles (check here) to the new users.

I have a basic registration form in my page and while user register I want to assign roles to them for example - employee, superuser and admin roles. 

How do I do it, do I have create a new module and may be use the ROLE module functionality in Core DRUPAL.

I have also checked this Link which explains about basic Users, roles and permissions in DRUPAL but it does not answer my question.

So 


I need to create new user in Drupal from my own Registration form. 
I need to have my own custom roles (eg. employee, superuser and admin roles) - This Link might help me in this 
This new user which are registering from my own custom registration form, should be assigned with this custom roles(eg. employee, superuser and admin roles).


Can some please tell me how do I do this in Drupal 7 or Does anyone knows any Drupal modules which can help me do this efficiently or should I go with own PHP code. 

which will be more efficient way for doing this.

Thanks in advance :)
function company_form()
    {
         $form['company_username'] =  array(
          '#type' =&gt; 'textfield',
          '#title' =&gt; 'company-username',
          '#default_value' =&gt; '',
              '#required'=&gt;'true' 
      );  
          $form['company_email'] =  array(
          '#type' =&gt; 'textfield',
          '#title' =&gt; 'company-email',
              '#required'=&gt;'true', 
          '#default_value' =&gt; '',
          '#element_validate' =&gt; array('generate_special_form_validate'),
      );  
           $form['company_password'] =  array(
          '#type' =&gt; 'textfield',
          '#title' =&gt; 'company-password',
               '#required'=&gt;'true', 
          '#default_value' =&gt; ''
      );  

      $form['submit'] =  array(
          '#type' =&gt; 'submit',
          '#title' =&gt; '',
          '#value' =&gt; 'Submit',
          '#default_value' =&gt; ''
      );
      return $form;
    }
    function company_form__validate(&amp;$form_state,$form) {

         if (!valid_email_address($form['input']['email'])) {
         form_set_error($form['input']['email'],'Please enter a valid email address.');
       }
    }
    function company_form_submit($form, &amp;$form_state)
    {


     global $user;
        $company_username = $form_state['input']['company_username'];
        $company_email = $form_state['input']['company_email'];
        $company_password = $form_state['input']['company_password'];        
         $fields = array(
              'name' =&gt; $company_username,
              'pass' =&gt;$company_password,
              'mail' =&gt; $company_email,
              'init' =&gt; $company_email,
              'status' =&gt; 1,
              'access' =&gt; REQUEST_TIME,
              'roles' =&gt; array(
               4 =&gt; 'company',
                ),

        );
        $account=user_save('', $fields);  


    if($account-&gt;uid)
    {
     drupal_set_message('User Created SuccessFully');
    }

}


Firstly you have to create roles from backend.
and then You can Assign as many roles by passing role id and role name in array.

'roles' =&gt; array(
               4 =&gt; 'company',
                ),


Hope this code helps you.