mono_class_get_interop_proxy_class ()
{
  struct MonoImage * D.19155;
  _Bool D.19156;
  long int D.19157;
  long int D.19158;
  struct MonoClass * D.19161;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19153>; else goto <D.19154>;
  <D.19153>:
  D.19155 = mono_defaults.corlib;
  class = mono_class_from_name (D.19155, "Mono.Interop", "ComInteropProxy");
  D.19156 = class == 0B;
  D.19157 = (long int) D.19156;
  D.19158 = __builtin_expect (D.19157, 0);
  if (D.19158 != 0) goto <D.19159>; else goto <D.19160>;
  <D.19159>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 88, "class");
  <D.19160>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19154>:
  D.19161 = class;
  return D.19161;
}


mono_memory_barrier ()
{
  __sync_synchronize ();
}


mono_class_get_idispatch_class ()
{
  struct MonoImage * D.19165;
  _Bool D.19166;
  long int D.19167;
  long int D.19168;
  struct MonoClass * D.19171;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19163>; else goto <D.19164>;
  <D.19163>:
  D.19165 = mono_defaults.corlib;
  class = mono_class_from_name (D.19165, "Mono.Interop", "IDispatch");
  D.19166 = class == 0B;
  D.19167 = (long int) D.19166;
  D.19168 = __builtin_expect (D.19167, 0);
  if (D.19168 != 0) goto <D.19169>; else goto <D.19170>;
  <D.19169>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 89, "class");
  <D.19170>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19164>:
  D.19171 = class;
  return D.19171;
}


mono_class_get_iunknown_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", "IUnknown");
  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", 90, "class");
  <D.19180>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19174>:
  D.19181 = class;
  return D.19181;
}


mono_class_get_com_object_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, "System", "__ComObject");
  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", 92, "class");
  <D.19190>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19184>:
  D.19191 = class;
  return D.19191;
}


mono_class_get_variant_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, "System", "Variant");
  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", 93, "class");
  <D.19200>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19194>:
  D.19201 = class;
  return D.19201;
}


mono_cominterop_init ()
{
  int D.18492;
  int iftmp.0;
  int D.18491;
  const char[3] * D.19208;
  unsigned char D.19209;
  int D.19210;
  unsigned char D.19211;
  int D.19212;
  const unsigned char * D.19217;
  unsigned char D.19218;
  int D.19219;
  const unsigned char * D.19220;
  unsigned char D.19221;
  int D.19222;
  const unsigned char * D.19227;
  unsigned char D.19228;
  int D.19229;
  const unsigned char * D.19230;
  unsigned char D.19231;
  int D.19232;
  const unsigned char * D.19237;
  unsigned char D.19238;
  int D.19239;
  const unsigned char * D.19240;
  unsigned char D.19241;
  int D.19242;
  const char * com_provider_env;

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

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

      __s2 = com_provider_env;
      D.19208 = "MS";
      D.19209 = MEM[(const unsigned char *)D.19208];
      D.19210 = (int) D.19209;
      D.19211 = *__s2;
      D.19212 = (int) D.19211;
      __result = D.19210 - D.19212;
      {
        if (__s2_len != 0) goto <D.19213>; else goto <D.19214>;
        <D.19213>:
        if (__result == 0) goto <D.19215>; else goto <D.19216>;
        <D.19215>:
        D.19217 = &MEM[(void *)"MS" + 1B];
        D.19218 = *D.19217;
        D.19219 = (int) D.19218;
        D.19220 = __s2 + 1;
        D.19221 = *D.19220;
        D.19222 = (int) D.19221;
        __result = D.19219 - D.19222;
        if (__s2_len > 1) goto <D.19223>; else goto <D.19224>;
        <D.19223>:
        if (__result == 0) goto <D.19225>; else goto <D.19226>;
        <D.19225>:
        D.19227 = &MEM[(void *)"MS" + 2B];
        D.19228 = *D.19227;
        D.19229 = (int) D.19228;
        D.19230 = __s2 + 2;
        D.19231 = *D.19230;
        D.19232 = (int) D.19231;
        __result = D.19229 - D.19232;
        if (__s2_len > 2) goto <D.19233>; else goto <D.19234>;
        <D.19233>:
        if (__result == 0) goto <D.19235>; else goto <D.19236>;
        <D.19235>:
        D.19237 = &MEM[(void *)"MS" + 3B];
        D.19238 = *D.19237;
        D.19239 = (int) D.19238;
        D.19240 = __s2 + 3;
        D.19241 = *D.19240;
        D.19242 = (int) D.19241;
        __result = D.19239 - D.19242;
        <D.19236>:
        <D.19234>:
        <D.19226>:
        <D.19224>:
        <D.19216>:
        <D.19214>:
      }
      D.18491 = __result;
    }
    iftmp.0 = -D.18491;
    goto <D.19243>;
    <D.19207>:
    iftmp.0 = __builtin_strcmp (com_provider_env, "MS");
    <D.19243>:
    D.18492 = iftmp.0;
  }
  if (D.18492 == 0) goto <D.19244>; else goto <D.19245>;
  <D.19244>:
  com_provider = 1;
  <D.19245>:
  <D.19204>:
  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.19250;
  int (*<T3334>) (void *, glong *, void * *) safe_array_put_element_ms.2;

  com_provider.1 = com_provider;
  if (com_provider.1 == 1) goto <D.19249>; else goto <D.19246>;
  <D.19249>:
  D.19250 = init_com_provider_ms ();
  if (D.19250 != 0) goto <D.19251>; else goto <D.19246>;
  <D.19251>:
  {
    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.19253>; else goto <D.19254>;
    <D.19253>:
    cominterop_raise_hr_exception (hr);
    <D.19254>:
  }
  goto <D.19247>;
  <D.19246>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3154);
  <D.19247>:
}


init_com_provider_ms ()
{
  int initialized.3;
  gboolean D.19258;
  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.19256>; else goto <D.19257>;
      <D.19256>:
      D.19258 = 1;
      return D.19258;
      <D.19257>:
      module = mono_dl_open (scope, 1, &error_msg);
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.19260>; else goto <D.19261>;
      <D.19260>:
      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.19258 = 0;
      return D.19258;
      <D.19261>:
      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.19263>; else goto <D.19264>;
      <D.19263>:
      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.19258 = 0;
      return D.19258;
      <D.19264>:
      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.19266>; else goto <D.19267>;
      <D.19266>:
      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.19258 = 0;
      return D.19258;
      <D.19267>:
      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.19269>; else goto <D.19270>;
      <D.19269>:
      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.19258 = 0;
      return D.19258;
      <D.19270>:
      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.19272>; else goto <D.19273>;
      <D.19272>:
      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.19258 = 0;
      return D.19258;
      <D.19273>:
      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.19275>; else goto <D.19276>;
      <D.19275>:
      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.19258 = 0;
      return D.19258;
      <D.19276>:
      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.19278>; else goto <D.19279>;
      <D.19278>:
      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.19258 = 0;
      return D.19258;
      <D.19279>:
      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.19281>; else goto <D.19282>;
      <D.19281>:
      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.19258 = 0;
      return D.19258;
      <D.19282>:
      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.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", "SafeArrayDestroy", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2552);
      D.19258 = 0;
      return D.19258;
      <D.19285>:
      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.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", "SafeArrayPutElement", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2559);
      D.19258 = 0;
      return D.19258;
      <D.19288>:
      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.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", "SafeArrayCreate", scope, error_msg.4);
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2566);
      D.19258 = 0;
      return D.19258;
      <D.19291>:
      initialized = 1;
      D.19258 = 1;
      return D.19258;
    }
  finally
    {
      error_msg = {CLOBBER};
    }
}


cominterop_raise_hr_exception (int hr)
{
  struct MonoMethod * throw_exception_for_hr.15;
  struct MonoClass * D.19297;
  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.19295>; else goto <D.19296>;
      <D.19295>:
      D.19297 = mono_defaults.marshal_class;
      throw_exception_for_hr.16 = mono_class_get_method_from_name (D.19297, "GetExceptionForHR", 1);
      throw_exception_for_hr = throw_exception_for_hr.16;
      <D.19296>:
      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.19303;
  gboolean D.19304;
  unsigned int D.19305;
  struct MonoVTable * D.19306;
  struct MonoClass * D.19307;
  unsigned char D.19308;
  unsigned int dim.18;
  unsigned int D.19310;
  void * D.19311;
  unsigned int D.19312;
  _Bool D.19313;
  int D.19314;
  void * D.19317;
  unsigned int i.19;
  unsigned int D.19319;
  int * D.19320;
  unsigned int D.19321;
  struct SAFEARRAYBOUND * D.19322;
  struct MonoArrayBounds * D.19323;
  struct MonoArrayBounds * D.19324;
  int D.19325;
  int D.19326;
  unsigned int D.19327;
  unsigned int max_array_length.20;
  void * (*<T3340>) (int, guint32, struct SAFEARRAYBOUND *) safe_array_create_ms.21;
  unsigned int dim.22;
  void * D.19332;
  int dim;
  struct SAFEARRAYBOUND * bounds;
  int i;
  int max_array_length;

  com_provider.17 = com_provider;
  if (com_provider.17 != 1) goto <D.19299>; else goto <D.19302>;
  <D.19302>:
  D.19303 = init_com_provider_ms ();
  if (D.19303 == 0) goto <D.19299>; else goto <D.19300>;
  <D.19299>:
  D.19304 = 0;
  return D.19304;
  <D.19300>:
  D.19305 = mono_array_length (input);
  max_array_length = (int) D.19305;
  D.19306 = MEM[(struct MonoObject *)input].vtable;
  D.19307 = D.19306->klass;
  D.19308 = D.19307->rank;
  dim = (int) D.19308;
  dim.18 = (unsigned int) dim;
  D.19310 = dim.18 * 4;
  D.19311 = monoeg_malloc (D.19310);
  *indices = D.19311;
  dim.18 = (unsigned int) dim;
  D.19312 = dim.18 * 8;
  bounds = __builtin_alloca (D.19312);
  D.19313 = max_array_length == 0;
  D.19314 = (int) D.19313;
  MEM[(int *)empty] = D.19314;
  if (dim > 1) goto <D.19315>; else goto <D.19316>;
  <D.19315>:
  i = 0;
  goto <D.19132>;
  <D.19131>:
  D.19317 = *indices;
  i.19 = (unsigned int) i;
  D.19319 = i.19 * 4;
  D.19320 = D.19317 + D.19319;
  i.19 = (unsigned int) i;
  D.19321 = i.19 * 8;
  D.19322 = bounds + D.19321;
  D.19323 = input->bounds;
  i.19 = (unsigned int) i;
  D.19321 = i.19 * 8;
  D.19324 = D.19323 + D.19321;
  D.19325 = D.19324->lower_bound;
  D.19322->lLbound = D.19325;
  D.19326 = D.19322->lLbound;
  *D.19320 = D.19326;
  i.19 = (unsigned int) i;
  D.19321 = i.19 * 8;
  D.19322 = bounds + D.19321;
  D.19323 = input->bounds;
  i.19 = (unsigned int) i;
  D.19321 = i.19 * 8;
  D.19324 = D.19323 + D.19321;
  D.19327 = D.19324->length;
  D.19322->cElements = D.19327;
  i = i + 1;
  <D.19132>:
  if (i < dim) goto <D.19131>; else goto <D.19133>;
  <D.19133>:
  goto <D.19328>;
  <D.19316>:
  D.19317 = *indices;
  MEM[(int *)D.19317] = 0;
  max_array_length.20 = (unsigned int) max_array_length;
  bounds->cElements = max_array_length.20;
  bounds->lLbound = 0;
  <D.19328>:
  safe_array_create_ms.21 = safe_array_create_ms;
  dim.22 = (unsigned int) dim;
  D.19332 = safe_array_create_ms.21 (12, dim.22, bounds);
  *newsafearray = D.19332;
  D.19304 = 1;
  return D.19304;
}


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

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


mono_marshal_safearray_next (void * safearray, void * indices)
{
  unsigned int D.19341;
  int D.19342;
  unsigned int D.19343;
  unsigned int i.25;
  unsigned int D.19347;
  int * D.19348;
  int D.19349;
  int D.19350;
  long int ubound.26;
  long int lbound.27;
  gboolean D.19358;
  int i;
  int dim;
  gboolean ret;
  int * pIndices;
  int hr;

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

    try
      {
        D.19342 = i + 1;
        D.19343 = (unsigned int) D.19342;
        hr = mono_marshal_safe_array_get_ubound (safearray, D.19343, &ubound);
        if (hr < 0) goto <D.19344>; else goto <D.19345>;
        <D.19344>:
        cominterop_raise_hr_exception (hr);
        <D.19345>:
        i.25 = (unsigned int) i;
        D.19347 = i.25 * 4;
        D.19348 = pIndices + D.19347;
        D.19349 = *D.19348;
        D.19350 = D.19349 + 1;
        *D.19348 = D.19350;
        D.19349 = *D.19348;
        ubound.26 = ubound;
        if (D.19349 <= ubound.26) goto <D.19114>; else goto <D.19352>;
        <D.19352>:
        D.19342 = i + 1;
        D.19343 = (unsigned int) D.19342;
        hr = mono_marshal_safe_array_get_lbound (safearray, D.19343, &lbound);
        if (hr < 0) goto <D.19353>; else goto <D.19354>;
        <D.19353>:
        cominterop_raise_hr_exception (hr);
        <D.19354>:
        i.25 = (unsigned int) i;
        D.19347 = i.25 * 4;
        D.19348 = pIndices + D.19347;
        lbound.27 = lbound;
        *D.19348 = lbound.27;
        if (i == 0) goto <D.19356>; else goto <D.19357>;
        <D.19356>:
        ret = 0;
        <D.19357>:
      }
    finally
      {
        lbound = {CLOBBER};
        ubound = {CLOBBER};
      }
  }
  i = i + -1;
  <D.19116>:
  if (i >= 0) goto <D.19115>; else goto <D.19114>;
  <D.19114>:
  D.19358 = ret;
  return D.19358;
}


mono_marshal_safearray_get_dim (void * safearray)
{
  <unnamed type> com_provider.28;
  int D.19366;
  guint32 (*<T1778>) (void *) safe_array_get_dim_ms.29;
  guint32 D.19369;
  guint32 result;

  result = 0;
  com_provider.28 = com_provider;
  if (com_provider.28 == 1) goto <D.19365>; else goto <D.19362>;
  <D.19365>:
  D.19366 = init_com_provider_ms ();
  if (D.19366 != 0) goto <D.19367>; else goto <D.19362>;
  <D.19367>:
  safe_array_get_dim_ms.29 = safe_array_get_dim_ms;
  result = safe_array_get_dim_ms.29 (safearray);
  goto <D.19363>;
  <D.19362>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2914);
  <D.19363>:
  D.19369 = result;
  return D.19369;
}


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

  result = 0;
  com_provider.30 = com_provider;
  if (com_provider.30 == 1) goto <D.19374>; else goto <D.19371>;
  <D.19374>:
  D.19375 = init_com_provider_ms ();
  if (D.19375 != 0) goto <D.19376>; else goto <D.19371>;
  <D.19376>:
  safe_array_get_ubound_ms.31 = safe_array_get_ubound_ms;
  result = safe_array_get_ubound_ms.31 (psa, nDim, plUbound);
  goto <D.19372>;
  <D.19371>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2946);
  <D.19372>:
  D.19378 = result;
  return D.19378;
}


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

  result = 0;
  com_provider.32 = com_provider;
  if (com_provider.32 == 1) goto <D.19383>; else goto <D.19380>;
  <D.19383>:
  D.19384 = init_com_provider_ms ();
  if (D.19384 != 0) goto <D.19385>; else goto <D.19380>;
  <D.19385>:
  safe_array_get_lbound_ms.33 = safe_array_get_lbound_ms;
  result = safe_array_get_lbound_ms.33 (psa, nDim, plLbound);
  goto <D.19381>;
  <D.19380>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2930);
  <D.19381>:
  D.19387 = result;
  return D.19387;
}


mono_marshal_safearray_get_value (void * safearray, void * indices)
{
  <unnamed type> com_provider.34;
  int D.19393;
  int (*<T3334>) (void *, glong *, void * *) safe_array_ptr_of_index_ms.35;
  void * D.19398;
  void * result;

  try
    {
      com_provider.34 = com_provider;
      if (com_provider.34 == 1) goto <D.19392>; else goto <D.19389>;
      <D.19392>:
      D.19393 = init_com_provider_ms ();
      if (D.19393 != 0) goto <D.19394>; else goto <D.19389>;
      <D.19394>:
      {
        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.19396>; else goto <D.19397>;
        <D.19396>:
        cominterop_raise_hr_exception (hr);
        <D.19397>:
      }
      goto <D.19390>;
      <D.19389>:
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3038);
      <D.19390>:
      D.19398 = result;
      return D.19398;
    }
  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.19405;
  gboolean D.19406;
  unsigned int D.19409;
  unsigned int dim.37;
  unsigned int D.19413;
  void * D.19414;
  int D.19415;
  unsigned int D.19416;
  long int lbound.38;
  long int ubound.39;
  long int D.19425;
  unsigned int i.40;
  unsigned int D.19427;
  uintptr_t * D.19428;
  unsigned int cursize.41;
  intptr_t * D.19430;
  void * D.19431;
  int * D.19432;
  struct MonoClass * D.19437;
  unsigned int dim.42;
  struct MonoDomain * D.19439;
  struct MonoArray * D.19440;
  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.19401>; else goto <D.19404>;
  <D.19404>:
  D.19405 = init_com_provider_ms ();
  if (D.19405 == 0) goto <D.19401>; else goto <D.19402>;
  <D.19401>:
  D.19406 = 0;
  return D.19406;
  <D.19402>:
  MEM[(int *)empty] = 1;
  if (safearray != 0B) goto <D.19407>; else goto <D.19408>;
  <D.19407>:
  D.19409 = mono_marshal_safearray_get_dim (safearray);
  dim = (int) D.19409;
  if (dim > 0) goto <D.19410>; else goto <D.19411>;
  <D.19410>:
  dim.37 = (unsigned int) dim;
  D.19413 = dim.37 * 4;
  D.19414 = monoeg_malloc (D.19413);
  *indices = D.19414;
  dim.37 = (unsigned int) dim;
  D.19413 = dim.37 * 4;
  sizes = __builtin_alloca (D.19413);
  dim.37 = (unsigned int) dim;
  D.19413 = dim.37 * 4;
  bounds = __builtin_alloca (D.19413);
  i = 0;
  goto <D.19095>;
  <D.19094>:
  {
    glong lbound;
    glong ubound;
    int cursize;
    int hr;

    try
      {
        D.19415 = i + 1;
        D.19416 = (unsigned int) D.19415;
        hr = mono_marshal_safe_array_get_lbound (safearray, D.19416, &lbound);
        if (hr < 0) goto <D.19417>; else goto <D.19418>;
        <D.19417>:
        cominterop_raise_hr_exception (hr);
        <D.19418>:
        lbound.38 = lbound;
        if (lbound.38 != 0) goto <D.19420>; else goto <D.19421>;
        <D.19420>:
        bounded = 1;
        <D.19421>:
        D.19415 = i + 1;
        D.19416 = (unsigned int) D.19415;
        hr = mono_marshal_safe_array_get_ubound (safearray, D.19416, &ubound);
        if (hr < 0) goto <D.19422>; else goto <D.19423>;
        <D.19422>:
        cominterop_raise_hr_exception (hr);
        <D.19423>:
        ubound.39 = ubound;
        lbound.38 = lbound;
        D.19425 = ubound.39 - lbound.38;
        cursize = D.19425 + 1;
        i.40 = (unsigned int) i;
        D.19427 = i.40 * 4;
        D.19428 = sizes + D.19427;
        cursize.41 = (unsigned int) cursize;
        *D.19428 = cursize.41;
        i.40 = (unsigned int) i;
        D.19427 = i.40 * 4;
        D.19430 = bounds + D.19427;
        lbound.38 = lbound;
        *D.19430 = lbound.38;
        D.19431 = *indices;
        i.40 = (unsigned int) i;
        D.19427 = i.40 * 4;
        D.19432 = D.19431 + D.19427;
        lbound.38 = lbound;
        *D.19432 = lbound.38;
        if (cursize != 0) goto <D.19433>; else goto <D.19434>;
        <D.19433>:
        MEM[(int *)empty] = 0;
        <D.19434>:
      }
    finally
      {
        lbound = {CLOBBER};
        ubound = {CLOBBER};
      }
  }
  i = i + 1;
  <D.19095>:
  if (i < dim) goto <D.19094>; else goto <D.19096>;
  <D.19096>:
  if (allocateNewArray != 0) goto <D.19435>; else goto <D.19436>;
  <D.19435>:
  D.19437 = mono_defaults.object_class;
  dim.42 = (unsigned int) dim;
  aklass = mono_bounded_array_class_get (D.19437, dim.42, bounded);
  D.19439 = mono_domain_get ();
  D.19440 = mono_array_new_full (D.19439, aklass, sizes, bounds);
  *result = D.19440;
  goto <D.19441>;
  <D.19436>:
  *result = parameter;
  <D.19441>:
  <D.19411>:
  <D.19408>:
  D.19406 = 1;
  return D.19406;
}


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

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


