mono_class_get_interop_proxy_class ()
{
  struct MonoImage * D.21740;
  _Bool D.21741;
  long int D.21742;
  long int D.21743;
  struct MonoClass * D.21746;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.21738>; else goto <D.21739>;
  <D.21738>:
  D.21740 = mono_defaults.corlib;
  class = mono_class_from_name (D.21740, "Mono.Interop", "ComInteropProxy");
  D.21741 = class == 0B;
  D.21742 = (long int) D.21741;
  D.21743 = __builtin_expect (D.21742, 0);
  if (D.21743 != 0) goto <D.21744>; else goto <D.21745>;
  <D.21744>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 88, "class");
  <D.21745>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.21739>:
  D.21746 = class;
  return D.21746;
}


mono_memory_barrier ()
{
  __sync_synchronize ();
}


mono_class_get_idispatch_class ()
{
  struct MonoImage * D.21750;
  _Bool D.21751;
  long int D.21752;
  long int D.21753;
  struct MonoClass * D.21756;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.21748>; else goto <D.21749>;
  <D.21748>:
  D.21750 = mono_defaults.corlib;
  class = mono_class_from_name (D.21750, "Mono.Interop", "IDispatch");
  D.21751 = class == 0B;
  D.21752 = (long int) D.21751;
  D.21753 = __builtin_expect (D.21752, 0);
  if (D.21753 != 0) goto <D.21754>; else goto <D.21755>;
  <D.21754>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 89, "class");
  <D.21755>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.21749>:
  D.21756 = class;
  return D.21756;
}


mono_class_get_iunknown_class ()
{
  struct MonoImage * D.21760;
  _Bool D.21761;
  long int D.21762;
  long int D.21763;
  struct MonoClass * D.21766;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.21758>; else goto <D.21759>;
  <D.21758>:
  D.21760 = mono_defaults.corlib;
  class = mono_class_from_name (D.21760, "Mono.Interop", "IUnknown");
  D.21761 = class == 0B;
  D.21762 = (long int) D.21761;
  D.21763 = __builtin_expect (D.21762, 0);
  if (D.21763 != 0) goto <D.21764>; else goto <D.21765>;
  <D.21764>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 90, "class");
  <D.21765>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.21759>:
  D.21766 = class;
  return D.21766;
}


mono_class_get_com_object_class ()
{
  struct MonoImage * D.21770;
  _Bool D.21771;
  long int D.21772;
  long int D.21773;
  struct MonoClass * D.21776;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.21768>; else goto <D.21769>;
  <D.21768>:
  D.21770 = mono_defaults.corlib;
  class = mono_class_from_name (D.21770, "System", "__ComObject");
  D.21771 = class == 0B;
  D.21772 = (long int) D.21771;
  D.21773 = __builtin_expect (D.21772, 0);
  if (D.21773 != 0) goto <D.21774>; else goto <D.21775>;
  <D.21774>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 92, "class");
  <D.21775>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.21769>:
  D.21776 = class;
  return D.21776;
}


mono_class_get_variant_class ()
{
  struct MonoImage * D.21780;
  _Bool D.21781;
  long int D.21782;
  long int D.21783;
  struct MonoClass * D.21786;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.21778>; else goto <D.21779>;
  <D.21778>:
  D.21780 = mono_defaults.corlib;
  class = mono_class_from_name (D.21780, "System", "Variant");
  D.21781 = class == 0B;
  D.21782 = (long int) D.21781;
  D.21783 = __builtin_expect (D.21782, 0);
  if (D.21783 != 0) goto <D.21784>; else goto <D.21785>;
  <D.21784>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 93, "class");
  <D.21785>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.21779>:
  D.21786 = class;
  return D.21786;
}


mono_cominterop_init ()
{
  int D.21075;
  int iftmp.0;
  int D.21074;
  const char[3] * D.21793;
  unsigned char D.21794;
  int D.21795;
  unsigned char D.21796;
  int D.21797;
  _Bool D.21798;
  _Bool D.21799;
  _Bool D.21800;
  const unsigned char * D.21803;
  unsigned char D.21804;
  int D.21805;
  const unsigned char * D.21806;
  unsigned char D.21807;
  int D.21808;
  _Bool D.21809;
  _Bool D.21810;
  const unsigned char * D.21813;
  unsigned char D.21814;
  int D.21815;
  const unsigned char * D.21816;
  unsigned char D.21817;
  int D.21818;
  _Bool D.21819;
  _Bool D.21820;
  const unsigned char * D.21823;
  unsigned char D.21824;
  int D.21825;
  const unsigned char * D.21826;
  unsigned char D.21827;
  int D.21828;
  const char * com_provider_env;

  InitializeCriticalSection (&cominterop_mutex);
  com_provider_env = monoeg_g_getenv ("MONO_COM");
  if (com_provider_env != 0B) goto <D.21788>; else goto <D.21789>;
  <D.21788>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 2;
    if (__s2_len <= 3) goto <D.21791>; else goto <D.21792>;
    <D.21791>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = com_provider_env;
      D.21793 = "MS";
      D.21794 = MEM[(const unsigned char *)D.21793];
      D.21795 = (int) D.21794;
      D.21796 = *__s2;
      D.21797 = (int) D.21796;
      __result = D.21795 - D.21797;
      {
        D.21798 = __s2_len != 0;
        D.21799 = __result == 0;
        D.21800 = D.21798 & D.21799;
        if (D.21800 != 0) goto <D.21801>; else goto <D.21802>;
        <D.21801>:
        D.21803 = &MEM[(void *)"MS" + 1B];
        D.21804 = *D.21803;
        D.21805 = (int) D.21804;
        D.21806 = __s2 + 1;
        D.21807 = *D.21806;
        D.21808 = (int) D.21807;
        __result = D.21805 - D.21808;
        D.21809 = __s2_len > 1;
        D.21799 = __result == 0;
        D.21810 = D.21809 & D.21799;
        if (D.21810 != 0) goto <D.21811>; else goto <D.21812>;
        <D.21811>:
        D.21813 = &MEM[(void *)"MS" + 2B];
        D.21814 = *D.21813;
        D.21815 = (int) D.21814;
        D.21816 = __s2 + 2;
        D.21817 = *D.21816;
        D.21818 = (int) D.21817;
        __result = D.21815 - D.21818;
        D.21819 = __s2_len > 2;
        D.21799 = __result == 0;
        D.21820 = D.21819 & D.21799;
        if (D.21820 != 0) goto <D.21821>; else goto <D.21822>;
        <D.21821>:
        D.21823 = &MEM[(void *)"MS" + 3B];
        D.21824 = *D.21823;
        D.21825 = (int) D.21824;
        D.21826 = __s2 + 3;
        D.21827 = *D.21826;
        D.21828 = (int) D.21827;
        __result = D.21825 - D.21828;
        <D.21822>:
        <D.21812>:
        <D.21802>:
      }
      D.21074 = __result;
    }
    iftmp.0 = -D.21074;
    goto <D.21829>;
    <D.21792>:
    iftmp.0 = __builtin_strcmp (com_provider_env, "MS");
    <D.21829>:
    D.21075 = iftmp.0;
  }
  if (D.21075 == 0) goto <D.21830>; else goto <D.21831>;
  <D.21830>:
  com_provider = 1;
  <D.21831>:
  <D.21789>:
  register_icall (cominterop_get_method_interface, "cominterop_get_method_interface", "ptr ptr", 0);
  register_icall (cominterop_get_function_pointer, "cominterop_get_function_pointer", "ptr ptr int32", 0);
  register_icall (cominterop_object_is_rcw, "cominterop_object_is_rcw", "int32 object", 0);
  register_icall (cominterop_get_ccw, "cominterop_get_ccw", "ptr object ptr", 0);
  register_icall (cominterop_get_ccw_object, "cominterop_get_ccw_object", "object ptr int32", 0);
  register_icall (cominterop_get_hresult_for_exception, "cominterop_get_hresult_for_exception", "int32 object", 0);
  register_icall (cominterop_get_interface, "cominterop_get_interface", "ptr object ptr int32", 0);
  register_icall (mono_string_to_bstr, "mono_string_to_bstr", "ptr obj", 0);
  register_icall (mono_string_from_bstr, "mono_string_from_bstr", "obj ptr", 0);
  register_icall (mono_free_bstr, "mono_free_bstr", "void ptr", 0);
  register_icall (cominterop_type_from_handle, "cominterop_type_from_handle", "object ptr", 0);
  register_icall (mono_marshal_safearray_begin, "mono_marshal_safearray_begin", "int32 ptr ptr ptr ptr ptr int32", 0);
  register_icall (mono_marshal_safearray_get_value, "mono_marshal_safearray_get_value", "ptr ptr ptr", 0);
  register_icall (mono_marshal_safearray_next, "mono_marshal_safearray_next", "int32 ptr ptr", 0);
  register_icall (mono_marshal_safearray_end, "mono_marshal_safearray_end", "void ptr ptr", 0);
  register_icall (mono_marshal_safearray_create, "mono_marshal_safearray_create", "int32 object ptr ptr ptr", 0);
  register_icall (mono_marshal_safearray_set_value, "mono_marshal_safearray_set_value", "void ptr ptr ptr", 0);
  register_icall (mono_marshal_safearray_free_indices, "mono_marshal_safearray_free_indices", "void ptr", 0);
}


mono_marshal_safearray_free_indices (void * indices)
{
  monoeg_g_free (indices);
}


mono_marshal_safearray_set_value (void * safearray, void * indices, void * value)
{
  <unnamed type> com_provider.1;
  int D.21836;
  int (*<T3da4>) (void *, glong *, void * *) safe_array_put_element_ms.2;

  com_provider.1 = com_provider;
  if (com_provider.1 == 1) goto <D.21835>; else goto <D.21832>;
  <D.21835>:
  D.21836 = init_com_provider_ms ();
  if (D.21836 != 0) goto <D.21837>; else goto <D.21832>;
  <D.21837>:
  {
    int hr;

    safe_array_put_element_ms.2 = safe_array_put_element_ms;
    hr = safe_array_put_element_ms.2 (safearray, indices, value);
    if (hr < 0) goto <D.21839>; else goto <D.21840>;
    <D.21839>:
    cominterop_raise_hr_exception (hr);
    <D.21840>:
  }
  goto <D.21833>;
  <D.21832>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3154);
  <D.21833>:
}


init_com_provider_ms ()
{
  int initialized.3;
  gboolean D.21844;
  char * error_msg.4;
  char * error_msg.5;
  char * error_msg.6;
  char * error_msg.7;
  char * error_msg.8;
  char * error_msg.9;
  char * error_msg.10;
  char * error_msg.11;
  char * error_msg.12;
  char * error_msg.13;
  char * error_msg.14;
  static gboolean initialized = 0;
  char * error_msg;
  struct MonoDl * module;
  const char * scope;

  try
    {
      module = 0B;
      scope = "liboleaut32.so";
      initialized.3 = initialized;
      if (initialized.3 != 0) goto <D.21842>; else goto <D.21843>;
      <D.21842>:
      D.21844 = 1;
      return D.21844;
      <D.21843>:
      module = mono_dl_open (scope, 1, &error_msg);
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21846>; else goto <D.21847>;
      <D.21846>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading COM support library \'%s\': %s", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2497);
      D.21844 = 0;
      return D.21844;
      <D.21847>:
      error_msg.5 = mono_dl_symbol (module, "SysAllocStringLen", &sys_alloc_string_len_ms);
      error_msg = error_msg.5;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21849>; else goto <D.21850>;
      <D.21849>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SysAllocStringLen", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2503);
      D.21844 = 0;
      return D.21844;
      <D.21850>:
      error_msg.6 = mono_dl_symbol (module, "SysStringLen", &sys_string_len_ms);
      error_msg = error_msg.6;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21852>; else goto <D.21853>;
      <D.21852>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SysStringLen", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2510);
      D.21844 = 0;
      return D.21844;
      <D.21853>:
      error_msg.7 = mono_dl_symbol (module, "SysFreeString", &sys_free_string_ms);
      error_msg = error_msg.7;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21855>; else goto <D.21856>;
      <D.21855>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SysFreeString", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2517);
      D.21844 = 0;
      return D.21844;
      <D.21856>:
      error_msg.8 = mono_dl_symbol (module, "SafeArrayGetDim", &safe_array_get_dim_ms);
      error_msg = error_msg.8;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21858>; else goto <D.21859>;
      <D.21858>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SafeArrayGetDim", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2524);
      D.21844 = 0;
      return D.21844;
      <D.21859>:
      error_msg.9 = mono_dl_symbol (module, "SafeArrayGetLBound", &safe_array_get_lbound_ms);
      error_msg = error_msg.9;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21861>; else goto <D.21862>;
      <D.21861>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SafeArrayGetLBound", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2531);
      D.21844 = 0;
      return D.21844;
      <D.21862>:
      error_msg.10 = mono_dl_symbol (module, "SafeArrayGetUBound", &safe_array_get_ubound_ms);
      error_msg = error_msg.10;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21864>; else goto <D.21865>;
      <D.21864>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SafeArrayGetUBound", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2538);
      D.21844 = 0;
      return D.21844;
      <D.21865>:
      error_msg.11 = mono_dl_symbol (module, "SafeArrayPtrOfIndex", &safe_array_ptr_of_index_ms);
      error_msg = error_msg.11;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21867>; else goto <D.21868>;
      <D.21867>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SafeArrayPtrOfIndex", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2545);
      D.21844 = 0;
      return D.21844;
      <D.21868>:
      error_msg.12 = mono_dl_symbol (module, "SafeArrayDestroy", &safe_array_destroy_ms);
      error_msg = error_msg.12;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21870>; else goto <D.21871>;
      <D.21870>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SafeArrayDestroy", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2552);
      D.21844 = 0;
      return D.21844;
      <D.21871>:
      error_msg.13 = mono_dl_symbol (module, "SafeArrayPutElement", &safe_array_put_element_ms);
      error_msg = error_msg.13;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21873>; else goto <D.21874>;
      <D.21873>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SafeArrayPutElement", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2559);
      D.21844 = 0;
      return D.21844;
      <D.21874>:
      error_msg.14 = mono_dl_symbol (module, "SafeArrayCreate", &safe_array_create_ms);
      error_msg = error_msg.14;
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.21876>; else goto <D.21877>;
      <D.21876>:
      error_msg.4 = error_msg;
      monoeg_g_log (0B, 16, "Error loading entry point \'%s\' in COM support library \'%s\': %s", "SafeArrayCreate", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2566);
      D.21844 = 0;
      return D.21844;
      <D.21877>:
      initialized = 1;
      D.21844 = 1;
      return D.21844;
    }
  finally
    {
      error_msg = {CLOBBER};
    }
}


cominterop_raise_hr_exception (int hr)
{
  struct MonoMethod * throw_exception_for_hr.15;
  struct MonoClass * D.21883;
  struct MonoMethod * throw_exception_for_hr.16;
  static struct MonoMethod * throw_exception_for_hr = 0B;
  struct MonoException * ex;
  void * params[1];

  try
    {
      params[0] = &hr;
      throw_exception_for_hr.15 = throw_exception_for_hr;
      if (throw_exception_for_hr.15 == 0B) goto <D.21881>; else goto <D.21882>;
      <D.21881>:
      D.21883 = mono_defaults.marshal_class;
      throw_exception_for_hr.16 = mono_class_get_method_from_name (D.21883, "GetExceptionForHR", 1);
      throw_exception_for_hr = throw_exception_for_hr.16;
      <D.21882>:
      throw_exception_for_hr.15 = throw_exception_for_hr;
      ex = mono_runtime_invoke (throw_exception_for_hr.15, 0B, &params, 0B);
      mono_raise_exception (ex);
    }
  finally
    {
      params = {CLOBBER};
    }
}


mono_marshal_safearray_create (struct MonoArray * input, void * * newsafearray, void * * indices, void * empty)
{
  <unnamed type> com_provider.17;
  int D.21889;
  gboolean D.21890;
  unsigned int D.21891;
  struct MonoVTable * D.21892;
  struct MonoClass * D.21893;
  unsigned char D.21894;
  unsigned int dim.18;
  unsigned int D.21896;
  void * D.21897;
  unsigned int D.21898;
  _Bool D.21899;
  int D.21900;
  void * D.21903;
  unsigned int i.19;
  unsigned int D.21905;
  int * D.21906;
  unsigned int D.21907;
  struct SAFEARRAYBOUND * D.21908;
  struct MonoArrayBounds * D.21909;
  struct MonoArrayBounds * D.21910;
  int D.21911;
  int D.21912;
  unsigned int D.21913;
  unsigned int max_array_length.20;
  void * (*<T3db0>) (int, guint32, struct SAFEARRAYBOUND *) safe_array_create_ms.21;
  unsigned int dim.22;
  void * D.21918;
  int dim;
  struct SAFEARRAYBOUND * bounds;
  int i;
  int max_array_length;

  com_provider.17 = com_provider;
  if (com_provider.17 != 1) goto <D.21885>; else goto <D.21888>;
  <D.21888>:
  D.21889 = init_com_provider_ms ();
  if (D.21889 == 0) goto <D.21885>; else goto <D.21886>;
  <D.21885>:
  D.21890 = 0;
  return D.21890;
  <D.21886>:
  D.21891 = mono_array_length (input);
  max_array_length = (int) D.21891;
  D.21892 = MEM[(struct MonoObject *)input].vtable;
  D.21893 = D.21892->klass;
  D.21894 = D.21893->rank;
  dim = (int) D.21894;
  dim.18 = (unsigned int) dim;
  D.21896 = dim.18 * 4;
  D.21897 = monoeg_malloc (D.21896);
  *indices = D.21897;
  dim.18 = (unsigned int) dim;
  D.21898 = dim.18 * 8;
  bounds = __builtin_alloca (D.21898);
  D.21899 = max_array_length == 0;
  D.21900 = (int) D.21899;
  MEM[(int *)empty] = D.21900;
  if (dim > 1) goto <D.21901>; else goto <D.21902>;
  <D.21901>:
  i = 0;
  goto <D.21715>;
  <D.21714>:
  D.21903 = *indices;
  i.19 = (unsigned int) i;
  D.21905 = i.19 * 4;
  D.21906 = D.21903 + D.21905;
  i.19 = (unsigned int) i;
  D.21907 = i.19 * 8;
  D.21908 = bounds + D.21907;
  D.21909 = input->bounds;
  i.19 = (unsigned int) i;
  D.21907 = i.19 * 8;
  D.21910 = D.21909 + D.21907;
  D.21911 = D.21910->lower_bound;
  D.21908->lLbound = D.21911;
  D.21912 = D.21908->lLbound;
  *D.21906 = D.21912;
  i.19 = (unsigned int) i;
  D.21907 = i.19 * 8;
  D.21908 = bounds + D.21907;
  D.21909 = input->bounds;
  i.19 = (unsigned int) i;
  D.21907 = i.19 * 8;
  D.21910 = D.21909 + D.21907;
  D.21913 = D.21910->length;
  D.21908->cElements = D.21913;
  i = i + 1;
  <D.21715>:
  if (i < dim) goto <D.21714>; else goto <D.21716>;
  <D.21716>:
  goto <D.21914>;
  <D.21902>:
  D.21903 = *indices;
  MEM[(int *)D.21903] = 0;
  max_array_length.20 = (unsigned int) max_array_length;
  bounds->cElements = max_array_length.20;
  bounds->lLbound = 0;
  <D.21914>:
  safe_array_create_ms.21 = safe_array_create_ms;
  dim.22 = (unsigned int) dim;
  D.21918 = safe_array_create_ms.21 (12, dim.22, bounds);
  *newsafearray = D.21918;
  D.21890 = 1;
  return D.21890;
}


mono_marshal_safearray_end (void * safearray, void * indices)
{
  <unnamed type> com_provider.23;
  int D.21924;
  int (*<T3b8e>) (void *) safe_array_destroy_ms.24;

  monoeg_g_free (indices);
  com_provider.23 = com_provider;
  if (com_provider.23 == 1) goto <D.21923>; else goto <D.21920>;
  <D.21923>:
  D.21924 = init_com_provider_ms ();
  if (D.21924 != 0) goto <D.21925>; else goto <D.21920>;
  <D.21925>:
  safe_array_destroy_ms.24 = safe_array_destroy_ms;
  safe_array_destroy_ms.24 (safearray);
  goto <D.21921>;
  <D.21920>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3089);
  <D.21921>:
}


mono_marshal_safearray_next (void * safearray, void * indices)
{
  unsigned int D.21927;
  int D.21928;
  unsigned int D.21929;
  unsigned int i.25;
  unsigned int D.21933;
  int * D.21934;
  int D.21935;
  int D.21936;
  long int ubound.26;
  long int lbound.27;
  gboolean D.21944;
  int i;
  int dim;
  gboolean ret;
  int * pIndices;
  int hr;

  D.21927 = mono_marshal_safearray_get_dim (safearray);
  dim = (int) D.21927;
  ret = 1;
  pIndices = indices;
  i = dim + -1;
  goto <D.21699>;
  <D.21698>:
  {
    glong lbound;
    glong ubound;

    try
      {
        D.21928 = i + 1;
        D.21929 = (unsigned int) D.21928;
        hr = mono_marshal_safe_array_get_ubound (safearray, D.21929, &ubound);
        if (hr < 0) goto <D.21930>; else goto <D.21931>;
        <D.21930>:
        cominterop_raise_hr_exception (hr);
        <D.21931>:
        i.25 = (unsigned int) i;
        D.21933 = i.25 * 4;
        D.21934 = pIndices + D.21933;
        D.21935 = *D.21934;
        D.21936 = D.21935 + 1;
        *D.21934 = D.21936;
        D.21935 = *D.21934;
        ubound.26 = ubound;
        if (D.21935 <= ubound.26) goto <D.21697>; else goto <D.21938>;
        <D.21938>:
        D.21928 = i + 1;
        D.21929 = (unsigned int) D.21928;
        hr = mono_marshal_safe_array_get_lbound (safearray, D.21929, &lbound);
        if (hr < 0) goto <D.21939>; else goto <D.21940>;
        <D.21939>:
        cominterop_raise_hr_exception (hr);
        <D.21940>:
        i.25 = (unsigned int) i;
        D.21933 = i.25 * 4;
        D.21934 = pIndices + D.21933;
        lbound.27 = lbound;
        *D.21934 = lbound.27;
        if (i == 0) goto <D.21942>; else goto <D.21943>;
        <D.21942>:
        ret = 0;
        <D.21943>:
      }
    finally
      {
        lbound = {CLOBBER};
        ubound = {CLOBBER};
      }
  }
  i = i + -1;
  <D.21699>:
  if (i >= 0) goto <D.21698>; else goto <D.21697>;
  <D.21697>:
  D.21944 = ret;
  return D.21944;
}


mono_marshal_safearray_get_dim (void * safearray)
{
  <unnamed type> com_provider.28;
  int D.21952;
  guint32 (*<T2201>) (void *) safe_array_get_dim_ms.29;
  guint32 D.21955;
  guint32 result;

  result = 0;
  com_provider.28 = com_provider;
  if (com_provider.28 == 1) goto <D.21951>; else goto <D.21948>;
  <D.21951>:
  D.21952 = init_com_provider_ms ();
  if (D.21952 != 0) goto <D.21953>; else goto <D.21948>;
  <D.21953>:
  safe_array_get_dim_ms.29 = safe_array_get_dim_ms;
  result = safe_array_get_dim_ms.29 (safearray);
  goto <D.21949>;
  <D.21948>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2914);
  <D.21949>:
  D.21955 = result;
  return D.21955;
}


mono_marshal_safe_array_get_ubound (void * psa, guint nDim, glong * plUbound)
{
  <unnamed type> com_provider.30;
  int D.21961;
  int (*<T3d9c>) (void *, guint32, glong *) safe_array_get_ubound_ms.31;
  int D.21964;
  int result;

  result = 0;
  com_provider.30 = com_provider;
  if (com_provider.30 == 1) goto <D.21960>; else goto <D.21957>;
  <D.21960>:
  D.21961 = init_com_provider_ms ();
  if (D.21961 != 0) goto <D.21962>; else goto <D.21957>;
  <D.21962>:
  safe_array_get_ubound_ms.31 = safe_array_get_ubound_ms;
  result = safe_array_get_ubound_ms.31 (psa, nDim, plUbound);
  goto <D.21958>;
  <D.21957>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2946);
  <D.21958>:
  D.21964 = result;
  return D.21964;
}


mono_marshal_safe_array_get_lbound (void * psa, guint nDim, glong * plLbound)
{
  <unnamed type> com_provider.32;
  int D.21970;
  int (*<T3d9c>) (void *, guint32, glong *) safe_array_get_lbound_ms.33;
  int D.21973;
  int result;

  result = 0;
  com_provider.32 = com_provider;
  if (com_provider.32 == 1) goto <D.21969>; else goto <D.21966>;
  <D.21969>:
  D.21970 = init_com_provider_ms ();
  if (D.21970 != 0) goto <D.21971>; else goto <D.21966>;
  <D.21971>:
  safe_array_get_lbound_ms.33 = safe_array_get_lbound_ms;
  result = safe_array_get_lbound_ms.33 (psa, nDim, plLbound);
  goto <D.21967>;
  <D.21966>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2930);
  <D.21967>:
  D.21973 = result;
  return D.21973;
}


mono_marshal_safearray_get_value (void * safearray, void * indices)
{
  <unnamed type> com_provider.34;
  int D.21979;
  int (*<T3da4>) (void *, glong *, void * *) safe_array_ptr_of_index_ms.35;
  void * D.21984;
  void * result;

  try
    {
      com_provider.34 = com_provider;
      if (com_provider.34 == 1) goto <D.21978>; else goto <D.21975>;
      <D.21978>:
      D.21979 = init_com_provider_ms ();
      if (D.21979 != 0) goto <D.21980>; else goto <D.21975>;
      <D.21980>:
      {
        int hr;

        safe_array_ptr_of_index_ms.35 = safe_array_ptr_of_index_ms;
        hr = safe_array_ptr_of_index_ms.35 (safearray, indices, &result);
        if (hr < 0) goto <D.21982>; else goto <D.21983>;
        <D.21982>:
        cominterop_raise_hr_exception (hr);
        <D.21983>:
      }
      goto <D.21976>;
      <D.21975>:
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3038);
      <D.21976>:
      D.21984 = result;
      return D.21984;
    }
  finally
    {
      result = {CLOBBER};
    }
}


mono_marshal_safearray_begin (void * safearray, struct MonoArray * * result, void * * indices, void * empty, void * parameter, gboolean allocateNewArray)
{
  <unnamed type> com_provider.36;
  int D.21991;
  gboolean D.21992;
  unsigned int D.21995;
  unsigned int dim.37;
  unsigned int D.21999;
  void * D.22000;
  int D.22001;
  unsigned int D.22002;
  long int lbound.38;
  long int ubound.39;
  long int D.22011;
  unsigned int i.40;
  unsigned int D.22013;
  uintptr_t * D.22014;
  unsigned int cursize.41;
  intptr_t * D.22016;
  void * D.22017;
  int * D.22018;
  struct MonoClass * D.22023;
  unsigned int dim.42;
  struct MonoDomain * D.22025;
  struct MonoArray * D.22026;
  int dim;
  uintptr_t * sizes;
  intptr_t * bounds;
  struct MonoClass * aklass;
  int i;
  gboolean bounded;

  bounded = 0;
  com_provider.36 = com_provider;
  if (com_provider.36 != 1) goto <D.21987>; else goto <D.21990>;
  <D.21990>:
  D.21991 = init_com_provider_ms ();
  if (D.21991 == 0) goto <D.21987>; else goto <D.21988>;
  <D.21987>:
  D.21992 = 0;
  return D.21992;
  <D.21988>:
  MEM[(int *)empty] = 1;
  if (safearray != 0B) goto <D.21993>; else goto <D.21994>;
  <D.21993>:
  D.21995 = mono_marshal_safearray_get_dim (safearray);
  dim = (int) D.21995;
  if (dim > 0) goto <D.21996>; else goto <D.21997>;
  <D.21996>:
  dim.37 = (unsigned int) dim;
  D.21999 = dim.37 * 4;
  D.22000 = monoeg_malloc (D.21999);
  *indices = D.22000;
  dim.37 = (unsigned int) dim;
  D.21999 = dim.37 * 4;
  sizes = __builtin_alloca (D.21999);
  dim.37 = (unsigned int) dim;
  D.21999 = dim.37 * 4;
  bounds = __builtin_alloca (D.21999);
  i = 0;
  goto <D.21678>;
  <D.21677>:
  {
    glong lbound;
    glong ubound;
    int cursize;
    int hr;

    try
      {
        D.22001 = i + 1;
        D.22002 = (unsigned int) D.22001;
        hr = mono_marshal_safe_array_get_lbound (safearray, D.22002, &lbound);
        if (hr < 0) goto <D.22003>; else goto <D.22004>;
        <D.22003>:
        cominterop_raise_hr_exception (hr);
        <D.22004>:
        lbound.38 = lbound;
        if (lbound.38 != 0) goto <D.22006>; else goto <D.22007>;
        <D.22006>:
        bounded = 1;
        <D.22007>:
        D.22001 = i + 1;
        D.22002 = (unsigned int) D.22001;
        hr = mono_marshal_safe_array_get_ubound (safearray, D.22002, &ubound);
        if (hr < 0) goto <D.22008>; else goto <D.22009>;
        <D.22008>:
        cominterop_raise_hr_exception (hr);
        <D.22009>:
        ubound.39 = ubound;
        lbound.38 = lbound;
        D.22011 = ubound.39 - lbound.38;
        cursize = D.22011 + 1;
        i.40 = (unsigned int) i;
        D.22013 = i.40 * 4;
        D.22014 = sizes + D.22013;
        cursize.41 = (unsigned int) cursize;
        *D.22014 = cursize.41;
        i.40 = (unsigned int) i;
        D.22013 = i.40 * 4;
        D.22016 = bounds + D.22013;
        lbound.38 = lbound;
        *D.22016 = lbound.38;
        D.22017 = *indices;
        i.40 = (unsigned int) i;
        D.22013 = i.40 * 4;
        D.22018 = D.22017 + D.22013;
        lbound.38 = lbound;
        *D.22018 = lbound.38;
        if (cursize != 0) goto <D.22019>; else goto <D.22020>;
        <D.22019>:
        MEM[(int *)empty] = 0;
        <D.22020>:
      }
    finally
      {
        lbound = {CLOBBER};
        ubound = {CLOBBER};
      }
  }
  i = i + 1;
  <D.21678>:
  if (i < dim) goto <D.21677>; else goto <D.21679>;
  <D.21679>:
  if (allocateNewArray != 0) goto <D.22021>; else goto <D.22022>;
  <D.22021>:
  D.22023 = mono_defaults.object_class;
  dim.42 = (unsigned int) dim;
  aklass = mono_bounded_array_class_get (D.22023, dim.42, bounded);
  D.22025 = mono_domain_get ();
  D.22026 = mono_array_new_full (D.22025, aklass, sizes, bounds);
  *result = D.22026;
  goto <D.22027>;
  <D.22022>:
  *result = parameter;
  <D.22027>:
  <D.21997>:
  <D.21994>:
  D.21992 = 1;
  return D.21992;
}


