mono_class_get_interop_proxy_class ()
{
  struct MonoImage * D.19175;
  _Bool D.19176;
  long int D.19177;
  long int D.19178;
  struct MonoClass * D.19181;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19173>; else goto <D.19174>;
  <D.19173>:
  D.19175 = mono_defaults.corlib;
  class = mono_class_from_name (D.19175, "Mono.Interop", "ComInteropProxy");
  D.19176 = class == 0B;
  D.19177 = (long int) D.19176;
  D.19178 = __builtin_expect (D.19177, 0);
  if (D.19178 != 0) goto <D.19179>; else goto <D.19180>;
  <D.19179>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 88, "class");
  <D.19180>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19174>:
  D.19181 = class;
  return D.19181;
}


mono_memory_barrier ()
{
  __sync_synchronize ();
}


mono_class_get_idispatch_class ()
{
  struct MonoImage * D.19185;
  _Bool D.19186;
  long int D.19187;
  long int D.19188;
  struct MonoClass * D.19191;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19183>; else goto <D.19184>;
  <D.19183>:
  D.19185 = mono_defaults.corlib;
  class = mono_class_from_name (D.19185, "Mono.Interop", "IDispatch");
  D.19186 = class == 0B;
  D.19187 = (long int) D.19186;
  D.19188 = __builtin_expect (D.19187, 0);
  if (D.19188 != 0) goto <D.19189>; else goto <D.19190>;
  <D.19189>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 89, "class");
  <D.19190>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19184>:
  D.19191 = class;
  return D.19191;
}


mono_class_get_iunknown_class ()
{
  struct MonoImage * D.19195;
  _Bool D.19196;
  long int D.19197;
  long int D.19198;
  struct MonoClass * D.19201;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19193>; else goto <D.19194>;
  <D.19193>:
  D.19195 = mono_defaults.corlib;
  class = mono_class_from_name (D.19195, "Mono.Interop", "IUnknown");
  D.19196 = class == 0B;
  D.19197 = (long int) D.19196;
  D.19198 = __builtin_expect (D.19197, 0);
  if (D.19198 != 0) goto <D.19199>; else goto <D.19200>;
  <D.19199>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 90, "class");
  <D.19200>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19194>:
  D.19201 = class;
  return D.19201;
}


mono_class_get_com_object_class ()
{
  struct MonoImage * D.19205;
  _Bool D.19206;
  long int D.19207;
  long int D.19208;
  struct MonoClass * D.19211;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19203>; else goto <D.19204>;
  <D.19203>:
  D.19205 = mono_defaults.corlib;
  class = mono_class_from_name (D.19205, "System", "__ComObject");
  D.19206 = class == 0B;
  D.19207 = (long int) D.19206;
  D.19208 = __builtin_expect (D.19207, 0);
  if (D.19208 != 0) goto <D.19209>; else goto <D.19210>;
  <D.19209>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 92, "class");
  <D.19210>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19204>:
  D.19211 = class;
  return D.19211;
}


mono_class_get_variant_class ()
{
  struct MonoImage * D.19215;
  _Bool D.19216;
  long int D.19217;
  long int D.19218;
  struct MonoClass * D.19221;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19213>; else goto <D.19214>;
  <D.19213>:
  D.19215 = mono_defaults.corlib;
  class = mono_class_from_name (D.19215, "System", "Variant");
  D.19216 = class == 0B;
  D.19217 = (long int) D.19216;
  D.19218 = __builtin_expect (D.19217, 0);
  if (D.19218 != 0) goto <D.19219>; else goto <D.19220>;
  <D.19219>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 93, "class");
  <D.19220>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19214>:
  D.19221 = class;
  return D.19221;
}


mono_cominterop_init ()
{
  int D.18512;
  int iftmp.0;
  int D.18511;
  const char[3] * D.19228;
  unsigned char D.19229;
  int D.19230;
  unsigned char D.19231;
  int D.19232;
  _Bool D.19233;
  _Bool D.19234;
  _Bool D.19235;
  const unsigned char * D.19238;
  unsigned char D.19239;
  int D.19240;
  const unsigned char * D.19241;
  unsigned char D.19242;
  int D.19243;
  _Bool D.19244;
  _Bool D.19245;
  const unsigned char * D.19248;
  unsigned char D.19249;
  int D.19250;
  const unsigned char * D.19251;
  unsigned char D.19252;
  int D.19253;
  _Bool D.19254;
  _Bool D.19255;
  const unsigned char * D.19258;
  unsigned char D.19259;
  int D.19260;
  const unsigned char * D.19261;
  unsigned char D.19262;
  int D.19263;
  const char * com_provider_env;

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

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

      __s2 = com_provider_env;
      D.19228 = "MS";
      D.19229 = MEM[(const unsigned char *)D.19228];
      D.19230 = (int) D.19229;
      D.19231 = *__s2;
      D.19232 = (int) D.19231;
      __result = D.19230 - D.19232;
      {
        D.19233 = __s2_len != 0;
        D.19234 = __result == 0;
        D.19235 = D.19233 & D.19234;
        if (D.19235 != 0) goto <D.19236>; else goto <D.19237>;
        <D.19236>:
        D.19238 = &MEM[(void *)"MS" + 1B];
        D.19239 = *D.19238;
        D.19240 = (int) D.19239;
        D.19241 = __s2 + 1;
        D.19242 = *D.19241;
        D.19243 = (int) D.19242;
        __result = D.19240 - D.19243;
        D.19244 = __s2_len > 1;
        D.19234 = __result == 0;
        D.19245 = D.19244 & D.19234;
        if (D.19245 != 0) goto <D.19246>; else goto <D.19247>;
        <D.19246>:
        D.19248 = &MEM[(void *)"MS" + 2B];
        D.19249 = *D.19248;
        D.19250 = (int) D.19249;
        D.19251 = __s2 + 2;
        D.19252 = *D.19251;
        D.19253 = (int) D.19252;
        __result = D.19250 - D.19253;
        D.19254 = __s2_len > 2;
        D.19234 = __result == 0;
        D.19255 = D.19254 & D.19234;
        if (D.19255 != 0) goto <D.19256>; else goto <D.19257>;
        <D.19256>:
        D.19258 = &MEM[(void *)"MS" + 3B];
        D.19259 = *D.19258;
        D.19260 = (int) D.19259;
        D.19261 = __s2 + 3;
        D.19262 = *D.19261;
        D.19263 = (int) D.19262;
        __result = D.19260 - D.19263;
        <D.19257>:
        <D.19247>:
        <D.19237>:
      }
      D.18511 = __result;
    }
    iftmp.0 = -D.18511;
    goto <D.19264>;
    <D.19227>:
    iftmp.0 = __builtin_strcmp (com_provider_env, "MS");
    <D.19264>:
    D.18512 = iftmp.0;
  }
  if (D.18512 == 0) goto <D.19265>; else goto <D.19266>;
  <D.19265>:
  com_provider = 1;
  <D.19266>:
  <D.19224>:
  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.19271;
  int (*<T333a>) (void *, glong *, void * *) safe_array_put_element_ms.2;

  com_provider.1 = com_provider;
  if (com_provider.1 == 1) goto <D.19270>; else goto <D.19267>;
  <D.19270>:
  D.19271 = init_com_provider_ms ();
  if (D.19271 != 0) goto <D.19272>; else goto <D.19267>;
  <D.19272>:
  {
    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.19274>; else goto <D.19275>;
    <D.19274>:
    cominterop_raise_hr_exception (hr);
    <D.19275>:
  }
  goto <D.19268>;
  <D.19267>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3154);
  <D.19268>:
}


init_com_provider_ms ()
{
  int initialized.3;
  gboolean D.19279;
  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.19277>; else goto <D.19278>;
      <D.19277>:
      D.19279 = 1;
      return D.19279;
      <D.19278>:
      module = mono_dl_open (scope, 1, &error_msg);
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.19281>; else goto <D.19282>;
      <D.19281>:
      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.19279 = 0;
      return D.19279;
      <D.19282>:
      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.19284>; else goto <D.19285>;
      <D.19284>:
      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.19279 = 0;
      return D.19279;
      <D.19285>:
      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.19287>; else goto <D.19288>;
      <D.19287>:
      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.19279 = 0;
      return D.19279;
      <D.19288>:
      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.19290>; else goto <D.19291>;
      <D.19290>:
      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.19279 = 0;
      return D.19279;
      <D.19291>:
      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.19293>; else goto <D.19294>;
      <D.19293>:
      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.19279 = 0;
      return D.19279;
      <D.19294>:
      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.19296>; else goto <D.19297>;
      <D.19296>:
      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.19279 = 0;
      return D.19279;
      <D.19297>:
      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.19299>; else goto <D.19300>;
      <D.19299>:
      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.19279 = 0;
      return D.19279;
      <D.19300>:
      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.19302>; else goto <D.19303>;
      <D.19302>:
      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.19279 = 0;
      return D.19279;
      <D.19303>:
      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.19305>; else goto <D.19306>;
      <D.19305>:
      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.19279 = 0;
      return D.19279;
      <D.19306>:
      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.19308>; else goto <D.19309>;
      <D.19308>:
      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.19279 = 0;
      return D.19279;
      <D.19309>:
      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.19311>; else goto <D.19312>;
      <D.19311>:
      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.19279 = 0;
      return D.19279;
      <D.19312>:
      initialized = 1;
      D.19279 = 1;
      return D.19279;
    }
  finally
    {
      error_msg = {CLOBBER};
    }
}


cominterop_raise_hr_exception (int hr)
{
  struct MonoMethod * throw_exception_for_hr.15;
  struct MonoClass * D.19318;
  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.19316>; else goto <D.19317>;
      <D.19316>:
      D.19318 = mono_defaults.marshal_class;
      throw_exception_for_hr.16 = mono_class_get_method_from_name (D.19318, "GetExceptionForHR", 1);
      throw_exception_for_hr = throw_exception_for_hr.16;
      <D.19317>:
      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.19324;
  gboolean D.19325;
  unsigned int D.19326;
  struct MonoVTable * D.19327;
  struct MonoClass * D.19328;
  unsigned char D.19329;
  unsigned int dim.18;
  unsigned int D.19331;
  void * D.19332;
  unsigned int D.19333;
  _Bool D.19334;
  int D.19335;
  void * D.19338;
  unsigned int i.19;
  unsigned int D.19340;
  int * D.19341;
  unsigned int D.19342;
  struct SAFEARRAYBOUND * D.19343;
  struct MonoArrayBounds * D.19344;
  struct MonoArrayBounds * D.19345;
  int D.19346;
  int D.19347;
  unsigned int D.19348;
  unsigned int max_array_length.20;
  void * (*<T3346>) (int, guint32, struct SAFEARRAYBOUND *) safe_array_create_ms.21;
  unsigned int dim.22;
  void * D.19353;
  int dim;
  struct SAFEARRAYBOUND * bounds;
  int i;
  int max_array_length;

  com_provider.17 = com_provider;
  if (com_provider.17 != 1) goto <D.19320>; else goto <D.19323>;
  <D.19323>:
  D.19324 = init_com_provider_ms ();
  if (D.19324 == 0) goto <D.19320>; else goto <D.19321>;
  <D.19320>:
  D.19325 = 0;
  return D.19325;
  <D.19321>:
  D.19326 = mono_array_length (input);
  max_array_length = (int) D.19326;
  D.19327 = MEM[(struct MonoObject *)input].vtable;
  D.19328 = D.19327->klass;
  D.19329 = D.19328->rank;
  dim = (int) D.19329;
  dim.18 = (unsigned int) dim;
  D.19331 = dim.18 * 4;
  D.19332 = monoeg_malloc (D.19331);
  *indices = D.19332;
  dim.18 = (unsigned int) dim;
  D.19333 = dim.18 * 8;
  bounds = __builtin_alloca (D.19333);
  D.19334 = max_array_length == 0;
  D.19335 = (int) D.19334;
  MEM[(int *)empty] = D.19335;
  if (dim > 1) goto <D.19336>; else goto <D.19337>;
  <D.19336>:
  i = 0;
  goto <D.19152>;
  <D.19151>:
  D.19338 = *indices;
  i.19 = (unsigned int) i;
  D.19340 = i.19 * 4;
  D.19341 = D.19338 + D.19340;
  i.19 = (unsigned int) i;
  D.19342 = i.19 * 8;
  D.19343 = bounds + D.19342;
  D.19344 = input->bounds;
  i.19 = (unsigned int) i;
  D.19342 = i.19 * 8;
  D.19345 = D.19344 + D.19342;
  D.19346 = D.19345->lower_bound;
  D.19343->lLbound = D.19346;
  D.19347 = D.19343->lLbound;
  *D.19341 = D.19347;
  i.19 = (unsigned int) i;
  D.19342 = i.19 * 8;
  D.19343 = bounds + D.19342;
  D.19344 = input->bounds;
  i.19 = (unsigned int) i;
  D.19342 = i.19 * 8;
  D.19345 = D.19344 + D.19342;
  D.19348 = D.19345->length;
  D.19343->cElements = D.19348;
  i = i + 1;
  <D.19152>:
  if (i < dim) goto <D.19151>; else goto <D.19153>;
  <D.19153>:
  goto <D.19349>;
  <D.19337>:
  D.19338 = *indices;
  MEM[(int *)D.19338] = 0;
  max_array_length.20 = (unsigned int) max_array_length;
  bounds->cElements = max_array_length.20;
  bounds->lLbound = 0;
  <D.19349>:
  safe_array_create_ms.21 = safe_array_create_ms;
  dim.22 = (unsigned int) dim;
  D.19353 = safe_array_create_ms.21 (12, dim.22, bounds);
  *newsafearray = D.19353;
  D.19325 = 1;
  return D.19325;
}


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

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


mono_marshal_safearray_next (void * safearray, void * indices)
{
  unsigned int D.19362;
  int D.19363;
  unsigned int D.19364;
  unsigned int i.25;
  unsigned int D.19368;
  int * D.19369;
  int D.19370;
  int D.19371;
  long int ubound.26;
  long int lbound.27;
  gboolean D.19379;
  int i;
  int dim;
  gboolean ret;
  int * pIndices;
  int hr;

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

    try
      {
        D.19363 = i + 1;
        D.19364 = (unsigned int) D.19363;
        hr = mono_marshal_safe_array_get_ubound (safearray, D.19364, &ubound);
        if (hr < 0) goto <D.19365>; else goto <D.19366>;
        <D.19365>:
        cominterop_raise_hr_exception (hr);
        <D.19366>:
        i.25 = (unsigned int) i;
        D.19368 = i.25 * 4;
        D.19369 = pIndices + D.19368;
        D.19370 = *D.19369;
        D.19371 = D.19370 + 1;
        *D.19369 = D.19371;
        D.19370 = *D.19369;
        ubound.26 = ubound;
        if (D.19370 <= ubound.26) goto <D.19134>; else goto <D.19373>;
        <D.19373>:
        D.19363 = i + 1;
        D.19364 = (unsigned int) D.19363;
        hr = mono_marshal_safe_array_get_lbound (safearray, D.19364, &lbound);
        if (hr < 0) goto <D.19374>; else goto <D.19375>;
        <D.19374>:
        cominterop_raise_hr_exception (hr);
        <D.19375>:
        i.25 = (unsigned int) i;
        D.19368 = i.25 * 4;
        D.19369 = pIndices + D.19368;
        lbound.27 = lbound;
        *D.19369 = lbound.27;
        if (i == 0) goto <D.19377>; else goto <D.19378>;
        <D.19377>:
        ret = 0;
        <D.19378>:
      }
    finally
      {
        lbound = {CLOBBER};
        ubound = {CLOBBER};
      }
  }
  i = i + -1;
  <D.19136>:
  if (i >= 0) goto <D.19135>; else goto <D.19134>;
  <D.19134>:
  D.19379 = ret;
  return D.19379;
}


mono_marshal_safearray_get_dim (void * safearray)
{
  <unnamed type> com_provider.28;
  int D.19387;
  guint32 (*<T176b>) (void *) safe_array_get_dim_ms.29;
  guint32 D.19390;
  guint32 result;

  result = 0;
  com_provider.28 = com_provider;
  if (com_provider.28 == 1) goto <D.19386>; else goto <D.19383>;
  <D.19386>:
  D.19387 = init_com_provider_ms ();
  if (D.19387 != 0) goto <D.19388>; else goto <D.19383>;
  <D.19388>:
  safe_array_get_dim_ms.29 = safe_array_get_dim_ms;
  result = safe_array_get_dim_ms.29 (safearray);
  goto <D.19384>;
  <D.19383>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2914);
  <D.19384>:
  D.19390 = result;
  return D.19390;
}


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

  result = 0;
  com_provider.30 = com_provider;
  if (com_provider.30 == 1) goto <D.19395>; else goto <D.19392>;
  <D.19395>:
  D.19396 = init_com_provider_ms ();
  if (D.19396 != 0) goto <D.19397>; else goto <D.19392>;
  <D.19397>:
  safe_array_get_ubound_ms.31 = safe_array_get_ubound_ms;
  result = safe_array_get_ubound_ms.31 (psa, nDim, plUbound);
  goto <D.19393>;
  <D.19392>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2946);
  <D.19393>:
  D.19399 = result;
  return D.19399;
}


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

  result = 0;
  com_provider.32 = com_provider;
  if (com_provider.32 == 1) goto <D.19404>; else goto <D.19401>;
  <D.19404>:
  D.19405 = init_com_provider_ms ();
  if (D.19405 != 0) goto <D.19406>; else goto <D.19401>;
  <D.19406>:
  safe_array_get_lbound_ms.33 = safe_array_get_lbound_ms;
  result = safe_array_get_lbound_ms.33 (psa, nDim, plLbound);
  goto <D.19402>;
  <D.19401>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2930);
  <D.19402>:
  D.19408 = result;
  return D.19408;
}


mono_marshal_safearray_get_value (void * safearray, void * indices)
{
  <unnamed type> com_provider.34;
  int D.19414;
  int (*<T333a>) (void *, glong *, void * *) safe_array_ptr_of_index_ms.35;
  void * D.19419;
  void * result;

  try
    {
      com_provider.34 = com_provider;
      if (com_provider.34 == 1) goto <D.19413>; else goto <D.19410>;
      <D.19413>:
      D.19414 = init_com_provider_ms ();
      if (D.19414 != 0) goto <D.19415>; else goto <D.19410>;
      <D.19415>:
      {
        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.19417>; else goto <D.19418>;
        <D.19417>:
        cominterop_raise_hr_exception (hr);
        <D.19418>:
      }
      goto <D.19411>;
      <D.19410>:
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3038);
      <D.19411>:
      D.19419 = result;
      return D.19419;
    }
  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.19426;
  gboolean D.19427;
  unsigned int D.19430;
  unsigned int dim.37;
  unsigned int D.19434;
  void * D.19435;
  int D.19436;
  unsigned int D.19437;
  long int lbound.38;
  long int ubound.39;
  long int D.19446;
  unsigned int i.40;
  unsigned int D.19448;
  uintptr_t * D.19449;
  unsigned int cursize.41;
  intptr_t * D.19451;
  void * D.19452;
  int * D.19453;
  unsigned int dim.42;
  struct MonoClass * D.19459;
  struct MonoDomain * D.19460;
  struct MonoArray * D.19461;
  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.19422>; else goto <D.19425>;
  <D.19425>:
  D.19426 = init_com_provider_ms ();
  if (D.19426 == 0) goto <D.19422>; else goto <D.19423>;
  <D.19422>:
  D.19427 = 0;
  return D.19427;
  <D.19423>:
  MEM[(int *)empty] = 1;
  if (safearray != 0B) goto <D.19428>; else goto <D.19429>;
  <D.19428>:
  D.19430 = mono_marshal_safearray_get_dim (safearray);
  dim = (int) D.19430;
  if (dim > 0) goto <D.19431>; else goto <D.19432>;
  <D.19431>:
  dim.37 = (unsigned int) dim;
  D.19434 = dim.37 * 4;
  D.19435 = monoeg_malloc (D.19434);
  *indices = D.19435;
  dim.37 = (unsigned int) dim;
  D.19434 = dim.37 * 4;
  sizes = __builtin_alloca (D.19434);
  dim.37 = (unsigned int) dim;
  D.19434 = dim.37 * 4;
  bounds = __builtin_alloca (D.19434);
  i = 0;
  goto <D.19115>;
  <D.19114>:
  {
    glong lbound;
    glong ubound;
    int cursize;
    int hr;

    try
      {
        D.19436 = i + 1;
        D.19437 = (unsigned int) D.19436;
        hr = mono_marshal_safe_array_get_lbound (safearray, D.19437, &lbound);
        if (hr < 0) goto <D.19438>; else goto <D.19439>;
        <D.19438>:
        cominterop_raise_hr_exception (hr);
        <D.19439>:
        lbound.38 = lbound;
        if (lbound.38 != 0) goto <D.19441>; else goto <D.19442>;
        <D.19441>:
        bounded = 1;
        <D.19442>:
        D.19436 = i + 1;
        D.19437 = (unsigned int) D.19436;
        hr = mono_marshal_safe_array_get_ubound (safearray, D.19437, &ubound);
        if (hr < 0) goto <D.19443>; else goto <D.19444>;
        <D.19443>:
        cominterop_raise_hr_exception (hr);
        <D.19444>:
        ubound.39 = ubound;
        lbound.38 = lbound;
        D.19446 = ubound.39 - lbound.38;
        cursize = D.19446 + 1;
        i.40 = (unsigned int) i;
        D.19448 = i.40 * 4;
        D.19449 = sizes + D.19448;
        cursize.41 = (unsigned int) cursize;
        *D.19449 = cursize.41;
        i.40 = (unsigned int) i;
        D.19448 = i.40 * 4;
        D.19451 = bounds + D.19448;
        lbound.38 = lbound;
        *D.19451 = lbound.38;
        D.19452 = *indices;
        i.40 = (unsigned int) i;
        D.19448 = i.40 * 4;
        D.19453 = D.19452 + D.19448;
        lbound.38 = lbound;
        *D.19453 = lbound.38;
        if (cursize != 0) goto <D.19454>; else goto <D.19455>;
        <D.19454>:
        MEM[(int *)empty] = 0;
        <D.19455>:
      }
    finally
      {
        lbound = {CLOBBER};
        ubound = {CLOBBER};
      }
  }
  i = i + 1;
  <D.19115>:
  if (i < dim) goto <D.19114>; else goto <D.19116>;
  <D.19116>:
  if (allocateNewArray != 0) goto <D.19456>; else goto <D.19457>;
  <D.19456>:
  dim.42 = (unsigned int) dim;
  D.19459 = mono_defaults.object_class;
  aklass = mono_bounded_array_class_get (D.19459, dim.42, bounded);
  D.19460 = mono_domain_get ();
  D.19461 = mono_array_new_full (D.19460, aklass, sizes, bounds);
  *result = D.19461;
  goto <D.19462>;
  <D.19457>:
  *result = parameter;
  <D.19462>:
  <D.19432>:
  <D.19429>:
  D.19427 = 1;
  return D.19427;
}


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

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


