monoeg_g_utf8_strup (const gchar * str, gssize len)
{
  gchar * D.4695;

  D.4695 = utf8_case_conv (str, len, 1);
  return D.4695;
}


utf8_case_conv (const gchar * str, gssize len, gboolean upper)
{
  unsigned int i.0;
  unsigned int D.4698;
  gunichar * D.4699;
  gunichar iftmp.1;
  unsigned int D.4703;
  long int ulen.2;
  gchar * D.4706;
  gunichar * ustr;
  glong i;
  glong ulen;
  gchar * utf8;

  try
    {
      ustr = monoeg_g_utf8_to_ucs4_fast (str, len, &ulen);
      i = 0;
      goto <D.4581>;
      <D.4580>:
      i.0 = (unsigned int) i;
      D.4698 = i.0 * 4;
      D.4699 = ustr + D.4698;
      if (upper != 0) goto <D.4701>; else goto <D.4702>;
      <D.4701>:
      i.0 = (unsigned int) i;
      D.4698 = i.0 * 4;
      D.4699 = ustr + D.4698;
      D.4703 = *D.4699;
      iftmp.1 = monoeg_g_unichar_toupper (D.4703);
      goto <D.4704>;
      <D.4702>:
      i.0 = (unsigned int) i;
      D.4698 = i.0 * 4;
      D.4699 = ustr + D.4698;
      D.4703 = *D.4699;
      iftmp.1 = monoeg_g_unichar_tolower (D.4703);
      <D.4704>:
      *D.4699 = iftmp.1;
      i = i + 1;
      <D.4581>:
      ulen.2 = ulen;
      if (i < ulen.2) goto <D.4580>; else goto <D.4582>;
      <D.4582>:
      ulen.2 = ulen;
      utf8 = monoeg_g_ucs4_to_utf8 (ustr, ulen.2, 0B, 0B, 0B);
      monoeg_g_free (ustr);
      D.4706 = utf8;
      return D.4706;
    }
  finally
    {
      ulen = {CLOBBER};
    }
}


monoeg_g_utf8_strdown (const gchar * str, gssize len)
{
  gchar * D.4709;

  D.4709 = utf8_case_conv (str, len, 0);
  return D.4709;
}


monoeg_g_utf8_validate (const gchar * str, gssize max_len, const gchar * * end)
{
  gboolean D.4713;
  unsigned char D.4716;
  int D.4717;
  unsigned char D.4718;
  int D.4719;
  int D.4725;
  unsigned int D.4726;
  int D.4727;
  unsigned int n.3;
  unsigned int D.4733;
  guchar * inptr;
  gboolean valid;
  guint length;
  guint min;
  gssize n;

  inptr = str;
  valid = 1;
  n = 0;
  if (max_len == 0) goto <D.4711>; else goto <D.4712>;
  <D.4711>:
  D.4713 = 0;
  return D.4713;
  <D.4712>:
  if (max_len < 0) goto <D.4714>; else goto <D.4715>;
  <D.4714>:
  goto <D.4621>;
  <D.4620>:
  D.4716 = *inptr;
  D.4717 = (int) D.4716;
  D.4718 = g_utf8_jump_table[D.4717];
  length = (guint) D.4718;
  D.4719 = utf8_validate (inptr, length);
  if (D.4719 == 0) goto <D.4720>; else goto <D.4721>;
  <D.4720>:
  valid = 0;
  goto <D.4619>;
  <D.4721>:
  inptr = inptr + length;
  <D.4621>:
  D.4716 = *inptr;
  if (D.4716 != 0) goto <D.4620>; else goto <D.4619>;
  <D.4619>:
  goto <D.4722>;
  <D.4715>:
  goto <D.4624>;
  <D.4623>:
  D.4716 = *inptr;
  if (D.4716 == 0) goto <D.4723>; else goto <D.4724>;
  <D.4723>:
  valid = 0;
  goto <D.4622>;
  <D.4724>:
  D.4716 = *inptr;
  D.4717 = (int) D.4716;
  D.4718 = g_utf8_jump_table[D.4717];
  length = (guint) D.4718;
  D.4725 = max_len - n;
  D.4726 = (unsigned int) D.4725;
  min = MIN_EXPR <D.4726, length>;
  D.4727 = utf8_validate (inptr, min);
  if (D.4727 == 0) goto <D.4728>; else goto <D.4729>;
  <D.4728>:
  valid = 0;
  goto <D.4622>;
  <D.4729>:
  if (min < length) goto <D.4730>; else goto <D.4731>;
  <D.4730>:
  valid = 0;
  goto <D.4622>;
  <D.4731>:
  inptr = inptr + length;
  n.3 = (unsigned int) n;
  D.4733 = n.3 + length;
  n = (gssize) D.4733;
  <D.4624>:
  if (n < max_len) goto <D.4623>; else goto <D.4622>;
  <D.4622>:
  <D.4722>:
  if (end != 0B) goto <D.4734>; else goto <D.4735>;
  <D.4734>:
  *end = inptr;
  <D.4735>:
  D.4713 = valid;
  return D.4713;
}


