main (int argc, char * * argv)
{
  struct GOptionGroup * D.18525;
  int D.18526;
  const char * iftmp.0;
  struct GError * err.1;
  gchar * D.18531;
  gchar * * args.2;
  gchar * D.18539;
  int D.18540;
  long unsigned int D.18541;
  long unsigned int D.18542;
  gchar * * D.18543;
  gchar * D.18544;
  int D.18545;
  unsigned int D.18549;
  int D.18552;
  void * * D.18553;
  long unsigned int D.18554;
  long unsigned int D.18555;
  void * * D.18556;
  void * D.18557;
  int run.3;
  double D.18559;

  {
    struct GPtrArray * files;
    gchar * * args;
    guint num;
    guint i;
    struct GError * err;
    gint run;
    struct GOptionContext * ctx;
    struct GOptionEntry options[3];
    struct GTimer * timer;

    try
      {
        args = 0B;
        err = 0B;
        run = 100;
        options = {};
        options[0].long_name = "runtime";
        options[0].arg = 2;
        options[0].arg_data = &run;
        options[0].description = "maximum play time (ms)";
        options[1].long_name = "";
        options[1].arg = 6;
        options[1].arg_data = &args;
        ctx = g_option_context_new ("FILES OR DIRECTORIES WITH AUDIO FILES");
        g_option_context_add_main_entries (ctx, &options, 0B);
        D.18525 = gst_init_get_option_group ();
        g_option_context_add_group (ctx, D.18525);
        D.18526 = g_option_context_parse (ctx, &argc, &argv, &err);
        if (D.18526 == 0) goto <D.18527>; else goto <D.18528>;
        <D.18527>:
        err.1 = err;
        D.18531 = err.1->message;
        if (D.18531 != 0B) goto <D.18532>; else goto <D.18533>;
        <D.18532>:
        err.1 = err;
        iftmp.0 = err.1->message;
        goto <D.18534>;
        <D.18533>:
        iftmp.0 = "(NULL)";
        <D.18534>:
        g_print ("Error initializing: %s\n", iftmp.0);
        exit (1);
        <D.18528>:
        g_option_context_free (ctx);
        args.2 = args;
        if (args.2 == 0B) goto <D.18535>; else goto <D.18538>;
        <D.18538>:
        args.2 = args;
        D.18539 = *args.2;
        if (D.18539 == 0B) goto <D.18535>; else goto <D.18536>;
        <D.18535>:
        g_print ("Please provide one or more directories with audio files\n\n");
        D.18540 = 1;
        return D.18540;
        <D.18536>:
        files = g_ptr_array_new ();
        args.2 = args;
        num = g_strv_length (args.2);
        i = 0;
        goto <D.18518>;
        <D.18517>:
        args.2 = args;
        D.18541 = (long unsigned int) i;
        D.18542 = D.18541 * 8;
        D.18543 = args.2 + D.18542;
        D.18544 = *D.18543;
        D.18545 = g_path_is_absolute (D.18544);
        if (D.18545 != 0) goto <D.18546>; else goto <D.18547>;
        <D.18546>:
        args.2 = args;
        D.18541 = (long unsigned int) i;
        D.18542 = D.18541 * 8;
        D.18543 = args.2 + D.18542;
        D.18544 = *D.18543;
        check_arg (files, D.18544);
        goto <D.18548>;
        <D.18547>:
        args.2 = args;
        D.18541 = (long unsigned int) i;
        D.18542 = D.18541 * 8;
        D.18543 = args.2 + D.18542;
        D.18544 = *D.18543;
        g_log (0B, 16, "Argument \'%s\' is not an absolute file path", D.18544);
        <D.18548>:
        i = i + 1;
        <D.18518>:
        if (i < num) goto <D.18517>; else goto <D.18519>;
        <D.18519>:
        D.18549 = files->len;
        if (D.18549 == 0) goto <D.18550>; else goto <D.18551>;
        <D.18550>:
        g_print ("Did not find any files\n\n");
        D.18540 = 1;
        return D.18540;
        <D.18551>:
        timer = g_timer_new ();
        goto <D.18522>;
        <D.18521>:
        {
          gint32 idx;

          D.18549 = files->len;
          D.18552 = (int) D.18549;
          idx = g_random_int_range (0, D.18552);
          D.18553 = files->pdata;
          D.18554 = (long unsigned int) idx;
          D.18555 = D.18554 * 8;
          D.18556 = D.18553 + D.18555;
          D.18557 = *D.18556;
          run.3 = run;
          play_file (run.3, D.18557);
        }
        <D.18522>:
        D.18559 = g_timer_elapsed (timer, 0B);
        if (D.18559 < 1.2e+2) goto <D.18521>; else goto <D.18523>;
        <D.18523>:
        args.2 = args;
        g_strfreev (args.2);
        g_timer_destroy (timer);
        D.18540 = 0;
        return D.18540;
      }
    finally
      {
        args = {CLOBBER};
        err = {CLOBBER};
        run = {CLOBBER};
        options = {CLOBBER};
      }
  }
  D.18540 = 0;
  return D.18540;
}