cominterop_get_interface (struct MonoComObject * obj, struct MonoClass * ic, gboolean throw_exception)
{
  _Bool D.19466;
  long int D.19467;
  long int D.19468;
  int iftmp.43;
  unsigned int D.19474;
  unsigned int D.19475;
  unsigned char D.19477;
  _Bool D.19480;
  long int D.19481;
  long int D.19482;
  _Bool D.19487;
  long int D.19488;
  long int D.19489;
  struct GHashTable * D.19492;
  short unsigned int D.19495;
  unsigned int D.19496;
  const void * D.19497;
  void * itf.44;
  _Bool D.19501;
  long int D.19502;
  long int D.19503;
  void * itf.45;
  _Bool D.19509;
  long int D.19510;
  long int D.19511;
  void * D.19514;
  _Bool D.19515;
  _Bool D.19516;
  _Bool D.19517;
  _Bool D.19526;
  long int D.19527;
  long int D.19528;
  struct GHashTable * D.19533;
  void * D.19534;
  _Bool D.19537;
  long int D.19538;
  long int D.19539;
  _Bool D.19544;
  long int D.19545;
  long int D.19546;
  void * D.19549;
  void * itf;

  try
    {
      itf = 0B;
      D.19466 = ic == 0B;
      D.19467 = (long int) D.19466;
      D.19468 = __builtin_expect (D.19467, 0);
      if (D.19468 != 0) goto <D.19469>; else goto <D.19470>;
      <D.19469>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 473, "ic");
      <D.19470>:
      D.19474 = ic->flags;
      D.19475 = D.19474 & 32;
      if (D.19475 == 0) goto <D.19476>; else goto <D.19472>;
      <D.19476>:
      D.19477 = ic->byval_arg.type;
      if (D.19477 != 19) goto <D.19478>; else goto <D.19472>;
      <D.19478>:
      D.19477 = ic->byval_arg.type;
      if (D.19477 != 30) goto <D.19479>; else goto <D.19472>;
      <D.19479>:
      iftmp.43 = 1;
      goto <D.19473>;
      <D.19472>:
      iftmp.43 = 0;
      <D.19473>:
      D.19480 = iftmp.43 != 0;
      D.19481 = (long int) D.19480;
      D.19482 = __builtin_expect (D.19481, 0);
      if (D.19482 != 0) goto <D.19483>; else goto <D.19484>;
      <D.19483>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 474, "MONO_CLASS_IS_INTERFACE (ic)");
      <D.19484>:
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19485>; else goto <D.19486>;
        <D.19485>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.19486>:
        D.19487 = ret != 0;
        D.19488 = (long int) D.19487;
        D.19489 = __builtin_expect (D.19488, 0);
        if (D.19489 != 0) goto <D.19490>; else goto <D.19491>;
        <D.19490>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 476, "ret == 0");
        <D.19491>:
      }
      D.19492 = obj->itf_hash;
      if (D.19492 != 0B) goto <D.19493>; else goto <D.19494>;
      <D.19493>:
      D.19495 = ic->interface_id;
      D.19496 = (unsigned int) D.19495;
      D.19497 = (const void *) D.19496;
      D.19492 = obj->itf_hash;
      itf.44 = monoeg_g_hash_table_lookup (D.19492, D.19497);
      itf = itf.44;
      <D.19494>:
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19499>; else goto <D.19500>;
        <D.19499>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.19500>:
        D.19501 = ret != 0;
        D.19502 = (long int) D.19501;
        D.19503 = __builtin_expect (D.19502, 0);
        if (D.19503 != 0) goto <D.19504>; else goto <D.19505>;
        <D.19504>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 479, "ret == 0");
        <D.19505>:
      }
      itf.45 = itf;
      if (itf.45 == 0B) goto <D.19507>; else goto <D.19508>;
      <D.19507>:
      {
        guint8 iid[16];
        int found;
        int hr;

        try
          {
            found = cominterop_class_guid (ic, &iid);
            D.19509 = found == 0;
            D.19510 = (long int) D.19509;
            D.19511 = __builtin_expect (D.19510, 0);
            if (D.19511 != 0) goto <D.19512>; else goto <D.19513>;
            <D.19512>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 485, "found");
            <D.19513>:
            D.19514 = obj->iunknown;
            hr = ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (D.19514, &iid, &itf);
            D.19515 = hr < 0;
            D.19516 = throw_exception != 0;
            D.19517 = D.19515 & D.19516;
            if (D.19517 != 0) goto <D.19518>; else goto <D.19519>;
            <D.19518>:
            cominterop_raise_hr_exception (hr);
            <D.19519>:
            if (hr >= 0) goto <D.19520>; else goto <D.19521>;
            <D.19520>:
            itf.45 = itf;
            if (itf.45 != 0B) goto <D.19522>; else goto <D.19523>;
            <D.19522>:
            {
              int ret;

              ret = pthread_mutex_lock (&cominterop_mutex.mutex);
              if (ret != 0) goto <D.19524>; else goto <D.19525>;
              <D.19524>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
              <D.19525>:
              D.19526 = ret != 0;
              D.19527 = (long int) D.19526;
              D.19528 = __builtin_expect (D.19527, 0);
              if (D.19528 != 0) goto <D.19529>; else goto <D.19530>;
              <D.19529>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 492, "ret == 0");
              <D.19530>:
            }
            D.19492 = obj->itf_hash;
            if (D.19492 == 0B) goto <D.19531>; else goto <D.19532>;
            <D.19531>:
            D.19533 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
            obj->itf_hash = D.19533;
            <D.19532>:
            itf.45 = itf;
            D.19495 = ic->interface_id;
            D.19496 = (unsigned int) D.19495;
            D.19534 = (void *) D.19496;
            D.19492 = obj->itf_hash;
            monoeg_g_hash_table_insert_replace (D.19492, D.19534, itf.45, 0);
            {
              int ret;

              ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
              if (ret != 0) goto <D.19535>; else goto <D.19536>;
              <D.19535>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
              <D.19536>:
              D.19537 = ret != 0;
              D.19538 = (long int) D.19537;
              D.19539 = __builtin_expect (D.19538, 0);
              if (D.19539 != 0) goto <D.19540>; else goto <D.19541>;
              <D.19540>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 496, "ret == 0");
              <D.19541>:
            }
            <D.19523>:
            <D.19521>:
          }
        finally
          {
            iid = {CLOBBER};
          }
      }
      <D.19508>:
      if (throw_exception != 0) goto <D.19542>; else goto <D.19543>;
      <D.19542>:
      itf.45 = itf;
      D.19544 = itf.45 == 0B;
      D.19545 = (long int) D.19544;
      D.19546 = __builtin_expect (D.19545, 0);
      if (D.19546 != 0) goto <D.19547>; else goto <D.19548>;
      <D.19547>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 501, "itf");
      <D.19548>:
      <D.19543>:
      D.19549 = itf;
      return D.19549;
    }
  finally
    {
      itf = {CLOBBER};
    }
}


cominterop_class_guid (struct MonoClass * klass, guint8 * guid)
{
  struct MonoClass * GuidAttribute.46;
  struct MonoImage * D.19555;
  struct MonoClass * GuidAttribute.47;
  gboolean D.19561;
  int D.19562;
  struct MonoString * D.19565;
  static struct MonoClass * GuidAttribute = 0B;
  struct MonoCustomAttrInfo * cinfo;

  GuidAttribute.46 = GuidAttribute;
  if (GuidAttribute.46 == 0B) goto <D.19553>; else goto <D.19554>;
  <D.19553>:
  D.19555 = mono_defaults.corlib;
  GuidAttribute.47 = mono_class_from_name (D.19555, "System.Runtime.InteropServices", "GuidAttribute");
  GuidAttribute = GuidAttribute.47;
  <D.19554>:
  cinfo = mono_custom_attrs_from_class (klass);
  if (cinfo != 0B) goto <D.19557>; else goto <D.19558>;
  <D.19557>:
  {
    struct MonoReflectionGuidAttribute * attr;

    GuidAttribute.46 = GuidAttribute;
    attr = mono_custom_attrs_get_attr (cinfo, GuidAttribute.46);
    if (attr == 0B) goto <D.19559>; else goto <D.19560>;
    <D.19559>:
    D.19561 = 0;
    return D.19561;
    <D.19560>:
    D.19562 = cinfo->cached;
    if (D.19562 == 0) goto <D.19563>; else goto <D.19564>;
    <D.19563>:
    mono_custom_attrs_free (cinfo);
    <D.19564>:
    D.19565 = attr->guid;
    cominterop_mono_string_to_guid (D.19565, guid);
    D.19561 = 1;
    return D.19561;
  }
  <D.19558>:
  D.19561 = 0;
  return D.19561;
}


cominterop_mono_string_to_guid (struct MonoString * string, guint8 * guid)
{
  sizetype i.48;
  guint8 * D.19568;
  unsigned char D.19569;
  unsigned int D.19570;
  unsigned int D.19571;
  gunichar2 * D.19572;
  short unsigned int D.19573;
  unsigned int D.19574;
  int D.19575;
  unsigned char D.19576;
  sizetype D.19577;
  sizetype D.19578;
  sizetype D.19579;
  gunichar2 * D.19580;
  short unsigned int D.19581;
  unsigned int D.19582;
  int D.19583;
  unsigned char D.19584;
  unsigned char D.19585;
  unsigned char D.19586;
  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.18894>;
  <D.18893>:
  i.48 = (sizetype) i;
  D.19568 = guid + i.48;
  D.19569 = indexes[i];
  D.19570 = (unsigned int) D.19569;
  D.19571 = D.19570 * 2;
  D.19572 = chars + D.19571;
  D.19573 = *D.19572;
  D.19574 = (unsigned int) D.19573;
  D.19575 = monoeg_g_unichar_xdigit_value (D.19574);
  D.19576 = (unsigned char) D.19575;
  D.19569 = indexes[i];
  D.19577 = (sizetype) D.19569;
  D.19578 = D.19577 + 2147483647;
  D.19579 = D.19578 * 2;
  D.19580 = chars + D.19579;
  D.19581 = *D.19580;
  D.19582 = (unsigned int) D.19581;
  D.19583 = monoeg_g_unichar_xdigit_value (D.19582);
  D.19584 = (unsigned char) D.19583;
  D.19585 = D.19584 << 4;
  D.19586 = D.19576 + D.19585;
  *D.19568 = D.19586;
  i = i + 1;
  <D.18894>:
  i.49 = (unsigned int) i;
  if (i.49 <= 15) goto <D.18893>; else goto <D.18895>;
  <D.18895>:
}


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

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


cominterop_get_ccw_object (struct MonoCCWInterface * ccw_entry, gboolean verify)
{
  struct GHashTable * ccw_interface_hash.50;
  struct MonoObject * D.19593;
  _Bool D.19597;
  long int D.19598;
  long int D.19599;
  unsigned int D.19604;
  struct MonoCCW * ccw;

  ccw = 0B;
  ccw_interface_hash.50 = ccw_interface_hash;
  if (ccw_interface_hash.50 == 0B) goto <D.19591>; else goto <D.19592>;
  <D.19591>:
  D.19593 = 0B;
  return D.19593;
  <D.19592>:
  if (verify != 0) goto <D.19594>; else goto <D.19595>;
  <D.19594>:
  ccw_interface_hash.50 = ccw_interface_hash;
  ccw = monoeg_g_hash_table_lookup (ccw_interface_hash.50, ccw_entry);
  goto <D.19596>;
  <D.19595>:
  ccw = ccw_entry->ccw;
  D.19597 = ccw == 0B;
  D.19598 = (long int) D.19597;
  D.19599 = __builtin_expect (D.19598, 0);
  if (D.19599 != 0) goto <D.19600>; else goto <D.19601>;
  <D.19600>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1764, "ccw");
  <D.19601>:
  <D.19596>:
  if (ccw != 0B) goto <D.19602>; else goto <D.19603>;
  <D.19602>:
  D.19604 = ccw->gc_handle;
  D.19593 = mono_gchandle_get_target (D.19604);
  return D.19593;
  <D.19603>:
  D.19593 = 0B;
  return D.19593;
}


cominterop_get_ccw (struct MonoObject * object, struct MonoClass * itf)
{
  void * D.19608;
  _Bool D.19611;
  long int D.19612;
  long int D.19613;
  struct GHashTable * ccw_hash.51;
  struct GHashTable * ccw_hash.52;
  struct GHashTable * ccw_interface_hash.53;
  struct GHashTable * ccw_interface_hash.54;
  int D.19624;
  const void * D.19625;
  _Bool D.19628;
  long int D.19629;
  long int D.19630;
  unsigned int D.19633;
  struct MonoObject * D.19634;
  struct GList * iftmp.55;
  void * D.19641;
  void * D.19644;
  struct GHashTable * D.19649;
  unsigned int D.19650;
  _Bool D.19656;
  long int D.19657;
  long int D.19658;
  int D.19661;
  void * D.19662;
  _Bool D.19665;
  long int D.19666;
  long int D.19667;
  struct MonoClass * coclass_attribute.56;
  struct MonoImage * D.19675;
  struct MonoClass * coclass_attribute.57;
  int D.19677;
  int iftmp.58;
  short unsigned int D.19684;
  struct MonoClass * * D.19686;
  struct MonoClass * D.19687;
  _Bool D.19688;
  long int D.19689;
  long int D.19690;
  int D.19693;
  struct MonoClass * D.19696;
  struct MonoClass * D.19700;
  unsigned int D.19704;
  unsigned int method_count.59;
  unsigned int D.19706;
  struct GHashTable * D.19707;
  int D.19710;
  int D.19711;
  unsigned int D.19712;
  unsigned int D.19713;
  struct MonoImage * D.19714;
  void * * D.19717;
  unsigned int D.19718;
  struct MonoMethod * * D.19719;
  unsigned int i.60;
  unsigned int D.19721;
  struct MonoMethod * * D.19722;
  short unsigned int D.19723;
  int D.19724;
  const char * D.19725;
  short unsigned int D.19726;
  int D.19727;
  int D.19728;
  unsigned int D.19729;
  unsigned int D.19730;
  short unsigned int D.19731;
  unsigned int mspec_index.61;
  unsigned int D.19733;
  struct MonoMarshalSpec * * D.19734;
  unsigned int param_index.62;
  unsigned int D.19736;
  struct MonoMarshalSpec * * D.19737;
  struct MonoMarshalSpec * D.19738;
  struct MonoMarshalSpec * D.19739;
  struct MonoType * D.19742;
  unsigned char D.19743;
  void * D.19746;
  void * D.19750;
  void * D.19754;
  void * D.19758;
  unsigned char D.19760;
  _Bool D.19761;
  _Bool D.19762;
  _Bool D.19763;
  short int D.19766;
  short int D.19769;
  unsigned short D.19770;
  unsigned short D.19771;
  short int D.19772;
  struct MonoMarshalSpec * * D.19773;
  struct MonoType * D.19776;
  int D.19777;
  struct MonoMarshalSpec * D.19780;
  int D.19783;
  struct MonoType * D.19784;
  unsigned char D.19785;
  void * D.19788;
  void * D.19792;
  void * D.19796;
  void * D.19800;
  unsigned int D.19801;
  unsigned int D.19802;
  struct MonoMarshalSpec * * D.19803;
  _Bool D.19806;
  long int D.19807;
  long int D.19808;
  struct MonoMethodSignature * D.19811;
  short unsigned int D.19812;
  int D.19813;
  int D.19814;
  _Bool D.19817;
  long int D.19818;
  long int D.19819;
  int vtable_index.63;
  unsigned int vtable_index.64;
  unsigned int D.19824;
  void * * D.19825;
  void * D.19826;
  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.19606>; else goto <D.19607>;
      <D.19606>:
      D.19608 = 0B;
      return D.19608;
      <D.19607>:
      klass = mono_object_get_class (object);
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19609>; else goto <D.19610>;
        <D.19609>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.19610>:
        D.19611 = ret != 0;
        D.19612 = (long int) D.19611;
        D.19613 = __builtin_expect (D.19612, 0);
        if (D.19613 != 0) goto <D.19614>; else goto <D.19615>;
        <D.19614>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1828, "ret == 0");
        <D.19615>:
      }
      ccw_hash.51 = ccw_hash;
      if (ccw_hash.51 == 0B) goto <D.19617>; else goto <D.19618>;
      <D.19617>:
      ccw_hash.52 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw_hash = ccw_hash.52;
      <D.19618>:
      ccw_interface_hash.53 = ccw_interface_hash;
      if (ccw_interface_hash.53 == 0B) goto <D.19621>; else goto <D.19622>;
      <D.19621>:
      ccw_interface_hash.54 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw_interface_hash = ccw_interface_hash.54;
      <D.19622>:
      D.19624 = mono_object_hash (object);
      D.19625 = (const void *) D.19624;
      ccw_hash.51 = ccw_hash;
      ccw_list = monoeg_g_hash_table_lookup (ccw_hash.51, D.19625);
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19626>; else goto <D.19627>;
        <D.19626>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.19627>:
        D.19628 = ret != 0;
        D.19629 = (long int) D.19628;
        D.19630 = __builtin_expect (D.19629, 0);
        if (D.19630 != 0) goto <D.19631>; else goto <D.19632>;
        <D.19631>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1835, "ret == 0");
        <D.19632>:
      }
      ccw_list_item = ccw_list;
      goto <D.18816>;
      <D.18815>:
      {
        struct MonoCCW * ccw_iter;

        ccw_iter = ccw_list_item->data;
        D.19633 = ccw_iter->gc_handle;
        D.19634 = mono_gchandle_get_target (D.19633);
        if (D.19634 == object) goto <D.19635>; else goto <D.19636>;
        <D.19635>:
        ccw = ccw_iter;
        goto <D.18814>;
        <D.19636>:
        if (ccw_list_item != 0B) goto <D.19638>; else goto <D.19639>;
        <D.19638>:
        iftmp.55 = ccw_list_item->next;
        goto <D.19640>;
        <D.19639>:
        iftmp.55 = 0B;
        <D.19640>:
        ccw_list_item = iftmp.55;
      }
      <D.18816>:
      if (ccw_list_item != 0B) goto <D.18815>; else goto <D.18814>;
      <D.18814>:
      D.19641 = iunknown[0];
      if (D.19641 == 0B) goto <D.19642>; else goto <D.19643>;
      <D.19642>:
      iunknown[0] = cominterop_ccw_queryinterface;
      iunknown[1] = cominterop_ccw_addref;
      iunknown[2] = cominterop_ccw_release;
      <D.19643>:
      D.19644 = idispatch[0];
      if (D.19644 == 0B) goto <D.19645>; else goto <D.19646>;
      <D.19645>:
      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.19646>:
      if (ccw == 0B) goto <D.19647>; else goto <D.19648>;
      <D.19647>:
      ccw = monoeg_malloc0 (12);
      D.19649 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw->vtable_hash = D.19649;
      ccw->ref_count = 0;
      D.19650 = mono_gchandle_new_weakref (object, 0);
      ccw->gc_handle = D.19650;
      if (ccw_list == 0B) goto <D.19651>; else goto <D.19652>;
      <D.19651>:
      ccw_list = monoeg_g_list_alloc ();
      ccw_list->data = ccw;
      goto <D.19653>;
      <D.19652>:
      ccw_list = monoeg_g_list_append (ccw_list, ccw);
      <D.19653>:
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19654>; else goto <D.19655>;
        <D.19654>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.19655>:
        D.19656 = ret != 0;
        D.19657 = (long int) D.19656;
        D.19658 = __builtin_expect (D.19657, 0);
        if (D.19658 != 0) goto <D.19659>; else goto <D.19660>;
        <D.19659>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1876, "ret == 0");
        <D.19660>:
      }
      D.19661 = mono_object_hash (object);
      D.19662 = (void *) D.19661;
      ccw_hash.51 = ccw_hash;
      monoeg_g_hash_table_insert_replace (ccw_hash.51, D.19662, ccw_list, 0);
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19663>; else goto <D.19664>;
        <D.19663>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.19664>:
        D.19665 = ret != 0;
        D.19666 = (long int) D.19665;
        D.19667 = __builtin_expect (D.19666, 0);
        if (D.19667 != 0) goto <D.19668>; else goto <D.19669>;
        <D.19668>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1878, "ret == 0");
        <D.19669>:
      }
      mono_object_register_finalizer (object);
      <D.19648>:
      cinfo = mono_custom_attrs_from_class (itf);
      if (cinfo != 0B) goto <D.19670>; else goto <D.19671>;
      <D.19670>:
      {
        static struct MonoClass * coclass_attribute = 0B;

        coclass_attribute.56 = coclass_attribute;
        if (coclass_attribute.56 == 0B) goto <D.19673>; else goto <D.19674>;
        <D.19673>:
        D.19675 = mono_defaults.corlib;
        coclass_attribute.57 = mono_class_from_name (D.19675, "System.Runtime.InteropServices", "CoClassAttribute");
        coclass_attribute = coclass_attribute.57;
        <D.19674>:
        coclass_attribute.56 = coclass_attribute;
        D.19677 = mono_custom_attrs_has_attr (cinfo, coclass_attribute.56);
        if (D.19677 != 0) goto <D.19678>; else goto <D.19679>;
        <D.19678>:
        D.19684 = itf->interface_count;
        if (D.19684 == 0) goto <D.19681>; else goto <D.19685>;
        <D.19685>:
        D.19686 = itf->interfaces;
        D.19687 = *D.19686;
        if (D.19687 == 0B) goto <D.19681>; else goto <D.19682>;
        <D.19681>:
        iftmp.58 = 1;
        goto <D.19683>;
        <D.19682>:
        iftmp.58 = 0;
        <D.19683>:
        D.19688 = iftmp.58 != 0;
        D.19689 = (long int) D.19688;
        D.19690 = __builtin_expect (D.19689, 0);
        if (D.19690 != 0) goto <D.19691>; else goto <D.19692>;
        <D.19691>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1889, "itf->interface_count && itf->interfaces[0]");
        <D.19692>:
        D.19686 = itf->interfaces;
        itf = *D.19686;
        <D.19679>:
        D.19693 = cinfo->cached;
        if (D.19693 == 0) goto <D.19694>; else goto <D.19695>;
        <D.19694>:
        mono_custom_attrs_free (cinfo);
        <D.19695>:
      }
      <D.19671>:
      iface = itf;
      D.19696 = mono_class_get_iunknown_class ();
      if (D.19696 == iface) goto <D.19697>; else goto <D.19698>;
      <D.19697>:
      start_slot = 3;
      goto <D.19699>;
      <D.19698>:
      D.19700 = mono_class_get_idispatch_class ();
      if (D.19700 == iface) goto <D.19701>; else goto <D.19702>;
      <D.19701>:
      start_slot = 7;
      goto <D.19703>;
      <D.19702>:
      D.19704 = iface->method.count;
      method_count.59 = (unsigned int) method_count;
      D.19706 = D.19704 + method_count.59;
      method_count = (int) D.19706;
      start_slot = cominterop_get_com_slot_begin (iface);
      iface = 0B;
      <D.19703>:
      <D.19699>:
      D.19707 = ccw->vtable_hash;
      ccw_entry = monoeg_g_hash_table_lookup (D.19707, itf);
      if (ccw_entry == 0B) goto <D.19708>; else goto <D.19709>;
      <D.19708>:
      {
        int vtable_index;

        D.19710 = method_count + -1;
        vtable_index = D.19710 + start_slot;
        D.19711 = method_count + start_slot;
        D.19712 = (unsigned int) D.19711;
        D.19713 = D.19712 * 4;
        D.19714 = klass->image;
        vtable = mono_image_alloc0 (D.19714, D.19713);
        memcpy (vtable, &iunknown, 12);
        if (start_slot == 7) goto <D.19715>; else goto <D.19716>;
        <D.19715>:
        D.19717 = vtable + 12;
        memcpy (D.19717, &idispatch, 16);
        <D.19716>:
        iface = itf;
        D.19704 = iface->method.count;
        D.19718 = D.19704 + 4294967295;
        i = (int) D.19718;
        goto <D.18840>;
        <D.18839>:
        {
          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.19719 = iface->methods;
          i.60 = (unsigned int) i;
          D.19721 = i.60 * 4;
          D.19722 = D.19719 + D.19721;
          method = *D.19722;
          sig = mono_method_signature (method);
          D.19723 = method->iflags;
          D.19724 = (int) D.19723;
          preserve_sig = D.19724 & 128;
          D.19725 = method->name;
          mb = mono_mb_new (iface, D.19725, 5);
          adjust_method = cominterop_get_managed_wrapper_adjusted (method);
          sig_adjusted = mono_method_signature (adjust_method);
          D.19726 = sig_adjusted->param_count;
          D.19727 = (int) D.19726;
          D.19728 = D.19727 + 1;
          D.19729 = (unsigned int) D.19728;
          D.19730 = D.19729 * 4;
          mspecs = monoeg_malloc (D.19730);
          mono_method_get_marshal_info (method, mspecs);
          D.19731 = sig->param_count;
          param_index = (int) D.19731;
          goto <D.18832>;
          <D.18831>:
          {
            int mspec_index;

            mspec_index = param_index + 1;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            param_index.62 = (unsigned int) param_index;
            D.19736 = param_index.62 * 4;
            D.19737 = mspecs + D.19736;
            D.19738 = *D.19737;
            *D.19734 = D.19738;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19739 = *D.19734;
            if (D.19739 == 0B) goto <D.19740>; else goto <D.19741>;
            <D.19740>:
            D.19742 = sig_adjusted->params[param_index];
            D.19743 = D.19742->type;
            if (D.19743 == 28) goto <D.19744>; else goto <D.19745>;
            <D.19744>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19746 = monoeg_malloc0 (16);
            *D.19734 = D.19746;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19739 = *D.19734;
            D.19739->native = 27;
            goto <D.19747>;
            <D.19745>:
            D.19742 = sig_adjusted->params[param_index];
            D.19743 = D.19742->type;
            if (D.19743 == 14) goto <D.19748>; else goto <D.19749>;
            <D.19748>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19750 = monoeg_malloc0 (16);
            *D.19734 = D.19750;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19739 = *D.19734;
            D.19739->native = 19;
            goto <D.19751>;
            <D.19749>:
            D.19742 = sig_adjusted->params[param_index];
            D.19743 = D.19742->type;
            if (D.19743 == 18) goto <D.19752>; else goto <D.19753>;
            <D.19752>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19754 = monoeg_malloc0 (16);
            *D.19734 = D.19754;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19739 = *D.19734;
            D.19739->native = 28;
            goto <D.19755>;
            <D.19753>:
            D.19742 = sig_adjusted->params[param_index];
            D.19743 = D.19742->type;
            if (D.19743 == 2) goto <D.19756>; else goto <D.19757>;
            <D.19756>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19758 = monoeg_malloc0 (16);
            *D.19734 = D.19758;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19739 = *D.19734;
            D.19739->native = 37;
            <D.19757>:
            <D.19755>:
            <D.19751>:
            <D.19747>:
            goto <D.19759>;
            <D.19741>:
            D.19742 = sig_adjusted->params[param_index];
            D.19760 = D.19742->type;
            D.19761 = D.19760 == 20;
            D.19762 = D.19760 == 29;
            D.19763 = D.19761 | D.19762;
            if (D.19763 != 0) goto <D.19764>; else goto <D.19765>;
            <D.19764>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19739 = *D.19734;
            D.19766 = D.19739->data.array_data.param_num;
            if (D.19766 != -1) goto <D.19767>; else goto <D.19768>;
            <D.19767>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19733 = mspec_index.61 * 4;
            D.19734 = mspecs + D.19733;
            D.19739 = *D.19734;
            D.19766 = D.19739->data.array_data.param_num;
            D.19769 = D.19766;
            D.19770 = (unsigned short) D.19769;
            D.19771 = D.19770 + 1;
            D.19772 = (short int) D.19771;
            D.19739->data.array_data.param_num = D.19772;
            <D.19768>:
            <D.19765>:
            <D.19759>:
          }
          param_index = param_index + -1;
          <D.18832>:
          if (param_index > 0) goto <D.18831>; else goto <D.18833>;
          <D.18833>:
          D.19773 = mspecs + 4;
          *D.19773 = 0B;
          if (preserve_sig == 0) goto <D.19774>; else goto <D.19775>;
          <D.19774>:
          D.19776 = sig->ret;
          D.19777 = mono_type_is_void (D.19776);
          if (D.19777 == 0) goto <D.19778>; else goto <D.19779>;
          <D.19778>:
          D.19780 = *mspecs;
          if (D.19780 == 0B) goto <D.19781>; else goto <D.19782>;
          <D.19781>:
          D.19726 = sig_adjusted->param_count;
          D.19727 = (int) D.19726;
          D.19783 = D.19727 + -1;
          D.19784 = sig_adjusted->params[D.19783];
          D.19785 = D.19784->type;
          if (D.19785 == 28) goto <D.19786>; else goto <D.19787>;
          <D.19786>:
          D.19788 = monoeg_malloc0 (16);
          *mspecs = D.19788;
          D.19780 = *mspecs;
          D.19780->native = 27;
          goto <D.19789>;
          <D.19787>:
          D.19726 = sig_adjusted->param_count;
          D.19727 = (int) D.19726;
          D.19783 = D.19727 + -1;
          D.19784 = sig_adjusted->params[D.19783];
          D.19785 = D.19784->type;
          if (D.19785 == 14) goto <D.19790>; else goto <D.19791>;
          <D.19790>:
          D.19792 = monoeg_malloc0 (16);
          *mspecs = D.19792;
          D.19780 = *mspecs;
          D.19780->native = 19;
          goto <D.19793>;
          <D.19791>:
          D.19726 = sig_adjusted->param_count;
          D.19727 = (int) D.19726;
          D.19783 = D.19727 + -1;
          D.19784 = sig_adjusted->params[D.19783];
          D.19785 = D.19784->type;
          if (D.19785 == 18) goto <D.19794>; else goto <D.19795>;
          <D.19794>:
          D.19796 = monoeg_malloc0 (16);
          *mspecs = D.19796;
          D.19780 = *mspecs;
          D.19780->native = 28;
          goto <D.19797>;
          <D.19795>:
          D.19726 = sig_adjusted->param_count;
          D.19727 = (int) D.19726;
          D.19783 = D.19727 + -1;
          D.19784 = sig_adjusted->params[D.19783];
          D.19785 = D.19784->type;
          if (D.19785 == 2) goto <D.19798>; else goto <D.19799>;
          <D.19798>:
          D.19800 = monoeg_malloc0 (16);
          *mspecs = D.19800;
          D.19780 = *mspecs;
          D.19780->native = 37;
          <D.19799>:
          <D.19797>:
          <D.19793>:
          <D.19789>:
          <D.19782>:
          D.19726 = sig_adjusted->param_count;
          D.19801 = (unsigned int) D.19726;
          D.19802 = D.19801 * 4;
          D.19803 = mspecs + D.19802;
          D.19780 = *mspecs;
          *D.19803 = D.19780;
          *mspecs = 0B;
          <D.19779>:
          <D.19775>:
          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.19804>; else goto <D.19805>;
            <D.19804>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
            <D.19805>:
            D.19806 = ret != 0;
            D.19807 = (long int) D.19806;
            D.19808 = __builtin_expect (D.19807, 0);
            if (D.19808 != 0) goto <D.19809>; else goto <D.19810>;
            <D.19809>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2003, "ret == 0");
            <D.19810>:
          }
          D.19811 = m.csig;
          D.19812 = D.19811->param_count;
          D.19813 = (int) D.19812;
          D.19814 = D.19813 + 16;
          D.19811 = m.csig;
          wrapper_method = mono_mb_create_method (mb, D.19811, D.19814);
          {
            int ret;

            ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
            if (ret != 0) goto <D.19815>; else goto <D.19816>;
            <D.19815>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.19816>:
            D.19817 = ret != 0;
            D.19818 = (long int) D.19817;
            D.19819 = __builtin_expect (D.19818, 0);
            if (D.19819 != 0) goto <D.19820>; else goto <D.19821>;
            <D.19820>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2005, "ret == 0");
            <D.19821>:
          }
          vtable_index.63 = vtable_index;
          vtable_index = vtable_index.63 + -1;
          vtable_index.64 = (unsigned int) vtable_index.63;
          D.19824 = vtable_index.64 * 4;
          D.19825 = vtable + D.19824;
          D.19826 = mono_compile_method (wrapper_method);
          *D.19825 = D.19826;
          D.19726 = sig_adjusted->param_count;
          param_index = (int) D.19726;
          goto <D.18837>;
          <D.18836>:
          param_index.62 = (unsigned int) param_index;
          D.19736 = param_index.62 * 4;
          D.19737 = mspecs + D.19736;
          D.19738 = *D.19737;
          if (D.19738 != 0B) goto <D.19827>; else goto <D.19828>;
          <D.19827>:
          param_index.62 = (unsigned int) param_index;
          D.19736 = param_index.62 * 4;
          D.19737 = mspecs + D.19736;
          D.19738 = *D.19737;
          mono_metadata_free_marshal_spec (D.19738);
          <D.19828>:
          param_index = param_index + -1;
          <D.18837>:
          if (param_index >= 0) goto <D.18836>; else goto <D.18838>;
          <D.18838>:
          monoeg_g_free (mspecs);
        }
        i = i + -1;
        <D.18840>:
        if (i >= 0) goto <D.18839>; else goto <D.18841>;
        <D.18841>:
        ccw_entry = monoeg_malloc0 (8);
        ccw_entry->ccw = ccw;
        ccw_entry->vtable = vtable;
        D.19707 = ccw->vtable_hash;
        monoeg_g_hash_table_insert_replace (D.19707, 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.19709>:
      D.19608 = ccw_entry;
      return D.19608;
    }
  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.19831;

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