utf8_validate (const unsigned char * inptr, size_t len)
{
  gboolean D.4737;
  signed char c.4;
  unsigned char D.4742;
  const unsigned char * D.4745;
  unsigned char D.4746;
  const unsigned char * D.4751;
  unsigned char D.4752;
  _Bool D.4753;
  _Bool D.4754;
  _Bool D.4755;
  unsigned char D.4764;
  int D.4765;
  const unsigned char * D.4772;
  unsigned char D.4773;
  unsigned char D.4774;
  unsigned char D.4779;
  unsigned char D.4788;
  const unsigned char * ptr;
  unsigned char c;

  ptr = inptr + len;
  switch (len) <default: <D.4597>, case 1: <D.4608>, case 2: <D.4600>, case 3: <D.4599>, case 4: <D.4598>>
  <D.4597>:
  D.4737 = 0;
  return D.4737;
  <D.4598>:
  ptr = ptr + 4294967295;
  c = *ptr;
  c.4 = (signed char) c;
  if (c.4 >= 0) goto <D.4738>; else goto <D.4741>;
  <D.4741>:
  if (c > 191) goto <D.4738>; else goto <D.4739>;
  <D.4738>:
  D.4737 = 0;
  return D.4737;
  <D.4739>:
  D.4742 = c + 66;
  if (D.4742 <= 1) goto <D.4743>; else goto <D.4744>;
  <D.4743>:
  D.4745 = ptr + 4294967295;
  D.4746 = *D.4745;
  if (D.4746 == 191) goto <D.4747>; else goto <D.4748>;
  <D.4747>:
  D.4751 = ptr + 4294967294;
  D.4752 = *D.4751;
  D.4753 = D.4752 == 143;
  D.4751 = ptr + 4294967294;
  D.4752 = *D.4751;
  D.4754 = D.4752 == 159;
  D.4755 = D.4753 | D.4754;
  if (D.4755 != 0) goto <D.4749>; else goto <D.4756>;
  <D.4756>:
  D.4751 = ptr + 4294967294;
  D.4752 = *D.4751;
  if (D.4752 == 175) goto <D.4749>; else goto <D.4757>;
  <D.4757>:
  D.4751 = ptr + 4294967294;
  D.4752 = *D.4751;
  if (D.4752 == 191) goto <D.4749>; else goto <D.4750>;
  <D.4749>:
  D.4737 = 0;
  return D.4737;
  <D.4750>:
  <D.4748>:
  <D.4744>:
  <D.4599>:
  ptr = ptr + 4294967295;
  c = *ptr;
  c.4 = (signed char) c;
  if (c.4 >= 0) goto <D.4758>; else goto <D.4760>;
  <D.4760>:
  if (c > 191) goto <D.4758>; else goto <D.4759>;
  <D.4758>:
  D.4737 = 0;
  return D.4737;
  <D.4759>:
  <D.4600>:
  ptr = ptr + 4294967295;
  c = *ptr;
  c.4 = (signed char) c;
  if (c.4 >= 0) goto <D.4761>; else goto <D.4763>;
  <D.4763>:
  if (c > 191) goto <D.4761>; else goto <D.4762>;
  <D.4761>:
  D.4737 = 0;
  return D.4737;
  <D.4762>:
  D.4764 = *inptr;
  D.4765 = (int) D.4764;
  switch (D.4765) <default: <D.4607>, case 224: <D.4601>, case 237: <D.4603>, case 239: <D.4604>, case 240: <D.4605>, case 244: <D.4606>>
  <D.4601>:
  if (c <= 159) goto <D.4766>; else goto <D.4767>;
  <D.4766>:
  D.4737 = 0;
  return D.4737;
  <D.4767>:
  goto <D.4602>;
  <D.4603>:
  if (c > 159) goto <D.4768>; else goto <D.4769>;
  <D.4768>:
  D.4737 = 0;
  return D.4737;
  <D.4769>:
  goto <D.4602>;
  <D.4604>:
  if (c == 183) goto <D.4770>; else goto <D.4771>;
  <D.4770>:
  D.4772 = ptr + 1;
  D.4773 = *D.4772;
  D.4774 = D.4773 + 112;
  if (D.4774 <= 31) goto <D.4775>; else goto <D.4776>;
  <D.4775>:
  D.4737 = 0;
  return D.4737;
  <D.4776>:
  <D.4771>:
  if (c == 191) goto <D.4777>; else goto <D.4778>;
  <D.4777>:
  D.4772 = ptr + 1;
  D.4773 = *D.4772;
  D.4779 = D.4773 + 66;
  if (D.4779 <= 1) goto <D.4780>; else goto <D.4781>;
  <D.4780>:
  D.4737 = 0;
  return D.4737;
  <D.4781>:
  <D.4778>:
  goto <D.4602>;
  <D.4605>:
  if (c <= 143) goto <D.4782>; else goto <D.4783>;
  <D.4782>:
  D.4737 = 0;
  return D.4737;
  <D.4783>:
  goto <D.4602>;
  <D.4606>:
  if (c > 143) goto <D.4784>; else goto <D.4785>;
  <D.4784>:
  D.4737 = 0;
  return D.4737;
  <D.4785>:
  goto <D.4602>;
  <D.4607>:
  c.4 = (signed char) c;
  if (c.4 >= 0) goto <D.4786>; else goto <D.4787>;
  <D.4786>:
  D.4737 = 0;
  return D.4737;
  <D.4787>:
  goto <D.4602>;
  <D.4602>:
  <D.4608>:
  D.4764 = *inptr;
  D.4788 = D.4764 + 128;
  if (D.4788 <= 65) goto <D.4789>; else goto <D.4790>;
  <D.4789>:
  D.4737 = 0;
  return D.4737;
  <D.4790>:
  D.4764 = *inptr;
  if (D.4764 > 244) goto <D.4791>; else goto <D.4792>;
  <D.4791>:
  D.4737 = 0;
  return D.4737;
  <D.4792>:
  D.4737 = 1;
  return D.4737;
}


