FormatMessage (guint32 flags, const void * source, guint32 messageid, guint32 languageid, gunichar2 * buf, guint32 size)
{
  unsigned int D.9128;
  guint32 D.9131;
  unsigned int D.9132;
  unsigned int D.9137;
  unsigned int D.9141;
  unsigned int D.9148;
  long unsigned int iftmp.0;
  unsigned int D.9152;
  long unsigned int D.9155;
  long unsigned int D.9157;
  void * D.9158;
  unsigned int D.9162;
  long unsigned int D.9163;
  long unsigned int D.9164;
  long unsigned int D.9165;
  gunichar2 * D.9166;
  guint32 strlen;
  guint32 cpy;
  gunichar2 * str;
  gboolean freestr;
  static const char __func__[14] = "FormatMessage";

  freestr = 0;
  D.9128 = flags & 10752;
  if (D.9128 != 512) goto <D.9129>; else goto <D.9130>;
  <D.9129>:
  monoeg_g_log (0B, 16, "%s: Unsupported flags passed: %d", &__func__, flags);
  SetLastError (50);
  D.9131 = 0;
  return D.9131;
  <D.9130>:
  D.9132 = flags & 255;
  if (D.9132 != 0) goto <D.9133>; else goto <D.9134>;
  <D.9133>:
  D.9132 = flags & 255;
  monoeg_g_log (0B, 16, "%s: Message width mask (%d) not supported", &__func__, D.9132);
  <D.9134>:
  if (languageid != 0) goto <D.9135>; else goto <D.9136>;
  <D.9135>:
  monoeg_g_log (0B, 16, "%s: Locale 0x%x not supported, returning language neutral string", &__func__, languageid);
  <D.9136>:
  D.9137 = flags & 1024;
  if (D.9137 != 0) goto <D.9138>; else goto <D.9139>;
  <D.9138>:
  str = source;
  goto <D.9140>;
  <D.9139>:
  D.9141 = flags & 4096;
  if (D.9141 != 0) goto <D.9142>; else goto <D.9143>;
  <D.9142>:
  {
    const char * msg;

    msg = message_string (messageid);
    if (msg != 0B) goto <D.9144>; else goto <D.9145>;
    <D.9144>:
    str = monoeg_g_utf8_to_utf16 (msg, -1, 0B, 0B, 0B);
    goto <D.9146>;
    <D.9145>:
    {
      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.9146>:
    freestr = 1;
  }
  goto <D.9147>;
  <D.9143>:
  str = monoeg_g_utf8_to_utf16 ("No message specified", -1, 0B, 0B, 0B);
  <D.9147>:
  <D.9140>:
  strlen = unicode_chars (str);
  D.9148 = flags & 256;
  if (D.9148 != 0) goto <D.9149>; else goto <D.9150>;
  <D.9149>:
  D.9152 = strlen + 2;
  if (D.9152 < size) goto <D.9153>; else goto <D.9154>;
  <D.9153>:
  D.9155 = (long unsigned int) size;
  iftmp.0 = D.9155 * 2;
  goto <D.9156>;
  <D.9154>:
  D.9152 = strlen + 2;
  D.9157 = (long unsigned int) D.9152;
  iftmp.0 = D.9157 * 2;
  <D.9156>:
  D.9158 = monoeg_malloc0 (iftmp.0);
  MEM[(void * *)buf] = D.9158;
  <D.9150>:
  if (strlen >= size) goto <D.9159>; else goto <D.9160>;
  <D.9159>:
  cpy = size + 4294967295;
  goto <D.9161>;
  <D.9160>:
  cpy = strlen;
  <D.9161>:
  D.9162 = cpy * 2;
  D.9163 = (long unsigned int) D.9162;
  memcpy (buf, str, D.9163);
  D.9164 = (long unsigned int) cpy;
  D.9165 = D.9164 * 2;
  D.9166 = buf + D.9165;
  *D.9166 = 0;
  if (freestr != 0) goto <D.9167>; else goto <D.9168>;
  <D.9167>:
  monoeg_g_free (str);
  <D.9168>:
  D.9131 = strlen;
  return D.9131;
}


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

  msg = find_msg (id, &common_messages, 85);
  if (msg != 0B) goto <D.9170>; else goto <D.9171>;
  <D.9170>:
  D.9172 = msg;
  return D.9172;
  <D.9171>:
  msg = find_msg (id, &messages, 1697);
  if (msg != 0B) goto <D.9173>; else goto <D.9174>;
  <D.9173>:
  stderr.1 = stderr;
  fprintf (stderr.1, "messages.c: A message was found on the uncommon code path: %d - %s", id, msg);
  D.9172 = msg;
  return D.9172;
  <D.9174>:
  msg = find_linear_msg (id, &common_messages, 85);
  if (msg != 0B) goto <D.9176>; else goto <D.9177>;
  <D.9176>:
  D.9172 = msg;
  return D.9172;
  <D.9177>:
  msg = find_linear_msg (id, &messages, 1697);
  if (msg != 0B) goto <D.9178>; else goto <D.9179>;
  <D.9178>:
  D.9172 = msg;
  return D.9172;
  <D.9179>:
  D.9172 = 0B;
  return D.9172;
}


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

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


