FormatMessage (guint32 flags, const void * source, guint32 messageid, guint32 languageid, gunichar2 * buf, guint32 size)
{
  unsigned int D.9301;
  guint32 D.9304;
  unsigned int D.9305;
  unsigned int D.9310;
  unsigned int D.9314;
  unsigned int D.9321;
  long unsigned int iftmp.0;
  unsigned int D.9325;
  long unsigned int D.9328;
  long unsigned int D.9330;
  void * D.9331;
  unsigned int D.9335;
  long unsigned int D.9336;
  long unsigned int D.9337;
  long unsigned int D.9338;
  gunichar2 * D.9339;
  guint32 strlen;
  guint32 cpy;
  gunichar2 * str;
  gboolean freestr;
  static const char __func__[14] = "FormatMessage";

  freestr = 0;
  D.9301 = flags & 10752;
  if (D.9301 != 512) goto <D.9302>; else goto <D.9303>;
  <D.9302>:
  monoeg_g_log (0B, 16, "%s: Unsupported flags passed: %d", &__func__, flags);
  SetLastError (50);
  D.9304 = 0;
  return D.9304;
  <D.9303>:
  D.9305 = flags & 255;
  if (D.9305 != 0) goto <D.9306>; else goto <D.9307>;
  <D.9306>:
  D.9305 = flags & 255;
  monoeg_g_log (0B, 16, "%s: Message width mask (%d) not supported", &__func__, D.9305);
  <D.9307>:
  if (languageid != 0) goto <D.9308>; else goto <D.9309>;
  <D.9308>:
  monoeg_g_log (0B, 16, "%s: Locale 0x%x not supported, returning language neutral string", &__func__, languageid);
  <D.9309>:
  D.9310 = flags & 1024;
  if (D.9310 != 0) goto <D.9311>; else goto <D.9312>;
  <D.9311>:
  str = source;
  goto <D.9313>;
  <D.9312>:
  D.9314 = flags & 4096;
  if (D.9314 != 0) goto <D.9315>; else goto <D.9316>;
  <D.9315>:
  {
    const char * msg;

    msg = message_string (messageid);
    if (msg != 0B) goto <D.9317>; else goto <D.9318>;
    <D.9317>:
    str = monoeg_g_utf8_to_utf16 (msg, -1, 0B, 0B, 0B);
    goto <D.9319>;
    <D.9318>:
    {
      char * msg2;

      msg2 = monoeg_g_strdup_printf ("mono-io-layer-error (%d)", messageid);
      str = monoeg_g_utf8_to_utf16 (msg2, -1, 0B, 0B, 0B);
      monoeg_g_free (msg2);
    }
    <D.9319>:
    freestr = 1;
  }
  goto <D.9320>;
  <D.9316>:
  str = monoeg_g_utf8_to_utf16 ("No message specified", -1, 0B, 0B, 0B);
  <D.9320>:
  <D.9313>:
  strlen = unicode_chars (str);
  D.9321 = flags & 256;
  if (D.9321 != 0) goto <D.9322>; else goto <D.9323>;
  <D.9322>:
  D.9325 = strlen + 2;
  if (D.9325 < size) goto <D.9326>; else goto <D.9327>;
  <D.9326>:
  D.9328 = (long unsigned int) size;
  iftmp.0 = D.9328 * 2;
  goto <D.9329>;
  <D.9327>:
  D.9325 = strlen + 2;
  D.9330 = (long unsigned int) D.9325;
  iftmp.0 = D.9330 * 2;
  <D.9329>:
  D.9331 = monoeg_malloc0 (iftmp.0);
  MEM[(void * *)buf] = D.9331;
  <D.9323>:
  if (strlen >= size) goto <D.9332>; else goto <D.9333>;
  <D.9332>:
  cpy = size + 4294967295;
  goto <D.9334>;
  <D.9333>:
  cpy = strlen;
  <D.9334>:
  D.9335 = cpy * 2;
  D.9336 = (long unsigned int) D.9335;
  memcpy (buf, str, D.9336);
  D.9337 = (long unsigned int) cpy;
  D.9338 = D.9337 * 2;
  D.9339 = buf + D.9338;
  *D.9339 = 0;
  if (freestr != 0) goto <D.9340>; else goto <D.9341>;
  <D.9340>:
  monoeg_g_free (str);
  <D.9341>:
  D.9304 = strlen;
  return D.9304;
}


message_string (guint32 id)
{
  const gchar * D.9345;
  struct _IO_FILE * stderr.1;
  const char * msg;

  msg = find_msg (id, &common_messages, 85);
  if (msg != 0B) goto <D.9343>; else goto <D.9344>;
  <D.9343>:
  D.9345 = msg;
  return D.9345;
  <D.9344>:
  msg = find_msg (id, &messages, 1697);
  if (msg != 0B) goto <D.9346>; else goto <D.9347>;
  <D.9346>:
  stderr.1 = stderr;
  fprintf (stderr.1, "messages.c: A message was found on the uncommon code path: %d - %s", id, msg);
  D.9345 = msg;
  return D.9345;
  <D.9347>:
  msg = find_linear_msg (id, &common_messages, 85);
  if (msg != 0B) goto <D.9349>; else goto <D.9350>;
  <D.9349>:
  D.9345 = msg;
  return D.9345;
  <D.9350>:
  msg = find_linear_msg (id, &messages, 1697);
  if (msg != 0B) goto <D.9351>; else goto <D.9352>;
  <D.9351>:
  D.9345 = msg;
  return D.9345;
  <D.9352>:
  D.9345 = 0B;
  return D.9345;
}