cominterop_get_interface (struct MonoComObject * obj, struct MonoClass * ic, gboolean throw_exception)
{
  _Bool D.19445;
  long int D.19446;
  long int D.19447;
  int iftmp.43;
  unsigned int D.19453;
  unsigned int D.19454;
  unsigned char D.19456;
  _Bool D.19459;
  long int D.19460;
  long int D.19461;
  _Bool D.19466;
  long int D.19467;
  long int D.19468;
  struct GHashTable * D.19471;
  short unsigned int D.19474;
  unsigned int D.19475;
  const void * D.19476;
  void * itf.44;
  _Bool D.19480;
  long int D.19481;
  long int D.19482;
  void * itf.45;
  _Bool D.19488;
  long int D.19489;
  long int D.19490;
  void * D.19493;
  _Bool D.19504;
  long int D.19505;
  long int D.19506;
  struct GHashTable * D.19511;
  void * D.19512;
  _Bool D.19515;
  long int D.19516;
  long int D.19517;
  _Bool D.19522;
  long int D.19523;
  long int D.19524;
  void * D.19527;
  void * itf;

  try
    {
      itf = 0B;
      D.19445 = ic == 0B;
      D.19446 = (long int) D.19445;
      D.19447 = __builtin_expect (D.19446, 0);
      if (D.19447 != 0) goto <D.19448>; else goto <D.19449>;
      <D.19448>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 473, "ic");
      <D.19449>:
      D.19453 = ic->flags;
      D.19454 = D.19453 & 32;
      if (D.19454 == 0) goto <D.19455>; else goto <D.19451>;
      <D.19455>:
      D.19456 = ic->byval_arg.type;
      if (D.19456 != 19) goto <D.19457>; else goto <D.19451>;
      <D.19457>:
      D.19456 = ic->byval_arg.type;
      if (D.19456 != 30) goto <D.19458>; else goto <D.19451>;
      <D.19458>:
      iftmp.43 = 1;
      goto <D.19452>;
      <D.19451>:
      iftmp.43 = 0;
      <D.19452>:
      D.19459 = iftmp.43 != 0;
      D.19460 = (long int) D.19459;
      D.19461 = __builtin_expect (D.19460, 0);
      if (D.19461 != 0) goto <D.19462>; else goto <D.19463>;
      <D.19462>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 474, "MONO_CLASS_IS_INTERFACE (ic)");
      <D.19463>:
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19464>; else goto <D.19465>;
        <D.19464>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.19465>:
        D.19466 = ret != 0;
        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", 476, "ret == 0");
        <D.19470>:
      }
      D.19471 = obj->itf_hash;
      if (D.19471 != 0B) goto <D.19472>; else goto <D.19473>;
      <D.19472>:
      D.19471 = obj->itf_hash;
      D.19474 = ic->interface_id;
      D.19475 = (unsigned int) D.19474;
      D.19476 = (const void *) D.19475;
      itf.44 = monoeg_g_hash_table_lookup (D.19471, D.19476);
      itf = itf.44;
      <D.19473>:
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19478>; else goto <D.19479>;
        <D.19478>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.19479>:
        D.19480 = ret != 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", 479, "ret == 0");
        <D.19484>:
      }
      itf.45 = itf;
      if (itf.45 == 0B) goto <D.19486>; else goto <D.19487>;
      <D.19486>:
      {
        guint8 iid[16];
        int found;
        int hr;

        try
          {
            found = cominterop_class_guid (ic, &iid);
            D.19488 = found == 0;
            D.19489 = (long int) D.19488;
            D.19490 = __builtin_expect (D.19489, 0);
            if (D.19490 != 0) goto <D.19491>; else goto <D.19492>;
            <D.19491>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 485, "found");
            <D.19492>:
            D.19493 = obj->iunknown;
            hr = ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (D.19493, &iid, &itf);
            if (hr < 0) goto <D.19494>; else goto <D.19495>;
            <D.19494>:
            if (throw_exception != 0) goto <D.19496>; else goto <D.19497>;
            <D.19496>:
            cominterop_raise_hr_exception (hr);
            <D.19497>:
            <D.19495>:
            if (hr >= 0) goto <D.19498>; else goto <D.19499>;
            <D.19498>:
            itf.45 = itf;
            if (itf.45 != 0B) goto <D.19500>; else goto <D.19501>;
            <D.19500>:
            {
              int ret;

              ret = pthread_mutex_lock (&cominterop_mutex.mutex);
              if (ret != 0) goto <D.19502>; else goto <D.19503>;
              <D.19502>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
              <D.19503>:
              D.19504 = ret != 0;
              D.19505 = (long int) D.19504;
              D.19506 = __builtin_expect (D.19505, 0);
              if (D.19506 != 0) goto <D.19507>; else goto <D.19508>;
              <D.19507>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 492, "ret == 0");
              <D.19508>:
            }
            D.19471 = obj->itf_hash;
            if (D.19471 == 0B) goto <D.19509>; else goto <D.19510>;
            <D.19509>:
            D.19511 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
            obj->itf_hash = D.19511;
            <D.19510>:
            D.19471 = obj->itf_hash;
            D.19474 = ic->interface_id;
            D.19475 = (unsigned int) D.19474;
            D.19512 = (void *) D.19475;
            itf.45 = itf;
            monoeg_g_hash_table_insert_replace (D.19471, D.19512, itf.45, 0);
            {
              int ret;

              ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
              if (ret != 0) goto <D.19513>; else goto <D.19514>;
              <D.19513>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
              <D.19514>:
              D.19515 = ret != 0;
              D.19516 = (long int) D.19515;
              D.19517 = __builtin_expect (D.19516, 0);
              if (D.19517 != 0) goto <D.19518>; else goto <D.19519>;
              <D.19518>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 496, "ret == 0");
              <D.19519>:
            }
            <D.19501>:
            <D.19499>:
          }
        finally
          {
            iid = {CLOBBER};
          }
      }
      <D.19487>:
      if (throw_exception != 0) goto <D.19520>; else goto <D.19521>;
      <D.19520>:
      itf.45 = itf;
      D.19522 = itf.45 == 0B;
      D.19523 = (long int) D.19522;
      D.19524 = __builtin_expect (D.19523, 0);
      if (D.19524 != 0) goto <D.19525>; else goto <D.19526>;
      <D.19525>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 501, "itf");
      <D.19526>:
      <D.19521>:
      D.19527 = itf;
      return D.19527;
    }
  finally
    {
      itf = {CLOBBER};
    }
}


cominterop_class_guid (struct MonoClass * klass, guint8 * guid)
{
  struct MonoClass * GuidAttribute.46;
  struct MonoImage * D.19533;
  struct MonoClass * GuidAttribute.47;
  gboolean D.19539;
  int D.19540;
  struct MonoString * D.19543;
  static struct MonoClass * GuidAttribute = 0B;
  struct MonoCustomAttrInfo * cinfo;

  GuidAttribute.46 = GuidAttribute;
  if (GuidAttribute.46 == 0B) goto <D.19531>; else goto <D.19532>;
  <D.19531>:
  D.19533 = mono_defaults.corlib;
  GuidAttribute.47 = mono_class_from_name (D.19533, "System.Runtime.InteropServices", "GuidAttribute");
  GuidAttribute = GuidAttribute.47;
  <D.19532>:
  cinfo = mono_custom_attrs_from_class (klass);
  if (cinfo != 0B) goto <D.19535>; else goto <D.19536>;
  <D.19535>:
  {
    struct MonoReflectionGuidAttribute * attr;

    GuidAttribute.46 = GuidAttribute;
    attr = mono_custom_attrs_get_attr (cinfo, GuidAttribute.46);
    if (attr == 0B) goto <D.19537>; else goto <D.19538>;
    <D.19537>:
    D.19539 = 0;
    return D.19539;
    <D.19538>:
    D.19540 = cinfo->cached;
    if (D.19540 == 0) goto <D.19541>; else goto <D.19542>;
    <D.19541>:
    mono_custom_attrs_free (cinfo);
    <D.19542>:
    D.19543 = attr->guid;
    cominterop_mono_string_to_guid (D.19543, guid);
    D.19539 = 1;
    return D.19539;
  }
  <D.19536>:
  D.19539 = 0;
  return D.19539;
}


cominterop_mono_string_to_guid (struct MonoString * string, guint8 * guid)
{
  sizetype i.48;
  guint8 * D.19546;
  unsigned char D.19547;
  unsigned int D.19548;
  unsigned int D.19549;
  gunichar2 * D.19550;
  short unsigned int D.19551;
  unsigned int D.19552;
  int D.19553;
  unsigned char D.19554;
  sizetype D.19555;
  sizetype D.19556;
  sizetype D.19557;
  gunichar2 * D.19558;
  short unsigned int D.19559;
  unsigned int D.19560;
  int D.19561;
  unsigned char D.19562;
  unsigned char D.19563;
  unsigned char D.19564;
  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.18874>;
  <D.18873>:
  i.48 = (sizetype) i;
  D.19546 = guid + i.48;
  D.19547 = indexes[i];
  D.19548 = (unsigned int) D.19547;
  D.19549 = D.19548 * 2;
  D.19550 = chars + D.19549;
  D.19551 = *D.19550;
  D.19552 = (unsigned int) D.19551;
  D.19553 = monoeg_g_unichar_xdigit_value (D.19552);
  D.19554 = (unsigned char) D.19553;
  D.19547 = indexes[i];
  D.19555 = (sizetype) D.19547;
  D.19556 = D.19555 + 2147483647;
  D.19557 = D.19556 * 2;
  D.19558 = chars + D.19557;
  D.19559 = *D.19558;
  D.19560 = (unsigned int) D.19559;
  D.19561 = monoeg_g_unichar_xdigit_value (D.19560);
  D.19562 = (unsigned char) D.19561;
  D.19563 = D.19562 << 4;
  D.19564 = D.19554 + D.19563;
  *D.19546 = D.19564;
  i = i + 1;
  <D.18874>:
  i.49 = (unsigned int) i;
  if (i.49 <= 15) goto <D.18873>; else goto <D.18875>;
  <D.18875>:
}


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

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


cominterop_get_ccw_object (struct MonoCCWInterface * ccw_entry, gboolean verify)
{
  struct GHashTable * ccw_interface_hash.50;
  struct MonoObject * D.19571;
  _Bool D.19575;
  long int D.19576;
  long int D.19577;
  unsigned int D.19582;
  struct MonoCCW * ccw;

  ccw = 0B;
  ccw_interface_hash.50 = ccw_interface_hash;
  if (ccw_interface_hash.50 == 0B) goto <D.19569>; else goto <D.19570>;
  <D.19569>:
  D.19571 = 0B;
  return D.19571;
  <D.19570>:
  if (verify != 0) goto <D.19572>; else goto <D.19573>;
  <D.19572>:
  ccw_interface_hash.50 = ccw_interface_hash;
  ccw = monoeg_g_hash_table_lookup (ccw_interface_hash.50, ccw_entry);
  goto <D.19574>;
  <D.19573>:
  ccw = ccw_entry->ccw;
  D.19575 = ccw == 0B;
  D.19576 = (long int) D.19575;
  D.19577 = __builtin_expect (D.19576, 0);
  if (D.19577 != 0) goto <D.19578>; else goto <D.19579>;
  <D.19578>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1764, "ccw");
  <D.19579>:
  <D.19574>:
  if (ccw != 0B) goto <D.19580>; else goto <D.19581>;
  <D.19580>:
  D.19582 = ccw->gc_handle;
  D.19571 = mono_gchandle_get_target (D.19582);
  return D.19571;
  <D.19581>:
  D.19571 = 0B;
  return D.19571;
}


cominterop_get_ccw (struct MonoObject * object, struct MonoClass * itf)
{
  void * D.19586;
  _Bool D.19589;
  long int D.19590;
  long int D.19591;
  struct GHashTable * ccw_hash.51;
  struct GHashTable * ccw_hash.52;
  struct GHashTable * ccw_interface_hash.53;
  struct GHashTable * ccw_interface_hash.54;
  int D.19602;
  const void * D.19603;
  _Bool D.19606;
  long int D.19607;
  long int D.19608;
  unsigned int D.19611;
  struct MonoObject * D.19612;
  struct GList * iftmp.55;
  void * D.19619;
  void * D.19622;
  struct GHashTable * D.19627;
  unsigned int D.19628;
  _Bool D.19634;
  long int D.19635;
  long int D.19636;
  int D.19639;
  void * D.19640;
  _Bool D.19643;
  long int D.19644;
  long int D.19645;
  struct MonoClass * coclass_attribute.56;
  struct MonoImage * D.19653;
  struct MonoClass * coclass_attribute.57;
  int D.19655;
  int iftmp.58;
  short unsigned int D.19662;
  struct MonoClass * * D.19664;
  struct MonoClass * D.19665;
  _Bool D.19666;
  long int D.19667;
  long int D.19668;
  int D.19671;
  struct MonoClass * D.19674;
  struct MonoClass * D.19678;
  unsigned int D.19682;
  unsigned int method_count.59;
  unsigned int D.19684;
  struct GHashTable * D.19685;
  int D.19688;
  struct MonoImage * D.19689;
  int D.19690;
  unsigned int D.19691;
  unsigned int D.19692;
  void * * D.19695;
  unsigned int D.19696;
  struct MonoMethod * * D.19697;
  unsigned int i.60;
  unsigned int D.19699;
  struct MonoMethod * * D.19700;
  short unsigned int D.19701;
  int D.19702;
  const char * D.19703;
  short unsigned int D.19704;
  int D.19705;
  int D.19706;
  unsigned int D.19707;
  unsigned int D.19708;
  short unsigned int D.19709;
  unsigned int mspec_index.61;
  unsigned int D.19711;
  struct MonoMarshalSpec * * D.19712;
  unsigned int param_index.62;
  unsigned int D.19714;
  struct MonoMarshalSpec * * D.19715;
  struct MonoMarshalSpec * D.19716;
  struct MonoMarshalSpec * D.19717;
  struct MonoType * D.19720;
  unsigned char D.19721;
  void * D.19724;
  void * D.19728;
  void * D.19732;
  void * D.19736;
  short int D.19741;
  short int D.19744;
  unsigned short D.19745;
  unsigned short D.19746;
  short int D.19747;
  struct MonoMarshalSpec * * D.19748;
  struct MonoType * D.19751;
  int D.19752;
  struct MonoMarshalSpec * D.19755;
  int D.19758;
  struct MonoType * D.19759;
  unsigned char D.19760;
  void * D.19763;
  void * D.19767;
  void * D.19771;
  void * D.19775;
  unsigned int D.19776;
  unsigned int D.19777;
  struct MonoMarshalSpec * * D.19778;
  _Bool D.19781;
  long int D.19782;
  long int D.19783;
  struct MonoMethodSignature * D.19786;
  short unsigned int D.19787;
  int D.19788;
  int D.19789;
  _Bool D.19792;
  long int D.19793;
  long int D.19794;
  int vtable_index.63;
  unsigned int vtable_index.64;
  unsigned int D.19799;
  void * * D.19800;
  void * D.19801;
  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.19584>; else goto <D.19585>;
      <D.19584>:
      D.19586 = 0B;
      return D.19586;
      <D.19585>:
      klass = mono_object_get_class (object);
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19587>; else goto <D.19588>;
        <D.19587>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.19588>:
        D.19589 = ret != 0;
        D.19590 = (long int) D.19589;
        D.19591 = __builtin_expect (D.19590, 0);
        if (D.19591 != 0) goto <D.19592>; else goto <D.19593>;
        <D.19592>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1828, "ret == 0");
        <D.19593>:
      }
      ccw_hash.51 = ccw_hash;
      if (ccw_hash.51 == 0B) goto <D.19595>; else goto <D.19596>;
      <D.19595>:
      ccw_hash.52 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw_hash = ccw_hash.52;
      <D.19596>:
      ccw_interface_hash.53 = ccw_interface_hash;
      if (ccw_interface_hash.53 == 0B) goto <D.19599>; else goto <D.19600>;
      <D.19599>:
      ccw_interface_hash.54 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw_interface_hash = ccw_interface_hash.54;
      <D.19600>:
      ccw_hash.51 = ccw_hash;
      D.19602 = mono_object_hash (object);
      D.19603 = (const void *) D.19602;
      ccw_list = monoeg_g_hash_table_lookup (ccw_hash.51, D.19603);
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19604>; else goto <D.19605>;
        <D.19604>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.19605>:
        D.19606 = ret != 0;
        D.19607 = (long int) D.19606;
        D.19608 = __builtin_expect (D.19607, 0);
        if (D.19608 != 0) goto <D.19609>; else goto <D.19610>;
        <D.19609>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1835, "ret == 0");
        <D.19610>:
      }
      ccw_list_item = ccw_list;
      goto <D.18796>;
      <D.18795>:
      {
        struct MonoCCW * ccw_iter;

        ccw_iter = ccw_list_item->data;
        D.19611 = ccw_iter->gc_handle;
        D.19612 = mono_gchandle_get_target (D.19611);
        if (D.19612 == object) goto <D.19613>; else goto <D.19614>;
        <D.19613>:
        ccw = ccw_iter;
        goto <D.18794>;
        <D.19614>:
        if (ccw_list_item != 0B) goto <D.19616>; else goto <D.19617>;
        <D.19616>:
        iftmp.55 = ccw_list_item->next;
        goto <D.19618>;
        <D.19617>:
        iftmp.55 = 0B;
        <D.19618>:
        ccw_list_item = iftmp.55;
      }
      <D.18796>:
      if (ccw_list_item != 0B) goto <D.18795>; else goto <D.18794>;
      <D.18794>:
      D.19619 = iunknown[0];
      if (D.19619 == 0B) goto <D.19620>; else goto <D.19621>;
      <D.19620>:
      iunknown[0] = cominterop_ccw_queryinterface;
      iunknown[1] = cominterop_ccw_addref;
      iunknown[2] = cominterop_ccw_release;
      <D.19621>:
      D.19622 = idispatch[0];
      if (D.19622 == 0B) goto <D.19623>; else goto <D.19624>;
      <D.19623>:
      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.19624>:
      if (ccw == 0B) goto <D.19625>; else goto <D.19626>;
      <D.19625>:
      ccw = monoeg_malloc0 (12);
      D.19627 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw->vtable_hash = D.19627;
      ccw->ref_count = 0;
      D.19628 = mono_gchandle_new_weakref (object, 0);
      ccw->gc_handle = D.19628;
      if (ccw_list == 0B) goto <D.19629>; else goto <D.19630>;
      <D.19629>:
      ccw_list = monoeg_g_list_alloc ();
      ccw_list->data = ccw;
      goto <D.19631>;
      <D.19630>:
      ccw_list = monoeg_g_list_append (ccw_list, ccw);
      <D.19631>:
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19632>; else goto <D.19633>;
        <D.19632>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.19633>:
        D.19634 = ret != 0;
        D.19635 = (long int) D.19634;
        D.19636 = __builtin_expect (D.19635, 0);
        if (D.19636 != 0) goto <D.19637>; else goto <D.19638>;
        <D.19637>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1876, "ret == 0");
        <D.19638>:
      }
      ccw_hash.51 = ccw_hash;
      D.19639 = mono_object_hash (object);
      D.19640 = (void *) D.19639;
      monoeg_g_hash_table_insert_replace (ccw_hash.51, D.19640, ccw_list, 0);
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19641>; else goto <D.19642>;
        <D.19641>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.19642>:
        D.19643 = ret != 0;
        D.19644 = (long int) D.19643;
        D.19645 = __builtin_expect (D.19644, 0);
        if (D.19645 != 0) goto <D.19646>; else goto <D.19647>;
        <D.19646>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1878, "ret == 0");
        <D.19647>:
      }
      mono_object_register_finalizer (object);
      <D.19626>:
      cinfo = mono_custom_attrs_from_class (itf);
      if (cinfo != 0B) goto <D.19648>; else goto <D.19649>;
      <D.19648>:
      {
        static struct MonoClass * coclass_attribute = 0B;

        coclass_attribute.56 = coclass_attribute;
        if (coclass_attribute.56 == 0B) goto <D.19651>; else goto <D.19652>;
        <D.19651>:
        D.19653 = mono_defaults.corlib;
        coclass_attribute.57 = mono_class_from_name (D.19653, "System.Runtime.InteropServices", "CoClassAttribute");
        coclass_attribute = coclass_attribute.57;
        <D.19652>:
        coclass_attribute.56 = coclass_attribute;
        D.19655 = mono_custom_attrs_has_attr (cinfo, coclass_attribute.56);
        if (D.19655 != 0) goto <D.19656>; else goto <D.19657>;
        <D.19656>:
        D.19662 = itf->interface_count;
        if (D.19662 == 0) goto <D.19659>; else goto <D.19663>;
        <D.19663>:
        D.19664 = itf->interfaces;
        D.19665 = *D.19664;
        if (D.19665 == 0B) goto <D.19659>; else goto <D.19660>;
        <D.19659>:
        iftmp.58 = 1;
        goto <D.19661>;
        <D.19660>:
        iftmp.58 = 0;
        <D.19661>:
        D.19666 = iftmp.58 != 0;
        D.19667 = (long int) D.19666;
        D.19668 = __builtin_expect (D.19667, 0);
        if (D.19668 != 0) goto <D.19669>; else goto <D.19670>;
        <D.19669>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1889, "itf->interface_count && itf->interfaces[0]");
        <D.19670>:
        D.19664 = itf->interfaces;
        itf = *D.19664;
        <D.19657>:
        D.19671 = cinfo->cached;
        if (D.19671 == 0) goto <D.19672>; else goto <D.19673>;
        <D.19672>:
        mono_custom_attrs_free (cinfo);
        <D.19673>:
      }
      <D.19649>:
      iface = itf;
      D.19674 = mono_class_get_iunknown_class ();
      if (D.19674 == iface) goto <D.19675>; else goto <D.19676>;
      <D.19675>:
      start_slot = 3;
      goto <D.19677>;
      <D.19676>:
      D.19678 = mono_class_get_idispatch_class ();
      if (D.19678 == iface) goto <D.19679>; else goto <D.19680>;
      <D.19679>:
      start_slot = 7;
      goto <D.19681>;
      <D.19680>:
      D.19682 = iface->method.count;
      method_count.59 = (unsigned int) method_count;
      D.19684 = D.19682 + method_count.59;
      method_count = (int) D.19684;
      start_slot = cominterop_get_com_slot_begin (iface);
      iface = 0B;
      <D.19681>:
      <D.19677>:
      D.19685 = ccw->vtable_hash;
      ccw_entry = monoeg_g_hash_table_lookup (D.19685, itf);
      if (ccw_entry == 0B) goto <D.19686>; else goto <D.19687>;
      <D.19686>:
      {
        int vtable_index;

        D.19688 = method_count + -1;
        vtable_index = D.19688 + start_slot;
        D.19689 = klass->image;
        D.19690 = method_count + start_slot;
        D.19691 = (unsigned int) D.19690;
        D.19692 = D.19691 * 4;
        vtable = mono_image_alloc0 (D.19689, D.19692);
        memcpy (vtable, &iunknown, 12);
        if (start_slot == 7) goto <D.19693>; else goto <D.19694>;
        <D.19693>:
        D.19695 = vtable + 12;
        memcpy (D.19695, &idispatch, 16);
        <D.19694>:
        iface = itf;
        D.19682 = iface->method.count;
        D.19696 = D.19682 + 4294967295;
        i = (int) D.19696;
        goto <D.18820>;
        <D.18819>:
        {
          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.19697 = iface->methods;
          i.60 = (unsigned int) i;
          D.19699 = i.60 * 4;
          D.19700 = D.19697 + D.19699;
          method = *D.19700;
          sig = mono_method_signature (method);
          D.19701 = method->iflags;
          D.19702 = (int) D.19701;
          preserve_sig = D.19702 & 128;
          D.19703 = method->name;
          mb = mono_mb_new (iface, D.19703, 5);
          adjust_method = cominterop_get_managed_wrapper_adjusted (method);
          sig_adjusted = mono_method_signature (adjust_method);
          D.19704 = sig_adjusted->param_count;
          D.19705 = (int) D.19704;
          D.19706 = D.19705 + 1;
          D.19707 = (unsigned int) D.19706;
          D.19708 = D.19707 * 4;
          mspecs = monoeg_malloc (D.19708);
          mono_method_get_marshal_info (method, mspecs);
          D.19709 = sig->param_count;
          param_index = (int) D.19709;
          goto <D.18812>;
          <D.18811>:
          {
            int mspec_index;

            mspec_index = param_index + 1;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            param_index.62 = (unsigned int) param_index;
            D.19714 = param_index.62 * 4;
            D.19715 = mspecs + D.19714;
            D.19716 = *D.19715;
            *D.19712 = D.19716;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19717 = *D.19712;
            if (D.19717 == 0B) goto <D.19718>; else goto <D.19719>;
            <D.19718>:
            D.19720 = sig_adjusted->params[param_index];
            D.19721 = D.19720->type;
            if (D.19721 == 28) goto <D.19722>; else goto <D.19723>;
            <D.19722>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19724 = monoeg_malloc0 (16);
            *D.19712 = D.19724;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19717 = *D.19712;
            D.19717->native = 27;
            goto <D.19725>;
            <D.19723>:
            D.19720 = sig_adjusted->params[param_index];
            D.19721 = D.19720->type;
            if (D.19721 == 14) goto <D.19726>; else goto <D.19727>;
            <D.19726>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19728 = monoeg_malloc0 (16);
            *D.19712 = D.19728;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19717 = *D.19712;
            D.19717->native = 19;
            goto <D.19729>;
            <D.19727>:
            D.19720 = sig_adjusted->params[param_index];
            D.19721 = D.19720->type;
            if (D.19721 == 18) goto <D.19730>; else goto <D.19731>;
            <D.19730>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19732 = monoeg_malloc0 (16);
            *D.19712 = D.19732;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19717 = *D.19712;
            D.19717->native = 28;
            goto <D.19733>;
            <D.19731>:
            D.19720 = sig_adjusted->params[param_index];
            D.19721 = D.19720->type;
            if (D.19721 == 2) goto <D.19734>; else goto <D.19735>;
            <D.19734>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19736 = monoeg_malloc0 (16);
            *D.19712 = D.19736;
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19717 = *D.19712;
            D.19717->native = 37;
            <D.19735>:
            <D.19733>:
            <D.19729>:
            <D.19725>:
            goto <D.19737>;
            <D.19719>:
            D.19720 = sig_adjusted->params[param_index];
            D.19721 = D.19720->type;
            if (D.19721 == 20) goto <D.19738>; else goto <D.19740>;
            <D.19740>:
            D.19720 = sig_adjusted->params[param_index];
            D.19721 = D.19720->type;
            if (D.19721 == 29) goto <D.19738>; else goto <D.19739>;
            <D.19738>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19717 = *D.19712;
            D.19741 = D.19717->data.array_data.param_num;
            if (D.19741 != -1) goto <D.19742>; else goto <D.19743>;
            <D.19742>:
            mspec_index.61 = (unsigned int) mspec_index;
            D.19711 = mspec_index.61 * 4;
            D.19712 = mspecs + D.19711;
            D.19717 = *D.19712;
            D.19741 = D.19717->data.array_data.param_num;
            D.19744 = D.19741;
            D.19745 = (unsigned short) D.19744;
            D.19746 = D.19745 + 1;
            D.19747 = (short int) D.19746;
            D.19717->data.array_data.param_num = D.19747;
            <D.19743>:
            <D.19739>:
            <D.19737>:
          }
          param_index = param_index + -1;
          <D.18812>:
          if (param_index > 0) goto <D.18811>; else goto <D.18813>;
          <D.18813>:
          D.19748 = mspecs + 4;
          *D.19748 = 0B;
          if (preserve_sig == 0) goto <D.19749>; else goto <D.19750>;
          <D.19749>:
          D.19751 = sig->ret;
          D.19752 = mono_type_is_void (D.19751);
          if (D.19752 == 0) goto <D.19753>; else goto <D.19754>;
          <D.19753>:
          D.19755 = *mspecs;
          if (D.19755 == 0B) goto <D.19756>; else goto <D.19757>;
          <D.19756>:
          D.19704 = sig_adjusted->param_count;
          D.19705 = (int) D.19704;
          D.19758 = D.19705 + -1;
          D.19759 = sig_adjusted->params[D.19758];
          D.19760 = D.19759->type;
          if (D.19760 == 28) goto <D.19761>; else goto <D.19762>;
          <D.19761>:
          D.19763 = monoeg_malloc0 (16);
          *mspecs = D.19763;
          D.19755 = *mspecs;
          D.19755->native = 27;
          goto <D.19764>;
          <D.19762>:
          D.19704 = sig_adjusted->param_count;
          D.19705 = (int) D.19704;
          D.19758 = D.19705 + -1;
          D.19759 = sig_adjusted->params[D.19758];
          D.19760 = D.19759->type;
          if (D.19760 == 14) goto <D.19765>; else goto <D.19766>;
          <D.19765>:
          D.19767 = monoeg_malloc0 (16);
          *mspecs = D.19767;
          D.19755 = *mspecs;
          D.19755->native = 19;
          goto <D.19768>;
          <D.19766>:
          D.19704 = sig_adjusted->param_count;
          D.19705 = (int) D.19704;
          D.19758 = D.19705 + -1;
          D.19759 = sig_adjusted->params[D.19758];
          D.19760 = D.19759->type;
          if (D.19760 == 18) goto <D.19769>; else goto <D.19770>;
          <D.19769>:
          D.19771 = monoeg_malloc0 (16);
          *mspecs = D.19771;
          D.19755 = *mspecs;
          D.19755->native = 28;
          goto <D.19772>;
          <D.19770>:
          D.19704 = sig_adjusted->param_count;
          D.19705 = (int) D.19704;
          D.19758 = D.19705 + -1;
          D.19759 = sig_adjusted->params[D.19758];
          D.19760 = D.19759->type;
          if (D.19760 == 2) goto <D.19773>; else goto <D.19774>;
          <D.19773>:
          D.19775 = monoeg_malloc0 (16);
          *mspecs = D.19775;
          D.19755 = *mspecs;
          D.19755->native = 37;
          <D.19774>:
          <D.19772>:
          <D.19768>:
          <D.19764>:
          <D.19757>:
          D.19704 = sig_adjusted->param_count;
          D.19776 = (unsigned int) D.19704;
          D.19777 = D.19776 * 4;
          D.19778 = mspecs + D.19777;
          D.19755 = *mspecs;
          *D.19778 = D.19755;
          *mspecs = 0B;
          <D.19754>:
          <D.19750>:
          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.19779>; else goto <D.19780>;
            <D.19779>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
            <D.19780>:
            D.19781 = ret != 0;
            D.19782 = (long int) D.19781;
            D.19783 = __builtin_expect (D.19782, 0);
            if (D.19783 != 0) goto <D.19784>; else goto <D.19785>;
            <D.19784>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2003, "ret == 0");
            <D.19785>:
          }
          D.19786 = m.csig;
          D.19786 = m.csig;
          D.19787 = D.19786->param_count;
          D.19788 = (int) D.19787;
          D.19789 = D.19788 + 16;
          wrapper_method = mono_mb_create_method (mb, D.19786, D.19789);
          {
            int ret;

            ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
            if (ret != 0) goto <D.19790>; else goto <D.19791>;
            <D.19790>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.19791>:
            D.19792 = ret != 0;
            D.19793 = (long int) D.19792;
            D.19794 = __builtin_expect (D.19793, 0);
            if (D.19794 != 0) goto <D.19795>; else goto <D.19796>;
            <D.19795>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2005, "ret == 0");
            <D.19796>:
          }
          vtable_index.63 = vtable_index;
          vtable_index = vtable_index.63 + -1;
          vtable_index.64 = (unsigned int) vtable_index.63;
          D.19799 = vtable_index.64 * 4;
          D.19800 = vtable + D.19799;
          D.19801 = mono_compile_method (wrapper_method);
          *D.19800 = D.19801;
          D.19704 = sig_adjusted->param_count;
          param_index = (int) D.19704;
          goto <D.18817>;
          <D.18816>:
          param_index.62 = (unsigned int) param_index;
          D.19714 = param_index.62 * 4;
          D.19715 = mspecs + D.19714;
          D.19716 = *D.19715;
          if (D.19716 != 0B) goto <D.19802>; else goto <D.19803>;
          <D.19802>:
          param_index.62 = (unsigned int) param_index;
          D.19714 = param_index.62 * 4;
          D.19715 = mspecs + D.19714;
          D.19716 = *D.19715;
          mono_metadata_free_marshal_spec (D.19716);
          <D.19803>:
          param_index = param_index + -1;
          <D.18817>:
          if (param_index >= 0) goto <D.18816>; else goto <D.18818>;
          <D.18818>:
          monoeg_g_free (mspecs);
        }
        i = i + -1;
        <D.18820>:
        if (i >= 0) goto <D.18819>; else goto <D.18821>;
        <D.18821>:
        ccw_entry = monoeg_malloc0 (8);
        ccw_entry->ccw = ccw;
        ccw_entry->vtable = vtable;
        D.19685 = ccw->vtable_hash;
        monoeg_g_hash_table_insert_replace (D.19685, 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.19687>:
      D.19586 = ccw_entry;
      return D.19586;
    }
  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.19806;

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


