Forming Basis Functions from 6-31G Basis Set for Carbon Atom

I am a computer science grad and I am working to write an electronic structure calculation program and I am stuck at forming basis functions using 6-31G Basis set for atoms having higher atomic numbers (p,d,f shells).


For example, consider a gaussian g as



```
g(alpha) = (2*alpha/pi)^(3/4) * exp(-alpha*r^2).

```

Looking at the Carbon (1s2 2s2 2p2) basis set data for 6-31G basis set



```
C     0
S   6   1.00
      0.3047524880D+04       0.1834737132D-02
      0.4573695180D+03       0.1403732281D-01
      0.1039486850D+03       0.6884262226D-01
      0.2921015530D+02       0.2321844432D+00
      0.9286662960D+01       0.4679413484D+00
      0.3163926960D+01       0.3623119853D+00
SP   3   1.00
      0.7868272350D+01      -0.1193324198D+00       0.6899906659D-01
      0.1881288540D+01      -0.1608541517D+00       0.3164239610D+00
      0.5442492580D+00       0.1143456438D+01       0.7443082909D+00
SP   1   1.00
      0.1687144782D+00       0.1000000000D+01       0.1000000000D+01

```

How many basis functions will carbon have in this case? I have been following a [lecture series](https://www.youtube.com/watch?v=yjVn6e-F_b8&list=PL1c_abw8OtQ_U3fuvA8UEB8Kq4r2lIsb3) which does HF SCF calculation for a simple H2 molecule where each Hydrogen atom has two basis functions as per 6-31G basis set.



```
H     0
S   3   1.00
      0.1873113696D+02       0.3349460434D-01
      0.2825394365D+01       0.2347269535D+00
      0.6401216923D+00       0.8137573261D+00
S   1   1.00
      0.1612777588D+00       1.0000000

```

I can write the two basis functions in the form



```
b1= 0.0334*g(18.73) + 0.2347*g(2.825) + 0.8137*g(0.64);
b2= g(0.161);

```

In a similar manner, how would I go about writing the basis functions for Carbon atom. Any advise would be very helpful as I am stuck in this for couple of days and haven't been able to find any substantial resource for this.


I did stumble upon this [previous post](https://chemistry.stackexchange.com/questions/86755/how-to-form-6-31g-basis-set-specific-instructions) but having a hard time figuring out how did 9 basis functions come for Carbon.