cominterop_ccw_get_ids_of_names (struct MonoCCWInterface * ccwe, void * riid, gunichar2 * * rgszNames, guint32 cNames, guint32 lcid, gint32 * rgDispId)
{
  unsigned int D.19833;
  _Bool D.19834;
  long int D.19835;
  long int D.19836;
  struct MonoVTable * D.19839;
  struct MonoDomain * D.19840;
  struct MonoDomain * D.19843;
  unsigned int i.65;
  unsigned int D.19845;
  gunichar2 * * D.19846;
  gunichar2 * D.19847;
  gint32 * D.19850;
  unsigned int D.19851;
  int D.19852;
  unsigned int i.66;
  int D.19855;
  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.19833 = ccw->gc_handle;
  object = mono_gchandle_get_target (D.19833);
  D.19834 = object == 0B;
  D.19835 = (long int) D.19834;
  D.19836 = __builtin_expect (D.19835, 0);
  if (D.19836 != 0) goto <D.19837>; else goto <D.19838>;
  <D.19837>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2418, "object");
  <D.19838>:
  D.19839 = object->vtable;
  klass = D.19839->klass;
  D.19840 = mono_domain_get ();
  if (D.19840 == 0B) goto <D.19841>; else goto <D.19842>;
  <D.19841>:
  D.19843 = mono_get_root_domain ();
  mono_thread_attach (D.19843);
  <D.19842>:
  i = 0;
  goto <D.18959>;
  <D.18958>:
  i.65 = (unsigned int) i;
  D.19845 = i.65 * 4;
  D.19846 = rgszNames + D.19845;
  D.19847 = *D.19846;
  methodname = mono_unicode_to_external (D.19847);
  method = mono_class_get_method_from_name (klass, methodname, -1);
  if (method != 0B) goto <D.19848>; else goto <D.19849>;
  <D.19848>:
  i.65 = (unsigned int) i;
  D.19845 = i.65 * 4;
  D.19850 = rgDispId + D.19845;
  D.19851 = method->token;
  D.19852 = (int) D.19851;
  *D.19850 = D.19852;
  goto <D.19853>;
  <D.19849>:
  i.65 = (unsigned int) i;
  D.19845 = i.65 * 4;
  D.19850 = rgDispId + D.19845;
  *D.19850 = -1;
  ret = -2147352570;
  <D.19853>:
  i = i + 1;
  <D.18959>:
  i.66 = (unsigned int) i;
  if (i.66 < cNames) goto <D.18958>; else goto <D.18960>;
  <D.18960>:
  D.19855 = ret;
  return D.19855;
}


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

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


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

  if (pctinfo == 0B) goto <D.19859>; else goto <D.19860>;
  <D.19859>:
  D.19861 = -2147024809;
  return D.19861;
  <D.19860>:
  *pctinfo = 1;
  D.19861 = 0;
  return D.19861;
}


cominterop_ccw_release (struct MonoCCWInterface * ccwe)
{
  _Bool D.19863;
  long int D.19864;
  long int D.19865;
  unsigned int D.19868;
  _Bool D.19869;
  long int D.19870;
  long int D.19871;
  guint32 * D.19874;
  _Bool D.19877;
  long int D.19878;
  long int D.19879;
  struct MonoObject * D.19882;
  unsigned int D.19883;
  int D.19884;
  gint32 ref_count;
  struct MonoCCW * ccw;

  ref_count = 0;
  ccw = ccwe->ccw;
  D.19863 = ccw == 0B;
  D.19864 = (long int) D.19863;
  D.19865 = __builtin_expect (D.19864, 0);
  if (D.19865 != 0) goto <D.19866>; else goto <D.19867>;
  <D.19866>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2272, "ccw");
  <D.19867>:
  D.19868 = ccw->ref_count;
  D.19869 = D.19868 == 0;
  D.19870 = (long int) D.19869;
  D.19871 = __builtin_expect (D.19870, 0);
  if (D.19871 != 0) goto <D.19872>; else goto <D.19873>;
  <D.19872>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2273, "ccw->ref_count > 0");
  <D.19873>:
  D.19874 = &ccw->ref_count;
  ref_count = InterlockedDecrement (D.19874);
  if (ref_count == 0) goto <D.19875>; else goto <D.19876>;
  <D.19875>:
  {
    guint32 oldhandle;

    oldhandle = ccw->gc_handle;
    D.19877 = oldhandle == 0;
    D.19878 = (long int) D.19877;
    D.19879 = __builtin_expect (D.19878, 0);
    if (D.19879 != 0) goto <D.19880>; else goto <D.19881>;
    <D.19880>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2278, "oldhandle");
    <D.19881>:
    D.19882 = mono_gchandle_get_target (oldhandle);
    D.19883 = mono_gchandle_new_weakref (D.19882, 0);
    ccw->gc_handle = D.19883;
    mono_gchandle_free (oldhandle);
  }
  <D.19876>:
  D.19884 = ref_count;
  return D.19884;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.19886;
  unsigned int D.19887;

  D.19887 = __sync_sub_and_fetch_4 (val, 1);
  D.19886 = (gint32) D.19887;
  return D.19886;
}


cominterop_ccw_addref (struct MonoCCWInterface * ccwe)
{
  _Bool D.19889;
  long int D.19890;
  long int D.19891;
  unsigned int D.19894;
  _Bool D.19895;
  long int D.19896;
  long int D.19897;
  guint32 * D.19902;
  _Bool D.19905;
  long int D.19906;
  long int D.19907;
  struct MonoObject * D.19910;
  unsigned int D.19911;
  int D.19912;
  gint32 ref_count;
  struct MonoCCW * ccw;

  ref_count = 0;
  ccw = ccwe->ccw;
  D.19889 = ccw == 0B;
  D.19890 = (long int) D.19889;
  D.19891 = __builtin_expect (D.19890, 0);
  if (D.19891 != 0) goto <D.19892>; else goto <D.19893>;
  <D.19892>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2253, "ccw");
  <D.19893>:
  D.19894 = ccw->gc_handle;
  D.19895 = D.19894 == 0;
  D.19896 = (long int) D.19895;
  D.19897 = __builtin_expect (D.19896, 0);
  if (D.19897 != 0) goto <D.19898>; else goto <D.19899>;
  <D.19898>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2254, "ccw->gc_handle");
  <D.19899>:
  if (0 != 0) goto <D.19900>; else goto <D.19901>;
  <D.19900>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2255, "ccw->ref_count >= 0");
  <D.19901>:
  D.19902 = &ccw->ref_count;
  ref_count = InterlockedIncrement (D.19902);
  if (ref_count == 1) goto <D.19903>; else goto <D.19904>;
  <D.19903>:
  {
    guint32 oldhandle;

    oldhandle = ccw->gc_handle;
    D.19905 = oldhandle == 0;
    D.19906 = (long int) D.19905;
    D.19907 = __builtin_expect (D.19906, 0);
    if (D.19907 != 0) goto <D.19908>; else goto <D.19909>;
    <D.19908>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2259, "oldhandle");
    <D.19909>:
    D.19910 = mono_gchandle_get_target (oldhandle);
    D.19911 = mono_gchandle_new (D.19910, 0);
    ccw->gc_handle = D.19911;
    mono_gchandle_free (oldhandle);
  }
  <D.19904>:
  D.19912 = ref_count;
  return D.19912;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.19914;
  unsigned int D.19915;

  D.19915 = __sync_add_and_fetch_4 (val, 1);
  D.19914 = (gint32) D.19915;
  return D.19914;
}


cominterop_ccw_queryinterface (struct MonoCCWInterface * ccwe, guint8 * riid, void * * ppv)
{
  unsigned int D.19917;
  _Bool D.19918;
  long int D.19919;
  long int D.19920;
  struct MonoVTable * D.19923;
  struct MonoDomain * D.19926;
  struct MonoDomain * D.19929;
  struct MonoClass * D.19930;
  int D.19931;
  struct MonoClass * D.19934;
  void * D.19935;
  void * D.19936;
  int D.19937;
  struct MonoClass * D.19938;
  int D.19939;
  int D.19942;
  struct MonoClass * D.19945;
  void * D.19946;
  int D.19947;
  _Bool D.19948;
  long int D.19949;
  long int D.19950;
  void * * D.19955;
  unsigned int i.67;
  unsigned int D.19957;
  void * * D.19958;
  int D.19959;
  unsigned int i.68;
  unsigned int D.19963;
  struct MonoClass * D.19966;
  void * D.19969;
  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.19917 = ccw->gc_handle;
      object = mono_gchandle_get_target (D.19917);
      D.19918 = object == 0B;
      D.19919 = (long int) D.19918;
      D.19920 = __builtin_expect (D.19919, 0);
      if (D.19920 != 0) goto <D.19921>; else goto <D.19922>;
      <D.19921>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2324, "object");
      <D.19922>:
      D.19923 = object->vtable;
      klass = D.19923->klass;
      if (ppv != 0B) goto <D.19924>; else goto <D.19925>;
      <D.19924>:
      *ppv = 0B;
      <D.19925>:
      D.19926 = mono_domain_get ();
      if (D.19926 == 0B) goto <D.19927>; else goto <D.19928>;
      <D.19927>:
      D.19929 = mono_get_root_domain ();
      mono_thread_attach (D.19929);
      <D.19928>:
      D.19930 = mono_class_get_iunknown_class ();
      D.19931 = cominterop_class_guid_equal (riid, D.19930);
      if (D.19931 != 0) goto <D.19932>; else goto <D.19933>;
      <D.19932>:
      D.19934 = mono_class_get_iunknown_class ();
      D.19935 = cominterop_get_ccw (object, D.19934);
      *ppv = D.19935;
      D.19936 = *ppv;
      cominterop_ccw_addref (D.19936);
      D.19937 = 0;
      return D.19937;
      <D.19933>:
      D.19938 = mono_class_get_idispatch_class ();
      D.19939 = cominterop_class_guid_equal (riid, D.19938);
      if (D.19939 != 0) goto <D.19940>; else goto <D.19941>;
      <D.19940>:
      D.19942 = cominterop_can_support_dispatch (klass);
      if (D.19942 == 0) goto <D.19943>; else goto <D.19944>;
      <D.19943>:
      D.19937 = -2147467262;
      return D.19937;
      <D.19944>:
      D.19945 = mono_class_get_idispatch_class ();
      D.19946 = cominterop_get_ccw (object, D.19945);
      *ppv = D.19946;
      D.19936 = *ppv;
      cominterop_ccw_addref (D.19936);
      D.19937 = 0;
      return D.19937;
      <D.19941>:
      klass_iter = klass;
      goto <D.18932>;
      <D.18931>:
      ifaces = mono_class_get_implemented_interfaces (klass_iter, &error);
      D.19947 = mono_error_ok (&error);
      D.19948 = D.19947 == 0;
      D.19949 = (long int) D.19948;
      D.19950 = __builtin_expect (D.19949, 0);
      if (D.19950 != 0) goto <D.19951>; else goto <D.19952>;
      <D.19951>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2361, "mono_error_ok (&error)");
      <D.19952>:
      if (ifaces != 0B) goto <D.19953>; else goto <D.19954>;
      <D.19953>:
      i = 0;
      goto <D.18929>;
      <D.18928>:
      {
        struct MonoClass * ic;

        ic = 0B;
        D.19955 = ifaces->pdata;
        i.67 = (unsigned int) i;
        D.19957 = i.67 * 4;
        D.19958 = D.19955 + D.19957;
        ic = *D.19958;
        D.19959 = cominterop_class_guid_equal (riid, ic);
        if (D.19959 != 0) goto <D.19960>; else goto <D.19961>;
        <D.19960>:
        itf = ic;
        goto <D.18927>;
        <D.19961>:
      }
      i = i + 1;
      <D.18929>:
      i.68 = (unsigned int) i;
      D.19963 = ifaces->len;
      if (i.68 < D.19963) goto <D.18928>; else goto <D.18927>;
      <D.18927>:
      monoeg_g_ptr_array_free (ifaces, 1);
      <D.19954>:
      if (itf != 0B) goto <D.18930>; else goto <D.19964>;
      <D.19964>:
      klass_iter = klass_iter->parent;
      <D.18932>:
      if (klass_iter != 0B) goto <D.19965>; else goto <D.18930>;
      <D.19965>:
      D.19966 = mono_defaults.object_class;
      if (D.19966 != klass_iter) goto <D.18931>; else goto <D.18930>;
      <D.18930>:
      if (itf != 0B) goto <D.19967>; else goto <D.19968>;
      <D.19967>:
      D.19969 = cominterop_get_ccw (object, itf);
      *ppv = D.19969;
      D.19936 = *ppv;
      cominterop_ccw_addref (D.19936);
      D.19937 = 0;
      return D.19937;
      <D.19968>:
      D.19937 = -2147467262;
      return D.19937;
    }
  finally
    {
      error = {CLOBBER};
    }
}


cominterop_can_support_dispatch (struct MonoClass * klass)
{
  unsigned int D.19972;
  unsigned int D.19973;
  gboolean D.19976;
  int D.19977;

  D.19972 = klass->flags;
  D.19973 = D.19972 & 1;
  if (D.19973 == 0) goto <D.19974>; else goto <D.19975>;
  <D.19974>:
  D.19976 = 0;
  return D.19976;
  <D.19975>:
  D.19977 = cominterop_com_visible (klass);
  if (D.19977 == 0) goto <D.19978>; else goto <D.19979>;
  <D.19978>:
  D.19976 = 0;
  return D.19976;
  <D.19979>:
  D.19976 = 1;
  return D.19976;
}


cominterop_com_visible (struct MonoClass * klass)
{
  struct MonoClass * ComVisibleAttribute.69;
  struct MonoImage * D.19984;
  struct MonoClass * ComVisibleAttribute.70;
  int D.19990;
  gboolean D.19995;
  int D.19996;
  _Bool D.19997;
  long int D.19998;
  long int D.19999;
  void * * D.20004;
  unsigned int i.71;
  unsigned int D.20006;
  void * * D.20007;
  unsigned int D.20008;
  unsigned int D.20009;
  unsigned int i.72;
  unsigned int D.20013;
  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.19982>; else goto <D.19983>;
      <D.19982>:
      D.19984 = mono_defaults.corlib;
      ComVisibleAttribute.70 = mono_class_from_name (D.19984, "System.Runtime.InteropServices", "ComVisibleAttribute");
      ComVisibleAttribute = ComVisibleAttribute.70;
      <D.19983>:
      cinfo = mono_custom_attrs_from_class (klass);
      if (cinfo != 0B) goto <D.19986>; else goto <D.19987>;
      <D.19986>:
      {
        struct MonoReflectionComVisibleAttribute * attr;

        ComVisibleAttribute.69 = ComVisibleAttribute;
        attr = mono_custom_attrs_get_attr (cinfo, ComVisibleAttribute.69);
        if (attr != 0B) goto <D.19988>; else goto <D.19989>;
        <D.19988>:
        visible = attr->visible;
        <D.19989>:
        D.19990 = cinfo->cached;
        if (D.19990 == 0) goto <D.19991>; else goto <D.19992>;
        <D.19991>:
        mono_custom_attrs_free (cinfo);
        <D.19992>:
        if (visible != 0) goto <D.19993>; else goto <D.19994>;
        <D.19993>:
        D.19995 = 1;
        return D.19995;
        <D.19994>:
      }
      <D.19987>:
      ifaces = mono_class_get_implemented_interfaces (klass, &error);
      D.19996 = mono_error_ok (&error);
      D.19997 = D.19996 == 0;
      D.19998 = (long int) D.19997;
      D.19999 = __builtin_expect (D.19998, 0);
      if (D.19999 != 0) goto <D.20000>; else goto <D.20001>;
      <D.20000>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 434, "mono_error_ok (&error)");
      <D.20001>:
      if (ifaces != 0B) goto <D.20002>; else goto <D.20003>;
      <D.20002>:
      {
        int i;

        i = 0;
        goto <D.18470>;
        <D.18469>:
        {
          struct MonoClass * ic;

          ic = 0B;
          D.20004 = ifaces->pdata;
          i.71 = (unsigned int) i;
          D.20006 = i.71 * 4;
          D.20007 = D.20004 + D.20006;
          ic = *D.20007;
          D.20008 = ic->flags;
          D.20009 = D.20008 & 4096;
          if (D.20009 != 0) goto <D.20010>; else goto <D.20011>;
          <D.20010>:
          visible = 1;
          <D.20011>:
        }
        i = i + 1;
        <D.18470>:
        i.72 = (unsigned int) i;
        D.20013 = ifaces->len;
        if (i.72 < D.20013) goto <D.18469>; else goto <D.18471>;
        <D.18471>:
        monoeg_g_ptr_array_free (ifaces, 1);
      }
      <D.20003>:
      D.19995 = (gboolean) visible;
      return D.19995;
    }
  finally
    {
      error = {CLOBBER};
    }
}