cominterop_type_from_handle (struct MonoType * handle)
{
  struct MonoReflectionType * D.22029;
  struct MonoDomain * domain;
  struct MonoClass * klass;

  domain = mono_domain_get ();
  klass = mono_class_from_mono_type (handle);
  mono_class_init (klass);
  D.22029 = mono_type_get_object (domain, handle);
  return D.22029;
}


cominterop_get_interface (struct MonoComObject * obj, struct MonoClass * ic, gboolean throw_exception)
{
  _Bool D.22031;
  long int D.22032;
  long int D.22033;
  int iftmp.43;
  unsigned int D.22039;
  unsigned int D.22040;
  unsigned char D.22042;
  _Bool D.22045;
  long int D.22046;
  long int D.22047;
  _Bool D.22052;
  long int D.22053;
  long int D.22054;
  struct GHashTable * D.22057;
  short unsigned int D.22060;
  unsigned int D.22061;
  const void * D.22062;
  void * itf.44;
  _Bool D.22066;
  long int D.22067;
  long int D.22068;
  void * itf.45;
  _Bool D.22074;
  long int D.22075;
  long int D.22076;
  void * D.22079;
  _Bool D.22080;
  _Bool D.22081;
  _Bool D.22082;
  _Bool D.22091;
  long int D.22092;
  long int D.22093;
  struct GHashTable * D.22098;
  void * D.22099;
  _Bool D.22102;
  long int D.22103;
  long int D.22104;
  _Bool D.22109;
  long int D.22110;
  long int D.22111;
  void * D.22114;
  void * itf;

  try
    {
      itf = 0B;
      D.22031 = ic == 0B;
      D.22032 = (long int) D.22031;
      D.22033 = __builtin_expect (D.22032, 0);
      if (D.22033 != 0) goto <D.22034>; else goto <D.22035>;
      <D.22034>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 473, "ic");
      <D.22035>:
      D.22039 = ic->flags;
      D.22040 = D.22039 & 32;
      if (D.22040 == 0) goto <D.22041>; else goto <D.22037>;
      <D.22041>:
      D.22042 = ic->byval_arg.type;
      if (D.22042 != 19) goto <D.22043>; else goto <D.22037>;
      <D.22043>:
      D.22042 = ic->byval_arg.type;
      if (D.22042 != 30) goto <D.22044>; else goto <D.22037>;
      <D.22044>:
      iftmp.43 = 1;
      goto <D.22038>;
      <D.22037>:
      iftmp.43 = 0;
      <D.22038>:
      D.22045 = iftmp.43 != 0;
      D.22046 = (long int) D.22045;
      D.22047 = __builtin_expect (D.22046, 0);
      if (D.22047 != 0) goto <D.22048>; else goto <D.22049>;
      <D.22048>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 474, "MONO_CLASS_IS_INTERFACE (ic)");
      <D.22049>:
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.22050>; else goto <D.22051>;
        <D.22050>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.22051>:
        D.22052 = ret != 0;
        D.22053 = (long int) D.22052;
        D.22054 = __builtin_expect (D.22053, 0);
        if (D.22054 != 0) goto <D.22055>; else goto <D.22056>;
        <D.22055>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 476, "ret == 0");
        <D.22056>:
      }
      D.22057 = obj->itf_hash;
      if (D.22057 != 0B) goto <D.22058>; else goto <D.22059>;
      <D.22058>:
      D.22057 = obj->itf_hash;
      D.22060 = ic->interface_id;
      D.22061 = (unsigned int) D.22060;
      D.22062 = (const void *) D.22061;
      itf.44 = monoeg_g_hash_table_lookup (D.22057, D.22062);
      itf = itf.44;
      <D.22059>:
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.22064>; else goto <D.22065>;
        <D.22064>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22065>:
        D.22066 = ret != 0;
        D.22067 = (long int) D.22066;
        D.22068 = __builtin_expect (D.22067, 0);
        if (D.22068 != 0) goto <D.22069>; else goto <D.22070>;
        <D.22069>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 479, "ret == 0");
        <D.22070>:
      }
      itf.45 = itf;
      if (itf.45 == 0B) goto <D.22072>; else goto <D.22073>;
      <D.22072>:
      {
        guint8 iid[16];
        int found;
        int hr;

        try
          {
            found = cominterop_class_guid (ic, &iid);
            D.22074 = found == 0;
            D.22075 = (long int) D.22074;
            D.22076 = __builtin_expect (D.22075, 0);
            if (D.22076 != 0) goto <D.22077>; else goto <D.22078>;
            <D.22077>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 485, "found");
            <D.22078>:
            D.22079 = obj->iunknown;
            hr = ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (D.22079, &iid, &itf);
            D.22080 = hr < 0;
            D.22081 = throw_exception != 0;
            D.22082 = D.22080 & D.22081;
            if (D.22082 != 0) goto <D.22083>; else goto <D.22084>;
            <D.22083>:
            cominterop_raise_hr_exception (hr);
            <D.22084>:
            if (hr >= 0) goto <D.22085>; else goto <D.22086>;
            <D.22085>:
            itf.45 = itf;
            if (itf.45 != 0B) goto <D.22087>; else goto <D.22088>;
            <D.22087>:
            {
              int ret;

              ret = pthread_mutex_lock (&cominterop_mutex.mutex);
              if (ret != 0) goto <D.22089>; else goto <D.22090>;
              <D.22089>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
              <D.22090>:
              D.22091 = ret != 0;
              D.22092 = (long int) D.22091;
              D.22093 = __builtin_expect (D.22092, 0);
              if (D.22093 != 0) goto <D.22094>; else goto <D.22095>;
              <D.22094>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 492, "ret == 0");
              <D.22095>:
            }
            D.22057 = obj->itf_hash;
            if (D.22057 == 0B) goto <D.22096>; else goto <D.22097>;
            <D.22096>:
            D.22098 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
            obj->itf_hash = D.22098;
            <D.22097>:
            D.22057 = obj->itf_hash;
            D.22060 = ic->interface_id;
            D.22061 = (unsigned int) D.22060;
            D.22099 = (void *) D.22061;
            itf.45 = itf;
            monoeg_g_hash_table_insert_replace (D.22057, D.22099, itf.45, 0);
            {
              int ret;

              ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
              if (ret != 0) goto <D.22100>; else goto <D.22101>;
              <D.22100>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
              <D.22101>:
              D.22102 = ret != 0;
              D.22103 = (long int) D.22102;
              D.22104 = __builtin_expect (D.22103, 0);
              if (D.22104 != 0) goto <D.22105>; else goto <D.22106>;
              <D.22105>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 496, "ret == 0");
              <D.22106>:
            }
            <D.22088>:
            <D.22086>:
          }
        finally
          {
            iid = {CLOBBER};
          }
      }
      <D.22073>:
      if (throw_exception != 0) goto <D.22107>; else goto <D.22108>;
      <D.22107>:
      itf.45 = itf;
      D.22109 = itf.45 == 0B;
      D.22110 = (long int) D.22109;
      D.22111 = __builtin_expect (D.22110, 0);
      if (D.22111 != 0) goto <D.22112>; else goto <D.22113>;
      <D.22112>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 501, "itf");
      <D.22113>:
      <D.22108>:
      D.22114 = itf;
      return D.22114;
    }
  finally
    {
      itf = {CLOBBER};
    }
}


cominterop_class_guid (struct MonoClass * klass, guint8 * guid)
{
  struct MonoClass * GuidAttribute.46;
  struct MonoImage * D.22120;
  struct MonoClass * GuidAttribute.47;
  gboolean D.22126;
  int D.22127;
  struct MonoString * D.22130;
  static struct MonoClass * GuidAttribute = 0B;
  struct MonoCustomAttrInfo * cinfo;

  GuidAttribute.46 = GuidAttribute;
  if (GuidAttribute.46 == 0B) goto <D.22118>; else goto <D.22119>;
  <D.22118>:
  D.22120 = mono_defaults.corlib;
  GuidAttribute.47 = mono_class_from_name (D.22120, "System.Runtime.InteropServices", "GuidAttribute");
  GuidAttribute = GuidAttribute.47;
  <D.22119>:
  cinfo = mono_custom_attrs_from_class (klass);
  if (cinfo != 0B) goto <D.22122>; else goto <D.22123>;
  <D.22122>:
  {
    struct MonoReflectionGuidAttribute * attr;

    GuidAttribute.46 = GuidAttribute;
    attr = mono_custom_attrs_get_attr (cinfo, GuidAttribute.46);
    if (attr == 0B) goto <D.22124>; else goto <D.22125>;
    <D.22124>:
    D.22126 = 0;
    return D.22126;
    <D.22125>:
    D.22127 = cinfo->cached;
    if (D.22127 == 0) goto <D.22128>; else goto <D.22129>;
    <D.22128>:
    mono_custom_attrs_free (cinfo);
    <D.22129>:
    D.22130 = attr->guid;
    cominterop_mono_string_to_guid (D.22130, guid);
    D.22126 = 1;
    return D.22126;
  }
  <D.22123>:
  D.22126 = 0;
  return D.22126;
}


cominterop_mono_string_to_guid (struct MonoString * string, guint8 * guid)
{
  sizetype i.48;
  guint8 * D.22133;
  unsigned char D.22134;
  unsigned int D.22135;
  unsigned int D.22136;
  gunichar2 * D.22137;
  short unsigned int D.22138;
  unsigned int D.22139;
  int D.22140;
  unsigned char D.22141;
  sizetype D.22142;
  sizetype D.22143;
  sizetype D.22144;
  gunichar2 * D.22145;
  short unsigned int D.22146;
  unsigned int D.22147;
  int D.22148;
  unsigned char D.22149;
  unsigned char D.22150;
  unsigned char D.22151;
  unsigned int i.49;
  gunichar2 * chars;
  int i;
  static guint8 indexes[16] = {7, 5, 3, 1, 12, 10, 17, 15, 20, 22, 25, 27, 29, 31, 33, 35};

  chars = mono_string_chars (string);
  i = 0;
  i = 0;
  goto <D.21457>;
  <D.21456>:
  i.48 = (sizetype) i;
  D.22133 = guid + i.48;
  D.22134 = indexes[i];
  D.22135 = (unsigned int) D.22134;
  D.22136 = D.22135 * 2;
  D.22137 = chars + D.22136;
  D.22138 = *D.22137;
  D.22139 = (unsigned int) D.22138;
  D.22140 = monoeg_g_unichar_xdigit_value (D.22139);
  D.22141 = (unsigned char) D.22140;
  D.22134 = indexes[i];
  D.22142 = (sizetype) D.22134;
  D.22143 = D.22142 + 2147483647;
  D.22144 = D.22143 * 2;
  D.22145 = chars + D.22144;
  D.22146 = *D.22145;
  D.22147 = (unsigned int) D.22146;
  D.22148 = monoeg_g_unichar_xdigit_value (D.22147);
  D.22149 = (unsigned char) D.22148;
  D.22150 = D.22149 << 4;
  D.22151 = D.22141 + D.22150;
  *D.22133 = D.22151;
  i = i + 1;
  <D.21457>:
  i.49 = (unsigned int) i;
  if (i.49 <= 15) goto <D.21456>; else goto <D.21458>;
  <D.21458>:
}


cominterop_get_hresult_for_exception (struct MonoException * exc)
{
  int D.22153;
  int hr;

  hr = 0;
  D.22153 = hr;
  return D.22153;
}


cominterop_get_ccw_object (struct MonoCCWInterface * ccw_entry, gboolean verify)
{
  struct GHashTable * ccw_interface_hash.50;
  struct MonoObject * D.22158;
  _Bool D.22162;
  long int D.22163;
  long int D.22164;
  unsigned int D.22169;
  struct MonoCCW * ccw;

  ccw = 0B;
  ccw_interface_hash.50 = ccw_interface_hash;
  if (ccw_interface_hash.50 == 0B) goto <D.22156>; else goto <D.22157>;
  <D.22156>:
  D.22158 = 0B;
  return D.22158;
  <D.22157>:
  if (verify != 0) goto <D.22159>; else goto <D.22160>;
  <D.22159>:
  ccw_interface_hash.50 = ccw_interface_hash;
  ccw = monoeg_g_hash_table_lookup (ccw_interface_hash.50, ccw_entry);
  goto <D.22161>;
  <D.22160>:
  ccw = ccw_entry->ccw;
  D.22162 = ccw == 0B;
  D.22163 = (long int) D.22162;
  D.22164 = __builtin_expect (D.22163, 0);
  if (D.22164 != 0) goto <D.22165>; else goto <D.22166>;
  <D.22165>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1764, "ccw");
  <D.22166>:
  <D.22161>:
  if (ccw != 0B) goto <D.22167>; else goto <D.22168>;
  <D.22167>:
  D.22169 = ccw->gc_handle;
  D.22158 = mono_gchandle_get_target (D.22169);
  return D.22158;
  <D.22168>:
  D.22158 = 0B;
  return D.22158;
}


cominterop_get_ccw (struct MonoObject * object, struct MonoClass * itf)
{
  void * D.22173;
  _Bool D.22176;
  long int D.22177;
  long int D.22178;
  struct GHashTable * ccw_hash.51;
  struct GHashTable * ccw_hash.52;
  struct GHashTable * ccw_interface_hash.53;
  struct GHashTable * ccw_interface_hash.54;
  int D.22189;
  const void * D.22190;
  _Bool D.22193;
  long int D.22194;
  long int D.22195;
  unsigned int D.22198;
  struct MonoObject * D.22199;
  struct GList * iftmp.55;
  void * D.22206;
  void * D.22209;
  struct GHashTable * D.22214;
  unsigned int D.22215;
  _Bool D.22221;
  long int D.22222;
  long int D.22223;
  int D.22226;
  void * D.22227;
  _Bool D.22230;
  long int D.22231;
  long int D.22232;
  struct MonoClass * coclass_attribute.56;
  struct MonoImage * D.22240;
  struct MonoClass * coclass_attribute.57;
  int D.22242;
  int iftmp.58;
  short unsigned int D.22249;
  struct MonoClass * * D.22251;
  struct MonoClass * D.22252;
  _Bool D.22253;
  long int D.22254;
  long int D.22255;
  int D.22258;
  struct MonoClass * D.22261;
  struct MonoClass * D.22265;
  unsigned int D.22269;
  unsigned int method_count.59;
  unsigned int D.22271;
  struct GHashTable * D.22272;
  int D.22275;
  struct MonoImage * D.22276;
  int D.22277;
  unsigned int D.22278;
  unsigned int D.22279;
  void * * D.22282;
  unsigned int D.22283;
  struct MonoMethod * * D.22284;
  unsigned int i.60;
  unsigned int D.22286;
  struct MonoMethod * * D.22287;
  short unsigned int D.22288;
  int D.22289;
  const char * D.22290;
  short unsigned int D.22291;
  int D.22292;
  int D.22293;
  unsigned int D.22294;
  unsigned int D.22295;
  short unsigned int D.22296;
  unsigned int mspec_index.61;
  unsigned int D.22298;
  struct MonoMarshalSpec * * D.22299;
  unsigned int param_index.62;
  unsigned int D.22301;
  struct MonoMarshalSpec * * D.22302;
  struct MonoMarshalSpec * D.22303;
  struct MonoMarshalSpec * D.22304;
  struct MonoType * D.22307;
  unsigned char D.22308;
  void * D.22311;
  void * D.22315;
  void * D.22319;
  void * D.22323;
  unsigned char D.22325;
  _Bool D.22326;
  _Bool D.22327;
  _Bool D.22328;
  short int D.22331;
  short int D.22334;
  unsigned short D.22335;
  unsigned short D.22336;
  short int D.22337;
  struct MonoMarshalSpec * * D.22338;
  struct MonoType * D.22341;
  int D.22342;
  struct MonoMarshalSpec * D.22345;
  int D.22348;
  struct MonoType * D.22349;
  unsigned char D.22350;
  void * D.22353;
  void * D.22357;
  void * D.22361;
  void * D.22365;
  unsigned int D.22366;
  unsigned int D.22367;
  struct MonoMarshalSpec * * D.22368;
  _Bool D.22371;
  long int D.22372;
  long int D.22373;
  struct MonoMethodSignature * D.22376;
  short unsigned int D.22377;
  int D.22378;
  int D.22379;
  _Bool D.22382;
  long int D.22383;
  long int D.22384;
  int vtable_index.63;
  unsigned int vtable_index.64;
  unsigned int D.22389;
  void * * D.22390;
  void * D.22391;
  int i;
  struct MonoCCW * ccw;
  struct MonoCCWInterface * ccw_entry;
  void * * vtable;
  static void * iunknown[3] = {0B, 0B, 0B};
  static void * idispatch[4] = {0B, 0B, 0B, 0B};
  struct MonoClass * iface;
  struct MonoClass * klass;
  struct EmitMarshalContext m;
  int start_slot;
  int method_count;
  struct GList * ccw_list;
  struct GList * ccw_list_item;
  struct MonoCustomAttrInfo * cinfo;

  try
    {
      ccw = 0B;
      ccw_entry = 0B;
      vtable = 0B;
      iface = 0B;
      klass = 0B;
      start_slot = 3;
      method_count = 0;
      cinfo = 0B;
      if (object == 0B) goto <D.22171>; else goto <D.22172>;
      <D.22171>:
      D.22173 = 0B;
      return D.22173;
      <D.22172>:
      klass = mono_object_get_class (object);
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.22174>; else goto <D.22175>;
        <D.22174>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.22175>:
        D.22176 = ret != 0;
        D.22177 = (long int) D.22176;
        D.22178 = __builtin_expect (D.22177, 0);
        if (D.22178 != 0) goto <D.22179>; else goto <D.22180>;
        <D.22179>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1828, "ret == 0");
        <D.22180>:
      }
      ccw_hash.51 = ccw_hash;
      if (ccw_hash.51 == 0B) goto <D.22182>; else goto <D.22183>;
      <D.22182>:
      ccw_hash.52 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw_hash = ccw_hash.52;
      <D.22183>:
      ccw_interface_hash.53 = ccw_interface_hash;
      if (ccw_interface_hash.53 == 0B) goto <D.22186>; else goto <D.22187>;
      <D.22186>:
      ccw_interface_hash.54 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw_interface_hash = ccw_interface_hash.54;
      <D.22187>:
      ccw_hash.51 = ccw_hash;
      D.22189 = mono_object_hash (object);
      D.22190 = (const void *) D.22189;
      ccw_list = monoeg_g_hash_table_lookup (ccw_hash.51, D.22190);
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.22191>; else goto <D.22192>;
        <D.22191>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22192>:
        D.22193 = ret != 0;
        D.22194 = (long int) D.22193;
        D.22195 = __builtin_expect (D.22194, 0);
        if (D.22195 != 0) goto <D.22196>; else goto <D.22197>;
        <D.22196>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1835, "ret == 0");
        <D.22197>:
      }
      ccw_list_item = ccw_list;
      goto <D.21379>;
      <D.21378>:
      {
        struct MonoCCW * ccw_iter;

        ccw_iter = ccw_list_item->data;
        D.22198 = ccw_iter->gc_handle;
        D.22199 = mono_gchandle_get_target (D.22198);
        if (D.22199 == object) goto <D.22200>; else goto <D.22201>;
        <D.22200>:
        ccw = ccw_iter;
        goto <D.21377>;
        <D.22201>:
        if (ccw_list_item != 0B) goto <D.22203>; else goto <D.22204>;
        <D.22203>:
        iftmp.55 = ccw_list_item->next;
        goto <D.22205>;
        <D.22204>:
        iftmp.55 = 0B;
        <D.22205>:
        ccw_list_item = iftmp.55;
      }
      <D.21379>:
      if (ccw_list_item != 0B) goto <D.21378>; else goto <D.21377>;
      <D.21377>:
      D.22206 = iunknown[0];
      if (D.22206 == 0B) goto <D.22207>; else goto <D.22208>;
      <D.22207>:
      iunknown[0] = cominterop_ccw_queryinterface;
      iunknown[1] = cominterop_ccw_addref;
      iunknown[2] = cominterop_ccw_release;
      <D.22208>:
      D.22209 = idispatch[0];
      if (D.22209 == 0B) goto <D.22210>; else goto <D.22211>;
      <D.22210>:
      idispatch[0] = cominterop_ccw_get_type_info_count;
      idispatch[1] = cominterop_ccw_get_type_info;
      idispatch[2] = cominterop_ccw_get_ids_of_names;
      idispatch[3] = cominterop_ccw_invoke;
      <D.22211>:
      if (ccw == 0B) goto <D.22212>; else goto <D.22213>;
      <D.22212>:
      ccw = monoeg_malloc0 (12);
      D.22214 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw->vtable_hash = D.22214;
      ccw->ref_count = 0;
      D.22215 = mono_gchandle_new_weakref (object, 0);
      ccw->gc_handle = D.22215;
      if (ccw_list == 0B) goto <D.22216>; else goto <D.22217>;
      <D.22216>:
      ccw_list = monoeg_g_list_alloc ();
      ccw_list->data = ccw;
      goto <D.22218>;
      <D.22217>:
      ccw_list = monoeg_g_list_append (ccw_list, ccw);
      <D.22218>:
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.22219>; else goto <D.22220>;
        <D.22219>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.22220>:
        D.22221 = ret != 0;
        D.22222 = (long int) D.22221;
        D.22223 = __builtin_expect (D.22222, 0);
        if (D.22223 != 0) goto <D.22224>; else goto <D.22225>;
        <D.22224>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1876, "ret == 0");
        <D.22225>:
      }
      ccw_hash.51 = ccw_hash;
      D.22226 = mono_object_hash (object);
      D.22227 = (void *) D.22226;
      monoeg_g_hash_table_insert_replace (ccw_hash.51, D.22227, ccw_list, 0);
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.22228>; else goto <D.22229>;
        <D.22228>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22229>:
        D.22230 = ret != 0;
        D.22231 = (long int) D.22230;
        D.22232 = __builtin_expect (D.22231, 0);
        if (D.22232 != 0) goto <D.22233>; else goto <D.22234>;
        <D.22233>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1878, "ret == 0");
        <D.22234>:
      }
      mono_object_register_finalizer (object);
      <D.22213>:
      cinfo = mono_custom_attrs_from_class (itf);
      if (cinfo != 0B) goto <D.22235>; else goto <D.22236>;
      <D.22235>:
      {
        static struct MonoClass * coclass_attribute = 0B;

        coclass_attribute.56 = coclass_attribute;
        if (coclass_attribute.56 == 0B) goto <D.22238>; else goto <D.22239>;
        <D.22238>:
        D.22240 = mono_defaults.corlib;
        coclass_attribute.57 = mono_class_from_name (D.22240, "System.Runtime.InteropServices", "CoClassAttribute");
        coclass_attribute = coclass_attribute.57;
        <D.22239>:
        coclass_attribute.56 = coclass_attribute;
        D.22242 = mono_custom_attrs_has_attr (cinfo, coclass_attribute.56);
        if (D.22242 != 0) goto <D.22243>; else goto <D.22244>;
        <D.22243>:
        D.22249 = itf->interface_count;
        if (D.22249 == 0) goto <D.22246>; else goto <D.22250>;
        <D.22250>:
        D.22251 = itf->interfaces;
        D.22252 = *D.22251;
        if (D.22252 == 0B) goto <D.22246>; else goto <D.22247>;
        <D.22246>:
        iftmp.58 = 1;
        goto <D.22248>;
        <D.22247>:
        iftmp.58 = 0;
        <D.22248>:
        D.22253 = iftmp.58 != 0;
        D.22254 = (long int) D.22253;
        D.22255 = __builtin_expect (D.22254, 0);
        if (D.22255 != 0) goto <D.22256>; else goto <D.22257>;
        <D.22256>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1889, "itf->interface_count && itf->interfaces[0]");
        <D.22257>:
        D.22251 = itf->interfaces;
        itf = *D.22251;
        <D.22244>:
        D.22258 = cinfo->cached;
        if (D.22258 == 0) goto <D.22259>; else goto <D.22260>;
        <D.22259>:
        mono_custom_attrs_free (cinfo);
        <D.22260>:
      }
      <D.22236>:
      iface = itf;
      D.22261 = mono_class_get_iunknown_class ();
      if (D.22261 == iface) goto <D.22262>; else goto <D.22263>;
      <D.22262>:
      start_slot = 3;
      goto <D.22264>;
      <D.22263>:
      D.22265 = mono_class_get_idispatch_class ();
      if (D.22265 == iface) goto <D.22266>; else goto <D.22267>;
      <D.22266>:
      start_slot = 7;
      goto <D.22268>;
      <D.22267>:
      D.22269 = iface->method.count;
      method_count.59 = (unsigned int) method_count;
      D.22271 = D.22269 + method_count.59;
      method_count = (int) D.22271;
      start_slot = cominterop_get_com_slot_begin (iface);
      iface = 0B;
      <D.22268>:
      <D.22264>:
      D.22272 = ccw->vtable_hash;
      ccw_entry = monoeg_g_hash_table_lookup (D.22272, itf);
      if (ccw_entry == 0B) goto <D.22273>; else goto <D.22274>;
      <D.22273>:
      {
        int vtable_index;

        D.22275 = method_count + -1;
        vtable_index = D.22275 + start_slot;
        D.22276 = klass->image;
        D.22277 = method_count + start_slot;
        D.22278 = (unsigned int) D.22277;
        D.22279 = D.22278 * 4;
        vtable = mono_image_alloc0 (D.22276, D.22279);
        memcpy (vtable, &iunknown, 12);
        if (start_slot == 7) goto <D.22280>; else goto <D.22281>;
        <D.22280>:
        D.22282 = vtable + 12;
        memcpy (D.22282, &idispatch, 16);
        <D.22281>:
        iface = itf;
        D.22269 = iface->method.count;
        D.22283 = D.22269 + 4294967295;
        i = (int) D.22283;
        goto <D.21403>;
        <D.21402>:
        {
          int param_index;
          struct MonoMethodBuilder * mb;
          struct MonoMarshalSpec * * mspecs;
          struct MonoMethod * wrapper_method;
          struct MonoMethod * adjust_method;
          struct MonoMethod * method;
          struct MonoMethodSignature * sig_adjusted;
          struct MonoMethodSignature * sig;
          gboolean preserve_sig;

          param_index = 0;
          D.22284 = iface->methods;
          i.60 = (unsigned int) i;
          D.22286 = i.60 * 4;
          D.22287 = D.22284 + D.22286;
          method = *D.22287;
          sig = mono_method_signature (method);
          D.22288 = method->iflags;
          D.22289 = (int) D.22288;
          preserve_sig = D.22289 & 128;
          D.22290 = method->name;
          mb = mono_mb_new (iface, D.22290, 5);
          adjust_method = cominterop_get_managed_wrapper_adjusted (method);
          sig_adjusted = mono_method_signature (adjust_method);
          D.22291 = sig_adjusted->param_count;
          D.22292 = (int) D.22291;
          D.22293 = D.22292 + 1;
          D.22294 = (unsigned int) D.22293;
          D.22295 = D.22294 * 4;
          mspecs = monoeg_malloc (D.22295);
          mono_method_get_marshal_info (method, mspecs);
          D.22296 = sig->param_count;
          param_index = (int) D.22296;
          goto <D.21395>;
          <D.21394>:
          {
            int mspec_index;

            mspec_index = param_index + 1;
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            param_index.62 = (unsigned int) param_index;
            D.22301 = param_index.62 * 4;
            D.22302 = mspecs + D.22301;
            D.22303 = *D.22302;
            *D.22299 = D.22303;
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22304 = *D.22299;
            if (D.22304 == 0B) goto <D.22305>; else goto <D.22306>;
            <D.22305>:
            D.22307 = sig_adjusted->params[param_index];
            D.22308 = D.22307->type;
            if (D.22308 == 28) goto <D.22309>; else goto <D.22310>;
            <D.22309>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22311 = monoeg_malloc0 (16);
            *D.22299 = D.22311;
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22304 = *D.22299;
            D.22304->native = 27;
            goto <D.22312>;
            <D.22310>:
            D.22307 = sig_adjusted->params[param_index];
            D.22308 = D.22307->type;
            if (D.22308 == 14) goto <D.22313>; else goto <D.22314>;
            <D.22313>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22315 = monoeg_malloc0 (16);
            *D.22299 = D.22315;
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22304 = *D.22299;
            D.22304->native = 19;
            goto <D.22316>;
            <D.22314>:
            D.22307 = sig_adjusted->params[param_index];
            D.22308 = D.22307->type;
            if (D.22308 == 18) goto <D.22317>; else goto <D.22318>;
            <D.22317>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22319 = monoeg_malloc0 (16);
            *D.22299 = D.22319;
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22304 = *D.22299;
            D.22304->native = 28;
            goto <D.22320>;
            <D.22318>:
            D.22307 = sig_adjusted->params[param_index];
            D.22308 = D.22307->type;
            if (D.22308 == 2) goto <D.22321>; else goto <D.22322>;
            <D.22321>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22323 = monoeg_malloc0 (16);
            *D.22299 = D.22323;
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22304 = *D.22299;
            D.22304->native = 37;
            <D.22322>:
            <D.22320>:
            <D.22316>:
            <D.22312>:
            goto <D.22324>;
            <D.22306>:
            D.22307 = sig_adjusted->params[param_index];
            D.22325 = D.22307->type;
            D.22326 = D.22325 == 20;
            D.22327 = D.22325 == 29;
            D.22328 = D.22326 | D.22327;
            if (D.22328 != 0) goto <D.22329>; else goto <D.22330>;
            <D.22329>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22304 = *D.22299;
            D.22331 = D.22304->data.array_data.param_num;
            if (D.22331 != -1) goto <D.22332>; else goto <D.22333>;
            <D.22332>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.22298 = mspec_index.61 * 4;
            D.22299 = mspecs + D.22298;
            D.22304 = *D.22299;
            D.22331 = D.22304->data.array_data.param_num;
            D.22334 = D.22331;
            D.22335 = (unsigned short) D.22334;
            D.22336 = D.22335 + 1;
            D.22337 = (short int) D.22336;
            D.22304->data.array_data.param_num = D.22337;
            <D.22333>:
            <D.22330>:
            <D.22324>:
          }
          param_index = param_index + -1;
          <D.21395>:
          if (param_index > 0) goto <D.21394>; else goto <D.21396>;
          <D.21396>:
          D.22338 = mspecs + 4;
          *D.22338 = 0B;
          if (preserve_sig == 0) goto <D.22339>; else goto <D.22340>;
          <D.22339>:
          D.22341 = sig->ret;
          D.22342 = mono_type_is_void (D.22341);
          if (D.22342 == 0) goto <D.22343>; else goto <D.22344>;
          <D.22343>:
          D.22345 = *mspecs;
          if (D.22345 == 0B) goto <D.22346>; else goto <D.22347>;
          <D.22346>:
          D.22291 = sig_adjusted->param_count;
          D.22292 = (int) D.22291;
          D.22348 = D.22292 + -1;
          D.22349 = sig_adjusted->params[D.22348];
          D.22350 = D.22349->type;
          if (D.22350 == 28) goto <D.22351>; else goto <D.22352>;
          <D.22351>:
          D.22353 = monoeg_malloc0 (16);
          *mspecs = D.22353;
          D.22345 = *mspecs;
          D.22345->native = 27;
          goto <D.22354>;
          <D.22352>:
          D.22291 = sig_adjusted->param_count;
          D.22292 = (int) D.22291;
          D.22348 = D.22292 + -1;
          D.22349 = sig_adjusted->params[D.22348];
          D.22350 = D.22349->type;
          if (D.22350 == 14) goto <D.22355>; else goto <D.22356>;
          <D.22355>:
          D.22357 = monoeg_malloc0 (16);
          *mspecs = D.22357;
          D.22345 = *mspecs;
          D.22345->native = 19;
          goto <D.22358>;
          <D.22356>:
          D.22291 = sig_adjusted->param_count;
          D.22292 = (int) D.22291;
          D.22348 = D.22292 + -1;
          D.22349 = sig_adjusted->params[D.22348];
          D.22350 = D.22349->type;
          if (D.22350 == 18) goto <D.22359>; else goto <D.22360>;
          <D.22359>:
          D.22361 = monoeg_malloc0 (16);
          *mspecs = D.22361;
          D.22345 = *mspecs;
          D.22345->native = 28;
          goto <D.22362>;
          <D.22360>:
          D.22291 = sig_adjusted->param_count;
          D.22292 = (int) D.22291;
          D.22348 = D.22292 + -1;
          D.22349 = sig_adjusted->params[D.22348];
          D.22350 = D.22349->type;
          if (D.22350 == 2) goto <D.22363>; else goto <D.22364>;
          <D.22363>:
          D.22365 = monoeg_malloc0 (16);
          *mspecs = D.22365;
          D.22345 = *mspecs;
          D.22345->native = 37;
          <D.22364>:
          <D.22362>:
          <D.22358>:
          <D.22354>:
          <D.22347>:
          D.22291 = sig_adjusted->param_count;
          D.22366 = (unsigned int) D.22291;
          D.22367 = D.22366 * 4;
          D.22368 = mspecs + D.22367;
          D.22345 = *mspecs;
          *D.22368 = D.22345;
          *mspecs = 0B;
          <D.22344>:
          <D.22340>:
          mb->skip_visibility = 1;
          cominterop_setup_marshal_context (&m, adjust_method);
          m.mb = mb;
          mono_marshal_emit_managed_wrapper (mb, sig_adjusted, mspecs, &m, adjust_method, 0);
          {
            int ret;

            ret = pthread_mutex_lock (&cominterop_mutex.mutex);
            if (ret != 0) goto <D.22369>; else goto <D.22370>;
            <D.22369>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
            <D.22370>:
            D.22371 = ret != 0;
            D.22372 = (long int) D.22371;
            D.22373 = __builtin_expect (D.22372, 0);
            if (D.22373 != 0) goto <D.22374>; else goto <D.22375>;
            <D.22374>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2003, "ret == 0");
            <D.22375>:
          }
          D.22376 = m.csig;
          D.22376 = m.csig;
          D.22377 = D.22376->param_count;
          D.22378 = (int) D.22377;
          D.22379 = D.22378 + 16;
          wrapper_method = mono_mb_create_method (mb, D.22376, D.22379);
          {
            int ret;

            ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
            if (ret != 0) goto <D.22380>; else goto <D.22381>;
            <D.22380>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.22381>:
            D.22382 = ret != 0;
            D.22383 = (long int) D.22382;
            D.22384 = __builtin_expect (D.22383, 0);
            if (D.22384 != 0) goto <D.22385>; else goto <D.22386>;
            <D.22385>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2005, "ret == 0");
            <D.22386>:
          }
          vtable_index.63 = vtable_index;
          vtable_index = vtable_index.63 + -1;
          vtable_index.64 = (unsigned int) vtable_index.63;
          D.22389 = vtable_index.64 * 4;
          D.22390 = vtable + D.22389;
          D.22391 = mono_compile_method (wrapper_method);
          *D.22390 = D.22391;
          D.22291 = sig_adjusted->param_count;
          param_index = (int) D.22291;
          goto <D.21400>;
          <D.21399>:
          param_index.62 = (unsigned int) param_index;
          D.22301 = param_index.62 * 4;
          D.22302 = mspecs + D.22301;
          D.22303 = *D.22302;
          if (D.22303 != 0B) goto <D.22392>; else goto <D.22393>;
          <D.22392>:
          param_index.62 = (unsigned int) param_index;
          D.22301 = param_index.62 * 4;
          D.22302 = mspecs + D.22301;
          D.22303 = *D.22302;
          mono_metadata_free_marshal_spec (D.22303);
          <D.22393>:
          param_index = param_index + -1;
          <D.21400>:
          if (param_index >= 0) goto <D.21399>; else goto <D.21401>;
          <D.21401>:
          monoeg_g_free (mspecs);
        }
        i = i + -1;
        <D.21403>:
        if (i >= 0) goto <D.21402>; else goto <D.21404>;
        <D.21404>:
        ccw_entry = monoeg_malloc0 (8);
        ccw_entry->ccw = ccw;
        ccw_entry->vtable = vtable;
        D.22272 = ccw->vtable_hash;
        monoeg_g_hash_table_insert_replace (D.22272, itf, ccw_entry, 0);
        ccw_interface_hash.53 = ccw_interface_hash;
        monoeg_g_hash_table_insert_replace (ccw_interface_hash.53, ccw_entry, ccw, 0);
      }
      <D.22274>:
      D.22173 = ccw_entry;
      return D.22173;
    }
  finally
    {
      m = {CLOBBER};
    }
}