cominterop_ccw_get_ids_of_names (struct MonoCCWInterface * ccwe, void * riid, gunichar2 * * rgszNames, guint32 cNames, guint32 lcid, gint32 * rgDispId)
{
  unsigned int D.19808;
  _Bool D.19809;
  long int D.19810;
  long int D.19811;
  struct MonoVTable * D.19814;
  struct MonoDomain * D.19815;
  struct MonoDomain * D.19818;
  unsigned int i.65;
  unsigned int D.19820;
  gunichar2 * * D.19821;
  gunichar2 * D.19822;
  gint32 * D.19825;
  unsigned int D.19826;
  int D.19827;
  unsigned int i.66;
  int D.19830;
  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.19808 = ccw->gc_handle;
  object = mono_gchandle_get_target (D.19808);
  D.19809 = object == 0B;
  D.19810 = (long int) D.19809;
  D.19811 = __builtin_expect (D.19810, 0);
  if (D.19811 != 0) goto <D.19812>; else goto <D.19813>;
  <D.19812>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2418, "object");
  <D.19813>:
  D.19814 = object->vtable;
  klass = D.19814->klass;
  D.19815 = mono_domain_get ();
  if (D.19815 == 0B) goto <D.19816>; else goto <D.19817>;
  <D.19816>:
  D.19818 = mono_get_root_domain ();
  mono_thread_attach (D.19818);
  <D.19817>:
  i = 0;
  goto <D.18939>;
  <D.18938>:
  i.65 = (unsigned int) i;
  D.19820 = i.65 * 4;
  D.19821 = rgszNames + D.19820;
  D.19822 = *D.19821;
  methodname = mono_unicode_to_external (D.19822);
  method = mono_class_get_method_from_name (klass, methodname, -1);
  if (method != 0B) goto <D.19823>; else goto <D.19824>;
  <D.19823>:
  i.65 = (unsigned int) i;
  D.19820 = i.65 * 4;
  D.19825 = rgDispId + D.19820;
  D.19826 = method->token;
  D.19827 = (int) D.19826;
  *D.19825 = D.19827;
  goto <D.19828>;
  <D.19824>:
  i.65 = (unsigned int) i;
  D.19820 = i.65 * 4;
  D.19825 = rgDispId + D.19820;
  *D.19825 = -1;
  ret = -2147352570;
  <D.19828>:
  i = i + 1;
  <D.18939>:
  i.66 = (unsigned int) i;
  if (i.66 < cNames) goto <D.18938>; else goto <D.18940>;
  <D.18940>:
  D.19830 = ret;
  return D.19830;
}


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

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


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

  if (pctinfo == 0B) goto <D.19834>; else goto <D.19835>;
  <D.19834>:
  D.19836 = -2147024809;
  return D.19836;
  <D.19835>:
  *pctinfo = 1;
  D.19836 = 0;
  return D.19836;
}


cominterop_ccw_release (struct MonoCCWInterface * ccwe)
{
  _Bool D.19838;
  long int D.19839;
  long int D.19840;
  unsigned int D.19843;
  _Bool D.19844;
  long int D.19845;
  long int D.19846;
  guint32 * D.19849;
  _Bool D.19852;
  long int D.19853;
  long int D.19854;
  struct MonoObject * D.19857;
  unsigned int D.19858;
  int D.19859;
  gint32 ref_count;
  struct MonoCCW * ccw;

  ref_count = 0;
  ccw = ccwe->ccw;
  D.19838 = ccw == 0B;
  D.19839 = (long int) D.19838;
  D.19840 = __builtin_expect (D.19839, 0);
  if (D.19840 != 0) goto <D.19841>; else goto <D.19842>;
  <D.19841>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2272, "ccw");
  <D.19842>:
  D.19843 = ccw->ref_count;
  D.19844 = D.19843 == 0;
  D.19845 = (long int) D.19844;
  D.19846 = __builtin_expect (D.19845, 0);
  if (D.19846 != 0) goto <D.19847>; else goto <D.19848>;
  <D.19847>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2273, "ccw->ref_count > 0");
  <D.19848>:
  D.19849 = &ccw->ref_count;
  ref_count = InterlockedDecrement (D.19849);
  if (ref_count == 0) goto <D.19850>; else goto <D.19851>;
  <D.19850>:
  {
    guint32 oldhandle;

    oldhandle = ccw->gc_handle;
    D.19852 = oldhandle == 0;
    D.19853 = (long int) D.19852;
    D.19854 = __builtin_expect (D.19853, 0);
    if (D.19854 != 0) goto <D.19855>; else goto <D.19856>;
    <D.19855>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2278, "oldhandle");
    <D.19856>:
    D.19857 = mono_gchandle_get_target (oldhandle);
    D.19858 = mono_gchandle_new_weakref (D.19857, 0);
    ccw->gc_handle = D.19858;
    mono_gchandle_free (oldhandle);
  }
  <D.19851>:
  D.19859 = ref_count;
  return D.19859;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.19861;
  unsigned int D.19862;

  D.19862 = __sync_sub_and_fetch_4 (val, 1);
  D.19861 = (gint32) D.19862;
  return D.19861;
}


cominterop_ccw_addref (struct MonoCCWInterface * ccwe)
{
  _Bool D.19864;
  long int D.19865;
  long int D.19866;
  unsigned int D.19869;
  _Bool D.19870;
  long int D.19871;
  long int D.19872;
  guint32 * D.19877;
  _Bool D.19880;
  long int D.19881;
  long int D.19882;
  struct MonoObject * D.19885;
  unsigned int D.19886;
  int D.19887;
  gint32 ref_count;
  struct MonoCCW * ccw;

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

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


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.19889;
  unsigned int D.19890;

  D.19890 = __sync_add_and_fetch_4 (val, 1);
  D.19889 = (gint32) D.19890;
  return D.19889;
}


cominterop_ccw_queryinterface (struct MonoCCWInterface * ccwe, guint8 * riid, void * * ppv)
{
  unsigned int D.19892;
  _Bool D.19893;
  long int D.19894;
  long int D.19895;
  struct MonoVTable * D.19898;
  struct MonoDomain * D.19901;
  struct MonoDomain * D.19904;
  struct MonoClass * D.19905;
  int D.19906;
  struct MonoClass * D.19909;
  void * D.19910;
  void * D.19911;
  int D.19912;
  struct MonoClass * D.19913;
  int D.19914;
  int D.19917;
  struct MonoClass * D.19920;
  void * D.19921;
  int D.19922;
  _Bool D.19923;
  long int D.19924;
  long int D.19925;
  void * * D.19930;
  unsigned int i.67;
  unsigned int D.19932;
  void * * D.19933;
  int D.19934;
  unsigned int i.68;
  unsigned int D.19938;
  struct MonoClass * D.19941;
  void * D.19944;
  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.19892 = ccw->gc_handle;
      object = mono_gchandle_get_target (D.19892);
      D.19893 = object == 0B;
      D.19894 = (long int) D.19893;
      D.19895 = __builtin_expect (D.19894, 0);
      if (D.19895 != 0) goto <D.19896>; else goto <D.19897>;
      <D.19896>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2324, "object");
      <D.19897>:
      D.19898 = object->vtable;
      klass = D.19898->klass;
      if (ppv != 0B) goto <D.19899>; else goto <D.19900>;
      <D.19899>:
      *ppv = 0B;
      <D.19900>:
      D.19901 = mono_domain_get ();
      if (D.19901 == 0B) goto <D.19902>; else goto <D.19903>;
      <D.19902>:
      D.19904 = mono_get_root_domain ();
      mono_thread_attach (D.19904);
      <D.19903>:
      D.19905 = mono_class_get_iunknown_class ();
      D.19906 = cominterop_class_guid_equal (riid, D.19905);
      if (D.19906 != 0) goto <D.19907>; else goto <D.19908>;
      <D.19907>:
      D.19909 = mono_class_get_iunknown_class ();
      D.19910 = cominterop_get_ccw (object, D.19909);
      *ppv = D.19910;
      D.19911 = *ppv;
      cominterop_ccw_addref (D.19911);
      D.19912 = 0;
      return D.19912;
      <D.19908>:
      D.19913 = mono_class_get_idispatch_class ();
      D.19914 = cominterop_class_guid_equal (riid, D.19913);
      if (D.19914 != 0) goto <D.19915>; else goto <D.19916>;
      <D.19915>:
      D.19917 = cominterop_can_support_dispatch (klass);
      if (D.19917 == 0) goto <D.19918>; else goto <D.19919>;
      <D.19918>:
      D.19912 = -2147467262;
      return D.19912;
      <D.19919>:
      D.19920 = mono_class_get_idispatch_class ();
      D.19921 = cominterop_get_ccw (object, D.19920);
      *ppv = D.19921;
      D.19911 = *ppv;
      cominterop_ccw_addref (D.19911);
      D.19912 = 0;
      return D.19912;
      <D.19916>:
      klass_iter = klass;
      goto <D.18912>;
      <D.18911>:
      ifaces = mono_class_get_implemented_interfaces (klass_iter, &error);
      D.19922 = mono_error_ok (&error);
      D.19923 = D.19922 == 0;
      D.19924 = (long int) D.19923;
      D.19925 = __builtin_expect (D.19924, 0);
      if (D.19925 != 0) goto <D.19926>; else goto <D.19927>;
      <D.19926>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2361, "mono_error_ok (&error)");
      <D.19927>:
      if (ifaces != 0B) goto <D.19928>; else goto <D.19929>;
      <D.19928>:
      i = 0;
      goto <D.18909>;
      <D.18908>:
      {
        struct MonoClass * ic;

        ic = 0B;
        D.19930 = ifaces->pdata;
        i.67 = (unsigned int) i;
        D.19932 = i.67 * 4;
        D.19933 = D.19930 + D.19932;
        ic = *D.19933;
        D.19934 = cominterop_class_guid_equal (riid, ic);
        if (D.19934 != 0) goto <D.19935>; else goto <D.19936>;
        <D.19935>:
        itf = ic;
        goto <D.18907>;
        <D.19936>:
      }
      i = i + 1;
      <D.18909>:
      i.68 = (unsigned int) i;
      D.19938 = ifaces->len;
      if (i.68 < D.19938) goto <D.18908>; else goto <D.18907>;
      <D.18907>:
      monoeg_g_ptr_array_free (ifaces, 1);
      <D.19929>:
      if (itf != 0B) goto <D.18910>; else goto <D.19939>;
      <D.19939>:
      klass_iter = klass_iter->parent;
      <D.18912>:
      if (klass_iter != 0B) goto <D.19940>; else goto <D.18910>;
      <D.19940>:
      D.19941 = mono_defaults.object_class;
      if (D.19941 != klass_iter) goto <D.18911>; else goto <D.18910>;
      <D.18910>:
      if (itf != 0B) goto <D.19942>; else goto <D.19943>;
      <D.19942>:
      D.19944 = cominterop_get_ccw (object, itf);
      *ppv = D.19944;
      D.19911 = *ppv;
      cominterop_ccw_addref (D.19911);
      D.19912 = 0;
      return D.19912;
      <D.19943>:
      D.19912 = -2147467262;
      return D.19912;
    }
  finally
    {
      error = {CLOBBER};
    }
}


cominterop_can_support_dispatch (struct MonoClass * klass)
{
  unsigned int D.19947;
  unsigned int D.19948;
  gboolean D.19951;
  int D.19952;

  D.19947 = klass->flags;
  D.19948 = D.19947 & 1;
  if (D.19948 == 0) goto <D.19949>; else goto <D.19950>;
  <D.19949>:
  D.19951 = 0;
  return D.19951;
  <D.19950>:
  D.19952 = cominterop_com_visible (klass);
  if (D.19952 == 0) goto <D.19953>; else goto <D.19954>;
  <D.19953>:
  D.19951 = 0;
  return D.19951;
  <D.19954>:
  D.19951 = 1;
  return D.19951;
}


cominterop_com_visible (struct MonoClass * klass)
{
  struct MonoClass * ComVisibleAttribute.69;
  struct MonoImage * D.19959;
  struct MonoClass * ComVisibleAttribute.70;
  int D.19965;
  gboolean D.19970;
  int D.19971;
  _Bool D.19972;
  long int D.19973;
  long int D.19974;
  void * * D.19979;
  unsigned int i.71;
  unsigned int D.19981;
  void * * D.19982;
  unsigned int D.19983;
  unsigned int D.19984;
  unsigned int i.72;
  unsigned int D.19988;
  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.19957>; else goto <D.19958>;
      <D.19957>:
      D.19959 = mono_defaults.corlib;
      ComVisibleAttribute.70 = mono_class_from_name (D.19959, "System.Runtime.InteropServices", "ComVisibleAttribute");
      ComVisibleAttribute = ComVisibleAttribute.70;
      <D.19958>:
      cinfo = mono_custom_attrs_from_class (klass);
      if (cinfo != 0B) goto <D.19961>; else goto <D.19962>;
      <D.19961>:
      {
        struct MonoReflectionComVisibleAttribute * attr;

        ComVisibleAttribute.69 = ComVisibleAttribute;
        attr = mono_custom_attrs_get_attr (cinfo, ComVisibleAttribute.69);
        if (attr != 0B) goto <D.19963>; else goto <D.19964>;
        <D.19963>:
        visible = attr->visible;
        <D.19964>:
        D.19965 = cinfo->cached;
        if (D.19965 == 0) goto <D.19966>; else goto <D.19967>;
        <D.19966>:
        mono_custom_attrs_free (cinfo);
        <D.19967>:
        if (visible != 0) goto <D.19968>; else goto <D.19969>;
        <D.19968>:
        D.19970 = 1;
        return D.19970;
        <D.19969>:
      }
      <D.19962>:
      ifaces = mono_class_get_implemented_interfaces (klass, &error);
      D.19971 = mono_error_ok (&error);
      D.19972 = D.19971 == 0;
      D.19973 = (long int) D.19972;
      D.19974 = __builtin_expect (D.19973, 0);
      if (D.19974 != 0) goto <D.19975>; else goto <D.19976>;
      <D.19975>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 434, "mono_error_ok (&error)");
      <D.19976>:
      if (ifaces != 0B) goto <D.19977>; else goto <D.19978>;
      <D.19977>:
      {
        int i;

        i = 0;
        goto <D.18450>;
        <D.18449>:
        {
          struct MonoClass * ic;

          ic = 0B;
          D.19979 = ifaces->pdata;
          i.71 = (unsigned int) i;
          D.19981 = i.71 * 4;
          D.19982 = D.19979 + D.19981;
          ic = *D.19982;
          D.19983 = ic->flags;
          D.19984 = D.19983 & 4096;
          if (D.19984 != 0) goto <D.19985>; else goto <D.19986>;
          <D.19985>:
          visible = 1;
          <D.19986>:
        }
        i = i + 1;
        <D.18450>:
        i.72 = (unsigned int) i;
        D.19988 = ifaces->len;
        if (i.72 < D.19988) goto <D.18449>; else goto <D.18451>;
        <D.18451>:
        monoeg_g_ptr_array_free (ifaces, 1);
      }
      <D.19978>:
      D.19970 = (gboolean) visible;
      return D.19970;
    }
  finally
    {
      error = {CLOBBER};
    }
}


cominterop_class_guid_equal (guint8 * guid, struct MonoClass * klass)
{
  int D.19991;
  gboolean D.19994;
  int D.19995;
  _Bool D.19996;
  guint8 klass_guid[16];

  try
    {
      D.19991 = cominterop_class_guid (klass, &klass_guid);
      if (D.19991 != 0) goto <D.19992>; else goto <D.19993>;
      <D.19992>:
      D.19995 = memcmp (guid, &klass_guid, 16);
      D.19996 = D.19995 == 0;
      D.19994 = (gboolean) D.19996;
      return D.19994;
      <D.19993>:
      D.19994 = 0;
      return D.19994;
    }
  finally
    {
      klass_guid = {CLOBBER};
    }
}


