mono_security_core_clr_set_options (MonoSecurityCoreCLROptions options)
{
  security_core_clr_options = options;
}


mono_security_core_clr_get_options ()
{
  MonoSecurityCoreCLROptions D.17815;

  D.17815 = security_core_clr_options;
  return D.17815;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_determine_platform_image (struct MonoImage * image)
{
  gboolean D.17817;
  mono_bool (*<Tc58>) (const char *) platform_callback.0;
  char * D.17819;

  platform_callback.0 = platform_callback;
  D.17819 = image->name;
  D.17817 = platform_callback.0 (D.17819);
  return D.17817;
}


default_platform_check (const char * image_name)
{
  struct MonoImage * D.17821;
  gboolean D.17824;
  char * D.17825;
  int D.17826;
  _Bool D.17827;
  long unsigned int D.17828;
  long unsigned int D.17829;
  int iftmp.1;
  sizetype D.17834;
  sizetype D.17835;
  sizetype D.17836;
  const char * D.17837;
  int D.17838;

  D.17821 = mono_defaults.corlib;
  if (D.17821 != 0B) goto <D.17822>; else goto <D.17823>;
  <D.17822>:
  D.17821 = mono_defaults.corlib;
  D.17825 = D.17821->name;
  D.17826 = strcmp (D.17825, image_name);
  D.17827 = D.17826 == 0;
  D.17824 = (gboolean) D.17827;
  return D.17824;
  <D.17823>:
  {
    const char * corlib;
    int ilen;
    int clen;

    corlib = "mscorlib.dll";
    D.17828 = __strlen_g (image_name);
    ilen = (int) D.17828;
    D.17829 = __strlen_g (corlib);
    clen = (int) D.17829;
    if (ilen >= clen) goto <D.17833>; else goto <D.17831>;
    <D.17833>:
    D.17834 = (sizetype) ilen;
    D.17835 = (sizetype) clen;
    D.17836 = D.17834 - D.17835;
    D.17837 = image_name + D.17836;
    D.17838 = strcmp ("mscorlib.dll", D.17837);
    if (D.17838 == 0) goto <D.17839>; else goto <D.17831>;
    <D.17839>:
    iftmp.1 = 1;
    goto <D.17832>;
    <D.17831>:
    iftmp.1 = 0;
    <D.17832>:
    D.17824 = iftmp.1;
    return D.17824;
  }
}


__attribute__((__gnu_inline__))
__strlen_g (const char * __str)
{
  size_t D.17841;
  long int __ptr.2;
  long int __str.3;
  long int D.17844;
  char * __ptr;
  char * __tmp;

  __ptr = 0B;
  __tmp = __str;
  __asm__ __volatile__("   la    0,0
0: srst  %0,%1
   jo    0b
" : "=&a" __ptr, "=&a" __tmp : "0" __ptr, "1" __tmp : "0", "memory", "cc");
  __ptr.2 = (long int) __ptr;
  __str.3 = (long int) __str;
  D.17844 = __ptr.2 - __str.3;
  D.17841 = (size_t) D.17844;
  return D.17841;
}


__attribute__((__gnu_inline__, nothrow, leaf, pure))
strcmp (const char * __s1, const char * __s2)
{
  int iftmp.4;
  int iftmp.5;
  int D.17854;
  char * __p1;
  char * __p2;
  int __ret;

  __p1 = __s1;
  __p2 = __s2;
  __asm__ __volatile__("   slr   0,0
0: clst  %1,%2
   jo    0b
   ipm   %0
   srl   %0,28" : "=d" __ret, "=&a" __p1, "=&a" __p2 : "1" __p1, "2" __p2 : "0", "memory", "cc");
  if (__ret != 0) goto <D.17847>; else goto <D.17848>;
  <D.17847>:
  if (__ret == 1) goto <D.17850>; else goto <D.17851>;
  <D.17850>:
  iftmp.5 = -1;
  goto <D.17852>;
  <D.17851>:
  iftmp.5 = 1;
  <D.17852>:
  iftmp.4 = iftmp.5;
  goto <D.17853>;
  <D.17848>:
  iftmp.4 = 0;
  <D.17853>:
  __ret = iftmp.4;
  D.17854 = __ret;
  return D.17854;
}


mono_security_set_core_clr_platform_callback (mono_bool (*MonoCoreClrPlatformCB) (const char *) callback)
{
  platform_callback = callback;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_is_platform_image (struct MonoImage * image)
{
  gboolean D.17856;
  <unnamed-unsigned:1> D.17857;

  D.17857 = image->core_clr_platform_code;
  D.17856 = (gboolean) D.17857;
  return D.17856;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_check_inheritance (struct MonoClass * class)
{
  short unsigned int D.17866;
  int D.17867;
  int D.17868;
  struct MonoMethod * D.17871;
  MonoSecurityCoreCLRLevel class_level;
  MonoSecurityCoreCLRLevel parent_level;
  struct MonoClass * parent;

  parent = class->parent;
  if (parent == 0B) goto <D.17859>; else goto <D.17860>;
  <D.17859>:
  return;
  <D.17860>:
  class_level = mono_security_core_clr_class_level (class);
  parent_level = mono_security_core_clr_class_level (parent);
  if (class_level < parent_level) goto <D.17861>; else goto <D.17862>;
  <D.17861>:
  set_type_load_exception_type ("Inheritance failure for type %s. Parent class %s is more restricted.", class);
  goto <D.17863>;
  <D.17862>:
  {
    struct MonoMethod * parent_ctor;

    parent_ctor = get_default_ctor (parent);
    if (parent_ctor != 0B) goto <D.17864>; else goto <D.17865>;
    <D.17864>:
    D.17866 = parent_ctor->flags;
    D.17867 = (int) D.17866;
    D.17868 = D.17867 & 6;
    if (D.17868 != 0) goto <D.17869>; else goto <D.17870>;
    <D.17869>:
    D.17871 = get_default_ctor (class);
    class_level = mono_security_core_clr_method_level (D.17871, 0);
    parent_level = mono_security_core_clr_method_level (parent_ctor, 0);
    if (class_level < parent_level) goto <D.17872>; else goto <D.17873>;
    <D.17872>:
    set_type_load_exception_type ("Inheritance failure for type %s. Default constructor security mismatch with %s.", class);
    <D.17873>:
    <D.17870>:
    <D.17865>:
  }
  <D.17863>:
}


get_default_ctor (struct MonoClass * klass)
{
  struct MonoMethod * * D.17875;
  struct MonoMethod * D.17878;
  long unsigned int D.17879;
  long unsigned int D.17880;
  struct MonoMethod * * D.17881;
  short unsigned int D.17884;
  int D.17885;
  int D.17886;
  const char * D.17891;
  char D.17892;
  int D.17894;
  short unsigned int D.17897;
  unsigned int D.17900;
  unsigned int i.6;
  int i;

  mono_class_setup_methods (klass);
  D.17875 = klass->methods;
  if (D.17875 == 0B) goto <D.17876>; else goto <D.17877>;
  <D.17876>:
  D.17878 = 0B;
  return D.17878;
  <D.17877>:
  i = 0;
  goto <D.17668>;
  <D.17667>:
  {
    struct MonoMethodSignature * sig;
    struct MonoMethod * method;

    D.17875 = klass->methods;
    D.17879 = (long unsigned int) i;
    D.17880 = D.17879 * 8;
    D.17881 = D.17875 + D.17880;
    method = *D.17881;
    if (method == 0B) goto <D.17882>; else goto <D.17883>;
    <D.17882>:
    // predicted unlikely by continue predictor.
    goto <D.17666>;
    <D.17883>:
    D.17884 = method->flags;
    D.17885 = (int) D.17884;
    D.17886 = D.17885 & 2048;
    if (D.17886 == 0) goto <D.17887>; else goto <D.17888>;
    <D.17887>:
    // predicted unlikely by continue predictor.
    goto <D.17666>;
    <D.17888>:
    D.17891 = method->name;
    D.17892 = *D.17891;
    if (D.17892 != 46) goto <D.17889>; else goto <D.17893>;
    <D.17893>:
    D.17891 = method->name;
    D.17894 = strcmp (".ctor", D.17891);
    if (D.17894 != 0) goto <D.17889>; else goto <D.17890>;
    <D.17889>:
    // predicted unlikely by continue predictor.
    goto <D.17666>;
    <D.17890>:
    sig = mono_method_signature (method);
    if (sig != 0B) goto <D.17895>; else goto <D.17896>;
    <D.17895>:
    D.17897 = sig->param_count;
    if (D.17897 == 0) goto <D.17898>; else goto <D.17899>;
    <D.17898>:
    D.17878 = method;
    return D.17878;
    <D.17899>:
    <D.17896>:
  }
  <D.17666>:
  i = i + 1;
  <D.17668>:
  D.17900 = klass->method.count;
  i.6 = (unsigned int) i;
  if (D.17900 > i.6) goto <D.17667>; else goto <D.17669>;
  <D.17669>:
  D.17878 = 0B;
  return D.17878;
}


set_type_load_exception_type (const char * format, struct MonoClass * class)
{
  struct MonoClass * D.17903;
  char * type_name;
  char * parent_name;
  char * message;

  type_name = mono_type_get_full_name (class);
  D.17903 = class->parent;
  parent_name = mono_type_get_full_name (D.17903);
  message = monoeg_g_strdup_printf (format, type_name, parent_name);
  monoeg_g_free (parent_name);
  monoeg_g_free (type_name);
  mono_trace (16, 64, message);
  mono_class_set_failure (class, 7, message);
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_check_override (struct MonoClass * class, struct MonoMethod * override, struct MonoMethod * base)
{
  MonoSecurityCoreCLRLevel base_level;
  MonoSecurityCoreCLRLevel override_level;

  base_level = mono_security_core_clr_method_level (base, 0);
  override_level = mono_security_core_clr_method_level (override, 0);
  if (base_level == 2) goto <D.17904>; else goto <D.17905>;
  <D.17904>:
  if (override_level != 2) goto <D.17906>; else goto <D.17907>;
  <D.17906>:
  set_type_load_exception_methods ("Override failure for %s over %s. Override MUST be [SecurityCritical].", override, base);
  <D.17907>:
  goto <D.17908>;
  <D.17905>:
  if (override_level == 2) goto <D.17909>; else goto <D.17910>;
  <D.17909>:
  set_type_load_exception_methods ("Override failure for %s over %s. Override must NOT be [SecurityCritical].", override, base);
  <D.17910>:
  <D.17908>:
}


set_type_load_exception_methods (const char * format, struct MonoMethod * override, struct MonoMethod * base)
{
  struct MonoClass * D.17911;
  char * method_name;
  char * base_name;
  char * message;

  method_name = get_method_full_name (override);
  base_name = get_method_full_name (base);
  message = monoeg_g_strdup_printf (format, method_name, base_name);
  monoeg_g_free (base_name);
  monoeg_g_free (method_name);
  mono_trace (16, 64, message);
  D.17911 = override->klass;
  mono_class_set_failure (D.17911, 7, message);
}


get_method_full_name (struct MonoMethod * method)
{
  char * D.17912;
  char * iftmp.7;

  if (method != 0B) goto <D.17914>; else goto <D.17915>;
  <D.17914>:
  iftmp.7 = mono_method_full_name (method, 1);
  goto <D.17916>;
  <D.17915>:
  iftmp.7 = monoeg_strdup ("\'no caller found\'");
  <D.17916>:
  D.17912 = iftmp.7;
  return D.17912;
}


monoeg_strdup (const gchar * str)
{
  gchar * D.17920;

  if (str != 0B) goto <D.17918>; else goto <D.17919>;
  <D.17918>:
  D.17920 = __strdup (str);
  return D.17920;
  <D.17919>:
  D.17920 = 0B;
  return D.17920;
}


mono_security_core_clr_require_elevated_permissions ()
{
  struct MonoMethod * D.17924;
  int D.17926;
  gboolean D.17927;
  <unnamed type> D.17928;
  _Bool D.17929;
  struct ElevatedTrustCookie cookie;

  try
    {
      cookie.depth = 0;
      cookie.caller = 0B;
      mono_stack_walk_no_il (get_caller_of_elevated_trust_code, &cookie);
      D.17924 = cookie.caller;
      if (D.17924 == 0B) goto <D.17922>; else goto <D.17925>;
      <D.17925>:
      D.17926 = cookie.depth;
      if (D.17926 <= 2) goto <D.17922>; else goto <D.17923>;
      <D.17922>:
      D.17927 = 1;
      return D.17927;
      <D.17923>:
      D.17924 = cookie.caller;
      D.17928 = mono_security_core_clr_method_level (D.17924, 1);
      D.17929 = D.17928 == 0;
      D.17927 = (gboolean) D.17929;
      return D.17927;
    }
  finally
    {
      cookie = {CLOBBER};
    }
}


get_caller_of_elevated_trust_code (struct MonoMethod * m, gint32 no, gint32 ilo, gboolean managed, void * data)
{
  long unsigned int D.17935;
  long unsigned int D.17936;
  gboolean D.17937;
  struct MonoClass * D.17938;
  struct MonoImage * D.17939;
  int D.17940;
  int D.17943;
  const char * D.17944;
  int D.17945;
  const char * D.17948;
  int D.17949;
  const char * D.17952;
  int D.17953;
  int D.17956;
  int D.17959;
  <unnamed type> D.17960;
  struct ElevatedTrustCookie * cookie;

  cookie = data;
  if (managed == 0) goto <D.17932>; else goto <D.17934>;
  <D.17934>:
  D.17935 = BIT_FIELD_REF <*m, 64, 256>;
  D.17936 = D.17935 & 4467570830351532032;
  if (D.17936 != 0) goto <D.17932>; else goto <D.17933>;
  <D.17932>:
  D.17937 = 0;
  return D.17937;
  <D.17933>:
  D.17938 = m->klass;
  D.17939 = D.17938->image;
  D.17940 = mono_security_core_clr_is_platform_image (D.17939);
  if (D.17940 == 0) goto <D.17941>; else goto <D.17942>;
  <D.17941>:
  cookie->caller = m;
  D.17937 = 1;
  return D.17937;
  <D.17942>:
  D.17943 = cookie->depth;
  switch (D.17943) <default: <D.17713>, case 0: <D.17710>, case 1: <D.17712>>
  <D.17710>:
  D.17938 = m->klass;
  D.17944 = D.17938->name_space;
  D.17945 = strcmp (D.17944, "System.Security");
  if (D.17945 != 0) goto <D.17946>; else goto <D.17947>;
  <D.17946>:
  D.17937 = 0;
  return D.17937;
  <D.17947>:
  D.17938 = m->klass;
  D.17948 = D.17938->name;
  D.17949 = strcmp (D.17948, "SecurityManager");
  if (D.17949 != 0) goto <D.17950>; else goto <D.17951>;
  <D.17950>:
  D.17937 = 0;
  return D.17937;
  <D.17951>:
  D.17952 = m->name;
  D.17953 = strcmp (D.17952, "EnsureElevatedPermissions");
  if (D.17953 != 0) goto <D.17954>; else goto <D.17955>;
  <D.17954>:
  D.17952 = m->name;
  D.17956 = strcmp (D.17952, "CheckElevatedPermissions");
  if (D.17956 != 0) goto <D.17957>; else goto <D.17958>;
  <D.17957>:
  D.17937 = 0;
  return D.17937;
  <D.17958>:
  <D.17955>:
  cookie->depth = 1;
  goto <D.17711>;
  <D.17712>:
  cookie->depth = 2;
  goto <D.17711>;
  <D.17713>:
  D.17943 = cookie->depth;
  D.17959 = D.17943 + 1;
  cookie->depth = D.17959;
  D.17960 = mono_security_core_clr_method_level (m, 1);
  if (D.17960 == 0) goto <D.17711>; else goto <D.17961>;
  <D.17961>:
  cookie->caller = m;
  D.17937 = 1;
  return D.17937;
  <D.17711>:
  D.17937 = 0;
  return D.17937;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_ensure_reflection_access_field (struct MonoClassField * field)
{
  <unnamed type> D.17963;
  <unnamed type> D.17966;
  unsigned int D.17967;
  struct MonoClass * D.17970;
  struct MonoImage * D.17971;
  int D.17972;
  struct MonoClass * D.17975;
  <unnamed type> D.17976;
  struct MonoException * D.17979;
  int D.17980;
  struct MonoException * D.17983;
  struct MonoMethod * caller;

  caller = get_reflection_caller ();
  D.17963 = mono_security_core_clr_method_level (caller, 1);
  if (D.17963 != 0) goto <D.17964>; else goto <D.17965>;
  <D.17964>:
  return;
  <D.17965>:
  D.17966 = mono_security_core_clr_get_options ();
  D.17967 = D.17966 & 1;
  if (D.17967 != 0) goto <D.17968>; else goto <D.17969>;
  <D.17968>:
  D.17970 = mono_field_get_parent (field);
  D.17971 = D.17970->image;
  D.17972 = mono_security_core_clr_is_platform_image (D.17971);
  if (D.17972 == 0) goto <D.17973>; else goto <D.17974>;
  <D.17973>:
  return;
  <D.17974>:
  <D.17969>:
  D.17975 = mono_field_get_parent (field);
  D.17976 = mono_security_core_clr_class_level (D.17975);
  if (D.17976 == 2) goto <D.17977>; else goto <D.17978>;
  <D.17977>:
  D.17979 = get_field_access_exception ("Transparent method %s cannot get or set Critical field %s.", caller, field);
  mono_raise_exception (D.17979);
  <D.17978>:
  D.17980 = check_field_access (caller, field);
  if (D.17980 == 0) goto <D.17981>; else goto <D.17982>;
  <D.17981>:
  D.17983 = get_field_access_exception ("Transparent method %s cannot get or set private/internal field %s.", caller, field);
  mono_raise_exception (D.17983);
  <D.17982>:
}


get_reflection_caller ()
{
  struct MonoMethod * m.8;
  _Bool D.17986;
  long int D.17987;
  long int D.17988;
  struct MonoMethod * D.17991;
  struct MonoMethod * m;

  try
    {
      m = 0B;
      mono_stack_walk_no_il (get_caller_no_reflection_related, &m);
      m.8 = m;
      D.17986 = m.8 == 0B;
      D.17987 = (long int) D.17986;
      D.17988 = __builtin_expect (D.17987, 0);
      if (D.17988 != 0) goto <D.17989>; else goto <D.17990>;
      <D.17989>:
      mono_trace (16, 64, "No caller outside reflection was found");
      <D.17990>:
      D.17991 = m;
      return D.17991;
    }
  finally
    {
      m = {CLOBBER};
    }
}


get_caller_no_reflection_related (struct MonoMethod * m, gint32 no, gint32 ilo, gboolean managed, void * data)
{
  gboolean D.17996;
  long unsigned int D.17997;
  long unsigned int D.17998;
  struct MonoClass * D.18001;
  char D.18005;
  struct MonoImage * D.18006;
  int D.18007;
  int D.18010;
  int D.18013;
  int D.18016;
  char D.18019;
  int D.18022;
  int D.18029;
  int D.18031;
  const char * D.18032;
  int D.18033;
  int D.18040;
  int D.18042;
  int D.18043;
  struct MonoMethod * D.18046;
  struct MonoMethod * * dest;
  const char * ns;

  dest = data;
  if (managed == 0) goto <D.17994>; else goto <D.17995>;
  <D.17994>:
  D.17996 = 0;
  return D.17996;
  <D.17995>:
  D.17997 = BIT_FIELD_REF <*m, 64, 256>;
  D.17998 = D.17997 & 4467570830351532032;
  if (D.17998 != 0) goto <D.17999>; else goto <D.18000>;
  <D.17999>:
  D.17996 = 0;
  return D.17996;
  <D.18000>:
  D.18001 = m->klass;
  ns = D.18001->name_space;
  if (ns == 0B) goto <D.18002>; else goto <D.18004>;
  <D.18004>:
  D.18005 = *ns;
  if (D.18005 != 83) goto <D.18002>; else goto <D.18003>;
  <D.18002>:
  *dest = m;
  D.17996 = 1;
  return D.17996;
  <D.18003>:
  D.18001 = m->klass;
  D.18006 = D.18001->image;
  D.18007 = mono_security_core_clr_is_platform_image (D.18006);
  if (D.18007 == 0) goto <D.18008>; else goto <D.18009>;
  <D.18008>:
  *dest = m;
  D.17996 = 1;
  return D.17996;
  <D.18009>:
  D.18010 = strcmp (ns, "System.Reflection");
  if (D.18010 == 0) goto <D.18011>; else goto <D.18012>;
  <D.18011>:
  D.17996 = 0;
  return D.17996;
  <D.18012>:
  D.18013 = strcmp (ns, "System.Reflection.Emit");
  if (D.18013 == 0) goto <D.18014>; else goto <D.18015>;
  <D.18014>:
  D.17996 = 0;
  return D.17996;
  <D.18015>:
  D.18016 = strcmp (ns, "System");
  if (D.18016 == 0) goto <D.18017>; else goto <D.18018>;
  <D.18017>:
  {
    const char * kname;

    D.18001 = m->klass;
    kname = D.18001->name;
    D.18019 = *kname;
    if (D.18019 == 65) goto <D.18020>; else goto <D.18021>;
    <D.18020>:
    D.18022 = strcmp (kname, "Activator");
    if (D.18022 == 0) goto <D.18023>; else goto <D.18024>;
    <D.18023>:
    D.17996 = 0;
    return D.17996;
    <D.18024>:
    <D.18021>:
    D.18019 = *kname;
    if (D.18019 == 84) goto <D.18028>; else goto <D.18025>;
    <D.18028>:
    D.18029 = strcmp (kname, "Type");
    if (D.18029 == 0) goto <D.18026>; else goto <D.18025>;
    <D.18025>:
    D.18019 = *kname;
    if (D.18019 == 77) goto <D.18030>; else goto <D.18027>;
    <D.18030>:
    D.18031 = strcmp (kname, "MonoType");
    if (D.18031 == 0) goto <D.18026>; else goto <D.18027>;
    <D.18026>:
    D.18032 = m->name;
    D.18033 = strcmp (D.18032, "InvokeMember");
    if (D.18033 == 0) goto <D.18034>; else goto <D.18035>;
    <D.18034>:
    D.17996 = 0;
    return D.17996;
    <D.18035>:
    <D.18027>:
    D.18019 = *kname;
    if (D.18019 == 68) goto <D.18039>; else goto <D.18036>;
    <D.18039>:
    D.18040 = strcmp (kname, "Delegate");
    if (D.18040 == 0) goto <D.18037>; else goto <D.18036>;
    <D.18036>:
    D.18019 = *kname;
    if (D.18019 == 77) goto <D.18041>; else goto <D.18038>;
    <D.18041>:
    D.18042 = strcmp (kname, "MulticastDelegate");
    if (D.18042 == 0) goto <D.18037>; else goto <D.18038>;
    <D.18037>:
    D.18032 = m->name;
    D.18043 = strcmp (D.18032, "DynamicInvoke");
    if (D.18043 != 0) goto <D.18044>; else goto <D.18045>;
    <D.18044>:
    D.17996 = 0;
    return D.17996;
    <D.18045>:
    <D.18038>:
  }
  <D.18018>:
  D.18046 = *dest;
  if (D.18046 == m) goto <D.18047>; else goto <D.18048>;
  <D.18047>:
  *dest = 0B;
  D.17996 = 0;
  return D.17996;
  <D.18048>:
  *dest = m;
  D.17996 = 1;
  return D.17996;
}


check_field_access (struct MonoMethod * caller, struct MonoClassField * field)
{
  int D.18052;
  gboolean D.18055;
  struct MonoClass * iftmp.9;
  unsigned int D.18057;
  unsigned int D.18058;

  if (caller != 0B) goto <D.18050>; else goto <D.18051>;
  <D.18050>:
  {
    struct MonoError error;
    struct MonoClass * klass;

    try
      {
        mono_field_get_type_checked (field, &error);
        D.18052 = mono_error_ok (&error);
        if (D.18052 == 0) goto <D.18053>; else goto <D.18054>;
        <D.18053>:
        mono_error_cleanup (&error);
        D.18055 = 0;
        return D.18055;
        <D.18054>:
        D.18057 = mono_field_get_flags (field);
        D.18058 = D.18057 & 16;
        if (D.18058 == 0) goto <D.18059>; else goto <D.18060>;
        <D.18059>:
        iftmp.9 = mono_field_get_parent (field);
        goto <D.18061>;
        <D.18060>:
        iftmp.9 = 0B;
        <D.18061>:
        klass = iftmp.9;
        D.18055 = mono_method_can_access_field_full (caller, field, klass);
        return D.18055;
      }
    finally
      {
        error = {CLOBBER};
      }
  }
  <D.18051>:
  D.18055 = 0;
  return D.18055;
}


get_field_access_exception (const char * format, struct MonoMethod * caller, struct MonoClassField * field)
{
  struct MonoException * D.18064;
  struct MonoException * ex;
  char * caller_name;
  char * field_name;
  char * message;

  caller_name = get_method_full_name (caller);
  field_name = mono_field_full_name (field);
  message = monoeg_g_strdup_printf (format, caller_name, field_name);
  monoeg_g_free (field_name);
  monoeg_g_free (caller_name);
  mono_trace (16, 64, message);
  ex = mono_get_exception_field_access_msg (message);
  monoeg_g_free (message);
  D.18064 = ex;
  return D.18064;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_ensure_reflection_access_method (struct MonoMethod * method)
{
  <unnamed type> D.18066;
  <unnamed type> D.18069;
  unsigned int D.18070;
  struct MonoClass * D.18073;
  struct MonoImage * D.18074;
  int D.18075;
  <unnamed type> D.18078;
  struct MonoException * D.18081;
  int D.18082;
  struct MonoException * D.18085;
  struct MonoMethod * caller;

  caller = get_reflection_caller ();
  D.18066 = mono_security_core_clr_method_level (caller, 1);
  if (D.18066 != 0) goto <D.18067>; else goto <D.18068>;
  <D.18067>:
  return;
  <D.18068>:
  D.18069 = mono_security_core_clr_get_options ();
  D.18070 = D.18069 & 1;
  if (D.18070 != 0) goto <D.18071>; else goto <D.18072>;
  <D.18071>:
  D.18073 = method->klass;
  D.18074 = D.18073->image;
  D.18075 = mono_security_core_clr_is_platform_image (D.18074);
  if (D.18075 == 0) goto <D.18076>; else goto <D.18077>;
  <D.18076>:
  return;
  <D.18077>:
  <D.18072>:
  D.18078 = mono_security_core_clr_method_level (method, 1);
  if (D.18078 == 2) goto <D.18079>; else goto <D.18080>;
  <D.18079>:
  D.18081 = get_method_access_exception ("Transparent method %s cannot invoke Critical method %s.", caller, method);
  mono_raise_exception (D.18081);
  <D.18080>:
  D.18082 = check_method_access (caller, method);
  if (D.18082 == 0) goto <D.18083>; else goto <D.18084>;
  <D.18083>:
  D.18085 = get_method_access_exception ("Transparent method %s cannot invoke private/internal method %s.", caller, method);
  mono_raise_exception (D.18085);
  <D.18084>:
}


check_method_access (struct MonoMethod * caller, struct MonoMethod * callee)
{
  struct MonoClass * iftmp.10;
  short unsigned int D.18090;
  int D.18091;
  int D.18092;
  gboolean D.18096;

  if (caller != 0B) goto <D.18087>; else goto <D.18088>;
  <D.18087>:
  {
    struct MonoClass * klass;

    D.18090 = callee->flags;
    D.18091 = (int) D.18090;
    D.18092 = D.18091 & 16;
    if (D.18092 == 0) goto <D.18093>; else goto <D.18094>;
    <D.18093>:
    iftmp.10 = callee->klass;
    goto <D.18095>;
    <D.18094>:
    iftmp.10 = 0B;
    <D.18095>:
    klass = iftmp.10;
    D.18096 = mono_method_can_access_method_full (caller, callee, klass);
    return D.18096;
  }
  <D.18088>:
  D.18096 = 0;
  return D.18096;
}


get_method_access_exception (const char * format, struct MonoMethod * caller, struct MonoMethod * callee)
{
  struct MonoException * D.18098;
  struct MonoException * ex;
  char * caller_name;
  char * callee_name;
  char * message;

  caller_name = get_method_full_name (caller);
  callee_name = get_method_full_name (callee);
  message = monoeg_g_strdup_printf (format, caller_name, callee_name);
  monoeg_g_free (callee_name);
  monoeg_g_free (caller_name);
  mono_trace (16, 64, message);
  ex = mono_get_exception_method_access_msg (message);
  monoeg_g_free (message);
  D.18098 = ex;
  return D.18098;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_ensure_delegate_creation (struct MonoMethod * method, gboolean throwOnBindFailure)
{
  int D.18100;
  gboolean D.18103;
  <unnamed type> D.18104;
  <unnamed type> D.18107;
  struct MonoException * D.18112;
  <unnamed type> D.18113;
  unsigned int D.18114;
  struct MonoClass * D.18117;
  struct MonoImage * D.18118;
  int D.18119;
  int D.18122;
  struct MonoException * D.18125;
  struct MonoMethod * caller;

  D.18100 = can_avoid_corlib_reflection_delegate_optimization (method);
  if (D.18100 != 0) goto <D.18101>; else goto <D.18102>;
  <D.18101>:
  D.18103 = 1;
  return D.18103;
  <D.18102>:
  caller = get_reflection_caller ();
  D.18104 = mono_security_core_clr_method_level (caller, 1);
  if (D.18104 != 0) goto <D.18105>; else goto <D.18106>;
  <D.18105>:
  D.18103 = 1;
  return D.18103;
  <D.18106>:
  D.18107 = mono_security_core_clr_method_level (method, 1);
  if (D.18107 == 2) goto <D.18108>; else goto <D.18109>;
  <D.18108>:
  if (throwOnBindFailure == 0) goto <D.18110>; else goto <D.18111>;
  <D.18110>:
  D.18103 = 0;
  return D.18103;
  <D.18111>:
  D.18112 = get_argument_exception ("Transparent method %s cannot create a delegate on Critical method %s.", caller, method);
  mono_raise_exception (D.18112);
  <D.18109>:
  D.18113 = mono_security_core_clr_get_options ();
  D.18114 = D.18113 & 2;
  if (D.18114 != 0) goto <D.18115>; else goto <D.18116>;
  <D.18115>:
  D.18117 = method->klass;
  D.18118 = D.18117->image;
  D.18119 = mono_security_core_clr_is_platform_image (D.18118);
  if (D.18119 == 0) goto <D.18120>; else goto <D.18121>;
  <D.18120>:
  D.18103 = 1;
  return D.18103;
  <D.18121>:
  <D.18116>:
  D.18122 = check_method_access (caller, method);
  if (D.18122 == 0) goto <D.18123>; else goto <D.18124>;
  <D.18123>:
  D.18125 = get_method_access_exception ("Transparent method %s cannot create a delegate on private/internal method %s.", caller, method);
  mono_raise_exception (D.18125);
  <D.18124>:
  D.18103 = 1;
  return D.18103;
}


can_avoid_corlib_reflection_delegate_optimization (struct MonoMethod * method)
{
  struct MonoClass * D.18127;
  struct MonoImage * D.18128;
  int D.18129;
  gboolean D.18132;
  const char * D.18133;
  int D.18134;
  const char * D.18137;
  int D.18138;
  const char * D.18143;
  int D.18144;
  int D.18146;
  int D.18148;
  int D.18153;
  int D.18155;

  D.18127 = method->klass;
  D.18128 = D.18127->image;
  D.18129 = mono_security_core_clr_is_platform_image (D.18128);
  if (D.18129 == 0) goto <D.18130>; else goto <D.18131>;
  <D.18130>:
  D.18132 = 0;
  return D.18132;
  <D.18131>:
  D.18127 = method->klass;
  D.18133 = D.18127->name_space;
  D.18134 = strcmp (D.18133, "System.Reflection");
  if (D.18134 != 0) goto <D.18135>; else goto <D.18136>;
  <D.18135>:
  D.18132 = 0;
  return D.18132;
  <D.18136>:
  D.18127 = method->klass;
  D.18137 = D.18127->name;
  D.18138 = strcmp (D.18137, "MonoProperty");
  if (D.18138 == 0) goto <D.18139>; else goto <D.18140>;
  <D.18139>:
  D.18143 = method->name;
  D.18144 = strcmp (D.18143, "GetterAdapterFrame");
  if (D.18144 == 0) goto <D.18141>; else goto <D.18145>;
  <D.18145>:
  D.18143 = method->name;
  D.18146 = strcmp (D.18143, "StaticGetterAdapterFrame");
  if (D.18146 == 0) goto <D.18141>; else goto <D.18142>;
  <D.18141>:
  D.18132 = 1;
  return D.18132;
  <D.18142>:
  goto <D.18147>;
  <D.18140>:
  D.18127 = method->klass;
  D.18137 = D.18127->name;
  D.18148 = strcmp (D.18137, "EventInfo");
  if (D.18148 == 0) goto <D.18149>; else goto <D.18150>;
  <D.18149>:
  D.18143 = method->name;
  D.18153 = strcmp (D.18143, "AddEventFrame");
  if (D.18153 == 0) goto <D.18151>; else goto <D.18154>;
  <D.18154>:
  D.18143 = method->name;
  D.18155 = strcmp (D.18143, "StaticAddEventAdapterFrame");
  if (D.18155 == 0) goto <D.18151>; else goto <D.18152>;
  <D.18151>:
  D.18132 = 1;
  return D.18132;
  <D.18152>:
  <D.18150>:
  <D.18147>:
  D.18132 = 0;
  return D.18132;
}


get_argument_exception (const char * format, struct MonoMethod * caller, struct MonoMethod * callee)
{
  struct MonoException * D.18157;
  struct MonoException * ex;
  char * caller_name;
  char * callee_name;
  char * message;

  caller_name = get_method_full_name (caller);
  callee_name = get_method_full_name (callee);
  message = monoeg_g_strdup_printf (format, caller_name, callee_name);
  monoeg_g_free (callee_name);
  monoeg_g_free (caller_name);
  mono_trace (16, 64, message);
  ex = mono_get_exception_argument ("method", message);
  monoeg_g_free (message);
  D.18157 = ex;
  return D.18157;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_ensure_dynamic_method_resolved_object (void * ref, struct MonoClass * handle_class)
{
  struct MonoClass * D.18159;
  struct MonoImage * D.18162;
  int D.18163;
  int D.18166;
  struct MonoException * D.18169;
  struct MonoClass * D.18171;
  struct MonoClass * D.18174;
  struct MonoImage * D.18175;
  int D.18176;
  int D.18179;

  D.18159 = mono_defaults.fieldhandle_class;
  if (D.18159 == handle_class) goto <D.18160>; else goto <D.18161>;
  <D.18160>:
  {
    struct MonoClassField * field;
    struct MonoClass * klass;

    field = ref;
    klass = mono_field_get_parent (field);
    D.18162 = klass->image;
    D.18163 = mono_security_core_clr_is_platform_image (D.18162);
    if (D.18163 != 0) goto <D.18164>; else goto <D.18165>;
    <D.18164>:
    {
      struct MonoMethod * caller;

      caller = get_reflection_caller ();
      D.18166 = check_field_access (caller, field);
      if (D.18166 == 0) goto <D.18167>; else goto <D.18168>;
      <D.18167>:
      D.18169 = get_field_access_exception ("Dynamic method %s cannot create access private/internal field %s.", caller, field);
      return D.18169;
      <D.18168>:
    }
    <D.18165>:
  }
  goto <D.18170>;
  <D.18161>:
  D.18171 = mono_defaults.methodhandle_class;
  if (D.18171 == handle_class) goto <D.18172>; else goto <D.18173>;
  <D.18172>:
  {
    struct MonoMethod * method;

    method = ref;
    D.18174 = method->klass;
    D.18175 = D.18174->image;
    D.18176 = mono_security_core_clr_is_platform_image (D.18175);
    if (D.18176 != 0) goto <D.18177>; else goto <D.18178>;
    <D.18177>:
    {
      struct MonoMethod * caller;

      caller = get_reflection_caller ();
      D.18179 = check_method_access (caller, method);
      if (D.18179 == 0) goto <D.18180>; else goto <D.18181>;
      <D.18180>:
      D.18169 = get_method_access_exception ("Dynamic method %s cannot create access private/internal method %s.", caller, method);
      return D.18169;
      <D.18181>:
    }
    <D.18178>:
  }
  <D.18173>:
  <D.18170>:
  D.18169 = 0B;
  return D.18169;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_can_access_internals (struct MonoImage * accessing, struct MonoImage * accessed)
{
  int D.18183;
  gboolean D.18186;
  int D.18187;
  struct MonoAssembly * D.18192;
  char * D.18193;
  struct MonoAssembly * D.18195;
  char * D.18196;
  int D.18197;
  _Bool D.18198;

  D.18183 = mono_security_core_clr_is_platform_image (accessed);
  if (D.18183 == 0) goto <D.18184>; else goto <D.18185>;
  <D.18184>:
  D.18186 = 1;
  return D.18186;
  <D.18185>:
  D.18187 = mono_security_core_clr_is_platform_image (accessing);
  if (D.18187 != 0) goto <D.18188>; else goto <D.18189>;
  <D.18188>:
  D.18186 = 1;
  return D.18186;
  <D.18189>:
  D.18192 = accessed->assembly;
  D.18193 = D.18192->basedir;
  if (D.18193 == 0B) goto <D.18190>; else goto <D.18194>;
  <D.18194>:
  D.18195 = accessing->assembly;
  D.18196 = D.18195->basedir;
  if (D.18196 == 0B) goto <D.18190>; else goto <D.18191>;
  <D.18190>:
  D.18186 = 0;
  return D.18186;
  <D.18191>:
  D.18192 = accessed->assembly;
  D.18193 = D.18192->basedir;
  D.18195 = accessing->assembly;
  D.18196 = D.18195->basedir;
  D.18197 = strcmp (D.18193, D.18196);
  D.18198 = D.18197 == 0;
  D.18186 = (gboolean) D.18198;
  return D.18186;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_is_field_access_allowed (struct MonoMethod * caller, struct MonoClassField * field)
{
  struct MonoClass * D.18200;
  <unnamed type> D.18201;
  struct MonoException * D.18204;
  <unnamed type> D.18208;

  D.18200 = mono_field_get_parent (field);
  D.18201 = mono_security_core_clr_class_level (D.18200);
  if (D.18201 != 2) goto <D.18202>; else goto <D.18203>;
  <D.18202>:
  D.18204 = 0B;
  return D.18204;
  <D.18203>:
  if (caller == 0B) goto <D.18205>; else goto <D.18207>;
  <D.18207>:
  D.18208 = mono_security_core_clr_method_level (caller, 1);
  if (D.18208 != 0) goto <D.18205>; else goto <D.18206>;
  <D.18205>:
  D.18204 = 0B;
  return D.18204;
  <D.18206>:
  D.18204 = get_field_access_exception ("Transparent method %s cannot call use Critical field %s.", caller, field);
  return D.18204;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_is_call_allowed (struct MonoMethod * caller, struct MonoMethod * callee)
{
  <unnamed type> D.18210;
  struct MonoException * D.18213;
  <unnamed type> D.18217;

  D.18210 = mono_security_core_clr_method_level (callee, 1);
  if (D.18210 != 2) goto <D.18211>; else goto <D.18212>;
  <D.18211>:
  D.18213 = 0B;
  return D.18213;
  <D.18212>:
  if (caller == 0B) goto <D.18214>; else goto <D.18216>;
  <D.18216>:
  D.18217 = mono_security_core_clr_method_level (caller, 1);
  if (D.18217 != 0) goto <D.18214>; else goto <D.18215>;
  <D.18214>:
  D.18213 = 0B;
  return D.18213;
  <D.18215>:
  D.18213 = get_method_access_exception ("Transparent method %s cannot call Critical method %s.", caller, callee);
  return D.18213;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_class_level (struct MonoClass * class)
{
  int mono_security_core_clr_test.11;
  struct MonoImage * D.18222;
  int D.18223;
  MonoSecurityCoreCLRLevel D.18226;

  mono_security_core_clr_test.11 = mono_security_core_clr_test;
  if (mono_security_core_clr_test.11 == 0) goto <D.18220>; else goto <D.18221>;
  <D.18220>:
  D.18222 = class->image;
  D.18223 = mono_security_core_clr_is_platform_image (D.18222);
  if (D.18223 == 0) goto <D.18224>; else goto <D.18225>;
  <D.18224>:
  D.18226 = 0;
  return D.18226;
  <D.18225>:
  <D.18221>:
  D.18226 = mono_security_core_clr_class_level_no_platform_check (class);
  return D.18226;
}


mono_security_core_clr_class_level_no_platform_check (struct MonoClass * class)
{
  struct MonoImage * D.18230;
  struct MonoClass * D.18233;
  MonoSecurityCoreCLRLevel D.18236;
  MonoSecurityCoreCLRLevel level;
  struct MonoCustomAttrInfo * cinfo;

  level = 0;
  cinfo = mono_custom_attrs_from_class (class);
  if (cinfo != 0B) goto <D.18228>; else goto <D.18229>;
  <D.18228>:
  D.18230 = class->image;
  level = mono_security_core_clr_level_from_cinfo (cinfo, D.18230);
  mono_custom_attrs_free (cinfo);
  <D.18229>:
  if (level == 0) goto <D.18231>; else goto <D.18232>;
  <D.18231>:
  D.18233 = class->nested_in;
  if (D.18233 != 0B) goto <D.18234>; else goto <D.18235>;
  <D.18234>:
  D.18233 = class->nested_in;
  level = mono_security_core_clr_class_level_no_platform_check (D.18233);
  <D.18235>:
  <D.18232>:
  D.18236 = level;
  return D.18236;
}


mono_security_core_clr_level_from_cinfo (struct MonoCustomAttrInfo * cinfo, struct MonoImage * image)
{
  struct MonoClass * D.18240;
  int D.18241;
  struct MonoClass * D.18246;
  int D.18247;
  MonoSecurityCoreCLRLevel D.18250;
  int level;

  level = 0;
  if (cinfo != 0B) goto <D.18238>; else goto <D.18239>;
  <D.18238>:
  D.18240 = security_safe_critical_attribute ();
  D.18241 = mono_custom_attrs_has_attr (cinfo, D.18240);
  if (D.18241 != 0) goto <D.18242>; else goto <D.18243>;
  <D.18242>:
  level = 1;
  <D.18243>:
  <D.18239>:
  if (cinfo != 0B) goto <D.18244>; else goto <D.18245>;
  <D.18244>:
  D.18246 = security_critical_attribute ();
  D.18247 = mono_custom_attrs_has_attr (cinfo, D.18246);
  if (D.18247 != 0) goto <D.18248>; else goto <D.18249>;
  <D.18248>:
  level = 2;
  <D.18249>:
  <D.18245>:
  D.18250 = (MonoSecurityCoreCLRLevel) level;
  return D.18250;
}


security_safe_critical_attribute ()
{
  struct MonoClass * class.12;
  struct MonoImage * D.18255;
  struct MonoClass * class.13;
  _Bool D.18257;
  long int D.18258;
  long int D.18259;
  struct MonoClass * D.18262;
  static struct MonoClass * class = 0B;

  class.12 = class;
  if (class.12 == 0B) goto <D.18253>; else goto <D.18254>;
  <D.18253>:
  D.18255 = mono_defaults.corlib;
  class.13 = mono_class_from_name (D.18255, "System.Security", "SecuritySafeCriticalAttribute");
  class = class.13;
  <D.18254>:
  class.12 = class;
  D.18257 = class.12 == 0B;
  D.18258 = (long int) D.18257;
  D.18259 = __builtin_expect (D.18258, 0);
  if (D.18259 != 0) goto <D.18260>; else goto <D.18261>;
  <D.18260>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "security-core-clr.c", 147, "class");
  <D.18261>:
  D.18262 = class;
  return D.18262;
}


security_critical_attribute ()
{
  struct MonoClass * class.14;
  struct MonoImage * D.18267;
  struct MonoClass * class.15;
  _Bool D.18269;
  long int D.18270;
  long int D.18271;
  struct MonoClass * D.18274;
  static struct MonoClass * class = 0B;

  class.14 = class;
  if (class.14 == 0B) goto <D.18265>; else goto <D.18266>;
  <D.18265>:
  D.18267 = mono_defaults.corlib;
  class.15 = mono_class_from_name (D.18267, "System.Security", "SecurityCriticalAttribute");
  class = class.15;
  <D.18266>:
  class.14 = class;
  D.18269 = class.14 == 0B;
  D.18270 = (long int) D.18269;
  D.18271 = __builtin_expect (D.18270, 0);
  if (D.18271 != 0) goto <D.18272>; else goto <D.18273>;
  <D.18272>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "security-core-clr.c", 134, "class");
  <D.18273>:
  D.18274 = class;
  return D.18274;
}


__attribute__((visibility ("hidden")))
mono_security_core_clr_method_level (struct MonoMethod * method, gboolean with_class_level)
{
  MonoSecurityCoreCLRLevel D.18278;
  int mono_security_core_clr_test.16;
  struct MonoClass * D.18282;
  struct MonoImage * D.18283;
  int D.18284;
  struct MonoCustomAttrInfo * cinfo;
  MonoSecurityCoreCLRLevel level;

  level = 0;
  if (method == 0B) goto <D.18276>; else goto <D.18277>;
  <D.18276>:
  D.18278 = level;
  return D.18278;
  <D.18277>:
  mono_security_core_clr_test.16 = mono_security_core_clr_test;
  if (mono_security_core_clr_test.16 == 0) goto <D.18280>; else goto <D.18281>;
  <D.18280>:
  D.18282 = method->klass;
  D.18283 = D.18282->image;
  D.18284 = mono_security_core_clr_is_platform_image (D.18283);
  if (D.18284 == 0) goto <D.18285>; else goto <D.18286>;
  <D.18285>:
  D.18278 = level;
  return D.18278;
  <D.18286>:
  <D.18281>:
  cinfo = mono_custom_attrs_from_method (method);
  if (cinfo != 0B) goto <D.18287>; else goto <D.18288>;
  <D.18287>:
  D.18282 = method->klass;
  D.18283 = D.18282->image;
  level = mono_security_core_clr_level_from_cinfo (cinfo, D.18283);
  mono_custom_attrs_free (cinfo);
  <D.18288>:
  if (with_class_level != 0) goto <D.18289>; else goto <D.18290>;
  <D.18289>:
  if (level == 0) goto <D.18291>; else goto <D.18292>;
  <D.18291>:
  D.18282 = method->klass;
  level = mono_security_core_clr_class_level (D.18282);
  <D.18292>:
  <D.18290>:
  D.18278 = level;
  return D.18278;
}


mono_security_enable_core_clr ()
{
  mono_verifier_set_mode (2);
  mono_security_set_mode (1);
}