cominterop_ccw_invoke (struct MonoCCWInterface * ccwe, guint32 dispIdMember, void * riid, guint32 lcid, guint16 wFlags, void * pDispParams, void * pVarResult, void * pExcepInfo, guint32 * puArgErr)
{
  int D.22396;

  D.22396 = -2147467263;
  return D.22396;
}


cominterop_ccw_get_ids_of_names (struct MonoCCWInterface * ccwe, void * riid, gunichar2 * * rgszNames, guint32 cNames, guint32 lcid, gint32 * rgDispId)
{
  unsigned int D.22398;
  _Bool D.22399;
  long int D.22400;
  long int D.22401;
  struct MonoVTable * D.22404;
  struct MonoDomain * D.22405;
  struct MonoDomain * D.22408;
  unsigned int i.65;
  unsigned int D.22410;
  gunichar2 * * D.22411;
  gunichar2 * D.22412;
  gint32 * D.22415;
  unsigned int D.22416;
  int D.22417;
  unsigned int i.66;
  int D.22420;
  int i;
  int ret;
  struct MonoMethod * method;
  gchar * methodname;
  struct MonoClass * klass;
  struct MonoCCW * ccw;
  struct MonoObject * object;

  ret = 0;
  klass = 0B;
  ccw = ccwe->ccw;
  D.22398 = ccw->gc_handle;
  object = mono_gchandle_get_target (D.22398);
  D.22399 = object == 0B;
  D.22400 = (long int) D.22399;
  D.22401 = __builtin_expect (D.22400, 0);
  if (D.22401 != 0) goto <D.22402>; else goto <D.22403>;
  <D.22402>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2418, "object");
  <D.22403>:
  D.22404 = object->vtable;
  klass = D.22404->klass;
  D.22405 = mono_domain_get ();
  if (D.22405 == 0B) goto <D.22406>; else goto <D.22407>;
  <D.22406>:
  D.22408 = mono_get_root_domain ();
  mono_thread_attach (D.22408);
  <D.22407>:
  i = 0;
  goto <D.21522>;
  <D.21521>:
  i.65 = (unsigned int) i;
  D.22410 = i.65 * 4;
  D.22411 = rgszNames + D.22410;
  D.22412 = *D.22411;
  methodname = mono_unicode_to_external (D.22412);
  method = mono_class_get_method_from_name (klass, methodname, -1);
  if (method != 0B) goto <D.22413>; else goto <D.22414>;
  <D.22413>:
  i.65 = (unsigned int) i;
  D.22410 = i.65 * 4;
  D.22415 = rgDispId + D.22410;
  D.22416 = method->token;
  D.22417 = (int) D.22416;
  *D.22415 = D.22417;
  goto <D.22418>;
  <D.22414>:
  i.65 = (unsigned int) i;
  D.22410 = i.65 * 4;
  D.22415 = rgDispId + D.22410;
  *D.22415 = -1;
  ret = -2147352570;
  <D.22418>:
  i = i + 1;
  <D.21522>:
  i.66 = (unsigned int) i;
  if (i.66 < cNames) goto <D.21521>; else goto <D.21523>;
  <D.21523>:
  D.22420 = ret;
  return D.22420;
}


cominterop_ccw_get_type_info (struct MonoCCWInterface * ccwe, guint32 iTInfo, guint32 lcid, void * * ppTInfo)
{
  int D.22422;

  D.22422 = -2147467263;
  return D.22422;
}


cominterop_ccw_get_type_info_count (struct MonoCCWInterface * ccwe, guint32 * pctinfo)
{
  int D.22426;

  if (pctinfo == 0B) goto <D.22424>; else goto <D.22425>;
  <D.22424>:
  D.22426 = -2147024809;
  return D.22426;
  <D.22425>:
  *pctinfo = 1;
  D.22426 = 0;
  return D.22426;
}


cominterop_ccw_release (struct MonoCCWInterface * ccwe)
{
  _Bool D.22428;
  long int D.22429;
  long int D.22430;
  unsigned int D.22433;
  _Bool D.22434;
  long int D.22435;
  long int D.22436;
  guint32 * D.22439;
  _Bool D.22442;
  long int D.22443;
  long int D.22444;
  struct MonoObject * D.22447;
  unsigned int D.22448;
  int D.22449;
  gint32 ref_count;
  struct MonoCCW * ccw;

  ref_count = 0;
  ccw = ccwe->ccw;
  D.22428 = ccw == 0B;
  D.22429 = (long int) D.22428;
  D.22430 = __builtin_expect (D.22429, 0);
  if (D.22430 != 0) goto <D.22431>; else goto <D.22432>;
  <D.22431>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2272, "ccw");
  <D.22432>:
  D.22433 = ccw->ref_count;
  D.22434 = D.22433 == 0;
  D.22435 = (long int) D.22434;
  D.22436 = __builtin_expect (D.22435, 0);
  if (D.22436 != 0) goto <D.22437>; else goto <D.22438>;
  <D.22437>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2273, "ccw->ref_count > 0");
  <D.22438>:
  D.22439 = &ccw->ref_count;
  ref_count = InterlockedDecrement (D.22439);
  if (ref_count == 0) goto <D.22440>; else goto <D.22441>;
  <D.22440>:
  {
    guint32 oldhandle;

    oldhandle = ccw->gc_handle;
    D.22442 = oldhandle == 0;
    D.22443 = (long int) D.22442;
    D.22444 = __builtin_expect (D.22443, 0);
    if (D.22444 != 0) goto <D.22445>; else goto <D.22446>;
    <D.22445>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2278, "oldhandle");
    <D.22446>:
    D.22447 = mono_gchandle_get_target (oldhandle);
    D.22448 = mono_gchandle_new_weakref (D.22447, 0);
    ccw->gc_handle = D.22448;
    mono_gchandle_free (oldhandle);
  }
  <D.22441>:
  D.22449 = ref_count;
  return D.22449;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.22451;
  unsigned int D.22452;

  D.22452 = __sync_sub_and_fetch_4 (val, 1);
  D.22451 = (gint32) D.22452;
  return D.22451;
}


cominterop_ccw_addref (struct MonoCCWInterface * ccwe)
{
  _Bool D.22454;
  long int D.22455;
  long int D.22456;
  unsigned int D.22459;
  _Bool D.22460;
  long int D.22461;
  long int D.22462;
  guint32 * D.22467;
  _Bool D.22470;
  long int D.22471;
  long int D.22472;
  struct MonoObject * D.22475;
  unsigned int D.22476;
  int D.22477;
  gint32 ref_count;
  struct MonoCCW * ccw;

  ref_count = 0;
  ccw = ccwe->ccw;
  D.22454 = ccw == 0B;
  D.22455 = (long int) D.22454;
  D.22456 = __builtin_expect (D.22455, 0);
  if (D.22456 != 0) goto <D.22457>; else goto <D.22458>;
  <D.22457>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2253, "ccw");
  <D.22458>:
  D.22459 = ccw->gc_handle;
  D.22460 = D.22459 == 0;
  D.22461 = (long int) D.22460;
  D.22462 = __builtin_expect (D.22461, 0);
  if (D.22462 != 0) goto <D.22463>; else goto <D.22464>;
  <D.22463>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2254, "ccw->gc_handle");
  <D.22464>:
  if (0 != 0) goto <D.22465>; else goto <D.22466>;
  <D.22465>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2255, "ccw->ref_count >= 0");
  <D.22466>:
  D.22467 = &ccw->ref_count;
  ref_count = InterlockedIncrement (D.22467);
  if (ref_count == 1) goto <D.22468>; else goto <D.22469>;
  <D.22468>:
  {
    guint32 oldhandle;

    oldhandle = ccw->gc_handle;
    D.22470 = oldhandle == 0;
    D.22471 = (long int) D.22470;
    D.22472 = __builtin_expect (D.22471, 0);
    if (D.22472 != 0) goto <D.22473>; else goto <D.22474>;
    <D.22473>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2259, "oldhandle");
    <D.22474>:
    D.22475 = mono_gchandle_get_target (oldhandle);
    D.22476 = mono_gchandle_new (D.22475, 0);
    ccw->gc_handle = D.22476;
    mono_gchandle_free (oldhandle);
  }
  <D.22469>:
  D.22477 = ref_count;
  return D.22477;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.22479;
  unsigned int D.22480;

  D.22480 = __sync_add_and_fetch_4 (val, 1);
  D.22479 = (gint32) D.22480;
  return D.22479;
}


cominterop_ccw_queryinterface (struct MonoCCWInterface * ccwe, guint8 * riid, void * * ppv)
{
  unsigned int D.22482;
  _Bool D.22483;
  long int D.22484;
  long int D.22485;
  struct MonoVTable * D.22488;
  struct MonoDomain * D.22491;
  struct MonoDomain * D.22494;
  struct MonoClass * D.22495;
  int D.22496;
  struct MonoClass * D.22499;
  void * D.22500;
  void * D.22501;
  int D.22502;
  struct MonoClass * D.22503;
  int D.22504;
  int D.22507;
  struct MonoClass * D.22510;
  void * D.22511;
  int D.22512;
  _Bool D.22513;
  long int D.22514;
  long int D.22515;
  void * * D.22520;
  unsigned int i.67;
  unsigned int D.22522;
  void * * D.22523;
  int D.22524;
  unsigned int i.68;
  unsigned int D.22528;
  struct MonoClass * D.22531;
  void * D.22534;
  struct MonoError error;
  struct GPtrArray * ifaces;
  struct MonoClass * itf;
  int i;
  struct MonoCCW * ccw;
  struct MonoClass * klass;
  struct MonoClass * klass_iter;
  struct MonoObject * object;

  try
    {
      itf = 0B;
      ccw = ccwe->ccw;
      klass = 0B;
      klass_iter = 0B;
      D.22482 = ccw->gc_handle;
      object = mono_gchandle_get_target (D.22482);
      D.22483 = object == 0B;
      D.22484 = (long int) D.22483;
      D.22485 = __builtin_expect (D.22484, 0);
      if (D.22485 != 0) goto <D.22486>; else goto <D.22487>;
      <D.22486>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2324, "object");
      <D.22487>:
      D.22488 = object->vtable;
      klass = D.22488->klass;
      if (ppv != 0B) goto <D.22489>; else goto <D.22490>;
      <D.22489>:
      *ppv = 0B;
      <D.22490>:
      D.22491 = mono_domain_get ();
      if (D.22491 == 0B) goto <D.22492>; else goto <D.22493>;
      <D.22492>:
      D.22494 = mono_get_root_domain ();
      mono_thread_attach (D.22494);
      <D.22493>:
      D.22495 = mono_class_get_iunknown_class ();
      D.22496 = cominterop_class_guid_equal (riid, D.22495);
      if (D.22496 != 0) goto <D.22497>; else goto <D.22498>;
      <D.22497>:
      D.22499 = mono_class_get_iunknown_class ();
      D.22500 = cominterop_get_ccw (object, D.22499);
      *ppv = D.22500;
      D.22501 = *ppv;
      cominterop_ccw_addref (D.22501);
      D.22502 = 0;
      return D.22502;
      <D.22498>:
      D.22503 = mono_class_get_idispatch_class ();
      D.22504 = cominterop_class_guid_equal (riid, D.22503);
      if (D.22504 != 0) goto <D.22505>; else goto <D.22506>;
      <D.22505>:
      D.22507 = cominterop_can_support_dispatch (klass);
      if (D.22507 == 0) goto <D.22508>; else goto <D.22509>;
      <D.22508>:
      D.22502 = -2147467262;
      return D.22502;
      <D.22509>:
      D.22510 = mono_class_get_idispatch_class ();
      D.22511 = cominterop_get_ccw (object, D.22510);
      *ppv = D.22511;
      D.22501 = *ppv;
      cominterop_ccw_addref (D.22501);
      D.22502 = 0;
      return D.22502;
      <D.22506>:
      klass_iter = klass;
      goto <D.21495>;
      <D.21494>:
      ifaces = mono_class_get_implemented_interfaces (klass_iter, &error);
      D.22512 = mono_error_ok (&error);
      D.22513 = D.22512 == 0;
      D.22514 = (long int) D.22513;
      D.22515 = __builtin_expect (D.22514, 0);
      if (D.22515 != 0) goto <D.22516>; else goto <D.22517>;
      <D.22516>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2361, "mono_error_ok (&error)");
      <D.22517>:
      if (ifaces != 0B) goto <D.22518>; else goto <D.22519>;
      <D.22518>:
      i = 0;
      goto <D.21492>;
      <D.21491>:
      {
        struct MonoClass * ic;

        ic = 0B;
        D.22520 = ifaces->pdata;
        i.67 = (unsigned int) i;
        D.22522 = i.67 * 4;
        D.22523 = D.22520 + D.22522;
        ic = *D.22523;
        D.22524 = cominterop_class_guid_equal (riid, ic);
        if (D.22524 != 0) goto <D.22525>; else goto <D.22526>;
        <D.22525>:
        itf = ic;
        goto <D.21490>;
        <D.22526>:
      }
      i = i + 1;
      <D.21492>:
      i.68 = (unsigned int) i;
      D.22528 = ifaces->len;
      if (i.68 < D.22528) goto <D.21491>; else goto <D.21490>;
      <D.21490>:
      monoeg_g_ptr_array_free (ifaces, 1);
      <D.22519>:
      if (itf != 0B) goto <D.21493>; else goto <D.22529>;
      <D.22529>:
      klass_iter = klass_iter->parent;
      <D.21495>:
      if (klass_iter != 0B) goto <D.22530>; else goto <D.21493>;
      <D.22530>:
      D.22531 = mono_defaults.object_class;
      if (D.22531 != klass_iter) goto <D.21494>; else goto <D.21493>;
      <D.21493>:
      if (itf != 0B) goto <D.22532>; else goto <D.22533>;
      <D.22532>:
      D.22534 = cominterop_get_ccw (object, itf);
      *ppv = D.22534;
      D.22501 = *ppv;
      cominterop_ccw_addref (D.22501);
      D.22502 = 0;
      return D.22502;
      <D.22533>:
      D.22502 = -2147467262;
      return D.22502;
    }
  finally
    {
      error = {CLOBBER};
    }
}


cominterop_can_support_dispatch (struct MonoClass * klass)
{
  unsigned int D.22537;
  unsigned int D.22538;
  gboolean D.22541;
  int D.22542;

  D.22537 = klass->flags;
  D.22538 = D.22537 & 1;
  if (D.22538 == 0) goto <D.22539>; else goto <D.22540>;
  <D.22539>:
  D.22541 = 0;
  return D.22541;
  <D.22540>:
  D.22542 = cominterop_com_visible (klass);
  if (D.22542 == 0) goto <D.22543>; else goto <D.22544>;
  <D.22543>:
  D.22541 = 0;
  return D.22541;
  <D.22544>:
  D.22541 = 1;
  return D.22541;
}


cominterop_com_visible (struct MonoClass * klass)
{
  struct MonoClass * ComVisibleAttribute.69;
  struct MonoImage * D.22549;
  struct MonoClass * ComVisibleAttribute.70;
  int D.22555;
  gboolean D.22560;
  int D.22561;
  _Bool D.22562;
  long int D.22563;
  long int D.22564;
  void * * D.22569;
  unsigned int i.71;
  unsigned int D.22571;
  void * * D.22572;
  unsigned int D.22573;
  unsigned int D.22574;
  unsigned int i.72;
  unsigned int D.22578;
  static struct MonoClass * ComVisibleAttribute = 0B;
  struct MonoError error;
  struct MonoCustomAttrInfo * cinfo;
  struct GPtrArray * ifaces;
  MonoBoolean visible;

  try
    {
      visible = 1;
      ComVisibleAttribute.69 = ComVisibleAttribute;
      if (ComVisibleAttribute.69 == 0B) goto <D.22547>; else goto <D.22548>;
      <D.22547>:
      D.22549 = mono_defaults.corlib;
      ComVisibleAttribute.70 = mono_class_from_name (D.22549, "System.Runtime.InteropServices", "ComVisibleAttribute");
      ComVisibleAttribute = ComVisibleAttribute.70;
      <D.22548>:
      cinfo = mono_custom_attrs_from_class (klass);
      if (cinfo != 0B) goto <D.22551>; else goto <D.22552>;
      <D.22551>:
      {
        struct MonoReflectionComVisibleAttribute * attr;

        ComVisibleAttribute.69 = ComVisibleAttribute;
        attr = mono_custom_attrs_get_attr (cinfo, ComVisibleAttribute.69);
        if (attr != 0B) goto <D.22553>; else goto <D.22554>;
        <D.22553>:
        visible = attr->visible;
        <D.22554>:
        D.22555 = cinfo->cached;
        if (D.22555 == 0) goto <D.22556>; else goto <D.22557>;
        <D.22556>:
        mono_custom_attrs_free (cinfo);
        <D.22557>:
        if (visible != 0) goto <D.22558>; else goto <D.22559>;
        <D.22558>:
        D.22560 = 1;
        return D.22560;
        <D.22559>:
      }
      <D.22552>:
      ifaces = mono_class_get_implemented_interfaces (klass, &error);
      D.22561 = mono_error_ok (&error);
      D.22562 = D.22561 == 0;
      D.22563 = (long int) D.22562;
      D.22564 = __builtin_expect (D.22563, 0);
      if (D.22564 != 0) goto <D.22565>; else goto <D.22566>;
      <D.22565>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 434, "mono_error_ok (&error)");
      <D.22566>:
      if (ifaces != 0B) goto <D.22567>; else goto <D.22568>;
      <D.22567>:
      {
        int i;

        i = 0;
        goto <D.21033>;
        <D.21032>:
        {
          struct MonoClass * ic;

          ic = 0B;
          D.22569 = ifaces->pdata;
          i.71 = (unsigned int) i;
          D.22571 = i.71 * 4;
          D.22572 = D.22569 + D.22571;
          ic = *D.22572;
          D.22573 = ic->flags;
          D.22574 = D.22573 & 4096;
          if (D.22574 != 0) goto <D.22575>; else goto <D.22576>;
          <D.22575>:
          visible = 1;
          <D.22576>:
        }
        i = i + 1;
        <D.21033>:
        i.72 = (unsigned int) i;
        D.22578 = ifaces->len;
        if (i.72 < D.22578) goto <D.21032>; else goto <D.21034>;
        <D.21034>:
        monoeg_g_ptr_array_free (ifaces, 1);
      }
      <D.22568>:
      D.22560 = (gboolean) visible;
      return D.22560;
    }
  finally
    {
      error = {CLOBBER};
    }
}


cominterop_class_guid_equal (guint8 * guid, struct MonoClass * klass)
{
  int D.22581;
  gboolean D.22584;
  int D.22585;
  _Bool D.22586;
  guint8 klass_guid[16];

  try
    {
      D.22581 = cominterop_class_guid (klass, &klass_guid);
      if (D.22581 != 0) goto <D.22582>; else goto <D.22583>;
      <D.22582>:
      D.22585 = memcmp (guid, &klass_guid, 16);
      D.22586 = D.22585 == 0;
      D.22584 = (gboolean) D.22586;
      return D.22584;
      <D.22583>:
      D.22584 = 0;
      return D.22584;
    }
  finally
    {
      klass_guid = {CLOBBER};
    }
}