find_msg (guint32 id, struct ErrorDesc * base, int n)
{
  int id.2;
  long unsigned int D.9355;
  const gchar * D.9358;
  struct ErrorDesc d;
  struct ErrorDesc * result;

  try
    {
      id.2 = (int) id;
      d.id = id.2;
      D.9355 = (long unsigned int) n;
      result = mono_binary_search (&d, base, D.9355, 16, msg_compare);
      if (result == 0B) goto <D.9356>; else goto <D.9357>;
      <D.9356>:
      D.9358 = 0B;
      return D.9358;
      <D.9357>:
      D.9358 = result->txt;
      return D.9358;
    }
  finally
    {
      d = {CLOBBER};
    }
}


msg_compare (const void * first, const void * second)
{
  int D.9361;
  int D.9362;
  int D.9363;
  struct ErrorDesc * efirst;
  struct ErrorDesc * esecond;

  efirst = first;
  esecond = second;
  D.9362 = efirst->id;
  D.9363 = esecond->id;
  D.9361 = D.9362 - D.9363;
  return D.9361;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__))
fprintf (struct FILE * restrict __stream, const char * restrict __fmt)
{
  int D.9365;

  D.9365 = __fprintf_chk (__stream, 1, __fmt, __builtin_va_arg_pack ());
  return D.9365;
}


find_linear_msg (guint32 id, struct ErrorDesc * base, int n)
{
  long unsigned int D.9367;
  long unsigned int D.9368;
  struct ErrorDesc * D.9369;
  int D.9370;
  int error_shown.3;
  struct _IO_FILE * stderr.4;
  const char * D.9378;
  unsigned int D.9379;
  int error_shown.5;
  const gchar * D.9385;
  int i;
  int prev;

  prev = -1;
  i = 0;
  goto <D.9274>;
  <D.9273>:
  D.9367 = (long unsigned int) i;
  D.9368 = D.9367 * 16;
  D.9369 = base + D.9368;
  D.9370 = D.9369->id;
  if (D.9370 > prev) goto <D.9371>; else goto <D.9372>;
  <D.9371>:
  D.9367 = (long unsigned int) i;
  D.9368 = D.9367 * 16;
  D.9369 = base + D.9368;
  prev = D.9369->id;
  goto <D.9373>;
  <D.9372>:
  {
    static int error_shown;

    error_shown.3 = error_shown;
    if (error_shown.3 == 0) goto <D.9375>; else goto <D.9376>;
    <D.9375>:
    error_shown = 1;
    stderr.4 = stderr;
    D.9367 = (long unsigned int) i;
    D.9368 = D.9367 * 16;
    D.9369 = base + D.9368;
    D.9378 = D.9369->txt;
    fprintf (stderr.4, "Mono: Incorrect message sorted in io-layer/messages.c at index %d (msg=%s)\n", i, D.9378);
    <D.9376>:
  }
  <D.9373>:
  D.9367 = (long unsigned int) i;
  D.9368 = D.9367 * 16;
  D.9369 = base + D.9368;
  D.9370 = D.9369->id;
  D.9379 = (unsigned int) D.9370;
  if (D.9379 == id) goto <D.9380>; else goto <D.9381>;
  <D.9380>:
  {
    static int error_shown;

    error_shown.5 = error_shown;
    if (error_shown.5 == 0) goto <D.9383>; else goto <D.9384>;
    <D.9383>:
    error_shown = 1;
    stderr.4 = stderr;
    D.9367 = (long unsigned int) i;
    D.9368 = D.9367 * 16;
    D.9369 = base + D.9368;
    D.9378 = D.9369->txt;
    fprintf (stderr.4, "Mono: Error %d with text %s is improperly sorted in io-layer/messages.c\n", id, D.9378);
    <D.9384>:
    D.9367 = (long unsigned int) i;
    D.9368 = D.9367 * 16;
    D.9369 = base + D.9368;
    D.9385 = D.9369->txt;
    return D.9385;
  }
  <D.9381>:
  i = i + 1;
  <D.9274>:
  if (i < n) goto <D.9273>; else goto <D.9275>;
  <D.9275>:
  D.9385 = 0B;
  return D.9385;
}


unicode_chars (const gunichar2 * str)
{
  long unsigned int D.9387;
  long unsigned int D.9388;
  const gunichar2 * D.9389;
  short unsigned int D.9390;
  guint32 D.9393;
  guint32 len;

  len = 0;
  <D.9284>:
  D.9387 = (long unsigned int) len;
  D.9388 = D.9387 * 2;
  D.9389 = str + D.9388;
  D.9390 = *D.9389;
  if (D.9390 == 0) goto <D.9391>; else goto <D.9392>;
  <D.9391>:
  D.9393 = len;
  return D.9393;
  <D.9392>:
  len = len + 1;
  goto <D.9284>;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.9395;
  long unsigned int D.9396;

  D.9396 = __builtin_object_size (__dest, 0);
  D.9395 = __builtin___memcpy_chk (__dest, __src, __len, D.9396);
  return D.9395;
}