cominterop_class_guid_equal (guint8 * guid, struct MonoClass * klass)
{
  int D.20016;
  gboolean D.20019;
  int D.20020;
  _Bool D.20021;
  guint8 klass_guid[16];

  try
    {
      D.20016 = cominterop_class_guid (klass, &klass_guid);
      if (D.20016 != 0) goto <D.20017>; else goto <D.20018>;
      <D.20017>:
      D.20020 = memcmp (guid, &klass_guid, 16);
      D.20021 = D.20020 == 0;
      D.20019 = (gboolean) D.20021;
      return D.20019;
      <D.20018>:
      D.20019 = 0;
      return D.20019;
    }
  finally
    {
      klass_guid = {CLOBBER};
    }
}


cominterop_get_com_slot_begin (struct MonoClass * klass)
{
  struct MonoClass * interface_type_attribute.73;
  struct MonoImage * D.20027;
  struct MonoClass * interface_type_attribute.74;
  int D.20031;
  unsigned int D.20036;
  int D.20038;
  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.20025>; else goto <D.20026>;
  <D.20025>:
  D.20027 = mono_defaults.corlib;
  interface_type_attribute.74 = mono_class_from_name (D.20027, "System.Runtime.InteropServices", "InterfaceTypeAttribute");
  interface_type_attribute = interface_type_attribute.74;
  <D.20026>:
  cinfo = mono_custom_attrs_from_class (klass);
  if (cinfo != 0B) goto <D.20029>; else goto <D.20030>;
  <D.20029>:
  interface_type_attribute.73 = interface_type_attribute;
  itf_attr = mono_custom_attrs_get_attr (cinfo, interface_type_attribute.73);
  D.20031 = cinfo->cached;
  if (D.20031 == 0) goto <D.20032>; else goto <D.20033>;
  <D.20032>:
  mono_custom_attrs_free (cinfo);
  <D.20033>:
  <D.20030>:
  if (itf_attr != 0B) goto <D.20035>; else goto <D.20034>;
  <D.20035>:
  D.20036 = itf_attr->intType;
  if (D.20036 == 1) goto <D.20037>; else goto <D.20034>;
  <D.20037>:
  D.20038 = 3;
  return D.20038;
  <D.20034>:
  D.20038 = 7;
  return D.20038;
}


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

  D.20041 = __builtin_object_size (__dest, 0);
  D.20040 = __builtin___memcpy_chk (__dest, __src, __len, D.20041);
  return D.20040;
}


cominterop_get_managed_wrapper_adjusted (struct MonoMethod * method)
{
  short unsigned int D.20043;
  int D.20044;
  struct MonoMethod * get_hr_for_exception.75;
  struct MonoClass * D.20048;
  struct MonoMethod * get_hr_for_exception.76;
  const char * D.20050;
  struct MonoClass * D.20051;
  short unsigned int D.20052;
  int D.20053;
  int D.20054;
  unsigned int D.20055;
  unsigned int D.20056;
  short unsigned int D.20057;
  sizetype i.77;
  sizetype D.20059;
  sizetype D.20060;
  struct MonoMarshalSpec * * D.20061;
  unsigned int i.78;
  unsigned int D.20063;
  struct MonoMarshalSpec * * D.20064;
  struct MonoMarshalSpec * D.20065;
  struct MonoMarshalSpec * * D.20066;
  struct MonoType * D.20069;
  int D.20070;
  unsigned int D.20073;
  unsigned int D.20074;
  struct MonoMarshalSpec * * D.20075;
  struct MonoMarshalSpec * D.20076;
  struct MonoClass * D.20079;
  struct MonoType * D.20080;
  int D.20082;
  int D.20085;
  unsigned int D.20086;
  int D.20089;
  int D.20092;
  unsigned int D.20093;
  int D.20094;
  unsigned int D.20095;
  int D.20096;
  int D.20097;
  unsigned char D.20102;
  unsigned char D.20103;
  unsigned int D.20107;
  unsigned char D.20108;
  int D.20109;
  unsigned int hr.79;
  unsigned int D.20112;
  int D.20113;
  unsigned int D.20114;
  unsigned int D.20115;
  unsigned int D.20116;
  struct MonoClass * D.20117;
  int D.20118;
  unsigned int D.20119;
  unsigned char D.20125;
  unsigned char D.20126;
  unsigned char D.20128;
  unsigned char D.20129;
  int D.20130;
  unsigned int D.20131;
  unsigned int D.20132;
  unsigned int D.20133;
  unsigned int pos_leave.80;
  int D.20138;
  _Bool D.20141;
  long int D.20142;
  long int D.20143;
  int D.20146;
  _Bool D.20149;
  long int D.20150;
  long int D.20151;
  struct MonoMethod * D.20156;
  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.20043 = method->iflags;
  D.20044 = (int) D.20043;
  preserve_sig = D.20044 & 128;
  get_hr_for_exception.75 = get_hr_for_exception;
  if (get_hr_for_exception.75 == 0B) goto <D.20046>; else goto <D.20047>;
  <D.20046>:
  D.20048 = mono_defaults.marshal_class;
  get_hr_for_exception.76 = mono_class_get_method_from_name (D.20048, "GetHRForException", -1);
  get_hr_for_exception = get_hr_for_exception.76;
  <D.20047>:
  sig = mono_method_signature (method);
  D.20050 = method->name;
  D.20051 = method->klass;
  mb = mono_mb_new (D.20051, D.20050, 27);
  sig_native = cominterop_method_signature (method);
  D.20052 = sig_native->param_count;
  D.20053 = (int) D.20052;
  D.20054 = D.20053 + 1;
  D.20055 = (unsigned int) D.20054;
  D.20056 = D.20055 * 4;
  mspecs = monoeg_malloc0 (D.20056);
  mono_method_get_marshal_info (method, mspecs);
  D.20057 = sig->param_count;
  i = (int) D.20057;
  goto <D.18875>;
  <D.18874>:
  i.77 = (sizetype) i;
  D.20059 = i.77 + 1;
  D.20060 = D.20059 * 4;
  D.20061 = mspecs + D.20060;
  i.78 = (unsigned int) i;
  D.20063 = i.78 * 4;
  D.20064 = mspecs + D.20063;
  D.20065 = *D.20064;
  *D.20061 = D.20065;
  i = i + -1;
  <D.18875>:
  if (i > 0) goto <D.18874>; else goto <D.18876>;
  <D.18876>:
  D.20066 = mspecs + 4;
  *D.20066 = 0B;
  if (preserve_sig == 0) goto <D.20067>; else goto <D.20068>;
  <D.20067>:
  D.20069 = sig->ret;
  D.20070 = mono_type_is_void (D.20069);
  if (D.20070 == 0) goto <D.20071>; else goto <D.20072>;
  <D.20071>:
  D.20052 = sig_native->param_count;
  D.20073 = (unsigned int) D.20052;
  D.20074 = D.20073 * 4;
  D.20075 = mspecs + D.20074;
  D.20076 = *mspecs;
  *D.20075 = D.20076;
  <D.20072>:
  <D.20068>:
  *mspecs = 0B;
  if (preserve_sig == 0) goto <D.20077>; else goto <D.20078>;
  <D.20077>:
  D.20079 = mono_defaults.int32_class;
  D.20080 = &D.20079->byval_arg;
  hr = mono_mb_add_local (mb, D.20080);
  goto <D.20081>;
  <D.20078>:
  D.20069 = sig->ret;
  D.20082 = mono_type_is_void (D.20069);
  if (D.20082 == 0) goto <D.20083>; else goto <D.20084>;
  <D.20083>:
  D.20069 = sig->ret;
  hr = mono_mb_add_local (mb, D.20069);
  <D.20084>:
  <D.20081>:
  main_clause = monoeg_malloc0 (24);
  D.20085 = mono_mb_get_label (mb);
  D.20086 = (unsigned int) D.20085;
  main_clause->try_offset = D.20086;
  if (preserve_sig == 0) goto <D.20087>; else goto <D.20088>;
  <D.20087>:
  D.20069 = sig->ret;
  D.20089 = mono_type_is_void (D.20069);
  if (D.20089 == 0) goto <D.20090>; else goto <D.20091>;
  <D.20090>:
  D.20052 = sig_native->param_count;
  D.20053 = (int) D.20052;
  D.20092 = D.20053 + -1;
  D.20093 = (unsigned int) D.20092;
  mono_mb_emit_ldarg (mb, D.20093);
  <D.20091>:
  <D.20088>:
  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.18878>;
  <D.18877>:
  D.20094 = i + 1;
  D.20095 = (unsigned int) D.20094;
  mono_mb_emit_ldarg (mb, D.20095);
  i = i + 1;
  <D.18878>:
  D.20057 = sig->param_count;
  D.20096 = (int) D.20057;
  if (D.20096 > i) goto <D.18877>; else goto <D.18879>;
  <D.18879>:
  mono_mb_emit_managed_call (mb, method, 0B);
  D.20069 = sig->ret;
  D.20097 = mono_type_is_void (D.20069);
  if (D.20097 == 0) goto <D.20098>; else goto <D.20099>;
  <D.20098>:
  if (preserve_sig == 0) goto <D.20100>; else goto <D.20101>;
  <D.20100>:
  {
    struct MonoClass * rclass;

    D.20069 = sig->ret;
    rclass = mono_class_from_mono_type (D.20069);
    D.20102 = BIT_FIELD_REF <*rclass, 8, 160>;
    D.20103 = D.20102 & 8;
    if (D.20103 != 0) goto <D.20104>; else goto <D.20105>;
    <D.20104>:
    mono_mb_emit_op (mb, 129, rclass);
    goto <D.20106>;
    <D.20105>:
    D.20069 = sig->ret;
    D.20107 = mono_type_to_stind (D.20069);
    D.20108 = (unsigned char) D.20107;
    D.20109 = (int) D.20108;
    mono_mb_emit_byte (mb, D.20109);
    <D.20106>:
  }
  goto <D.20110>;
  <D.20101>:
  hr.79 = (unsigned int) hr;
  mono_mb_emit_stloc (mb, hr.79);
  <D.20110>:
  <D.20099>:
  D.20112 = mono_mb_emit_branch (mb, 221);
  pos_leave = (int) D.20112;
  main_clause->flags = 0;
  D.20113 = mono_mb_get_pos (mb);
  D.20114 = (unsigned int) D.20113;
  D.20115 = main_clause->try_offset;
  D.20116 = D.20114 - D.20115;
  main_clause->try_len = D.20116;
  D.20117 = mono_defaults.object_class;
  main_clause->data.catch_class = D.20117;
  D.20118 = mono_mb_get_label (mb);
  D.20119 = (unsigned int) D.20118;
  main_clause->handler_offset = D.20119;
  if (preserve_sig == 0) goto <D.20120>; else goto <D.20123>;
  <D.20123>:
  D.20069 = sig->ret;
  if (D.20069 != 0B) goto <D.20124>; else goto <D.20121>;
  <D.20124>:
  D.20069 = sig->ret;
  D.20125 = BIT_FIELD_REF <*D.20069, 8, 56>;
  D.20126 = D.20125 & 64;
  if (D.20126 == 0) goto <D.20127>; else goto <D.20121>;
  <D.20127>:
  D.20069 = sig->ret;
  D.20128 = D.20069->type;
  D.20129 = D.20128 + 248;
  if (D.20129 <= 1) goto <D.20120>; else goto <D.20121>;
  <D.20120>:
  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.20122>;
  <D.20121>:
  mono_mb_emit_byte (mb, 38);
  <D.20122>:
  mono_mb_emit_branch (mb, 221);
  D.20130 = mono_mb_get_pos (mb);
  D.20131 = (unsigned int) D.20130;
  D.20132 = main_clause->handler_offset;
  D.20133 = D.20131 - D.20132;
  main_clause->handler_len = D.20133;
  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.20135>; else goto <D.20137>;
  <D.20137>:
  D.20069 = sig->ret;
  D.20138 = mono_type_is_void (D.20069);
  if (D.20138 == 0) goto <D.20135>; else goto <D.20136>;
  <D.20135>:
  hr.79 = (unsigned int) hr;
  mono_mb_emit_ldloc (mb, hr.79);
  <D.20136>:
  mono_mb_emit_byte (mb, 42);
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.20139>; else goto <D.20140>;
    <D.20139>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.20140>:
    D.20141 = ret != 0;
    D.20142 = (long int) D.20141;
    D.20143 = __builtin_expect (D.20142, 0);
    if (D.20143 != 0) goto <D.20144>; else goto <D.20145>;
    <D.20144>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2209, "ret == 0");
    <D.20145>:
  }
  D.20052 = sig_native->param_count;
  D.20053 = (int) D.20052;
  D.20146 = D.20053 + 16;
  res = mono_mb_create_method (mb, sig_native, D.20146);
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.20147>; else goto <D.20148>;
    <D.20147>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.20148>:
    D.20149 = ret != 0;
    D.20150 = (long int) D.20149;
    D.20151 = __builtin_expect (D.20150, 0);
    if (D.20151 != 0) goto <D.20152>; else goto <D.20153>;
    <D.20152>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2211, "ret == 0");
    <D.20153>:
  }
  mono_mb_free (mb);
  D.20052 = sig_native->param_count;
  i = (int) D.20052;
  goto <D.18884>;
  <D.18883>:
  i.78 = (unsigned int) i;
  D.20063 = i.78 * 4;
  D.20064 = mspecs + D.20063;
  D.20065 = *D.20064;
  if (D.20065 != 0B) goto <D.20154>; else goto <D.20155>;
  <D.20154>:
  i.78 = (unsigned int) i;
  D.20063 = i.78 * 4;
  D.20064 = mspecs + D.20063;
  D.20065 = *D.20064;
  mono_metadata_free_marshal_spec (D.20065);
  <D.20155>:
  i = i + -1;
  <D.18884>:
  if (i >= 0) goto <D.18883>; else goto <D.18885>;
  <D.18885>:
  monoeg_g_free (mspecs);
  D.20156 = res;
  return D.20156;
}


cominterop_method_signature (struct MonoMethod * method)
{
  struct MonoClass * D.20158;
  short unsigned int D.20159;
  int D.20160;
  short unsigned int D.20161;
  int D.20162;
  struct MonoType * D.20165;
  int D.20166;
  unsigned int param_count.81;
  unsigned int D.20170;
  unsigned int D.20171;
  unsigned int D.20172;
  unsigned int sigsize.82;
  int D.20174;
  struct MonoType * D.20175;
  struct MonoClass * D.20176;
  struct MonoType * D.20177;
  int D.20181;
  int D.20184;
  struct MonoType * D.20185;
  struct MonoType * D.20186;
  struct MonoClass * D.20187;
  struct MonoType * D.20188;
  short unsigned int D.20189;
  struct MonoMethodSignature * D.20190;
  struct MonoMethodSignature * res;
  struct MonoImage * image;
  struct MonoMethodSignature * sig;
  gboolean preserve_sig;
  int sigsize;
  int i;
  int param_count;

  D.20158 = method->klass;
  image = D.20158->image;
  sig = mono_method_signature (method);
  D.20159 = method->iflags;
  D.20160 = (int) D.20159;
  preserve_sig = D.20160 & 128;
  D.20161 = sig->param_count;
  D.20162 = (int) D.20161;
  param_count = D.20162 + 1;
  if (preserve_sig == 0) goto <D.20163>; else goto <D.20164>;
  <D.20163>:
  D.20165 = sig->ret;
  D.20166 = mono_type_is_void (D.20165);
  if (D.20166 == 0) goto <D.20167>; else goto <D.20168>;
  <D.20167>:
  param_count = param_count + 1;
  <D.20168>:
  <D.20164>:
  param_count.81 = (unsigned int) param_count;
  res = mono_metadata_signature_alloc (image, param_count.81);
  D.20161 = sig->param_count;
  D.20170 = (unsigned int) D.20161;
  D.20171 = D.20170 + 3;
  D.20172 = D.20171 * 4;
  sigsize = (int) D.20172;
  sigsize.82 = (unsigned int) sigsize;
  memcpy (res, sig, sigsize.82);
  D.20161 = sig->param_count;
  D.20162 = (int) D.20161;
  i = D.20162 + -1;
  goto <D.18404>;
  <D.18403>:
  D.20174 = i + 1;
  D.20175 = sig->params[i];
  res->params[D.20174] = D.20175;
  i = i + -1;
  <D.18404>:
  if (i >= 0) goto <D.18403>; else goto <D.18405>;
  <D.18405>:
  D.20176 = mono_defaults.int_class;
  D.20177 = &D.20176->byval_arg;
  res->params[0] = D.20177;
  if (preserve_sig != 0) goto <D.20178>; else goto <D.20179>;
  <D.20178>:
  D.20165 = sig->ret;
  res->ret = D.20165;
  goto <D.20180>;
  <D.20179>:
  D.20165 = sig->ret;
  D.20181 = mono_type_is_void (D.20165);
  if (D.20181 == 0) goto <D.20182>; else goto <D.20183>;
  <D.20182>:
  D.20184 = param_count + -1;
  D.20165 = sig->ret;
  D.20185 = mono_metadata_type_dup (image, D.20165);
  res->params[D.20184] = D.20185;
  D.20184 = param_count + -1;
  D.20186 = res->params[D.20184];
  D.20186->byref = 1;
  D.20184 = param_count + -1;
  D.20186 = res->params[D.20184];
  D.20186->attrs = 2;
  <D.20183>:
  D.20187 = mono_defaults.int32_class;
  D.20188 = &D.20187->byval_arg;
  res->ret = D.20188;
  <D.20180>:
  res->pinvoke = 0;
  res->hasthis = 0;
  D.20189 = (short unsigned int) param_count;
  res->param_count = D.20189;
  res->call_convention = 1;
  D.20190 = res;
  return D.20190;
}


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

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


cominterop_object_is_rcw (struct MonoObject * obj)
{
  gboolean D.20196;
  struct MonoVTable * D.20197;
  struct MonoClass * D.20198;
  struct MonoVTable * D.20203;
  int iftmp.83;
  struct MonoClass * D.20208;
  struct MonoClass * klass;
  struct MonoRealProxy * real_proxy;

  klass = 0B;
  real_proxy = 0B;
  if (obj == 0B) goto <D.20194>; else goto <D.20195>;
  <D.20194>:
  D.20196 = 0;
  return D.20196;
  <D.20195>:
  D.20197 = obj->vtable;
  klass = D.20197->klass;
  D.20198 = mono_defaults.transparent_proxy_class;
  if (D.20198 != klass) goto <D.20199>; else goto <D.20200>;
  <D.20199>:
  D.20196 = 0;
  return D.20196;
  <D.20200>:
  real_proxy = MEM[(struct MonoTransparentProxy *)obj].rp;
  if (real_proxy == 0B) goto <D.20201>; else goto <D.20202>;
  <D.20201>:
  D.20196 = 0;
  return D.20196;
  <D.20202>:
  D.20203 = MEM[(struct MonoObject *)real_proxy].vtable;
  klass = D.20203->klass;
  if (klass != 0B) goto <D.20207>; else goto <D.20205>;
  <D.20207>:
  D.20208 = mono_class_get_interop_proxy_class ();
  if (D.20208 == klass) goto <D.20209>; else goto <D.20205>;
  <D.20209>:
  iftmp.83 = 1;
  goto <D.20206>;
  <D.20205>:
  iftmp.83 = 0;
  <D.20206>:
  D.20196 = iftmp.83;
  return D.20196;
}


cominterop_get_function_pointer (void * itf, int slot)
{
  void * * D.20211;
  unsigned int slot.84;
  unsigned int D.20213;
  void * * D.20214;
  void * D.20215;
  void * func;

  D.20211 = MEM[(void * * *)itf];
  slot.84 = (unsigned int) slot;
  D.20213 = slot.84 * 4;
  D.20214 = D.20211 + D.20213;
  func = *D.20214;
  D.20215 = func;
  return D.20215;
}