monoeg_utf8_get_char_validated (const gchar * str, gssize max_len)
{
  unsigned char D.4794;
  gunichar D.4797;
  int D.4819;
  unsigned int D.4820;
  int D.4821;
  unsigned int n.5;
  int D.4828;
  unsigned int D.4831;
  unsigned char D.4832;
  unsigned int D.4833;
  unsigned char * inptr;
  gunichar u;
  int n;
  int i;

  inptr = str;
  D.4794 = *inptr;
  u = (gunichar) D.4794;
  if (max_len == 0) goto <D.4795>; else goto <D.4796>;
  <D.4795>:
  D.4797 = 4294967294;
  return D.4797;
  <D.4796>:
  if (u <= 127) goto <D.4798>; else goto <D.4799>;
  <D.4798>:
  D.4797 = u;
  return D.4797;
  <D.4799>:
  if (u <= 193) goto <D.4800>; else goto <D.4801>;
  <D.4800>:
  D.4797 = 4294967295;
  return D.4797;
  <D.4801>:
  if (u <= 223) goto <D.4802>; else goto <D.4803>;
  <D.4802>:
  u = u & 31;
  n = 2;
  goto <D.4804>;
  <D.4803>:
  if (u <= 239) goto <D.4805>; else goto <D.4806>;
  <D.4805>:
  u = u & 15;
  n = 3;
  goto <D.4807>;
  <D.4806>:
  if (u <= 247) goto <D.4808>; else goto <D.4809>;
  <D.4808>:
  u = u & 7;
  n = 4;
  goto <D.4810>;
  <D.4809>:
  if (u <= 251) goto <D.4811>; else goto <D.4812>;
  <D.4811>:
  u = u & 3;
  n = 5;
  goto <D.4813>;
  <D.4812>:
  if (u <= 253) goto <D.4814>; else goto <D.4815>;
  <D.4814>:
  u = u & 1;
  n = 6;
  goto <D.4816>;
  <D.4815>:
  D.4797 = 4294967295;
  return D.4797;
  <D.4816>:
  <D.4813>:
  <D.4810>:
  <D.4807>:
  <D.4804>:
  if (max_len > 0) goto <D.4817>; else goto <D.4818>;
  <D.4817>:
  D.4819 = MIN_EXPR <n, max_len>;
  D.4820 = (unsigned int) D.4819;
  D.4821 = utf8_validate (inptr, D.4820);
  if (D.4821 == 0) goto <D.4822>; else goto <D.4823>;
  <D.4822>:
  D.4797 = 4294967295;
  return D.4797;
  <D.4823>:
  if (max_len < n) goto <D.4824>; else goto <D.4825>;
  <D.4824>:
  D.4797 = 4294967294;
  return D.4797;
  <D.4825>:
  goto <D.4826>;
  <D.4818>:
  n.5 = (unsigned int) n;
  D.4828 = utf8_validate (inptr, n.5);
  if (D.4828 == 0) goto <D.4829>; else goto <D.4830>;
  <D.4829>:
  D.4797 = 4294967295;
  return D.4797;
  <D.4830>:
  <D.4826>:
  i = 1;
  goto <D.4634>;
  <D.4633>:
  D.4831 = u << 6;
  inptr = inptr + 1;
  D.4794 = *inptr;
  D.4832 = D.4794 ^ 128;
  D.4833 = (unsigned int) D.4832;
  u = D.4831 | D.4833;
  i = i + 1;
  <D.4634>:
  if (i < n) goto <D.4633>; else goto <D.4635>;
  <D.4635>:
  D.4797 = u;
  return D.4797;
}