cominterop_get_com_slot_begin (struct MonoClass * klass)
{
  struct MonoClass * interface_type_attribute.73;
  struct MonoImage * D.22592;
  struct MonoClass * interface_type_attribute.74;
  int D.22596;
  unsigned int D.22601;
  int D.22603;
  static struct MonoClass * interface_type_attribute = 0B;
  struct MonoCustomAttrInfo * cinfo;
  struct MonoInterfaceTypeAttribute * itf_attr;

  cinfo = 0B;
  itf_attr = 0B;
  interface_type_attribute.73 = interface_type_attribute;
  if (interface_type_attribute.73 == 0B) goto <D.22590>; else goto <D.22591>;
  <D.22590>:
  D.22592 = mono_defaults.corlib;
  interface_type_attribute.74 = mono_class_from_name (D.22592, "System.Runtime.InteropServices", "InterfaceTypeAttribute");
  interface_type_attribute = interface_type_attribute.74;
  <D.22591>:
  cinfo = mono_custom_attrs_from_class (klass);
  if (cinfo != 0B) goto <D.22594>; else goto <D.22595>;
  <D.22594>:
  interface_type_attribute.73 = interface_type_attribute;
  itf_attr = mono_custom_attrs_get_attr (cinfo, interface_type_attribute.73);
  D.22596 = cinfo->cached;
  if (D.22596 == 0) goto <D.22597>; else goto <D.22598>;
  <D.22597>:
  mono_custom_attrs_free (cinfo);
  <D.22598>:
  <D.22595>:
  if (itf_attr != 0B) goto <D.22600>; else goto <D.22599>;
  <D.22600>:
  D.22601 = itf_attr->intType;
  if (D.22601 == 1) goto <D.22602>; else goto <D.22599>;
  <D.22602>:
  D.22603 = 3;
  return D.22603;
  <D.22599>:
  D.22603 = 7;
  return D.22603;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.22605;
  unsigned int D.22606;

  D.22606 = __builtin_object_size (__dest, 0);
  D.22605 = __builtin___memcpy_chk (__dest, __src, __len, D.22606);
  return D.22605;
}


cominterop_get_managed_wrapper_adjusted (struct MonoMethod * method)
{
  short unsigned int D.22608;
  int D.22609;
  struct MonoMethod * get_hr_for_exception.75;
  struct MonoClass * D.22613;
  struct MonoMethod * get_hr_for_exception.76;
  struct MonoClass * D.22615;
  const char * D.22616;
  short unsigned int D.22617;
  int D.22618;
  int D.22619;
  unsigned int D.22620;
  unsigned int D.22621;
  short unsigned int D.22622;
  sizetype i.77;
  sizetype D.22624;
  sizetype D.22625;
  struct MonoMarshalSpec * * D.22626;
  unsigned int i.78;
  unsigned int D.22628;
  struct MonoMarshalSpec * * D.22629;
  struct MonoMarshalSpec * D.22630;
  struct MonoMarshalSpec * * D.22631;
  struct MonoType * D.22634;
  int D.22635;
  unsigned int D.22638;
  unsigned int D.22639;
  struct MonoMarshalSpec * * D.22640;
  struct MonoMarshalSpec * D.22641;
  struct MonoClass * D.22644;
  struct MonoType * D.22645;
  int D.22647;
  int D.22650;
  unsigned int D.22651;
  int D.22654;
  int D.22657;
  unsigned int D.22658;
  int D.22659;
  unsigned int D.22660;
  int D.22661;
  int D.22662;
  unsigned char D.22667;
  unsigned char D.22668;
  unsigned int D.22672;
  unsigned char D.22673;
  unsigned int hr.79;
  unsigned int D.22676;
  int D.22677;
  unsigned int D.22678;
  unsigned int D.22679;
  unsigned int D.22680;
  struct MonoClass * D.22681;
  int D.22682;
  unsigned int D.22683;
  unsigned char D.22689;
  unsigned char D.22690;
  unsigned char D.22692;
  unsigned char D.22693;
  int D.22694;
  unsigned int D.22695;
  unsigned int D.22696;
  unsigned int D.22697;
  unsigned int pos_leave.80;
  int D.22702;
  _Bool D.22705;
  long int D.22706;
  long int D.22707;
  int D.22710;
  _Bool D.22713;
  long int D.22714;
  long int D.22715;
  struct MonoMethod * D.22720;
  static struct MonoMethod * get_hr_for_exception = 0B;
  struct MonoMethod * res;
  struct MonoMethodBuilder * mb;
  struct MonoMarshalSpec * * mspecs;
  struct MonoMethodSignature * sig;
  struct MonoMethodSignature * sig_native;
  struct MonoExceptionClause * main_clause;
  int pos_leave;
  int hr;
  int i;
  gboolean preserve_sig;

  res = 0B;
  main_clause = 0B;
  hr = 0;
  D.22608 = method->iflags;
  D.22609 = (int) D.22608;
  preserve_sig = D.22609 & 128;
  get_hr_for_exception.75 = get_hr_for_exception;
  if (get_hr_for_exception.75 == 0B) goto <D.22611>; else goto <D.22612>;
  <D.22611>:
  D.22613 = mono_defaults.marshal_class;
  get_hr_for_exception.76 = mono_class_get_method_from_name (D.22613, "GetHRForException", -1);
  get_hr_for_exception = get_hr_for_exception.76;
  <D.22612>:
  sig = mono_method_signature (method);
  D.22615 = method->klass;
  D.22616 = method->name;
  mb = mono_mb_new (D.22615, D.22616, 27);
  sig_native = cominterop_method_signature (method);
  D.22617 = sig_native->param_count;
  D.22618 = (int) D.22617;
  D.22619 = D.22618 + 1;
  D.22620 = (unsigned int) D.22619;
  D.22621 = D.22620 * 4;
  mspecs = monoeg_malloc0 (D.22621);
  mono_method_get_marshal_info (method, mspecs);
  D.22622 = sig->param_count;
  i = (int) D.22622;
  goto <D.21438>;
  <D.21437>:
  i.77 = (sizetype) i;
  D.22624 = i.77 + 1;
  D.22625 = D.22624 * 4;
  D.22626 = mspecs + D.22625;
  i.78 = (unsigned int) i;
  D.22628 = i.78 * 4;
  D.22629 = mspecs + D.22628;
  D.22630 = *D.22629;
  *D.22626 = D.22630;
  i = i + -1;
  <D.21438>:
  if (i > 0) goto <D.21437>; else goto <D.21439>;
  <D.21439>:
  D.22631 = mspecs + 4;
  *D.22631 = 0B;
  if (preserve_sig == 0) goto <D.22632>; else goto <D.22633>;
  <D.22632>:
  D.22634 = sig->ret;
  D.22635 = mono_type_is_void (D.22634);
  if (D.22635 == 0) goto <D.22636>; else goto <D.22637>;
  <D.22636>:
  D.22617 = sig_native->param_count;
  D.22638 = (unsigned int) D.22617;
  D.22639 = D.22638 * 4;
  D.22640 = mspecs + D.22639;
  D.22641 = *mspecs;
  *D.22640 = D.22641;
  <D.22637>:
  <D.22633>:
  *mspecs = 0B;
  if (preserve_sig == 0) goto <D.22642>; else goto <D.22643>;
  <D.22642>:
  D.22644 = mono_defaults.int32_class;
  D.22645 = &D.22644->byval_arg;
  hr = mono_mb_add_local (mb, D.22645);
  goto <D.22646>;
  <D.22643>:
  D.22634 = sig->ret;
  D.22647 = mono_type_is_void (D.22634);
  if (D.22647 == 0) goto <D.22648>; else goto <D.22649>;
  <D.22648>:
  D.22634 = sig->ret;
  hr = mono_mb_add_local (mb, D.22634);
  <D.22649>:
  <D.22646>:
  main_clause = monoeg_malloc0 (24);
  D.22650 = mono_mb_get_label (mb);
  D.22651 = (unsigned int) D.22650;
  main_clause->try_offset = D.22651;
  if (preserve_sig == 0) goto <D.22652>; else goto <D.22653>;
  <D.22652>:
  D.22634 = sig->ret;
  D.22654 = mono_type_is_void (D.22634);
  if (D.22654 == 0) goto <D.22655>; else goto <D.22656>;
  <D.22655>:
  D.22617 = sig_native->param_count;
  D.22618 = (int) D.22617;
  D.22657 = D.22618 + -1;
  D.22658 = (unsigned int) D.22657;
  mono_mb_emit_ldarg (mb, D.22658);
  <D.22656>:
  <D.22653>:
  mono_mb_emit_ldarg (mb, 0);
  mono_mb_emit_icon (mb, 0);
  mono_mb_emit_icall (mb, cominterop_get_ccw_object);
  i = 0;
  goto <D.21441>;
  <D.21440>:
  D.22659 = i + 1;
  D.22660 = (unsigned int) D.22659;
  mono_mb_emit_ldarg (mb, D.22660);
  i = i + 1;
  <D.21441>:
  D.22622 = sig->param_count;
  D.22661 = (int) D.22622;
  if (D.22661 > i) goto <D.21440>; else goto <D.21442>;
  <D.21442>:
  mono_mb_emit_managed_call (mb, method, 0B);
  D.22634 = sig->ret;
  D.22662 = mono_type_is_void (D.22634);
  if (D.22662 == 0) goto <D.22663>; else goto <D.22664>;
  <D.22663>:
  if (preserve_sig == 0) goto <D.22665>; else goto <D.22666>;
  <D.22665>:
  {
    struct MonoClass * rclass;

    D.22634 = sig->ret;
    rclass = mono_class_from_mono_type (D.22634);
    D.22667 = BIT_FIELD_REF <*rclass, 8, 160>;
    D.22668 = D.22667 & 8;
    if (D.22668 != 0) goto <D.22669>; else goto <D.22670>;
    <D.22669>:
    mono_mb_emit_op (mb, 129, rclass);
    goto <D.22671>;
    <D.22670>:
    D.22634 = sig->ret;
    D.22672 = mono_type_to_stind (D.22634);
    D.22673 = (unsigned char) D.22672;
    mono_mb_emit_byte (mb, D.22673);
    <D.22671>:
  }
  goto <D.22674>;
  <D.22666>:
  hr.79 = (unsigned int) hr;
  mono_mb_emit_stloc (mb, hr.79);
  <D.22674>:
  <D.22664>:
  D.22676 = mono_mb_emit_branch (mb, 221);
  pos_leave = (int) D.22676;
  main_clause->flags = 0;
  D.22677 = mono_mb_get_pos (mb);
  D.22678 = (unsigned int) D.22677;
  D.22679 = main_clause->try_offset;
  D.22680 = D.22678 - D.22679;
  main_clause->try_len = D.22680;
  D.22681 = mono_defaults.object_class;
  main_clause->data.catch_class = D.22681;
  D.22682 = mono_mb_get_label (mb);
  D.22683 = (unsigned int) D.22682;
  main_clause->handler_offset = D.22683;
  if (preserve_sig == 0) goto <D.22684>; else goto <D.22687>;
  <D.22687>:
  D.22634 = sig->ret;
  if (D.22634 != 0B) goto <D.22688>; else goto <D.22685>;
  <D.22688>:
  D.22634 = sig->ret;
  D.22689 = BIT_FIELD_REF <*D.22634, 8, 56>;
  D.22690 = D.22689 & 64;
  if (D.22690 == 0) goto <D.22691>; else goto <D.22685>;
  <D.22691>:
  D.22634 = sig->ret;
  D.22692 = D.22634->type;
  D.22693 = D.22692 + 248;
  if (D.22693 <= 1) goto <D.22684>; else goto <D.22685>;
  <D.22684>:
  get_hr_for_exception.75 = get_hr_for_exception;
  mono_mb_emit_managed_call (mb, get_hr_for_exception.75, 0B);
  hr.79 = (unsigned int) hr;
  mono_mb_emit_stloc (mb, hr.79);
  goto <D.22686>;
  <D.22685>:
  mono_mb_emit_byte (mb, 38);
  <D.22686>:
  mono_mb_emit_branch (mb, 221);
  D.22694 = mono_mb_get_pos (mb);
  D.22695 = (unsigned int) D.22694;
  D.22696 = main_clause->handler_offset;
  D.22697 = D.22695 - D.22696;
  main_clause->handler_len = D.22697;
  mono_mb_set_clauses (mb, 1, main_clause);
  pos_leave.80 = (unsigned int) pos_leave;
  mono_mb_patch_branch (mb, pos_leave.80);
  if (preserve_sig == 0) goto <D.22699>; else goto <D.22701>;
  <D.22701>:
  D.22634 = sig->ret;
  D.22702 = mono_type_is_void (D.22634);
  if (D.22702 == 0) goto <D.22699>; else goto <D.22700>;
  <D.22699>:
  hr.79 = (unsigned int) hr;
  mono_mb_emit_ldloc (mb, hr.79);
  <D.22700>:
  mono_mb_emit_byte (mb, 42);
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.22703>; else goto <D.22704>;
    <D.22703>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.22704>:
    D.22705 = ret != 0;
    D.22706 = (long int) D.22705;
    D.22707 = __builtin_expect (D.22706, 0);
    if (D.22707 != 0) goto <D.22708>; else goto <D.22709>;
    <D.22708>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2209, "ret == 0");
    <D.22709>:
  }
  D.22617 = sig_native->param_count;
  D.22618 = (int) D.22617;
  D.22710 = D.22618 + 16;
  res = mono_mb_create_method (mb, sig_native, D.22710);
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.22711>; else goto <D.22712>;
    <D.22711>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.22712>:
    D.22713 = ret != 0;
    D.22714 = (long int) D.22713;
    D.22715 = __builtin_expect (D.22714, 0);
    if (D.22715 != 0) goto <D.22716>; else goto <D.22717>;
    <D.22716>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2211, "ret == 0");
    <D.22717>:
  }
  mono_mb_free (mb);
  D.22617 = sig_native->param_count;
  i = (int) D.22617;
  goto <D.21447>;
  <D.21446>:
  i.78 = (unsigned int) i;
  D.22628 = i.78 * 4;
  D.22629 = mspecs + D.22628;
  D.22630 = *D.22629;
  if (D.22630 != 0B) goto <D.22718>; else goto <D.22719>;
  <D.22718>:
  i.78 = (unsigned int) i;
  D.22628 = i.78 * 4;
  D.22629 = mspecs + D.22628;
  D.22630 = *D.22629;
  mono_metadata_free_marshal_spec (D.22630);
  <D.22719>:
  i = i + -1;
  <D.21447>:
  if (i >= 0) goto <D.21446>; else goto <D.21448>;
  <D.21448>:
  monoeg_g_free (mspecs);
  D.22720 = res;
  return D.22720;
}


cominterop_method_signature (struct MonoMethod * method)
{
  struct MonoClass * D.22722;
  short unsigned int D.22723;
  int D.22724;
  short unsigned int D.22725;
  int D.22726;
  struct MonoType * D.22729;
  int D.22730;
  unsigned int param_count.81;
  unsigned int D.22734;
  unsigned int D.22735;
  unsigned int D.22736;
  unsigned int sigsize.82;
  int D.22738;
  struct MonoType * D.22739;
  struct MonoClass * D.22740;
  struct MonoType * D.22741;
  int D.22745;
  int D.22748;
  struct MonoType * D.22749;
  struct MonoType * D.22750;
  struct MonoClass * D.22751;
  struct MonoType * D.22752;
  short unsigned int D.22753;
  struct MonoMethodSignature * D.22754;
  struct MonoMethodSignature * res;
  struct MonoImage * image;
  struct MonoMethodSignature * sig;
  gboolean preserve_sig;
  int sigsize;
  int i;
  int param_count;

  D.22722 = method->klass;
  image = D.22722->image;
  sig = mono_method_signature (method);
  D.22723 = method->iflags;
  D.22724 = (int) D.22723;
  preserve_sig = D.22724 & 128;
  D.22725 = sig->param_count;
  D.22726 = (int) D.22725;
  param_count = D.22726 + 1;
  if (preserve_sig == 0) goto <D.22727>; else goto <D.22728>;
  <D.22727>:
  D.22729 = sig->ret;
  D.22730 = mono_type_is_void (D.22729);
  if (D.22730 == 0) goto <D.22731>; else goto <D.22732>;
  <D.22731>:
  param_count = param_count + 1;
  <D.22732>:
  <D.22728>:
  param_count.81 = (unsigned int) param_count;
  res = mono_metadata_signature_alloc (image, param_count.81);
  D.22725 = sig->param_count;
  D.22734 = (unsigned int) D.22725;
  D.22735 = D.22734 + 3;
  D.22736 = D.22735 * 4;
  sigsize = (int) D.22736;
  sigsize.82 = (unsigned int) sigsize;
  memcpy (res, sig, sigsize.82);
  D.22725 = sig->param_count;
  D.22726 = (int) D.22725;
  i = D.22726 + -1;
  goto <D.20967>;
  <D.20966>:
  D.22738 = i + 1;
  D.22739 = sig->params[i];
  res->params[D.22738] = D.22739;
  i = i + -1;
  <D.20967>:
  if (i >= 0) goto <D.20966>; else goto <D.20968>;
  <D.20968>:
  D.22740 = mono_defaults.int_class;
  D.22741 = &D.22740->byval_arg;
  res->params[0] = D.22741;
  if (preserve_sig != 0) goto <D.22742>; else goto <D.22743>;
  <D.22742>:
  D.22729 = sig->ret;
  res->ret = D.22729;
  goto <D.22744>;
  <D.22743>:
  D.22729 = sig->ret;
  D.22745 = mono_type_is_void (D.22729);
  if (D.22745 == 0) goto <D.22746>; else goto <D.22747>;
  <D.22746>:
  D.22748 = param_count + -1;
  D.22729 = sig->ret;
  D.22749 = mono_metadata_type_dup (image, D.22729);
  res->params[D.22748] = D.22749;
  D.22748 = param_count + -1;
  D.22750 = res->params[D.22748];
  D.22750->byref = 1;
  D.22748 = param_count + -1;
  D.22750 = res->params[D.22748];
  D.22750->attrs = 2;
  <D.22747>:
  D.22751 = mono_defaults.int32_class;
  D.22752 = &D.22751->byval_arg;
  res->ret = D.22752;
  <D.22744>:
  res->pinvoke = 0;
  res->hasthis = 0;
  D.22753 = (short unsigned int) param_count;
  res->param_count = D.22753;
  res->call_convention = 1;
  D.22754 = res;
  return D.22754;
}


cominterop_setup_marshal_context (struct EmitMarshalContext * m, struct MonoMethod * method)
{
  struct MonoClass * D.22756;
  struct MonoImage * D.22757;
  struct MonoMethodSignature * sig;
  struct MonoMethodSignature * csig;

  sig = mono_method_signature (method);
  D.22756 = method->klass;
  D.22757 = D.22756->image;
  csig = mono_metadata_signature_dup_full (D.22757, sig);
  csig->call_convention = 1;
  csig->hasthis = 0;
  csig->pinvoke = 1;
  D.22756 = method->klass;
  D.22757 = D.22756->image;
  m->image = D.22757;
  m->piinfo = 0B;
  m->retobj_var = 0;
  m->sig = sig;
  m->csig = csig;
}


cominterop_object_is_rcw (struct MonoObject * obj)
{
  gboolean D.22760;
  struct MonoVTable * D.22761;
  struct MonoClass * D.22762;
  struct MonoVTable * D.22767;
  int iftmp.83;
  struct MonoClass * D.22772;
  struct MonoClass * klass;
  struct MonoRealProxy * real_proxy;

  klass = 0B;
  real_proxy = 0B;
  if (obj == 0B) goto <D.22758>; else goto <D.22759>;
  <D.22758>:
  D.22760 = 0;
  return D.22760;
  <D.22759>:
  D.22761 = obj->vtable;
  klass = D.22761->klass;
  D.22762 = mono_defaults.transparent_proxy_class;
  if (D.22762 != klass) goto <D.22763>; else goto <D.22764>;
  <D.22763>:
  D.22760 = 0;
  return D.22760;
  <D.22764>:
  real_proxy = MEM[(struct MonoTransparentProxy *)obj].rp;
  if (real_proxy == 0B) goto <D.22765>; else goto <D.22766>;
  <D.22765>:
  D.22760 = 0;
  return D.22760;
  <D.22766>:
  D.22767 = MEM[(struct MonoObject *)real_proxy].vtable;
  klass = D.22767->klass;
  if (klass != 0B) goto <D.22771>; else goto <D.22769>;
  <D.22771>:
  D.22772 = mono_class_get_interop_proxy_class ();
  if (D.22772 == klass) goto <D.22773>; else goto <D.22769>;
  <D.22773>:
  iftmp.83 = 1;
  goto <D.22770>;
  <D.22769>:
  iftmp.83 = 0;
  <D.22770>:
  D.22760 = iftmp.83;
  return D.22760;
}


cominterop_get_function_pointer (void * itf, int slot)
{
  void * * D.22775;
  unsigned int slot.84;
  unsigned int D.22777;
  void * * D.22778;
  void * D.22779;
  void * func;

  D.22775 = MEM[(void * * *)itf];
  slot.84 = (unsigned int) slot;
  D.22777 = slot.84 * 4;
  D.22778 = D.22775 + D.22777;
  func = *D.22778;
  D.22779 = func;
  return D.22779;
}


cominterop_get_method_interface (struct MonoMethod * method)
{
  struct MonoClass * D.22781;
  unsigned int D.22782;
  unsigned int D.22783;
  unsigned char D.22786;
  int D.22791;
  _Bool D.22792;
  long int D.22793;
  long int D.22794;
  void * * D.22799;
  unsigned int i.85;
  unsigned int D.22801;
  void * * D.22802;
  struct MonoMethod * * D.22803;
  int D.22804;
  unsigned int D.22805;
  unsigned int D.22806;
  struct MonoMethod * * D.22807;
  struct MonoMethod * D.22808;
  unsigned int j.86;
  unsigned int D.22812;
  unsigned int i.87;
  unsigned int D.22815;
  _Bool D.22818;
  long int D.22819;
  long int D.22820;
  int iftmp.88;
  unsigned int D.22826;
  unsigned int D.22827;
  unsigned char D.22829;
  _Bool D.22832;
  long int D.22833;
  long int D.22834;
  struct MonoClass * D.22837;
  struct MonoError error;
  struct MonoClass * ic;

  try
    {
      ic = method->klass;
      D.22781 = method->klass;
      D.22782 = D.22781->flags;
      D.22783 = D.22782 & 32;
      if (D.22783 == 0) goto <D.22784>; else goto <D.22785>;
      <D.22784>:
      D.22781 = method->klass;
      D.22786 = D.22781->byval_arg.type;
      if (D.22786 != 19) goto <D.22787>; else goto <D.22788>;
      <D.22787>:
      D.22781 = method->klass;
      D.22786 = D.22781->byval_arg.type;
      if (D.22786 != 30) goto <D.22789>; else goto <D.22790>;
      <D.22789>:
      {
        struct GPtrArray * ifaces;

        D.22781 = method->klass;
        ifaces = mono_class_get_implemented_interfaces (D.22781, &error);
        D.22791 = mono_error_ok (&error);
        D.22792 = D.22791 == 0;
        D.22793 = (long int) D.22792;
        D.22794 = __builtin_expect (D.22793, 0);
        if (D.22794 != 0) goto <D.22795>; else goto <D.22796>;
        <D.22795>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 315, "mono_error_ok (&error)");
        <D.22796>:
        if (ifaces != 0B) goto <D.22797>; else goto <D.22798>;
        <D.22797>:
        {
          int i;

          D.22781 = method->klass;
          mono_class_setup_vtable (D.22781);
          i = 0;
          goto <D.21000>;
          <D.20999>:
          {
            int j;
            int offset;
            gboolean found;

            found = 0;
            D.22799 = ifaces->pdata;
            i.85 = (unsigned int) i;
            D.22801 = i.85 * 4;
            D.22802 = D.22799 + D.22801;
            ic = *D.22802;
            D.22781 = method->klass;
            offset = mono_class_interface_offset (D.22781, ic);
            j = 0;
            goto <D.20997>;
            <D.20996>:
            D.22781 = method->klass;
            D.22803 = D.22781->vtable;
            D.22804 = j + offset;
            D.22805 = (unsigned int) D.22804;
            D.22806 = D.22805 * 4;
            D.22807 = D.22803 + D.22806;
            D.22808 = *D.22807;
            if (D.22808 == method) goto <D.22809>; else goto <D.22810>;
            <D.22809>:
            found = 1;
            goto <D.20995>;
            <D.22810>:
            j = j + 1;
            <D.20997>:
            j.86 = (unsigned int) j;
            D.22812 = ic->method.count;
            if (j.86 < D.22812) goto <D.20996>; else goto <D.20995>;
            <D.20995>:
            if (found != 0) goto <D.20998>; else goto <D.22813>;
            <D.22813>:
            ic = 0B;
          }
          i = i + 1;
          <D.21000>:
          i.87 = (unsigned int) i;
          D.22815 = ifaces->len;
          if (i.87 < D.22815) goto <D.20999>; else goto <D.20998>;
          <D.20998>:
          monoeg_g_ptr_array_free (ifaces, 1);
        }
        <D.22798>:
      }
      <D.22790>:
      <D.22788>:
      <D.22785>:
      if (ic == 0B) goto <D.22816>; else goto <D.22817>;
      <D.22816>:
      D.22818 = ic == 0B;
      D.22819 = (long int) D.22818;
      D.22820 = __builtin_expect (D.22819, 0);
      if (D.22820 != 0) goto <D.22821>; else goto <D.22822>;
      <D.22821>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 339, "ic");
      <D.22822>:
      <D.22817>:
      D.22826 = ic->flags;
      D.22827 = D.22826 & 32;
      if (D.22827 == 0) goto <D.22828>; else goto <D.22824>;
      <D.22828>:
      D.22829 = ic->byval_arg.type;
      if (D.22829 != 19) goto <D.22830>; else goto <D.22824>;
      <D.22830>:
      D.22829 = ic->byval_arg.type;
      if (D.22829 != 30) goto <D.22831>; else goto <D.22824>;
      <D.22831>:
      iftmp.88 = 1;
      goto <D.22825>;
      <D.22824>:
      iftmp.88 = 0;
      <D.22825>:
      D.22832 = iftmp.88 != 0;
      D.22833 = (long int) D.22832;
      D.22834 = __builtin_expect (D.22833, 0);
      if (D.22834 != 0) goto <D.22835>; else goto <D.22836>;
      <D.22835>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 340, "MONO_CLASS_IS_INTERFACE (ic)");
      <D.22836>:
      D.22837 = ic;
      return D.22837;
    }
  finally
    {
      error = {CLOBBER};
    }
}


register_icall (void * func, const char * name, const char * sigstr, gboolean save)
{
  struct MonoMethodSignature * sig;

  sig = mono_create_icall_signature (sigstr);
  mono_register_jit_icall (func, name, sig, save);
}


mono_cominterop_cleanup ()
{
  DeleteCriticalSection (&cominterop_mutex);
}


mono_mb_emit_cominterop_call (struct MonoMethodBuilder * mb, struct MonoMethodSignature * sig, struct MonoMethod * method)
{
  int D.22840;

  mono_mb_emit_ldarg (mb, 0);
  D.22840 = cominterop_get_com_slot_for_method (method);
  mono_mb_emit_icon (mb, D.22840);
  mono_mb_emit_icall (mb, cominterop_get_function_pointer);
  mono_mb_emit_byte (mb, 240);
  mono_mb_emit_byte (mb, 9);
  mono_mb_emit_calli (mb, sig);
  mono_mb_emit_byte (mb, 240);
  mono_mb_emit_byte (mb, 10);
}