cominterop_get_method_interface (struct MonoMethod * method)
{
  struct MonoClass * D.20217;
  unsigned int D.20218;
  unsigned int D.20219;
  unsigned char D.20222;
  int D.20227;
  _Bool D.20228;
  long int D.20229;
  long int D.20230;
  void * * D.20235;
  unsigned int i.85;
  unsigned int D.20237;
  void * * D.20238;
  struct MonoMethod * * D.20239;
  int D.20240;
  unsigned int D.20241;
  unsigned int D.20242;
  struct MonoMethod * * D.20243;
  struct MonoMethod * D.20244;
  unsigned int j.86;
  unsigned int D.20248;
  unsigned int i.87;
  unsigned int D.20251;
  _Bool D.20254;
  long int D.20255;
  long int D.20256;
  int iftmp.88;
  unsigned int D.20262;
  unsigned int D.20263;
  unsigned char D.20265;
  _Bool D.20268;
  long int D.20269;
  long int D.20270;
  struct MonoClass * D.20273;
  struct MonoError error;
  struct MonoClass * ic;

  try
    {
      ic = method->klass;
      D.20217 = method->klass;
      D.20218 = D.20217->flags;
      D.20219 = D.20218 & 32;
      if (D.20219 == 0) goto <D.20220>; else goto <D.20221>;
      <D.20220>:
      D.20217 = method->klass;
      D.20222 = D.20217->byval_arg.type;
      if (D.20222 != 19) goto <D.20223>; else goto <D.20224>;
      <D.20223>:
      D.20217 = method->klass;
      D.20222 = D.20217->byval_arg.type;
      if (D.20222 != 30) goto <D.20225>; else goto <D.20226>;
      <D.20225>:
      {
        struct GPtrArray * ifaces;

        D.20217 = method->klass;
        ifaces = mono_class_get_implemented_interfaces (D.20217, &error);
        D.20227 = mono_error_ok (&error);
        D.20228 = D.20227 == 0;
        D.20229 = (long int) D.20228;
        D.20230 = __builtin_expect (D.20229, 0);
        if (D.20230 != 0) goto <D.20231>; else goto <D.20232>;
        <D.20231>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 315, "mono_error_ok (&error)");
        <D.20232>:
        if (ifaces != 0B) goto <D.20233>; else goto <D.20234>;
        <D.20233>:
        {
          int i;

          D.20217 = method->klass;
          mono_class_setup_vtable (D.20217);
          i = 0;
          goto <D.18437>;
          <D.18436>:
          {
            int j;
            int offset;
            gboolean found;

            found = 0;
            D.20235 = ifaces->pdata;
            i.85 = (unsigned int) i;
            D.20237 = i.85 * 4;
            D.20238 = D.20235 + D.20237;
            ic = *D.20238;
            D.20217 = method->klass;
            offset = mono_class_interface_offset (D.20217, ic);
            j = 0;
            goto <D.18434>;
            <D.18433>:
            D.20217 = method->klass;
            D.20239 = D.20217->vtable;
            D.20240 = j + offset;
            D.20241 = (unsigned int) D.20240;
            D.20242 = D.20241 * 4;
            D.20243 = D.20239 + D.20242;
            D.20244 = *D.20243;
            if (D.20244 == method) goto <D.20245>; else goto <D.20246>;
            <D.20245>:
            found = 1;
            goto <D.18432>;
            <D.20246>:
            j = j + 1;
            <D.18434>:
            j.86 = (unsigned int) j;
            D.20248 = ic->method.count;
            if (j.86 < D.20248) goto <D.18433>; else goto <D.18432>;
            <D.18432>:
            if (found != 0) goto <D.18435>; else goto <D.20249>;
            <D.20249>:
            ic = 0B;
          }
          i = i + 1;
          <D.18437>:
          i.87 = (unsigned int) i;
          D.20251 = ifaces->len;
          if (i.87 < D.20251) goto <D.18436>; else goto <D.18435>;
          <D.18435>:
          monoeg_g_ptr_array_free (ifaces, 1);
        }
        <D.20234>:
      }
      <D.20226>:
      <D.20224>:
      <D.20221>:
      if (ic == 0B) goto <D.20252>; else goto <D.20253>;
      <D.20252>:
      D.20254 = ic == 0B;
      D.20255 = (long int) D.20254;
      D.20256 = __builtin_expect (D.20255, 0);
      if (D.20256 != 0) goto <D.20257>; else goto <D.20258>;
      <D.20257>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 339, "ic");
      <D.20258>:
      <D.20253>:
      D.20262 = ic->flags;
      D.20263 = D.20262 & 32;
      if (D.20263 == 0) goto <D.20264>; else goto <D.20260>;
      <D.20264>:
      D.20265 = ic->byval_arg.type;
      if (D.20265 != 19) goto <D.20266>; else goto <D.20260>;
      <D.20266>:
      D.20265 = ic->byval_arg.type;
      if (D.20265 != 30) goto <D.20267>; else goto <D.20260>;
      <D.20267>:
      iftmp.88 = 1;
      goto <D.20261>;
      <D.20260>:
      iftmp.88 = 0;
      <D.20261>:
      D.20268 = iftmp.88 != 0;
      D.20269 = (long int) D.20268;
      D.20270 = __builtin_expect (D.20269, 0);
      if (D.20270 != 0) goto <D.20271>; else goto <D.20272>;
      <D.20271>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 340, "MONO_CLASS_IS_INTERFACE (ic)");
      <D.20272>:
      D.20273 = ic;
      return D.20273;
    }
  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.20276;

  mono_mb_emit_ldarg (mb, 0);
  D.20276 = cominterop_get_com_slot_for_method (method);
  mono_mb_emit_icon (mb, D.20276);
  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.20277;
  unsigned int D.20278;
  unsigned int D.20279;
  unsigned char D.20282;
  struct MonoClass * D.20287;
  _Bool D.20288;
  long int D.20289;
  long int D.20290;
  struct MonoMethod * * D.20293;
  int D.20294;
  unsigned int D.20295;
  unsigned int D.20296;
  struct MonoMethod * * D.20297;
  struct MonoMethod * D.20298;
  struct MonoMethod * * D.20301;
  unsigned int i.89;
  unsigned int D.20303;
  struct MonoMethod * * D.20304;
  struct MonoMethod * D.20305;
  short int D.20306;
  unsigned int i.90;
  unsigned int D.20308;
  _Bool D.20309;
  long int D.20310;
  long int D.20311;
  int iftmp.91;
  _Bool D.20320;
  long int D.20321;
  long int D.20322;
  int D.20325;
  int D.20326;
  unsigned int D.20327;
  unsigned int D.20328;
  guint32 slot;
  struct MonoClass * ic;

  D.20277 = method->slot;
  slot = (guint32) D.20277;
  ic = method->klass;
  D.20278 = ic->flags;
  D.20279 = D.20278 & 32;
  if (D.20279 == 0) goto <D.20280>; else goto <D.20281>;
  <D.20280>:
  D.20282 = ic->byval_arg.type;
  if (D.20282 != 19) goto <D.20283>; else goto <D.20284>;
  <D.20283>:
  D.20282 = ic->byval_arg.type;
  if (D.20282 != 30) goto <D.20285>; else goto <D.20286>;
  <D.20285>:
  {
    int offset;
    int i;

    offset = 0;
    i = 0;
    ic = cominterop_get_method_interface (method);
    D.20287 = method->klass;
    offset = mono_class_interface_offset (D.20287, ic);
    D.20288 = offset < 0;
    D.20289 = (long int) D.20288;
    D.20290 = __builtin_expect (D.20289, 0);
    if (D.20290 != 0) goto <D.20291>; else goto <D.20292>;
    <D.20291>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 363, "offset >= 0");
    <D.20292>:
    i = 0;
    goto <D.18447>;
    <D.18446>:
    D.20287 = method->klass;
    D.20293 = D.20287->vtable;
    D.20294 = i + offset;
    D.20295 = (unsigned int) D.20294;
    D.20296 = D.20295 * 4;
    D.20297 = D.20293 + D.20296;
    D.20298 = *D.20297;
    if (D.20298 == method) goto <D.20299>; else goto <D.20300>;
    <D.20299>:
    D.20301 = ic->methods;
    i.89 = (unsigned int) i;
    D.20303 = i.89 * 4;
    D.20304 = D.20301 + D.20303;
    D.20305 = *D.20304;
    D.20306 = D.20305->slot;
    slot = (guint32) D.20306;
    goto <D.18445>;
    <D.20300>:
    i = i + 1;
    <D.18447>:
    i.90 = (unsigned int) i;
    D.20308 = ic->method.count;
    if (i.90 < D.20308) goto <D.18446>; else goto <D.18445>;
    <D.18445>:
  }
  <D.20286>:
  <D.20284>:
  <D.20281>:
  D.20309 = ic == 0B;
  D.20310 = (long int) D.20309;
  D.20311 = __builtin_expect (D.20310, 0);
  if (D.20311 != 0) goto <D.20312>; else goto <D.20313>;
  <D.20312>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 373, "ic");
  <D.20313>:
  D.20278 = ic->flags;
  D.20279 = D.20278 & 32;
  if (D.20279 == 0) goto <D.20317>; else goto <D.20315>;
  <D.20317>:
  D.20282 = ic->byval_arg.type;
  if (D.20282 != 19) goto <D.20318>; else goto <D.20315>;
  <D.20318>:
  D.20282 = ic->byval_arg.type;
  if (D.20282 != 30) goto <D.20319>; else goto <D.20315>;
  <D.20319>:
  iftmp.91 = 1;
  goto <D.20316>;
  <D.20315>:
  iftmp.91 = 0;
  <D.20316>:
  D.20320 = iftmp.91 != 0;
  D.20321 = (long int) D.20320;
  D.20322 = __builtin_expect (D.20321, 0);
  if (D.20322 != 0) goto <D.20323>; else goto <D.20324>;
  <D.20323>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 374, "MONO_CLASS_IS_INTERFACE (ic)");
  <D.20324>:
  D.20326 = cominterop_get_com_slot_begin (ic);
  D.20327 = (unsigned int) D.20326;
  D.20328 = D.20327 + slot;
  D.20325 = (int) D.20328;
  return D.20325;
}


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.20333;
  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.20342;
  struct MonoMethod * get_transparent_proxy.97;
  struct MonoType * D.20344;
  struct MonoClass * D.20345;
  struct MonoType * D.20346;
  _Bool D.20349;
  long int D.20350;
  long int D.20351;

  switch (conv) <default: <D.18539>, case 25: <D.18527>, case 26: <D.18529>, case 27: <D.18528>>
  <D.18527>:
  <D.18528>:
  <D.18529>:
  {
    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.20331>; else goto <D.20332>;
    <D.20331>:
    D.20333 = mono_defaults.corlib;
    com_interop_proxy_class.93 = mono_class_from_name (D.20333, "Mono.Interop", "ComInteropProxy");
    com_interop_proxy_class = com_interop_proxy_class.93;
    <D.20332>:
    com_interop_proxy_get_proxy.94 = com_interop_proxy_get_proxy;
    if (com_interop_proxy_get_proxy.94 == 0B) goto <D.20336>; else goto <D.20337>;
    <D.20336>:
    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.20337>:
    get_transparent_proxy.96 = get_transparent_proxy;
    if (get_transparent_proxy.96 == 0B) goto <D.20340>; else goto <D.20341>;
    <D.20340>:
    D.20342 = mono_defaults.real_proxy_class;
    get_transparent_proxy.97 = mono_class_get_method_from_name (D.20342, "GetTransparentProxy", 0);
    get_transparent_proxy = get_transparent_proxy.97;
    <D.20341>:
    com_interop_proxy_class.92 = com_interop_proxy_class;
    D.20344 = &com_interop_proxy_class.92->byval_arg;
    real_proxy = mono_mb_add_local (mb, D.20344);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 77);
    D.20345 = mono_class_get_com_object_class ();
    D.20346 = &D.20345->byval_arg;
    mono_mb_emit_ptr (mb, D.20346);
    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.20347>; else goto <D.20348>;
    <D.20347>:
    D.20349 = klass == 0B;
    D.20350 = (long int) D.20349;
    D.20351 = __builtin_expect (D.20350, 0);
    if (D.20351 != 0) goto <D.20352>; else goto <D.20353>;
    <D.20352>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 631, "klass");
    <D.20353>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20348>:
    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.20354>; else goto <D.20355>;
    <D.20354>:
    D.20349 = klass == 0B;
    D.20350 = (long int) D.20349;
    D.20351 = __builtin_expect (D.20350, 0);
    if (D.20351 != 0) goto <D.20356>; else goto <D.20357>;
    <D.20356>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 645, "klass");
    <D.20357>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20355>:
    mono_mb_emit_byte (mb, 81);
    mono_mb_patch_short_branch (mb, pos_end);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.18538>;
  }
  <D.18539>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 656);
  <D.18538>:
}


mono_cominterop_emit_object_to_ptr_conv (struct MonoMethodBuilder * mb, struct MonoType * type, MonoMarshalConv conv, struct MonoMarshalSpec * mspec)
{
  struct MonoClass * D.20360;
  struct MonoProperty * iunknown.98;
  struct MonoClass * D.20367;
  struct MonoProperty * iunknown.99;
  struct MonoMethod * D.20369;
  struct MonoProperty * idispatch.100;
  struct MonoClass * D.20376;
  struct MonoProperty * idispatch.101;
  struct MonoMethod * D.20378;
  struct MonoClass * D.20382;
  struct MonoClass * D.20386;
  struct MonoClass * D.20390;

  switch (conv) <default: <D.18555>, case 25: <D.18546>, case 26: <D.18547>, case 27: <D.18548>>
  <D.18546>:
  <D.18547>:
  <D.18548>:
  {
    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.20358>; else goto <D.20359>;
    <D.20358>:
    D.20360 = mono_type_get_class (type);
    mono_mb_emit_ptr (mb, D.20360);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_interface);
    goto <D.20361>;
    <D.20359>:
    if (conv == 27) goto <D.20362>; else goto <D.20363>;
    <D.20362>:
    {
      static struct MonoProperty * iunknown = 0B;

      iunknown.98 = iunknown;
      if (iunknown.98 == 0B) goto <D.20365>; else goto <D.20366>;
      <D.20365>:
      D.20367 = mono_class_get_com_object_class ();
      iunknown.99 = mono_class_get_property_from_name (D.20367, "IUnknown");
      iunknown = iunknown.99;
      <D.20366>:
      iunknown.98 = iunknown;
      D.20369 = iunknown.98->get;
      mono_mb_emit_managed_call (mb, D.20369, 0B);
    }
    goto <D.20370>;
    <D.20363>:
    if (conv == 26) goto <D.20371>; else goto <D.20372>;
    <D.20371>:
    {
      static struct MonoProperty * idispatch = 0B;

      idispatch.100 = idispatch;
      if (idispatch.100 == 0B) goto <D.20374>; else goto <D.20375>;
      <D.20374>:
      D.20376 = mono_class_get_com_object_class ();
      idispatch.101 = mono_class_get_property_from_name (D.20376, "IDispatch");
      idispatch = idispatch.101;
      <D.20375>:
      idispatch.100 = idispatch;
      D.20378 = idispatch.100->get;
      mono_mb_emit_managed_call (mb, D.20378, 0B);
    }
    goto <D.20379>;
    <D.20372>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 719);
    <D.20379>:
    <D.20370>:
    <D.20361>:
    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.20380>; else goto <D.20381>;
    <D.20380>:
    D.20382 = mono_type_get_class (type);
    mono_mb_emit_ptr (mb, D.20382);
    goto <D.20383>;
    <D.20381>:
    if (conv == 27) goto <D.20384>; else goto <D.20385>;
    <D.20384>:
    D.20386 = mono_class_get_iunknown_class ();
    mono_mb_emit_ptr (mb, D.20386);
    goto <D.20387>;
    <D.20385>:
    if (conv == 26) goto <D.20388>; else goto <D.20389>;
    <D.20388>:
    D.20390 = mono_class_get_idispatch_class ();
    mono_mb_emit_ptr (mb, D.20390);
    goto <D.20391>;
    <D.20389>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 739);
    <D.20391>:
    <D.20387>:
    <D.20383>:
    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.18554>;
  }
  <D.18555>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 748);
  <D.18554>:
}


mono_cominterop_get_native_wrapper (struct MonoMethod * method)
{
  _Bool D.20392;
  long int D.20393;
  long int D.20394;
  struct MonoClass * D.20397;
  struct MonoImage * D.20398;
  struct GHashTable * * D.20399;
  struct MonoMethod * D.20402;
  struct MonoMethod * * D.20403;
  struct MonoMethod * * D.20406;
  unsigned char D.20409;
  _Bool D.20410;
  long int D.20411;
  long int D.20412;
  const char * D.20415;
  unsigned int D.20416;
  unsigned int D.20417;
  int D.18592;
  int iftmp.102;
  int D.18591;
  const char[6] * D.20423;
  unsigned char D.20424;
  int D.20425;
  unsigned char D.20426;
  int D.20427;
  _Bool D.20428;
  _Bool D.20429;
  _Bool D.20430;
  const unsigned char * D.20433;
  unsigned char D.20434;
  int D.20435;
  const unsigned char * D.20436;
  unsigned char D.20437;
  int D.20438;
  _Bool D.20439;
  _Bool D.20440;
  const unsigned char * D.20443;
  unsigned char D.20444;
  int D.20445;
  const unsigned char * D.20446;
  unsigned char D.20447;
  int D.20448;
  _Bool D.20449;
  _Bool D.20450;
  const unsigned char * D.20453;
  unsigned char D.20454;
  int D.20455;
  const unsigned char * D.20456;
  unsigned char D.20457;
  int D.20458;
  struct MonoMethod * ctor.103;
  struct MonoClass * D.20465;
  struct MonoMethod * ctor.104;
  short unsigned int D.20468;
  int D.20469;
  struct MonoClass * D.20470;
  struct MonoType * D.20471;
  struct MonoType * D.20472;
  int D.20473;
  unsigned int ptr_this.105;
  unsigned int i.106;
  short unsigned int D.20478;
  int D.20479;
  int D.20480;
  unsigned int retval.107;
  struct MonoMethod * ThrowExceptionForHR.108;
  struct MonoClass * D.20491;
  struct MonoMethod * ThrowExceptionForHR.109;
  int D.20493;
  short unsigned int D.20497;
  int D.20498;
  int D.20499;
  struct MonoMethod * res;
  struct GHashTable * cache;
  struct MonoMethodBuilder * mb;
  struct MonoMethodSignature * sig;
  struct MonoMethodSignature * csig;

  D.20392 = method == 0B;
  D.20393 = (long int) D.20392;
  D.20394 = __builtin_expect (D.20393, 0);
  if (D.20394 != 0) goto <D.20395>; else goto <D.20396>;
  <D.20395>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 869, "method");
  <D.20396>:
  D.20397 = method->klass;
  D.20398 = D.20397->image;
  D.20399 = &D.20398->cominterop_wrapper_cache;
  cache = mono_marshal_get_cache (D.20399, mono_aligned_addr_hash, 0B);
  res = mono_marshal_find_in_cache (cache, method);
  if (res != 0B) goto <D.20400>; else goto <D.20401>;
  <D.20400>:
  D.20402 = res;
  return D.20402;
  <D.20401>:
  D.20397 = method->klass;
  D.20403 = D.20397->vtable;
  if (D.20403 == 0B) goto <D.20404>; else goto <D.20405>;
  <D.20404>:
  D.20397 = method->klass;
  mono_class_setup_vtable (D.20397);
  <D.20405>:
  D.20397 = method->klass;
  D.20406 = D.20397->methods;
  if (D.20406 == 0B) goto <D.20407>; else goto <D.20408>;
  <D.20407>:
  D.20397 = method->klass;
  mono_class_setup_methods (D.20397);
  <D.20408>:
  D.20397 = method->klass;
  D.20409 = D.20397->exception_type;
  D.20410 = D.20409 != 0;
  D.20411 = (long int) D.20410;
  D.20412 = __builtin_expect (D.20411, 0);
  if (D.20412 != 0) goto <D.20413>; else goto <D.20414>;
  <D.20413>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 880, "!method->klass->exception_type");
  <D.20414>:
  sig = mono_method_signature (method);
  D.20415 = method->name;
  D.20397 = method->klass;
  mb = mono_mb_new (D.20397, D.20415, 27);
  D.20397 = method->klass;
  D.20416 = D.20397->flags;
  D.20417 = D.20416 & 4096;
  if (D.20417 != 0) goto <D.20418>; else goto <D.20419>;
  <D.20418>:
  {
    size_t __s1_len;
    size_t __s2_len;

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

      __s2 = method->name;
      D.20423 = ".ctor";
      D.20424 = MEM[(const unsigned char *)D.20423];
      D.20425 = (int) D.20424;
      D.20426 = *__s2;
      D.20427 = (int) D.20426;
      __result = D.20425 - D.20427;
      {
        D.20428 = __s2_len != 0;
        D.20429 = __result == 0;
        D.20430 = D.20428 & D.20429;
        if (D.20430 != 0) goto <D.20431>; else goto <D.20432>;
        <D.20431>:
        D.20433 = &MEM[(void *)".ctor" + 1B];
        D.20434 = *D.20433;
        D.20435 = (int) D.20434;
        D.20436 = __s2 + 1;
        D.20437 = *D.20436;
        D.20438 = (int) D.20437;
        __result = D.20435 - D.20438;
        D.20439 = __s2_len > 1;
        D.20429 = __result == 0;
        D.20440 = D.20439 & D.20429;
        if (D.20440 != 0) goto <D.20441>; else goto <D.20442>;
        <D.20441>:
        D.20443 = &MEM[(void *)".ctor" + 2B];
        D.20444 = *D.20443;
        D.20445 = (int) D.20444;
        D.20446 = __s2 + 2;
        D.20447 = *D.20446;
        D.20448 = (int) D.20447;
        __result = D.20445 - D.20448;
        D.20449 = __s2_len > 2;
        D.20429 = __result == 0;
        D.20450 = D.20449 & D.20429;
        if (D.20450 != 0) goto <D.20451>; else goto <D.20452>;
        <D.20451>:
        D.20453 = &MEM[(void *)".ctor" + 3B];
        D.20454 = *D.20453;
        D.20455 = (int) D.20454;
        D.20456 = __s2 + 3;
        D.20457 = *D.20456;
        D.20458 = (int) D.20457;
        __result = D.20455 - D.20458;
        <D.20452>:
        <D.20442>:
        <D.20432>:
      }
      D.18591 = __result;
    }
    iftmp.102 = -D.18591;
    goto <D.20459>;
    <D.20422>:
    D.20415 = method->name;
    iftmp.102 = __builtin_strcmp (D.20415, ".ctor");
    <D.20459>:
    D.18592 = iftmp.102;
  }
  if (D.18592 == 0) goto <D.20460>; else goto <D.20461>;
  <D.20460>:
  {
    static struct MonoMethod * ctor = 0B;

    ctor.103 = ctor;
    if (ctor.103 == 0B) goto <D.20463>; else goto <D.20464>;
    <D.20463>:
    D.20465 = mono_class_get_com_object_class ();
    ctor.104 = mono_class_get_method_from_name (D.20465, ".ctor", 0);
    ctor = ctor.104;
    <D.20464>:
    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.20467>;
  <D.20461>:
  {
    static struct MonoMethod * ThrowExceptionForHR = 0B;
    struct MonoMethod * adjusted_method;
    int retval;
    int ptr_this;
    int i;
    gboolean preserve_sig;

    retval = 0;
    D.20468 = method->iflags;
    D.20469 = (int) D.20468;
    preserve_sig = D.20469 & 128;
    D.20470 = mono_defaults.int_class;
    D.20471 = &D.20470->byval_arg;
    ptr_this = mono_mb_add_local (mb, D.20471);
    D.20472 = sig->ret;
    D.20473 = mono_type_is_void (D.20472);
    if (D.20473 == 0) goto <D.20474>; else goto <D.20475>;
    <D.20474>:
    D.20472 = sig->ret;
    retval = mono_mb_add_local (mb, D.20472);
    <D.20475>:
    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.18601>;
    <D.18600>:
    i.106 = (unsigned int) i;
    mono_mb_emit_ldarg (mb, i.106);
    i = i + 1;
    <D.18601>:
    D.20478 = sig->param_count;
    D.20479 = (int) D.20478;
    if (D.20479 >= i) goto <D.18600>; else goto <D.18602>;
    <D.18602>:
    D.20472 = sig->ret;
    D.20480 = mono_type_is_void (D.20472);
    if (D.20480 == 0) goto <D.20481>; else goto <D.20482>;
    <D.20481>:
    if (preserve_sig == 0) goto <D.20483>; else goto <D.20484>;
    <D.20483>:
    retval.107 = (unsigned int) retval;
    mono_mb_emit_ldloc_addr (mb, retval.107);
    <D.20484>:
    <D.20482>:
    adjusted_method = cominterop_get_native_wrapper_adjusted (method);
    mono_mb_emit_managed_call (mb, adjusted_method, 0B);
    if (preserve_sig == 0) goto <D.20486>; else goto <D.20487>;
    <D.20486>:
    ThrowExceptionForHR.108 = ThrowExceptionForHR;
    if (ThrowExceptionForHR.108 == 0B) goto <D.20489>; else goto <D.20490>;
    <D.20489>:
    D.20491 = mono_defaults.marshal_class;
    ThrowExceptionForHR.109 = mono_class_get_method_from_name (D.20491, "ThrowExceptionForHR", 1);
    ThrowExceptionForHR = ThrowExceptionForHR.109;
    <D.20490>:
    ThrowExceptionForHR.108 = ThrowExceptionForHR;
    mono_mb_emit_managed_call (mb, ThrowExceptionForHR.108, 0B);
    D.20472 = sig->ret;
    D.20493 = mono_type_is_void (D.20472);
    if (D.20493 == 0) goto <D.20494>; else goto <D.20495>;
    <D.20494>:
    retval.107 = (unsigned int) retval;
    mono_mb_emit_ldloc (mb, retval.107);
    <D.20495>:
    <D.20487>:
    mono_mb_emit_byte (mb, 42);
  }
  <D.20467>:
  goto <D.20496>;
  <D.20419>:
  {
    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.20496>:
  D.20397 = method->klass;
  D.20398 = D.20397->image;
  csig = mono_metadata_signature_dup_full (D.20398, sig);
  csig->pinvoke = 0;
  D.20497 = csig->param_count;
  D.20498 = (int) D.20497;
  D.20499 = D.20498 + 16;
  res = mono_mb_create_and_cache (cache, method, mb, csig, D.20499);
  mono_mb_free (mb);
  D.20402 = res;
  return D.20402;
}


cominterop_get_native_wrapper_adjusted (struct MonoMethod * method)
{
  const char * D.20501;
  struct MonoClass * D.20502;
  short unsigned int D.20503;
  int D.20504;
  int D.20505;
  unsigned int D.20506;
  unsigned int D.20507;
  short unsigned int D.20508;
  sizetype i.110;
  sizetype D.20510;
  sizetype D.20511;
  struct MonoMarshalSpec * * D.20512;
  unsigned int i.111;
  unsigned int D.20514;
  struct MonoMarshalSpec * * D.20515;
  struct MonoMarshalSpec * D.20516;
  struct MonoMarshalSpec * * D.20517;
  short unsigned int D.20518;
  int D.20519;
  int D.20520;
  struct MonoType * D.20523;
  int D.20524;
  unsigned int D.20527;
  unsigned int D.20528;
  struct MonoMarshalSpec * * D.20529;
  struct MonoMarshalSpec * D.20530;
  unsigned int mspec_index.112;
  unsigned int D.20532;
  struct MonoMarshalSpec * * D.20533;
  struct MonoMarshalSpec * D.20534;
  struct MonoType * D.20537;
  unsigned char D.20538;
  void * D.20541;
  void * D.20545;
  void * D.20549;
  void * D.20553;
  int D.20556;
  unsigned char D.20561;
  void * D.20564;
  void * D.20568;
  void * D.20572;
  void * D.20576;
  void * D.20577;
  struct MonoImage * D.20578;
  int D.20579;
  struct MonoMethod * D.20582;
  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.20501 = method->name;
  D.20502 = method->klass;
  mb_native = mono_mb_new (D.20502, D.20501, 6);
  sig_native = cominterop_method_signature (method);
  D.20503 = sig_native->param_count;
  D.20504 = (int) D.20503;
  D.20505 = D.20504 + 1;
  D.20506 = (unsigned int) D.20505;
  D.20507 = D.20506 * 4;
  mspecs = monoeg_malloc (D.20507);
  D.20503 = sig_native->param_count;
  D.20504 = (int) D.20503;
  D.20505 = D.20504 + 1;
  D.20506 = (unsigned int) D.20505;
  D.20507 = D.20506 * 4;
  memset (mspecs, 0, D.20507);
  mono_method_get_marshal_info (method, mspecs);
  D.20508 = sig->param_count;
  i = (int) D.20508;
  goto <D.18567>;
  <D.18566>:
  i.110 = (sizetype) i;
  D.20510 = i.110 + 1;
  D.20511 = D.20510 * 4;
  D.20512 = mspecs + D.20511;
  i.111 = (unsigned int) i;
  D.20514 = i.111 * 4;
  D.20515 = mspecs + D.20514;
  D.20516 = *D.20515;
  *D.20512 = D.20516;
  i = i + -1;
  <D.18567>:
  if (i > 0) goto <D.18566>; else goto <D.18568>;
  <D.18568>:
  D.20517 = mspecs + 4;
  *D.20517 = 0B;
  D.20518 = method->iflags;
  D.20519 = (int) D.20518;
  D.20520 = D.20519 & 128;
  if (D.20520 == 0) goto <D.20521>; else goto <D.20522>;
  <D.20521>:
  D.20523 = sig->ret;
  D.20524 = mono_type_is_void (D.20523);
  if (D.20524 == 0) goto <D.20525>; else goto <D.20526>;
  <D.20525>:
  D.20503 = sig_native->param_count;
  D.20527 = (unsigned int) D.20503;
  D.20528 = D.20527 * 4;
  D.20529 = mspecs + D.20528;
  D.20530 = *mspecs;
  *D.20529 = D.20530;
  <D.20526>:
  *mspecs = 0B;
  <D.20522>:
  i = 1;
  goto <D.18571>;
  <D.18570>:
  {
    int mspec_index;

    mspec_index = i + 1;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20534 = *D.20533;
    if (D.20534 == 0B) goto <D.20535>; else goto <D.20536>;
    <D.20535>:
    D.20537 = sig_native->params[i];
    D.20538 = D.20537->type;
    if (D.20538 == 28) goto <D.20539>; else goto <D.20540>;
    <D.20539>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20541 = monoeg_malloc0 (16);
    *D.20533 = D.20541;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20534 = *D.20533;
    D.20534->native = 27;
    goto <D.20542>;
    <D.20540>:
    D.20537 = sig_native->params[i];
    D.20538 = D.20537->type;
    if (D.20538 == 14) goto <D.20543>; else goto <D.20544>;
    <D.20543>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20545 = monoeg_malloc0 (16);
    *D.20533 = D.20545;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20534 = *D.20533;
    D.20534->native = 19;
    goto <D.20546>;
    <D.20544>:
    D.20537 = sig_native->params[i];
    D.20538 = D.20537->type;
    if (D.20538 == 18) goto <D.20547>; else goto <D.20548>;
    <D.20547>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20549 = monoeg_malloc0 (16);
    *D.20533 = D.20549;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20534 = *D.20533;
    D.20534->native = 28;
    goto <D.20550>;
    <D.20548>:
    D.20537 = sig_native->params[i];
    D.20538 = D.20537->type;
    if (D.20538 == 2) goto <D.20551>; else goto <D.20552>;
    <D.20551>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20553 = monoeg_malloc0 (16);
    *D.20533 = D.20553;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20532 = mspec_index.112 * 4;
    D.20533 = mspecs + D.20532;
    D.20534 = *D.20533;
    D.20534->native = 37;
    <D.20552>:
    <D.20550>:
    <D.20546>:
    <D.20542>:
    <D.20536>:
  }
  i = i + 1;
  <D.18571>:
  D.20503 = sig_native->param_count;
  D.20504 = (int) D.20503;
  if (D.20504 > i) goto <D.18570>; else goto <D.18572>;
  <D.18572>:
  D.20518 = method->iflags;
  D.20519 = (int) D.20518;
  D.20520 = D.20519 & 128;
  if (D.20520 != 0) goto <D.20554>; else goto <D.20555>;
  <D.20554>:
  D.20523 = sig->ret;
  D.20556 = mono_type_is_void (D.20523);
  if (D.20556 == 0) goto <D.20557>; else goto <D.20558>;
  <D.20557>:
  D.20530 = *mspecs;
  if (D.20530 == 0B) goto <D.20559>; else goto <D.20560>;
  <D.20559>:
  D.20523 = sig->ret;
  D.20561 = D.20523->type;
  if (D.20561 == 28) goto <D.20562>; else goto <D.20563>;
  <D.20562>:
  D.20564 = monoeg_malloc0 (16);
  *mspecs = D.20564;
  D.20530 = *mspecs;
  D.20530->native = 27;
  goto <D.20565>;
  <D.20563>:
  D.20523 = sig->ret;
  D.20561 = D.20523->type;
  if (D.20561 == 14) goto <D.20566>; else goto <D.20567>;
  <D.20566>:
  D.20568 = monoeg_malloc0 (16);
  *mspecs = D.20568;
  D.20530 = *mspecs;
  D.20530->native = 19;
  goto <D.20569>;
  <D.20567>:
  D.20523 = sig->ret;
  D.20561 = D.20523->type;
  if (D.20561 == 18) goto <D.20570>; else goto <D.20571>;
  <D.20570>:
  D.20572 = monoeg_malloc0 (16);
  *mspecs = D.20572;
  D.20530 = *mspecs;
  D.20530->native = 28;
  goto <D.20573>;
  <D.20571>:
  D.20523 = sig->ret;
  D.20561 = D.20523->type;
  if (D.20561 == 2) goto <D.20574>; else goto <D.20575>;
  <D.20574>:
  D.20576 = monoeg_malloc0 (16);
  *mspecs = D.20576;
  D.20530 = *mspecs;
  D.20530->native = 37;
  <D.20575>:
  <D.20573>:
  <D.20569>:
  <D.20565>:
  <D.20560>:
  <D.20558>:
  <D.20555>:
  D.20577 = piinfo->addr;
  D.20502 = method->klass;
  D.20578 = D.20502->image;
  mono_marshal_emit_native_wrapper (D.20578, mb_native, sig_native, piinfo, mspecs, D.20577, 0, 1, 0);
  D.20503 = sig_native->param_count;
  D.20504 = (int) D.20503;
  D.20579 = D.20504 + 16;
  res = mono_mb_create_method (mb_native, sig_native, D.20579);
  mono_mb_free (mb_native);
  D.20503 = sig_native->param_count;
  i = (int) D.20503;
  goto <D.18574>;
  <D.18573>:
  i.111 = (unsigned int) i;
  D.20514 = i.111 * 4;
  D.20515 = mspecs + D.20514;
  D.20516 = *D.20515;
  if (D.20516 != 0B) goto <D.20580>; else goto <D.20581>;
  <D.20580>:
  i.111 = (unsigned int) i;
  D.20514 = i.111 * 4;
  D.20515 = mspecs + D.20514;
  D.20516 = *D.20515;
  mono_metadata_free_marshal_spec (D.20516);
  <D.20581>:
  i = i + -1;
  <D.18574>:
  if (i >= 0) goto <D.18573>; else goto <D.18575>;
  <D.18575>:
  monoeg_g_free (mspecs);
  D.20582 = res;
  return D.20582;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.20586;
  int D.20591;
  void * D.20593;
  unsigned int D.20594;

  D.20586 = __builtin_constant_p (__len);
  if (D.20586 != 0) goto <D.20587>; else goto <D.20588>;
  <D.20587>:
  if (__len == 0) goto <D.20589>; else goto <D.20590>;
  <D.20589>:
  D.20591 = __builtin_constant_p (__ch);
  if (D.20591 == 0) goto <D.20584>; else goto <D.20592>;
  <D.20592>:
  if (__ch != 0) goto <D.20584>; else goto <D.20585>;
  <D.20584>:
  __warn_memset_zero_len ();
  D.20593 = __dest;
  return D.20593;
  <D.20585>:
  <D.20590>:
  <D.20588>:
  D.20594 = __builtin_object_size (__dest, 0);
  D.20593 = __builtin___memset_chk (__dest, __ch, __len, D.20594);
  return D.20593;
}


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

  if (str != 0B) goto <D.20596>; else goto <D.20597>;
  <D.20596>:
  D.20598 = __strdup (str);
  return D.20598;
  <D.20597>:
  D.20598 = 0B;
  return D.20598;
}