cominterop_get_com_slot_begin (struct MonoClass * klass)
{
  struct MonoClass * interface_type_attribute.73;
  struct MonoImage * D.20002;
  struct MonoClass * interface_type_attribute.74;
  int D.20006;
  unsigned int D.20011;
  int D.20013;
  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.20000>; else goto <D.20001>;
  <D.20000>:
  D.20002 = mono_defaults.corlib;
  interface_type_attribute.74 = mono_class_from_name (D.20002, "System.Runtime.InteropServices", "InterfaceTypeAttribute");
  interface_type_attribute = interface_type_attribute.74;
  <D.20001>:
  cinfo = mono_custom_attrs_from_class (klass);
  if (cinfo != 0B) goto <D.20004>; else goto <D.20005>;
  <D.20004>:
  interface_type_attribute.73 = interface_type_attribute;
  itf_attr = mono_custom_attrs_get_attr (cinfo, interface_type_attribute.73);
  D.20006 = cinfo->cached;
  if (D.20006 == 0) goto <D.20007>; else goto <D.20008>;
  <D.20007>:
  mono_custom_attrs_free (cinfo);
  <D.20008>:
  <D.20005>:
  if (itf_attr != 0B) goto <D.20010>; else goto <D.20009>;
  <D.20010>:
  D.20011 = itf_attr->intType;
  if (D.20011 == 1) goto <D.20012>; else goto <D.20009>;
  <D.20012>:
  D.20013 = 3;
  return D.20013;
  <D.20009>:
  D.20013 = 7;
  return D.20013;
}


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

  D.20016 = __builtin_object_size (__dest, 0);
  D.20015 = __builtin___memcpy_chk (__dest, __src, __len, D.20016);
  return D.20015;
}


cominterop_get_managed_wrapper_adjusted (struct MonoMethod * method)
{
  short unsigned int D.20018;
  int D.20019;
  struct MonoMethod * get_hr_for_exception.75;
  struct MonoClass * D.20023;
  struct MonoMethod * get_hr_for_exception.76;
  struct MonoClass * D.20025;
  const char * D.20026;
  short unsigned int D.20027;
  int D.20028;
  int D.20029;
  unsigned int D.20030;
  unsigned int D.20031;
  short unsigned int D.20032;
  sizetype i.77;
  sizetype D.20034;
  sizetype D.20035;
  struct MonoMarshalSpec * * D.20036;
  unsigned int i.78;
  unsigned int D.20038;
  struct MonoMarshalSpec * * D.20039;
  struct MonoMarshalSpec * D.20040;
  struct MonoMarshalSpec * * D.20041;
  struct MonoType * D.20044;
  int D.20045;
  unsigned int D.20048;
  unsigned int D.20049;
  struct MonoMarshalSpec * * D.20050;
  struct MonoMarshalSpec * D.20051;
  struct MonoClass * D.20054;
  struct MonoType * D.20055;
  int D.20057;
  int D.20060;
  unsigned int D.20061;
  int D.20064;
  int D.20067;
  unsigned int D.20068;
  int D.20069;
  unsigned int D.20070;
  int D.20071;
  int D.20072;
  unsigned int D.20077;
  unsigned int D.20078;
  unsigned int D.20082;
  unsigned char D.20083;
  int D.20084;
  unsigned int hr.79;
  unsigned int D.20087;
  int D.20088;
  unsigned int D.20089;
  unsigned int D.20090;
  unsigned int D.20091;
  struct MonoClass * D.20092;
  int D.20093;
  unsigned int D.20094;
  unsigned int D.20100;
  unsigned int D.20101;
  unsigned char D.20103;
  unsigned char D.20104;
  int D.20105;
  unsigned int D.20106;
  unsigned int D.20107;
  unsigned int D.20108;
  unsigned int pos_leave.80;
  int D.20113;
  _Bool D.20116;
  long int D.20117;
  long int D.20118;
  int D.20121;
  _Bool D.20124;
  long int D.20125;
  long int D.20126;
  struct MonoMethod * D.20131;
  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.20018 = method->iflags;
  D.20019 = (int) D.20018;
  preserve_sig = D.20019 & 128;
  get_hr_for_exception.75 = get_hr_for_exception;
  if (get_hr_for_exception.75 == 0B) goto <D.20021>; else goto <D.20022>;
  <D.20021>:
  D.20023 = mono_defaults.marshal_class;
  get_hr_for_exception.76 = mono_class_get_method_from_name (D.20023, "GetHRForException", -1);
  get_hr_for_exception = get_hr_for_exception.76;
  <D.20022>:
  sig = mono_method_signature (method);
  D.20025 = method->klass;
  D.20026 = method->name;
  mb = mono_mb_new (D.20025, D.20026, 27);
  sig_native = cominterop_method_signature (method);
  D.20027 = sig_native->param_count;
  D.20028 = (int) D.20027;
  D.20029 = D.20028 + 1;
  D.20030 = (unsigned int) D.20029;
  D.20031 = D.20030 * 4;
  mspecs = monoeg_malloc0 (D.20031);
  mono_method_get_marshal_info (method, mspecs);
  D.20032 = sig->param_count;
  i = (int) D.20032;
  goto <D.18855>;
  <D.18854>:
  i.77 = (sizetype) i;
  D.20034 = i.77 + 1;
  D.20035 = D.20034 * 4;
  D.20036 = mspecs + D.20035;
  i.78 = (unsigned int) i;
  D.20038 = i.78 * 4;
  D.20039 = mspecs + D.20038;
  D.20040 = *D.20039;
  *D.20036 = D.20040;
  i = i + -1;
  <D.18855>:
  if (i > 0) goto <D.18854>; else goto <D.18856>;
  <D.18856>:
  D.20041 = mspecs + 4;
  *D.20041 = 0B;
  if (preserve_sig == 0) goto <D.20042>; else goto <D.20043>;
  <D.20042>:
  D.20044 = sig->ret;
  D.20045 = mono_type_is_void (D.20044);
  if (D.20045 == 0) goto <D.20046>; else goto <D.20047>;
  <D.20046>:
  D.20027 = sig_native->param_count;
  D.20048 = (unsigned int) D.20027;
  D.20049 = D.20048 * 4;
  D.20050 = mspecs + D.20049;
  D.20051 = *mspecs;
  *D.20050 = D.20051;
  <D.20047>:
  <D.20043>:
  *mspecs = 0B;
  if (preserve_sig == 0) goto <D.20052>; else goto <D.20053>;
  <D.20052>:
  D.20054 = mono_defaults.int32_class;
  D.20055 = &D.20054->byval_arg;
  hr = mono_mb_add_local (mb, D.20055);
  goto <D.20056>;
  <D.20053>:
  D.20044 = sig->ret;
  D.20057 = mono_type_is_void (D.20044);
  if (D.20057 == 0) goto <D.20058>; else goto <D.20059>;
  <D.20058>:
  D.20044 = sig->ret;
  hr = mono_mb_add_local (mb, D.20044);
  <D.20059>:
  <D.20056>:
  main_clause = monoeg_malloc0 (24);
  D.20060 = mono_mb_get_label (mb);
  D.20061 = (unsigned int) D.20060;
  main_clause->try_offset = D.20061;
  if (preserve_sig == 0) goto <D.20062>; else goto <D.20063>;
  <D.20062>:
  D.20044 = sig->ret;
  D.20064 = mono_type_is_void (D.20044);
  if (D.20064 == 0) goto <D.20065>; else goto <D.20066>;
  <D.20065>:
  D.20027 = sig_native->param_count;
  D.20028 = (int) D.20027;
  D.20067 = D.20028 + -1;
  D.20068 = (unsigned int) D.20067;
  mono_mb_emit_ldarg (mb, D.20068);
  <D.20066>:
  <D.20063>:
  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.18858>;
  <D.18857>:
  D.20069 = i + 1;
  D.20070 = (unsigned int) D.20069;
  mono_mb_emit_ldarg (mb, D.20070);
  i = i + 1;
  <D.18858>:
  D.20032 = sig->param_count;
  D.20071 = (int) D.20032;
  if (D.20071 > i) goto <D.18857>; else goto <D.18859>;
  <D.18859>:
  mono_mb_emit_managed_call (mb, method, 0B);
  D.20044 = sig->ret;
  D.20072 = mono_type_is_void (D.20044);
  if (D.20072 == 0) goto <D.20073>; else goto <D.20074>;
  <D.20073>:
  if (preserve_sig == 0) goto <D.20075>; else goto <D.20076>;
  <D.20075>:
  {
    struct MonoClass * rclass;

    D.20044 = sig->ret;
    rclass = mono_class_from_mono_type (D.20044);
    D.20077 = BIT_FIELD_REF <*rclass, 32, 160>;
    D.20078 = D.20077 & 8;
    if (D.20078 != 0) goto <D.20079>; else goto <D.20080>;
    <D.20079>:
    mono_mb_emit_op (mb, 129, rclass);
    goto <D.20081>;
    <D.20080>:
    D.20044 = sig->ret;
    D.20082 = mono_type_to_stind (D.20044);
    D.20083 = (unsigned char) D.20082;
    D.20084 = (int) D.20083;
    mono_mb_emit_byte (mb, D.20084);
    <D.20081>:
  }
  goto <D.20085>;
  <D.20076>:
  hr.79 = (unsigned int) hr;
  mono_mb_emit_stloc (mb, hr.79);
  <D.20085>:
  <D.20074>:
  D.20087 = mono_mb_emit_branch (mb, 221);
  pos_leave = (int) D.20087;
  main_clause->flags = 0;
  D.20088 = mono_mb_get_pos (mb);
  D.20089 = (unsigned int) D.20088;
  D.20090 = main_clause->try_offset;
  D.20091 = D.20089 - D.20090;
  main_clause->try_len = D.20091;
  D.20092 = mono_defaults.object_class;
  main_clause->data.catch_class = D.20092;
  D.20093 = mono_mb_get_label (mb);
  D.20094 = (unsigned int) D.20093;
  main_clause->handler_offset = D.20094;
  if (preserve_sig == 0) goto <D.20095>; else goto <D.20098>;
  <D.20098>:
  D.20044 = sig->ret;
  if (D.20044 != 0B) goto <D.20099>; else goto <D.20096>;
  <D.20099>:
  D.20044 = sig->ret;
  D.20100 = BIT_FIELD_REF <*D.20044, 32, 32>;
  D.20101 = D.20100 & 1073741824;
  if (D.20101 == 0) goto <D.20102>; else goto <D.20096>;
  <D.20102>:
  D.20044 = sig->ret;
  D.20103 = D.20044->type;
  D.20104 = D.20103 + 248;
  if (D.20104 <= 1) goto <D.20095>; else goto <D.20096>;
  <D.20095>:
  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.20097>;
  <D.20096>:
  mono_mb_emit_byte (mb, 38);
  <D.20097>:
  mono_mb_emit_branch (mb, 221);
  D.20105 = mono_mb_get_pos (mb);
  D.20106 = (unsigned int) D.20105;
  D.20107 = main_clause->handler_offset;
  D.20108 = D.20106 - D.20107;
  main_clause->handler_len = D.20108;
  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.20110>; else goto <D.20112>;
  <D.20112>:
  D.20044 = sig->ret;
  D.20113 = mono_type_is_void (D.20044);
  if (D.20113 == 0) goto <D.20110>; else goto <D.20111>;
  <D.20110>:
  hr.79 = (unsigned int) hr;
  mono_mb_emit_ldloc (mb, hr.79);
  <D.20111>:
  mono_mb_emit_byte (mb, 42);
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.20114>; else goto <D.20115>;
    <D.20114>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.20115>:
    D.20116 = ret != 0;
    D.20117 = (long int) D.20116;
    D.20118 = __builtin_expect (D.20117, 0);
    if (D.20118 != 0) goto <D.20119>; else goto <D.20120>;
    <D.20119>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2209, "ret == 0");
    <D.20120>:
  }
  D.20027 = sig_native->param_count;
  D.20028 = (int) D.20027;
  D.20121 = D.20028 + 16;
  res = mono_mb_create_method (mb, sig_native, D.20121);
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.20122>; else goto <D.20123>;
    <D.20122>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.20123>:
    D.20124 = ret != 0;
    D.20125 = (long int) D.20124;
    D.20126 = __builtin_expect (D.20125, 0);
    if (D.20126 != 0) goto <D.20127>; else goto <D.20128>;
    <D.20127>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2211, "ret == 0");
    <D.20128>:
  }
  mono_mb_free (mb);
  D.20027 = sig_native->param_count;
  i = (int) D.20027;
  goto <D.18864>;
  <D.18863>:
  i.78 = (unsigned int) i;
  D.20038 = i.78 * 4;
  D.20039 = mspecs + D.20038;
  D.20040 = *D.20039;
  if (D.20040 != 0B) goto <D.20129>; else goto <D.20130>;
  <D.20129>:
  i.78 = (unsigned int) i;
  D.20038 = i.78 * 4;
  D.20039 = mspecs + D.20038;
  D.20040 = *D.20039;
  mono_metadata_free_marshal_spec (D.20040);
  <D.20130>:
  i = i + -1;
  <D.18864>:
  if (i >= 0) goto <D.18863>; else goto <D.18865>;
  <D.18865>:
  monoeg_g_free (mspecs);
  D.20131 = res;
  return D.20131;
}


cominterop_method_signature (struct MonoMethod * method)
{
  struct MonoClass * D.20133;
  short unsigned int D.20134;
  int D.20135;
  short unsigned int D.20136;
  int D.20137;
  struct MonoType * D.20140;
  int D.20141;
  unsigned int param_count.81;
  unsigned int D.20145;
  unsigned int D.20146;
  unsigned int D.20147;
  unsigned int sigsize.82;
  int D.20149;
  struct MonoType * D.20150;
  struct MonoClass * D.20151;
  struct MonoType * D.20152;
  int D.20156;
  int D.20159;
  struct MonoType * D.20160;
  struct MonoType * D.20161;
  struct MonoClass * D.20162;
  struct MonoType * D.20163;
  short unsigned int D.20164;
  struct MonoMethodSignature * D.20165;
  struct MonoMethodSignature * res;
  struct MonoImage * image;
  struct MonoMethodSignature * sig;
  gboolean preserve_sig;
  int sigsize;
  int i;
  int param_count;

  D.20133 = method->klass;
  image = D.20133->image;
  sig = mono_method_signature (method);
  D.20134 = method->iflags;
  D.20135 = (int) D.20134;
  preserve_sig = D.20135 & 128;
  D.20136 = sig->param_count;
  D.20137 = (int) D.20136;
  param_count = D.20137 + 1;
  if (preserve_sig == 0) goto <D.20138>; else goto <D.20139>;
  <D.20138>:
  D.20140 = sig->ret;
  D.20141 = mono_type_is_void (D.20140);
  if (D.20141 == 0) goto <D.20142>; else goto <D.20143>;
  <D.20142>:
  param_count = param_count + 1;
  <D.20143>:
  <D.20139>:
  param_count.81 = (unsigned int) param_count;
  res = mono_metadata_signature_alloc (image, param_count.81);
  D.20136 = sig->param_count;
  D.20145 = (unsigned int) D.20136;
  D.20146 = D.20145 + 3;
  D.20147 = D.20146 * 4;
  sigsize = (int) D.20147;
  sigsize.82 = (unsigned int) sigsize;
  memcpy (res, sig, sigsize.82);
  D.20136 = sig->param_count;
  D.20137 = (int) D.20136;
  i = D.20137 + -1;
  goto <D.18384>;
  <D.18383>:
  D.20149 = i + 1;
  D.20150 = sig->params[i];
  res->params[D.20149] = D.20150;
  i = i + -1;
  <D.18384>:
  if (i >= 0) goto <D.18383>; else goto <D.18385>;
  <D.18385>:
  D.20151 = mono_defaults.int_class;
  D.20152 = &D.20151->byval_arg;
  res->params[0] = D.20152;
  if (preserve_sig != 0) goto <D.20153>; else goto <D.20154>;
  <D.20153>:
  D.20140 = sig->ret;
  res->ret = D.20140;
  goto <D.20155>;
  <D.20154>:
  D.20140 = sig->ret;
  D.20156 = mono_type_is_void (D.20140);
  if (D.20156 == 0) goto <D.20157>; else goto <D.20158>;
  <D.20157>:
  D.20159 = param_count + -1;
  D.20140 = sig->ret;
  D.20160 = mono_metadata_type_dup (image, D.20140);
  res->params[D.20159] = D.20160;
  D.20159 = param_count + -1;
  D.20161 = res->params[D.20159];
  D.20161->byref = 1;
  D.20159 = param_count + -1;
  D.20161 = res->params[D.20159];
  D.20161->attrs = 2;
  <D.20158>:
  D.20162 = mono_defaults.int32_class;
  D.20163 = &D.20162->byval_arg;
  res->ret = D.20163;
  <D.20155>:
  res->pinvoke = 0;
  res->hasthis = 0;
  D.20164 = (short unsigned int) param_count;
  res->param_count = D.20164;
  res->call_convention = 1;
  D.20165 = res;
  return D.20165;
}


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

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


cominterop_object_is_rcw (struct MonoObject * obj)
{
  gboolean D.20171;
  struct MonoVTable * D.20172;
  struct MonoClass * D.20173;
  struct MonoVTable * D.20178;
  int iftmp.83;
  struct MonoClass * D.20183;
  struct MonoClass * klass;
  struct MonoRealProxy * real_proxy;

  klass = 0B;
  real_proxy = 0B;
  if (obj == 0B) goto <D.20169>; else goto <D.20170>;
  <D.20169>:
  D.20171 = 0;
  return D.20171;
  <D.20170>:
  D.20172 = obj->vtable;
  klass = D.20172->klass;
  D.20173 = mono_defaults.transparent_proxy_class;
  if (D.20173 != klass) goto <D.20174>; else goto <D.20175>;
  <D.20174>:
  D.20171 = 0;
  return D.20171;
  <D.20175>:
  real_proxy = MEM[(struct MonoTransparentProxy *)obj].rp;
  if (real_proxy == 0B) goto <D.20176>; else goto <D.20177>;
  <D.20176>:
  D.20171 = 0;
  return D.20171;
  <D.20177>:
  D.20178 = MEM[(struct MonoObject *)real_proxy].vtable;
  klass = D.20178->klass;
  if (klass != 0B) goto <D.20182>; else goto <D.20180>;
  <D.20182>:
  D.20183 = mono_class_get_interop_proxy_class ();
  if (D.20183 == klass) goto <D.20184>; else goto <D.20180>;
  <D.20184>:
  iftmp.83 = 1;
  goto <D.20181>;
  <D.20180>:
  iftmp.83 = 0;
  <D.20181>:
  D.20171 = iftmp.83;
  return D.20171;
}


cominterop_get_function_pointer (void * itf, int slot)
{
  void * * D.20186;
  unsigned int slot.84;
  unsigned int D.20188;
  void * * D.20189;
  void * D.20190;
  void * func;

  D.20186 = MEM[(void * * *)itf];
  slot.84 = (unsigned int) slot;
  D.20188 = slot.84 * 4;
  D.20189 = D.20186 + D.20188;
  func = *D.20189;
  D.20190 = func;
  return D.20190;
}