cominterop_get_com_slot_for_method (struct MonoMethod * method)
{
  short int D.22841;
  unsigned int D.22842;
  unsigned int D.22843;
  unsigned char D.22846;
  struct MonoClass * D.22851;
  _Bool D.22852;
  long int D.22853;
  long int D.22854;
  struct MonoMethod * * D.22857;
  int D.22858;
  unsigned int D.22859;
  unsigned int D.22860;
  struct MonoMethod * * D.22861;
  struct MonoMethod * D.22862;
  struct MonoMethod * * D.22865;
  unsigned int i.89;
  unsigned int D.22867;
  struct MonoMethod * * D.22868;
  struct MonoMethod * D.22869;
  short int D.22870;
  unsigned int i.90;
  unsigned int D.22872;
  _Bool D.22873;
  long int D.22874;
  long int D.22875;
  int iftmp.91;
  _Bool D.22884;
  long int D.22885;
  long int D.22886;
  int D.22889;
  int D.22890;
  unsigned int D.22891;
  unsigned int D.22892;
  guint32 slot;
  struct MonoClass * ic;

  D.22841 = method->slot;
  slot = (guint32) D.22841;
  ic = method->klass;
  D.22842 = ic->flags;
  D.22843 = D.22842 & 32;
  if (D.22843 == 0) goto <D.22844>; else goto <D.22845>;
  <D.22844>:
  D.22846 = ic->byval_arg.type;
  if (D.22846 != 19) goto <D.22847>; else goto <D.22848>;
  <D.22847>:
  D.22846 = ic->byval_arg.type;
  if (D.22846 != 30) goto <D.22849>; else goto <D.22850>;
  <D.22849>:
  {
    int offset;
    int i;

    offset = 0;
    i = 0;
    ic = cominterop_get_method_interface (method);
    D.22851 = method->klass;
    offset = mono_class_interface_offset (D.22851, ic);
    D.22852 = offset < 0;
    D.22853 = (long int) D.22852;
    D.22854 = __builtin_expect (D.22853, 0);
    if (D.22854 != 0) goto <D.22855>; else goto <D.22856>;
    <D.22855>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 363, "offset >= 0");
    <D.22856>:
    i = 0;
    goto <D.21010>;
    <D.21009>:
    D.22851 = method->klass;
    D.22857 = D.22851->vtable;
    D.22858 = i + offset;
    D.22859 = (unsigned int) D.22858;
    D.22860 = D.22859 * 4;
    D.22861 = D.22857 + D.22860;
    D.22862 = *D.22861;
    if (D.22862 == method) goto <D.22863>; else goto <D.22864>;
    <D.22863>:
    D.22865 = ic->methods;
    i.89 = (unsigned int) i;
    D.22867 = i.89 * 4;
    D.22868 = D.22865 + D.22867;
    D.22869 = *D.22868;
    D.22870 = D.22869->slot;
    slot = (guint32) D.22870;
    goto <D.21008>;
    <D.22864>:
    i = i + 1;
    <D.21010>:
    i.90 = (unsigned int) i;
    D.22872 = ic->method.count;
    if (i.90 < D.22872) goto <D.21009>; else goto <D.21008>;
    <D.21008>:
  }
  <D.22850>:
  <D.22848>:
  <D.22845>:
  D.22873 = ic == 0B;
  D.22874 = (long int) D.22873;
  D.22875 = __builtin_expect (D.22874, 0);
  if (D.22875 != 0) goto <D.22876>; else goto <D.22877>;
  <D.22876>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 373, "ic");
  <D.22877>:
  D.22842 = ic->flags;
  D.22843 = D.22842 & 32;
  if (D.22843 == 0) goto <D.22881>; else goto <D.22879>;
  <D.22881>:
  D.22846 = ic->byval_arg.type;
  if (D.22846 != 19) goto <D.22882>; else goto <D.22879>;
  <D.22882>:
  D.22846 = ic->byval_arg.type;
  if (D.22846 != 30) goto <D.22883>; else goto <D.22879>;
  <D.22883>:
  iftmp.91 = 1;
  goto <D.22880>;
  <D.22879>:
  iftmp.91 = 0;
  <D.22880>:
  D.22884 = iftmp.91 != 0;
  D.22885 = (long int) D.22884;
  D.22886 = __builtin_expect (D.22885, 0);
  if (D.22886 != 0) goto <D.22887>; else goto <D.22888>;
  <D.22887>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 374, "MONO_CLASS_IS_INTERFACE (ic)");
  <D.22888>:
  D.22890 = cominterop_get_com_slot_begin (ic);
  D.22891 = (unsigned int) D.22890;
  D.22892 = D.22891 + slot;
  D.22889 = (int) D.22892;
  return D.22889;
}


mono_cominterop_emit_ptr_to_object_conv (struct MonoMethodBuilder * mb, struct MonoType * type, MonoMarshalConv conv, struct MonoMarshalSpec * mspec)
{
  struct MonoClass * com_interop_proxy_class.92;
  struct MonoImage * D.22897;
  struct MonoClass * com_interop_proxy_class.93;
  struct MonoMethod * com_interop_proxy_get_proxy.94;
  struct MonoMethod * com_interop_proxy_get_proxy.95;
  struct MonoMethod * get_transparent_proxy.96;
  struct MonoClass * D.22906;
  struct MonoMethod * get_transparent_proxy.97;
  struct MonoType * D.22908;
  struct MonoClass * D.22909;
  struct MonoType * D.22910;
  _Bool D.22913;
  long int D.22914;
  long int D.22915;

  switch (conv) <default: <D.21102>, case 25: <D.21090>, case 26: <D.21092>, case 27: <D.21091>>
  <D.21090>:
  <D.21091>:
  <D.21092>:
  {
    static struct MonoClass * com_interop_proxy_class = 0B;
    static struct MonoMethod * com_interop_proxy_get_proxy = 0B;
    static struct MonoMethod * get_transparent_proxy = 0B;
    int real_proxy;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;
    struct MonoClass * klass;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    klass = 0B;
    klass = mono_class_from_mono_type (type);
    mono_mb_emit_ldloc (mb, 1);
    mono_mb_emit_byte (mb, 20);
    mono_mb_emit_byte (mb, 81);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 77);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    mono_mb_emit_ldloc (mb, 1);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 77);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_ccw_object);
    pos_ccw = mono_mb_emit_short_branch (mb, 45);
    com_interop_proxy_class.92 = com_interop_proxy_class;
    if (com_interop_proxy_class.92 == 0B) goto <D.22895>; else goto <D.22896>;
    <D.22895>:
    D.22897 = mono_defaults.corlib;
    com_interop_proxy_class.93 = mono_class_from_name (D.22897, "Mono.Interop", "ComInteropProxy");
    com_interop_proxy_class = com_interop_proxy_class.93;
    <D.22896>:
    com_interop_proxy_get_proxy.94 = com_interop_proxy_get_proxy;
    if (com_interop_proxy_get_proxy.94 == 0B) goto <D.22900>; else goto <D.22901>;
    <D.22900>:
    com_interop_proxy_class.92 = com_interop_proxy_class;
    com_interop_proxy_get_proxy.95 = mono_class_get_method_from_name_flags (com_interop_proxy_class.92, "GetProxy", 2, 1);
    com_interop_proxy_get_proxy = com_interop_proxy_get_proxy.95;
    <D.22901>:
    get_transparent_proxy.96 = get_transparent_proxy;
    if (get_transparent_proxy.96 == 0B) goto <D.22904>; else goto <D.22905>;
    <D.22904>:
    D.22906 = mono_defaults.real_proxy_class;
    get_transparent_proxy.97 = mono_class_get_method_from_name (D.22906, "GetTransparentProxy", 0);
    get_transparent_proxy = get_transparent_proxy.97;
    <D.22905>:
    com_interop_proxy_class.92 = com_interop_proxy_class;
    D.22908 = &com_interop_proxy_class.92->byval_arg;
    real_proxy = mono_mb_add_local (mb, D.22908);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 77);
    D.22909 = mono_class_get_com_object_class ();
    D.22910 = &D.22909->byval_arg;
    mono_mb_emit_ptr (mb, D.22910);
    mono_mb_emit_icall (mb, cominterop_type_from_handle);
    com_interop_proxy_get_proxy.94 = com_interop_proxy_get_proxy;
    mono_mb_emit_managed_call (mb, com_interop_proxy_get_proxy.94, 0B);
    get_transparent_proxy.96 = get_transparent_proxy;
    mono_mb_emit_managed_call (mb, get_transparent_proxy.96, 0B);
    if (conv == 25) goto <D.22911>; else goto <D.22912>;
    <D.22911>:
    D.22913 = klass == 0B;
    D.22914 = (long int) D.22913;
    D.22915 = __builtin_expect (D.22914, 0);
    if (D.22915 != 0) goto <D.22916>; else goto <D.22917>;
    <D.22916>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 631, "klass");
    <D.22917>:
    mono_mb_emit_op (mb, 116, klass);
    <D.22912>:
    mono_mb_emit_byte (mb, 81);
    pos_end = mono_mb_emit_short_branch (mb, 43);
    mono_mb_patch_short_branch (mb, pos_ccw);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 77);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_ccw_object);
    if (conv == 25) goto <D.22918>; else goto <D.22919>;
    <D.22918>:
    D.22913 = klass == 0B;
    D.22914 = (long int) D.22913;
    D.22915 = __builtin_expect (D.22914, 0);
    if (D.22915 != 0) goto <D.22920>; else goto <D.22921>;
    <D.22920>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 645, "klass");
    <D.22921>:
    mono_mb_emit_op (mb, 116, klass);
    <D.22919>:
    mono_mb_emit_byte (mb, 81);
    mono_mb_patch_short_branch (mb, pos_end);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.21101>;
  }
  <D.21102>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 656);
  <D.21101>:
}


mono_cominterop_emit_object_to_ptr_conv (struct MonoMethodBuilder * mb, struct MonoType * type, MonoMarshalConv conv, struct MonoMarshalSpec * mspec)
{
  struct MonoClass * D.22924;
  struct MonoProperty * iunknown.98;
  struct MonoClass * D.22931;
  struct MonoProperty * iunknown.99;
  struct MonoMethod * D.22933;
  struct MonoProperty * idispatch.100;
  struct MonoClass * D.22940;
  struct MonoProperty * idispatch.101;
  struct MonoMethod * D.22942;
  struct MonoClass * D.22946;
  struct MonoClass * D.22950;
  struct MonoClass * D.22954;

  switch (conv) <default: <D.21118>, case 25: <D.21109>, case 26: <D.21110>, case 27: <D.21111>>
  <D.21109>:
  <D.21110>:
  <D.21111>:
  {
    guint32 pos_null;
    guint32 pos_rcw;
    guint32 pos_end;

    pos_null = 0;
    pos_rcw = 0;
    pos_end = 0;
    mono_mb_emit_ldloc (mb, 1);
    mono_mb_emit_icon (mb, 0);
    mono_mb_emit_byte (mb, 224);
    mono_mb_emit_byte (mb, 223);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 80);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 80);
    mono_mb_emit_icall (mb, cominterop_object_is_rcw);
    pos_rcw = mono_mb_emit_short_branch (mb, 44);
    mono_mb_emit_ldloc (mb, 1);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 80);
    mono_mb_emit_ldflda (mb, 8);
    mono_mb_emit_byte (mb, 80);
    mono_mb_emit_ldflda (mb, 40);
    mono_mb_emit_byte (mb, 80);
    if (conv == 25) goto <D.22922>; else goto <D.22923>;
    <D.22922>:
    D.22924 = mono_type_get_class (type);
    mono_mb_emit_ptr (mb, D.22924);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_interface);
    goto <D.22925>;
    <D.22923>:
    if (conv == 27) goto <D.22926>; else goto <D.22927>;
    <D.22926>:
    {
      static struct MonoProperty * iunknown = 0B;

      iunknown.98 = iunknown;
      if (iunknown.98 == 0B) goto <D.22929>; else goto <D.22930>;
      <D.22929>:
      D.22931 = mono_class_get_com_object_class ();
      iunknown.99 = mono_class_get_property_from_name (D.22931, "IUnknown");
      iunknown = iunknown.99;
      <D.22930>:
      iunknown.98 = iunknown;
      D.22933 = iunknown.98->get;
      mono_mb_emit_managed_call (mb, D.22933, 0B);
    }
    goto <D.22934>;
    <D.22927>:
    if (conv == 26) goto <D.22935>; else goto <D.22936>;
    <D.22935>:
    {
      static struct MonoProperty * idispatch = 0B;

      idispatch.100 = idispatch;
      if (idispatch.100 == 0B) goto <D.22938>; else goto <D.22939>;
      <D.22938>:
      D.22940 = mono_class_get_com_object_class ();
      idispatch.101 = mono_class_get_property_from_name (D.22940, "IDispatch");
      idispatch = idispatch.101;
      <D.22939>:
      idispatch.100 = idispatch;
      D.22942 = idispatch.100->get;
      mono_mb_emit_managed_call (mb, D.22942, 0B);
    }
    goto <D.22943>;
    <D.22936>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 719);
    <D.22943>:
    <D.22934>:
    <D.22925>:
    mono_mb_emit_byte (mb, 223);
    pos_end = mono_mb_emit_short_branch (mb, 43);
    mono_mb_patch_short_branch (mb, pos_rcw);
    mono_mb_emit_ldloc (mb, 1);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 80);
    if (conv == 25) goto <D.22944>; else goto <D.22945>;
    <D.22944>:
    D.22946 = mono_type_get_class (type);
    mono_mb_emit_ptr (mb, D.22946);
    goto <D.22947>;
    <D.22945>:
    if (conv == 27) goto <D.22948>; else goto <D.22949>;
    <D.22948>:
    D.22950 = mono_class_get_iunknown_class ();
    mono_mb_emit_ptr (mb, D.22950);
    goto <D.22951>;
    <D.22949>:
    if (conv == 26) goto <D.22952>; else goto <D.22953>;
    <D.22952>:
    D.22954 = mono_class_get_idispatch_class ();
    mono_mb_emit_ptr (mb, D.22954);
    goto <D.22955>;
    <D.22953>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 739);
    <D.22955>:
    <D.22951>:
    <D.22947>:
    mono_mb_emit_icall (mb, cominterop_get_ccw);
    mono_mb_emit_byte (mb, 223);
    mono_mb_patch_short_branch (mb, pos_end);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.21117>;
  }
  <D.21118>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 748);
  <D.21117>:
}


mono_cominterop_get_native_wrapper (struct MonoMethod * method)
{
  _Bool D.22956;
  long int D.22957;
  long int D.22958;
  struct MonoClass * D.22961;
  struct MonoImage * D.22962;
  struct GHashTable * * D.22963;
  struct MonoMethod * D.22966;
  struct MonoMethod * * D.22967;
  struct MonoMethod * * D.22970;
  unsigned char D.22973;
  _Bool D.22974;
  long int D.22975;
  long int D.22976;
  const char * D.22979;
  unsigned int D.22980;
  unsigned int D.22981;
  int D.21155;
  int iftmp.102;
  int D.21154;
  const char[6] * D.22987;
  unsigned char D.22988;
  int D.22989;
  unsigned char D.22990;
  int D.22991;
  _Bool D.22992;
  _Bool D.22993;
  _Bool D.22994;
  const unsigned char * D.22997;
  unsigned char D.22998;
  int D.22999;
  const unsigned char * D.23000;
  unsigned char D.23001;
  int D.23002;
  _Bool D.23003;
  _Bool D.23004;
  const unsigned char * D.23007;
  unsigned char D.23008;
  int D.23009;
  const unsigned char * D.23010;
  unsigned char D.23011;
  int D.23012;
  _Bool D.23013;
  _Bool D.23014;
  const unsigned char * D.23017;
  unsigned char D.23018;
  int D.23019;
  const unsigned char * D.23020;
  unsigned char D.23021;
  int D.23022;
  struct MonoMethod * ctor.103;
  struct MonoClass * D.23029;
  struct MonoMethod * ctor.104;
  short unsigned int D.23032;
  int D.23033;
  struct MonoClass * D.23034;
  struct MonoType * D.23035;
  struct MonoType * D.23036;
  int D.23037;
  unsigned int ptr_this.105;
  unsigned int i.106;
  short unsigned int D.23042;
  int D.23043;
  int D.23044;
  unsigned int retval.107;
  struct MonoMethod * ThrowExceptionForHR.108;
  struct MonoClass * D.23055;
  struct MonoMethod * ThrowExceptionForHR.109;
  int D.23057;
  short unsigned int D.23061;
  int D.23062;
  int D.23063;
  struct MonoMethod * res;
  struct GHashTable * cache;
  struct MonoMethodBuilder * mb;
  struct MonoMethodSignature * sig;
  struct MonoMethodSignature * csig;

  D.22956 = method == 0B;
  D.22957 = (long int) D.22956;
  D.22958 = __builtin_expect (D.22957, 0);
  if (D.22958 != 0) goto <D.22959>; else goto <D.22960>;
  <D.22959>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 869, "method");
  <D.22960>:
  D.22961 = method->klass;
  D.22962 = D.22961->image;
  D.22963 = &D.22962->cominterop_wrapper_cache;
  cache = mono_marshal_get_cache (D.22963, mono_aligned_addr_hash, 0B);
  res = mono_marshal_find_in_cache (cache, method);
  if (res != 0B) goto <D.22964>; else goto <D.22965>;
  <D.22964>:
  D.22966 = res;
  return D.22966;
  <D.22965>:
  D.22961 = method->klass;
  D.22967 = D.22961->vtable;
  if (D.22967 == 0B) goto <D.22968>; else goto <D.22969>;
  <D.22968>:
  D.22961 = method->klass;
  mono_class_setup_vtable (D.22961);
  <D.22969>:
  D.22961 = method->klass;
  D.22970 = D.22961->methods;
  if (D.22970 == 0B) goto <D.22971>; else goto <D.22972>;
  <D.22971>:
  D.22961 = method->klass;
  mono_class_setup_methods (D.22961);
  <D.22972>:
  D.22961 = method->klass;
  D.22973 = D.22961->exception_type;
  D.22974 = D.22973 != 0;
  D.22975 = (long int) D.22974;
  D.22976 = __builtin_expect (D.22975, 0);
  if (D.22976 != 0) goto <D.22977>; else goto <D.22978>;
  <D.22977>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 880, "!method->klass->exception_type");
  <D.22978>:
  sig = mono_method_signature (method);
  D.22961 = method->klass;
  D.22979 = method->name;
  mb = mono_mb_new (D.22961, D.22979, 27);
  D.22961 = method->klass;
  D.22980 = D.22961->flags;
  D.22981 = D.22980 & 4096;
  if (D.22981 != 0) goto <D.22982>; else goto <D.22983>;
  <D.22982>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 5;
    if (__s2_len <= 3) goto <D.22985>; else goto <D.22986>;
    <D.22985>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = method->name;
      D.22987 = ".ctor";
      D.22988 = MEM[(const unsigned char *)D.22987];
      D.22989 = (int) D.22988;
      D.22990 = *__s2;
      D.22991 = (int) D.22990;
      __result = D.22989 - D.22991;
      {
        D.22992 = __s2_len != 0;
        D.22993 = __result == 0;
        D.22994 = D.22992 & D.22993;
        if (D.22994 != 0) goto <D.22995>; else goto <D.22996>;
        <D.22995>:
        D.22997 = &MEM[(void *)".ctor" + 1B];
        D.22998 = *D.22997;
        D.22999 = (int) D.22998;
        D.23000 = __s2 + 1;
        D.23001 = *D.23000;
        D.23002 = (int) D.23001;
        __result = D.22999 - D.23002;
        D.23003 = __s2_len > 1;
        D.22993 = __result == 0;
        D.23004 = D.23003 & D.22993;
        if (D.23004 != 0) goto <D.23005>; else goto <D.23006>;
        <D.23005>:
        D.23007 = &MEM[(void *)".ctor" + 2B];
        D.23008 = *D.23007;
        D.23009 = (int) D.23008;
        D.23010 = __s2 + 2;
        D.23011 = *D.23010;
        D.23012 = (int) D.23011;
        __result = D.23009 - D.23012;
        D.23013 = __s2_len > 2;
        D.22993 = __result == 0;
        D.23014 = D.23013 & D.22993;
        if (D.23014 != 0) goto <D.23015>; else goto <D.23016>;
        <D.23015>:
        D.23017 = &MEM[(void *)".ctor" + 3B];
        D.23018 = *D.23017;
        D.23019 = (int) D.23018;
        D.23020 = __s2 + 3;
        D.23021 = *D.23020;
        D.23022 = (int) D.23021;
        __result = D.23019 - D.23022;
        <D.23016>:
        <D.23006>:
        <D.22996>:
      }
      D.21154 = __result;
    }
    iftmp.102 = -D.21154;
    goto <D.23023>;
    <D.22986>:
    D.22979 = method->name;
    iftmp.102 = __builtin_strcmp (D.22979, ".ctor");
    <D.23023>:
    D.21155 = iftmp.102;
  }
  if (D.21155 == 0) goto <D.23024>; else goto <D.23025>;
  <D.23024>:
  {
    static struct MonoMethod * ctor = 0B;

    ctor.103 = ctor;
    if (ctor.103 == 0B) goto <D.23027>; else goto <D.23028>;
    <D.23027>:
    D.23029 = mono_class_get_com_object_class ();
    ctor.104 = mono_class_get_method_from_name (D.23029, ".ctor", 0);
    ctor = ctor.104;
    <D.23028>:
    mono_mb_emit_ldarg (mb, 0);
    ctor.103 = ctor;
    mono_mb_emit_managed_call (mb, ctor.103, 0B);
    mono_mb_emit_byte (mb, 42);
  }
  goto <D.23031>;
  <D.23025>:
  {
    static struct MonoMethod * ThrowExceptionForHR = 0B;
    struct MonoMethod * adjusted_method;
    int retval;
    int ptr_this;
    int i;
    gboolean preserve_sig;

    retval = 0;
    D.23032 = method->iflags;
    D.23033 = (int) D.23032;
    preserve_sig = D.23033 & 128;
    D.23034 = mono_defaults.int_class;
    D.23035 = &D.23034->byval_arg;
    ptr_this = mono_mb_add_local (mb, D.23035);
    D.23036 = sig->ret;
    D.23037 = mono_type_is_void (D.23036);
    if (D.23037 == 0) goto <D.23038>; else goto <D.23039>;
    <D.23038>:
    D.23036 = sig->ret;
    retval = mono_mb_add_local (mb, D.23036);
    <D.23039>:
    mono_mb_emit_ldarg (mb, 0);
    mono_mb_emit_ptr (mb, method);
    mono_mb_emit_icall (mb, cominterop_get_method_interface);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_interface);
    ptr_this.105 = (unsigned int) ptr_this;
    mono_mb_emit_stloc (mb, ptr_this.105);
    ptr_this.105 = (unsigned int) ptr_this;
    mono_mb_emit_ldloc (mb, ptr_this.105);
    i = 1;
    goto <D.21164>;
    <D.21163>:
    i.106 = (unsigned int) i;
    mono_mb_emit_ldarg (mb, i.106);
    i = i + 1;
    <D.21164>:
    D.23042 = sig->param_count;
    D.23043 = (int) D.23042;
    if (D.23043 >= i) goto <D.21163>; else goto <D.21165>;
    <D.21165>:
    D.23036 = sig->ret;
    D.23044 = mono_type_is_void (D.23036);
    if (D.23044 == 0) goto <D.23045>; else goto <D.23046>;
    <D.23045>:
    if (preserve_sig == 0) goto <D.23047>; else goto <D.23048>;
    <D.23047>:
    retval.107 = (unsigned int) retval;
    mono_mb_emit_ldloc_addr (mb, retval.107);
    <D.23048>:
    <D.23046>:
    adjusted_method = cominterop_get_native_wrapper_adjusted (method);
    mono_mb_emit_managed_call (mb, adjusted_method, 0B);
    if (preserve_sig == 0) goto <D.23050>; else goto <D.23051>;
    <D.23050>:
    ThrowExceptionForHR.108 = ThrowExceptionForHR;
    if (ThrowExceptionForHR.108 == 0B) goto <D.23053>; else goto <D.23054>;
    <D.23053>:
    D.23055 = mono_defaults.marshal_class;
    ThrowExceptionForHR.109 = mono_class_get_method_from_name (D.23055, "ThrowExceptionForHR", 1);
    ThrowExceptionForHR = ThrowExceptionForHR.109;
    <D.23054>:
    ThrowExceptionForHR.108 = ThrowExceptionForHR;
    mono_mb_emit_managed_call (mb, ThrowExceptionForHR.108, 0B);
    D.23036 = sig->ret;
    D.23057 = mono_type_is_void (D.23036);
    if (D.23057 == 0) goto <D.23058>; else goto <D.23059>;
    <D.23058>:
    retval.107 = (unsigned int) retval;
    mono_mb_emit_ldloc (mb, retval.107);
    <D.23059>:
    <D.23051>:
    mono_mb_emit_byte (mb, 42);
  }
  <D.23031>:
  goto <D.23060>;
  <D.22983>:
  {
    char * msg;

    msg = monoeg_strdup ("non imported interfaces on \t\t\timported classes is not yet implemented.");
    mono_mb_emit_exception (mb, "NotSupportedException", msg);
  }
  <D.23060>:
  D.22961 = method->klass;
  D.22962 = D.22961->image;
  csig = mono_metadata_signature_dup_full (D.22962, sig);
  csig->pinvoke = 0;
  D.23061 = csig->param_count;
  D.23062 = (int) D.23061;
  D.23063 = D.23062 + 16;
  res = mono_mb_create_and_cache (cache, method, mb, csig, D.23063);
  mono_mb_free (mb);
  D.22966 = res;
  return D.22966;
}


cominterop_get_native_wrapper_adjusted (struct MonoMethod * method)
{
  struct MonoClass * D.23065;
  const char * D.23066;
  short unsigned int D.23067;
  int D.23068;
  int D.23069;
  unsigned int D.23070;
  unsigned int D.23071;
  short unsigned int D.23072;
  sizetype i.110;
  sizetype D.23074;
  sizetype D.23075;
  struct MonoMarshalSpec * * D.23076;
  unsigned int i.111;
  unsigned int D.23078;
  struct MonoMarshalSpec * * D.23079;
  struct MonoMarshalSpec * D.23080;
  struct MonoMarshalSpec * * D.23081;
  short unsigned int D.23082;
  int D.23083;
  int D.23084;
  struct MonoType * D.23087;
  int D.23088;
  unsigned int D.23091;
  unsigned int D.23092;
  struct MonoMarshalSpec * * D.23093;
  struct MonoMarshalSpec * D.23094;
  unsigned int mspec_index.112;
  unsigned int D.23096;
  struct MonoMarshalSpec * * D.23097;
  struct MonoMarshalSpec * D.23098;
  struct MonoType * D.23101;
  unsigned char D.23102;
  void * D.23105;
  void * D.23109;
  void * D.23113;
  void * D.23117;
  int D.23120;
  unsigned char D.23125;
  void * D.23128;
  void * D.23132;
  void * D.23136;
  void * D.23140;
  struct MonoImage * D.23141;
  void * D.23142;
  int D.23143;
  struct MonoMethod * D.23146;
  struct MonoMethod * res;
  struct MonoMethodBuilder * mb_native;
  struct MonoMarshalSpec * * mspecs;
  struct MonoMethodSignature * sig;
  struct MonoMethodSignature * sig_native;
  struct MonoMethodPInvoke * piinfo;
  int i;

  piinfo = method;
  sig = mono_method_signature (method);
  D.23065 = method->klass;
  D.23066 = method->name;
  mb_native = mono_mb_new (D.23065, D.23066, 6);
  sig_native = cominterop_method_signature (method);
  D.23067 = sig_native->param_count;
  D.23068 = (int) D.23067;
  D.23069 = D.23068 + 1;
  D.23070 = (unsigned int) D.23069;
  D.23071 = D.23070 * 4;
  mspecs = monoeg_malloc (D.23071);
  D.23067 = sig_native->param_count;
  D.23068 = (int) D.23067;
  D.23069 = D.23068 + 1;
  D.23070 = (unsigned int) D.23069;
  D.23071 = D.23070 * 4;
  memset (mspecs, 0, D.23071);
  mono_method_get_marshal_info (method, mspecs);
  D.23072 = sig->param_count;
  i = (int) D.23072;
  goto <D.21130>;
  <D.21129>:
  i.110 = (sizetype) i;
  D.23074 = i.110 + 1;
  D.23075 = D.23074 * 4;
  D.23076 = mspecs + D.23075;
  i.111 = (unsigned int) i;
  D.23078 = i.111 * 4;
  D.23079 = mspecs + D.23078;
  D.23080 = *D.23079;
  *D.23076 = D.23080;
  i = i + -1;
  <D.21130>:
  if (i > 0) goto <D.21129>; else goto <D.21131>;
  <D.21131>:
  D.23081 = mspecs + 4;
  *D.23081 = 0B;
  D.23082 = method->iflags;
  D.23083 = (int) D.23082;
  D.23084 = D.23083 & 128;
  if (D.23084 == 0) goto <D.23085>; else goto <D.23086>;
  <D.23085>:
  D.23087 = sig->ret;
  D.23088 = mono_type_is_void (D.23087);
  if (D.23088 == 0) goto <D.23089>; else goto <D.23090>;
  <D.23089>:
  D.23067 = sig_native->param_count;
  D.23091 = (unsigned int) D.23067;
  D.23092 = D.23091 * 4;
  D.23093 = mspecs + D.23092;
  D.23094 = *mspecs;
  *D.23093 = D.23094;
  <D.23090>:
  *mspecs = 0B;
  <D.23086>:
  i = 1;
  goto <D.21134>;
  <D.21133>:
  {
    int mspec_index;

    mspec_index = i + 1;
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23098 = *D.23097;
    if (D.23098 == 0B) goto <D.23099>; else goto <D.23100>;
    <D.23099>:
    D.23101 = sig_native->params[i];
    D.23102 = D.23101->type;
    if (D.23102 == 28) goto <D.23103>; else goto <D.23104>;
    <D.23103>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23105 = monoeg_malloc0 (16);
    *D.23097 = D.23105;
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23098 = *D.23097;
    D.23098->native = 27;
    goto <D.23106>;
    <D.23104>:
    D.23101 = sig_native->params[i];
    D.23102 = D.23101->type;
    if (D.23102 == 14) goto <D.23107>; else goto <D.23108>;
    <D.23107>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23109 = monoeg_malloc0 (16);
    *D.23097 = D.23109;
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23098 = *D.23097;
    D.23098->native = 19;
    goto <D.23110>;
    <D.23108>:
    D.23101 = sig_native->params[i];
    D.23102 = D.23101->type;
    if (D.23102 == 18) goto <D.23111>; else goto <D.23112>;
    <D.23111>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23113 = monoeg_malloc0 (16);
    *D.23097 = D.23113;
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23098 = *D.23097;
    D.23098->native = 28;
    goto <D.23114>;
    <D.23112>:
    D.23101 = sig_native->params[i];
    D.23102 = D.23101->type;
    if (D.23102 == 2) goto <D.23115>; else goto <D.23116>;
    <D.23115>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23117 = monoeg_malloc0 (16);
    *D.23097 = D.23117;
    mspec_index.112 = (unsigned int) mspec_index;
    D.23096 = mspec_index.112 * 4;
    D.23097 = mspecs + D.23096;
    D.23098 = *D.23097;
    D.23098->native = 37;
    <D.23116>:
    <D.23114>:
    <D.23110>:
    <D.23106>:
    <D.23100>:
  }
  i = i + 1;
  <D.21134>:
  D.23067 = sig_native->param_count;
  D.23068 = (int) D.23067;
  if (D.23068 > i) goto <D.21133>; else goto <D.21135>;
  <D.21135>:
  D.23082 = method->iflags;
  D.23083 = (int) D.23082;
  D.23084 = D.23083 & 128;
  if (D.23084 != 0) goto <D.23118>; else goto <D.23119>;
  <D.23118>:
  D.23087 = sig->ret;
  D.23120 = mono_type_is_void (D.23087);
  if (D.23120 == 0) goto <D.23121>; else goto <D.23122>;
  <D.23121>:
  D.23094 = *mspecs;
  if (D.23094 == 0B) goto <D.23123>; else goto <D.23124>;
  <D.23123>:
  D.23087 = sig->ret;
  D.23125 = D.23087->type;
  if (D.23125 == 28) goto <D.23126>; else goto <D.23127>;
  <D.23126>:
  D.23128 = monoeg_malloc0 (16);
  *mspecs = D.23128;
  D.23094 = *mspecs;
  D.23094->native = 27;
  goto <D.23129>;
  <D.23127>:
  D.23087 = sig->ret;
  D.23125 = D.23087->type;
  if (D.23125 == 14) goto <D.23130>; else goto <D.23131>;
  <D.23130>:
  D.23132 = monoeg_malloc0 (16);
  *mspecs = D.23132;
  D.23094 = *mspecs;
  D.23094->native = 19;
  goto <D.23133>;
  <D.23131>:
  D.23087 = sig->ret;
  D.23125 = D.23087->type;
  if (D.23125 == 18) goto <D.23134>; else goto <D.23135>;
  <D.23134>:
  D.23136 = monoeg_malloc0 (16);
  *mspecs = D.23136;
  D.23094 = *mspecs;
  D.23094->native = 28;
  goto <D.23137>;
  <D.23135>:
  D.23087 = sig->ret;
  D.23125 = D.23087->type;
  if (D.23125 == 2) goto <D.23138>; else goto <D.23139>;
  <D.23138>:
  D.23140 = monoeg_malloc0 (16);
  *mspecs = D.23140;
  D.23094 = *mspecs;
  D.23094->native = 37;
  <D.23139>:
  <D.23137>:
  <D.23133>:
  <D.23129>:
  <D.23124>:
  <D.23122>:
  <D.23119>:
  D.23065 = method->klass;
  D.23141 = D.23065->image;
  D.23142 = piinfo->addr;
  mono_marshal_emit_native_wrapper (D.23141, mb_native, sig_native, piinfo, mspecs, D.23142, 0, 1, 0);
  D.23067 = sig_native->param_count;
  D.23068 = (int) D.23067;
  D.23143 = D.23068 + 16;
  res = mono_mb_create_method (mb_native, sig_native, D.23143);
  mono_mb_free (mb_native);
  D.23067 = sig_native->param_count;
  i = (int) D.23067;
  goto <D.21137>;
  <D.21136>:
  i.111 = (unsigned int) i;
  D.23078 = i.111 * 4;
  D.23079 = mspecs + D.23078;
  D.23080 = *D.23079;
  if (D.23080 != 0B) goto <D.23144>; else goto <D.23145>;
  <D.23144>:
  i.111 = (unsigned int) i;
  D.23078 = i.111 * 4;
  D.23079 = mspecs + D.23078;
  D.23080 = *D.23079;
  mono_metadata_free_marshal_spec (D.23080);
  <D.23145>:
  i = i + -1;
  <D.21137>:
  if (i >= 0) goto <D.21136>; else goto <D.21138>;
  <D.21138>:
  monoeg_g_free (mspecs);
  D.23146 = res;
  return D.23146;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.23150;
  int D.23155;
  void * D.23157;
  unsigned int D.23158;

  D.23150 = __builtin_constant_p (__len);
  if (D.23150 != 0) goto <D.23151>; else goto <D.23152>;
  <D.23151>:
  if (__len == 0) goto <D.23153>; else goto <D.23154>;
  <D.23153>:
  D.23155 = __builtin_constant_p (__ch);
  if (D.23155 == 0) goto <D.23148>; else goto <D.23156>;
  <D.23156>:
  if (__ch != 0) goto <D.23148>; else goto <D.23149>;
  <D.23148>:
  __warn_memset_zero_len ();
  D.23157 = __dest;
  return D.23157;
  <D.23149>:
  <D.23154>:
  <D.23152>:
  D.23158 = __builtin_object_size (__dest, 0);
  D.23157 = __builtin___memset_chk (__dest, __ch, __len, D.23158);
  return D.23157;
}


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

  if (str != 0B) goto <D.23160>; else goto <D.23161>;
  <D.23160>:
  D.23162 = __strdup (str);
  return D.23162;
  <D.23161>:
  D.23162 = 0B;
  return D.23162;
}