mono_cominterop_get_invoke (struct MonoMethod * method)
{
  struct MonoClass * D.20600;
  struct MonoImage * D.20601;
  struct GHashTable * * D.20602;
  _Bool D.20603;
  long int D.20604;
  long int D.20605;
  struct MonoMethod * D.20610;
  unsigned char D.20611;
  unsigned char D.20612;
  const char * D.20615;
  struct MonoClass * D.20616;
  struct MonoType * D.20617;
  unsigned int i.113;
  short unsigned int D.20619;
  int D.20620;
  short unsigned int D.20621;
  int D.20622;
  int D.20623;
  short unsigned int D.20627;
  int D.20628;
  int D.20629;
  int D.18625;
  int iftmp.114;
  int D.18624;
  const char[6] * D.20636;
  unsigned char D.20637;
  int D.20638;
  unsigned char D.20639;
  int D.20640;
  _Bool D.20641;
  _Bool D.20642;
  _Bool D.20643;
  const unsigned char * D.20646;
  unsigned char D.20647;
  int D.20648;
  const unsigned char * D.20649;
  unsigned char D.20650;
  int D.20651;
  _Bool D.20652;
  _Bool D.20653;
  const unsigned char * D.20656;
  unsigned char D.20657;
  int D.20658;
  const unsigned char * D.20659;
  unsigned char D.20660;
  int D.20661;
  _Bool D.20662;
  _Bool D.20663;
  const unsigned char * D.20666;
  unsigned char D.20667;
  int D.20668;
  const unsigned char * D.20669;
  unsigned char D.20670;
  int D.20671;
  struct MonoClass * com_interop_proxy_class.115;
  struct MonoImage * D.20678;
  struct MonoClass * com_interop_proxy_class.116;
  struct MonoMethod * cache_proxy.117;
  struct MonoMethod * cache_proxy.118;
  int D.20684;
  struct MonoMethodSignature * sig;
  struct MonoMethodBuilder * mb;
  struct MonoMethod * res;
  int i;
  int temp_obj;
  struct GHashTable * cache;

  D.20600 = method->klass;
  D.20601 = D.20600->image;
  D.20602 = &D.20601->cominterop_invoke_cache;
  cache = mono_marshal_get_cache (D.20602, mono_aligned_addr_hash, 0B);
  D.20603 = method == 0B;
  D.20604 = (long int) D.20603;
  D.20605 = __builtin_expect (D.20604, 0);
  if (D.20605 != 0) goto <D.20606>; else goto <D.20607>;
  <D.20606>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 982, "method");
  <D.20607>:
  res = mono_marshal_find_in_cache (cache, method);
  if (res != 0B) goto <D.20608>; else goto <D.20609>;
  <D.20608>:
  D.20610 = res;
  return D.20610;
  <D.20609>:
  sig = mono_signature_no_pinvoke (method);
  D.20611 = BIT_FIELD_REF <*sig, 8, 80>;
  D.20612 = D.20611 & 64;
  if (D.20612 == 0) goto <D.20613>; else goto <D.20614>;
  <D.20613>:
  D.20610 = method;
  return D.20610;
  <D.20614>:
  D.20615 = method->name;
  D.20600 = method->klass;
  mb = mono_mb_new (D.20600, D.20615, 26);
  D.20616 = mono_defaults.object_class;
  D.20617 = &D.20616->byval_arg;
  temp_obj = mono_mb_add_local (mb, D.20617);
  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.18614>;
  <D.18613>:
  i.113 = (unsigned int) i;
  mono_mb_emit_ldarg (mb, i.113);
  i = i + 1;
  <D.18614>:
  D.20619 = sig->param_count;
  D.20620 = (int) D.20619;
  if (D.20620 >= i) goto <D.18613>; else goto <D.18615>;
  <D.18615>:
  D.20621 = method->iflags;
  D.20622 = (int) D.20621;
  D.20623 = D.20622 & 4096;
  if (D.20623 != 0) goto <D.20624>; else goto <D.20625>;
  <D.20624>:
  {
    struct MonoMethod * native_wrapper;

    native_wrapper = mono_cominterop_get_native_wrapper (method);
    mono_mb_emit_managed_call (mb, native_wrapper, 0B);
  }
  goto <D.20626>;
  <D.20625>:
  D.20627 = method->flags;
  D.20628 = (int) D.20627;
  D.20629 = D.20628 & 64;
  if (D.20629 != 0) goto <D.20630>; else goto <D.20631>;
  <D.20630>:
  mono_mb_emit_op (mb, 111, method);
  goto <D.20632>;
  <D.20631>:
  mono_mb_emit_op (mb, 40, method);
  <D.20632>:
  <D.20626>:
  {
    size_t __s1_len;
    size_t __s2_len;

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

      __s2 = method->name;
      D.20636 = ".ctor";
      D.20637 = MEM[(const unsigned char *)D.20636];
      D.20638 = (int) D.20637;
      D.20639 = *__s2;
      D.20640 = (int) D.20639;
      __result = D.20638 - D.20640;
      {
        D.20641 = __s2_len != 0;
        D.20642 = __result == 0;
        D.20643 = D.20641 & D.20642;
        if (D.20643 != 0) goto <D.20644>; else goto <D.20645>;
        <D.20644>:
        D.20646 = &MEM[(void *)".ctor" + 1B];
        D.20647 = *D.20646;
        D.20648 = (int) D.20647;
        D.20649 = __s2 + 1;
        D.20650 = *D.20649;
        D.20651 = (int) D.20650;
        __result = D.20648 - D.20651;
        D.20652 = __s2_len > 1;
        D.20642 = __result == 0;
        D.20653 = D.20652 & D.20642;
        if (D.20653 != 0) goto <D.20654>; else goto <D.20655>;
        <D.20654>:
        D.20656 = &MEM[(void *)".ctor" + 2B];
        D.20657 = *D.20656;
        D.20658 = (int) D.20657;
        D.20659 = __s2 + 2;
        D.20660 = *D.20659;
        D.20661 = (int) D.20660;
        __result = D.20658 - D.20661;
        D.20662 = __s2_len > 2;
        D.20642 = __result == 0;
        D.20663 = D.20662 & D.20642;
        if (D.20663 != 0) goto <D.20664>; else goto <D.20665>;
        <D.20664>:
        D.20666 = &MEM[(void *)".ctor" + 3B];
        D.20667 = *D.20666;
        D.20668 = (int) D.20667;
        D.20669 = __s2 + 3;
        D.20670 = *D.20669;
        D.20671 = (int) D.20670;
        __result = D.20668 - D.20671;
        <D.20665>:
        <D.20655>:
        <D.20645>:
      }
      D.18624 = __result;
    }
    iftmp.114 = -D.18624;
    goto <D.20672>;
    <D.20635>:
    D.20615 = method->name;
    iftmp.114 = __builtin_strcmp (D.20615, ".ctor");
    <D.20672>:
    D.18625 = iftmp.114;
  }
  if (D.18625 == 0) goto <D.20673>; else goto <D.20674>;
  <D.20673>:
  {
    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.20676>; else goto <D.20677>;
    <D.20676>:
    D.20678 = mono_defaults.corlib;
    com_interop_proxy_class.116 = mono_class_from_name (D.20678, "Mono.Interop", "ComInteropProxy");
    com_interop_proxy_class = com_interop_proxy_class.116;
    <D.20677>:
    cache_proxy.117 = cache_proxy;
    if (cache_proxy.117 == 0B) goto <D.20681>; else goto <D.20682>;
    <D.20681>:
    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.20682>:
    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.20674>:
  mono_marshal_emit_thread_interrupt_checkpoint (mb);
  mono_mb_emit_byte (mb, 42);
  D.20619 = sig->param_count;
  D.20620 = (int) D.20619;
  D.20684 = D.20620 + 16;
  res = mono_mb_create_and_cache (cache, method, mb, sig, D.20684);
  mono_mb_free (mb);
  D.20610 = res;
  return D.20610;
}


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.20689;
  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.20707;
  struct MonoType * D.20708;
  unsigned int conv_arg.129;
  unsigned char D.20710;
  unsigned char D.20711;
  short unsigned int D.20714;
  int D.20715;
  int D.20716;
  unsigned int argnum.130;
  struct MonoClass * D.20726;
  <unnamed type> D.20728;
  struct MonoType * D.20743;
  unsigned int ccw_obj.131;
  unsigned int ret_ptr.132;
  unsigned int ccw_obj.133;
  struct MonoType * D.20766;
  unsigned int ccw_obj.134;
  struct MonoMethod * AddRef.135;
  struct MonoMethod * AddRef.136;
  struct MonoMethod * AddRef.137;
  unsigned int ccw_obj.138;
  int D.20823;
  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.20687>; else goto <D.20688>;
  <D.20687>:
  D.20689 = mono_defaults.marshal_class;
  get_object_for_iunknown.120 = mono_class_get_method_from_name (D.20689, "GetObjectForIUnknown", 1);
  get_object_for_iunknown = get_object_for_iunknown.120;
  <D.20688>:
  get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
  if (get_iunknown_for_object_internal.121 == 0B) goto <D.20692>; else goto <D.20693>;
  <D.20692>:
  D.20689 = mono_defaults.marshal_class;
  get_iunknown_for_object_internal.122 = mono_class_get_method_from_name (D.20689, "GetIUnknownForObjectInternal", 1);
  get_iunknown_for_object_internal = get_iunknown_for_object_internal.122;
  <D.20693>:
  get_idispatch_for_object_internal.123 = get_idispatch_for_object_internal;
  if (get_idispatch_for_object_internal.123 == 0B) goto <D.20696>; else goto <D.20697>;
  <D.20696>:
  D.20689 = mono_defaults.marshal_class;
  get_idispatch_for_object_internal.124 = mono_class_get_method_from_name (D.20689, "GetIDispatchForObjectInternal", 1);
  get_idispatch_for_object_internal = get_idispatch_for_object_internal.124;
  <D.20697>:
  get_com_interface_for_object_internal.125 = get_com_interface_for_object_internal;
  if (get_com_interface_for_object_internal.125 == 0B) goto <D.20700>; else goto <D.20701>;
  <D.20700>:
  D.20689 = mono_defaults.marshal_class;
  get_com_interface_for_object_internal.126 = mono_class_get_method_from_name (D.20689, "GetComInterfaceForObjectInternal", 2);
  get_com_interface_for_object_internal = get_com_interface_for_object_internal.126;
  <D.20701>:
  marshal_release.127 = marshal_release;
  if (marshal_release.127 == 0B) goto <D.20704>; else goto <D.20705>;
  <D.20704>:
  D.20689 = mono_defaults.marshal_class;
  marshal_release.128 = mono_class_get_method_from_name (D.20689, "Release", 1);
  marshal_release = marshal_release.128;
  <D.20705>:
  switch (action) <default: <D.18673>, case 0: <D.18648>, case 1: <D.18656>, case 2: <D.18651>, case 3: <D.18657>, case 4: <D.18663>, case 5: <D.18668>, case 6: <D.18670>>
  <D.18648>:
  {
    guint32 pos_null;

    pos_null = 0;
    D.20707 = mono_defaults.int_class;
    D.20708 = &D.20707->byval_arg;
    *conv_arg_type = D.20708;
    D.20707 = mono_defaults.int_class;
    D.20708 = &D.20707->byval_arg;
    conv_arg = mono_mb_add_local (mb, D.20708);
    mono_mb_emit_ptr (mb, 0B);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    D.20710 = BIT_FIELD_REF <*t, 8, 56>;
    D.20711 = D.20710 & 64;
    if (D.20711 != 0) goto <D.20712>; else goto <D.20713>;
    <D.20712>:
    D.20714 = t->attrs;
    D.20715 = (int) D.20714;
    D.20716 = D.20715 & 2;
    if (D.20716 != 0) goto <D.18650>; else goto <D.20717>;
    <D.20717>:
    <D.20713>:
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.20710 = BIT_FIELD_REF <*t, 8, 56>;
    D.20711 = D.20710 & 64;
    if (D.20711 != 0) goto <D.20719>; else goto <D.20720>;
    <D.20719>:
    mono_mb_emit_byte (mb, 80);
    <D.20720>:
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.20710 = BIT_FIELD_REF <*t, 8, 56>;
    D.20711 = D.20710 & 64;
    if (D.20711 != 0) goto <D.20721>; else goto <D.20722>;
    <D.20721>:
    mono_mb_emit_byte (mb, 80);
    <D.20722>:
    if (klass != 0B) goto <D.20725>; else goto <D.20723>;
    <D.20725>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20727>; else goto <D.20723>;
    <D.20727>:
    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.20724>;
    <D.20723>:
    D.20728 = spec->native;
    if (D.20728 == 25) goto <D.20729>; else goto <D.20730>;
    <D.20729>:
    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.20731>;
    <D.20730>:
    D.20728 = spec->native;
    if (D.20728 == 26) goto <D.20732>; else goto <D.20733>;
    <D.20732>:
    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.20734>;
    <D.20733>:
    if (klass == 0B) goto <D.20737>; else goto <D.20735>;
    <D.20737>:
    D.20728 = spec->native;
    if (D.20728 == 28) goto <D.20738>; else goto <D.20735>;
    <D.20738>:
    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.20736>;
    <D.20735>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1128);
    <D.20736>:
    <D.20734>:
    <D.20731>:
    <D.20724>:
    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.18650>;
  }
  <D.18651>:
  D.20710 = BIT_FIELD_REF <*t, 8, 56>;
  D.20711 = D.20710 & 64;
  if (D.20711 != 0) goto <D.20739>; else goto <D.20740>;
  <D.20739>:
  D.20714 = t->attrs;
  D.20715 = (int) D.20714;
  D.20716 = D.20715 & 2;
  if (D.20716 != 0) goto <D.20741>; else goto <D.20742>;
  <D.20741>:
  {
    int ccw_obj;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.20726 = mono_defaults.object_class;
    D.20743 = &D.20726->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.20743);
    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.20745>; else goto <D.20746>;
    <D.20745>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20747>; else goto <D.20748>;
    <D.20747>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20748>:
    <D.20746>:
    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.20749>; else goto <D.20750>;
    <D.20749>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20751>; else goto <D.20752>;
    <D.20751>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20752>:
    <D.20750>:
    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.20742>:
  <D.20740>:
  goto <D.18650>;
  <D.18656>:
  D.20710 = BIT_FIELD_REF <*t, 8, 56>;
  D.20711 = D.20710 & 64;
  if (D.20711 != 0) goto <D.20753>; else goto <D.20754>;
  <D.20753>:
  conv_arg.129 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc_addr (mb, conv_arg.129);
  goto <D.20755>;
  <D.20754>:
  conv_arg.129 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc (mb, conv_arg.129);
  <D.20755>:
  goto <D.18650>;
  <D.18657>:
  {
    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.20726 = mono_defaults.object_class;
    D.20743 = &D.20726->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.20743);
    D.20707 = mono_defaults.int_class;
    D.20708 = &D.20707->byval_arg;
    ret_ptr = mono_mb_add_local (mb, D.20708);
    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.20758>; else goto <D.20759>;
    <D.20758>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20760>; else goto <D.20761>;
    <D.20760>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20761>:
    <D.20759>:
    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.20762>; else goto <D.20763>;
    <D.20762>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20764>; else goto <D.20765>;
    <D.20764>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20765>:
    <D.20763>:
    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.18650>;
  }
  <D.18663>:
  {
    int ccw_obj;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.20726 = mono_defaults.object_class;
    D.20743 = &D.20726->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.20743);
    klass = mono_class_from_mono_type (t);
    D.20766 = &klass->byval_arg;
    conv_arg = mono_mb_add_local (mb, D.20766);
    D.20707 = mono_defaults.int_class;
    D.20708 = &D.20707->byval_arg;
    *conv_arg_type = D.20708;
    mono_mb_emit_byte (mb, 20);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    D.20714 = t->attrs;
    D.20715 = (int) D.20714;
    D.20716 = D.20715 & 2;
    if (D.20716 != 0) goto <D.18650>; else goto <D.20767>;
    <D.20767>:
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.20710 = BIT_FIELD_REF <*t, 8, 56>;
    D.20711 = D.20710 & 64;
    if (D.20711 != 0) goto <D.20768>; else goto <D.20769>;
    <D.20768>:
    mono_mb_emit_byte (mb, 80);
    <D.20769>:
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.20710 = BIT_FIELD_REF <*t, 8, 56>;
    D.20711 = D.20710 & 64;
    if (D.20711 != 0) goto <D.20770>; else goto <D.20771>;
    <D.20770>:
    mono_mb_emit_byte (mb, 80);
    <D.20771>:
    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.20710 = BIT_FIELD_REF <*t, 8, 56>;
    D.20711 = D.20710 & 64;
    if (D.20711 != 0) goto <D.20773>; else goto <D.20774>;
    <D.20773>:
    mono_mb_emit_byte (mb, 80);
    <D.20774>:
    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.20775>; else goto <D.20776>;
    <D.20775>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20777>; else goto <D.20778>;
    <D.20777>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20778>:
    <D.20776>:
    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.20779>; else goto <D.20780>;
    <D.20779>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20781>; else goto <D.20782>;
    <D.20781>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20782>:
    <D.20780>:
    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.18650>;
  }
  <D.18668>:
  D.20710 = BIT_FIELD_REF <*t, 8, 56>;
  D.20711 = D.20710 & 64;
  if (D.20711 != 0) goto <D.20783>; else goto <D.20784>;
  <D.20783>:
  D.20714 = t->attrs;
  D.20715 = (int) D.20714;
  D.20716 = D.20715 & 2;
  if (D.20716 != 0) goto <D.20785>; else goto <D.20786>;
  <D.20785>:
  {
    guint32 pos_null;

    pos_null = 0;
    AddRef.135 = AddRef;
    if (AddRef.135 == 0B) goto <D.20788>; else goto <D.20789>;
    <D.20788>:
    D.20689 = mono_defaults.marshal_class;
    AddRef.136 = mono_class_get_method_from_name (D.20689, "AddRef", 1);
    AddRef = AddRef.136;
    <D.20789>:
    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.20793>; else goto <D.20791>;
    <D.20793>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20794>; else goto <D.20791>;
    <D.20794>:
    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.20792>;
    <D.20791>:
    D.20728 = spec->native;
    if (D.20728 == 25) goto <D.20795>; else goto <D.20796>;
    <D.20795>:
    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.20797>;
    <D.20796>:
    D.20728 = spec->native;
    if (D.20728 == 26) goto <D.20798>; else goto <D.20799>;
    <D.20798>:
    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.20800>;
    <D.20799>:
    if (klass == 0B) goto <D.20803>; else goto <D.20801>;
    <D.20803>:
    D.20728 = spec->native;
    if (D.20728 == 28) goto <D.20804>; else goto <D.20801>;
    <D.20804>:
    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.20802>;
    <D.20801>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1321);
    <D.20802>:
    <D.20800>:
    <D.20797>:
    <D.20792>:
    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.20786>:
  <D.20784>:
  goto <D.18650>;
  <D.18670>:
  {
    guint32 pos_null;
    int ccw_obj;

    pos_null = 0;
    D.20726 = mono_defaults.object_class;
    D.20743 = &D.20726->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.20743);
    AddRef.135 = AddRef;
    if (AddRef.135 == 0B) goto <D.20805>; else goto <D.20806>;
    <D.20805>:
    D.20689 = mono_defaults.marshal_class;
    AddRef.137 = mono_class_get_method_from_name (D.20689, "AddRef", 1);
    AddRef = AddRef.137;
    <D.20806>:
    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.20811>; else goto <D.20809>;
    <D.20811>:
    D.20726 = mono_defaults.object_class;
    if (D.20726 != klass) goto <D.20812>; else goto <D.20809>;
    <D.20812>:
    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.20810>;
    <D.20809>:
    D.20728 = spec->native;
    if (D.20728 == 25) goto <D.20813>; else goto <D.20814>;
    <D.20813>:
    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.20815>;
    <D.20814>:
    D.20728 = spec->native;
    if (D.20728 == 26) goto <D.20816>; else goto <D.20817>;
    <D.20816>:
    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.20818>;
    <D.20817>:
    if (klass == 0B) goto <D.20821>; else goto <D.20819>;
    <D.20821>:
    D.20728 = spec->native;
    if (D.20728 == 28) goto <D.20822>; else goto <D.20819>;
    <D.20822>:
    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.20820>;
    <D.20819>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1364);
    <D.20820>:
    <D.20818>:
    <D.20815>:
    <D.20810>:
    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.18650>;
  }
  <D.18673>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1376);
  <D.18650>:
  D.20823 = conv_arg;
  return D.20823;
}


ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (void * pUnk)
{
  _Bool D.20825;
  long int D.20826;
  long int D.20827;
  int D.20830;
  struct MonoIUnknown * D.20831;
  int (*<T3124>) (void *) D.20832;

  D.20825 = pUnk == 0B;
  D.20826 = (long int) D.20825;
  D.20827 = __builtin_expect (D.20826, 0);
  if (D.20827 != 0) goto <D.20828>; else goto <D.20829>;
  <D.20828>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1399, "pUnk");
  <D.20829>:
  D.20831 = MEM[(struct MonoIUnknown * *)pUnk];
  D.20832 = D.20831->AddRef;
  D.20830 = D.20832 (pUnk);
  return D.20830;
}


ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (void * pUnk, void * riid, void * * ppv)
{
  _Bool D.20834;
  long int D.20835;
  long int D.20836;
  int D.20839;
  struct MonoIUnknown * D.20840;
  int (*<T2f4b>) (void *, void *, void * *) D.20841;

  D.20834 = pUnk == 0B;
  D.20835 = (long int) D.20834;
  D.20836 = __builtin_expect (D.20835, 0);
  if (D.20836 != 0) goto <D.20837>; else goto <D.20838>;
  <D.20837>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1406, "pUnk");
  <D.20838>:
  D.20840 = MEM[(struct MonoIUnknown * *)pUnk];
  D.20841 = D.20840->QueryInterface;
  D.20839 = D.20841 (pUnk, riid, ppv);
  return D.20839;
}


ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (void * pUnk)
{
  _Bool D.20843;
  long int D.20844;
  long int D.20845;
  int D.20848;
  struct MonoIUnknown * D.20849;
  int (*<T3124>) (void *) D.20850;

  D.20843 = pUnk == 0B;
  D.20844 = (long int) D.20843;
  D.20845 = __builtin_expect (D.20844, 0);
  if (D.20845 != 0) goto <D.20846>; else goto <D.20847>;
  <D.20846>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1413, "pUnk");
  <D.20847>:
  D.20849 = MEM[(struct MonoIUnknown * *)pUnk];
  D.20850 = D.20849->Release;
  D.20848 = D.20850 (pUnk);
  return D.20848;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal (struct MonoObject * object)
{
  void * D.20854;
  int D.20855;
  struct MonoVTable * D.20860;
  struct MonoClass * D.20861;
  struct MonoVTable * D.20866;
  struct MonoClass * D.20867;
  struct MonoComObject * D.20870;
  struct MonoClass * D.20873;

  if (object == 0B) goto <D.20852>; else goto <D.20853>;
  <D.20852>:
  D.20854 = 0B;
  return D.20854;
  <D.20853>:
  D.20855 = cominterop_object_is_rcw (object);
  if (D.20855 != 0) goto <D.20856>; else goto <D.20857>;
  <D.20856>:
  {
    struct MonoClass * klass;
    struct MonoRealProxy * real_proxy;

    klass = 0B;
    real_proxy = 0B;
    if (object == 0B) goto <D.20858>; else goto <D.20859>;
    <D.20858>:
    D.20854 = 0B;
    return D.20854;
    <D.20859>:
    D.20860 = object->vtable;
    klass = D.20860->klass;
    D.20861 = mono_defaults.transparent_proxy_class;
    if (D.20861 != klass) goto <D.20862>; else goto <D.20863>;
    <D.20862>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1460);
    D.20854 = 0B;
    return D.20854;
    <D.20863>:
    real_proxy = MEM[(struct MonoTransparentProxy *)object].rp;
    if (real_proxy == 0B) goto <D.20864>; else goto <D.20865>;
    <D.20864>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1466);
    D.20854 = 0B;
    return D.20854;
    <D.20865>:
    D.20866 = MEM[(struct MonoObject *)real_proxy].vtable;
    klass = D.20866->klass;
    D.20867 = mono_class_get_interop_proxy_class ();
    if (D.20867 != klass) goto <D.20868>; else goto <D.20869>;
    <D.20868>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1472);
    D.20854 = 0B;
    return D.20854;
    <D.20869>:
    D.20870 = MEM[(struct MonoComInteropProxy *)real_proxy].com_object;
    if (D.20870 == 0B) goto <D.20871>; else goto <D.20872>;
    <D.20871>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1477);
    D.20854 = 0B;
    return D.20854;
    <D.20872>:
    D.20870 = MEM[(struct MonoComInteropProxy *)real_proxy].com_object;
    D.20854 = D.20870->iunknown;
    return D.20854;
  }
  <D.20857>:
  D.20873 = mono_class_get_iunknown_class ();
  D.20854 = cominterop_get_ccw (object, D.20873);
  return D.20854;
}


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

  object = 0B;
  if (pUnk == 0B) goto <D.20875>; else goto <D.20876>;
  <D.20875>:
  D.20877 = 0B;
  return D.20877;
  <D.20876>:
  object = cominterop_get_ccw_object (pUnk, 1);
  D.20877 = object;
  return D.20877;
}


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

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