cominterop_get_method_interface (struct MonoMethod * method)
{
  struct MonoClass * D.20192;
  unsigned int D.20193;
  unsigned int D.20194;
  unsigned char D.20197;
  int D.20202;
  _Bool D.20203;
  long int D.20204;
  long int D.20205;
  void * * D.20210;
  unsigned int i.85;
  unsigned int D.20212;
  void * * D.20213;
  struct MonoMethod * * D.20214;
  int D.20215;
  unsigned int D.20216;
  unsigned int D.20217;
  struct MonoMethod * * D.20218;
  struct MonoMethod * D.20219;
  unsigned int j.86;
  unsigned int D.20223;
  unsigned int i.87;
  unsigned int D.20226;
  _Bool D.20229;
  long int D.20230;
  long int D.20231;
  int iftmp.88;
  unsigned int D.20237;
  unsigned int D.20238;
  unsigned char D.20240;
  _Bool D.20243;
  long int D.20244;
  long int D.20245;
  struct MonoClass * D.20248;
  struct MonoError error;
  struct MonoClass * ic;

  try
    {
      ic = method->klass;
      D.20192 = method->klass;
      D.20193 = D.20192->flags;
      D.20194 = D.20193 & 32;
      if (D.20194 == 0) goto <D.20195>; else goto <D.20196>;
      <D.20195>:
      D.20192 = method->klass;
      D.20197 = D.20192->byval_arg.type;
      if (D.20197 != 19) goto <D.20198>; else goto <D.20199>;
      <D.20198>:
      D.20192 = method->klass;
      D.20197 = D.20192->byval_arg.type;
      if (D.20197 != 30) goto <D.20200>; else goto <D.20201>;
      <D.20200>:
      {
        struct GPtrArray * ifaces;

        D.20192 = method->klass;
        ifaces = mono_class_get_implemented_interfaces (D.20192, &error);
        D.20202 = mono_error_ok (&error);
        D.20203 = D.20202 == 0;
        D.20204 = (long int) D.20203;
        D.20205 = __builtin_expect (D.20204, 0);
        if (D.20205 != 0) goto <D.20206>; else goto <D.20207>;
        <D.20206>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 315, "mono_error_ok (&error)");
        <D.20207>:
        if (ifaces != 0B) goto <D.20208>; else goto <D.20209>;
        <D.20208>:
        {
          int i;

          D.20192 = method->klass;
          mono_class_setup_vtable (D.20192);
          i = 0;
          goto <D.18417>;
          <D.18416>:
          {
            int j;
            int offset;
            gboolean found;

            found = 0;
            D.20210 = ifaces->pdata;
            i.85 = (unsigned int) i;
            D.20212 = i.85 * 4;
            D.20213 = D.20210 + D.20212;
            ic = *D.20213;
            D.20192 = method->klass;
            offset = mono_class_interface_offset (D.20192, ic);
            j = 0;
            goto <D.18414>;
            <D.18413>:
            D.20192 = method->klass;
            D.20214 = D.20192->vtable;
            D.20215 = j + offset;
            D.20216 = (unsigned int) D.20215;
            D.20217 = D.20216 * 4;
            D.20218 = D.20214 + D.20217;
            D.20219 = *D.20218;
            if (D.20219 == method) goto <D.20220>; else goto <D.20221>;
            <D.20220>:
            found = 1;
            goto <D.18412>;
            <D.20221>:
            j = j + 1;
            <D.18414>:
            j.86 = (unsigned int) j;
            D.20223 = ic->method.count;
            if (j.86 < D.20223) goto <D.18413>; else goto <D.18412>;
            <D.18412>:
            if (found != 0) goto <D.18415>; else goto <D.20224>;
            <D.20224>:
            ic = 0B;
          }
          i = i + 1;
          <D.18417>:
          i.87 = (unsigned int) i;
          D.20226 = ifaces->len;
          if (i.87 < D.20226) goto <D.18416>; else goto <D.18415>;
          <D.18415>:
          monoeg_g_ptr_array_free (ifaces, 1);
        }
        <D.20209>:
      }
      <D.20201>:
      <D.20199>:
      <D.20196>:
      if (ic == 0B) goto <D.20227>; else goto <D.20228>;
      <D.20227>:
      D.20229 = ic == 0B;
      D.20230 = (long int) D.20229;
      D.20231 = __builtin_expect (D.20230, 0);
      if (D.20231 != 0) goto <D.20232>; else goto <D.20233>;
      <D.20232>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 339, "ic");
      <D.20233>:
      <D.20228>:
      D.20237 = ic->flags;
      D.20238 = D.20237 & 32;
      if (D.20238 == 0) goto <D.20239>; else goto <D.20235>;
      <D.20239>:
      D.20240 = ic->byval_arg.type;
      if (D.20240 != 19) goto <D.20241>; else goto <D.20235>;
      <D.20241>:
      D.20240 = ic->byval_arg.type;
      if (D.20240 != 30) goto <D.20242>; else goto <D.20235>;
      <D.20242>:
      iftmp.88 = 1;
      goto <D.20236>;
      <D.20235>:
      iftmp.88 = 0;
      <D.20236>:
      D.20243 = iftmp.88 != 0;
      D.20244 = (long int) D.20243;
      D.20245 = __builtin_expect (D.20244, 0);
      if (D.20245 != 0) goto <D.20246>; else goto <D.20247>;
      <D.20246>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 340, "MONO_CLASS_IS_INTERFACE (ic)");
      <D.20247>:
      D.20248 = ic;
      return D.20248;
    }
  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.20251;

  mono_mb_emit_ldarg (mb, 0);
  D.20251 = cominterop_get_com_slot_for_method (method);
  mono_mb_emit_icon (mb, D.20251);
  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.20252;
  unsigned int D.20253;
  unsigned int D.20254;
  unsigned char D.20257;
  struct MonoClass * D.20262;
  _Bool D.20263;
  long int D.20264;
  long int D.20265;
  struct MonoMethod * * D.20268;
  int D.20269;
  unsigned int D.20270;
  unsigned int D.20271;
  struct MonoMethod * * D.20272;
  struct MonoMethod * D.20273;
  struct MonoMethod * * D.20276;
  unsigned int i.89;
  unsigned int D.20278;
  struct MonoMethod * * D.20279;
  struct MonoMethod * D.20280;
  short int D.20281;
  unsigned int i.90;
  unsigned int D.20283;
  _Bool D.20284;
  long int D.20285;
  long int D.20286;
  int iftmp.91;
  _Bool D.20295;
  long int D.20296;
  long int D.20297;
  int D.20300;
  int D.20301;
  unsigned int D.20302;
  unsigned int D.20303;
  guint32 slot;
  struct MonoClass * ic;

  D.20252 = method->slot;
  slot = (guint32) D.20252;
  ic = method->klass;
  D.20253 = ic->flags;
  D.20254 = D.20253 & 32;
  if (D.20254 == 0) goto <D.20255>; else goto <D.20256>;
  <D.20255>:
  D.20257 = ic->byval_arg.type;
  if (D.20257 != 19) goto <D.20258>; else goto <D.20259>;
  <D.20258>:
  D.20257 = ic->byval_arg.type;
  if (D.20257 != 30) goto <D.20260>; else goto <D.20261>;
  <D.20260>:
  {
    int offset;
    int i;

    offset = 0;
    i = 0;
    ic = cominterop_get_method_interface (method);
    D.20262 = method->klass;
    offset = mono_class_interface_offset (D.20262, ic);
    D.20263 = offset < 0;
    D.20264 = (long int) D.20263;
    D.20265 = __builtin_expect (D.20264, 0);
    if (D.20265 != 0) goto <D.20266>; else goto <D.20267>;
    <D.20266>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 363, "offset >= 0");
    <D.20267>:
    i = 0;
    goto <D.18427>;
    <D.18426>:
    D.20262 = method->klass;
    D.20268 = D.20262->vtable;
    D.20269 = i + offset;
    D.20270 = (unsigned int) D.20269;
    D.20271 = D.20270 * 4;
    D.20272 = D.20268 + D.20271;
    D.20273 = *D.20272;
    if (D.20273 == method) goto <D.20274>; else goto <D.20275>;
    <D.20274>:
    D.20276 = ic->methods;
    i.89 = (unsigned int) i;
    D.20278 = i.89 * 4;
    D.20279 = D.20276 + D.20278;
    D.20280 = *D.20279;
    D.20281 = D.20280->slot;
    slot = (guint32) D.20281;
    goto <D.18425>;
    <D.20275>:
    i = i + 1;
    <D.18427>:
    i.90 = (unsigned int) i;
    D.20283 = ic->method.count;
    if (i.90 < D.20283) goto <D.18426>; else goto <D.18425>;
    <D.18425>:
  }
  <D.20261>:
  <D.20259>:
  <D.20256>:
  D.20284 = ic == 0B;
  D.20285 = (long int) D.20284;
  D.20286 = __builtin_expect (D.20285, 0);
  if (D.20286 != 0) goto <D.20287>; else goto <D.20288>;
  <D.20287>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 373, "ic");
  <D.20288>:
  D.20253 = ic->flags;
  D.20254 = D.20253 & 32;
  if (D.20254 == 0) goto <D.20292>; else goto <D.20290>;
  <D.20292>:
  D.20257 = ic->byval_arg.type;
  if (D.20257 != 19) goto <D.20293>; else goto <D.20290>;
  <D.20293>:
  D.20257 = ic->byval_arg.type;
  if (D.20257 != 30) goto <D.20294>; else goto <D.20290>;
  <D.20294>:
  iftmp.91 = 1;
  goto <D.20291>;
  <D.20290>:
  iftmp.91 = 0;
  <D.20291>:
  D.20295 = iftmp.91 != 0;
  D.20296 = (long int) D.20295;
  D.20297 = __builtin_expect (D.20296, 0);
  if (D.20297 != 0) goto <D.20298>; else goto <D.20299>;
  <D.20298>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 374, "MONO_CLASS_IS_INTERFACE (ic)");
  <D.20299>:
  D.20301 = cominterop_get_com_slot_begin (ic);
  D.20302 = (unsigned int) D.20301;
  D.20303 = D.20302 + slot;
  D.20300 = (int) D.20303;
  return D.20300;
}


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.20308;
  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.20317;
  struct MonoMethod * get_transparent_proxy.97;
  struct MonoType * D.20319;
  struct MonoClass * D.20320;
  struct MonoType * D.20321;
  _Bool D.20324;
  long int D.20325;
  long int D.20326;

  switch (conv) <default: <D.18519>, case 25: <D.18507>, case 26: <D.18509>, case 27: <D.18508>>
  <D.18507>:
  <D.18508>:
  <D.18509>:
  {
    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.20306>; else goto <D.20307>;
    <D.20306>:
    D.20308 = mono_defaults.corlib;
    com_interop_proxy_class.93 = mono_class_from_name (D.20308, "Mono.Interop", "ComInteropProxy");
    com_interop_proxy_class = com_interop_proxy_class.93;
    <D.20307>:
    com_interop_proxy_get_proxy.94 = com_interop_proxy_get_proxy;
    if (com_interop_proxy_get_proxy.94 == 0B) goto <D.20311>; else goto <D.20312>;
    <D.20311>:
    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.20312>:
    get_transparent_proxy.96 = get_transparent_proxy;
    if (get_transparent_proxy.96 == 0B) goto <D.20315>; else goto <D.20316>;
    <D.20315>:
    D.20317 = mono_defaults.real_proxy_class;
    get_transparent_proxy.97 = mono_class_get_method_from_name (D.20317, "GetTransparentProxy", 0);
    get_transparent_proxy = get_transparent_proxy.97;
    <D.20316>:
    com_interop_proxy_class.92 = com_interop_proxy_class;
    D.20319 = &com_interop_proxy_class.92->byval_arg;
    real_proxy = mono_mb_add_local (mb, D.20319);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 77);
    D.20320 = mono_class_get_com_object_class ();
    D.20321 = &D.20320->byval_arg;
    mono_mb_emit_ptr (mb, D.20321);
    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.20322>; else goto <D.20323>;
    <D.20322>:
    D.20324 = klass == 0B;
    D.20325 = (long int) D.20324;
    D.20326 = __builtin_expect (D.20325, 0);
    if (D.20326 != 0) goto <D.20327>; else goto <D.20328>;
    <D.20327>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 631, "klass");
    <D.20328>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20323>:
    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.20329>; else goto <D.20330>;
    <D.20329>:
    D.20324 = klass == 0B;
    D.20325 = (long int) D.20324;
    D.20326 = __builtin_expect (D.20325, 0);
    if (D.20326 != 0) goto <D.20331>; else goto <D.20332>;
    <D.20331>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 645, "klass");
    <D.20332>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20330>:
    mono_mb_emit_byte (mb, 81);
    mono_mb_patch_short_branch (mb, pos_end);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.18518>;
  }
  <D.18519>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 656);
  <D.18518>:
}


mono_cominterop_emit_object_to_ptr_conv (struct MonoMethodBuilder * mb, struct MonoType * type, MonoMarshalConv conv, struct MonoMarshalSpec * mspec)
{
  struct MonoClass * D.20335;
  struct MonoProperty * iunknown.98;
  struct MonoClass * D.20342;
  struct MonoProperty * iunknown.99;
  struct MonoMethod * D.20344;
  struct MonoProperty * idispatch.100;
  struct MonoClass * D.20351;
  struct MonoProperty * idispatch.101;
  struct MonoMethod * D.20353;
  struct MonoClass * D.20357;
  struct MonoClass * D.20361;
  struct MonoClass * D.20365;

  switch (conv) <default: <D.18535>, case 25: <D.18526>, case 26: <D.18527>, case 27: <D.18528>>
  <D.18526>:
  <D.18527>:
  <D.18528>:
  {
    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.20333>; else goto <D.20334>;
    <D.20333>:
    D.20335 = mono_type_get_class (type);
    mono_mb_emit_ptr (mb, D.20335);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_interface);
    goto <D.20336>;
    <D.20334>:
    if (conv == 27) goto <D.20337>; else goto <D.20338>;
    <D.20337>:
    {
      static struct MonoProperty * iunknown = 0B;

      iunknown.98 = iunknown;
      if (iunknown.98 == 0B) goto <D.20340>; else goto <D.20341>;
      <D.20340>:
      D.20342 = mono_class_get_com_object_class ();
      iunknown.99 = mono_class_get_property_from_name (D.20342, "IUnknown");
      iunknown = iunknown.99;
      <D.20341>:
      iunknown.98 = iunknown;
      D.20344 = iunknown.98->get;
      mono_mb_emit_managed_call (mb, D.20344, 0B);
    }
    goto <D.20345>;
    <D.20338>:
    if (conv == 26) goto <D.20346>; else goto <D.20347>;
    <D.20346>:
    {
      static struct MonoProperty * idispatch = 0B;

      idispatch.100 = idispatch;
      if (idispatch.100 == 0B) goto <D.20349>; else goto <D.20350>;
      <D.20349>:
      D.20351 = mono_class_get_com_object_class ();
      idispatch.101 = mono_class_get_property_from_name (D.20351, "IDispatch");
      idispatch = idispatch.101;
      <D.20350>:
      idispatch.100 = idispatch;
      D.20353 = idispatch.100->get;
      mono_mb_emit_managed_call (mb, D.20353, 0B);
    }
    goto <D.20354>;
    <D.20347>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 719);
    <D.20354>:
    <D.20345>:
    <D.20336>:
    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.20355>; else goto <D.20356>;
    <D.20355>:
    D.20357 = mono_type_get_class (type);
    mono_mb_emit_ptr (mb, D.20357);
    goto <D.20358>;
    <D.20356>:
    if (conv == 27) goto <D.20359>; else goto <D.20360>;
    <D.20359>:
    D.20361 = mono_class_get_iunknown_class ();
    mono_mb_emit_ptr (mb, D.20361);
    goto <D.20362>;
    <D.20360>:
    if (conv == 26) goto <D.20363>; else goto <D.20364>;
    <D.20363>:
    D.20365 = mono_class_get_idispatch_class ();
    mono_mb_emit_ptr (mb, D.20365);
    goto <D.20366>;
    <D.20364>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 739);
    <D.20366>:
    <D.20362>:
    <D.20358>:
    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.18534>;
  }
  <D.18535>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 748);
  <D.18534>:
}


mono_cominterop_get_native_wrapper (struct MonoMethod * method)
{
  _Bool D.20367;
  long int D.20368;
  long int D.20369;
  struct MonoClass * D.20372;
  struct MonoImage * D.20373;
  struct GHashTable * * D.20374;
  struct MonoMethod * D.20377;
  struct MonoMethod * * D.20378;
  struct MonoMethod * * D.20381;
  unsigned char D.20384;
  _Bool D.20385;
  long int D.20386;
  long int D.20387;
  const char * D.20390;
  unsigned int D.20391;
  unsigned int D.20392;
  int D.18572;
  int iftmp.102;
  int D.18571;
  const char[6] * D.20398;
  unsigned char D.20399;
  int D.20400;
  unsigned char D.20401;
  int D.20402;
  const unsigned char * D.20407;
  unsigned char D.20408;
  int D.20409;
  const unsigned char * D.20410;
  unsigned char D.20411;
  int D.20412;
  const unsigned char * D.20417;
  unsigned char D.20418;
  int D.20419;
  const unsigned char * D.20420;
  unsigned char D.20421;
  int D.20422;
  const unsigned char * D.20427;
  unsigned char D.20428;
  int D.20429;
  const unsigned char * D.20430;
  unsigned char D.20431;
  int D.20432;
  struct MonoMethod * ctor.103;
  struct MonoClass * D.20439;
  struct MonoMethod * ctor.104;
  short unsigned int D.20442;
  int D.20443;
  struct MonoClass * D.20444;
  struct MonoType * D.20445;
  struct MonoType * D.20446;
  int D.20447;
  unsigned int ptr_this.105;
  unsigned int i.106;
  short unsigned int D.20452;
  int D.20453;
  int D.20454;
  unsigned int retval.107;
  struct MonoMethod * ThrowExceptionForHR.108;
  struct MonoClass * D.20465;
  struct MonoMethod * ThrowExceptionForHR.109;
  int D.20467;
  short unsigned int D.20471;
  int D.20472;
  int D.20473;
  struct MonoMethod * res;
  struct GHashTable * cache;
  struct MonoMethodBuilder * mb;
  struct MonoMethodSignature * sig;
  struct MonoMethodSignature * csig;

  D.20367 = method == 0B;
  D.20368 = (long int) D.20367;
  D.20369 = __builtin_expect (D.20368, 0);
  if (D.20369 != 0) goto <D.20370>; else goto <D.20371>;
  <D.20370>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 869, "method");
  <D.20371>:
  D.20372 = method->klass;
  D.20373 = D.20372->image;
  D.20374 = &D.20373->cominterop_wrapper_cache;
  cache = mono_marshal_get_cache (D.20374, mono_aligned_addr_hash, 0B);
  res = mono_marshal_find_in_cache (cache, method);
  if (res != 0B) goto <D.20375>; else goto <D.20376>;
  <D.20375>:
  D.20377 = res;
  return D.20377;
  <D.20376>:
  D.20372 = method->klass;
  D.20378 = D.20372->vtable;
  if (D.20378 == 0B) goto <D.20379>; else goto <D.20380>;
  <D.20379>:
  D.20372 = method->klass;
  mono_class_setup_vtable (D.20372);
  <D.20380>:
  D.20372 = method->klass;
  D.20381 = D.20372->methods;
  if (D.20381 == 0B) goto <D.20382>; else goto <D.20383>;
  <D.20382>:
  D.20372 = method->klass;
  mono_class_setup_methods (D.20372);
  <D.20383>:
  D.20372 = method->klass;
  D.20384 = D.20372->exception_type;
  D.20385 = D.20384 != 0;
  D.20386 = (long int) D.20385;
  D.20387 = __builtin_expect (D.20386, 0);
  if (D.20387 != 0) goto <D.20388>; else goto <D.20389>;
  <D.20388>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 880, "!method->klass->exception_type");
  <D.20389>:
  sig = mono_method_signature (method);
  D.20372 = method->klass;
  D.20390 = method->name;
  mb = mono_mb_new (D.20372, D.20390, 27);
  D.20372 = method->klass;
  D.20391 = D.20372->flags;
  D.20392 = D.20391 & 4096;
  if (D.20392 != 0) goto <D.20393>; else goto <D.20394>;
  <D.20393>:
  {
    size_t __s1_len;
    size_t __s2_len;

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

      __s2 = method->name;
      D.20398 = ".ctor";
      D.20399 = MEM[(const unsigned char *)D.20398];
      D.20400 = (int) D.20399;
      D.20401 = *__s2;
      D.20402 = (int) D.20401;
      __result = D.20400 - D.20402;
      {
        if (__s2_len != 0) goto <D.20403>; else goto <D.20404>;
        <D.20403>:
        if (__result == 0) goto <D.20405>; else goto <D.20406>;
        <D.20405>:
        D.20407 = &MEM[(void *)".ctor" + 1B];
        D.20408 = *D.20407;
        D.20409 = (int) D.20408;
        D.20410 = __s2 + 1;
        D.20411 = *D.20410;
        D.20412 = (int) D.20411;
        __result = D.20409 - D.20412;
        if (__s2_len > 1) goto <D.20413>; else goto <D.20414>;
        <D.20413>:
        if (__result == 0) goto <D.20415>; else goto <D.20416>;
        <D.20415>:
        D.20417 = &MEM[(void *)".ctor" + 2B];
        D.20418 = *D.20417;
        D.20419 = (int) D.20418;
        D.20420 = __s2 + 2;
        D.20421 = *D.20420;
        D.20422 = (int) D.20421;
        __result = D.20419 - D.20422;
        if (__s2_len > 2) goto <D.20423>; else goto <D.20424>;
        <D.20423>:
        if (__result == 0) goto <D.20425>; else goto <D.20426>;
        <D.20425>:
        D.20427 = &MEM[(void *)".ctor" + 3B];
        D.20428 = *D.20427;
        D.20429 = (int) D.20428;
        D.20430 = __s2 + 3;
        D.20431 = *D.20430;
        D.20432 = (int) D.20431;
        __result = D.20429 - D.20432;
        <D.20426>:
        <D.20424>:
        <D.20416>:
        <D.20414>:
        <D.20406>:
        <D.20404>:
      }
      D.18571 = __result;
    }
    iftmp.102 = -D.18571;
    goto <D.20433>;
    <D.20397>:
    D.20390 = method->name;
    iftmp.102 = __builtin_strcmp (D.20390, ".ctor");
    <D.20433>:
    D.18572 = iftmp.102;
  }
  if (D.18572 == 0) goto <D.20434>; else goto <D.20435>;
  <D.20434>:
  {
    static struct MonoMethod * ctor = 0B;

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

    retval = 0;
    D.20442 = method->iflags;
    D.20443 = (int) D.20442;
    preserve_sig = D.20443 & 128;
    D.20444 = mono_defaults.int_class;
    D.20445 = &D.20444->byval_arg;
    ptr_this = mono_mb_add_local (mb, D.20445);
    D.20446 = sig->ret;
    D.20447 = mono_type_is_void (D.20446);
    if (D.20447 == 0) goto <D.20448>; else goto <D.20449>;
    <D.20448>:
    D.20446 = sig->ret;
    retval = mono_mb_add_local (mb, D.20446);
    <D.20449>:
    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.18581>;
    <D.18580>:
    i.106 = (unsigned int) i;
    mono_mb_emit_ldarg (mb, i.106);
    i = i + 1;
    <D.18581>:
    D.20452 = sig->param_count;
    D.20453 = (int) D.20452;
    if (D.20453 >= i) goto <D.18580>; else goto <D.18582>;
    <D.18582>:
    D.20446 = sig->ret;
    D.20454 = mono_type_is_void (D.20446);
    if (D.20454 == 0) goto <D.20455>; else goto <D.20456>;
    <D.20455>:
    if (preserve_sig == 0) goto <D.20457>; else goto <D.20458>;
    <D.20457>:
    retval.107 = (unsigned int) retval;
    mono_mb_emit_ldloc_addr (mb, retval.107);
    <D.20458>:
    <D.20456>:
    adjusted_method = cominterop_get_native_wrapper_adjusted (method);
    mono_mb_emit_managed_call (mb, adjusted_method, 0B);
    if (preserve_sig == 0) goto <D.20460>; else goto <D.20461>;
    <D.20460>:
    ThrowExceptionForHR.108 = ThrowExceptionForHR;
    if (ThrowExceptionForHR.108 == 0B) goto <D.20463>; else goto <D.20464>;
    <D.20463>:
    D.20465 = mono_defaults.marshal_class;
    ThrowExceptionForHR.109 = mono_class_get_method_from_name (D.20465, "ThrowExceptionForHR", 1);
    ThrowExceptionForHR = ThrowExceptionForHR.109;
    <D.20464>:
    ThrowExceptionForHR.108 = ThrowExceptionForHR;
    mono_mb_emit_managed_call (mb, ThrowExceptionForHR.108, 0B);
    D.20446 = sig->ret;
    D.20467 = mono_type_is_void (D.20446);
    if (D.20467 == 0) goto <D.20468>; else goto <D.20469>;
    <D.20468>:
    retval.107 = (unsigned int) retval;
    mono_mb_emit_ldloc (mb, retval.107);
    <D.20469>:
    <D.20461>:
    mono_mb_emit_byte (mb, 42);
  }
  <D.20441>:
  goto <D.20470>;
  <D.20394>:
  {
    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.20470>:
  D.20372 = method->klass;
  D.20373 = D.20372->image;
  csig = mono_metadata_signature_dup_full (D.20373, sig);
  csig->pinvoke = 0;
  D.20471 = csig->param_count;
  D.20472 = (int) D.20471;
  D.20473 = D.20472 + 16;
  res = mono_mb_create_and_cache (cache, method, mb, csig, D.20473);
  mono_mb_free (mb);
  D.20377 = res;
  return D.20377;
}


