#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.14159265358979323846
int main (int argc, char **argv)
{
double offset, x, y, r, angle;
int order, n;

order = atoi (argv[1]);
r = atof (argv[2]);

offset = (2 * PI) / 36;
printf ("<gml>\n  <molecule>\n");

printf ("    <atom element=\"Si\" x =\"%f\" y=\"%f\" z=\"%f\"/>\n", 0.0, 0.0, -1.0);
printf ("    <atom element=\"Si\" x =\"%f\" y=\"%f\" z=\"%f\"/>\n", 0.0, 0.0, 1.0);
for (n = 0; n < order; n++)
  {
  angle = (2 * PI) / order;
  x = r * cos (n * angle);
  y = r * sin (n * angle);
  printf ("    <atom element=\"C\" x =\"%f\" y=\"%f\" z=\"%f\"/>\n", x, y, 0.0);

  x = r * cos (n * angle + offset);
  y = r * sin (n * angle + offset);
  printf ("    <atom element=\"O\" x =\"%f\" y=\"%f\" z=\"%f\"/>\n", x, y, 0.0);
  }

printf ("  </molecule>\n</gml>\n");

return 0;
}