cominterop_get_idispatch_for_object (struct MonoObject * object)
{
  void * D.20883;
  int D.20884;
  struct MonoClass * D.20887;
  struct MonoRealProxy * D.20888;
  struct MonoComObject * D.20889;
  struct MonoVTable * D.20890;
  int D.20891;
  struct MonoClass * D.20894;

  if (object == 0B) goto <D.20881>; else goto <D.20882>;
  <D.20881>:
  D.20883 = 0B;
  return D.20883;
  <D.20882>:
  D.20884 = cominterop_object_is_rcw (object);
  if (D.20884 != 0) goto <D.20885>; else goto <D.20886>;
  <D.20885>:
  D.20887 = mono_class_get_idispatch_class ();
  D.20888 = MEM[(struct MonoTransparentProxy *)object].rp;
  D.20889 = MEM[(struct MonoComInteropProxy *)D.20888].com_object;
  D.20883 = cominterop_get_interface (D.20889, D.20887, 1);
  return D.20883;
  <D.20886>:
  {
    struct MonoClass * klass;

    D.20890 = object->vtable;
    klass = D.20890->klass;
    D.20891 = cominterop_can_support_dispatch (klass);
    if (D.20891 == 0) goto <D.20892>; else goto <D.20893>;
    <D.20892>:
    cominterop_raise_hr_exception (-2147467262);
    <D.20893>:
    D.20894 = mono_class_get_idispatch_class ();
    D.20883 = cominterop_get_ccw (object, D.20894);
    return D.20883;
  }
}


ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (struct MonoObject * object, struct MonoReflectionType * type)
{
  _Bool D.20896;
  long int D.20897;
  long int D.20898;
  struct MonoType * D.20901;
  _Bool D.20902;
  long int D.20903;
  long int D.20904;
  _Bool D.20907;
  long int D.20908;
  long int D.20909;
  int D.20912;
  struct MonoException * D.20915;
  _Bool D.20916;
  long int D.20917;
  long int D.20918;
  void * D.20921;
  struct MonoClass * klass;
  void * itf;

  klass = 0B;
  itf = 0B;
  D.20896 = type == 0B;
  D.20897 = (long int) D.20896;
  D.20898 = __builtin_expect (D.20897, 0);
  if (D.20898 != 0) goto <D.20899>; else goto <D.20900>;
  <D.20899>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1525, "type");
  <D.20900>:
  D.20901 = type->type;
  D.20902 = D.20901 == 0B;
  D.20903 = (long int) D.20902;
  D.20904 = __builtin_expect (D.20903, 0);
  if (D.20904 != 0) goto <D.20905>; else goto <D.20906>;
  <D.20905>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1526, "type->type");
  <D.20906>:
  D.20901 = type->type;
  klass = mono_type_get_class (D.20901);
  D.20907 = klass == 0B;
  D.20908 = (long int) D.20907;
  D.20909 = __builtin_expect (D.20908, 0);
  if (D.20909 != 0) goto <D.20910>; else goto <D.20911>;
  <D.20910>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1528, "klass");
  <D.20911>:
  D.20912 = mono_class_init (klass);
  if (D.20912 == 0) goto <D.20913>; else goto <D.20914>;
  <D.20913>:
  D.20915 = mono_class_get_exception_for_failure (klass);
  mono_raise_exception (D.20915);
  <D.20914>:
  itf = cominterop_get_ccw (object, klass);
  D.20916 = itf == 0B;
  D.20917 = (long int) D.20916;
  D.20918 = __builtin_expect (D.20917, 0);
  if (D.20918 != 0) goto <D.20919>; else goto <D.20920>;
  <D.20919>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1533, "itf");
  <D.20920>:
  D.20921 = itf;
  return D.20921;
}


ves_icall_System_Runtime_InteropServices_Marshal_IsComObject (struct MonoObject * object)
{
  MonoBoolean D.20923;
  int D.20924;

  D.20924 = cominterop_object_is_rcw (object);
  D.20923 = (MonoBoolean) D.20924;
  return D.20923;
}


ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal (struct MonoObject * object)
{
  _Bool D.20926;
  long int D.20927;
  long int D.20928;
  int D.20931;
  _Bool D.20932;
  long int D.20933;
  long int D.20934;
  _Bool D.20937;
  long int D.20938;
  long int D.20939;
  int D.20942;
  gint32 D.20945;
  gint32 * D.20946;
  _Bool D.20947;
  long int D.20948;
  long int D.20949;
  struct MonoComObject * D.20954;
  struct MonoComInteropProxy * proxy;
  gint32 ref_count;

  proxy = 0B;
  ref_count = 0;
  D.20926 = object == 0B;
  D.20927 = (long int) D.20926;
  D.20928 = __builtin_expect (D.20927, 0);
  if (D.20928 != 0) goto <D.20929>; else goto <D.20930>;
  <D.20929>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1558, "object");
  <D.20930>:
  D.20931 = cominterop_object_is_rcw (object);
  D.20932 = D.20931 == 0;
  D.20933 = (long int) D.20932;
  D.20934 = __builtin_expect (D.20933, 0);
  if (D.20934 != 0) goto <D.20935>; else goto <D.20936>;
  <D.20935>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1559, "cominterop_object_is_rcw (object)");
  <D.20936>:
  proxy = MEM[(struct MonoTransparentProxy *)object].rp;
  D.20937 = proxy == 0B;
  D.20938 = (long int) D.20937;
  D.20939 = __builtin_expect (D.20938, 0);
  if (D.20939 != 0) goto <D.20940>; else goto <D.20941>;
  <D.20940>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1562, "proxy");
  <D.20941>:
  D.20942 = proxy->ref_count;
  if (D.20942 == 0) goto <D.20943>; else goto <D.20944>;
  <D.20943>:
  D.20945 = -1;
  return D.20945;
  <D.20944>:
  D.20946 = &proxy->ref_count;
  ref_count = InterlockedDecrement (D.20946);
  D.20947 = ref_count < 0;
  D.20948 = (long int) D.20947;
  D.20949 = __builtin_expect (D.20948, 0);
  if (D.20949 != 0) goto <D.20950>; else goto <D.20951>;
  <D.20950>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1569, "ref_count >= 0");
  <D.20951>:
  if (ref_count == 0) goto <D.20952>; else goto <D.20953>;
  <D.20952>:
  D.20954 = proxy->com_object;
  ves_icall_System_ComObject_ReleaseInterfaces (D.20954);
  <D.20953>:
  D.20945 = ref_count;
  return D.20945;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal (struct MonoReflectionMethod * m)
{
  guint32 D.20956;
  struct MonoMethod * D.20957;
  int D.20958;

  D.20957 = m->method;
  D.20958 = cominterop_get_com_slot_for_method (D.20957);
  D.20956 = (guint32) D.20958;
  return D.20956;
}


ves_icall_System_ComObject_CreateRCW (struct MonoReflectionType * type)
{
  struct MonoVTable * D.20960;
  struct MonoType * D.20961;
  struct MonoVTable * D.20962;
  struct MonoObject * D.20963;
  struct MonoClass * klass;
  struct MonoDomain * domain;
  struct MonoObject * obj;

  D.20960 = MEM[(struct MonoObject *)type].vtable;
  domain = D.20960->domain;
  D.20961 = type->type;
  klass = mono_class_from_mono_type (D.20961);
  D.20962 = mono_class_vtable_full (domain, klass, 1);
  obj = mono_object_new_alloc_specific (D.20962);
  D.20963 = obj;
  return D.20963;
}


ves_icall_System_ComObject_ReleaseInterfaces (struct MonoComObject * obj)
{
  _Bool D.20965;
  long int D.20966;
  long int D.20967;
  struct GHashTable * D.20970;
  _Bool D.20975;
  long int D.20976;
  long int D.20977;
  void * D.20980;
  struct GHashTable * rcw_hash.139;
  void * D.20982;
  _Bool D.20987;
  long int D.20988;
  long int D.20989;

  D.20965 = obj == 0B;
  D.20966 = (long int) D.20965;
  D.20967 = __builtin_expect (D.20966, 0);
  if (D.20967 != 0) goto <D.20968>; else goto <D.20969>;
  <D.20968>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1625, "obj");
  <D.20969>:
  D.20970 = obj->itf_hash;
  if (D.20970 != 0B) goto <D.20971>; else goto <D.20972>;
  <D.20971>:
  {
    guint32 gchandle;

    gchandle = 0;
    {
      int ret;

      ret = pthread_mutex_lock (&cominterop_mutex.mutex);
      if (ret != 0) goto <D.20973>; else goto <D.20974>;
      <D.20973>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
      <D.20974>:
      D.20975 = ret != 0;
      D.20976 = (long int) D.20975;
      D.20977 = __builtin_expect (D.20976, 0);
      if (D.20977 != 0) goto <D.20978>; else goto <D.20979>;
      <D.20978>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1628, "ret == 0");
      <D.20979>:
    }
    D.20980 = obj->iunknown;
    rcw_hash.139 = rcw_hash;
    D.20982 = monoeg_g_hash_table_lookup (rcw_hash.139, D.20980);
    gchandle = (guint32) D.20982;
    if (gchandle != 0) goto <D.20983>; else goto <D.20984>;
    <D.20983>:
    mono_gchandle_free (gchandle);
    D.20980 = obj->iunknown;
    rcw_hash.139 = rcw_hash;
    monoeg_g_hash_table_remove (rcw_hash.139, D.20980);
    <D.20984>:
    D.20970 = obj->itf_hash;
    monoeg_g_hash_table_foreach_remove (D.20970, cominterop_rcw_interface_finalizer, 0B);
    D.20970 = obj->itf_hash;
    monoeg_g_hash_table_destroy (D.20970);
    D.20980 = obj->iunknown;
    ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (D.20980);
    obj->iunknown = 0B;
    obj->itf_hash = 0B;
    {
      int ret;

      ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
      if (ret != 0) goto <D.20985>; else goto <D.20986>;
      <D.20985>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
      <D.20986>:
      D.20987 = ret != 0;
      D.20988 = (long int) D.20987;
      D.20989 = __builtin_expect (D.20988, 0);
      if (D.20989 != 0) goto <D.20990>; else goto <D.20991>;
      <D.20990>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1639, "ret == 0");
      <D.20991>:
    }
  }
  <D.20972>:
}


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

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


cominterop_release_all_rcws ()
{
  struct GHashTable * rcw_hash.140;
  _Bool D.20999;
  long int D.21000;
  long int D.21001;
  _Bool D.21006;
  long int D.21007;
  long int D.21008;

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

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.20997>; else goto <D.20998>;
    <D.20997>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.20998>:
    D.20999 = ret != 0;
    D.21000 = (long int) D.20999;
    D.21001 = __builtin_expect (D.21000, 0);
    if (D.21001 != 0) goto <D.21002>; else goto <D.21003>;
    <D.21002>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1674, "ret == 0");
    <D.21003>:
  }
  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.21004>; else goto <D.21005>;
    <D.21004>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21005>:
    D.21006 = ret != 0;
    D.21007 = (long int) D.21006;
    D.21008 = __builtin_expect (D.21007, 0);
    if (D.21008 != 0) goto <D.21009>; else goto <D.21010>;
    <D.21009>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1680, "ret == 0");
    <D.21010>:
  }
}


cominterop_rcw_finalizer (void * key, void * value, void * user_data)
{
  struct MonoComObject * D.21016;
  struct GHashTable * D.21017;
  void * D.21020;
  gboolean D.21023;
  guint32 gchandle;

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

    proxy = mono_gchandle_get_target (gchandle);
    if (proxy != 0B) goto <D.21014>; else goto <D.21015>;
    <D.21014>:
    D.21016 = proxy->com_object;
    D.21017 = D.21016->itf_hash;
    if (D.21017 != 0B) goto <D.21018>; else goto <D.21019>;
    <D.21018>:
    D.21016 = proxy->com_object;
    D.21017 = D.21016->itf_hash;
    monoeg_g_hash_table_foreach_remove (D.21017, cominterop_rcw_interface_finalizer, 0B);
    D.21016 = proxy->com_object;
    D.21017 = D.21016->itf_hash;
    monoeg_g_hash_table_destroy (D.21017);
    <D.21019>:
    D.21016 = proxy->com_object;
    D.21020 = D.21016->iunknown;
    if (D.21020 != 0B) goto <D.21021>; else goto <D.21022>;
    <D.21021>:
    D.21016 = proxy->com_object;
    D.21020 = D.21016->iunknown;
    ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (D.21020);
    <D.21022>:
    D.21016 = proxy->com_object;
    D.21016->iunknown = 0B;
    D.21016 = proxy->com_object;
    D.21016->itf_hash = 0B;
    <D.21015>:
    mono_gchandle_free (gchandle);
  }
  <D.21013>:
  D.21023 = 1;
  return D.21023;
}


ves_icall_System_ComObject_GetInterfaceInternal (struct MonoComObject * obj, struct MonoReflectionType * type, MonoBoolean throw_exception)
{
  struct MonoType * D.21025;
  int D.21026;
  struct MonoException * D.21029;
  void * D.21030;
  int D.21031;
  struct MonoClass * class;

  D.21025 = type->type;
  class = mono_type_get_class (D.21025);
  D.21026 = mono_class_init (class);
  if (D.21026 == 0) goto <D.21027>; else goto <D.21028>;
  <D.21027>:
  D.21029 = mono_class_get_exception_for_failure (class);
  mono_raise_exception (D.21029);
  <D.21028>:
  D.21031 = (int) throw_exception;
  D.21030 = cominterop_get_interface (obj, class, D.21031);
  return D.21030;
}


ves_icall_Mono_Interop_ComInteropProxy_AddProxy (void * pUnk, struct MonoComInteropProxy * proxy)
{
  struct GHashTable * rcw_hash.141;
  _Bool D.21038;
  long int D.21039;
  long int D.21040;
  struct GHashTable * rcw_hash.142;
  _Bool D.21046;
  long int D.21047;
  long int D.21048;
  _Bool D.21053;
  long int D.21054;
  long int D.21055;
  void * gchandle.143;
  _Bool D.21061;
  long int D.21062;
  long int D.21063;
  guint32 gchandle;

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

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21036>; else goto <D.21037>;
    <D.21036>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21037>:
    D.21038 = ret != 0;
    D.21039 = (long int) D.21038;
    D.21040 = __builtin_expect (D.21039, 0);
    if (D.21040 != 0) goto <D.21041>; else goto <D.21042>;
    <D.21041>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1703, "ret == 0");
    <D.21042>:
  }
  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.21044>; else goto <D.21045>;
    <D.21044>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21045>:
    D.21046 = ret != 0;
    D.21047 = (long int) D.21046;
    D.21048 = __builtin_expect (D.21047, 0);
    if (D.21048 != 0) goto <D.21049>; else goto <D.21050>;
    <D.21049>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1705, "ret == 0");
    <D.21050>:
  }
  <D.21035>:
  gchandle = mono_gchandle_new_weakref (proxy, 0);
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21051>; else goto <D.21052>;
    <D.21051>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21052>:
    D.21053 = ret != 0;
    D.21054 = (long int) D.21053;
    D.21055 = __builtin_expect (D.21054, 0);
    if (D.21055 != 0) goto <D.21056>; else goto <D.21057>;
    <D.21056>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1710, "ret == 0");
    <D.21057>:
  }
  gchandle.143 = (void *) gchandle;
  rcw_hash.141 = rcw_hash;
  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.21059>; else goto <D.21060>;
    <D.21059>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21060>:
    D.21061 = ret != 0;
    D.21062 = (long int) D.21061;
    D.21063 = __builtin_expect (D.21062, 0);
    if (D.21063 != 0) goto <D.21064>; else goto <D.21065>;
    <D.21064>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1712, "ret == 0");
    <D.21065>:
  }
}