monoeg_g_utf8_strlen (const gchar * str, gssize max_len)
{
  glong D.4837;
  unsigned char D.4840;
  int D.4841;
  unsigned char D.4842;
  sizetype D.4843;
  long int D.4845;
  sizetype n.6;
  const guchar * inptr;
  glong clen;
  glong len;
  glong n;

  inptr = str;
  clen = 0;
  len = 0;
  if (max_len == 0) goto <D.4835>; else goto <D.4836>;
  <D.4835>:
  D.4837 = 0;
  return D.4837;
  <D.4836>:
  if (max_len < 0) goto <D.4838>; else goto <D.4839>;
  <D.4838>:
  goto <D.4645>;
  <D.4644>:
  D.4840 = *inptr;
  D.4841 = (int) D.4840;
  D.4842 = g_utf8_jump_table[D.4841];
  D.4843 = (sizetype) D.4842;
  inptr = inptr + D.4843;
  len = len + 1;
  <D.4645>:
  D.4840 = *inptr;
  if (D.4840 != 0) goto <D.4644>; else goto <D.4646>;
  <D.4646>:
  goto <D.4844>;
  <D.4839>:
  goto <D.4649>;
  <D.4648>:
  D.4840 = *inptr;
  D.4841 = (int) D.4840;
  D.4842 = g_utf8_jump_table[D.4841];
  n = (glong) D.4842;
  D.4845 = clen + n;
  if (D.4845 > max_len) goto <D.4647>; else goto <D.4846>;
  <D.4846>:
  n.6 = (sizetype) n;
  inptr = inptr + n.6;
  clen = clen + n;
  len = len + 1;
  <D.4649>:
  if (len < max_len) goto <D.4848>; else goto <D.4647>;
  <D.4848>:
  D.4840 = *inptr;
  if (D.4840 != 0) goto <D.4648>; else goto <D.4647>;
  <D.4647>:
  <D.4844>:
  D.4837 = len;
  return D.4837;
}


monoeg_g_utf8_get_char (const gchar * src)
{
  unsigned char D.4850;
  gunichar D.4853;
  unsigned int D.4866;
  unsigned char D.4867;
  unsigned int D.4868;
  unsigned char * inptr;
  gunichar u;
  int n;
  int i;

  inptr = src;
  D.4850 = *inptr;
  u = (gunichar) D.4850;
  if (u <= 127) goto <D.4851>; else goto <D.4852>;
  <D.4851>:
  D.4853 = u;
  return D.4853;
  <D.4852>:
  if (u <= 223) goto <D.4854>; else goto <D.4855>;
  <D.4854>:
  u = u & 31;
  n = 2;
  goto <D.4856>;
  <D.4855>:
  if (u <= 239) goto <D.4857>; else goto <D.4858>;
  <D.4857>:
  u = u & 15;
  n = 3;
  goto <D.4859>;
  <D.4858>:
  if (u <= 247) goto <D.4860>; else goto <D.4861>;
  <D.4860>:
  u = u & 7;
  n = 4;
  goto <D.4862>;
  <D.4861>:
  if (u <= 251) goto <D.4863>; else goto <D.4864>;
  <D.4863>:
  u = u & 3;
  n = 5;
  goto <D.4865>;
  <D.4864>:
  u = u & 1;
  n = 6;
  <D.4865>:
  <D.4862>:
  <D.4859>:
  <D.4856>:
  i = 1;
  goto <D.4658>;
  <D.4657>:
  D.4866 = u << 6;
  inptr = inptr + 1;
  D.4850 = *inptr;
  D.4867 = D.4850 ^ 128;
  D.4868 = (unsigned int) D.4867;
  u = D.4866 | D.4868;
  i = i + 1;
  <D.4658>:
  if (i < n) goto <D.4657>; else goto <D.4659>;
  <D.4659>:
  D.4853 = u;
  return D.4853;
}