cominterop_get_native_wrapper_adjusted (struct MonoMethod * method)
{
  struct MonoClass * D.20475;
  const char * D.20476;
  short unsigned int D.20477;
  int D.20478;
  int D.20479;
  unsigned int D.20480;
  unsigned int D.20481;
  short unsigned int D.20482;
  sizetype i.110;
  sizetype D.20484;
  sizetype D.20485;
  struct MonoMarshalSpec * * D.20486;
  unsigned int i.111;
  unsigned int D.20488;
  struct MonoMarshalSpec * * D.20489;
  struct MonoMarshalSpec * D.20490;
  struct MonoMarshalSpec * * D.20491;
  short unsigned int D.20492;
  int D.20493;
  int D.20494;
  struct MonoType * D.20497;
  int D.20498;
  unsigned int D.20501;
  unsigned int D.20502;
  struct MonoMarshalSpec * * D.20503;
  struct MonoMarshalSpec * D.20504;
  unsigned int mspec_index.112;
  unsigned int D.20506;
  struct MonoMarshalSpec * * D.20507;
  struct MonoMarshalSpec * D.20508;
  struct MonoType * D.20511;
  unsigned char D.20512;
  void * D.20515;
  void * D.20519;
  void * D.20523;
  void * D.20527;
  int D.20530;
  unsigned char D.20535;
  void * D.20538;
  void * D.20542;
  void * D.20546;
  void * D.20550;
  struct MonoImage * D.20551;
  void * D.20552;
  int D.20553;
  struct MonoMethod * D.20556;
  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.20475 = method->klass;
  D.20476 = method->name;
  mb_native = mono_mb_new (D.20475, D.20476, 6);
  sig_native = cominterop_method_signature (method);
  D.20477 = sig_native->param_count;
  D.20478 = (int) D.20477;
  D.20479 = D.20478 + 1;
  D.20480 = (unsigned int) D.20479;
  D.20481 = D.20480 * 4;
  mspecs = monoeg_malloc (D.20481);
  D.20477 = sig_native->param_count;
  D.20478 = (int) D.20477;
  D.20479 = D.20478 + 1;
  D.20480 = (unsigned int) D.20479;
  D.20481 = D.20480 * 4;
  memset (mspecs, 0, D.20481);
  mono_method_get_marshal_info (method, mspecs);
  D.20482 = sig->param_count;
  i = (int) D.20482;
  goto <D.18547>;
  <D.18546>:
  i.110 = (sizetype) i;
  D.20484 = i.110 + 1;
  D.20485 = D.20484 * 4;
  D.20486 = mspecs + D.20485;
  i.111 = (unsigned int) i;
  D.20488 = i.111 * 4;
  D.20489 = mspecs + D.20488;
  D.20490 = *D.20489;
  *D.20486 = D.20490;
  i = i + -1;
  <D.18547>:
  if (i > 0) goto <D.18546>; else goto <D.18548>;
  <D.18548>:
  D.20491 = mspecs + 4;
  *D.20491 = 0B;
  D.20492 = method->iflags;
  D.20493 = (int) D.20492;
  D.20494 = D.20493 & 128;
  if (D.20494 == 0) goto <D.20495>; else goto <D.20496>;
  <D.20495>:
  D.20497 = sig->ret;
  D.20498 = mono_type_is_void (D.20497);
  if (D.20498 == 0) goto <D.20499>; else goto <D.20500>;
  <D.20499>:
  D.20477 = sig_native->param_count;
  D.20501 = (unsigned int) D.20477;
  D.20502 = D.20501 * 4;
  D.20503 = mspecs + D.20502;
  D.20504 = *mspecs;
  *D.20503 = D.20504;
  <D.20500>:
  *mspecs = 0B;
  <D.20496>:
  i = 1;
  goto <D.18551>;
  <D.18550>:
  {
    int mspec_index;

    mspec_index = i + 1;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20508 = *D.20507;
    if (D.20508 == 0B) goto <D.20509>; else goto <D.20510>;
    <D.20509>:
    D.20511 = sig_native->params[i];
    D.20512 = D.20511->type;
    if (D.20512 == 28) goto <D.20513>; else goto <D.20514>;
    <D.20513>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20515 = monoeg_malloc0 (16);
    *D.20507 = D.20515;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20508 = *D.20507;
    D.20508->native = 27;
    goto <D.20516>;
    <D.20514>:
    D.20511 = sig_native->params[i];
    D.20512 = D.20511->type;
    if (D.20512 == 14) goto <D.20517>; else goto <D.20518>;
    <D.20517>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20519 = monoeg_malloc0 (16);
    *D.20507 = D.20519;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20508 = *D.20507;
    D.20508->native = 19;
    goto <D.20520>;
    <D.20518>:
    D.20511 = sig_native->params[i];
    D.20512 = D.20511->type;
    if (D.20512 == 18) goto <D.20521>; else goto <D.20522>;
    <D.20521>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20523 = monoeg_malloc0 (16);
    *D.20507 = D.20523;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20508 = *D.20507;
    D.20508->native = 28;
    goto <D.20524>;
    <D.20522>:
    D.20511 = sig_native->params[i];
    D.20512 = D.20511->type;
    if (D.20512 == 2) goto <D.20525>; else goto <D.20526>;
    <D.20525>:
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20527 = monoeg_malloc0 (16);
    *D.20507 = D.20527;
    mspec_index.112 = (unsigned int) mspec_index;
    D.20506 = mspec_index.112 * 4;
    D.20507 = mspecs + D.20506;
    D.20508 = *D.20507;
    D.20508->native = 37;
    <D.20526>:
    <D.20524>:
    <D.20520>:
    <D.20516>:
    <D.20510>:
  }
  i = i + 1;
  <D.18551>:
  D.20477 = sig_native->param_count;
  D.20478 = (int) D.20477;
  if (D.20478 > i) goto <D.18550>; else goto <D.18552>;
  <D.18552>:
  D.20492 = method->iflags;
  D.20493 = (int) D.20492;
  D.20494 = D.20493 & 128;
  if (D.20494 != 0) goto <D.20528>; else goto <D.20529>;
  <D.20528>:
  D.20497 = sig->ret;
  D.20530 = mono_type_is_void (D.20497);
  if (D.20530 == 0) goto <D.20531>; else goto <D.20532>;
  <D.20531>:
  D.20504 = *mspecs;
  if (D.20504 == 0B) goto <D.20533>; else goto <D.20534>;
  <D.20533>:
  D.20497 = sig->ret;
  D.20535 = D.20497->type;
  if (D.20535 == 28) goto <D.20536>; else goto <D.20537>;
  <D.20536>:
  D.20538 = monoeg_malloc0 (16);
  *mspecs = D.20538;
  D.20504 = *mspecs;
  D.20504->native = 27;
  goto <D.20539>;
  <D.20537>:
  D.20497 = sig->ret;
  D.20535 = D.20497->type;
  if (D.20535 == 14) goto <D.20540>; else goto <D.20541>;
  <D.20540>:
  D.20542 = monoeg_malloc0 (16);
  *mspecs = D.20542;
  D.20504 = *mspecs;
  D.20504->native = 19;
  goto <D.20543>;
  <D.20541>:
  D.20497 = sig->ret;
  D.20535 = D.20497->type;
  if (D.20535 == 18) goto <D.20544>; else goto <D.20545>;
  <D.20544>:
  D.20546 = monoeg_malloc0 (16);
  *mspecs = D.20546;
  D.20504 = *mspecs;
  D.20504->native = 28;
  goto <D.20547>;
  <D.20545>:
  D.20497 = sig->ret;
  D.20535 = D.20497->type;
  if (D.20535 == 2) goto <D.20548>; else goto <D.20549>;
  <D.20548>:
  D.20550 = monoeg_malloc0 (16);
  *mspecs = D.20550;
  D.20504 = *mspecs;
  D.20504->native = 37;
  <D.20549>:
  <D.20547>:
  <D.20543>:
  <D.20539>:
  <D.20534>:
  <D.20532>:
  <D.20529>:
  D.20475 = method->klass;
  D.20551 = D.20475->image;
  D.20552 = piinfo->addr;
  mono_marshal_emit_native_wrapper (D.20551, mb_native, sig_native, piinfo, mspecs, D.20552, 0, 1, 0);
  D.20477 = sig_native->param_count;
  D.20478 = (int) D.20477;
  D.20553 = D.20478 + 16;
  res = mono_mb_create_method (mb_native, sig_native, D.20553);
  mono_mb_free (mb_native);
  D.20477 = sig_native->param_count;
  i = (int) D.20477;
  goto <D.18554>;
  <D.18553>:
  i.111 = (unsigned int) i;
  D.20488 = i.111 * 4;
  D.20489 = mspecs + D.20488;
  D.20490 = *D.20489;
  if (D.20490 != 0B) goto <D.20554>; else goto <D.20555>;
  <D.20554>:
  i.111 = (unsigned int) i;
  D.20488 = i.111 * 4;
  D.20489 = mspecs + D.20488;
  D.20490 = *D.20489;
  mono_metadata_free_marshal_spec (D.20490);
  <D.20555>:
  i = i + -1;
  <D.18554>:
  if (i >= 0) goto <D.18553>; else goto <D.18555>;
  <D.18555>:
  monoeg_g_free (mspecs);
  D.20556 = res;
  return D.20556;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.20560;
  int D.20565;
  void * D.20567;
  unsigned int D.20568;

  D.20560 = __builtin_constant_p (__len);
  if (D.20560 != 0) goto <D.20561>; else goto <D.20562>;
  <D.20561>:
  if (__len == 0) goto <D.20563>; else goto <D.20564>;
  <D.20563>:
  D.20565 = __builtin_constant_p (__ch);
  if (D.20565 == 0) goto <D.20558>; else goto <D.20566>;
  <D.20566>:
  if (__ch != 0) goto <D.20558>; else goto <D.20559>;
  <D.20558>:
  __warn_memset_zero_len ();
  D.20567 = __dest;
  return D.20567;
  <D.20559>:
  <D.20564>:
  <D.20562>:
  D.20568 = __builtin_object_size (__dest, 0);
  D.20567 = __builtin___memset_chk (__dest, __ch, __len, D.20568);
  return D.20567;
}


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

  if (str != 0B) goto <D.20570>; else goto <D.20571>;
  <D.20570>:
  D.20572 = __strdup (str);
  return D.20572;
  <D.20571>:
  D.20572 = 0B;
  return D.20572;
}


mono_cominterop_get_invoke (struct MonoMethod * method)
{
  struct MonoClass * D.20574;
  struct MonoImage * D.20575;
  struct GHashTable * * D.20576;
  _Bool D.20577;
  long int D.20578;
  long int D.20579;
  struct MonoMethod * D.20584;
  unsigned int D.20585;
  unsigned int D.20586;
  const char * D.20589;
  struct MonoClass * D.20590;
  struct MonoType * D.20591;
  unsigned int i.113;
  short unsigned int D.20593;
  int D.20594;
  short unsigned int D.20595;
  int D.20596;
  int D.20597;
  short unsigned int D.20601;
  int D.20602;
  int D.20603;
  int D.18605;
  int iftmp.114;
  int D.18604;
  const char[6] * D.20610;
  unsigned char D.20611;
  int D.20612;
  unsigned char D.20613;
  int D.20614;
  const unsigned char * D.20619;
  unsigned char D.20620;
  int D.20621;
  const unsigned char * D.20622;
  unsigned char D.20623;
  int D.20624;
  const unsigned char * D.20629;
  unsigned char D.20630;
  int D.20631;
  const unsigned char * D.20632;
  unsigned char D.20633;
  int D.20634;
  const unsigned char * D.20639;
  unsigned char D.20640;
  int D.20641;
  const unsigned char * D.20642;
  unsigned char D.20643;
  int D.20644;
  struct MonoClass * com_interop_proxy_class.115;
  struct MonoImage * D.20651;
  struct MonoClass * com_interop_proxy_class.116;
  struct MonoMethod * cache_proxy.117;
  struct MonoMethod * cache_proxy.118;
  int D.20657;
  struct MonoMethodSignature * sig;
  struct MonoMethodBuilder * mb;
  struct MonoMethod * res;
  int i;
  int temp_obj;
  struct GHashTable * cache;

  D.20574 = method->klass;
  D.20575 = D.20574->image;
  D.20576 = &D.20575->cominterop_invoke_cache;
  cache = mono_marshal_get_cache (D.20576, mono_aligned_addr_hash, 0B);
  D.20577 = method == 0B;
  D.20578 = (long int) D.20577;
  D.20579 = __builtin_expect (D.20578, 0);
  if (D.20579 != 0) goto <D.20580>; else goto <D.20581>;
  <D.20580>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 982, "method");
  <D.20581>:
  res = mono_marshal_find_in_cache (cache, method);
  if (res != 0B) goto <D.20582>; else goto <D.20583>;
  <D.20582>:
  D.20584 = res;
  return D.20584;
  <D.20583>:
  sig = mono_signature_no_pinvoke (method);
  D.20585 = BIT_FIELD_REF <*sig, 32, 64>;
  D.20586 = D.20585 & 4194304;
  if (D.20586 == 0) goto <D.20587>; else goto <D.20588>;
  <D.20587>:
  D.20584 = method;
  return D.20584;
  <D.20588>:
  D.20574 = method->klass;
  D.20589 = method->name;
  mb = mono_mb_new (D.20574, D.20589, 26);
  D.20590 = mono_defaults.object_class;
  D.20591 = &D.20590->byval_arg;
  temp_obj = mono_mb_add_local (mb, D.20591);
  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.18594>;
  <D.18593>:
  i.113 = (unsigned int) i;
  mono_mb_emit_ldarg (mb, i.113);
  i = i + 1;
  <D.18594>:
  D.20593 = sig->param_count;
  D.20594 = (int) D.20593;
  if (D.20594 >= i) goto <D.18593>; else goto <D.18595>;
  <D.18595>:
  D.20595 = method->iflags;
  D.20596 = (int) D.20595;
  D.20597 = D.20596 & 4096;
  if (D.20597 != 0) goto <D.20598>; else goto <D.20599>;
  <D.20598>:
  {
    struct MonoMethod * native_wrapper;

    native_wrapper = mono_cominterop_get_native_wrapper (method);
    mono_mb_emit_managed_call (mb, native_wrapper, 0B);
  }
  goto <D.20600>;
  <D.20599>:
  D.20601 = method->flags;
  D.20602 = (int) D.20601;
  D.20603 = D.20602 & 64;
  if (D.20603 != 0) goto <D.20604>; else goto <D.20605>;
  <D.20604>:
  mono_mb_emit_op (mb, 111, method);
  goto <D.20606>;
  <D.20605>:
  mono_mb_emit_op (mb, 40, method);
  <D.20606>:
  <D.20600>:
  {
    size_t __s1_len;
    size_t __s2_len;

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

      __s2 = method->name;
      D.20610 = ".ctor";
      D.20611 = MEM[(const unsigned char *)D.20610];
      D.20612 = (int) D.20611;
      D.20613 = *__s2;
      D.20614 = (int) D.20613;
      __result = D.20612 - D.20614;
      {
        if (__s2_len != 0) goto <D.20615>; else goto <D.20616>;
        <D.20615>:
        if (__result == 0) goto <D.20617>; else goto <D.20618>;
        <D.20617>:
        D.20619 = &MEM[(void *)".ctor" + 1B];
        D.20620 = *D.20619;
        D.20621 = (int) D.20620;
        D.20622 = __s2 + 1;
        D.20623 = *D.20622;
        D.20624 = (int) D.20623;
        __result = D.20621 - D.20624;
        if (__s2_len > 1) goto <D.20625>; else goto <D.20626>;
        <D.20625>:
        if (__result == 0) goto <D.20627>; else goto <D.20628>;
        <D.20627>:
        D.20629 = &MEM[(void *)".ctor" + 2B];
        D.20630 = *D.20629;
        D.20631 = (int) D.20630;
        D.20632 = __s2 + 2;
        D.20633 = *D.20632;
        D.20634 = (int) D.20633;
        __result = D.20631 - D.20634;
        if (__s2_len > 2) goto <D.20635>; else goto <D.20636>;
        <D.20635>:
        if (__result == 0) goto <D.20637>; else goto <D.20638>;
        <D.20637>:
        D.20639 = &MEM[(void *)".ctor" + 3B];
        D.20640 = *D.20639;
        D.20641 = (int) D.20640;
        D.20642 = __s2 + 3;
        D.20643 = *D.20642;
        D.20644 = (int) D.20643;
        __result = D.20641 - D.20644;
        <D.20638>:
        <D.20636>:
        <D.20628>:
        <D.20626>:
        <D.20618>:
        <D.20616>:
      }
      D.18604 = __result;
    }
    iftmp.114 = -D.18604;
    goto <D.20645>;
    <D.20609>:
    D.20589 = method->name;
    iftmp.114 = __builtin_strcmp (D.20589, ".ctor");
    <D.20645>:
    D.18605 = iftmp.114;
  }
  if (D.18605 == 0) goto <D.20646>; else goto <D.20647>;
  <D.20646>:
  {
    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.20649>; else goto <D.20650>;
    <D.20649>:
    D.20651 = mono_defaults.corlib;
    com_interop_proxy_class.116 = mono_class_from_name (D.20651, "Mono.Interop", "ComInteropProxy");
    com_interop_proxy_class = com_interop_proxy_class.116;
    <D.20650>:
    cache_proxy.117 = cache_proxy;
    if (cache_proxy.117 == 0B) goto <D.20654>; else goto <D.20655>;
    <D.20654>:
    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.20655>:
    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.20647>:
  mono_marshal_emit_thread_interrupt_checkpoint (mb);
  mono_mb_emit_byte (mb, 42);
  D.20593 = sig->param_count;
  D.20594 = (int) D.20593;
  D.20657 = D.20594 + 16;
  res = mono_mb_create_and_cache (cache, method, mb, sig, D.20657);
  mono_mb_free (mb);
  D.20584 = res;
  return D.20584;
}


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.20662;
  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.20680;
  struct MonoType * D.20681;
  unsigned int conv_arg.129;
  unsigned int D.20683;
  unsigned int D.20684;
  short unsigned int D.20687;
  int D.20688;
  int D.20689;
  unsigned int argnum.130;
  struct MonoClass * D.20699;
  <unnamed type> D.20701;
  struct MonoType * D.20716;
  unsigned int ccw_obj.131;
  unsigned int ret_ptr.132;
  unsigned int ccw_obj.133;
  struct MonoType * D.20739;
  unsigned int ccw_obj.134;
  struct MonoMethod * AddRef.135;
  struct MonoMethod * AddRef.136;
  struct MonoMethod * AddRef.137;
  unsigned int ccw_obj.138;
  int D.20796;
  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.20660>; else goto <D.20661>;
  <D.20660>:
  D.20662 = mono_defaults.marshal_class;
  get_object_for_iunknown.120 = mono_class_get_method_from_name (D.20662, "GetObjectForIUnknown", 1);
  get_object_for_iunknown = get_object_for_iunknown.120;
  <D.20661>:
  get_iunknown_for_object_internal.121 = get_iunknown_for_object_internal;
  if (get_iunknown_for_object_internal.121 == 0B) goto <D.20665>; else goto <D.20666>;
  <D.20665>:
  D.20662 = mono_defaults.marshal_class;
  get_iunknown_for_object_internal.122 = mono_class_get_method_from_name (D.20662, "GetIUnknownForObjectInternal", 1);
  get_iunknown_for_object_internal = get_iunknown_for_object_internal.122;
  <D.20666>:
  get_idispatch_for_object_internal.123 = get_idispatch_for_object_internal;
  if (get_idispatch_for_object_internal.123 == 0B) goto <D.20669>; else goto <D.20670>;
  <D.20669>:
  D.20662 = mono_defaults.marshal_class;
  get_idispatch_for_object_internal.124 = mono_class_get_method_from_name (D.20662, "GetIDispatchForObjectInternal", 1);
  get_idispatch_for_object_internal = get_idispatch_for_object_internal.124;
  <D.20670>:
  get_com_interface_for_object_internal.125 = get_com_interface_for_object_internal;
  if (get_com_interface_for_object_internal.125 == 0B) goto <D.20673>; else goto <D.20674>;
  <D.20673>:
  D.20662 = mono_defaults.marshal_class;
  get_com_interface_for_object_internal.126 = mono_class_get_method_from_name (D.20662, "GetComInterfaceForObjectInternal", 2);
  get_com_interface_for_object_internal = get_com_interface_for_object_internal.126;
  <D.20674>:
  marshal_release.127 = marshal_release;
  if (marshal_release.127 == 0B) goto <D.20677>; else goto <D.20678>;
  <D.20677>:
  D.20662 = mono_defaults.marshal_class;
  marshal_release.128 = mono_class_get_method_from_name (D.20662, "Release", 1);
  marshal_release = marshal_release.128;
  <D.20678>:
  switch (action) <default: <D.18653>, case 0: <D.18628>, case 1: <D.18636>, case 2: <D.18631>, case 3: <D.18637>, case 4: <D.18643>, case 5: <D.18648>, case 6: <D.18650>>
  <D.18628>:
  {
    guint32 pos_null;

    pos_null = 0;
    D.20680 = mono_defaults.int_class;
    D.20681 = &D.20680->byval_arg;
    *conv_arg_type = D.20681;
    D.20680 = mono_defaults.int_class;
    D.20681 = &D.20680->byval_arg;
    conv_arg = mono_mb_add_local (mb, D.20681);
    mono_mb_emit_ptr (mb, 0B);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    D.20683 = BIT_FIELD_REF <*t, 32, 32>;
    D.20684 = D.20683 & 1073741824;
    if (D.20684 != 0) goto <D.20685>; else goto <D.20686>;
    <D.20685>:
    D.20687 = t->attrs;
    D.20688 = (int) D.20687;
    D.20689 = D.20688 & 2;
    if (D.20689 != 0) goto <D.18630>; else goto <D.20690>;
    <D.20690>:
    <D.20686>:
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.20683 = BIT_FIELD_REF <*t, 32, 32>;
    D.20684 = D.20683 & 1073741824;
    if (D.20684 != 0) goto <D.20692>; else goto <D.20693>;
    <D.20692>:
    mono_mb_emit_byte (mb, 80);
    <D.20693>:
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.20683 = BIT_FIELD_REF <*t, 32, 32>;
    D.20684 = D.20683 & 1073741824;
    if (D.20684 != 0) goto <D.20694>; else goto <D.20695>;
    <D.20694>:
    mono_mb_emit_byte (mb, 80);
    <D.20695>:
    if (klass != 0B) goto <D.20698>; else goto <D.20696>;
    <D.20698>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20700>; else goto <D.20696>;
    <D.20700>:
    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.20697>;
    <D.20696>:
    D.20701 = spec->native;
    if (D.20701 == 25) goto <D.20702>; else goto <D.20703>;
    <D.20702>:
    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.20704>;
    <D.20703>:
    D.20701 = spec->native;
    if (D.20701 == 26) goto <D.20705>; else goto <D.20706>;
    <D.20705>:
    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.20707>;
    <D.20706>:
    if (klass == 0B) goto <D.20710>; else goto <D.20708>;
    <D.20710>:
    D.20701 = spec->native;
    if (D.20701 == 28) goto <D.20711>; else goto <D.20708>;
    <D.20711>:
    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.20709>;
    <D.20708>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1128);
    <D.20709>:
    <D.20707>:
    <D.20704>:
    <D.20697>:
    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.18630>;
  }
  <D.18631>:
  D.20683 = BIT_FIELD_REF <*t, 32, 32>;
  D.20684 = D.20683 & 1073741824;
  if (D.20684 != 0) goto <D.20712>; else goto <D.20713>;
  <D.20712>:
  D.20687 = t->attrs;
  D.20688 = (int) D.20687;
  D.20689 = D.20688 & 2;
  if (D.20689 != 0) goto <D.20714>; else goto <D.20715>;
  <D.20714>:
  {
    int ccw_obj;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.20699 = mono_defaults.object_class;
    D.20716 = &D.20699->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.20716);
    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.20718>; else goto <D.20719>;
    <D.20718>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20720>; else goto <D.20721>;
    <D.20720>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20721>:
    <D.20719>:
    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.20722>; else goto <D.20723>;
    <D.20722>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20724>; else goto <D.20725>;
    <D.20724>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20725>:
    <D.20723>:
    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.20715>:
  <D.20713>:
  goto <D.18630>;
  <D.18636>:
  D.20683 = BIT_FIELD_REF <*t, 32, 32>;
  D.20684 = D.20683 & 1073741824;
  if (D.20684 != 0) goto <D.20726>; else goto <D.20727>;
  <D.20726>:
  conv_arg.129 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc_addr (mb, conv_arg.129);
  goto <D.20728>;
  <D.20727>:
  conv_arg.129 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc (mb, conv_arg.129);
  <D.20728>:
  goto <D.18630>;
  <D.18637>:
  {
    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.20699 = mono_defaults.object_class;
    D.20716 = &D.20699->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.20716);
    D.20680 = mono_defaults.int_class;
    D.20681 = &D.20680->byval_arg;
    ret_ptr = mono_mb_add_local (mb, D.20681);
    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.20731>; else goto <D.20732>;
    <D.20731>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20733>; else goto <D.20734>;
    <D.20733>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20734>:
    <D.20732>:
    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.20735>; else goto <D.20736>;
    <D.20735>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20737>; else goto <D.20738>;
    <D.20737>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20738>:
    <D.20736>:
    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.18630>;
  }
  <D.18643>:
  {
    int ccw_obj;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.20699 = mono_defaults.object_class;
    D.20716 = &D.20699->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.20716);
    klass = mono_class_from_mono_type (t);
    D.20739 = &klass->byval_arg;
    conv_arg = mono_mb_add_local (mb, D.20739);
    D.20680 = mono_defaults.int_class;
    D.20681 = &D.20680->byval_arg;
    *conv_arg_type = D.20681;
    mono_mb_emit_byte (mb, 20);
    conv_arg.129 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.129);
    D.20687 = t->attrs;
    D.20688 = (int) D.20687;
    D.20689 = D.20688 & 2;
    if (D.20689 != 0) goto <D.18630>; else goto <D.20740>;
    <D.20740>:
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.20683 = BIT_FIELD_REF <*t, 32, 32>;
    D.20684 = D.20683 & 1073741824;
    if (D.20684 != 0) goto <D.20741>; else goto <D.20742>;
    <D.20741>:
    mono_mb_emit_byte (mb, 80);
    <D.20742>:
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.130 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.130);
    D.20683 = BIT_FIELD_REF <*t, 32, 32>;
    D.20684 = D.20683 & 1073741824;
    if (D.20684 != 0) goto <D.20743>; else goto <D.20744>;
    <D.20743>:
    mono_mb_emit_byte (mb, 80);
    <D.20744>:
    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.20683 = BIT_FIELD_REF <*t, 32, 32>;
    D.20684 = D.20683 & 1073741824;
    if (D.20684 != 0) goto <D.20746>; else goto <D.20747>;
    <D.20746>:
    mono_mb_emit_byte (mb, 80);
    <D.20747>:
    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.20748>; else goto <D.20749>;
    <D.20748>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20750>; else goto <D.20751>;
    <D.20750>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20751>:
    <D.20749>:
    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.20752>; else goto <D.20753>;
    <D.20752>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20754>; else goto <D.20755>;
    <D.20754>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20755>:
    <D.20753>:
    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.18630>;
  }
  <D.18648>:
  D.20683 = BIT_FIELD_REF <*t, 32, 32>;
  D.20684 = D.20683 & 1073741824;
  if (D.20684 != 0) goto <D.20756>; else goto <D.20757>;
  <D.20756>:
  D.20687 = t->attrs;
  D.20688 = (int) D.20687;
  D.20689 = D.20688 & 2;
  if (D.20689 != 0) goto <D.20758>; else goto <D.20759>;
  <D.20758>:
  {
    guint32 pos_null;

    pos_null = 0;
    AddRef.135 = AddRef;
    if (AddRef.135 == 0B) goto <D.20761>; else goto <D.20762>;
    <D.20761>:
    D.20662 = mono_defaults.marshal_class;
    AddRef.136 = mono_class_get_method_from_name (D.20662, "AddRef", 1);
    AddRef = AddRef.136;
    <D.20762>:
    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.20766>; else goto <D.20764>;
    <D.20766>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20767>; else goto <D.20764>;
    <D.20767>:
    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.20765>;
    <D.20764>:
    D.20701 = spec->native;
    if (D.20701 == 25) goto <D.20768>; else goto <D.20769>;
    <D.20768>:
    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.20770>;
    <D.20769>:
    D.20701 = spec->native;
    if (D.20701 == 26) goto <D.20771>; else goto <D.20772>;
    <D.20771>:
    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.20773>;
    <D.20772>:
    if (klass == 0B) goto <D.20776>; else goto <D.20774>;
    <D.20776>:
    D.20701 = spec->native;
    if (D.20701 == 28) goto <D.20777>; else goto <D.20774>;
    <D.20777>:
    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.20775>;
    <D.20774>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1321);
    <D.20775>:
    <D.20773>:
    <D.20770>:
    <D.20765>:
    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.20759>:
  <D.20757>:
  goto <D.18630>;
  <D.18650>:
  {
    guint32 pos_null;
    int ccw_obj;

    pos_null = 0;
    D.20699 = mono_defaults.object_class;
    D.20716 = &D.20699->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.20716);
    AddRef.135 = AddRef;
    if (AddRef.135 == 0B) goto <D.20778>; else goto <D.20779>;
    <D.20778>:
    D.20662 = mono_defaults.marshal_class;
    AddRef.137 = mono_class_get_method_from_name (D.20662, "AddRef", 1);
    AddRef = AddRef.137;
    <D.20779>:
    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.20784>; else goto <D.20782>;
    <D.20784>:
    D.20699 = mono_defaults.object_class;
    if (D.20699 != klass) goto <D.20785>; else goto <D.20782>;
    <D.20785>:
    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.20783>;
    <D.20782>:
    D.20701 = spec->native;
    if (D.20701 == 25) goto <D.20786>; else goto <D.20787>;
    <D.20786>:
    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.20788>;
    <D.20787>:
    D.20701 = spec->native;
    if (D.20701 == 26) goto <D.20789>; else goto <D.20790>;
    <D.20789>:
    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.20791>;
    <D.20790>:
    if (klass == 0B) goto <D.20794>; else goto <D.20792>;
    <D.20794>:
    D.20701 = spec->native;
    if (D.20701 == 28) goto <D.20795>; else goto <D.20792>;
    <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.20793>;
    <D.20792>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1364);
    <D.20793>:
    <D.20791>:
    <D.20788>:
    <D.20783>:
    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.18630>;
  }
  <D.18653>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1376);
  <D.18630>:
  D.20796 = conv_arg;
  return D.20796;
}


ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (void * pUnk)
{
  _Bool D.20798;
  long int D.20799;
  long int D.20800;
  int D.20803;
  struct MonoIUnknown * D.20804;
  int (*<T311e>) (void *) D.20805;

  D.20798 = pUnk == 0B;
  D.20799 = (long int) D.20798;
  D.20800 = __builtin_expect (D.20799, 0);
  if (D.20800 != 0) goto <D.20801>; else goto <D.20802>;
  <D.20801>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1399, "pUnk");
  <D.20802>:
  D.20804 = MEM[(struct MonoIUnknown * *)pUnk];
  D.20805 = D.20804->AddRef;
  D.20803 = D.20805 (pUnk);
  return D.20803;
}


ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (void * pUnk, void * riid, void * * ppv)
{
  _Bool D.20807;
  long int D.20808;
  long int D.20809;
  int D.20812;
  struct MonoIUnknown * D.20813;
  int (*<T2f45>) (void *, void *, void * *) D.20814;

  D.20807 = pUnk == 0B;
  D.20808 = (long int) D.20807;
  D.20809 = __builtin_expect (D.20808, 0);
  if (D.20809 != 0) goto <D.20810>; else goto <D.20811>;
  <D.20810>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1406, "pUnk");
  <D.20811>:
  D.20813 = MEM[(struct MonoIUnknown * *)pUnk];
  D.20814 = D.20813->QueryInterface;
  D.20812 = D.20814 (pUnk, riid, ppv);
  return D.20812;
}


ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (void * pUnk)
{
  _Bool D.20816;
  long int D.20817;
  long int D.20818;
  int D.20821;
  struct MonoIUnknown * D.20822;
  int (*<T311e>) (void *) D.20823;

  D.20816 = pUnk == 0B;
  D.20817 = (long int) D.20816;
  D.20818 = __builtin_expect (D.20817, 0);
  if (D.20818 != 0) goto <D.20819>; else goto <D.20820>;
  <D.20819>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1413, "pUnk");
  <D.20820>:
  D.20822 = MEM[(struct MonoIUnknown * *)pUnk];
  D.20823 = D.20822->Release;
  D.20821 = D.20823 (pUnk);
  return D.20821;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal (struct MonoObject * object)
{
  void * D.20827;
  int D.20828;
  struct MonoVTable * D.20833;
  struct MonoClass * D.20834;
  struct MonoVTable * D.20839;
  struct MonoClass * D.20840;
  struct MonoComObject * D.20843;
  struct MonoClass * D.20846;

  if (object == 0B) goto <D.20825>; else goto <D.20826>;
  <D.20825>:
  D.20827 = 0B;
  return D.20827;
  <D.20826>:
  D.20828 = cominterop_object_is_rcw (object);
  if (D.20828 != 0) goto <D.20829>; else goto <D.20830>;
  <D.20829>:
  {
    struct MonoClass * klass;
    struct MonoRealProxy * real_proxy;

    klass = 0B;
    real_proxy = 0B;
    if (object == 0B) goto <D.20831>; else goto <D.20832>;
    <D.20831>:
    D.20827 = 0B;
    return D.20827;
    <D.20832>:
    D.20833 = object->vtable;
    klass = D.20833->klass;
    D.20834 = mono_defaults.transparent_proxy_class;
    if (D.20834 != klass) goto <D.20835>; else goto <D.20836>;
    <D.20835>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1460);
    D.20827 = 0B;
    return D.20827;
    <D.20836>:
    real_proxy = MEM[(struct MonoTransparentProxy *)object].rp;
    if (real_proxy == 0B) goto <D.20837>; else goto <D.20838>;
    <D.20837>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1466);
    D.20827 = 0B;
    return D.20827;
    <D.20838>:
    D.20839 = MEM[(struct MonoObject *)real_proxy].vtable;
    klass = D.20839->klass;
    D.20840 = mono_class_get_interop_proxy_class ();
    if (D.20840 != klass) goto <D.20841>; else goto <D.20842>;
    <D.20841>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1472);
    D.20827 = 0B;
    return D.20827;
    <D.20842>:
    D.20843 = MEM[(struct MonoComInteropProxy *)real_proxy].com_object;
    if (D.20843 == 0B) goto <D.20844>; else goto <D.20845>;
    <D.20844>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1477);
    D.20827 = 0B;
    return D.20827;
    <D.20845>:
    D.20843 = MEM[(struct MonoComInteropProxy *)real_proxy].com_object;
    D.20827 = D.20843->iunknown;
    return D.20827;
  }
  <D.20830>:
  D.20846 = mono_class_get_iunknown_class ();
  D.20827 = cominterop_get_ccw (object, D.20846);
  return D.20827;
}


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

  object = 0B;
  if (pUnk == 0B) goto <D.20848>; else goto <D.20849>;
  <D.20848>:
  D.20850 = 0B;
  return D.20850;
  <D.20849>:
  object = cominterop_get_ccw_object (pUnk, 1);
  D.20850 = object;
  return D.20850;
}


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

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