ves_icall_Mono_Interop_ComInteropProxy_FindProxy (void * pUnk)
{
  _Bool D.21068;
  long int D.21069;
  long int D.21070;
  struct GHashTable * rcw_hash.144;
  void * D.21076;
  _Bool D.21079;
  long int D.21080;
  long int D.21081;
  struct MonoComInteropProxy * D.21088;
  struct MonoComInteropProxy * proxy;
  guint32 gchandle;

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

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21066>; else goto <D.21067>;
    <D.21066>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21067>:
    D.21068 = ret != 0;
    D.21069 = (long int) D.21068;
    D.21070 = __builtin_expect (D.21069, 0);
    if (D.21070 != 0) goto <D.21071>; else goto <D.21072>;
    <D.21071>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1725, "ret == 0");
    <D.21072>:
  }
  rcw_hash.144 = rcw_hash;
  if (rcw_hash.144 != 0B) goto <D.21074>; else goto <D.21075>;
  <D.21074>:
  rcw_hash.144 = rcw_hash;
  D.21076 = monoeg_g_hash_table_lookup (rcw_hash.144, pUnk);
  gchandle = (guint32) D.21076;
  <D.21075>:
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21077>; else goto <D.21078>;
    <D.21077>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21078>:
    D.21079 = ret != 0;
    D.21080 = (long int) D.21079;
    D.21081 = __builtin_expect (D.21080, 0);
    if (D.21081 != 0) goto <D.21082>; else goto <D.21083>;
    <D.21082>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1728, "ret == 0");
    <D.21083>:
  }
  if (gchandle != 0) goto <D.21084>; else goto <D.21085>;
  <D.21084>:
  proxy = mono_gchandle_get_target (gchandle);
  if (proxy == 0B) goto <D.21086>; else goto <D.21087>;
  <D.21086>:
  mono_gchandle_free (gchandle);
  rcw_hash.144 = rcw_hash;
  monoeg_g_hash_table_remove (rcw_hash.144, pUnk);
  <D.21087>:
  <D.21085>:
  D.21088 = proxy;
  return D.21088;
}


mono_marshal_free_ccw (struct MonoObject * object)
{
  struct GHashTable * ccw_hash.145;
  unsigned int D.21094;
  gboolean D.21095;
  _Bool D.21098;
  long int D.21099;
  long int D.21100;
  int D.21103;
  const void * D.21104;
  _Bool D.21107;
  long int D.21108;
  long int D.21109;
  unsigned int D.21114;
  _Bool D.21115;
  _Bool D.21116;
  _Bool D.21117;
  struct GHashTable * D.21120;
  struct GList * iftmp.146;
  struct GList * iftmp.147;
  unsigned int D.21130;
  int D.21133;
  const void * D.21134;
  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.21090>; else goto <D.21093>;
  <D.21093>:
  ccw_hash.145 = ccw_hash;
  D.21094 = monoeg_g_hash_table_size (ccw_hash.145);
  if (D.21094 == 0) goto <D.21090>; else goto <D.21091>;
  <D.21090>:
  D.21095 = 0;
  return D.21095;
  <D.21091>:
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21096>; else goto <D.21097>;
    <D.21096>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21097>:
    D.21098 = ret != 0;
    D.21099 = (long int) D.21098;
    D.21100 = __builtin_expect (D.21099, 0);
    if (D.21100 != 0) goto <D.21101>; else goto <D.21102>;
    <D.21101>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2050, "ret == 0");
    <D.21102>:
  }
  D.21103 = mono_object_hash (object);
  D.21104 = (const void *) D.21103;
  ccw_hash.145 = ccw_hash;
  ccw_list_orig = monoeg_g_hash_table_lookup (ccw_hash.145, D.21104);
  ccw_list = ccw_list_orig;
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21105>; else goto <D.21106>;
    <D.21105>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21106>:
    D.21107 = ret != 0;
    D.21108 = (long int) D.21107;
    D.21109 = __builtin_expect (D.21108, 0);
    if (D.21109 != 0) goto <D.21110>; else goto <D.21111>;
    <D.21110>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2052, "ret == 0");
    <D.21111>:
  }
  if (ccw_list == 0B) goto <D.21112>; else goto <D.21113>;
  <D.21112>:
  D.21095 = 0;
  return D.21095;
  <D.21113>:
  ccw_list_item = ccw_list;
  goto <D.18858>;
  <D.18857>:
  {
    struct MonoCCW * ccw_iter;
    struct MonoObject * handle_target;

    ccw_iter = ccw_list_item->data;
    D.21114 = ccw_iter->gc_handle;
    handle_target = mono_gchandle_get_target (D.21114);
    D.21115 = handle_target == 0B;
    D.21116 = handle_target == object;
    D.21117 = D.21115 | D.21116;
    if (D.21117 != 0) goto <D.21118>; else goto <D.21119>;
    <D.21118>:
    D.21120 = ccw_iter->vtable_hash;
    monoeg_g_hash_table_foreach_remove (D.21120, mono_marshal_free_ccw_entry, 0B);
    D.21120 = ccw_iter->vtable_hash;
    monoeg_g_hash_table_destroy (D.21120);
    if (ccw_list_item != 0B) goto <D.21122>; else goto <D.21123>;
    <D.21122>:
    iftmp.146 = ccw_list_item->next;
    goto <D.21124>;
    <D.21123>:
    iftmp.146 = 0B;
    <D.21124>:
    ccw_list_item = iftmp.146;
    ccw_list = monoeg_g_list_remove (ccw_list, ccw_iter);
    monoeg_g_free (ccw_iter);
    goto <D.21125>;
    <D.21119>:
    if (ccw_list_item != 0B) goto <D.21127>; else goto <D.21128>;
    <D.21127>:
    iftmp.147 = ccw_list_item->next;
    goto <D.21129>;
    <D.21128>:
    iftmp.147 = 0B;
    <D.21129>:
    ccw_list_item = iftmp.147;
    <D.21125>:
  }
  <D.18858>:
  if (ccw_list_item != 0B) goto <D.18857>; else goto <D.18859>;
  <D.18859>:
  D.21130 = monoeg_g_list_length (ccw_list);
  if (D.21130 == 0) goto <D.21131>; else goto <D.21132>;
  <D.21131>:
  D.21133 = mono_object_hash (object);
  D.21134 = (const void *) D.21133;
  ccw_hash.145 = ccw_hash;
  monoeg_g_hash_table_remove (ccw_hash.145, D.21134);
  <D.21132>:
  D.21095 = 1;
  return D.21095;
}


mono_marshal_free_ccw_entry (void * key, void * value, void * user_data)
{
  struct GHashTable * ccw_interface_hash.148;
  _Bool D.21137;
  long int D.21138;
  long int D.21139;
  gboolean D.21142;

  ccw_interface_hash.148 = ccw_interface_hash;
  monoeg_g_hash_table_remove (ccw_interface_hash.148, value);
  D.21137 = value == 0B;
  D.21138 = (long int) D.21137;
  D.21139 = __builtin_expect (D.21138, 0);
  if (D.21139 != 0) goto <D.21140>; else goto <D.21141>;
  <D.21140>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2030, "value");
  <D.21141>:
  monoeg_g_free (value);
  D.21142 = 1;
  return D.21142;
}


mono_string_to_bstr (struct MonoString * string_obj)
{
  void * D.21146;
  <unnamed type> com_provider.149;
  unsigned int slen.150;
  unsigned int D.21151;
  unsigned int D.21152;
  unsigned int D.21155;
  mono_unichar2 * D.21156;
  char * D.21157;
  unsigned int D.21158;
  unsigned int D.21159;
  char * D.21160;
  unsigned int D.21161;
  char * D.21162;
  int D.21165;
  int D.21167;
  long int len.151;
  mono_unichar2 * D.21169;
  void * (*<T331e>) (gunichar *, guint32) sys_alloc_string_len_ms.152;

  if (string_obj == 0B) goto <D.21144>; else goto <D.21145>;
  <D.21144>:
  D.21146 = 0B;
  return D.21146;
  <D.21145>:
  com_provider.149 = com_provider;
  if (com_provider.149 == 0) goto <D.21148>; else goto <D.21149>;
  <D.21148>:
  {
    int slen;
    char * ret;

    slen = mono_string_length (string_obj);
    slen.150 = (unsigned int) slen;
    D.21151 = slen.150 + 3;
    D.21152 = D.21151 * 2;
    ret = monoeg_malloc (D.21152);
    if (ret == 0B) goto <D.21153>; else goto <D.21154>;
    <D.21153>:
    D.21146 = 0B;
    return D.21146;
    <D.21154>:
    slen.150 = (unsigned int) slen;
    D.21155 = slen.150 * 2;
    D.21156 = mono_string_chars (string_obj);
    D.21157 = ret + 4;
    memcpy (D.21157, D.21156, D.21155);
    slen.150 = (unsigned int) slen;
    D.21155 = slen.150 * 2;
    MEM[(guint32 *)ret] = D.21155;
    slen.150 = (unsigned int) slen;
    D.21158 = slen.150 + 2;
    D.21159 = D.21158 * 2;
    D.21160 = ret + D.21159;
    *D.21160 = 0;
    slen.150 = (unsigned int) slen;
    D.21155 = slen.150 * 2;
    D.21161 = D.21155 + 5;
    D.21162 = ret + D.21161;
    *D.21162 = 0;
    D.21146 = ret + 4;
    return D.21146;
  }
  <D.21149>:
  com_provider.149 = com_provider;
  if (com_provider.149 == 1) goto <D.21164>; else goto <D.21163>;
  <D.21164>:
  D.21165 = init_com_provider_ms ();
  if (D.21165 != 0) goto <D.21166>; else goto <D.21163>;
  <D.21166>:
  {
    void * ret;
    gunichar * str;
    guint32 len;

    ret = 0B;
    str = 0B;
    D.21167 = mono_string_length (string_obj);
    len = (guint32) D.21167;
    len.151 = (long int) len;
    D.21169 = mono_string_chars (string_obj);
    str = monoeg_g_utf16_to_ucs4 (D.21169, 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.21146 = ret;
    return D.21146;
  }
  <D.21163>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2605);
}


mono_string_from_bstr (void * bstr)
{
  struct MonoString * D.21174;
  <unnamed type> com_provider.153;
  guint32 * D.21178;
  unsigned int D.21179;
  unsigned int D.21180;
  int D.21181;
  struct MonoDomain * D.21182;
  int D.21185;
  guint32 (*<T176b>) (void *) sys_string_len_ms.154;
  unsigned int D.21188;
  long int D.21189;
  long int written.155;
  struct MonoDomain * D.21191;

  if (bstr == 0B) goto <D.21172>; else goto <D.21173>;
  <D.21172>:
  D.21174 = 0B;
  return D.21174;
  <D.21173>:
  com_provider.153 = com_provider;
  if (com_provider.153 == 0) goto <D.21176>; else goto <D.21177>;
  <D.21176>:
  D.21178 = bstr + 4294967292;
  D.21179 = *D.21178;
  D.21180 = D.21179 / 2;
  D.21181 = (int) D.21180;
  D.21182 = mono_domain_get ();
  D.21174 = mono_string_new_utf16 (D.21182, bstr, D.21181);
  return D.21174;
  <D.21177>:
  com_provider.153 = com_provider;
  if (com_provider.153 == 1) goto <D.21184>; else goto <D.21183>;
  <D.21184>:
  D.21185 = init_com_provider_ms ();
  if (D.21185 != 0) goto <D.21186>; else goto <D.21183>;
  <D.21186>:
  {
    struct MonoString * str;
    glong written;
    gunichar2 * utf16;

    try
      {
        str = 0B;
        written = 0;
        utf16 = 0B;
        sys_string_len_ms.154 = sys_string_len_ms;
        D.21188 = sys_string_len_ms.154 (bstr);
        D.21189 = (long int) D.21188;
        utf16 = monoeg_g_ucs4_to_utf16 (bstr, D.21189, 0B, &written, 0B);
        written.155 = written;
        D.21191 = mono_domain_get ();
        str = mono_string_new_utf16 (D.21191, utf16, written.155);
        monoeg_g_free (utf16);
        D.21174 = str;
        return D.21174;
      }
    finally
      {
        written = {CLOBBER};
      }
  }
  <D.21183>:
  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.21199;
  int D.21204;
  void (*<T3326>) (gunichar *) sys_free_string_ms.157;

  if (bstr == 0B) goto <D.21194>; else goto <D.21195>;
  <D.21194>:
  return;
  <D.21195>:
  com_provider.156 = com_provider;
  if (com_provider.156 == 0) goto <D.21197>; else goto <D.21198>;
  <D.21197>:
  D.21199 = bstr + 4294967292;
  monoeg_g_free (D.21199);
  goto <D.21200>;
  <D.21198>:
  com_provider.156 = com_provider;
  if (com_provider.156 == 1) goto <D.21203>; else goto <D.21201>;
  <D.21203>:
  D.21204 = init_com_provider_ms ();
  if (D.21204 != 0) goto <D.21205>; else goto <D.21201>;
  <D.21205>:
  sys_free_string_ms.157 = sys_free_string_ms;
  sys_free_string_ms.157 (bstr);
  goto <D.21202>;
  <D.21201>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2649);
  <D.21202>:
  <D.21200>:
}


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.21208;
  int D.21209;
  int D.21210;
  struct MonoClass * D.21213;
  struct MonoType * D.21214;
  struct MonoClass * D.21215;
  struct MonoType * D.21216;
  unsigned char D.21217;
  unsigned char D.21218;
  unsigned int argnum.158;
  unsigned int safearray_var.159;
  unsigned int indices_var.160;
  unsigned int empty_var.161;
  struct MonoClass * D.21226;
  struct MonoType * D.21227;
  unsigned int index_var.162;
  int D.21229;
  struct MonoMethod * get_value_impl.163;
  struct MonoClass * D.21233;
  struct MonoMethod * get_value_impl.164;
  _Bool D.21235;
  long int D.21236;
  long int D.21237;
  struct MonoMethod * get_native_variant_for_object.165;
  struct MonoClass * D.21246;
  struct MonoMethod * get_native_variant_for_object.166;
  _Bool D.21248;
  long int D.21249;
  long int D.21250;
  struct MonoClass * D.21253;
  struct MonoType * D.21254;
  unsigned int elem_var.167;
  struct MonoMethod * variant_clear.168;
  struct MonoClass * D.21259;
  struct MonoMethod * variant_clear.169;
  short unsigned int D.21261;
  int D.21262;
  unsigned int conv_arg.170;
  int D.21267;
  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.21282;
  struct MonoMethod * get_object_for_native_variant.176;
  struct MonoMethod * get_object_for_native_variant.177;
  _Bool D.21289;
  long int D.21290;
  long int D.21291;
  struct MonoMethod * set_value_impl.178;
  struct MonoMethod * set_value_impl.179;
  _Bool D.21298;
  long int D.21299;
  long int D.21300;
  unsigned int elem_var.180;
  short unsigned int D.21306;
  int D.21307;
  int D.21310;
  struct MonoMethodBuilder * mb;

  mb = m->mb;
  switch (action) <default: <D.19079>, case 0: <D.19052>, case 1: <D.19065>, case 2: <D.19066>>
  <D.19052>:
  D.21208 = t->attrs;
  D.21209 = (int) D.21208;
  D.21210 = D.21209 & 1;
  if (D.21210 != 0) goto <D.21211>; else goto <D.21212>;
  <D.21211>:
  {
    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.21213 = mono_defaults.object_class;
    D.21214 = &D.21213->byval_arg;
    safearray_var = mono_mb_add_local (mb, D.21214);
    conv_arg = safearray_var;
    D.21215 = mono_defaults.int_class;
    D.21216 = &D.21215->byval_arg;
    indices_var = mono_mb_add_local (mb, D.21216);
    D.21215 = mono_defaults.int_class;
    D.21216 = &D.21215->byval_arg;
    empty_var = mono_mb_add_local (mb, D.21216);
    D.21217 = BIT_FIELD_REF <*t, 8, 56>;
    D.21218 = D.21217 & 64;
    if (D.21218 != 0) goto <D.21219>; else goto <D.21220>;
    <D.21219>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    mono_mb_emit_byte (mb, 80);
    goto <D.21222>;
    <D.21220>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    <D.21222>:
    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.21226 = mono_defaults.int32_class;
    D.21227 = &D.21226->byval_arg;
    index_var = mono_mb_add_local (mb, D.21227);
    mono_mb_emit_byte (mb, 22);
    index_var.162 = (unsigned int) index_var;
    mono_mb_emit_stloc (mb, index_var.162);
    D.21229 = mono_mb_get_label (mb);
    label3 = (guint32) D.21229;
    get_value_impl.163 = get_value_impl;
    if (get_value_impl.163 == 0B) goto <D.21231>; else goto <D.21232>;
    <D.21231>:
    D.21233 = mono_defaults.array_class;
    get_value_impl.164 = mono_class_get_method_from_name (D.21233, "GetValueImpl", 1);
    get_value_impl = get_value_impl.164;
    <D.21232>:
    get_value_impl.163 = get_value_impl;
    D.21235 = get_value_impl.163 == 0B;
    D.21236 = (long int) D.21235;
    D.21237 = __builtin_expect (D.21236, 0);
    if (D.21237 != 0) goto <D.21238>; else goto <D.21239>;
    <D.21238>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2725, "get_value_impl");
    <D.21239>:
    D.21217 = BIT_FIELD_REF <*t, 8, 56>;
    D.21218 = D.21217 & 64;
    if (D.21218 != 0) goto <D.21240>; else goto <D.21241>;
    <D.21240>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    mono_mb_emit_byte (mb, 80);
    goto <D.21242>;
    <D.21241>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    <D.21242>:
    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.21244>; else goto <D.21245>;
    <D.21244>:
    D.21246 = mono_defaults.marshal_class;
    get_native_variant_for_object.166 = mono_class_get_method_from_name (D.21246, "GetNativeVariantForObject", 2);
    get_native_variant_for_object = get_native_variant_for_object.166;
    <D.21245>:
    get_native_variant_for_object.165 = get_native_variant_for_object;
    D.21248 = get_native_variant_for_object.165 == 0B;
    D.21249 = (long int) D.21248;
    D.21250 = __builtin_expect (D.21249, 0);
    if (D.21250 != 0) goto <D.21251>; else goto <D.21252>;
    <D.21251>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2739, "get_native_variant_for_object");
    <D.21252>:
    D.21253 = mono_class_get_variant_class ();
    D.21254 = &D.21253->byval_arg;
    elem_var = mono_mb_add_local (mb, D.21254);
    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.21257>; else goto <D.21258>;
    <D.21257>:
    D.21259 = mono_class_get_variant_class ();
    variant_clear.169 = mono_class_get_method_from_name (D.21259, "Clear", 0);
    variant_clear = variant_clear.169;
    <D.21258>:
    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.21261 = (short unsigned int) index_var;
    D.21262 = (int) D.21261;
    mono_mb_emit_add_to_local (mb, D.21262, 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.21212>:
  goto <D.19064>;
  <D.19065>:
  D.21217 = BIT_FIELD_REF <*t, 8, 56>;
  D.21218 = D.21217 & 64;
  if (D.21218 != 0) goto <D.21263>; else goto <D.21264>;
  <D.21263>:
  conv_arg.170 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc_addr (mb, conv_arg.170);
  goto <D.21266>;
  <D.21264>:
  conv_arg.170 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc (mb, conv_arg.170);
  <D.21266>:
  goto <D.19064>;
  <D.19066>:
  D.21208 = t->attrs;
  D.21209 = (int) D.21208;
  D.21267 = D.21209 & 2;
  if (D.21267 != 0) goto <D.21268>; else goto <D.21269>;
  <D.21268>:
  {
    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.21217 = BIT_FIELD_REF <*t, 8, 56>;
    D.21218 = D.21217 & 64;
    if (D.21218 == 0) goto <D.21273>; else goto <D.21271>;
    <D.21273>:
    D.21208 = t->attrs;
    D.21209 = (int) D.21208;
    D.21210 = D.21209 & 1;
    if (D.21210 != 0) goto <D.21274>; else goto <D.21271>;
    <D.21274>:
    iftmp.171 = 1;
    goto <D.21272>;
    <D.21271>:
    iftmp.171 = 0;
    <D.21272>:
    byValue = iftmp.171;
    D.21213 = mono_defaults.object_class;
    D.21214 = &D.21213->byval_arg;
    result_var = mono_mb_add_local (mb, D.21214);
    D.21215 = mono_defaults.int_class;
    D.21216 = &D.21215->byval_arg;
    indices_var = mono_mb_add_local (mb, D.21216);
    D.21215 = mono_defaults.int_class;
    D.21216 = &D.21215->byval_arg;
    empty_var = mono_mb_add_local (mb, D.21216);
    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.21278>; else goto <D.21279>;
    <D.21278>:
    mono_mb_emit_byte (mb, 22);
    goto <D.21280>;
    <D.21279>:
    mono_mb_emit_byte (mb, 23);
    <D.21280>:
    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.21215 = mono_defaults.int_class;
    D.21216 = &D.21215->byval_arg;
    index_var = mono_mb_add_local (mb, D.21216);
    mono_mb_emit_byte (mb, 22);
    index_var.175 = (unsigned int) index_var;
    mono_mb_emit_stloc (mb, index_var.175);
    D.21282 = mono_mb_get_label (mb);
    label3 = (guint32) D.21282;
    if (byValue != 0) goto <D.21283>; else goto <D.21284>;
    <D.21283>:
    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.21284>:
    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.21286>; else goto <D.21287>;
    <D.21286>:
    D.21246 = mono_defaults.marshal_class;
    get_object_for_native_variant.177 = mono_class_get_method_from_name (D.21246, "GetObjectForNativeVariant", 1);
    get_object_for_native_variant = get_object_for_native_variant.177;
    <D.21287>:
    get_object_for_native_variant.176 = get_object_for_native_variant;
    D.21289 = get_object_for_native_variant.176 == 0B;
    D.21290 = (long int) D.21289;
    D.21291 = __builtin_expect (D.21290, 0);
    if (D.21291 != 0) goto <D.21292>; else goto <D.21293>;
    <D.21292>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2854, "get_object_for_native_variant");
    <D.21293>:
    set_value_impl.178 = set_value_impl;
    if (set_value_impl.178 == 0B) goto <D.21295>; else goto <D.21296>;
    <D.21295>:
    D.21233 = mono_defaults.array_class;
    set_value_impl.179 = mono_class_get_method_from_name (D.21233, "SetValueImpl", 2);
    set_value_impl = set_value_impl.179;
    <D.21296>:
    set_value_impl.178 = set_value_impl;
    D.21298 = set_value_impl.178 == 0B;
    D.21299 = (long int) D.21298;
    D.21300 = __builtin_expect (D.21299, 0);
    if (D.21300 != 0) goto <D.21301>; else goto <D.21302>;
    <D.21301>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2858, "set_value_impl");
    <D.21302>:
    D.21213 = mono_defaults.object_class;
    D.21214 = &D.21213->byval_arg;
    elem_var = mono_mb_add_local (mb, D.21214);
    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.21304>; else goto <D.21305>;
    <D.21304>:
    mono_mb_patch_short_branch (mb, label4);
    <D.21305>:
    D.21306 = (short unsigned int) index_var;
    D.21307 = (int) D.21306;
    mono_mb_emit_add_to_local (mb, D.21307, 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.21308>; else goto <D.21309>;
    <D.21308>:
    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.21309>:
  }
  <D.21269>:
  goto <D.19064>;
  <D.19079>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2898);
  <D.19064>:
  D.21310 = conv_arg;
  return D.21310;
}


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

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


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

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


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