check_arg (struct GPtrArray * files, const gchar * arg)
{
  int D.18564;
  gchar * D.18567;
  struct GDir * dir;

  dir = g_dir_open (arg, 0, 0B);
  if (dir != 0B) goto <D.18562>; else goto <D.18563>;
  <D.18562>:
  {
    const gchar * entry;

    goto <D.18502>;
    <D.18501>:
    {
      gchar * path;

      path = g_strconcat (arg, "/", entry, 0B);
      check_arg (files, path);
      g_free (path);
    }
    <D.18502>:
    entry = g_dir_read_name (dir);
    if (entry != 0B) goto <D.18501>; else goto <D.18503>;
    <D.18503>:
    g_dir_close (dir);
    return;
  }
  <D.18563>:
  D.18564 = g_file_test (arg, 16);
  if (D.18564 != 0) goto <D.18565>; else goto <D.18566>;
  <D.18565>:
  D.18567 = g_strdup_printf ("file://%s", arg);
  g_ptr_array_add (files, D.18567);
  <D.18566>:
}


play_file (const gint delay, const gchar * uri)
{
  unsigned int D.18569;
  unsigned int delay.4;
  unsigned int D.18573;
  int D.18574;
  int D.18575;
  long unsigned int D.18576;
  struct GstBus * D.18577;
  <unnamed type> D.18580;
  gchar * debug.5;
  struct GError * gerror.6;
  struct GstObject * D.18583;
  const gchar * D.18584;
  GstStateChangeReturn sret;
  struct GstMessage * msg;
  struct GstElement * play;
  guint wait_nanosecs;
  void next = <<< error >>>;

  play = gst_element_factory_make ("playbin", "playbin");
  g_object_set (play, "uri", uri, 0B);
  g_printerr ("Playing %s\n", uri);
  sret = gst_element_set_state (play, 4);
  D.18569 = sret + 4294967295;
  if (D.18569 > 1) goto <D.18570>; else goto <D.18571>;
  <D.18570>:
  g_printerr ("ERROR: state change failed, sret=%d\n", sret);
  goto next;
  <D.18571>:
  delay.4 = (unsigned int) delay;
  D.18573 = delay.4 * 1000000;
  D.18574 = (int) D.18573;
  D.18575 = g_random_int_range (0, D.18574);
  wait_nanosecs = (guint) D.18575;
  D.18576 = (long unsigned int) wait_nanosecs;
  D.18577 = play->bus;
  msg = gst_bus_poll (D.18577, 3, D.18576);
  if (msg != 0B) goto <D.18578>; else goto <D.18579>;
  <D.18578>:
  D.18580 = msg->type;
  switch (D.18580) <default: <D.18493>, case 1: <D.18492>, case 2: <D.18488>>
  <D.18488>:
  {
    struct GError * gerror;
    gchar * debug;

    try
      {
        gst_message_parse_error (msg, &gerror, &debug);
        debug.5 = debug;
        gerror.6 = gerror;
        D.18583 = msg->src;
        gst_object_default_error (D.18583, gerror.6, debug.5);
        gerror.6 = gerror;
        g_error_free (gerror.6);
        debug.5 = debug;
        g_free (debug.5);
        goto <D.18491>;
      }
    finally
      {
        gerror = {CLOBBER};
        debug = {CLOBBER};
      }
  }
  <D.18492>:
  g_printerr ("Got EOS\n");
  goto <D.18491>;
  <D.18493>:
  D.18580 = msg->type;
  D.18584 = gst_message_type_get_name (D.18580);
  g_printerr ("Got unexpected %s messge\n", D.18584);
  goto <D.18491>;
  <D.18491>:
  gst_message_unref (msg);
  goto next;
  <D.18579>:
  g_print (".");
  next:
  gst_element_set_state (play, 1);
  gst_object_unref (play);
}


gst_message_unref (struct GstMessage * msg)
{
  gst_mini_object_unref (msg);
}