cominterop_get_idispatch_for_object (struct MonoObject * object)
{
  void * D.20856;
  int D.20857;
  struct MonoRealProxy * D.20860;
  struct MonoComObject * D.20861;
  struct MonoClass * D.20862;
  struct MonoVTable * D.20863;
  int D.20864;
  struct MonoClass * D.20867;

  if (object == 0B) goto <D.20854>; else goto <D.20855>;
  <D.20854>:
  D.20856 = 0B;
  return D.20856;
  <D.20855>:
  D.20857 = cominterop_object_is_rcw (object);
  if (D.20857 != 0) goto <D.20858>; else goto <D.20859>;
  <D.20858>:
  D.20860 = MEM[(struct MonoTransparentProxy *)object].rp;
  D.20861 = MEM[(struct MonoComInteropProxy *)D.20860].com_object;
  D.20862 = mono_class_get_idispatch_class ();
  D.20856 = cominterop_get_interface (D.20861, D.20862, 1);
  return D.20856;
  <D.20859>:
  {
    struct MonoClass * klass;

    D.20863 = object->vtable;
    klass = D.20863->klass;
    D.20864 = cominterop_can_support_dispatch (klass);
    if (D.20864 == 0) goto <D.20865>; else goto <D.20866>;
    <D.20865>:
    cominterop_raise_hr_exception (-2147467262);
    <D.20866>:
    D.20867 = mono_class_get_idispatch_class ();
    D.20856 = cominterop_get_ccw (object, D.20867);
    return D.20856;
  }
}


ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (struct MonoObject * object, struct MonoReflectionType * type)
{
  _Bool D.20869;
  long int D.20870;
  long int D.20871;
  struct MonoType * D.20874;
  _Bool D.20875;
  long int D.20876;
  long int D.20877;
  _Bool D.20880;
  long int D.20881;
  long int D.20882;
  int D.20885;
  struct MonoException * D.20888;
  _Bool D.20889;
  long int D.20890;
  long int D.20891;
  void * D.20894;
  struct MonoClass * klass;
  void * itf;

  klass = 0B;
  itf = 0B;
  D.20869 = type == 0B;
  D.20870 = (long int) D.20869;
  D.20871 = __builtin_expect (D.20870, 0);
  if (D.20871 != 0) goto <D.20872>; else goto <D.20873>;
  <D.20872>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1525, "type");
  <D.20873>:
  D.20874 = type->type;
  D.20875 = D.20874 == 0B;
  D.20876 = (long int) D.20875;
  D.20877 = __builtin_expect (D.20876, 0);
  if (D.20877 != 0) goto <D.20878>; else goto <D.20879>;
  <D.20878>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1526, "type->type");
  <D.20879>:
  D.20874 = type->type;
  klass = mono_type_get_class (D.20874);
  D.20880 = klass == 0B;
  D.20881 = (long int) D.20880;
  D.20882 = __builtin_expect (D.20881, 0);
  if (D.20882 != 0) goto <D.20883>; else goto <D.20884>;
  <D.20883>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1528, "klass");
  <D.20884>:
  D.20885 = mono_class_init (klass);
  if (D.20885 == 0) goto <D.20886>; else goto <D.20887>;
  <D.20886>:
  D.20888 = mono_class_get_exception_for_failure (klass);
  mono_raise_exception (D.20888);
  <D.20887>:
  itf = cominterop_get_ccw (object, klass);
  D.20889 = itf == 0B;
  D.20890 = (long int) D.20889;
  D.20891 = __builtin_expect (D.20890, 0);
  if (D.20891 != 0) goto <D.20892>; else goto <D.20893>;
  <D.20892>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1533, "itf");
  <D.20893>:
  D.20894 = itf;
  return D.20894;
}


ves_icall_System_Runtime_InteropServices_Marshal_IsComObject (struct MonoObject * object)
{
  MonoBoolean D.20896;
  int D.20897;

  D.20897 = cominterop_object_is_rcw (object);
  D.20896 = (MonoBoolean) D.20897;
  return D.20896;
}


ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal (struct MonoObject * object)
{
  _Bool D.20899;
  long int D.20900;
  long int D.20901;
  int D.20904;
  _Bool D.20905;
  long int D.20906;
  long int D.20907;
  _Bool D.20910;
  long int D.20911;
  long int D.20912;
  int D.20915;
  gint32 D.20918;
  gint32 * D.20919;
  _Bool D.20920;
  long int D.20921;
  long int D.20922;
  struct MonoComObject * D.20927;
  struct MonoComInteropProxy * proxy;
  gint32 ref_count;

  proxy = 0B;
  ref_count = 0;
  D.20899 = object == 0B;
  D.20900 = (long int) D.20899;
  D.20901 = __builtin_expect (D.20900, 0);
  if (D.20901 != 0) goto <D.20902>; else goto <D.20903>;
  <D.20902>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1558, "object");
  <D.20903>:
  D.20904 = cominterop_object_is_rcw (object);
  D.20905 = D.20904 == 0;
  D.20906 = (long int) D.20905;
  D.20907 = __builtin_expect (D.20906, 0);
  if (D.20907 != 0) goto <D.20908>; else goto <D.20909>;
  <D.20908>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1559, "cominterop_object_is_rcw (object)");
  <D.20909>:
  proxy = MEM[(struct MonoTransparentProxy *)object].rp;
  D.20910 = proxy == 0B;
  D.20911 = (long int) D.20910;
  D.20912 = __builtin_expect (D.20911, 0);
  if (D.20912 != 0) goto <D.20913>; else goto <D.20914>;
  <D.20913>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1562, "proxy");
  <D.20914>:
  D.20915 = proxy->ref_count;
  if (D.20915 == 0) goto <D.20916>; else goto <D.20917>;
  <D.20916>:
  D.20918 = -1;
  return D.20918;
  <D.20917>:
  D.20919 = &proxy->ref_count;
  ref_count = InterlockedDecrement (D.20919);
  D.20920 = ref_count < 0;
  D.20921 = (long int) D.20920;
  D.20922 = __builtin_expect (D.20921, 0);
  if (D.20922 != 0) goto <D.20923>; else goto <D.20924>;
  <D.20923>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1569, "ref_count >= 0");
  <D.20924>:
  if (ref_count == 0) goto <D.20925>; else goto <D.20926>;
  <D.20925>:
  D.20927 = proxy->com_object;
  ves_icall_System_ComObject_ReleaseInterfaces (D.20927);
  <D.20926>:
  D.20918 = ref_count;
  return D.20918;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal (struct MonoReflectionMethod * m)
{
  guint32 D.20929;
  struct MonoMethod * D.20930;
  int D.20931;

  D.20930 = m->method;
  D.20931 = cominterop_get_com_slot_for_method (D.20930);
  D.20929 = (guint32) D.20931;
  return D.20929;
}


ves_icall_System_ComObject_CreateRCW (struct MonoReflectionType * type)
{
  struct MonoVTable * D.20933;
  struct MonoType * D.20934;
  struct MonoVTable * D.20935;
  struct MonoObject * D.20936;
  struct MonoClass * klass;
  struct MonoDomain * domain;
  struct MonoObject * obj;

  D.20933 = MEM[(struct MonoObject *)type].vtable;
  domain = D.20933->domain;
  D.20934 = type->type;
  klass = mono_class_from_mono_type (D.20934);
  D.20935 = mono_class_vtable_full (domain, klass, 1);
  obj = mono_object_new_alloc_specific (D.20935);
  D.20936 = obj;
  return D.20936;
}


ves_icall_System_ComObject_ReleaseInterfaces (struct MonoComObject * obj)
{
  _Bool D.20938;
  long int D.20939;
  long int D.20940;
  struct GHashTable * D.20943;
  _Bool D.20948;
  long int D.20949;
  long int D.20950;
  struct GHashTable * rcw_hash.139;
  void * D.20954;
  void * D.20955;
  _Bool D.20960;
  long int D.20961;
  long int D.20962;

  D.20938 = obj == 0B;
  D.20939 = (long int) D.20938;
  D.20940 = __builtin_expect (D.20939, 0);
  if (D.20940 != 0) goto <D.20941>; else goto <D.20942>;
  <D.20941>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1625, "obj");
  <D.20942>:
  D.20943 = obj->itf_hash;
  if (D.20943 != 0B) goto <D.20944>; else goto <D.20945>;
  <D.20944>:
  {
    guint32 gchandle;

    gchandle = 0;
    {
      int ret;

      ret = pthread_mutex_lock (&cominterop_mutex.mutex);
      if (ret != 0) goto <D.20946>; else goto <D.20947>;
      <D.20946>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
      <D.20947>:
      D.20948 = ret != 0;
      D.20949 = (long int) D.20948;
      D.20950 = __builtin_expect (D.20949, 0);
      if (D.20950 != 0) goto <D.20951>; else goto <D.20952>;
      <D.20951>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1628, "ret == 0");
      <D.20952>:
    }
    rcw_hash.139 = rcw_hash;
    D.20954 = obj->iunknown;
    D.20955 = monoeg_g_hash_table_lookup (rcw_hash.139, D.20954);
    gchandle = (guint32) D.20955;
    if (gchandle != 0) goto <D.20956>; else goto <D.20957>;
    <D.20956>:
    mono_gchandle_free (gchandle);
    rcw_hash.139 = rcw_hash;
    D.20954 = obj->iunknown;
    monoeg_g_hash_table_remove (rcw_hash.139, D.20954);
    <D.20957>:
    D.20943 = obj->itf_hash;
    monoeg_g_hash_table_foreach_remove (D.20943, cominterop_rcw_interface_finalizer, 0B);
    D.20943 = obj->itf_hash;
    monoeg_g_hash_table_destroy (D.20943);
    D.20954 = obj->iunknown;
    ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (D.20954);
    obj->iunknown = 0B;
    obj->itf_hash = 0B;
    {
      int ret;

      ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
      if (ret != 0) goto <D.20958>; else goto <D.20959>;
      <D.20958>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
      <D.20959>:
      D.20960 = ret != 0;
      D.20961 = (long int) D.20960;
      D.20962 = __builtin_expect (D.20961, 0);
      if (D.20962 != 0) goto <D.20963>; else goto <D.20964>;
      <D.20963>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1639, "ret == 0");
      <D.20964>:
    }
  }
  <D.20945>:
}


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

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


cominterop_release_all_rcws ()
{
  struct GHashTable * rcw_hash.140;
  _Bool D.20972;
  long int D.20973;
  long int D.20974;
  _Bool D.20979;
  long int D.20980;
  long int D.20981;

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

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.20970>; else goto <D.20971>;
    <D.20970>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.20971>:
    D.20972 = ret != 0;
    D.20973 = (long int) D.20972;
    D.20974 = __builtin_expect (D.20973, 0);
    if (D.20974 != 0) goto <D.20975>; else goto <D.20976>;
    <D.20975>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1674, "ret == 0");
    <D.20976>:
  }
  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.20977>; else goto <D.20978>;
    <D.20977>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.20978>:
    D.20979 = ret != 0;
    D.20980 = (long int) D.20979;
    D.20981 = __builtin_expect (D.20980, 0);
    if (D.20981 != 0) goto <D.20982>; else goto <D.20983>;
    <D.20982>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1680, "ret == 0");
    <D.20983>:
  }
}


cominterop_rcw_finalizer (void * key, void * value, void * user_data)
{
  struct MonoComObject * D.20989;
  struct GHashTable * D.20990;
  void * D.20993;
  gboolean D.20996;
  guint32 gchandle;

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

    proxy = mono_gchandle_get_target (gchandle);
    if (proxy != 0B) goto <D.20987>; else goto <D.20988>;
    <D.20987>:
    D.20989 = proxy->com_object;
    D.20990 = D.20989->itf_hash;
    if (D.20990 != 0B) goto <D.20991>; else goto <D.20992>;
    <D.20991>:
    D.20989 = proxy->com_object;
    D.20990 = D.20989->itf_hash;
    monoeg_g_hash_table_foreach_remove (D.20990, cominterop_rcw_interface_finalizer, 0B);
    D.20989 = proxy->com_object;
    D.20990 = D.20989->itf_hash;
    monoeg_g_hash_table_destroy (D.20990);
    <D.20992>:
    D.20989 = proxy->com_object;
    D.20993 = D.20989->iunknown;
    if (D.20993 != 0B) goto <D.20994>; else goto <D.20995>;
    <D.20994>:
    D.20989 = proxy->com_object;
    D.20993 = D.20989->iunknown;
    ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (D.20993);
    <D.20995>:
    D.20989 = proxy->com_object;
    D.20989->iunknown = 0B;
    D.20989 = proxy->com_object;
    D.20989->itf_hash = 0B;
    <D.20988>:
    mono_gchandle_free (gchandle);
  }
  <D.20986>:
  D.20996 = 1;
  return D.20996;
}


ves_icall_System_ComObject_GetInterfaceInternal (struct MonoComObject * obj, struct MonoReflectionType * type, MonoBoolean throw_exception)
{
  struct MonoType * D.20998;
  int D.20999;
  struct MonoException * D.21002;
  void * D.21003;
  int D.21004;
  struct MonoClass * class;

  D.20998 = type->type;
  class = mono_type_get_class (D.20998);
  D.20999 = mono_class_init (class);
  if (D.20999 == 0) goto <D.21000>; else goto <D.21001>;
  <D.21000>:
  D.21002 = mono_class_get_exception_for_failure (class);
  mono_raise_exception (D.21002);
  <D.21001>:
  D.21004 = (int) throw_exception;
  D.21003 = cominterop_get_interface (obj, class, D.21004);
  return D.21003;
}


ves_icall_Mono_Interop_ComInteropProxy_AddProxy (void * pUnk, struct MonoComInteropProxy * proxy)
{
  struct GHashTable * rcw_hash.141;
  _Bool D.21011;
  long int D.21012;
  long int D.21013;
  struct GHashTable * rcw_hash.142;
  _Bool D.21019;
  long int D.21020;
  long int D.21021;
  _Bool D.21026;
  long int D.21027;
  long int D.21028;
  void * gchandle.143;
  _Bool D.21034;
  long int D.21035;
  long int D.21036;
  guint32 gchandle;

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

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21009>; else goto <D.21010>;
    <D.21009>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21010>:
    D.21011 = ret != 0;
    D.21012 = (long int) D.21011;
    D.21013 = __builtin_expect (D.21012, 0);
    if (D.21013 != 0) goto <D.21014>; else goto <D.21015>;
    <D.21014>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1703, "ret == 0");
    <D.21015>:
  }
  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.21017>; else goto <D.21018>;
    <D.21017>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21018>:
    D.21019 = ret != 0;
    D.21020 = (long int) D.21019;
    D.21021 = __builtin_expect (D.21020, 0);
    if (D.21021 != 0) goto <D.21022>; else goto <D.21023>;
    <D.21022>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1705, "ret == 0");
    <D.21023>:
  }
  <D.21008>:
  gchandle = mono_gchandle_new_weakref (proxy, 0);
  {
    int ret;

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

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21032>; else goto <D.21033>;
    <D.21032>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21033>:
    D.21034 = ret != 0;
    D.21035 = (long int) D.21034;
    D.21036 = __builtin_expect (D.21035, 0);
    if (D.21036 != 0) goto <D.21037>; else goto <D.21038>;
    <D.21037>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1712, "ret == 0");
    <D.21038>:
  }
}