mono_cominterop_get_invoke (struct MonoMethod * method)
{
  struct MonoClass * D.23164;
  struct MonoImage * D.23165;
  struct GHashTable * * D.23166;
  _Bool D.23167;
  long int D.23168;
  long int D.23169;
  struct MonoMethod * D.23174;
  unsigned char D.23175;
  unsigned char D.23176;
  const char * D.23179;
  struct MonoClass * D.23180;
  struct MonoType * D.23181;
  unsigned int i.113;
  short unsigned int D.23183;
  int D.23184;
  short unsigned int D.23185;
  int D.23186;
  int D.23187;
  short unsigned int D.23191;
  int D.23192;
  int D.23193;
  int D.21188;
  int iftmp.114;
  int D.21187;
  const char[6] * D.23200;
  unsigned char D.23201;
  int D.23202;
  unsigned char D.23203;
  int D.23204;
  _Bool D.23205;
  _Bool D.23206;
  _Bool D.23207;
  const unsigned char * D.23210;
  unsigned char D.23211;
  int D.23212;
  const unsigned char * D.23213;
  unsigned char D.23214;
  int D.23215;
  _Bool D.23216;
  _Bool D.23217;
  const unsigned char * D.23220;
  unsigned char D.23221;
  int D.23222;
  const unsigned char * D.23223;
  unsigned char D.23224;
  int D.23225;
  _Bool D.23226;
  _Bool D.23227;
  const unsigned char * D.23230;
  unsigned char D.23231;
  int D.23232;
  const unsigned char * D.23233;
  unsigned char D.23234;
  int D.23235;
  struct MonoClass * com_interop_proxy_class.115;
  struct MonoImage * D.23242;
  struct MonoClass * com_interop_proxy_class.116;
  struct MonoMethod * cache_proxy.117;
  struct MonoMethod * cache_proxy.118;
  int D.23248;
  struct MonoMethodSignature * sig;
  struct MonoMethodBuilder * mb;
  struct MonoMethod * res;
  int i;
  int temp_obj;
  struct GHashTable * cache;

  D.23164 = method->klass;
  D.23165 = D.23164->image;
  D.23166 = &D.23165->cominterop_invoke_cache;
  cache = mono_marshal_get_cache (D.23166, mono_aligned_addr_hash, 0B);
  D.23167 = method == 0B;
  D.23168 = (long int) D.23167;
  D.23169 = __builtin_expect (D.23168, 0);
  if (D.23169 != 0) goto <D.23170>; else goto <D.23171>;
  <D.23170>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 982, "method");
  <D.23171>:
  res = mono_marshal_find_in_cache (cache, method);
  if (res != 0B) goto <D.23172>; else goto <D.23173>;
  <D.23172>:
  D.23174 = res;
  return D.23174;
  <D.23173>:
  sig = mono_signature_no_pinvoke (method);
  D.23175 = BIT_FIELD_REF <*sig, 8, 80>;
  D.23176 = D.23175 & 64;
  if (D.23176 == 0) goto <D.23177>; else goto <D.23178>;
  <D.23177>:
  D.23174 = method;
  return D.23174;
  <D.23178>:
  D.23164 = method->klass;
  D.23179 = method->name;
  mb = mono_mb_new (D.23164, D.23179, 26);
  D.23180 = mono_defaults.object_class;
  D.23181 = &D.23180->byval_arg;
  temp_obj = mono_mb_add_local (mb, D.23181);
  mono_mb_emit_ldarg (mb, 0);
  mono_mb_emit_ldflda (mb, 8);
  mono_mb_emit_byte (mb, 80);
  mono_mb_emit_ldflda (mb, 40);
  mono_mb_emit_byte (mb, 80);
  i = 1;
  goto <D.21177>;
  <D.21176>:
  i.113 = (unsigned int) i;
  mono_mb_emit_ldarg (mb, i.113);
  i = i + 1;
  <D.21177>:
  D.23183 = sig->param_count;
  D.23184 = (int) D.23183;
  if (D.23184 >= i) goto <D.21176>; else goto <D.21178>;
  <D.21178>:
  D.23185 = method->iflags;
  D.23186 = (int) D.23185;
  D.23187 = D.23186 & 4096;
  if (D.23187 != 0) goto <D.23188>; else goto <D.23189>;
  <D.23188>:
  {
    struct MonoMethod * native_wrapper;

    native_wrapper = mono_cominterop_get_native_wrapper (method);
    mono_mb_emit_managed_call (mb, native_wrapper, 0B);
  }
  goto <D.23190>;
  <D.23189>:
  D.23191 = method->flags;
  D.23192 = (int) D.23191;
  D.23193 = D.23192 & 64;
  if (D.23193 != 0) goto <D.23194>; else goto <D.23195>;
  <D.23194>:
  mono_mb_emit_op (mb, 111, method);
  goto <D.23196>;
  <D.23195>:
  mono_mb_emit_op (mb, 40, method);
  <D.23196>:
  <D.23190>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 5;
    if (__s2_len <= 3) goto <D.23198>; else goto <D.23199>;
    <D.23198>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = method->name;
      D.23200 = ".ctor";
      D.23201 = MEM[(const unsigned char *)D.23200];
      D.23202 = (int) D.23201;
      D.23203 = *__s2;
      D.23204 = (int) D.23203;
      __result = D.23202 - D.23204;
      {
        D.23205 = __s2_len != 0;
        D.23206 = __result == 0;
        D.23207 = D.23205 & D.23206;
        if (D.23207 != 0) goto <D.23208>; else goto <D.23209>;
        <D.23208>:
        D.23210 = &MEM[(void *)".ctor" + 1B];
        D.23211 = *D.23210;
        D.23212 = (int) D.23211;
        D.23213 = __s2 + 1;
        D.23214 = *D.23213;
        D.23215 = (int) D.23214;
        __result = D.23212 - D.23215;
        D.23216 = __s2_len > 1;
        D.23206 = __result == 0;
        D.23217 = D.23216 & D.23206;
        if (D.23217 != 0) goto <D.23218>; else goto <D.23219>;
        <D.23218>:
        D.23220 = &MEM[(void *)".ctor" + 2B];
        D.23221 = *D.23220;
        D.23222 = (int) D.23221;
        D.23223 = __s2 + 2;
        D.23224 = *D.23223;
        D.23225 = (int) D.23224;
        __result = D.23222 - D.23225;
        D.23226 = __s2_len > 2;
        D.23206 = __result == 0;
        D.23227 = D.23226 & D.23206;
        if (D.23227 != 0) goto <D.23228>; else goto <D.23229>;
        <D.23228>:
        D.23230 = &MEM[(void *)".ctor" + 3B];
        D.23231 = *D.23230;
        D.23232 = (int) D.23231;
        D.23233 = __s2 + 3;
        D.23234 = *D.23233;
        D.23235 = (int) D.23234;
        __result = D.23232 - D.23235;
        <D.23229>:
        <D.23219>:
        <D.23209>:
      }
      D.21187 = __result;
    }
    iftmp.114 = -D.21187;
    goto <D.23236>;
    <D.23199>:
    D.23179 = method->name;
    iftmp.114 = __builtin_strcmp (D.23179, ".ctor");
    <D.23236>:
    D.21188 = iftmp.114;
  }
  if (D.21188 == 0) goto <D.23237>; else goto <D.23238>;
  <D.23237>:
  {
    static struct MonoClass * com_interop_proxy_class = 0B;
    static struct MonoMethod * cache_proxy = 0B;

    com_interop_proxy_class.115 = com_interop_proxy_class;
    if (com_interop_proxy_class.115 == 0B) goto <D.23240>; else goto <D.23241>;
    <D.23240>:
    D.23242 = mono_defaults.corlib;
    com_interop_proxy_class.116 = mono_class_from_name (D.23242, "Mono.Interop", "ComInteropProxy");
    com_interop_proxy_class = com_interop_proxy_class.116;
    <D.23241>:
    cache_proxy.117 = cache_proxy;
    if (cache_proxy.117 == 0B) goto <D.23245>; else goto <D.23246>;
    <D.23245>:
    com_interop_proxy_class.115 = com_interop_proxy_class;
    cache_proxy.118 = mono_class_get_method_from_name (com_interop_proxy_class.115, "CacheProxy", 0);
    cache_proxy = cache_proxy.118;
    <D.23246>:
    mono_mb_emit_ldarg (mb, 0);
    mono_mb_emit_ldflda (mb, 8);
    mono_mb_emit_byte (mb, 80);
    cache_proxy.117 = cache_proxy;
    mono_mb_emit_managed_call (mb, cache_proxy.117, 0B);
  }
  <D.23238>:
  mono_marshal_emit_thread_interrupt_checkpoint (mb);
  mono_mb_emit_byte (mb, 42);
  D.23183 = sig->param_count;
  D.23184 = (int) D.23183;
  D.23248 = D.23184 + 16;
  res = mono_mb_create_and_cache (cache, method, mb, sig, D.23248);
  mono_mb_free (mb);
  D.23174 = res;
  return D.23174;
}


mono_cominterop_emit_marshal_com_interface (struct EmitMarshalContext * m, int argnum, struct MonoType * t, struct MonoMarshalSpec * spec, int conv_arg, struct MonoType * * conv_arg_type, MarshalAction action)
{
  struct MonoMethod * get_object_for_iunknown.119;
  struct MonoClass * D.23253;
  struct MonoMethod * get_object_for_iunknown.120;
  struct MonoMethod * get_iunknown_for_object_internal.121;
  struct MonoMethod * get_iunknown_for_object_internal.122;
  struct MonoMethod * get_idispatch_for_object_internal.123;
  struct MonoMethod * get_idispatch_for_object_internal.124;
  struct MonoMethod * get_com_interface_for_object_internal.125;
  struct MonoMethod * get_com_interface_for_object_internal.126;
  struct MonoMethod * marshal_release.127;
  struct MonoMethod * marshal_release.128;
  struct MonoClass * D.23271;
  struct MonoType * D.23272;
  unsigned int conv_arg.129;
  unsigned char D.23274;
  unsigned char D.23275;
  short unsigned int D.23278;
  int D.23279;
  int D.23280;
  unsigned int argnum.130;
  struct MonoClass * D.23290;
  <unnamed type> D.23292;
  struct MonoType * D.23307;
  unsigned int ccw_obj.131;
  unsigned int ret_ptr.132;
  unsigned int ccw_obj.133;
  struct MonoType * D.23330;
  unsigned int ccw_obj.134;
  struct MonoMethod * AddRef.135;
  struct MonoMethod * AddRef.136;
  struct MonoMethod * AddRef.137;
  unsigned int ccw_obj.138;
  int D.23387;
  struct MonoMethodBuilder * mb;
  struct MonoClass * klass;
  static struct MonoMethod * get_object_for_iunknown = 0B;
  static struct MonoMethod * get_iunknown_for_object_internal = 0B;
  static struct MonoMethod * get_com_interface_for_object_internal = 0B;
  static struct MonoMethod * get_idispatch_for_object_internal = 0B;
  static struct MonoMethod * marshal_release = 0B;
  static struct MonoMethod * AddRef = 0B;

  mb = m->mb;
  klass = t->data.klass;
  get_object_for_iunknown.119 = get_object_for_iunknown;
  if (get_object_for_iunknown.119 == 0B) goto <D.23251>; else goto <D.23252>;
  <D.23251>:
  D.23253 = mono_defaults.marshal_class;
  get_object_for_iunknown.120 = mono_class_get_method_from_name (D.23253, "GetObjectForIUnknown", 1);
  get_object_for_iunknown = get_object_for_iunknown.120;
  <D.23252>:
  get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
  if (get_iunknown_for_object_internal.121 == 0B) goto <D.23256>; else goto <D.23257>;
  <D.23256>:
  D.23253 = mono_defaults.marshal_class;
  get_iunknown_for_object_internal.122 = mono_class_get_method_from_name (D.23253, "GetIUnknownForObjectInternal", 1);
  get_iunknown_for_object_internal = get_iunknown_for_object_internal.122;
  <D.23257>:
  get_idispatch_for_object_internal.123 = get_idispatch_for_object_internal;
  if (get_idispatch_for_object_internal.123 == 0B) goto <D.23260>; else goto <D.23261>;
  <D.23260>:
  D.23253 = mono_defaults.marshal_class;
  get_idispatch_for_object_internal.124 = mono_class_get_method_from_name (D.23253, "GetIDispatchForObjectInternal", 1);
  get_idispatch_for_object_internal = get_idispatch_for_object_internal.124;
  <D.23261>:
  get_com_interface_for_object_internal.125 = get_com_interface_for_object_internal;
  if (get_com_interface_for_object_internal.125 == 0B) goto <D.23264>; else goto <D.23265>;
  <D.23264>:
  D.23253 = mono_defaults.marshal_class;
  get_com_interface_for_object_internal.126 = mono_class_get_method_from_name (D.23253, "GetComInterfaceForObjectInternal", 2);
  get_com_interface_for_object_internal = get_com_interface_for_object_internal.126;
  <D.23265>:
  marshal_release.127 = marshal_release;
  if (marshal_release.127 == 0B) goto <D.23268>; else goto <D.23269>;
  <D.23268>:
  D.23253 = mono_defaults.marshal_class;
  marshal_release.128 = mono_class_get_method_from_name (D.23253, "Release", 1);
  marshal_release = marshal_release.128;
  <D.23269>:
  switch (action) <default: <D.21236>, case 0: <D.21211>, case 1: <D.21219>, case 2: <D.21214>, case 3: <D.21220>, case 4: <D.21226>, case 5: <D.21231>, case 6: <D.21233>>
  <D.21211>:
  {
    guint32 pos_null;

    pos_null = 0;
    D.23271 = mono_defaults.int_class;
    D.23272 = &D.23271->byval_arg;
    *conv_arg_type = D.23272;
    D.23271 = mono_defaults.int_class;
    D.23272 = &D.23271->byval_arg;
    conv_arg = mono_mb_add_local (mb, D.23272);
    mono_mb_emit_ptr (mb, 0B);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    D.23274 = BIT_FIELD_REF <*t, 8, 56>;
    D.23275 = D.23274 & 64;
    if (D.23275 != 0) goto <D.23276>; else goto <D.23277>;
    <D.23276>:
    D.23278 = t->attrs;
    D.23279 = (int) D.23278;
    D.23280 = D.23279 & 2;
    if (D.23280 != 0) goto <D.21213>; else goto <D.23281>;
    <D.23281>:
    <D.23277>:
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.23274 = BIT_FIELD_REF <*t, 8, 56>;
    D.23275 = D.23274 & 64;
    if (D.23275 != 0) goto <D.23283>; else goto <D.23284>;
    <D.23283>:
    mono_mb_emit_byte (mb, 80);
    <D.23284>:
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.23274 = BIT_FIELD_REF <*t, 8, 56>;
    D.23275 = D.23274 & 64;
    if (D.23275 != 0) goto <D.23285>; else goto <D.23286>;
    <D.23285>:
    mono_mb_emit_byte (mb, 80);
    <D.23286>:
    if (klass != 0B) goto <D.23289>; else goto <D.23287>;
    <D.23289>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23291>; else goto <D.23287>;
    <D.23291>:
    mono_mb_emit_ptr (mb, t);
    mono_mb_emit_icall (mb, cominterop_type_from_handle);
    get_com_interface_for_object_internal.125 = get_com_interface_for_object_internal;
    mono_mb_emit_managed_call (mb, get_com_interface_for_object_internal.125, 0B);
    goto <D.23288>;
    <D.23287>:
    D.23292 = spec->native;
    if (D.23292 == 25) goto <D.23293>; else goto <D.23294>;
    <D.23293>:
    get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.121, 0B);
    goto <D.23295>;
    <D.23294>:
    D.23292 = spec->native;
    if (D.23292 == 26) goto <D.23296>; else goto <D.23297>;
    <D.23296>:
    get_idispatch_for_object_internal.123 = get_idispatch_for_object_internal;
    mono_mb_emit_managed_call (mb, get_idispatch_for_object_internal.123, 0B);
    goto <D.23298>;
    <D.23297>:
    if (klass == 0B) goto <D.23301>; else goto <D.23299>;
    <D.23301>:
    D.23292 = spec->native;
    if (D.23292 == 28) goto <D.23302>; else goto <D.23299>;
    <D.23302>:
    get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.121, 0B);
    goto <D.23300>;
    <D.23299>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1128);
    <D.23300>:
    <D.23298>:
    <D.23295>:
    <D.23288>:
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.21213>;
  }
  <D.21214>:
  D.23274 = BIT_FIELD_REF <*t, 8, 56>;
  D.23275 = D.23274 & 64;
  if (D.23275 != 0) goto <D.23303>; else goto <D.23304>;
  <D.23303>:
  D.23278 = t->attrs;
  D.23279 = (int) D.23278;
  D.23280 = D.23279 & 2;
  if (D.23280 != 0) goto <D.23305>; else goto <D.23306>;
  <D.23305>:
  {
    int ccw_obj;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.23290 = mono_defaults.object_class;
    D.23307 = &D.23290->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.23307);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    mono_mb_emit_byte (mb, 20);
    mono_mb_emit_byte (mb, 81);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.129);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.129);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_ccw_object);
    ccw_obj.131 = (unsigned int) ccw_obj;
    mono_mb_emit_stloc (mb, ccw_obj.131);
    ccw_obj.131 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.131);
    pos_ccw = mono_mb_emit_short_branch (mb, 45);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.129);
    get_object_for_iunknown.119 = get_object_for_iunknown;
    mono_mb_emit_managed_call (mb, get_object_for_iunknown.119, 0B);
    if (klass != 0B) goto <D.23309>; else goto <D.23310>;
    <D.23309>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23311>; else goto <D.23312>;
    <D.23311>:
    mono_mb_emit_op (mb, 116, klass);
    <D.23312>:
    <D.23310>:
    mono_mb_emit_byte (mb, 81);
    pos_end = mono_mb_emit_short_branch (mb, 43);
    mono_mb_patch_short_branch (mb, pos_ccw);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    ccw_obj.131 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.131);
    if (klass != 0B) goto <D.23313>; else goto <D.23314>;
    <D.23313>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23315>; else goto <D.23316>;
    <D.23315>:
    mono_mb_emit_op (mb, 116, klass);
    <D.23316>:
    <D.23314>:
    mono_mb_emit_byte (mb, 81);
    mono_mb_patch_short_branch (mb, pos_end);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.129);
    marshal_release.127 = marshal_release;
    mono_mb_emit_managed_call (mb, marshal_release.127, 0B);
    mono_mb_emit_byte (mb, 38);
    mono_mb_patch_short_branch (mb, pos_null);
  }
  <D.23306>:
  <D.23304>:
  goto <D.21213>;
  <D.21219>:
  D.23274 = BIT_FIELD_REF <*t, 8, 56>;
  D.23275 = D.23274 & 64;
  if (D.23275 != 0) goto <D.23317>; else goto <D.23318>;
  <D.23317>:
  conv_arg.129 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc_addr (mb, conv_arg.129);
  goto <D.23319>;
  <D.23318>:
  conv_arg.129 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc (mb, conv_arg.129);
  <D.23319>:
  goto <D.21213>;
  <D.21220>:
  {
    int ccw_obj;
    int ret_ptr;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.23290 = mono_defaults.object_class;
    D.23307 = &D.23290->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.23307);
    D.23271 = mono_defaults.int_class;
    D.23272 = &D.23271->byval_arg;
    ret_ptr = mono_mb_add_local (mb, D.23272);
    ret_ptr.132 = (unsigned int) ret_ptr;
    mono_mb_emit_stloc (mb, ret_ptr.132);
    ret_ptr.132 = (unsigned int) ret_ptr;
    mono_mb_emit_ldloc (mb, ret_ptr.132);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    ret_ptr.132 = (unsigned int) ret_ptr;
    mono_mb_emit_ldloc (mb, ret_ptr.132);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_ccw_object);
    ccw_obj.133 = (unsigned int) ccw_obj;
    mono_mb_emit_stloc (mb, ccw_obj.133);
    ccw_obj.133 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.133);
    pos_ccw = mono_mb_emit_short_branch (mb, 45);
    ret_ptr.132 = (unsigned int) ret_ptr;
    mono_mb_emit_ldloc (mb, ret_ptr.132);
    get_object_for_iunknown.119 = get_object_for_iunknown;
    mono_mb_emit_managed_call (mb, get_object_for_iunknown.119, 0B);
    if (klass != 0B) goto <D.23322>; else goto <D.23323>;
    <D.23322>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23324>; else goto <D.23325>;
    <D.23324>:
    mono_mb_emit_op (mb, 116, klass);
    <D.23325>:
    <D.23323>:
    mono_mb_emit_stloc (mb, 3);
    pos_end = mono_mb_emit_short_branch (mb, 43);
    mono_mb_patch_short_branch (mb, pos_ccw);
    ccw_obj.133 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.133);
    if (klass != 0B) goto <D.23326>; else goto <D.23327>;
    <D.23326>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23328>; else goto <D.23329>;
    <D.23328>:
    mono_mb_emit_op (mb, 116, klass);
    <D.23329>:
    <D.23327>:
    mono_mb_emit_stloc (mb, 3);
    mono_mb_patch_short_branch (mb, pos_end);
    ret_ptr.132 = (unsigned int) ret_ptr;
    mono_mb_emit_ldloc (mb, ret_ptr.132);
    marshal_release.127 = marshal_release;
    mono_mb_emit_managed_call (mb, marshal_release.127, 0B);
    mono_mb_emit_byte (mb, 38);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.21213>;
  }
  <D.21226>:
  {
    int ccw_obj;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.23290 = mono_defaults.object_class;
    D.23307 = &D.23290->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.23307);
    klass = mono_class_from_mono_type (t);
    D.23330 = &klass->byval_arg;
    conv_arg = mono_mb_add_local (mb, D.23330);
    D.23271 = mono_defaults.int_class;
    D.23272 = &D.23271->byval_arg;
    *conv_arg_type = D.23272;
    mono_mb_emit_byte (mb, 20);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    D.23278 = t->attrs;
    D.23279 = (int) D.23278;
    D.23280 = D.23279 & 2;
    if (D.23280 != 0) goto <D.21213>; else goto <D.23331>;
    <D.23331>:
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.23274 = BIT_FIELD_REF <*t, 8, 56>;
    D.23275 = D.23274 & 64;
    if (D.23275 != 0) goto <D.23332>; else goto <D.23333>;
    <D.23332>:
    mono_mb_emit_byte (mb, 80);
    <D.23333>:
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.23274 = BIT_FIELD_REF <*t, 8, 56>;
    D.23275 = D.23274 & 64;
    if (D.23275 != 0) goto <D.23334>; else goto <D.23335>;
    <D.23334>:
    mono_mb_emit_byte (mb, 80);
    <D.23335>:
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_ccw_object);
    ccw_obj.134 = (unsigned int) ccw_obj;
    mono_mb_emit_stloc (mb, ccw_obj.134);
    ccw_obj.134 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.134);
    pos_ccw = mono_mb_emit_short_branch (mb, 45);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.23274 = BIT_FIELD_REF <*t, 8, 56>;
    D.23275 = D.23274 & 64;
    if (D.23275 != 0) goto <D.23337>; else goto <D.23338>;
    <D.23337>:
    mono_mb_emit_byte (mb, 80);
    <D.23338>:
    get_object_for_iunknown.119 = get_object_for_iunknown;
    mono_mb_emit_managed_call (mb, get_object_for_iunknown.119, 0B);
    if (klass != 0B) goto <D.23339>; else goto <D.23340>;
    <D.23339>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23341>; else goto <D.23342>;
    <D.23341>:
    mono_mb_emit_op (mb, 116, klass);
    <D.23342>:
    <D.23340>:
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    pos_end = mono_mb_emit_short_branch (mb, 43);
    mono_mb_patch_short_branch (mb, pos_ccw);
    ccw_obj.134 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.134);
    if (klass != 0B) goto <D.23343>; else goto <D.23344>;
    <D.23343>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23345>; else goto <D.23346>;
    <D.23345>:
    mono_mb_emit_op (mb, 116, klass);
    <D.23346>:
    <D.23344>:
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    mono_mb_patch_short_branch (mb, pos_end);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.21213>;
  }
  <D.21231>:
  D.23274 = BIT_FIELD_REF <*t, 8, 56>;
  D.23275 = D.23274 & 64;
  if (D.23275 != 0) goto <D.23347>; else goto <D.23348>;
  <D.23347>:
  D.23278 = t->attrs;
  D.23279 = (int) D.23278;
  D.23280 = D.23279 & 2;
  if (D.23280 != 0) goto <D.23349>; else goto <D.23350>;
  <D.23349>:
  {
    guint32 pos_null;

    pos_null = 0;
    AddRef.135 = AddRef;
    if (AddRef.135 == 0B) goto <D.23352>; else goto <D.23353>;
    <D.23352>:
    D.23253 = mono_defaults.marshal_class;
    AddRef.136 = mono_class_get_method_from_name (D.23253, "AddRef", 1);
    AddRef = AddRef.136;
    <D.23353>:
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    mono_mb_emit_byte (mb, 22);
    mono_mb_emit_byte (mb, 223);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.129);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.129);
    if (klass != 0B) goto <D.23357>; else goto <D.23355>;
    <D.23357>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23358>; else goto <D.23355>;
    <D.23358>:
    mono_mb_emit_ptr (mb, t);
    mono_mb_emit_icall (mb, cominterop_type_from_handle);
    get_com_interface_for_object_internal.125 = get_com_interface_for_object_internal;
    mono_mb_emit_managed_call (mb, get_com_interface_for_object_internal.125, 0B);
    goto <D.23356>;
    <D.23355>:
    D.23292 = spec->native;
    if (D.23292 == 25) goto <D.23359>; else goto <D.23360>;
    <D.23359>:
    get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.121, 0B);
    goto <D.23361>;
    <D.23360>:
    D.23292 = spec->native;
    if (D.23292 == 26) goto <D.23362>; else goto <D.23363>;
    <D.23362>:
    get_idispatch_for_object_internal.123 = get_idispatch_for_object_internal;
    mono_mb_emit_managed_call (mb, get_idispatch_for_object_internal.123, 0B);
    goto <D.23364>;
    <D.23363>:
    if (klass == 0B) goto <D.23367>; else goto <D.23365>;
    <D.23367>:
    D.23292 = spec->native;
    if (D.23292 == 28) goto <D.23368>; else goto <D.23365>;
    <D.23368>:
    get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.121, 0B);
    goto <D.23366>;
    <D.23365>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1321);
    <D.23366>:
    <D.23364>:
    <D.23361>:
    <D.23356>:
    mono_mb_emit_byte (mb, 223);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    mono_mb_emit_byte (mb, 77);
    AddRef.135 = AddRef;
    mono_mb_emit_managed_call (mb, AddRef.135, 0B);
    mono_mb_emit_byte (mb, 38);
    mono_mb_patch_short_branch (mb, pos_null);
  }
  <D.23350>:
  <D.23348>:
  goto <D.21213>;
  <D.21233>:
  {
    guint32 pos_null;
    int ccw_obj;

    pos_null = 0;
    D.23290 = mono_defaults.object_class;
    D.23307 = &D.23290->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.23307);
    AddRef.135 = AddRef;
    if (AddRef.135 == 0B) goto <D.23369>; else goto <D.23370>;
    <D.23369>:
    D.23253 = mono_defaults.marshal_class;
    AddRef.137 = mono_class_get_method_from_name (D.23253, "AddRef", 1);
    AddRef = AddRef.137;
    <D.23370>:
    ccw_obj.138 = (unsigned int) ccw_obj;
    mono_mb_emit_stloc (mb, ccw_obj.138);
    ccw_obj.138 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.138);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    ccw_obj.138 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.138);
    if (klass != 0B) goto <D.23375>; else goto <D.23373>;
    <D.23375>:
    D.23290 = mono_defaults.object_class;
    if (D.23290 != klass) goto <D.23376>; else goto <D.23373>;
    <D.23376>:
    mono_mb_emit_ptr (mb, t);
    mono_mb_emit_icall (mb, cominterop_type_from_handle);
    get_com_interface_for_object_internal.125 = get_com_interface_for_object_internal;
    mono_mb_emit_managed_call (mb, get_com_interface_for_object_internal.125, 0B);
    goto <D.23374>;
    <D.23373>:
    D.23292 = spec->native;
    if (D.23292 == 25) goto <D.23377>; else goto <D.23378>;
    <D.23377>:
    get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.121, 0B);
    goto <D.23379>;
    <D.23378>:
    D.23292 = spec->native;
    if (D.23292 == 26) goto <D.23380>; else goto <D.23381>;
    <D.23380>:
    get_idispatch_for_object_internal.123 = get_idispatch_for_object_internal;
    mono_mb_emit_managed_call (mb, get_idispatch_for_object_internal.123, 0B);
    goto <D.23382>;
    <D.23381>:
    if (klass == 0B) goto <D.23385>; else goto <D.23383>;
    <D.23385>:
    D.23292 = spec->native;
    if (D.23292 == 28) goto <D.23386>; else goto <D.23383>;
    <D.23386>:
    get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.121, 0B);
    goto <D.23384>;
    <D.23383>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1364);
    <D.23384>:
    <D.23382>:
    <D.23379>:
    <D.23374>:
    mono_mb_emit_stloc (mb, 3);
    mono_mb_emit_ldloc (mb, 3);
    AddRef.135 = AddRef;
    mono_mb_emit_managed_call (mb, AddRef.135, 0B);
    mono_mb_emit_byte (mb, 38);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.21213>;
  }
  <D.21236>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1376);
  <D.21213>:
  D.23387 = conv_arg;
  return D.23387;
}


ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (void * pUnk)
{
  _Bool D.23389;
  long int D.23390;
  long int D.23391;
  int D.23394;
  struct MonoIUnknown * D.23395;
  int (*<T3b8e>) (void *) D.23396;

  D.23389 = pUnk == 0B;
  D.23390 = (long int) D.23389;
  D.23391 = __builtin_expect (D.23390, 0);
  if (D.23391 != 0) goto <D.23392>; else goto <D.23393>;
  <D.23392>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1399, "pUnk");
  <D.23393>:
  D.23395 = MEM[(struct MonoIUnknown * *)pUnk];
  D.23396 = D.23395->AddRef;
  D.23394 = D.23396 (pUnk);
  return D.23394;
}


ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (void * pUnk, void * riid, void * * ppv)
{
  _Bool D.23398;
  long int D.23399;
  long int D.23400;
  int D.23403;
  struct MonoIUnknown * D.23404;
  int (*<T39b6>) (void *, void *, void * *) D.23405;

  D.23398 = pUnk == 0B;
  D.23399 = (long int) D.23398;
  D.23400 = __builtin_expect (D.23399, 0);
  if (D.23400 != 0) goto <D.23401>; else goto <D.23402>;
  <D.23401>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1406, "pUnk");
  <D.23402>:
  D.23404 = MEM[(struct MonoIUnknown * *)pUnk];
  D.23405 = D.23404->QueryInterface;
  D.23403 = D.23405 (pUnk, riid, ppv);
  return D.23403;
}


ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (void * pUnk)
{
  _Bool D.23407;
  long int D.23408;
  long int D.23409;
  int D.23412;
  struct MonoIUnknown * D.23413;
  int (*<T3b8e>) (void *) D.23414;

  D.23407 = pUnk == 0B;
  D.23408 = (long int) D.23407;
  D.23409 = __builtin_expect (D.23408, 0);
  if (D.23409 != 0) goto <D.23410>; else goto <D.23411>;
  <D.23410>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1413, "pUnk");
  <D.23411>:
  D.23413 = MEM[(struct MonoIUnknown * *)pUnk];
  D.23414 = D.23413->Release;
  D.23412 = D.23414 (pUnk);
  return D.23412;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal (struct MonoObject * object)
{
  void * D.23418;
  int D.23419;
  struct MonoVTable * D.23424;
  struct MonoClass * D.23425;
  struct MonoVTable * D.23430;
  struct MonoClass * D.23431;
  struct MonoComObject * D.23434;
  struct MonoClass * D.23437;

  if (object == 0B) goto <D.23416>; else goto <D.23417>;
  <D.23416>:
  D.23418 = 0B;
  return D.23418;
  <D.23417>:
  D.23419 = cominterop_object_is_rcw (object);
  if (D.23419 != 0) goto <D.23420>; else goto <D.23421>;
  <D.23420>:
  {
    struct MonoClass * klass;
    struct MonoRealProxy * real_proxy;

    klass = 0B;
    real_proxy = 0B;
    if (object == 0B) goto <D.23422>; else goto <D.23423>;
    <D.23422>:
    D.23418 = 0B;
    return D.23418;
    <D.23423>:
    D.23424 = object->vtable;
    klass = D.23424->klass;
    D.23425 = mono_defaults.transparent_proxy_class;
    if (D.23425 != klass) goto <D.23426>; else goto <D.23427>;
    <D.23426>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1460);
    D.23418 = 0B;
    return D.23418;
    <D.23427>:
    real_proxy = MEM[(struct MonoTransparentProxy *)object].rp;
    if (real_proxy == 0B) goto <D.23428>; else goto <D.23429>;
    <D.23428>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1466);
    D.23418 = 0B;
    return D.23418;
    <D.23429>:
    D.23430 = MEM[(struct MonoObject *)real_proxy].vtable;
    klass = D.23430->klass;
    D.23431 = mono_class_get_interop_proxy_class ();
    if (D.23431 != klass) goto <D.23432>; else goto <D.23433>;
    <D.23432>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1472);
    D.23418 = 0B;
    return D.23418;
    <D.23433>:
    D.23434 = MEM[(struct MonoComInteropProxy *)real_proxy].com_object;
    if (D.23434 == 0B) goto <D.23435>; else goto <D.23436>;
    <D.23435>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1477);
    D.23418 = 0B;
    return D.23418;
    <D.23436>:
    D.23434 = MEM[(struct MonoComInteropProxy *)real_proxy].com_object;
    D.23418 = D.23434->iunknown;
    return D.23418;
  }
  <D.23421>:
  D.23437 = mono_class_get_iunknown_class ();
  D.23418 = cominterop_get_ccw (object, D.23437);
  return D.23418;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetObjectForCCW (void * pUnk)
{
  struct MonoObject * D.23441;
  struct MonoObject * object;

  object = 0B;
  if (pUnk == 0B) goto <D.23439>; else goto <D.23440>;
  <D.23439>:
  D.23441 = 0B;
  return D.23441;
  <D.23440>:
  object = cominterop_get_ccw_object (pUnk, 1);
  D.23441 = object;
  return D.23441;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetIDispatchForObjectInternal (struct MonoObject * object)
{
  void * D.23443;

  D.23443 = cominterop_get_idispatch_for_object (object);
  return D.23443;
}


cominterop_get_idispatch_for_object (struct MonoObject * object)
{
  void * D.23447;
  int D.23448;
  struct MonoRealProxy * D.23451;
  struct MonoComObject * D.23452;
  struct MonoClass * D.23453;
  struct MonoVTable * D.23454;
  int D.23455;
  struct MonoClass * D.23458;

  if (object == 0B) goto <D.23445>; else goto <D.23446>;
  <D.23445>:
  D.23447 = 0B;
  return D.23447;
  <D.23446>:
  D.23448 = cominterop_object_is_rcw (object);
  if (D.23448 != 0) goto <D.23449>; else goto <D.23450>;
  <D.23449>:
  D.23451 = MEM[(struct MonoTransparentProxy *)object].rp;
  D.23452 = MEM[(struct MonoComInteropProxy *)D.23451].com_object;
  D.23453 = mono_class_get_idispatch_class ();
  D.23447 = cominterop_get_interface (D.23452, D.23453, 1);
  return D.23447;
  <D.23450>:
  {
    struct MonoClass * klass;

    D.23454 = object->vtable;
    klass = D.23454->klass;
    D.23455 = cominterop_can_support_dispatch (klass);
    if (D.23455 == 0) goto <D.23456>; else goto <D.23457>;
    <D.23456>:
    cominterop_raise_hr_exception (-2147467262);
    <D.23457>:
    D.23458 = mono_class_get_idispatch_class ();
    D.23447 = cominterop_get_ccw (object, D.23458);
    return D.23447;
  }
}


ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (struct MonoObject * object, struct MonoReflectionType * type)
{
  _Bool D.23460;
  long int D.23461;
  long int D.23462;
  struct MonoType * D.23465;
  _Bool D.23466;
  long int D.23467;
  long int D.23468;
  _Bool D.23471;
  long int D.23472;
  long int D.23473;
  int D.23476;
  struct MonoException * D.23479;
  _Bool D.23480;
  long int D.23481;
  long int D.23482;
  void * D.23485;
  struct MonoClass * klass;
  void * itf;

  klass = 0B;
  itf = 0B;
  D.23460 = type == 0B;
  D.23461 = (long int) D.23460;
  D.23462 = __builtin_expect (D.23461, 0);
  if (D.23462 != 0) goto <D.23463>; else goto <D.23464>;
  <D.23463>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1525, "type");
  <D.23464>:
  D.23465 = type->type;
  D.23466 = D.23465 == 0B;
  D.23467 = (long int) D.23466;
  D.23468 = __builtin_expect (D.23467, 0);
  if (D.23468 != 0) goto <D.23469>; else goto <D.23470>;
  <D.23469>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1526, "type->type");
  <D.23470>:
  D.23465 = type->type;
  klass = mono_type_get_class (D.23465);
  D.23471 = klass == 0B;
  D.23472 = (long int) D.23471;
  D.23473 = __builtin_expect (D.23472, 0);
  if (D.23473 != 0) goto <D.23474>; else goto <D.23475>;
  <D.23474>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1528, "klass");
  <D.23475>:
  D.23476 = mono_class_init (klass);
  if (D.23476 == 0) goto <D.23477>; else goto <D.23478>;
  <D.23477>:
  D.23479 = mono_class_get_exception_for_failure (klass);
  mono_raise_exception (D.23479);
  <D.23478>:
  itf = cominterop_get_ccw (object, klass);
  D.23480 = itf == 0B;
  D.23481 = (long int) D.23480;
  D.23482 = __builtin_expect (D.23481, 0);
  if (D.23482 != 0) goto <D.23483>; else goto <D.23484>;
  <D.23483>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1533, "itf");
  <D.23484>:
  D.23485 = itf;
  return D.23485;
}