msg_compare (const void * first, const void * second)
{
  int D.9188;
  int D.9189;
  int D.9190;
  struct ErrorDesc * efirst;
  struct ErrorDesc * esecond;

  efirst = first;
  esecond = second;
  D.9189 = efirst->id;
  D.9190 = esecond->id;
  D.9188 = D.9189 - D.9190;
  return D.9188;
}


fprintf (struct FILE * restrict __stream, const char * restrict __fmt)
{
  int D.9192;

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


find_linear_msg (guint32 id, struct ErrorDesc * base, int n)
{
  long unsigned int D.9194;
  long unsigned int D.9195;
  struct ErrorDesc * D.9196;
  int D.9197;
  int error_shown.3;
  const char * D.9204;
  struct _IO_FILE * stderr.4;
  unsigned int D.9206;
  int error_shown.5;
  const gchar * D.9212;
  int i;
  int prev;

  prev = -1;
  i = 0;
  goto <D.9101>;
  <D.9100>:
  D.9194 = (long unsigned int) i;
  D.9195 = D.9194 * 16;
  D.9196 = base + D.9195;
  D.9197 = D.9196->id;
  if (D.9197 > prev) goto <D.9198>; else goto <D.9199>;
  <D.9198>:
  D.9194 = (long unsigned int) i;
  D.9195 = D.9194 * 16;
  D.9196 = base + D.9195;
  prev = D.9196->id;
  goto <D.9200>;
  <D.9199>:
  {
    static int error_shown;

    error_shown.3 = error_shown;
    if (error_shown.3 == 0) goto <D.9202>; else goto <D.9203>;
    <D.9202>:
    error_shown = 1;
    D.9194 = (long unsigned int) i;
    D.9195 = D.9194 * 16;
    D.9196 = base + D.9195;
    D.9204 = D.9196->txt;
    stderr.4 = stderr;
    fprintf (stderr.4, "Mono: Incorrect message sorted in io-layer/messages.c at index %d (msg=%s)\n", i, D.9204);
    <D.9203>:
  }
  <D.9200>:
  D.9194 = (long unsigned int) i;
  D.9195 = D.9194 * 16;
  D.9196 = base + D.9195;
  D.9197 = D.9196->id;
  D.9206 = (unsigned int) D.9197;
  if (D.9206 == id) goto <D.9207>; else goto <D.9208>;
  <D.9207>:
  {
    static int error_shown;

    error_shown.5 = error_shown;
    if (error_shown.5 == 0) goto <D.9210>; else goto <D.9211>;
    <D.9210>:
    error_shown = 1;
    D.9194 = (long unsigned int) i;
    D.9195 = D.9194 * 16;
    D.9196 = base + D.9195;
    D.9204 = D.9196->txt;
    stderr.4 = stderr;
    fprintf (stderr.4, "Mono: Error %d with text %s is improperly sorted in io-layer/messages.c\n", id, D.9204);
    <D.9211>:
    D.9194 = (long unsigned int) i;
    D.9195 = D.9194 * 16;
    D.9196 = base + D.9195;
    D.9212 = D.9196->txt;
    return D.9212;
  }
  <D.9208>:
  i = i + 1;
  <D.9101>:
  if (i < n) goto <D.9100>; else goto <D.9102>;
  <D.9102>:
  D.9212 = 0B;
  return D.9212;
}


unicode_chars (const gunichar2 * str)
{
  long unsigned int D.9214;
  long unsigned int D.9215;
  const gunichar2 * D.9216;
  short unsigned int D.9217;
  guint32 D.9220;
  guint32 len;

  len = 0;
  <D.9111>:
  D.9214 = (long unsigned int) len;
  D.9215 = D.9214 * 2;
  D.9216 = str + D.9215;
  D.9217 = *D.9216;
  if (D.9217 == 0) goto <D.9218>; else goto <D.9219>;
  <D.9218>:
  D.9220 = len;
  return D.9220;
  <D.9219>:
  len = len + 1;
  goto <D.9111>;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.9222;
  long unsigned int D.9223;

  D.9223 = __builtin_object_size (__dest, 0);
  D.9222 = __builtin___memcpy_chk (__dest, __src, __len, D.9223);
  return D.9222;
}