ves_icall_Mono_Interop_ComInteropProxy_FindProxy (void * pUnk)
{
  _Bool D.21041;
  long int D.21042;
  long int D.21043;
  struct GHashTable * rcw_hash.144;
  void * D.21049;
  _Bool D.21052;
  long int D.21053;
  long int D.21054;
  struct MonoComInteropProxy * D.21061;
  struct MonoComInteropProxy * proxy;
  guint32 gchandle;

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

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21039>; else goto <D.21040>;
    <D.21039>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21040>:
    D.21041 = ret != 0;
    D.21042 = (long int) D.21041;
    D.21043 = __builtin_expect (D.21042, 0);
    if (D.21043 != 0) goto <D.21044>; else goto <D.21045>;
    <D.21044>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1725, "ret == 0");
    <D.21045>:
  }
  rcw_hash.144 = rcw_hash;
  if (rcw_hash.144 != 0B) goto <D.21047>; else goto <D.21048>;
  <D.21047>:
  rcw_hash.144 = rcw_hash;
  D.21049 = monoeg_g_hash_table_lookup (rcw_hash.144, pUnk);
  gchandle = (guint32) D.21049;
  <D.21048>:
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21050>; else goto <D.21051>;
    <D.21050>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21051>:
    D.21052 = ret != 0;
    D.21053 = (long int) D.21052;
    D.21054 = __builtin_expect (D.21053, 0);
    if (D.21054 != 0) goto <D.21055>; else goto <D.21056>;
    <D.21055>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1728, "ret == 0");
    <D.21056>:
  }
  if (gchandle != 0) goto <D.21057>; else goto <D.21058>;
  <D.21057>:
  proxy = mono_gchandle_get_target (gchandle);
  if (proxy == 0B) goto <D.21059>; else goto <D.21060>;
  <D.21059>:
  mono_gchandle_free (gchandle);
  rcw_hash.144 = rcw_hash;
  monoeg_g_hash_table_remove (rcw_hash.144, pUnk);
  <D.21060>:
  <D.21058>:
  D.21061 = proxy;
  return D.21061;
}


mono_marshal_free_ccw (struct MonoObject * object)
{
  struct GHashTable * ccw_hash.145;
  unsigned int D.21067;
  gboolean D.21068;
  _Bool D.21071;
  long int D.21072;
  long int D.21073;
  int D.21076;
  const void * D.21077;
  _Bool D.21080;
  long int D.21081;
  long int D.21082;
  unsigned int D.21087;
  struct GHashTable * D.21092;
  struct GList * iftmp.146;
  struct GList * iftmp.147;
  unsigned int D.21101;
  int D.21104;
  const void * D.21105;
  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.21063>; else goto <D.21066>;
  <D.21066>:
  ccw_hash.145 = ccw_hash;
  D.21067 = monoeg_g_hash_table_size (ccw_hash.145);
  if (D.21067 == 0) goto <D.21063>; else goto <D.21064>;
  <D.21063>:
  D.21068 = 0;
  return D.21068;
  <D.21064>:
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21069>; else goto <D.21070>;
    <D.21069>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21070>:
    D.21071 = ret != 0;
    D.21072 = (long int) D.21071;
    D.21073 = __builtin_expect (D.21072, 0);
    if (D.21073 != 0) goto <D.21074>; else goto <D.21075>;
    <D.21074>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2050, "ret == 0");
    <D.21075>:
  }
  ccw_hash.145 = ccw_hash;
  D.21076 = mono_object_hash (object);
  D.21077 = (const void *) D.21076;
  ccw_list_orig = monoeg_g_hash_table_lookup (ccw_hash.145, D.21077);
  ccw_list = ccw_list_orig;
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21078>; else goto <D.21079>;
    <D.21078>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21079>:
    D.21080 = ret != 0;
    D.21081 = (long int) D.21080;
    D.21082 = __builtin_expect (D.21081, 0);
    if (D.21082 != 0) goto <D.21083>; else goto <D.21084>;
    <D.21083>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2052, "ret == 0");
    <D.21084>:
  }
  if (ccw_list == 0B) goto <D.21085>; else goto <D.21086>;
  <D.21085>:
  D.21068 = 0;
  return D.21068;
  <D.21086>:
  ccw_list_item = ccw_list;
  goto <D.18838>;
  <D.18837>:
  {
    struct MonoCCW * ccw_iter;
    struct MonoObject * handle_target;

    ccw_iter = ccw_list_item->data;
    D.21087 = ccw_iter->gc_handle;
    handle_target = mono_gchandle_get_target (D.21087);
    if (handle_target == 0B) goto <D.21088>; else goto <D.21091>;
    <D.21091>:
    if (handle_target == object) goto <D.21088>; else goto <D.21089>;
    <D.21088>:
    D.21092 = ccw_iter->vtable_hash;
    monoeg_g_hash_table_foreach_remove (D.21092, mono_marshal_free_ccw_entry, 0B);
    D.21092 = ccw_iter->vtable_hash;
    monoeg_g_hash_table_destroy (D.21092);
    if (ccw_list_item != 0B) goto <D.21094>; else goto <D.21095>;
    <D.21094>:
    iftmp.146 = ccw_list_item->next;
    goto <D.21096>;
    <D.21095>:
    iftmp.146 = 0B;
    <D.21096>:
    ccw_list_item = iftmp.146;
    ccw_list = monoeg_g_list_remove (ccw_list, ccw_iter);
    monoeg_g_free (ccw_iter);
    goto <D.21090>;
    <D.21089>:
    if (ccw_list_item != 0B) goto <D.21098>; else goto <D.21099>;
    <D.21098>:
    iftmp.147 = ccw_list_item->next;
    goto <D.21100>;
    <D.21099>:
    iftmp.147 = 0B;
    <D.21100>:
    ccw_list_item = iftmp.147;
    <D.21090>:
  }
  <D.18838>:
  if (ccw_list_item != 0B) goto <D.18837>; else goto <D.18839>;
  <D.18839>:
  D.21101 = monoeg_g_list_length (ccw_list);
  if (D.21101 == 0) goto <D.21102>; else goto <D.21103>;
  <D.21102>:
  ccw_hash.145 = ccw_hash;
  D.21104 = mono_object_hash (object);
  D.21105 = (const void *) D.21104;
  monoeg_g_hash_table_remove (ccw_hash.145, D.21105);
  <D.21103>:
  D.21068 = 1;
  return D.21068;
}


mono_marshal_free_ccw_entry (void * key, void * value, void * user_data)
{
  struct GHashTable * ccw_interface_hash.148;
  _Bool D.21108;
  long int D.21109;
  long int D.21110;
  gboolean D.21113;

  ccw_interface_hash.148 = ccw_interface_hash;
  monoeg_g_hash_table_remove (ccw_interface_hash.148, value);
  D.21108 = value == 0B;
  D.21109 = (long int) D.21108;
  D.21110 = __builtin_expect (D.21109, 0);
  if (D.21110 != 0) goto <D.21111>; else goto <D.21112>;
  <D.21111>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2030, "value");
  <D.21112>:
  monoeg_g_free (value);
  D.21113 = 1;
  return D.21113;
}


mono_string_to_bstr (struct MonoString * string_obj)
{
  void * D.21117;
  <unnamed type> com_provider.149;
  unsigned int slen.150;
  unsigned int D.21122;
  unsigned int D.21123;
  char * D.21126;
  mono_unichar2 * D.21127;
  unsigned int D.21128;
  unsigned int D.21129;
  unsigned int D.21130;
  char * D.21131;
  unsigned int D.21132;
  char * D.21133;
  int D.21136;
  int D.21138;
  mono_unichar2 * D.21139;
  long int len.151;
  void * (*<T3318>) (gunichar *, guint32) sys_alloc_string_len_ms.152;

  if (string_obj == 0B) goto <D.21115>; else goto <D.21116>;
  <D.21115>:
  D.21117 = 0B;
  return D.21117;
  <D.21116>:
  com_provider.149 = com_provider;
  if (com_provider.149 == 0) goto <D.21119>; else goto <D.21120>;
  <D.21119>:
  {
    int slen;
    char * ret;

    slen = mono_string_length (string_obj);
    slen.150 = (unsigned int) slen;
    D.21122 = slen.150 + 3;
    D.21123 = D.21122 * 2;
    ret = monoeg_malloc (D.21123);
    if (ret == 0B) goto <D.21124>; else goto <D.21125>;
    <D.21124>:
    D.21117 = 0B;
    return D.21117;
    <D.21125>:
    D.21126 = ret + 4;
    D.21127 = mono_string_chars (string_obj);
    slen.150 = (unsigned int) slen;
    D.21128 = slen.150 * 2;
    memcpy (D.21126, D.21127, D.21128);
    slen.150 = (unsigned int) slen;
    D.21128 = slen.150 * 2;
    MEM[(guint32 *)ret] = D.21128;
    slen.150 = (unsigned int) slen;
    D.21129 = slen.150 + 2;
    D.21130 = D.21129 * 2;
    D.21131 = ret + D.21130;
    *D.21131 = 0;
    slen.150 = (unsigned int) slen;
    D.21128 = slen.150 * 2;
    D.21132 = D.21128 + 5;
    D.21133 = ret + D.21132;
    *D.21133 = 0;
    D.21117 = ret + 4;
    return D.21117;
  }
  <D.21120>:
  com_provider.149 = com_provider;
  if (com_provider.149 == 1) goto <D.21135>; else goto <D.21134>;
  <D.21135>:
  D.21136 = init_com_provider_ms ();
  if (D.21136 != 0) goto <D.21137>; else goto <D.21134>;
  <D.21137>:
  {
    void * ret;
    gunichar * str;
    guint32 len;

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


mono_string_from_bstr (void * bstr)
{
  struct MonoString * D.21145;
  <unnamed type> com_provider.153;
  struct MonoDomain * D.21149;
  guint32 * D.21150;
  unsigned int D.21151;
  unsigned int D.21152;
  int D.21153;
  int D.21156;
  guint32 (*<T1778>) (void *) sys_string_len_ms.154;
  unsigned int D.21159;
  long int D.21160;
  struct MonoDomain * D.21161;
  long int written.155;

  if (bstr == 0B) goto <D.21143>; else goto <D.21144>;
  <D.21143>:
  D.21145 = 0B;
  return D.21145;
  <D.21144>:
  com_provider.153 = com_provider;
  if (com_provider.153 == 0) goto <D.21147>; else goto <D.21148>;
  <D.21147>:
  D.21149 = mono_domain_get ();
  D.21150 = bstr + 4294967292;
  D.21151 = *D.21150;
  D.21152 = D.21151 / 2;
  D.21153 = (int) D.21152;
  D.21145 = mono_string_new_utf16 (D.21149, bstr, D.21153);
  return D.21145;
  <D.21148>:
  com_provider.153 = com_provider;
  if (com_provider.153 == 1) goto <D.21155>; else goto <D.21154>;
  <D.21155>:
  D.21156 = init_com_provider_ms ();
  if (D.21156 != 0) goto <D.21157>; else goto <D.21154>;
  <D.21157>:
  {
    struct MonoString * str;
    glong written;
    gunichar2 * utf16;

    try
      {
        str = 0B;
        written = 0;
        utf16 = 0B;
        sys_string_len_ms.154 = sys_string_len_ms;
        D.21159 = sys_string_len_ms.154 (bstr);
        D.21160 = (long int) D.21159;
        utf16 = monoeg_g_ucs4_to_utf16 (bstr, D.21160, 0B, &written, 0B);
        D.21161 = mono_domain_get ();
        written.155 = written;
        str = mono_string_new_utf16 (D.21161, utf16, written.155);
        monoeg_g_free (utf16);
        D.21145 = str;
        return D.21145;
      }
    finally
      {
        written = {CLOBBER};
      }
  }
  <D.21154>:
  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.21170;
  int D.21175;
  void (*<T3320>) (gunichar *) sys_free_string_ms.157;

  if (bstr == 0B) goto <D.21165>; else goto <D.21166>;
  <D.21165>:
  return;
  <D.21166>:
  com_provider.156 = com_provider;
  if (com_provider.156 == 0) goto <D.21168>; else goto <D.21169>;
  <D.21168>:
  D.21170 = bstr + 4294967292;
  monoeg_g_free (D.21170);
  goto <D.21171>;
  <D.21169>:
  com_provider.156 = com_provider;
  if (com_provider.156 == 1) goto <D.21174>; else goto <D.21172>;
  <D.21174>:
  D.21175 = init_com_provider_ms ();
  if (D.21175 != 0) goto <D.21176>; else goto <D.21172>;
  <D.21176>:
  sys_free_string_ms.157 = sys_free_string_ms;
  sys_free_string_ms.157 (bstr);
  goto <D.21173>;
  <D.21172>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2649);
  <D.21173>:
  <D.21171>:
}


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.21179;
  int D.21180;
  int D.21181;
  struct MonoClass * D.21184;
  struct MonoType * D.21185;
  struct MonoClass * D.21186;
  struct MonoType * D.21187;
  unsigned int D.21188;
  unsigned int D.21189;
  unsigned int argnum.158;
  unsigned int safearray_var.159;
  unsigned int indices_var.160;
  unsigned int empty_var.161;
  struct MonoClass * D.21197;
  struct MonoType * D.21198;
  unsigned int index_var.162;
  int D.21200;
  struct MonoMethod * get_value_impl.163;
  struct MonoClass * D.21204;
  struct MonoMethod * get_value_impl.164;
  _Bool D.21206;
  long int D.21207;
  long int D.21208;
  struct MonoMethod * get_native_variant_for_object.165;
  struct MonoClass * D.21217;
  struct MonoMethod * get_native_variant_for_object.166;
  _Bool D.21219;
  long int D.21220;
  long int D.21221;
  struct MonoClass * D.21224;
  struct MonoType * D.21225;
  unsigned int elem_var.167;
  struct MonoMethod * variant_clear.168;
  struct MonoClass * D.21230;
  struct MonoMethod * variant_clear.169;
  short unsigned int D.21232;
  int D.21233;
  unsigned int conv_arg.170;
  int D.21238;
  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.21253;
  struct MonoMethod * get_object_for_native_variant.176;
  struct MonoMethod * get_object_for_native_variant.177;
  _Bool D.21260;
  long int D.21261;
  long int D.21262;
  struct MonoMethod * set_value_impl.178;
  struct MonoMethod * set_value_impl.179;
  _Bool D.21269;
  long int D.21270;
  long int D.21271;
  unsigned int elem_var.180;
  short unsigned int D.21277;
  int D.21278;
  int D.21281;
  struct MonoMethodBuilder * mb;

  mb = m->mb;
  switch (action) <default: <D.19059>, case 0: <D.19032>, case 1: <D.19045>, case 2: <D.19046>>
  <D.19032>:
  D.21179 = t->attrs;
  D.21180 = (int) D.21179;
  D.21181 = D.21180 & 1;
  if (D.21181 != 0) goto <D.21182>; else goto <D.21183>;
  <D.21182>:
  {
    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.21184 = mono_defaults.object_class;
    D.21185 = &D.21184->byval_arg;
    safearray_var = mono_mb_add_local (mb, D.21185);
    conv_arg = safearray_var;
    D.21186 = mono_defaults.int_class;
    D.21187 = &D.21186->byval_arg;
    indices_var = mono_mb_add_local (mb, D.21187);
    D.21186 = mono_defaults.int_class;
    D.21187 = &D.21186->byval_arg;
    empty_var = mono_mb_add_local (mb, D.21187);
    D.21188 = BIT_FIELD_REF <*t, 32, 32>;
    D.21189 = D.21188 & 1073741824;
    if (D.21189 != 0) goto <D.21190>; else goto <D.21191>;
    <D.21190>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    mono_mb_emit_byte (mb, 80);
    goto <D.21193>;
    <D.21191>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    <D.21193>:
    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.21197 = mono_defaults.int32_class;
    D.21198 = &D.21197->byval_arg;
    index_var = mono_mb_add_local (mb, D.21198);
    mono_mb_emit_byte (mb, 22);
    index_var.162 = (unsigned int) index_var;
    mono_mb_emit_stloc (mb, index_var.162);
    D.21200 = mono_mb_get_label (mb);
    label3 = (guint32) D.21200;
    get_value_impl.163 = get_value_impl;
    if (get_value_impl.163 == 0B) goto <D.21202>; else goto <D.21203>;
    <D.21202>:
    D.21204 = mono_defaults.array_class;
    get_value_impl.164 = mono_class_get_method_from_name (D.21204, "GetValueImpl", 1);
    get_value_impl = get_value_impl.164;
    <D.21203>:
    get_value_impl.163 = get_value_impl;
    D.21206 = get_value_impl.163 == 0B;
    D.21207 = (long int) D.21206;
    D.21208 = __builtin_expect (D.21207, 0);
    if (D.21208 != 0) goto <D.21209>; else goto <D.21210>;
    <D.21209>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2725, "get_value_impl");
    <D.21210>:
    D.21188 = BIT_FIELD_REF <*t, 32, 32>;
    D.21189 = D.21188 & 1073741824;
    if (D.21189 != 0) goto <D.21211>; else goto <D.21212>;
    <D.21211>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    mono_mb_emit_byte (mb, 80);
    goto <D.21213>;
    <D.21212>:
    argnum.158 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.158);
    <D.21213>:
    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.21215>; else goto <D.21216>;
    <D.21215>:
    D.21217 = mono_defaults.marshal_class;
    get_native_variant_for_object.166 = mono_class_get_method_from_name (D.21217, "GetNativeVariantForObject", 2);
    get_native_variant_for_object = get_native_variant_for_object.166;
    <D.21216>:
    get_native_variant_for_object.165 = get_native_variant_for_object;
    D.21219 = get_native_variant_for_object.165 == 0B;
    D.21220 = (long int) D.21219;
    D.21221 = __builtin_expect (D.21220, 0);
    if (D.21221 != 0) goto <D.21222>; else goto <D.21223>;
    <D.21222>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2739, "get_native_variant_for_object");
    <D.21223>:
    D.21224 = mono_class_get_variant_class ();
    D.21225 = &D.21224->byval_arg;
    elem_var = mono_mb_add_local (mb, D.21225);
    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.21228>; else goto <D.21229>;
    <D.21228>:
    D.21230 = mono_class_get_variant_class ();
    variant_clear.169 = mono_class_get_method_from_name (D.21230, "Clear", 0);
    variant_clear = variant_clear.169;
    <D.21229>:
    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.21232 = (short unsigned int) index_var;
    D.21233 = (int) D.21232;
    mono_mb_emit_add_to_local (mb, D.21233, 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.21183>:
  goto <D.19044>;
  <D.19045>:
  D.21188 = BIT_FIELD_REF <*t, 32, 32>;
  D.21189 = D.21188 & 1073741824;
  if (D.21189 != 0) goto <D.21234>; else goto <D.21235>;
  <D.21234>:
  conv_arg.170 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc_addr (mb, conv_arg.170);
  goto <D.21237>;
  <D.21235>:
  conv_arg.170 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc (mb, conv_arg.170);
  <D.21237>:
  goto <D.19044>;
  <D.19046>:
  D.21179 = t->attrs;
  D.21180 = (int) D.21179;
  D.21238 = D.21180 & 2;
  if (D.21238 != 0) goto <D.21239>; else goto <D.21240>;
  <D.21239>:
  {
    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.21188 = BIT_FIELD_REF <*t, 32, 32>;
    D.21189 = D.21188 & 1073741824;
    if (D.21189 == 0) goto <D.21244>; else goto <D.21242>;
    <D.21244>:
    D.21179 = t->attrs;
    D.21180 = (int) D.21179;
    D.21181 = D.21180 & 1;
    if (D.21181 != 0) goto <D.21245>; else goto <D.21242>;
    <D.21245>:
    iftmp.171 = 1;
    goto <D.21243>;
    <D.21242>:
    iftmp.171 = 0;
    <D.21243>:
    byValue = iftmp.171;
    D.21184 = mono_defaults.object_class;
    D.21185 = &D.21184->byval_arg;
    result_var = mono_mb_add_local (mb, D.21185);
    D.21186 = mono_defaults.int_class;
    D.21187 = &D.21186->byval_arg;
    indices_var = mono_mb_add_local (mb, D.21187);
    D.21186 = mono_defaults.int_class;
    D.21187 = &D.21186->byval_arg;
    empty_var = mono_mb_add_local (mb, D.21187);
    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.21249>; else goto <D.21250>;
    <D.21249>:
    mono_mb_emit_byte (mb, 22);
    goto <D.21251>;
    <D.21250>:
    mono_mb_emit_byte (mb, 23);
    <D.21251>:
    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.21186 = mono_defaults.int_class;
    D.21187 = &D.21186->byval_arg;
    index_var = mono_mb_add_local (mb, D.21187);
    mono_mb_emit_byte (mb, 22);
    index_var.175 = (unsigned int) index_var;
    mono_mb_emit_stloc (mb, index_var.175);
    D.21253 = mono_mb_get_label (mb);
    label3 = (guint32) D.21253;
    if (byValue != 0) goto <D.21254>; else goto <D.21255>;
    <D.21254>:
    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.21255>:
    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.21257>; else goto <D.21258>;
    <D.21257>:
    D.21217 = mono_defaults.marshal_class;
    get_object_for_native_variant.177 = mono_class_get_method_from_name (D.21217, "GetObjectForNativeVariant", 1);
    get_object_for_native_variant = get_object_for_native_variant.177;
    <D.21258>:
    get_object_for_native_variant.176 = get_object_for_native_variant;
    D.21260 = get_object_for_native_variant.176 == 0B;
    D.21261 = (long int) D.21260;
    D.21262 = __builtin_expect (D.21261, 0);
    if (D.21262 != 0) goto <D.21263>; else goto <D.21264>;
    <D.21263>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2854, "get_object_for_native_variant");
    <D.21264>:
    set_value_impl.178 = set_value_impl;
    if (set_value_impl.178 == 0B) goto <D.21266>; else goto <D.21267>;
    <D.21266>:
    D.21204 = mono_defaults.array_class;
    set_value_impl.179 = mono_class_get_method_from_name (D.21204, "SetValueImpl", 2);
    set_value_impl = set_value_impl.179;
    <D.21267>:
    set_value_impl.178 = set_value_impl;
    D.21269 = set_value_impl.178 == 0B;
    D.21270 = (long int) D.21269;
    D.21271 = __builtin_expect (D.21270, 0);
    if (D.21271 != 0) goto <D.21272>; else goto <D.21273>;
    <D.21272>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2858, "set_value_impl");
    <D.21273>:
    D.21184 = mono_defaults.object_class;
    D.21185 = &D.21184->byval_arg;
    elem_var = mono_mb_add_local (mb, D.21185);
    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.21275>; else goto <D.21276>;
    <D.21275>:
    mono_mb_patch_short_branch (mb, label4);
    <D.21276>:
    D.21277 = (short unsigned int) index_var;
    D.21278 = (int) D.21277;
    mono_mb_emit_add_to_local (mb, D.21278, 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.21279>; else goto <D.21280>;
    <D.21279>:
    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.21280>:
  }
  <D.21240>:
  goto <D.19044>;
  <D.19059>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2898);
  <D.19044>:
  D.21281 = conv_arg;
  return D.21281;
}


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

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


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

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


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