ves_icall_System_Runtime_InteropServices_Marshal_IsComObject (struct MonoObject * object)
{
  MonoBoolean D.23487;
  int D.23488;

  D.23488 = cominterop_object_is_rcw (object);
  D.23487 = (MonoBoolean) D.23488;
  return D.23487;
}


ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal (struct MonoObject * object)
{
  _Bool D.23490;
  long int D.23491;
  long int D.23492;
  int D.23495;
  _Bool D.23496;
  long int D.23497;
  long int D.23498;
  _Bool D.23501;
  long int D.23502;
  long int D.23503;
  int D.23506;
  gint32 D.23509;
  gint32 * D.23510;
  _Bool D.23511;
  long int D.23512;
  long int D.23513;
  struct MonoComObject * D.23518;
  struct MonoComInteropProxy * proxy;
  gint32 ref_count;

  proxy = 0B;
  ref_count = 0;
  D.23490 = object == 0B;
  D.23491 = (long int) D.23490;
  D.23492 = __builtin_expect (D.23491, 0);
  if (D.23492 != 0) goto <D.23493>; else goto <D.23494>;
  <D.23493>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1558, "object");
  <D.23494>:
  D.23495 = cominterop_object_is_rcw (object);
  D.23496 = D.23495 == 0;
  D.23497 = (long int) D.23496;
  D.23498 = __builtin_expect (D.23497, 0);
  if (D.23498 != 0) goto <D.23499>; else goto <D.23500>;
  <D.23499>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1559, "cominterop_object_is_rcw (object)");
  <D.23500>:
  proxy = MEM[(struct MonoTransparentProxy *)object].rp;
  D.23501 = proxy == 0B;
  D.23502 = (long int) D.23501;
  D.23503 = __builtin_expect (D.23502, 0);
  if (D.23503 != 0) goto <D.23504>; else goto <D.23505>;
  <D.23504>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1562, "proxy");
  <D.23505>:
  D.23506 = proxy->ref_count;
  if (D.23506 == 0) goto <D.23507>; else goto <D.23508>;
  <D.23507>:
  D.23509 = -1;
  return D.23509;
  <D.23508>:
  D.23510 = &proxy->ref_count;
  ref_count = InterlockedDecrement (D.23510);
  D.23511 = ref_count < 0;
  D.23512 = (long int) D.23511;
  D.23513 = __builtin_expect (D.23512, 0);
  if (D.23513 != 0) goto <D.23514>; else goto <D.23515>;
  <D.23514>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1569, "ref_count >= 0");
  <D.23515>:
  if (ref_count == 0) goto <D.23516>; else goto <D.23517>;
  <D.23516>:
  D.23518 = proxy->com_object;
  ves_icall_System_ComObject_ReleaseInterfaces (D.23518);
  <D.23517>:
  D.23509 = ref_count;
  return D.23509;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal (struct MonoReflectionMethod * m)
{
  guint32 D.23520;
  struct MonoMethod * D.23521;
  int D.23522;

  D.23521 = m->method;
  D.23522 = cominterop_get_com_slot_for_method (D.23521);
  D.23520 = (guint32) D.23522;
  return D.23520;
}


ves_icall_System_ComObject_CreateRCW (struct MonoReflectionType * type)
{
  struct MonoVTable * D.23524;
  struct MonoType * D.23525;
  struct MonoVTable * D.23526;
  struct MonoObject * D.23527;
  struct MonoClass * klass;
  struct MonoDomain * domain;
  struct MonoObject * obj;

  D.23524 = MEM[(struct MonoObject *)type].vtable;
  domain = D.23524->domain;
  D.23525 = type->type;
  klass = mono_class_from_mono_type (D.23525);
  D.23526 = mono_class_vtable_full (domain, klass, 1);
  obj = mono_object_new_alloc_specific (D.23526);
  D.23527 = obj;
  return D.23527;
}


ves_icall_System_ComObject_ReleaseInterfaces (struct MonoComObject * obj)
{
  _Bool D.23529;
  long int D.23530;
  long int D.23531;
  struct GHashTable * D.23534;
  _Bool D.23539;
  long int D.23540;
  long int D.23541;
  struct GHashTable * rcw_hash.139;
  void * D.23545;
  void * D.23546;
  _Bool D.23551;
  long int D.23552;
  long int D.23553;

  D.23529 = obj == 0B;
  D.23530 = (long int) D.23529;
  D.23531 = __builtin_expect (D.23530, 0);
  if (D.23531 != 0) goto <D.23532>; else goto <D.23533>;
  <D.23532>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1625, "obj");
  <D.23533>:
  D.23534 = obj->itf_hash;
  if (D.23534 != 0B) goto <D.23535>; else goto <D.23536>;
  <D.23535>:
  {
    guint32 gchandle;

    gchandle = 0;
    {
      int ret;

      ret = pthread_mutex_lock (&cominterop_mutex.mutex);
      if (ret != 0) goto <D.23537>; else goto <D.23538>;
      <D.23537>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
      <D.23538>:
      D.23539 = ret != 0;
      D.23540 = (long int) D.23539;
      D.23541 = __builtin_expect (D.23540, 0);
      if (D.23541 != 0) goto <D.23542>; else goto <D.23543>;
      <D.23542>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1628, "ret == 0");
      <D.23543>:
    }
    rcw_hash.139 = rcw_hash;
    D.23545 = obj->iunknown;
    D.23546 = monoeg_g_hash_table_lookup (rcw_hash.139, D.23545);
    gchandle = (guint32) D.23546;
    if (gchandle != 0) goto <D.23547>; else goto <D.23548>;
    <D.23547>:
    mono_gchandle_free (gchandle);
    rcw_hash.139 = rcw_hash;
    D.23545 = obj->iunknown;
    monoeg_g_hash_table_remove (rcw_hash.139, D.23545);
    <D.23548>:
    D.23534 = obj->itf_hash;
    monoeg_g_hash_table_foreach_remove (D.23534, cominterop_rcw_interface_finalizer, 0B);
    D.23534 = obj->itf_hash;
    monoeg_g_hash_table_destroy (D.23534);
    D.23545 = obj->iunknown;
    ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (D.23545);
    obj->iunknown = 0B;
    obj->itf_hash = 0B;
    {
      int ret;

      ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
      if (ret != 0) goto <D.23549>; else goto <D.23550>;
      <D.23549>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
      <D.23550>:
      D.23551 = ret != 0;
      D.23552 = (long int) D.23551;
      D.23553 = __builtin_expect (D.23552, 0);
      if (D.23553 != 0) goto <D.23554>; else goto <D.23555>;
      <D.23554>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1639, "ret == 0");
      <D.23555>:
    }
  }
  <D.23536>:
}


cominterop_rcw_interface_finalizer (void * key, void * value, void * user_data)
{
  gboolean D.23556;

  ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (value);
  D.23556 = 1;
  return D.23556;
}


cominterop_release_all_rcws ()
{
  struct GHashTable * rcw_hash.140;
  _Bool D.23563;
  long int D.23564;
  long int D.23565;
  _Bool D.23570;
  long int D.23571;
  long int D.23572;

  rcw_hash.140 = rcw_hash;
  if (rcw_hash.140 == 0B) goto <D.23559>; else goto <D.23560>;
  <D.23559>:
  return;
  <D.23560>:
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23561>; else goto <D.23562>;
    <D.23561>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.23562>:
    D.23563 = ret != 0;
    D.23564 = (long int) D.23563;
    D.23565 = __builtin_expect (D.23564, 0);
    if (D.23565 != 0) goto <D.23566>; else goto <D.23567>;
    <D.23566>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1674, "ret == 0");
    <D.23567>:
  }
  rcw_hash.140 = rcw_hash;
  monoeg_g_hash_table_foreach_remove (rcw_hash.140, cominterop_rcw_finalizer, 0B);
  rcw_hash.140 = rcw_hash;
  monoeg_g_hash_table_destroy (rcw_hash.140);
  rcw_hash = 0B;
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23568>; else goto <D.23569>;
    <D.23568>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.23569>:
    D.23570 = ret != 0;
    D.23571 = (long int) D.23570;
    D.23572 = __builtin_expect (D.23571, 0);
    if (D.23572 != 0) goto <D.23573>; else goto <D.23574>;
    <D.23573>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1680, "ret == 0");
    <D.23574>:
  }
}


cominterop_rcw_finalizer (void * key, void * value, void * user_data)
{
  struct MonoComObject * D.23580;
  struct GHashTable * D.23581;
  void * D.23584;
  gboolean D.23587;
  guint32 gchandle;

  gchandle = 0;
  gchandle = (guint32) value;
  if (gchandle != 0) goto <D.23576>; else goto <D.23577>;
  <D.23576>:
  {
    struct MonoComInteropProxy * proxy;

    proxy = mono_gchandle_get_target (gchandle);
    if (proxy != 0B) goto <D.23578>; else goto <D.23579>;
    <D.23578>:
    D.23580 = proxy->com_object;
    D.23581 = D.23580->itf_hash;
    if (D.23581 != 0B) goto <D.23582>; else goto <D.23583>;
    <D.23582>:
    D.23580 = proxy->com_object;
    D.23581 = D.23580->itf_hash;
    monoeg_g_hash_table_foreach_remove (D.23581, cominterop_rcw_interface_finalizer, 0B);
    D.23580 = proxy->com_object;
    D.23581 = D.23580->itf_hash;
    monoeg_g_hash_table_destroy (D.23581);
    <D.23583>:
    D.23580 = proxy->com_object;
    D.23584 = D.23580->iunknown;
    if (D.23584 != 0B) goto <D.23585>; else goto <D.23586>;
    <D.23585>:
    D.23580 = proxy->com_object;
    D.23584 = D.23580->iunknown;
    ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (D.23584);
    <D.23586>:
    D.23580 = proxy->com_object;
    D.23580->iunknown = 0B;
    D.23580 = proxy->com_object;
    D.23580->itf_hash = 0B;
    <D.23579>:
    mono_gchandle_free (gchandle);
  }
  <D.23577>:
  D.23587 = 1;
  return D.23587;
}


ves_icall_System_ComObject_GetInterfaceInternal (struct MonoComObject * obj, struct MonoReflectionType * type, MonoBoolean throw_exception)
{
  struct MonoType * D.23589;
  int D.23590;
  struct MonoException * D.23593;
  void * D.23594;
  int D.23595;
  struct MonoClass * class;

  D.23589 = type->type;
  class = mono_type_get_class (D.23589);
  D.23590 = mono_class_init (class);
  if (D.23590 == 0) goto <D.23591>; else goto <D.23592>;
  <D.23591>:
  D.23593 = mono_class_get_exception_for_failure (class);
  mono_raise_exception (D.23593);
  <D.23592>:
  D.23595 = (int) throw_exception;
  D.23594 = cominterop_get_interface (obj, class, D.23595);
  return D.23594;
}


ves_icall_Mono_Interop_ComInteropProxy_AddProxy (void * pUnk, struct MonoComInteropProxy * proxy)
{
  struct GHashTable * rcw_hash.141;
  _Bool D.23602;
  long int D.23603;
  long int D.23604;
  struct GHashTable * rcw_hash.142;
  _Bool D.23610;
  long int D.23611;
  long int D.23612;
  _Bool D.23617;
  long int D.23618;
  long int D.23619;
  void * gchandle.143;
  _Bool D.23625;
  long int D.23626;
  long int D.23627;
  guint32 gchandle;

  gchandle = 0;
  rcw_hash.141 = rcw_hash;
  if (rcw_hash.141 == 0B) goto <D.23598>; else goto <D.23599>;
  <D.23598>:
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23600>; else goto <D.23601>;
    <D.23600>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.23601>:
    D.23602 = ret != 0;
    D.23603 = (long int) D.23602;
    D.23604 = __builtin_expect (D.23603, 0);
    if (D.23604 != 0) goto <D.23605>; else goto <D.23606>;
    <D.23605>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1703, "ret == 0");
    <D.23606>:
  }
  rcw_hash.142 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
  rcw_hash = rcw_hash.142;
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23608>; else goto <D.23609>;
    <D.23608>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.23609>:
    D.23610 = ret != 0;
    D.23611 = (long int) D.23610;
    D.23612 = __builtin_expect (D.23611, 0);
    if (D.23612 != 0) goto <D.23613>; else goto <D.23614>;
    <D.23613>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1705, "ret == 0");
    <D.23614>:
  }
  <D.23599>:
  gchandle = mono_gchandle_new_weakref (proxy, 0);
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23615>; else goto <D.23616>;
    <D.23615>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.23616>:
    D.23617 = ret != 0;
    D.23618 = (long int) D.23617;
    D.23619 = __builtin_expect (D.23618, 0);
    if (D.23619 != 0) goto <D.23620>; else goto <D.23621>;
    <D.23620>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1710, "ret == 0");
    <D.23621>:
  }
  rcw_hash.141 = rcw_hash;
  gchandle.143 = (void *) gchandle;
  monoeg_g_hash_table_insert_replace (rcw_hash.141, pUnk, gchandle.143, 0);
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23623>; else goto <D.23624>;
    <D.23623>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.23624>:
    D.23625 = ret != 0;
    D.23626 = (long int) D.23625;
    D.23627 = __builtin_expect (D.23626, 0);
    if (D.23627 != 0) goto <D.23628>; else goto <D.23629>;
    <D.23628>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1712, "ret == 0");
    <D.23629>:
  }
}


ves_icall_Mono_Interop_ComInteropProxy_FindProxy (void * pUnk)
{
  _Bool D.23632;
  long int D.23633;
  long int D.23634;
  struct GHashTable * rcw_hash.144;
  void * D.23640;
  _Bool D.23643;
  long int D.23644;
  long int D.23645;
  struct MonoComInteropProxy * D.23652;
  struct MonoComInteropProxy * proxy;
  guint32 gchandle;

  proxy = 0B;
  gchandle = 0;
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23630>; else goto <D.23631>;
    <D.23630>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.23631>:
    D.23632 = ret != 0;
    D.23633 = (long int) D.23632;
    D.23634 = __builtin_expect (D.23633, 0);
    if (D.23634 != 0) goto <D.23635>; else goto <D.23636>;
    <D.23635>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1725, "ret == 0");
    <D.23636>:
  }
  rcw_hash.144 = rcw_hash;
  if (rcw_hash.144 != 0B) goto <D.23638>; else goto <D.23639>;
  <D.23638>:
  rcw_hash.144 = rcw_hash;
  D.23640 = monoeg_g_hash_table_lookup (rcw_hash.144, pUnk);
  gchandle = (guint32) D.23640;
  <D.23639>:
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23641>; else goto <D.23642>;
    <D.23641>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.23642>:
    D.23643 = ret != 0;
    D.23644 = (long int) D.23643;
    D.23645 = __builtin_expect (D.23644, 0);
    if (D.23645 != 0) goto <D.23646>; else goto <D.23647>;
    <D.23646>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1728, "ret == 0");
    <D.23647>:
  }
  if (gchandle != 0) goto <D.23648>; else goto <D.23649>;
  <D.23648>:
  proxy = mono_gchandle_get_target (gchandle);
  if (proxy == 0B) goto <D.23650>; else goto <D.23651>;
  <D.23650>:
  mono_gchandle_free (gchandle);
  rcw_hash.144 = rcw_hash;
  monoeg_g_hash_table_remove (rcw_hash.144, pUnk);
  <D.23651>:
  <D.23649>:
  D.23652 = proxy;
  return D.23652;
}