monoeg_utf8_find_prev_char (const gchar * str, const gchar * p)
{
  gchar * D.4872;

  goto <D.4665>;
  <D.4664>:
  p = p + 4294967295;
  if (1 != 0) goto <D.4870>; else goto <D.4871>;
  <D.4870>:
  D.4872 = p;
  return D.4872;
  <D.4871>:
  <D.4665>:
  if (p > str) goto <D.4664>; else goto <D.4666>;
  <D.4666>:
  D.4872 = 0B;
  return D.4872;
}


monoeg_utf8_prev_char (const gchar * str)
{
  gchar * D.4874;
  const gchar * p;

  p = str;
  p = p + 4294967295;
  D.4874 = p;
  return D.4874;
}


monoeg_g_utf8_offset_to_pointer (const gchar * str, glong offset)
{
  char D.4878;
  unsigned char D.4879;
  int D.4880;
  unsigned char D.4881;
  sizetype D.4882;
  sizetype offset.7;
  gchar * D.4887;
  const gchar * p;

  p = str;
  if (offset > 0) goto <D.4876>; else goto <D.4877>;
  <D.4876>:
  <D.4676>:
  D.4878 = *p;
  D.4879 = (unsigned char) D.4878;
  D.4880 = (int) D.4879;
  D.4881 = g_utf8_jump_table[D.4880];
  D.4882 = (sizetype) D.4881;
  p = p + D.4882;
  offset = offset + -1;
  if (offset > 0) goto <D.4676>; else goto <D.4677>;
  <D.4677>:
  goto <D.4883>;
  <D.4877>:
  if (offset < 0) goto <D.4884>; else goto <D.4885>;
  <D.4884>:
  {
    const gchar * jump;

    jump = str;
    <D.4682>:
    offset.7 = (sizetype) offset;
    jump = jump + offset.7;
    goto <D.4679>;
    jump = jump + 4294967295;
    <D.4679>:
    p = jump;
    <D.4680>:
    D.4878 = *p;
    D.4879 = (unsigned char) D.4878;
    D.4880 = (int) D.4879;
    D.4881 = g_utf8_jump_table[D.4880];
    D.4882 = (sizetype) D.4881;
    p = p + D.4882;
    offset = offset + 1;
    if (p < jump) goto <D.4680>; else goto <D.4681>;
    <D.4681>:
    if (offset < 0) goto <D.4682>; else goto <D.4683>;
    <D.4683>:
  }
  <D.4885>:
  <D.4883>:
  D.4887 = p;
  return D.4887;
}


monoeg_g_utf8_pointer_to_offset (const gchar * str, const gchar * pos)
{
  glong D.4891;
  char D.4895;
  unsigned char D.4896;
  int D.4897;
  unsigned char D.4898;
  sizetype D.4899;
  const gchar * inptr;
  const gchar * inend;
  glong offset;
  glong sign;

  offset = 0;
  sign = 1;
  if (pos == str) goto <D.4889>; else goto <D.4890>;
  <D.4889>:
  D.4891 = 0;
  return D.4891;
  <D.4890>:
  if (str < pos) goto <D.4892>; else goto <D.4893>;
  <D.4892>:
  inptr = str;
  inend = pos;
  goto <D.4894>;
  <D.4893>:
  inptr = pos;
  inend = str;
  sign = -1;
  <D.4894>:
  <D.4692>:
  D.4895 = *inptr;
  D.4896 = (unsigned char) D.4895;
  D.4897 = (int) D.4896;
  D.4898 = g_utf8_jump_table[D.4897];
  D.4899 = (sizetype) D.4898;
  inptr = inptr + D.4899;
  offset = offset + 1;
  if (inptr < inend) goto <D.4692>; else goto <D.4693>;
  <D.4693>:
  D.4891 = offset * sign;
  return D.4891;
}