mono_marshal_free_ccw (struct MonoObject * object)
{
  struct GHashTable * ccw_hash.145;
  unsigned int D.23658;
  gboolean D.23659;
  _Bool D.23662;
  long int D.23663;
  long int D.23664;
  int D.23667;
  const void * D.23668;
  _Bool D.23671;
  long int D.23672;
  long int D.23673;
  unsigned int D.23678;
  _Bool D.23679;
  _Bool D.23680;
  _Bool D.23681;
  struct GHashTable * D.23684;
  struct GList * iftmp.146;
  struct GList * iftmp.147;
  unsigned int D.23694;
  int D.23697;
  const void * D.23698;
  struct GList * ccw_list;
  struct GList * ccw_list_orig;
  struct GList * ccw_list_item;

  ccw_hash.145 = ccw_hash;
  if (ccw_hash.145 == 0B) goto <D.23654>; else goto <D.23657>;
  <D.23657>:
  ccw_hash.145 = ccw_hash;
  D.23658 = monoeg_g_hash_table_size (ccw_hash.145);
  if (D.23658 == 0) goto <D.23654>; else goto <D.23655>;
  <D.23654>:
  D.23659 = 0;
  return D.23659;
  <D.23655>:
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23660>; else goto <D.23661>;
    <D.23660>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.23661>:
    D.23662 = ret != 0;
    D.23663 = (long int) D.23662;
    D.23664 = __builtin_expect (D.23663, 0);
    if (D.23664 != 0) goto <D.23665>; else goto <D.23666>;
    <D.23665>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2050, "ret == 0");
    <D.23666>:
  }
  ccw_hash.145 = ccw_hash;
  D.23667 = mono_object_hash (object);
  D.23668 = (const void *) D.23667;
  ccw_list_orig = monoeg_g_hash_table_lookup (ccw_hash.145, D.23668);
  ccw_list = ccw_list_orig;
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.23669>; else goto <D.23670>;
    <D.23669>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.23670>:
    D.23671 = ret != 0;
    D.23672 = (long int) D.23671;
    D.23673 = __builtin_expect (D.23672, 0);
    if (D.23673 != 0) goto <D.23674>; else goto <D.23675>;
    <D.23674>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2052, "ret == 0");
    <D.23675>:
  }
  if (ccw_list == 0B) goto <D.23676>; else goto <D.23677>;
  <D.23676>:
  D.23659 = 0;
  return D.23659;
  <D.23677>:
  ccw_list_item = ccw_list;
  goto <D.21421>;
  <D.21420>:
  {
    struct MonoCCW * ccw_iter;
    struct MonoObject * handle_target;

    ccw_iter = ccw_list_item->data;
    D.23678 = ccw_iter->gc_handle;
    handle_target = mono_gchandle_get_target (D.23678);
    D.23679 = handle_target == 0B;
    D.23680 = handle_target == object;
    D.23681 = D.23679 | D.23680;
    if (D.23681 != 0) goto <D.23682>; else goto <D.23683>;
    <D.23682>:
    D.23684 = ccw_iter->vtable_hash;
    monoeg_g_hash_table_foreach_remove (D.23684, mono_marshal_free_ccw_entry, 0B);
    D.23684 = ccw_iter->vtable_hash;
    monoeg_g_hash_table_destroy (D.23684);
    if (ccw_list_item != 0B) goto <D.23686>; else goto <D.23687>;
    <D.23686>:
    iftmp.146 = ccw_list_item->next;
    goto <D.23688>;
    <D.23687>:
    iftmp.146 = 0B;
    <D.23688>:
    ccw_list_item = iftmp.146;
    ccw_list = monoeg_g_list_remove (ccw_list, ccw_iter);
    monoeg_g_free (ccw_iter);
    goto <D.23689>;
    <D.23683>:
    if (ccw_list_item != 0B) goto <D.23691>; else goto <D.23692>;
    <D.23691>:
    iftmp.147 = ccw_list_item->next;
    goto <D.23693>;
    <D.23692>:
    iftmp.147 = 0B;
    <D.23693>:
    ccw_list_item = iftmp.147;
    <D.23689>:
  }
  <D.21421>:
  if (ccw_list_item != 0B) goto <D.21420>; else goto <D.21422>;
  <D.21422>:
  D.23694 = monoeg_g_list_length (ccw_list);
  if (D.23694 == 0) goto <D.23695>; else goto <D.23696>;
  <D.23695>:
  ccw_hash.145 = ccw_hash;
  D.23697 = mono_object_hash (object);
  D.23698 = (const void *) D.23697;
  monoeg_g_hash_table_remove (ccw_hash.145, D.23698);
  <D.23696>:
  D.23659 = 1;
  return D.23659;
}


mono_marshal_free_ccw_entry (void * key, void * value, void * user_data)
{
  struct GHashTable * ccw_interface_hash.148;
  _Bool D.23701;
  long int D.23702;
  long int D.23703;
  gboolean D.23706;

  ccw_interface_hash.148 = ccw_interface_hash;
  monoeg_g_hash_table_remove (ccw_interface_hash.148, value);
  D.23701 = value == 0B;
  D.23702 = (long int) D.23701;
  D.23703 = __builtin_expect (D.23702, 0);
  if (D.23703 != 0) goto <D.23704>; else goto <D.23705>;
  <D.23704>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2030, "value");
  <D.23705>:
  monoeg_g_free (value);
  D.23706 = 1;
  return D.23706;
}


mono_string_to_bstr (struct MonoString * string_obj)
{
  void * D.23710;
  <unnamed type> com_provider.149;
  unsigned int slen.150;
  unsigned int D.23715;
  unsigned int D.23716;
  char * D.23719;
  mono_unichar2 * D.23720;
  unsigned int D.23721;
  unsigned int D.23722;
  unsigned int D.23723;
  char * D.23724;
  unsigned int D.23725;
  char * D.23726;
  int D.23729;
  int D.23731;
  mono_unichar2 * D.23732;
  long int len.151;
  void * (*<T3d88>) (gunichar *, guint32) sys_alloc_string_len_ms.152;

  if (string_obj == 0B) goto <D.23708>; else goto <D.23709>;
  <D.23708>:
  D.23710 = 0B;
  return D.23710;
  <D.23709>:
  com_provider.149 = com_provider;
  if (com_provider.149 == 0) goto <D.23712>; else goto <D.23713>;
  <D.23712>:
  {
    int slen;
    char * ret;

    slen = mono_string_length (string_obj);
    slen.150 = (unsigned int) slen;
    D.23715 = slen.150 + 3;
    D.23716 = D.23715 * 2;
    ret = monoeg_malloc (D.23716);
    if (ret == 0B) goto <D.23717>; else goto <D.23718>;
    <D.23717>:
    D.23710 = 0B;
    return D.23710;
    <D.23718>:
    D.23719 = ret + 4;
    D.23720 = mono_string_chars (string_obj);
    slen.150 = (unsigned int) slen;
    D.23721 = slen.150 * 2;
    memcpy (D.23719, D.23720, D.23721);
    slen.150 = (unsigned int) slen;
    D.23721 = slen.150 * 2;
    MEM[(guint32 *)ret] = D.23721;
    slen.150 = (unsigned int) slen;
    D.23722 = slen.150 + 2;
    D.23723 = D.23722 * 2;
    D.23724 = ret + D.23723;
    *D.23724 = 0;
    slen.150 = (unsigned int) slen;
    D.23721 = slen.150 * 2;
    D.23725 = D.23721 + 5;
    D.23726 = ret + D.23725;
    *D.23726 = 0;
    D.23710 = ret + 4;
    return D.23710;
  }
  <D.23713>:
  com_provider.149 = com_provider;
  if (com_provider.149 == 1) goto <D.23728>; else goto <D.23727>;
  <D.23728>:
  D.23729 = init_com_provider_ms ();
  if (D.23729 != 0) goto <D.23730>; else goto <D.23727>;
  <D.23730>:
  {
    void * ret;
    gunichar * str;
    guint32 len;

    ret = 0B;
    str = 0B;
    D.23731 = mono_string_length (string_obj);
    len = (guint32) D.23731;
    D.23732 = mono_string_chars (string_obj);
    len.151 = (long int) len;
    str = monoeg_g_utf16_to_ucs4 (D.23732, len.151, 0B, 0B, 0B);
    sys_alloc_string_len_ms.152 = sys_alloc_string_len_ms;
    ret = sys_alloc_string_len_ms.152 (str, len);
    monoeg_g_free (str);
    D.23710 = ret;
    return D.23710;
  }
  <D.23727>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2605);
}


mono_string_from_bstr (void * bstr)
{
  struct MonoString * D.23738;
  <unnamed type> com_provider.153;
  struct MonoDomain * D.23742;
  guint32 * D.23743;
  unsigned int D.23744;
  unsigned int D.23745;
  int D.23746;
  int D.23749;
  guint32 (*<T2201>) (void *) sys_string_len_ms.154;
  unsigned int D.23752;
  long int D.23753;
  struct MonoDomain * D.23754;
  long int written.155;

  if (bstr == 0B) goto <D.23736>; else goto <D.23737>;
  <D.23736>:
  D.23738 = 0B;
  return D.23738;
  <D.23737>:
  com_provider.153 = com_provider;
  if (com_provider.153 == 0) goto <D.23740>; else goto <D.23741>;
  <D.23740>:
  D.23742 = mono_domain_get ();
  D.23743 = bstr + 4294967292;
  D.23744 = *D.23743;
  D.23745 = D.23744 / 2;
  D.23746 = (int) D.23745;
  D.23738 = mono_string_new_utf16 (D.23742, bstr, D.23746);
  return D.23738;
  <D.23741>:
  com_provider.153 = com_provider;
  if (com_provider.153 == 1) goto <D.23748>; else goto <D.23747>;
  <D.23748>:
  D.23749 = init_com_provider_ms ();
  if (D.23749 != 0) goto <D.23750>; else goto <D.23747>;
  <D.23750>:
  {
    struct MonoString * str;
    glong written;
    gunichar2 * utf16;

    try
      {
        str = 0B;
        written = 0;
        utf16 = 0B;
        sys_string_len_ms.154 = sys_string_len_ms;
        D.23752 = sys_string_len_ms.154 (bstr);
        D.23753 = (long int) D.23752;
        utf16 = monoeg_g_ucs4_to_utf16 (bstr, D.23753, 0B, &written, 0B);
        D.23754 = mono_domain_get ();
        written.155 = written;
        str = mono_string_new_utf16 (D.23754, utf16, written.155);
        monoeg_g_free (utf16);
        D.23738 = str;
        return D.23738;
      }
    finally
      {
        written = {CLOBBER};
      }
  }
  <D.23747>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2630);
}


mono_free_bstr (void * bstr)
{
  <unnamed type> com_provider.156;
  void * D.23763;
  int D.23768;
  void (*<T3d90>) (gunichar *) sys_free_string_ms.157;

  if (bstr == 0B) goto <D.23758>; else goto <D.23759>;
  <D.23758>:
  return;
  <D.23759>:
  com_provider.156 = com_provider;
  if (com_provider.156 == 0) goto <D.23761>; else goto <D.23762>;
  <D.23761>:
  D.23763 = bstr + 4294967292;
  monoeg_g_free (D.23763);
  goto <D.23764>;
  <D.23762>:
  com_provider.156 = com_provider;
  if (com_provider.156 == 1) goto <D.23767>; else goto <D.23765>;
  <D.23767>:
  D.23768 = init_com_provider_ms ();
  if (D.23768 != 0) goto <D.23769>; else goto <D.23765>;
  <D.23769>:
  sys_free_string_ms.157 = sys_free_string_ms;
  sys_free_string_ms.157 (bstr);
  goto <D.23766>;
  <D.23765>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2649);
  <D.23766>:
  <D.23764>:
}


mono_cominterop_emit_marshal_safearray (struct EmitMarshalContext * m, int argnum, struct MonoType * t, struct MonoMarshalSpec * spec, int conv_arg, struct MonoType * * conv_arg_type, MarshalAction action)
{
  short unsigned int D.23772;
  int D.23773;
  int D.23774;
  struct MonoClass * D.23777;
  struct MonoType * D.23778;
  struct MonoClass * D.23779;
  struct MonoType * D.23780;
  unsigned char D.23781;
  unsigned char D.23782;
  unsigned int argnum.158;
  unsigned int safearray_var.159;
  unsigned int indices_var.160;
  unsigned int empty_var.161;
  struct MonoClass * D.23790;
  struct MonoType * D.23791;
  unsigned int index_var.162;
  int D.23793;
  struct MonoMethod * get_value_impl.163;
  struct MonoClass * D.23797;
  struct MonoMethod * get_value_impl.164;
  _Bool D.23799;
  long int D.23800;
  long int D.23801;
  struct MonoMethod * get_native_variant_for_object.165;
  struct MonoClass * D.23810;
  struct MonoMethod * get_native_variant_for_object.166;
  _Bool D.23812;
  long int D.23813;
  long int D.23814;
  struct MonoClass * D.23817;
  struct MonoType * D.23818;
  unsigned int elem_var.167;
  struct MonoMethod * variant_clear.168;
  struct MonoClass * D.23823;
  struct MonoMethod * variant_clear.169;
  short unsigned int D.23825;
  unsigned int conv_arg.170;
  int D.23830;
  int iftmp.171;
  unsigned int result_var.172;
  unsigned int indices_var.173;
  unsigned int empty_var.174;
  unsigned int index_var.175;
  int D.23845;
  struct MonoMethod * get_object_for_native_variant.176;
  struct MonoMethod * get_object_for_native_variant.177;
  _Bool D.23852;
  long int D.23853;
  long int D.23854;
  struct MonoMethod * set_value_impl.178;
  struct MonoMethod * set_value_impl.179;
  _Bool D.23861;
  long int D.23862;
  long int D.23863;
  unsigned int elem_var.180;
  short unsigned int D.23869;
  int D.23872;
  struct MonoMethodBuilder * mb;

  mb = m->mb;
  switch (action) <default: <D.21642>, case 0: <D.21615>, case 1: <D.21628>, case 2: <D.21629>>
  <D.21615>:
  D.23772 = t->attrs;
  D.23773 = (int) D.23772;
  D.23774 = D.23773 & 1;
  if (D.23774 != 0) goto <D.23775>; else goto <D.23776>;
  <D.23775>:
  {
    int safearray_var;
    int indices_var;
    int empty_var;
    int elem_var;
    int index_var;
    guint32 label1;
    guint32 label2;
    guint32 label3;
    static struct MonoMethod * get_native_variant_for_object = 0B;
    static struct MonoMethod * get_value_impl = 0B;
    static struct MonoMethod * variant_clear = 0B;

    label1 = 0;
    label2 = 0;
    label3 = 0;
    D.23777 = mono_defaults.object_class;
    D.23778 = &D.23777->byval_arg;
    safearray_var = mono_mb_add_local (mb, D.23778);
    conv_arg = safearray_var;
    D.23779 = mono_defaults.int_class;
    D.23780 = &D.23779->byval_arg;
    indices_var = mono_mb_add_local (mb, D.23780);
    D.23779 = mono_defaults.int_class;
    D.23780 = &D.23779->byval_arg;
    empty_var = mono_mb_add_local (mb, D.23780);
    D.23781 = BIT_FIELD_REF <*t, 8, 56>;
    D.23782 = D.23781 & 64;
    if (D.23782 != 0) goto <D.23783>; else goto <D.23784>;
    <D.23783>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    mono_mb_emit_byte (mb, 80);
    goto <D.23786>;
    <D.23784>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    <D.23786>:
    safearray_var.159 = (unsigned int) safearray_var;
    mono_mb_emit_ldloc_addr (mb, safearray_var.159);
    indices_var.160 = (unsigned int) indices_var;
    mono_mb_emit_ldloc_addr (mb, indices_var.160);
    empty_var.161 = (unsigned int) empty_var;
    mono_mb_emit_ldloc_addr (mb, empty_var.161);
    mono_mb_emit_icall (mb, mono_marshal_safearray_create);
    label1 = mono_mb_emit_short_branch (mb, 44);
    empty_var.161 = (unsigned int) empty_var;
    mono_mb_emit_ldloc (mb, empty_var.161);
    label2 = mono_mb_emit_short_branch (mb, 45);
    D.23790 = mono_defaults.int32_class;
    D.23791 = &D.23790->byval_arg;
    index_var = mono_mb_add_local (mb, D.23791);
    mono_mb_emit_byte (mb, 22);
    index_var.162 = (unsigned int) index_var;
    mono_mb_emit_stloc (mb, index_var.162);
    D.23793 = mono_mb_get_label (mb);
    label3 = (guint32) D.23793;
    get_value_impl.163 = get_value_impl;
    if (get_value_impl.163 == 0B) goto <D.23795>; else goto <D.23796>;
    <D.23795>:
    D.23797 = mono_defaults.array_class;
    get_value_impl.164 = mono_class_get_method_from_name (D.23797, "GetValueImpl", 1);
    get_value_impl = get_value_impl.164;
    <D.23796>:
    get_value_impl.163 = get_value_impl;
    D.23799 = get_value_impl.163 == 0B;
    D.23800 = (long int) D.23799;
    D.23801 = __builtin_expect (D.23800, 0);
    if (D.23801 != 0) goto <D.23802>; else goto <D.23803>;
    <D.23802>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2725, "get_value_impl");
    <D.23803>:
    D.23781 = BIT_FIELD_REF <*t, 8, 56>;
    D.23782 = D.23781 & 64;
    if (D.23782 != 0) goto <D.23804>; else goto <D.23805>;
    <D.23804>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    mono_mb_emit_byte (mb, 80);
    goto <D.23806>;
    <D.23805>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    <D.23806>:
    index_var.162 = (unsigned int) index_var;
    mono_mb_emit_ldloc (mb, index_var.162);
    get_value_impl.163 = get_value_impl;
    mono_mb_emit_managed_call (mb, get_value_impl.163, 0B);
    get_native_variant_for_object.165 = get_native_variant_for_object;
    if (get_native_variant_for_object.165 == 0B) goto <D.23808>; else goto <D.23809>;
    <D.23808>:
    D.23810 = mono_defaults.marshal_class;
    get_native_variant_for_object.166 = mono_class_get_method_from_name (D.23810, "GetNativeVariantForObject", 2);
    get_native_variant_for_object = get_native_variant_for_object.166;
    <D.23809>:
    get_native_variant_for_object.165 = get_native_variant_for_object;
    D.23812 = get_native_variant_for_object.165 == 0B;
    D.23813 = (long int) D.23812;
    D.23814 = __builtin_expect (D.23813, 0);
    if (D.23814 != 0) goto <D.23815>; else goto <D.23816>;
    <D.23815>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2739, "get_native_variant_for_object");
    <D.23816>:
    D.23817 = mono_class_get_variant_class ();
    D.23818 = &D.23817->byval_arg;
    elem_var = mono_mb_add_local (mb, D.23818);
    elem_var.167 = (unsigned int) elem_var;
    mono_mb_emit_ldloc_addr (mb, elem_var.167);
    get_native_variant_for_object.165 = get_native_variant_for_object;
    mono_mb_emit_managed_call (mb, get_native_variant_for_object.165, 0B);
    safearray_var.159 = (unsigned int) safearray_var;
    mono_mb_emit_ldloc (mb, safearray_var.159);
    indices_var.160 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.160);
    elem_var.167 = (unsigned int) elem_var;
    mono_mb_emit_ldloc_addr (mb, elem_var.167);
    mono_mb_emit_icall (mb, mono_marshal_safearray_set_value);
    variant_clear.168 = variant_clear;
    if (variant_clear.168 == 0B) goto <D.23821>; else goto <D.23822>;
    <D.23821>:
    D.23823 = mono_class_get_variant_class ();
    variant_clear.169 = mono_class_get_method_from_name (D.23823, "Clear", 0);
    variant_clear = variant_clear.169;
    <D.23822>:
    elem_var.167 = (unsigned int) elem_var;
    mono_mb_emit_ldloc_addr (mb, elem_var.167);
    variant_clear.168 = variant_clear;
    mono_mb_emit_managed_call (mb, variant_clear.168, 0B);
    D.23825 = (short unsigned int) index_var;
    mono_mb_emit_add_to_local (mb, D.23825, 1);
    safearray_var.159 = (unsigned int) safearray_var;
    mono_mb_emit_ldloc (mb, safearray_var.159);
    indices_var.160 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.160);
    mono_mb_emit_icall (mb, mono_marshal_safearray_next);
    mono_mb_emit_branch_label (mb, 58, label3);
    mono_mb_patch_short_branch (mb, label2);
    indices_var.160 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.160);
    mono_mb_emit_icall (mb, mono_marshal_safearray_free_indices);
    mono_mb_patch_short_branch (mb, label1);
  }
  <D.23776>:
  goto <D.21627>;
  <D.21628>:
  D.23781 = BIT_FIELD_REF <*t, 8, 56>;
  D.23782 = D.23781 & 64;
  if (D.23782 != 0) goto <D.23826>; else goto <D.23827>;
  <D.23826>:
  conv_arg.170 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc_addr (mb, conv_arg.170);
  goto <D.23829>;
  <D.23827>:
  conv_arg.170 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc (mb, conv_arg.170);
  <D.23829>:
  goto <D.21627>;
  <D.21629>:
  D.23772 = t->attrs;
  D.23773 = (int) D.23772;
  D.23830 = D.23773 & 2;
  if (D.23830 != 0) goto <D.23831>; else goto <D.23832>;
  <D.23831>:
  {
    int result_var;
    int indices_var;
    int empty_var;
    int elem_var;
    int index_var;
    guint32 label1;
    guint32 label2;
    guint32 label3;
    guint32 label4;
    static struct MonoMethod * get_object_for_native_variant = 0B;
    static struct MonoMethod * set_value_impl = 0B;
    gboolean byValue;

    label1 = 0;
    label2 = 0;
    label3 = 0;
    label4 = 0;
    D.23781 = BIT_FIELD_REF <*t, 8, 56>;
    D.23782 = D.23781 & 64;
    if (D.23782 == 0) goto <D.23836>; else goto <D.23834>;
    <D.23836>:
    D.23772 = t->attrs;
    D.23773 = (int) D.23772;
    D.23774 = D.23773 & 1;
    if (D.23774 != 0) goto <D.23837>; else goto <D.23834>;
    <D.23837>:
    iftmp.171 = 1;
    goto <D.23835>;
    <D.23834>:
    iftmp.171 = 0;
    <D.23835>:
    byValue = iftmp.171;
    D.23777 = mono_defaults.object_class;
    D.23778 = &D.23777->byval_arg;
    result_var = mono_mb_add_local (mb, D.23778);
    D.23779 = mono_defaults.int_class;
    D.23780 = &D.23779->byval_arg;
    indices_var = mono_mb_add_local (mb, D.23780);
    D.23779 = mono_defaults.int_class;
    D.23780 = &D.23779->byval_arg;
    empty_var = mono_mb_add_local (mb, D.23780);
    conv_arg.170 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.170);
    result_var.172 = (unsigned int) result_var;
    mono_mb_emit_ldloc_addr (mb, result_var.172);
    indices_var.173 = (unsigned int) indices_var;
    mono_mb_emit_ldloc_addr (mb, indices_var.173);
    empty_var.174 = (unsigned int) empty_var;
    mono_mb_emit_ldloc_addr (mb, empty_var.174);
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    if (byValue != 0) goto <D.23841>; else goto <D.23842>;
    <D.23841>:
    mono_mb_emit_byte (mb, 22);
    goto <D.23843>;
    <D.23842>:
    mono_mb_emit_byte (mb, 23);
    <D.23843>:
    mono_mb_emit_icall (mb, mono_marshal_safearray_begin);
    label1 = mono_mb_emit_short_branch (mb, 44);
    empty_var.174 = (unsigned int) empty_var;
    mono_mb_emit_ldloc (mb, empty_var.174);
    label2 = mono_mb_emit_short_branch (mb, 45);
    D.23779 = mono_defaults.int_class;
    D.23780 = &D.23779->byval_arg;
    index_var = mono_mb_add_local (mb, D.23780);
    mono_mb_emit_byte (mb, 22);
    index_var.175 = (unsigned int) index_var;
    mono_mb_emit_stloc (mb, index_var.175);
    D.23845 = mono_mb_get_label (mb);
    label3 = (guint32) D.23845;
    if (byValue != 0) goto <D.23846>; else goto <D.23847>;
    <D.23846>:
    index_var.175 = (unsigned int) index_var;
    mono_mb_emit_ldloc (mb, index_var.175);
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    mono_mb_emit_byte (mb, 142);
    label4 = mono_mb_emit_branch (mb, 60);
    <D.23847>:
    conv_arg.170 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.170);
    indices_var.173 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.173);
    mono_mb_emit_icall (mb, mono_marshal_safearray_get_value);
    get_object_for_native_variant.176 = get_object_for_native_variant;
    if (get_object_for_native_variant.176 == 0B) goto <D.23849>; else goto <D.23850>;
    <D.23849>:
    D.23810 = mono_defaults.marshal_class;
    get_object_for_native_variant.177 = mono_class_get_method_from_name (D.23810, "GetObjectForNativeVariant", 1);
    get_object_for_native_variant = get_object_for_native_variant.177;
    <D.23850>:
    get_object_for_native_variant.176 = get_object_for_native_variant;
    D.23852 = get_object_for_native_variant.176 == 0B;
    D.23853 = (long int) D.23852;
    D.23854 = __builtin_expect (D.23853, 0);
    if (D.23854 != 0) goto <D.23855>; else goto <D.23856>;
    <D.23855>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2854, "get_object_for_native_variant");
    <D.23856>:
    set_value_impl.178 = set_value_impl;
    if (set_value_impl.178 == 0B) goto <D.23858>; else goto <D.23859>;
    <D.23858>:
    D.23797 = mono_defaults.array_class;
    set_value_impl.179 = mono_class_get_method_from_name (D.23797, "SetValueImpl", 2);
    set_value_impl = set_value_impl.179;
    <D.23859>:
    set_value_impl.178 = set_value_impl;
    D.23861 = set_value_impl.178 == 0B;
    D.23862 = (long int) D.23861;
    D.23863 = __builtin_expect (D.23862, 0);
    if (D.23863 != 0) goto <D.23864>; else goto <D.23865>;
    <D.23864>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2858, "set_value_impl");
    <D.23865>:
    D.23777 = mono_defaults.object_class;
    D.23778 = &D.23777->byval_arg;
    elem_var = mono_mb_add_local (mb, D.23778);
    get_object_for_native_variant.176 = get_object_for_native_variant;
    mono_mb_emit_managed_call (mb, get_object_for_native_variant.176, 0B);
    elem_var.180 = (unsigned int) elem_var;
    mono_mb_emit_stloc (mb, elem_var.180);
    result_var.172 = (unsigned int) result_var;
    mono_mb_emit_ldloc (mb, result_var.172);
    elem_var.180 = (unsigned int) elem_var;
    mono_mb_emit_ldloc (mb, elem_var.180);
    index_var.175 = (unsigned int) index_var;
    mono_mb_emit_ldloc (mb, index_var.175);
    set_value_impl.178 = set_value_impl;
    mono_mb_emit_managed_call (mb, set_value_impl.178, 0B);
    if (byValue != 0) goto <D.23867>; else goto <D.23868>;
    <D.23867>:
    mono_mb_patch_short_branch (mb, label4);
    <D.23868>:
    D.23869 = (short unsigned int) index_var;
    mono_mb_emit_add_to_local (mb, D.23869, 1);
    conv_arg.170 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.170);
    indices_var.173 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.173);
    mono_mb_emit_icall (mb, mono_marshal_safearray_next);
    mono_mb_emit_branch_label (mb, 58, label3);
    mono_mb_patch_short_branch (mb, label2);
    conv_arg.170 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.170);
    indices_var.173 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.173);
    mono_mb_emit_icall (mb, mono_marshal_safearray_end);
    mono_mb_patch_short_branch (mb, label1);
    if (byValue == 0) goto <D.23870>; else goto <D.23871>;
    <D.23870>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    result_var.172 = (unsigned int) result_var;
    mono_mb_emit_ldloc (mb, result_var.172);
    mono_mb_emit_byte (mb, 81);
    <D.23871>:
  }
  <D.23832>:
  goto <D.21627>;
  <D.21642>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2898);
  <D.21627>:
  D.23872 = conv_arg;
  return D.23872;
}


ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (void * ptr)
{
  struct MonoString * D.23874;

  D.23874 = mono_string_from_bstr (ptr);
  return D.23874;
}


ves_icall_System_Runtime_InteropServices_Marshal_StringToBSTR (struct MonoString * ptr)
{
  void * D.23876;

  D.23876 = mono_string_to_bstr (ptr);
  return D.23876;
}


ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR (void * ptr)
{
  mono_free_bstr (ptr);
}


