mono_class_get_interop_proxy_class ()
{
  struct MonoImage * D.19539;
  _Bool D.19540;
  long int D.19541;
  long int D.19542;
  struct MonoClass * D.19545;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19537>; else goto <D.19538>;
  <D.19537>:
  D.19539 = mono_defaults.corlib;
  class = mono_class_from_name (D.19539, "Mono.Interop", "ComInteropProxy");
  D.19540 = class == 0B;
  D.19541 = (long int) D.19540;
  D.19542 = __builtin_expect (D.19541, 0);
  if (D.19542 != 0) goto <D.19543>; else goto <D.19544>;
  <D.19543>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 88, "class");
  <D.19544>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19538>:
  D.19545 = class;
  return D.19545;
}


mono_memory_barrier ()
{
  __sync_synchronize ();
}


mono_class_get_idispatch_class ()
{
  struct MonoImage * D.19549;
  _Bool D.19550;
  long int D.19551;
  long int D.19552;
  struct MonoClass * D.19555;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19547>; else goto <D.19548>;
  <D.19547>:
  D.19549 = mono_defaults.corlib;
  class = mono_class_from_name (D.19549, "Mono.Interop", "IDispatch");
  D.19550 = class == 0B;
  D.19551 = (long int) D.19550;
  D.19552 = __builtin_expect (D.19551, 0);
  if (D.19552 != 0) goto <D.19553>; else goto <D.19554>;
  <D.19553>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 89, "class");
  <D.19554>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19548>:
  D.19555 = class;
  return D.19555;
}


mono_class_get_iunknown_class ()
{
  struct MonoImage * D.19559;
  _Bool D.19560;
  long int D.19561;
  long int D.19562;
  struct MonoClass * D.19565;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19557>; else goto <D.19558>;
  <D.19557>:
  D.19559 = mono_defaults.corlib;
  class = mono_class_from_name (D.19559, "Mono.Interop", "IUnknown");
  D.19560 = class == 0B;
  D.19561 = (long int) D.19560;
  D.19562 = __builtin_expect (D.19561, 0);
  if (D.19562 != 0) goto <D.19563>; else goto <D.19564>;
  <D.19563>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 90, "class");
  <D.19564>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19558>:
  D.19565 = class;
  return D.19565;
}


mono_class_get_com_object_class ()
{
  struct MonoImage * D.19569;
  _Bool D.19570;
  long int D.19571;
  long int D.19572;
  struct MonoClass * D.19575;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19567>; else goto <D.19568>;
  <D.19567>:
  D.19569 = mono_defaults.corlib;
  class = mono_class_from_name (D.19569, "System", "__ComObject");
  D.19570 = class == 0B;
  D.19571 = (long int) D.19570;
  D.19572 = __builtin_expect (D.19571, 0);
  if (D.19572 != 0) goto <D.19573>; else goto <D.19574>;
  <D.19573>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 92, "class");
  <D.19574>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19568>:
  D.19575 = class;
  return D.19575;
}


mono_class_get_variant_class ()
{
  struct MonoImage * D.19579;
  _Bool D.19580;
  long int D.19581;
  long int D.19582;
  struct MonoClass * D.19585;
  static struct MonoClass * tmp_class;
  struct MonoClass * class;

  class = tmp_class;
  if (class == 0B) goto <D.19577>; else goto <D.19578>;
  <D.19577>:
  D.19579 = mono_defaults.corlib;
  class = mono_class_from_name (D.19579, "System", "Variant");
  D.19580 = class == 0B;
  D.19581 = (long int) D.19580;
  D.19582 = __builtin_expect (D.19581, 0);
  if (D.19582 != 0) goto <D.19583>; else goto <D.19584>;
  <D.19583>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 93, "class");
  <D.19584>:
  mono_memory_barrier ();
  tmp_class = class;
  <D.19578>:
  D.19585 = class;
  return D.19585;
}


mono_cominterop_init ()
{
  int D.18876;
  int iftmp.0;
  int D.18875;
  const char[3] * D.19592;
  unsigned char D.19593;
  int D.19594;
  unsigned char D.19595;
  int D.19596;
  _Bool D.19597;
  _Bool D.19598;
  _Bool D.19599;
  const unsigned char * D.19602;
  unsigned char D.19603;
  int D.19604;
  const unsigned char * D.19605;
  unsigned char D.19606;
  int D.19607;
  _Bool D.19608;
  _Bool D.19609;
  const unsigned char * D.19612;
  unsigned char D.19613;
  int D.19614;
  const unsigned char * D.19615;
  unsigned char D.19616;
  int D.19617;
  _Bool D.19618;
  _Bool D.19619;
  const unsigned char * D.19622;
  unsigned char D.19623;
  int D.19624;
  const unsigned char * D.19625;
  unsigned char D.19626;
  int D.19627;
  const char * com_provider_env;

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

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

      __s2 = com_provider_env;
      D.19592 = "MS";
      D.19593 = MEM[(const unsigned char *)D.19592];
      D.19594 = (int) D.19593;
      D.19595 = *__s2;
      D.19596 = (int) D.19595;
      __result = D.19594 - D.19596;
      {
        D.19597 = __s2_len != 0;
        D.19598 = __result == 0;
        D.19599 = D.19597 & D.19598;
        if (D.19599 != 0) goto <D.19600>; else goto <D.19601>;
        <D.19600>:
        D.19602 = &MEM[(void *)"MS" + 1B];
        D.19603 = *D.19602;
        D.19604 = (int) D.19603;
        D.19605 = __s2 + 1;
        D.19606 = *D.19605;
        D.19607 = (int) D.19606;
        __result = D.19604 - D.19607;
        D.19608 = __s2_len > 1;
        D.19598 = __result == 0;
        D.19609 = D.19608 & D.19598;
        if (D.19609 != 0) goto <D.19610>; else goto <D.19611>;
        <D.19610>:
        D.19612 = &MEM[(void *)"MS" + 2B];
        D.19613 = *D.19612;
        D.19614 = (int) D.19613;
        D.19615 = __s2 + 2;
        D.19616 = *D.19615;
        D.19617 = (int) D.19616;
        __result = D.19614 - D.19617;
        D.19618 = __s2_len > 2;
        D.19598 = __result == 0;
        D.19619 = D.19618 & D.19598;
        if (D.19619 != 0) goto <D.19620>; else goto <D.19621>;
        <D.19620>:
        D.19622 = &MEM[(void *)"MS" + 3B];
        D.19623 = *D.19622;
        D.19624 = (int) D.19623;
        D.19625 = __s2 + 3;
        D.19626 = *D.19625;
        D.19627 = (int) D.19626;
        __result = D.19624 - D.19627;
        <D.19621>:
        <D.19611>:
        <D.19601>:
      }
      D.18875 = __result;
    }
    iftmp.0 = -D.18875;
    goto <D.19628>;
    <D.19591>:
    iftmp.0 = __builtin_strcmp (com_provider_env, "MS");
    <D.19628>:
    D.18876 = iftmp.0;
  }
  if (D.18876 == 0) goto <D.19629>; else goto <D.19630>;
  <D.19629>:
  com_provider = 1;
  <D.19630>:
  <D.19588>:
  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.19635;
  int (*<T33e6>) (void *, glong *, void * *) safe_array_put_element_ms.2;

  com_provider.1 = com_provider;
  if (com_provider.1 == 1) goto <D.19634>; else goto <D.19631>;
  <D.19634>:
  D.19635 = init_com_provider_ms ();
  if (D.19635 != 0) goto <D.19636>; else goto <D.19631>;
  <D.19636>:
  {
    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.19638>; else goto <D.19639>;
    <D.19638>:
    cominterop_raise_hr_exception (hr);
    <D.19639>:
  }
  goto <D.19632>;
  <D.19631>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3154);
  <D.19632>:
}


init_com_provider_ms ()
{
  int initialized.3;
  gboolean D.19643;
  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.19641>; else goto <D.19642>;
      <D.19641>:
      D.19643 = 1;
      return D.19643;
      <D.19642>:
      module = mono_dl_open (scope, 1, &error_msg);
      error_msg.4 = error_msg;
      if (error_msg.4 != 0B) goto <D.19645>; else goto <D.19646>;
      <D.19645>:
      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.19643 = 0;
      return D.19643;
      <D.19646>:
      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.19648>; else goto <D.19649>;
      <D.19648>:
      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.19643 = 0;
      return D.19643;
      <D.19649>:
      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.19651>; else goto <D.19652>;
      <D.19651>:
      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.19643 = 0;
      return D.19643;
      <D.19652>:
      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.19654>; else goto <D.19655>;
      <D.19654>:
      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.19643 = 0;
      return D.19643;
      <D.19655>:
      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.19657>; else goto <D.19658>;
      <D.19657>:
      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.19643 = 0;
      return D.19643;
      <D.19658>:
      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.19660>; else goto <D.19661>;
      <D.19660>:
      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.19643 = 0;
      return D.19643;
      <D.19661>:
      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.19663>; else goto <D.19664>;
      <D.19663>:
      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.19643 = 0;
      return D.19643;
      <D.19664>:
      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.19666>; else goto <D.19667>;
      <D.19666>:
      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.19643 = 0;
      return D.19643;
      <D.19667>:
      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.19669>; else goto <D.19670>;
      <D.19669>:
      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.19643 = 0;
      return D.19643;
      <D.19670>:
      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.19672>; else goto <D.19673>;
      <D.19672>:
      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.19643 = 0;
      return D.19643;
      <D.19673>:
      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.19675>; else goto <D.19676>;
      <D.19675>:
      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.19643 = 0;
      return D.19643;
      <D.19676>:
      initialized = 1;
      D.19643 = 1;
      return D.19643;
    }
  finally
    {
      error_msg = {CLOBBER};
    }
}


cominterop_raise_hr_exception (int hr)
{
  struct MonoMethod * throw_exception_for_hr.15;
  struct MonoClass * D.19682;
  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.19680>; else goto <D.19681>;
      <D.19680>:
      D.19682 = mono_defaults.marshal_class;
      throw_exception_for_hr.16 = mono_class_get_method_from_name (D.19682, "GetExceptionForHR", 1);
      throw_exception_for_hr = throw_exception_for_hr.16;
      <D.19681>:
      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.19688;
  gboolean D.19689;
  long unsigned int D.19690;
  struct MonoVTable * D.19691;
  struct MonoClass * D.19692;
  unsigned char D.19693;
  long unsigned int D.19694;
  long unsigned int D.19695;
  void * D.19696;
  long unsigned int D.19697;
  _Bool D.19698;
  int D.19699;
  void * D.19702;
  long unsigned int D.19703;
  long unsigned int D.19704;
  int * D.19705;
  long unsigned int D.19706;
  struct SAFEARRAYBOUND * D.19707;
  struct MonoArrayBounds * D.19708;
  struct MonoArrayBounds * D.19709;
  int D.19710;
  int D.19711;
  unsigned int D.19712;
  unsigned int max_array_length.18;
  void * (*<T33f2>) (int, guint32, struct SAFEARRAYBOUND *) safe_array_create_ms.19;
  unsigned int dim.20;
  void * D.19717;
  int dim;
  struct SAFEARRAYBOUND * bounds;
  int i;
  int max_array_length;

  com_provider.17 = com_provider;
  if (com_provider.17 != 1) goto <D.19684>; else goto <D.19687>;
  <D.19687>:
  D.19688 = init_com_provider_ms ();
  if (D.19688 == 0) goto <D.19684>; else goto <D.19685>;
  <D.19684>:
  D.19689 = 0;
  return D.19689;
  <D.19685>:
  D.19690 = mono_array_length (input);
  max_array_length = (int) D.19690;
  D.19691 = MEM[(struct MonoObject *)input].vtable;
  D.19692 = D.19691->klass;
  D.19693 = D.19692->rank;
  dim = (int) D.19693;
  D.19694 = (long unsigned int) dim;
  D.19695 = D.19694 * 4;
  D.19696 = monoeg_malloc (D.19695);
  *indices = D.19696;
  D.19694 = (long unsigned int) dim;
  D.19697 = D.19694 * 8;
  bounds = __builtin_alloca (D.19697);
  D.19698 = max_array_length == 0;
  D.19699 = (int) D.19698;
  MEM[(int *)empty] = D.19699;
  if (dim > 1) goto <D.19700>; else goto <D.19701>;
  <D.19700>:
  i = 0;
  goto <D.19516>;
  <D.19515>:
  D.19702 = *indices;
  D.19703 = (long unsigned int) i;
  D.19704 = D.19703 * 4;
  D.19705 = D.19702 + D.19704;
  D.19703 = (long unsigned int) i;
  D.19706 = D.19703 * 8;
  D.19707 = bounds + D.19706;
  D.19708 = input->bounds;
  D.19703 = (long unsigned int) i;
  D.19706 = D.19703 * 8;
  D.19709 = D.19708 + D.19706;
  D.19710 = D.19709->lower_bound;
  D.19707->lLbound = D.19710;
  D.19711 = D.19707->lLbound;
  *D.19705 = D.19711;
  D.19703 = (long unsigned int) i;
  D.19706 = D.19703 * 8;
  D.19707 = bounds + D.19706;
  D.19708 = input->bounds;
  D.19703 = (long unsigned int) i;
  D.19706 = D.19703 * 8;
  D.19709 = D.19708 + D.19706;
  D.19712 = D.19709->length;
  D.19707->cElements = D.19712;
  i = i + 1;
  <D.19516>:
  if (i < dim) goto <D.19515>; else goto <D.19517>;
  <D.19517>:
  goto <D.19713>;
  <D.19701>:
  D.19702 = *indices;
  MEM[(int *)D.19702] = 0;
  max_array_length.18 = (unsigned int) max_array_length;
  bounds->cElements = max_array_length.18;
  bounds->lLbound = 0;
  <D.19713>:
  safe_array_create_ms.19 = safe_array_create_ms;
  dim.20 = (unsigned int) dim;
  D.19717 = safe_array_create_ms.19 (12, dim.20, bounds);
  *newsafearray = D.19717;
  D.19689 = 1;
  return D.19689;
}


mono_marshal_safearray_end (void * safearray, void * indices)
{
  <unnamed type> com_provider.21;
  int D.19723;
  int (*<T31d0>) (void *) safe_array_destroy_ms.22;

  monoeg_g_free (indices);
  com_provider.21 = com_provider;
  if (com_provider.21 == 1) goto <D.19722>; else goto <D.19719>;
  <D.19722>:
  D.19723 = init_com_provider_ms ();
  if (D.19723 != 0) goto <D.19724>; else goto <D.19719>;
  <D.19724>:
  safe_array_destroy_ms.22 = safe_array_destroy_ms;
  safe_array_destroy_ms.22 (safearray);
  goto <D.19720>;
  <D.19719>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3089);
  <D.19720>:
}


mono_marshal_safearray_next (void * safearray, void * indices)
{
  unsigned int D.19726;
  int D.19727;
  unsigned int D.19728;
  long unsigned int D.19731;
  long unsigned int D.19732;
  int * D.19733;
  int D.19734;
  int D.19735;
  long int D.19736;
  long int ubound.23;
  long int lbound.24;
  int D.19742;
  gboolean D.19745;
  int i;
  int dim;
  gboolean ret;
  int * pIndices;
  int hr;

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

    try
      {
        D.19727 = i + 1;
        D.19728 = (unsigned int) D.19727;
        hr = mono_marshal_safe_array_get_ubound (safearray, D.19728, &ubound);
        if (hr < 0) goto <D.19729>; else goto <D.19730>;
        <D.19729>:
        cominterop_raise_hr_exception (hr);
        <D.19730>:
        D.19731 = (long unsigned int) i;
        D.19732 = D.19731 * 4;
        D.19733 = pIndices + D.19732;
        D.19734 = *D.19733;
        D.19735 = D.19734 + 1;
        *D.19733 = D.19735;
        D.19734 = *D.19733;
        D.19736 = (long int) D.19734;
        ubound.23 = ubound;
        if (D.19736 <= ubound.23) goto <D.19498>; else goto <D.19738>;
        <D.19738>:
        D.19727 = i + 1;
        D.19728 = (unsigned int) D.19727;
        hr = mono_marshal_safe_array_get_lbound (safearray, D.19728, &lbound);
        if (hr < 0) goto <D.19739>; else goto <D.19740>;
        <D.19739>:
        cominterop_raise_hr_exception (hr);
        <D.19740>:
        D.19731 = (long unsigned int) i;
        D.19732 = D.19731 * 4;
        D.19733 = pIndices + D.19732;
        lbound.24 = lbound;
        D.19742 = (int) lbound.24;
        *D.19733 = D.19742;
        if (i == 0) goto <D.19743>; else goto <D.19744>;
        <D.19743>:
        ret = 0;
        <D.19744>:
      }
    finally
      {
        lbound = {CLOBBER};
        ubound = {CLOBBER};
      }
  }
  i = i + -1;
  <D.19500>:
  if (i >= 0) goto <D.19499>; else goto <D.19498>;
  <D.19498>:
  D.19745 = ret;
  return D.19745;
}


mono_marshal_safearray_get_dim (void * safearray)
{
  <unnamed type> com_provider.25;
  int D.19753;
  guint32 (*<T1816>) (void *) safe_array_get_dim_ms.26;
  guint32 D.19756;
  guint32 result;

  result = 0;
  com_provider.25 = com_provider;
  if (com_provider.25 == 1) goto <D.19752>; else goto <D.19749>;
  <D.19752>:
  D.19753 = init_com_provider_ms ();
  if (D.19753 != 0) goto <D.19754>; else goto <D.19749>;
  <D.19754>:
  safe_array_get_dim_ms.26 = safe_array_get_dim_ms;
  result = safe_array_get_dim_ms.26 (safearray);
  goto <D.19750>;
  <D.19749>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2914);
  <D.19750>:
  D.19756 = result;
  return D.19756;
}


mono_marshal_safe_array_get_ubound (void * psa, guint nDim, glong * plUbound)
{
  <unnamed type> com_provider.27;
  int D.19762;
  int (*<T33de>) (void *, guint32, glong *) safe_array_get_ubound_ms.28;
  int D.19765;
  int result;

  result = 0;
  com_provider.27 = com_provider;
  if (com_provider.27 == 1) goto <D.19761>; else goto <D.19758>;
  <D.19761>:
  D.19762 = init_com_provider_ms ();
  if (D.19762 != 0) goto <D.19763>; else goto <D.19758>;
  <D.19763>:
  safe_array_get_ubound_ms.28 = safe_array_get_ubound_ms;
  result = safe_array_get_ubound_ms.28 (psa, nDim, plUbound);
  goto <D.19759>;
  <D.19758>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2946);
  <D.19759>:
  D.19765 = result;
  return D.19765;
}


mono_marshal_safe_array_get_lbound (void * psa, guint nDim, glong * plLbound)
{
  <unnamed type> com_provider.29;
  int D.19771;
  int (*<T33de>) (void *, guint32, glong *) safe_array_get_lbound_ms.30;
  int D.19774;
  int result;

  result = 0;
  com_provider.29 = com_provider;
  if (com_provider.29 == 1) goto <D.19770>; else goto <D.19767>;
  <D.19770>:
  D.19771 = init_com_provider_ms ();
  if (D.19771 != 0) goto <D.19772>; else goto <D.19767>;
  <D.19772>:
  safe_array_get_lbound_ms.30 = safe_array_get_lbound_ms;
  result = safe_array_get_lbound_ms.30 (psa, nDim, plLbound);
  goto <D.19768>;
  <D.19767>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2930);
  <D.19768>:
  D.19774 = result;
  return D.19774;
}


mono_marshal_safearray_get_value (void * safearray, void * indices)
{
  <unnamed type> com_provider.31;
  int D.19780;
  int (*<T33e6>) (void *, glong *, void * *) safe_array_ptr_of_index_ms.32;
  void * D.19785;
  void * result;

  try
    {
      com_provider.31 = com_provider;
      if (com_provider.31 == 1) goto <D.19779>; else goto <D.19776>;
      <D.19779>:
      D.19780 = init_com_provider_ms ();
      if (D.19780 != 0) goto <D.19781>; else goto <D.19776>;
      <D.19781>:
      {
        int hr;

        safe_array_ptr_of_index_ms.32 = safe_array_ptr_of_index_ms;
        hr = safe_array_ptr_of_index_ms.32 (safearray, indices, &result);
        if (hr < 0) goto <D.19783>; else goto <D.19784>;
        <D.19783>:
        cominterop_raise_hr_exception (hr);
        <D.19784>:
      }
      goto <D.19777>;
      <D.19776>:
      monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 3038);
      <D.19777>:
      D.19785 = result;
      return D.19785;
    }
  finally
    {
      result = {CLOBBER};
    }
}


mono_marshal_safearray_begin (void * safearray, struct MonoArray * * result, void * * indices, void * empty, void * parameter, gboolean allocateNewArray)
{
  <unnamed type> com_provider.33;
  int D.19792;
  gboolean D.19793;
  unsigned int D.19796;
  long unsigned int D.19799;
  long unsigned int D.19800;
  void * D.19801;
  long unsigned int D.19802;
  int D.19803;
  unsigned int D.19804;
  long int lbound.34;
  long int ubound.35;
  unsigned int D.19813;
  unsigned int D.19814;
  unsigned int D.19815;
  unsigned int D.19816;
  long unsigned int D.19817;
  long unsigned int D.19818;
  uintptr_t * D.19819;
  long unsigned int D.19820;
  intptr_t * D.19821;
  void * D.19822;
  long unsigned int D.19823;
  int * D.19824;
  int D.19825;
  unsigned int dim.36;
  struct MonoClass * D.19831;
  struct MonoDomain * D.19832;
  struct MonoArray * D.19833;
  int dim;
  uintptr_t * sizes;
  intptr_t * bounds;
  struct MonoClass * aklass;
  int i;
  gboolean bounded;

  bounded = 0;
  com_provider.33 = com_provider;
  if (com_provider.33 != 1) goto <D.19788>; else goto <D.19791>;
  <D.19791>:
  D.19792 = init_com_provider_ms ();
  if (D.19792 == 0) goto <D.19788>; else goto <D.19789>;
  <D.19788>:
  D.19793 = 0;
  return D.19793;
  <D.19789>:
  MEM[(int *)empty] = 1;
  if (safearray != 0B) goto <D.19794>; else goto <D.19795>;
  <D.19794>:
  D.19796 = mono_marshal_safearray_get_dim (safearray);
  dim = (int) D.19796;
  if (dim > 0) goto <D.19797>; else goto <D.19798>;
  <D.19797>:
  D.19799 = (long unsigned int) dim;
  D.19800 = D.19799 * 4;
  D.19801 = monoeg_malloc (D.19800);
  *indices = D.19801;
  D.19799 = (long unsigned int) dim;
  D.19802 = D.19799 * 8;
  sizes = __builtin_alloca (D.19802);
  D.19799 = (long unsigned int) dim;
  D.19802 = D.19799 * 8;
  bounds = __builtin_alloca (D.19802);
  i = 0;
  goto <D.19479>;
  <D.19478>:
  {
    glong lbound;
    glong ubound;
    int cursize;
    int hr;

    try
      {
        D.19803 = i + 1;
        D.19804 = (unsigned int) D.19803;
        hr = mono_marshal_safe_array_get_lbound (safearray, D.19804, &lbound);
        if (hr < 0) goto <D.19805>; else goto <D.19806>;
        <D.19805>:
        cominterop_raise_hr_exception (hr);
        <D.19806>:
        lbound.34 = lbound;
        if (lbound.34 != 0) goto <D.19808>; else goto <D.19809>;
        <D.19808>:
        bounded = 1;
        <D.19809>:
        D.19803 = i + 1;
        D.19804 = (unsigned int) D.19803;
        hr = mono_marshal_safe_array_get_ubound (safearray, D.19804, &ubound);
        if (hr < 0) goto <D.19810>; else goto <D.19811>;
        <D.19810>:
        cominterop_raise_hr_exception (hr);
        <D.19811>:
        ubound.35 = ubound;
        D.19813 = (unsigned int) ubound.35;
        lbound.34 = lbound;
        D.19814 = (unsigned int) lbound.34;
        D.19815 = D.19813 - D.19814;
        D.19816 = D.19815 + 1;
        cursize = (int) D.19816;
        D.19817 = (long unsigned int) i;
        D.19818 = D.19817 * 8;
        D.19819 = sizes + D.19818;
        D.19820 = (long unsigned int) cursize;
        *D.19819 = D.19820;
        D.19817 = (long unsigned int) i;
        D.19818 = D.19817 * 8;
        D.19821 = bounds + D.19818;
        lbound.34 = lbound;
        *D.19821 = lbound.34;
        D.19822 = *indices;
        D.19817 = (long unsigned int) i;
        D.19823 = D.19817 * 4;
        D.19824 = D.19822 + D.19823;
        lbound.34 = lbound;
        D.19825 = (int) lbound.34;
        *D.19824 = D.19825;
        if (cursize != 0) goto <D.19826>; else goto <D.19827>;
        <D.19826>:
        MEM[(int *)empty] = 0;
        <D.19827>:
      }
    finally
      {
        lbound = {CLOBBER};
        ubound = {CLOBBER};
      }
  }
  i = i + 1;
  <D.19479>:
  if (i < dim) goto <D.19478>; else goto <D.19480>;
  <D.19480>:
  if (allocateNewArray != 0) goto <D.19828>; else goto <D.19829>;
  <D.19828>:
  dim.36 = (unsigned int) dim;
  D.19831 = mono_defaults.object_class;
  aklass = mono_bounded_array_class_get (D.19831, dim.36, bounded);
  D.19832 = mono_domain_get ();
  D.19833 = mono_array_new_full (D.19832, aklass, sizes, bounds);
  *result = D.19833;
  goto <D.19834>;
  <D.19829>:
  *result = parameter;
  <D.19834>:
  <D.19798>:
  <D.19795>:
  D.19793 = 1;
  return D.19793;
}


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

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


cominterop_get_interface (struct MonoComObject * obj, struct MonoClass * ic, gboolean throw_exception)
{
  _Bool D.19838;
  long int D.19839;
  long int D.19840;
  int iftmp.37;
  unsigned int D.19846;
  unsigned int D.19847;
  unsigned char D.19849;
  _Bool D.19852;
  long int D.19853;
  long int D.19854;
  _Bool D.19859;
  long int D.19860;
  long int D.19861;
  struct GHashTable * D.19864;
  short unsigned int D.19867;
  long unsigned int D.19868;
  const void * D.19869;
  void * itf.38;
  _Bool D.19873;
  long int D.19874;
  long int D.19875;
  void * itf.39;
  _Bool D.19881;
  long int D.19882;
  long int D.19883;
  void * D.19886;
  _Bool D.19887;
  _Bool D.19888;
  _Bool D.19889;
  _Bool D.19898;
  long int D.19899;
  long int D.19900;
  struct GHashTable * D.19905;
  void * D.19906;
  _Bool D.19909;
  long int D.19910;
  long int D.19911;
  _Bool D.19916;
  long int D.19917;
  long int D.19918;
  void * D.19921;
  void * itf;

  try
    {
      itf = 0B;
      D.19838 = ic == 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", 473, "ic");
      <D.19842>:
      D.19846 = ic->flags;
      D.19847 = D.19846 & 32;
      if (D.19847 == 0) goto <D.19848>; else goto <D.19844>;
      <D.19848>:
      D.19849 = ic->byval_arg.type;
      if (D.19849 != 19) goto <D.19850>; else goto <D.19844>;
      <D.19850>:
      D.19849 = ic->byval_arg.type;
      if (D.19849 != 30) goto <D.19851>; else goto <D.19844>;
      <D.19851>:
      iftmp.37 = 1;
      goto <D.19845>;
      <D.19844>:
      iftmp.37 = 0;
      <D.19845>:
      D.19852 = iftmp.37 != 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", 474, "MONO_CLASS_IS_INTERFACE (ic)");
      <D.19856>:
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19857>; else goto <D.19858>;
        <D.19857>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.19858>:
        D.19859 = ret != 0;
        D.19860 = (long int) D.19859;
        D.19861 = __builtin_expect (D.19860, 0);
        if (D.19861 != 0) goto <D.19862>; else goto <D.19863>;
        <D.19862>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 476, "ret == 0");
        <D.19863>:
      }
      D.19864 = obj->itf_hash;
      if (D.19864 != 0B) goto <D.19865>; else goto <D.19866>;
      <D.19865>:
      D.19867 = ic->interface_id;
      D.19868 = (long unsigned int) D.19867;
      D.19869 = (const void *) D.19868;
      D.19864 = obj->itf_hash;
      itf.38 = monoeg_g_hash_table_lookup (D.19864, D.19869);
      itf = itf.38;
      <D.19866>:
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19871>; else goto <D.19872>;
        <D.19871>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.19872>:
        D.19873 = ret != 0;
        D.19874 = (long int) D.19873;
        D.19875 = __builtin_expect (D.19874, 0);
        if (D.19875 != 0) goto <D.19876>; else goto <D.19877>;
        <D.19876>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 479, "ret == 0");
        <D.19877>:
      }
      itf.39 = itf;
      if (itf.39 == 0B) goto <D.19879>; else goto <D.19880>;
      <D.19879>:
      {
        guint8 iid[16];
        int found;
        int hr;

        try
          {
            found = cominterop_class_guid (ic, &iid);
            D.19881 = found == 0;
            D.19882 = (long int) D.19881;
            D.19883 = __builtin_expect (D.19882, 0);
            if (D.19883 != 0) goto <D.19884>; else goto <D.19885>;
            <D.19884>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 485, "found");
            <D.19885>:
            D.19886 = obj->iunknown;
            hr = ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (D.19886, &iid, &itf);
            D.19887 = hr < 0;
            D.19888 = throw_exception != 0;
            D.19889 = D.19887 & D.19888;
            if (D.19889 != 0) goto <D.19890>; else goto <D.19891>;
            <D.19890>:
            cominterop_raise_hr_exception (hr);
            <D.19891>:
            if (hr >= 0) goto <D.19892>; else goto <D.19893>;
            <D.19892>:
            itf.39 = itf;
            if (itf.39 != 0B) goto <D.19894>; else goto <D.19895>;
            <D.19894>:
            {
              int ret;

              ret = pthread_mutex_lock (&cominterop_mutex.mutex);
              if (ret != 0) goto <D.19896>; else goto <D.19897>;
              <D.19896>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
              <D.19897>:
              D.19898 = ret != 0;
              D.19899 = (long int) D.19898;
              D.19900 = __builtin_expect (D.19899, 0);
              if (D.19900 != 0) goto <D.19901>; else goto <D.19902>;
              <D.19901>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 492, "ret == 0");
              <D.19902>:
            }
            D.19864 = obj->itf_hash;
            if (D.19864 == 0B) goto <D.19903>; else goto <D.19904>;
            <D.19903>:
            D.19905 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
            obj->itf_hash = D.19905;
            <D.19904>:
            itf.39 = itf;
            D.19867 = ic->interface_id;
            D.19868 = (long unsigned int) D.19867;
            D.19906 = (void *) D.19868;
            D.19864 = obj->itf_hash;
            monoeg_g_hash_table_insert_replace (D.19864, D.19906, itf.39, 0);
            {
              int ret;

              ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
              if (ret != 0) goto <D.19907>; else goto <D.19908>;
              <D.19907>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
              <D.19908>:
              D.19909 = ret != 0;
              D.19910 = (long int) D.19909;
              D.19911 = __builtin_expect (D.19910, 0);
              if (D.19911 != 0) goto <D.19912>; else goto <D.19913>;
              <D.19912>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 496, "ret == 0");
              <D.19913>:
            }
            <D.19895>:
            <D.19893>:
          }
        finally
          {
            iid = {CLOBBER};
          }
      }
      <D.19880>:
      if (throw_exception != 0) goto <D.19914>; else goto <D.19915>;
      <D.19914>:
      itf.39 = itf;
      D.19916 = itf.39 == 0B;
      D.19917 = (long int) D.19916;
      D.19918 = __builtin_expect (D.19917, 0);
      if (D.19918 != 0) goto <D.19919>; else goto <D.19920>;
      <D.19919>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 501, "itf");
      <D.19920>:
      <D.19915>:
      D.19921 = itf;
      return D.19921;
    }
  finally
    {
      itf = {CLOBBER};
    }
}


cominterop_class_guid (struct MonoClass * klass, guint8 * guid)
{
  struct MonoClass * GuidAttribute.40;
  struct MonoImage * D.19927;
  struct MonoClass * GuidAttribute.41;
  gboolean D.19933;
  int D.19934;
  struct MonoString * D.19937;
  static struct MonoClass * GuidAttribute = 0B;
  struct MonoCustomAttrInfo * cinfo;

  GuidAttribute.40 = GuidAttribute;
  if (GuidAttribute.40 == 0B) goto <D.19925>; else goto <D.19926>;
  <D.19925>:
  D.19927 = mono_defaults.corlib;
  GuidAttribute.41 = mono_class_from_name (D.19927, "System.Runtime.InteropServices", "GuidAttribute");
  GuidAttribute = GuidAttribute.41;
  <D.19926>:
  cinfo = mono_custom_attrs_from_class (klass);
  if (cinfo != 0B) goto <D.19929>; else goto <D.19930>;
  <D.19929>:
  {
    struct MonoReflectionGuidAttribute * attr;

    GuidAttribute.40 = GuidAttribute;
    attr = mono_custom_attrs_get_attr (cinfo, GuidAttribute.40);
    if (attr == 0B) goto <D.19931>; else goto <D.19932>;
    <D.19931>:
    D.19933 = 0;
    return D.19933;
    <D.19932>:
    D.19934 = cinfo->cached;
    if (D.19934 == 0) goto <D.19935>; else goto <D.19936>;
    <D.19935>:
    mono_custom_attrs_free (cinfo);
    <D.19936>:
    D.19937 = attr->guid;
    cominterop_mono_string_to_guid (D.19937, guid);
    D.19933 = 1;
    return D.19933;
  }
  <D.19930>:
  D.19933 = 0;
  return D.19933;
}


cominterop_mono_string_to_guid (struct MonoString * string, guint8 * guid)
{
  sizetype D.19939;
  guint8 * D.19940;
  unsigned char D.19941;
  long unsigned int D.19942;
  long unsigned int D.19943;
  gunichar2 * D.19944;
  short unsigned int D.19945;
  unsigned int D.19946;
  int D.19947;
  unsigned char D.19948;
  sizetype D.19949;
  gunichar2 * D.19950;
  short unsigned int D.19951;
  unsigned int D.19952;
  int D.19953;
  unsigned char D.19954;
  unsigned char D.19955;
  unsigned char D.19956;
  unsigned int i.42;
  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.19258>;
  <D.19257>:
  D.19939 = (sizetype) i;
  D.19940 = guid + D.19939;
  D.19941 = indexes[i];
  D.19942 = (long unsigned int) D.19941;
  D.19943 = D.19942 * 2;
  D.19944 = chars + D.19943;
  D.19945 = *D.19944;
  D.19946 = (unsigned int) D.19945;
  D.19947 = monoeg_g_unichar_xdigit_value (D.19946);
  D.19948 = (unsigned char) D.19947;
  D.19941 = indexes[i];
  D.19942 = (long unsigned int) D.19941;
  D.19943 = D.19942 * 2;
  D.19949 = D.19943 + 18446744073709551614;
  D.19950 = chars + D.19949;
  D.19951 = *D.19950;
  D.19952 = (unsigned int) D.19951;
  D.19953 = monoeg_g_unichar_xdigit_value (D.19952);
  D.19954 = (unsigned char) D.19953;
  D.19955 = D.19954 << 4;
  D.19956 = D.19948 + D.19955;
  *D.19940 = D.19956;
  i = i + 1;
  <D.19258>:
  i.42 = (unsigned int) i;
  if (i.42 <= 15) goto <D.19257>; else goto <D.19259>;
  <D.19259>:
}


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

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


cominterop_get_ccw_object (struct MonoCCWInterface * ccw_entry, gboolean verify)
{
  struct GHashTable * ccw_interface_hash.43;
  struct MonoObject * D.19963;
  _Bool D.19967;
  long int D.19968;
  long int D.19969;
  unsigned int D.19974;
  struct MonoCCW * ccw;

  ccw = 0B;
  ccw_interface_hash.43 = ccw_interface_hash;
  if (ccw_interface_hash.43 == 0B) goto <D.19961>; else goto <D.19962>;
  <D.19961>:
  D.19963 = 0B;
  return D.19963;
  <D.19962>:
  if (verify != 0) goto <D.19964>; else goto <D.19965>;
  <D.19964>:
  ccw_interface_hash.43 = ccw_interface_hash;
  ccw = monoeg_g_hash_table_lookup (ccw_interface_hash.43, ccw_entry);
  goto <D.19966>;
  <D.19965>:
  ccw = ccw_entry->ccw;
  D.19967 = ccw == 0B;
  D.19968 = (long int) D.19967;
  D.19969 = __builtin_expect (D.19968, 0);
  if (D.19969 != 0) goto <D.19970>; else goto <D.19971>;
  <D.19970>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1764, "ccw");
  <D.19971>:
  <D.19966>:
  if (ccw != 0B) goto <D.19972>; else goto <D.19973>;
  <D.19972>:
  D.19974 = ccw->gc_handle;
  D.19963 = mono_gchandle_get_target (D.19974);
  return D.19963;
  <D.19973>:
  D.19963 = 0B;
  return D.19963;
}


cominterop_get_ccw (struct MonoObject * object, struct MonoClass * itf)
{
  void * D.19978;
  _Bool D.19981;
  long int D.19982;
  long int D.19983;
  struct GHashTable * ccw_hash.44;
  struct GHashTable * ccw_hash.45;
  struct GHashTable * ccw_interface_hash.46;
  struct GHashTable * ccw_interface_hash.47;
  int D.19994;
  long int D.19995;
  const void * D.19996;
  _Bool D.19999;
  long int D.20000;
  long int D.20001;
  unsigned int D.20004;
  struct MonoObject * D.20005;
  struct GList * iftmp.48;
  void * D.20012;
  void * D.20015;
  struct GHashTable * D.20020;
  unsigned int D.20021;
  _Bool D.20027;
  long int D.20028;
  long int D.20029;
  int D.20032;
  long int D.20033;
  void * D.20034;
  _Bool D.20037;
  long int D.20038;
  long int D.20039;
  struct MonoClass * coclass_attribute.49;
  struct MonoImage * D.20047;
  struct MonoClass * coclass_attribute.50;
  int D.20049;
  int iftmp.51;
  short unsigned int D.20056;
  struct MonoClass * * D.20058;
  struct MonoClass * D.20059;
  _Bool D.20060;
  long int D.20061;
  long int D.20062;
  int D.20065;
  struct MonoClass * D.20068;
  struct MonoClass * D.20072;
  unsigned int D.20076;
  unsigned int method_count.52;
  unsigned int D.20078;
  struct GHashTable * D.20079;
  int D.20082;
  int D.20083;
  long unsigned int D.20084;
  unsigned int D.20085;
  unsigned int D.20086;
  struct MonoImage * D.20087;
  void * * D.20090;
  unsigned int D.20091;
  struct MonoMethod * * D.20092;
  long unsigned int D.20093;
  long unsigned int D.20094;
  struct MonoMethod * * D.20095;
  short unsigned int D.20096;
  int D.20097;
  const char * D.20098;
  short unsigned int D.20099;
  int D.20100;
  int D.20101;
  long unsigned int D.20102;
  long unsigned int D.20103;
  short unsigned int D.20104;
  long unsigned int D.20105;
  long unsigned int D.20106;
  struct MonoMarshalSpec * * D.20107;
  long unsigned int D.20108;
  long unsigned int D.20109;
  struct MonoMarshalSpec * * D.20110;
  struct MonoMarshalSpec * D.20111;
  struct MonoMarshalSpec * D.20112;
  struct MonoType * D.20115;
  unsigned char D.20116;
  void * D.20119;
  void * D.20123;
  void * D.20127;
  void * D.20131;
  unsigned char D.20133;
  _Bool D.20134;
  _Bool D.20135;
  _Bool D.20136;
  short int D.20139;
  short int D.20142;
  unsigned short D.20143;
  unsigned short D.20144;
  short int D.20145;
  struct MonoMarshalSpec * * D.20146;
  struct MonoType * D.20149;
  int D.20150;
  struct MonoMarshalSpec * D.20153;
  int D.20156;
  struct MonoType * D.20157;
  unsigned char D.20158;
  void * D.20161;
  void * D.20165;
  void * D.20169;
  void * D.20173;
  long unsigned int D.20174;
  long unsigned int D.20175;
  struct MonoMarshalSpec * * D.20176;
  _Bool D.20179;
  long int D.20180;
  long int D.20181;
  struct MonoMethodSignature * D.20184;
  short unsigned int D.20185;
  int D.20186;
  int D.20187;
  _Bool D.20190;
  long int D.20191;
  long int D.20192;
  int vtable_index.53;
  long unsigned int D.20196;
  long unsigned int D.20197;
  void * * D.20198;
  void * D.20199;
  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.19976>; else goto <D.19977>;
      <D.19976>:
      D.19978 = 0B;
      return D.19978;
      <D.19977>:
      klass = mono_object_get_class (object);
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19979>; else goto <D.19980>;
        <D.19979>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.19980>:
        D.19981 = ret != 0;
        D.19982 = (long int) D.19981;
        D.19983 = __builtin_expect (D.19982, 0);
        if (D.19983 != 0) goto <D.19984>; else goto <D.19985>;
        <D.19984>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1828, "ret == 0");
        <D.19985>:
      }
      ccw_hash.44 = ccw_hash;
      if (ccw_hash.44 == 0B) goto <D.19987>; else goto <D.19988>;
      <D.19987>:
      ccw_hash.45 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw_hash = ccw_hash.45;
      <D.19988>:
      ccw_interface_hash.46 = ccw_interface_hash;
      if (ccw_interface_hash.46 == 0B) goto <D.19991>; else goto <D.19992>;
      <D.19991>:
      ccw_interface_hash.47 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw_interface_hash = ccw_interface_hash.47;
      <D.19992>:
      D.19994 = mono_object_hash (object);
      D.19995 = (long int) D.19994;
      D.19996 = (const void *) D.19995;
      ccw_hash.44 = ccw_hash;
      ccw_list = monoeg_g_hash_table_lookup (ccw_hash.44, D.19996);
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.19997>; else goto <D.19998>;
        <D.19997>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.19998>:
        D.19999 = ret != 0;
        D.20000 = (long int) D.19999;
        D.20001 = __builtin_expect (D.20000, 0);
        if (D.20001 != 0) goto <D.20002>; else goto <D.20003>;
        <D.20002>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1835, "ret == 0");
        <D.20003>:
      }
      ccw_list_item = ccw_list;
      goto <D.19180>;
      <D.19179>:
      {
        struct MonoCCW * ccw_iter;

        ccw_iter = ccw_list_item->data;
        D.20004 = ccw_iter->gc_handle;
        D.20005 = mono_gchandle_get_target (D.20004);
        if (D.20005 == object) goto <D.20006>; else goto <D.20007>;
        <D.20006>:
        ccw = ccw_iter;
        goto <D.19178>;
        <D.20007>:
        if (ccw_list_item != 0B) goto <D.20009>; else goto <D.20010>;
        <D.20009>:
        iftmp.48 = ccw_list_item->next;
        goto <D.20011>;
        <D.20010>:
        iftmp.48 = 0B;
        <D.20011>:
        ccw_list_item = iftmp.48;
      }
      <D.19180>:
      if (ccw_list_item != 0B) goto <D.19179>; else goto <D.19178>;
      <D.19178>:
      D.20012 = iunknown[0];
      if (D.20012 == 0B) goto <D.20013>; else goto <D.20014>;
      <D.20013>:
      iunknown[0] = cominterop_ccw_queryinterface;
      iunknown[1] = cominterop_ccw_addref;
      iunknown[2] = cominterop_ccw_release;
      <D.20014>:
      D.20015 = idispatch[0];
      if (D.20015 == 0B) goto <D.20016>; else goto <D.20017>;
      <D.20016>:
      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.20017>:
      if (ccw == 0B) goto <D.20018>; else goto <D.20019>;
      <D.20018>:
      ccw = monoeg_malloc0 (16);
      D.20020 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
      ccw->vtable_hash = D.20020;
      ccw->ref_count = 0;
      D.20021 = mono_gchandle_new_weakref (object, 0);
      ccw->gc_handle = D.20021;
      if (ccw_list == 0B) goto <D.20022>; else goto <D.20023>;
      <D.20022>:
      ccw_list = monoeg_g_list_alloc ();
      ccw_list->data = ccw;
      goto <D.20024>;
      <D.20023>:
      ccw_list = monoeg_g_list_append (ccw_list, ccw);
      <D.20024>:
      {
        int ret;

        ret = pthread_mutex_lock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.20025>; else goto <D.20026>;
        <D.20025>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.20026>:
        D.20027 = ret != 0;
        D.20028 = (long int) D.20027;
        D.20029 = __builtin_expect (D.20028, 0);
        if (D.20029 != 0) goto <D.20030>; else goto <D.20031>;
        <D.20030>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1876, "ret == 0");
        <D.20031>:
      }
      D.20032 = mono_object_hash (object);
      D.20033 = (long int) D.20032;
      D.20034 = (void *) D.20033;
      ccw_hash.44 = ccw_hash;
      monoeg_g_hash_table_insert_replace (ccw_hash.44, D.20034, ccw_list, 0);
      {
        int ret;

        ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
        if (ret != 0) goto <D.20035>; else goto <D.20036>;
        <D.20035>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.20036>:
        D.20037 = ret != 0;
        D.20038 = (long int) D.20037;
        D.20039 = __builtin_expect (D.20038, 0);
        if (D.20039 != 0) goto <D.20040>; else goto <D.20041>;
        <D.20040>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1878, "ret == 0");
        <D.20041>:
      }
      mono_object_register_finalizer (object);
      <D.20019>:
      cinfo = mono_custom_attrs_from_class (itf);
      if (cinfo != 0B) goto <D.20042>; else goto <D.20043>;
      <D.20042>:
      {
        static struct MonoClass * coclass_attribute = 0B;

        coclass_attribute.49 = coclass_attribute;
        if (coclass_attribute.49 == 0B) goto <D.20045>; else goto <D.20046>;
        <D.20045>:
        D.20047 = mono_defaults.corlib;
        coclass_attribute.50 = mono_class_from_name (D.20047, "System.Runtime.InteropServices", "CoClassAttribute");
        coclass_attribute = coclass_attribute.50;
        <D.20046>:
        coclass_attribute.49 = coclass_attribute;
        D.20049 = mono_custom_attrs_has_attr (cinfo, coclass_attribute.49);
        if (D.20049 != 0) goto <D.20050>; else goto <D.20051>;
        <D.20050>:
        D.20056 = itf->interface_count;
        if (D.20056 == 0) goto <D.20053>; else goto <D.20057>;
        <D.20057>:
        D.20058 = itf->interfaces;
        D.20059 = *D.20058;
        if (D.20059 == 0B) goto <D.20053>; else goto <D.20054>;
        <D.20053>:
        iftmp.51 = 1;
        goto <D.20055>;
        <D.20054>:
        iftmp.51 = 0;
        <D.20055>:
        D.20060 = iftmp.51 != 0;
        D.20061 = (long int) D.20060;
        D.20062 = __builtin_expect (D.20061, 0);
        if (D.20062 != 0) goto <D.20063>; else goto <D.20064>;
        <D.20063>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1889, "itf->interface_count && itf->interfaces[0]");
        <D.20064>:
        D.20058 = itf->interfaces;
        itf = *D.20058;
        <D.20051>:
        D.20065 = cinfo->cached;
        if (D.20065 == 0) goto <D.20066>; else goto <D.20067>;
        <D.20066>:
        mono_custom_attrs_free (cinfo);
        <D.20067>:
      }
      <D.20043>:
      iface = itf;
      D.20068 = mono_class_get_iunknown_class ();
      if (D.20068 == iface) goto <D.20069>; else goto <D.20070>;
      <D.20069>:
      start_slot = 3;
      goto <D.20071>;
      <D.20070>:
      D.20072 = mono_class_get_idispatch_class ();
      if (D.20072 == iface) goto <D.20073>; else goto <D.20074>;
      <D.20073>:
      start_slot = 7;
      goto <D.20075>;
      <D.20074>:
      D.20076 = iface->method.count;
      method_count.52 = (unsigned int) method_count;
      D.20078 = D.20076 + method_count.52;
      method_count = (int) D.20078;
      start_slot = cominterop_get_com_slot_begin (iface);
      iface = 0B;
      <D.20075>:
      <D.20071>:
      D.20079 = ccw->vtable_hash;
      ccw_entry = monoeg_g_hash_table_lookup (D.20079, itf);
      if (ccw_entry == 0B) goto <D.20080>; else goto <D.20081>;
      <D.20080>:
      {
        int vtable_index;

        D.20082 = method_count + -1;
        vtable_index = D.20082 + start_slot;
        D.20083 = method_count + start_slot;
        D.20084 = (long unsigned int) D.20083;
        D.20085 = (unsigned int) D.20084;
        D.20086 = D.20085 * 8;
        D.20087 = klass->image;
        vtable = mono_image_alloc0 (D.20087, D.20086);
        memcpy (vtable, &iunknown, 24);
        if (start_slot == 7) goto <D.20088>; else goto <D.20089>;
        <D.20088>:
        D.20090 = vtable + 24;
        memcpy (D.20090, &idispatch, 32);
        <D.20089>:
        iface = itf;
        D.20076 = iface->method.count;
        D.20091 = D.20076 + 4294967295;
        i = (int) D.20091;
        goto <D.19204>;
        <D.19203>:
        {
          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.20092 = iface->methods;
          D.20093 = (long unsigned int) i;
          D.20094 = D.20093 * 8;
          D.20095 = D.20092 + D.20094;
          method = *D.20095;
          sig = mono_method_signature (method);
          D.20096 = method->iflags;
          D.20097 = (int) D.20096;
          preserve_sig = D.20097 & 128;
          D.20098 = method->name;
          mb = mono_mb_new (iface, D.20098, 5);
          adjust_method = cominterop_get_managed_wrapper_adjusted (method);
          sig_adjusted = mono_method_signature (adjust_method);
          D.20099 = sig_adjusted->param_count;
          D.20100 = (int) D.20099;
          D.20101 = D.20100 + 1;
          D.20102 = (long unsigned int) D.20101;
          D.20103 = D.20102 * 8;
          mspecs = monoeg_malloc (D.20103);
          mono_method_get_marshal_info (method, mspecs);
          D.20104 = sig->param_count;
          param_index = (int) D.20104;
          goto <D.19196>;
          <D.19195>:
          {
            int mspec_index;

            mspec_index = param_index + 1;
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20108 = (long unsigned int) param_index;
            D.20109 = D.20108 * 8;
            D.20110 = mspecs + D.20109;
            D.20111 = *D.20110;
            *D.20107 = D.20111;
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20112 = *D.20107;
            if (D.20112 == 0B) goto <D.20113>; else goto <D.20114>;
            <D.20113>:
            D.20115 = sig_adjusted->params[param_index];
            D.20116 = D.20115->type;
            if (D.20116 == 28) goto <D.20117>; else goto <D.20118>;
            <D.20117>:
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20119 = monoeg_malloc0 (24);
            *D.20107 = D.20119;
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20112 = *D.20107;
            D.20112->native = 27;
            goto <D.20120>;
            <D.20118>:
            D.20115 = sig_adjusted->params[param_index];
            D.20116 = D.20115->type;
            if (D.20116 == 14) goto <D.20121>; else goto <D.20122>;
            <D.20121>:
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20123 = monoeg_malloc0 (24);
            *D.20107 = D.20123;
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20112 = *D.20107;
            D.20112->native = 19;
            goto <D.20124>;
            <D.20122>:
            D.20115 = sig_adjusted->params[param_index];
            D.20116 = D.20115->type;
            if (D.20116 == 18) goto <D.20125>; else goto <D.20126>;
            <D.20125>:
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20127 = monoeg_malloc0 (24);
            *D.20107 = D.20127;
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20112 = *D.20107;
            D.20112->native = 28;
            goto <D.20128>;
            <D.20126>:
            D.20115 = sig_adjusted->params[param_index];
            D.20116 = D.20115->type;
            if (D.20116 == 2) goto <D.20129>; else goto <D.20130>;
            <D.20129>:
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20131 = monoeg_malloc0 (24);
            *D.20107 = D.20131;
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20112 = *D.20107;
            D.20112->native = 37;
            <D.20130>:
            <D.20128>:
            <D.20124>:
            <D.20120>:
            goto <D.20132>;
            <D.20114>:
            D.20115 = sig_adjusted->params[param_index];
            D.20133 = D.20115->type;
            D.20134 = D.20133 == 20;
            D.20135 = D.20133 == 29;
            D.20136 = D.20134 | D.20135;
            if (D.20136 != 0) goto <D.20137>; else goto <D.20138>;
            <D.20137>:
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20112 = *D.20107;
            D.20139 = D.20112->data.array_data.param_num;
            if (D.20139 != -1) goto <D.20140>; else goto <D.20141>;
            <D.20140>:
            D.20105 = (long unsigned int) mspec_index;
            D.20106 = D.20105 * 8;
            D.20107 = mspecs + D.20106;
            D.20112 = *D.20107;
            D.20139 = D.20112->data.array_data.param_num;
            D.20142 = D.20139;
            D.20143 = (unsigned short) D.20142;
            D.20144 = D.20143 + 1;
            D.20145 = (short int) D.20144;
            D.20112->data.array_data.param_num = D.20145;
            <D.20141>:
            <D.20138>:
            <D.20132>:
          }
          param_index = param_index + -1;
          <D.19196>:
          if (param_index > 0) goto <D.19195>; else goto <D.19197>;
          <D.19197>:
          D.20146 = mspecs + 8;
          *D.20146 = 0B;
          if (preserve_sig == 0) goto <D.20147>; else goto <D.20148>;
          <D.20147>:
          D.20149 = sig->ret;
          D.20150 = mono_type_is_void (D.20149);
          if (D.20150 == 0) goto <D.20151>; else goto <D.20152>;
          <D.20151>:
          D.20153 = *mspecs;
          if (D.20153 == 0B) goto <D.20154>; else goto <D.20155>;
          <D.20154>:
          D.20099 = sig_adjusted->param_count;
          D.20100 = (int) D.20099;
          D.20156 = D.20100 + -1;
          D.20157 = sig_adjusted->params[D.20156];
          D.20158 = D.20157->type;
          if (D.20158 == 28) goto <D.20159>; else goto <D.20160>;
          <D.20159>:
          D.20161 = monoeg_malloc0 (24);
          *mspecs = D.20161;
          D.20153 = *mspecs;
          D.20153->native = 27;
          goto <D.20162>;
          <D.20160>:
          D.20099 = sig_adjusted->param_count;
          D.20100 = (int) D.20099;
          D.20156 = D.20100 + -1;
          D.20157 = sig_adjusted->params[D.20156];
          D.20158 = D.20157->type;
          if (D.20158 == 14) goto <D.20163>; else goto <D.20164>;
          <D.20163>:
          D.20165 = monoeg_malloc0 (24);
          *mspecs = D.20165;
          D.20153 = *mspecs;
          D.20153->native = 19;
          goto <D.20166>;
          <D.20164>:
          D.20099 = sig_adjusted->param_count;
          D.20100 = (int) D.20099;
          D.20156 = D.20100 + -1;
          D.20157 = sig_adjusted->params[D.20156];
          D.20158 = D.20157->type;
          if (D.20158 == 18) goto <D.20167>; else goto <D.20168>;
          <D.20167>:
          D.20169 = monoeg_malloc0 (24);
          *mspecs = D.20169;
          D.20153 = *mspecs;
          D.20153->native = 28;
          goto <D.20170>;
          <D.20168>:
          D.20099 = sig_adjusted->param_count;
          D.20100 = (int) D.20099;
          D.20156 = D.20100 + -1;
          D.20157 = sig_adjusted->params[D.20156];
          D.20158 = D.20157->type;
          if (D.20158 == 2) goto <D.20171>; else goto <D.20172>;
          <D.20171>:
          D.20173 = monoeg_malloc0 (24);
          *mspecs = D.20173;
          D.20153 = *mspecs;
          D.20153->native = 37;
          <D.20172>:
          <D.20170>:
          <D.20166>:
          <D.20162>:
          <D.20155>:
          D.20099 = sig_adjusted->param_count;
          D.20174 = (long unsigned int) D.20099;
          D.20175 = D.20174 * 8;
          D.20176 = mspecs + D.20175;
          D.20153 = *mspecs;
          *D.20176 = D.20153;
          *mspecs = 0B;
          <D.20152>:
          <D.20148>:
          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.20177>; else goto <D.20178>;
            <D.20177>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
            <D.20178>:
            D.20179 = ret != 0;
            D.20180 = (long int) D.20179;
            D.20181 = __builtin_expect (D.20180, 0);
            if (D.20181 != 0) goto <D.20182>; else goto <D.20183>;
            <D.20182>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2003, "ret == 0");
            <D.20183>:
          }
          D.20184 = m.csig;
          D.20185 = D.20184->param_count;
          D.20186 = (int) D.20185;
          D.20187 = D.20186 + 16;
          D.20184 = m.csig;
          wrapper_method = mono_mb_create_method (mb, D.20184, D.20187);
          {
            int ret;

            ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
            if (ret != 0) goto <D.20188>; else goto <D.20189>;
            <D.20188>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.20189>:
            D.20190 = ret != 0;
            D.20191 = (long int) D.20190;
            D.20192 = __builtin_expect (D.20191, 0);
            if (D.20192 != 0) goto <D.20193>; else goto <D.20194>;
            <D.20193>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2005, "ret == 0");
            <D.20194>:
          }
          vtable_index.53 = vtable_index;
          vtable_index = vtable_index.53 + -1;
          D.20196 = (long unsigned int) vtable_index.53;
          D.20197 = D.20196 * 8;
          D.20198 = vtable + D.20197;
          D.20199 = mono_compile_method (wrapper_method);
          *D.20198 = D.20199;
          D.20099 = sig_adjusted->param_count;
          param_index = (int) D.20099;
          goto <D.19201>;
          <D.19200>:
          D.20108 = (long unsigned int) param_index;
          D.20109 = D.20108 * 8;
          D.20110 = mspecs + D.20109;
          D.20111 = *D.20110;
          if (D.20111 != 0B) goto <D.20200>; else goto <D.20201>;
          <D.20200>:
          D.20108 = (long unsigned int) param_index;
          D.20109 = D.20108 * 8;
          D.20110 = mspecs + D.20109;
          D.20111 = *D.20110;
          mono_metadata_free_marshal_spec (D.20111);
          <D.20201>:
          param_index = param_index + -1;
          <D.19201>:
          if (param_index >= 0) goto <D.19200>; else goto <D.19202>;
          <D.19202>:
          monoeg_g_free (mspecs);
        }
        i = i + -1;
        <D.19204>:
        if (i >= 0) goto <D.19203>; else goto <D.19205>;
        <D.19205>:
        ccw_entry = monoeg_malloc0 (16);
        ccw_entry->ccw = ccw;
        ccw_entry->vtable = vtable;
        D.20079 = ccw->vtable_hash;
        monoeg_g_hash_table_insert_replace (D.20079, itf, ccw_entry, 0);
        ccw_interface_hash.46 = ccw_interface_hash;
        monoeg_g_hash_table_insert_replace (ccw_interface_hash.46, ccw_entry, ccw, 0);
      }
      <D.20081>:
      D.19978 = ccw_entry;
      return D.19978;
    }
  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.20204;

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


cominterop_ccw_get_ids_of_names (struct MonoCCWInterface * ccwe, void * riid, gunichar2 * * rgszNames, guint32 cNames, guint32 lcid, gint32 * rgDispId)
{
  unsigned int D.20206;
  _Bool D.20207;
  long int D.20208;
  long int D.20209;
  struct MonoVTable * D.20212;
  struct MonoDomain * D.20213;
  struct MonoDomain * D.20216;
  long unsigned int D.20217;
  long unsigned int D.20218;
  gunichar2 * * D.20219;
  gunichar2 * D.20220;
  long unsigned int D.20223;
  gint32 * D.20224;
  unsigned int D.20225;
  int D.20226;
  unsigned int i.54;
  int D.20229;
  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.20206 = ccw->gc_handle;
  object = mono_gchandle_get_target (D.20206);
  D.20207 = object == 0B;
  D.20208 = (long int) D.20207;
  D.20209 = __builtin_expect (D.20208, 0);
  if (D.20209 != 0) goto <D.20210>; else goto <D.20211>;
  <D.20210>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2418, "object");
  <D.20211>:
  D.20212 = object->vtable;
  klass = D.20212->klass;
  D.20213 = mono_domain_get ();
  if (D.20213 == 0B) goto <D.20214>; else goto <D.20215>;
  <D.20214>:
  D.20216 = mono_get_root_domain ();
  mono_thread_attach (D.20216);
  <D.20215>:
  i = 0;
  goto <D.19323>;
  <D.19322>:
  D.20217 = (long unsigned int) i;
  D.20218 = D.20217 * 8;
  D.20219 = rgszNames + D.20218;
  D.20220 = *D.20219;
  methodname = mono_unicode_to_external (D.20220);
  method = mono_class_get_method_from_name (klass, methodname, -1);
  if (method != 0B) goto <D.20221>; else goto <D.20222>;
  <D.20221>:
  D.20217 = (long unsigned int) i;
  D.20223 = D.20217 * 4;
  D.20224 = rgDispId + D.20223;
  D.20225 = method->token;
  D.20226 = (int) D.20225;
  *D.20224 = D.20226;
  goto <D.20227>;
  <D.20222>:
  D.20217 = (long unsigned int) i;
  D.20223 = D.20217 * 4;
  D.20224 = rgDispId + D.20223;
  *D.20224 = -1;
  ret = -2147352570;
  <D.20227>:
  i = i + 1;
  <D.19323>:
  i.54 = (unsigned int) i;
  if (i.54 < cNames) goto <D.19322>; else goto <D.19324>;
  <D.19324>:
  D.20229 = ret;
  return D.20229;
}


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

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


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

  if (pctinfo == 0B) goto <D.20233>; else goto <D.20234>;
  <D.20233>:
  D.20235 = -2147024809;
  return D.20235;
  <D.20234>:
  *pctinfo = 1;
  D.20235 = 0;
  return D.20235;
}


cominterop_ccw_release (struct MonoCCWInterface * ccwe)
{
  _Bool D.20237;
  long int D.20238;
  long int D.20239;
  unsigned int D.20242;
  _Bool D.20243;
  long int D.20244;
  long int D.20245;
  guint32 * D.20248;
  _Bool D.20251;
  long int D.20252;
  long int D.20253;
  struct MonoObject * D.20256;
  unsigned int D.20257;
  int D.20258;
  gint32 ref_count;
  struct MonoCCW * ccw;

  ref_count = 0;
  ccw = ccwe->ccw;
  D.20237 = ccw == 0B;
  D.20238 = (long int) D.20237;
  D.20239 = __builtin_expect (D.20238, 0);
  if (D.20239 != 0) goto <D.20240>; else goto <D.20241>;
  <D.20240>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2272, "ccw");
  <D.20241>:
  D.20242 = ccw->ref_count;
  D.20243 = D.20242 == 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", 2273, "ccw->ref_count > 0");
  <D.20247>:
  D.20248 = &ccw->ref_count;
  ref_count = InterlockedDecrement (D.20248);
  if (ref_count == 0) goto <D.20249>; else goto <D.20250>;
  <D.20249>:
  {
    guint32 oldhandle;

    oldhandle = ccw->gc_handle;
    D.20251 = oldhandle == 0;
    D.20252 = (long int) D.20251;
    D.20253 = __builtin_expect (D.20252, 0);
    if (D.20253 != 0) goto <D.20254>; else goto <D.20255>;
    <D.20254>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2278, "oldhandle");
    <D.20255>:
    D.20256 = mono_gchandle_get_target (oldhandle);
    D.20257 = mono_gchandle_new_weakref (D.20256, 0);
    ccw->gc_handle = D.20257;
    mono_gchandle_free (oldhandle);
  }
  <D.20250>:
  D.20258 = ref_count;
  return D.20258;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.20260;
  unsigned int D.20261;

  D.20261 = __sync_sub_and_fetch_4 (val, 1);
  D.20260 = (gint32) D.20261;
  return D.20260;
}


cominterop_ccw_addref (struct MonoCCWInterface * ccwe)
{
  _Bool D.20263;
  long int D.20264;
  long int D.20265;
  unsigned int D.20268;
  _Bool D.20269;
  long int D.20270;
  long int D.20271;
  guint32 * D.20276;
  _Bool D.20279;
  long int D.20280;
  long int D.20281;
  struct MonoObject * D.20284;
  unsigned int D.20285;
  int D.20286;
  gint32 ref_count;
  struct MonoCCW * ccw;

  ref_count = 0;
  ccw = ccwe->ccw;
  D.20263 = ccw == 0B;
  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", 2253, "ccw");
  <D.20267>:
  D.20268 = ccw->gc_handle;
  D.20269 = D.20268 == 0;
  D.20270 = (long int) D.20269;
  D.20271 = __builtin_expect (D.20270, 0);
  if (D.20271 != 0) goto <D.20272>; else goto <D.20273>;
  <D.20272>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2254, "ccw->gc_handle");
  <D.20273>:
  if (0 != 0) goto <D.20274>; else goto <D.20275>;
  <D.20274>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2255, "ccw->ref_count >= 0");
  <D.20275>:
  D.20276 = &ccw->ref_count;
  ref_count = InterlockedIncrement (D.20276);
  if (ref_count == 1) goto <D.20277>; else goto <D.20278>;
  <D.20277>:
  {
    guint32 oldhandle;

    oldhandle = ccw->gc_handle;
    D.20279 = oldhandle == 0;
    D.20280 = (long int) D.20279;
    D.20281 = __builtin_expect (D.20280, 0);
    if (D.20281 != 0) goto <D.20282>; else goto <D.20283>;
    <D.20282>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2259, "oldhandle");
    <D.20283>:
    D.20284 = mono_gchandle_get_target (oldhandle);
    D.20285 = mono_gchandle_new (D.20284, 0);
    ccw->gc_handle = D.20285;
    mono_gchandle_free (oldhandle);
  }
  <D.20278>:
  D.20286 = ref_count;
  return D.20286;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.20288;
  unsigned int D.20289;

  D.20289 = __sync_add_and_fetch_4 (val, 1);
  D.20288 = (gint32) D.20289;
  return D.20288;
}


cominterop_ccw_queryinterface (struct MonoCCWInterface * ccwe, guint8 * riid, void * * ppv)
{
  unsigned int D.20291;
  _Bool D.20292;
  long int D.20293;
  long int D.20294;
  struct MonoVTable * D.20297;
  struct MonoDomain * D.20300;
  struct MonoDomain * D.20303;
  struct MonoClass * D.20304;
  int D.20305;
  struct MonoClass * D.20308;
  void * D.20309;
  void * D.20310;
  int D.20311;
  struct MonoClass * D.20312;
  int D.20313;
  int D.20316;
  struct MonoClass * D.20319;
  void * D.20320;
  int D.20321;
  _Bool D.20322;
  long int D.20323;
  long int D.20324;
  void * * D.20329;
  long unsigned int D.20330;
  long unsigned int D.20331;
  void * * D.20332;
  int D.20333;
  unsigned int i.55;
  unsigned int D.20337;
  struct MonoClass * D.20340;
  void * D.20343;
  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.20291 = ccw->gc_handle;
      object = mono_gchandle_get_target (D.20291);
      D.20292 = object == 0B;
      D.20293 = (long int) D.20292;
      D.20294 = __builtin_expect (D.20293, 0);
      if (D.20294 != 0) goto <D.20295>; else goto <D.20296>;
      <D.20295>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2324, "object");
      <D.20296>:
      D.20297 = object->vtable;
      klass = D.20297->klass;
      if (ppv != 0B) goto <D.20298>; else goto <D.20299>;
      <D.20298>:
      *ppv = 0B;
      <D.20299>:
      D.20300 = mono_domain_get ();
      if (D.20300 == 0B) goto <D.20301>; else goto <D.20302>;
      <D.20301>:
      D.20303 = mono_get_root_domain ();
      mono_thread_attach (D.20303);
      <D.20302>:
      D.20304 = mono_class_get_iunknown_class ();
      D.20305 = cominterop_class_guid_equal (riid, D.20304);
      if (D.20305 != 0) goto <D.20306>; else goto <D.20307>;
      <D.20306>:
      D.20308 = mono_class_get_iunknown_class ();
      D.20309 = cominterop_get_ccw (object, D.20308);
      *ppv = D.20309;
      D.20310 = *ppv;
      cominterop_ccw_addref (D.20310);
      D.20311 = 0;
      return D.20311;
      <D.20307>:
      D.20312 = mono_class_get_idispatch_class ();
      D.20313 = cominterop_class_guid_equal (riid, D.20312);
      if (D.20313 != 0) goto <D.20314>; else goto <D.20315>;
      <D.20314>:
      D.20316 = cominterop_can_support_dispatch (klass);
      if (D.20316 == 0) goto <D.20317>; else goto <D.20318>;
      <D.20317>:
      D.20311 = -2147467262;
      return D.20311;
      <D.20318>:
      D.20319 = mono_class_get_idispatch_class ();
      D.20320 = cominterop_get_ccw (object, D.20319);
      *ppv = D.20320;
      D.20310 = *ppv;
      cominterop_ccw_addref (D.20310);
      D.20311 = 0;
      return D.20311;
      <D.20315>:
      klass_iter = klass;
      goto <D.19296>;
      <D.19295>:
      ifaces = mono_class_get_implemented_interfaces (klass_iter, &error);
      D.20321 = mono_error_ok (&error);
      D.20322 = D.20321 == 0;
      D.20323 = (long int) D.20322;
      D.20324 = __builtin_expect (D.20323, 0);
      if (D.20324 != 0) goto <D.20325>; else goto <D.20326>;
      <D.20325>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2361, "mono_error_ok (&error)");
      <D.20326>:
      if (ifaces != 0B) goto <D.20327>; else goto <D.20328>;
      <D.20327>:
      i = 0;
      goto <D.19293>;
      <D.19292>:
      {
        struct MonoClass * ic;

        ic = 0B;
        D.20329 = ifaces->pdata;
        D.20330 = (long unsigned int) i;
        D.20331 = D.20330 * 8;
        D.20332 = D.20329 + D.20331;
        ic = *D.20332;
        D.20333 = cominterop_class_guid_equal (riid, ic);
        if (D.20333 != 0) goto <D.20334>; else goto <D.20335>;
        <D.20334>:
        itf = ic;
        goto <D.19291>;
        <D.20335>:
      }
      i = i + 1;
      <D.19293>:
      i.55 = (unsigned int) i;
      D.20337 = ifaces->len;
      if (i.55 < D.20337) goto <D.19292>; else goto <D.19291>;
      <D.19291>:
      monoeg_g_ptr_array_free (ifaces, 1);
      <D.20328>:
      if (itf != 0B) goto <D.19294>; else goto <D.20338>;
      <D.20338>:
      klass_iter = klass_iter->parent;
      <D.19296>:
      if (klass_iter != 0B) goto <D.20339>; else goto <D.19294>;
      <D.20339>:
      D.20340 = mono_defaults.object_class;
      if (D.20340 != klass_iter) goto <D.19295>; else goto <D.19294>;
      <D.19294>:
      if (itf != 0B) goto <D.20341>; else goto <D.20342>;
      <D.20341>:
      D.20343 = cominterop_get_ccw (object, itf);
      *ppv = D.20343;
      D.20310 = *ppv;
      cominterop_ccw_addref (D.20310);
      D.20311 = 0;
      return D.20311;
      <D.20342>:
      D.20311 = -2147467262;
      return D.20311;
    }
  finally
    {
      error = {CLOBBER};
    }
}


cominterop_can_support_dispatch (struct MonoClass * klass)
{
  unsigned int D.20346;
  unsigned int D.20347;
  gboolean D.20350;
  int D.20351;

  D.20346 = klass->flags;
  D.20347 = D.20346 & 1;
  if (D.20347 == 0) goto <D.20348>; else goto <D.20349>;
  <D.20348>:
  D.20350 = 0;
  return D.20350;
  <D.20349>:
  D.20351 = cominterop_com_visible (klass);
  if (D.20351 == 0) goto <D.20352>; else goto <D.20353>;
  <D.20352>:
  D.20350 = 0;
  return D.20350;
  <D.20353>:
  D.20350 = 1;
  return D.20350;
}


cominterop_com_visible (struct MonoClass * klass)
{
  struct MonoClass * ComVisibleAttribute.56;
  struct MonoImage * D.20358;
  struct MonoClass * ComVisibleAttribute.57;
  int D.20364;
  gboolean D.20369;
  int D.20370;
  _Bool D.20371;
  long int D.20372;
  long int D.20373;
  void * * D.20378;
  long unsigned int D.20379;
  long unsigned int D.20380;
  void * * D.20381;
  unsigned int D.20382;
  unsigned int D.20383;
  unsigned int i.58;
  unsigned int D.20387;
  static struct MonoClass * ComVisibleAttribute = 0B;
  struct MonoError error;
  struct MonoCustomAttrInfo * cinfo;
  struct GPtrArray * ifaces;
  MonoBoolean visible;

  try
    {
      visible = 1;
      ComVisibleAttribute.56 = ComVisibleAttribute;
      if (ComVisibleAttribute.56 == 0B) goto <D.20356>; else goto <D.20357>;
      <D.20356>:
      D.20358 = mono_defaults.corlib;
      ComVisibleAttribute.57 = mono_class_from_name (D.20358, "System.Runtime.InteropServices", "ComVisibleAttribute");
      ComVisibleAttribute = ComVisibleAttribute.57;
      <D.20357>:
      cinfo = mono_custom_attrs_from_class (klass);
      if (cinfo != 0B) goto <D.20360>; else goto <D.20361>;
      <D.20360>:
      {
        struct MonoReflectionComVisibleAttribute * attr;

        ComVisibleAttribute.56 = ComVisibleAttribute;
        attr = mono_custom_attrs_get_attr (cinfo, ComVisibleAttribute.56);
        if (attr != 0B) goto <D.20362>; else goto <D.20363>;
        <D.20362>:
        visible = attr->visible;
        <D.20363>:
        D.20364 = cinfo->cached;
        if (D.20364 == 0) goto <D.20365>; else goto <D.20366>;
        <D.20365>:
        mono_custom_attrs_free (cinfo);
        <D.20366>:
        if (visible != 0) goto <D.20367>; else goto <D.20368>;
        <D.20367>:
        D.20369 = 1;
        return D.20369;
        <D.20368>:
      }
      <D.20361>:
      ifaces = mono_class_get_implemented_interfaces (klass, &error);
      D.20370 = mono_error_ok (&error);
      D.20371 = D.20370 == 0;
      D.20372 = (long int) D.20371;
      D.20373 = __builtin_expect (D.20372, 0);
      if (D.20373 != 0) goto <D.20374>; else goto <D.20375>;
      <D.20374>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 434, "mono_error_ok (&error)");
      <D.20375>:
      if (ifaces != 0B) goto <D.20376>; else goto <D.20377>;
      <D.20376>:
      {
        int i;

        i = 0;
        goto <D.18834>;
        <D.18833>:
        {
          struct MonoClass * ic;

          ic = 0B;
          D.20378 = ifaces->pdata;
          D.20379 = (long unsigned int) i;
          D.20380 = D.20379 * 8;
          D.20381 = D.20378 + D.20380;
          ic = *D.20381;
          D.20382 = ic->flags;
          D.20383 = D.20382 & 4096;
          if (D.20383 != 0) goto <D.20384>; else goto <D.20385>;
          <D.20384>:
          visible = 1;
          <D.20385>:
        }
        i = i + 1;
        <D.18834>:
        i.58 = (unsigned int) i;
        D.20387 = ifaces->len;
        if (i.58 < D.20387) goto <D.18833>; else goto <D.18835>;
        <D.18835>:
        monoeg_g_ptr_array_free (ifaces, 1);
      }
      <D.20377>:
      D.20369 = (gboolean) visible;
      return D.20369;
    }
  finally
    {
      error = {CLOBBER};
    }
}


cominterop_class_guid_equal (guint8 * guid, struct MonoClass * klass)
{
  int D.20390;
  gboolean D.20393;
  int D.20394;
  _Bool D.20395;
  guint8 klass_guid[16];

  try
    {
      D.20390 = cominterop_class_guid (klass, &klass_guid);
      if (D.20390 != 0) goto <D.20391>; else goto <D.20392>;
      <D.20391>:
      D.20394 = memcmp (guid, &klass_guid, 16);
      D.20395 = D.20394 == 0;
      D.20393 = (gboolean) D.20395;
      return D.20393;
      <D.20392>:
      D.20393 = 0;
      return D.20393;
    }
  finally
    {
      klass_guid = {CLOBBER};
    }
}


cominterop_get_com_slot_begin (struct MonoClass * klass)
{
  struct MonoClass * interface_type_attribute.59;
  struct MonoImage * D.20401;
  struct MonoClass * interface_type_attribute.60;
  int D.20405;
  unsigned int D.20410;
  int D.20412;
  static struct MonoClass * interface_type_attribute = 0B;
  struct MonoCustomAttrInfo * cinfo;
  struct MonoInterfaceTypeAttribute * itf_attr;

  cinfo = 0B;
  itf_attr = 0B;
  interface_type_attribute.59 = interface_type_attribute;
  if (interface_type_attribute.59 == 0B) goto <D.20399>; else goto <D.20400>;
  <D.20399>:
  D.20401 = mono_defaults.corlib;
  interface_type_attribute.60 = mono_class_from_name (D.20401, "System.Runtime.InteropServices", "InterfaceTypeAttribute");
  interface_type_attribute = interface_type_attribute.60;
  <D.20400>:
  cinfo = mono_custom_attrs_from_class (klass);
  if (cinfo != 0B) goto <D.20403>; else goto <D.20404>;
  <D.20403>:
  interface_type_attribute.59 = interface_type_attribute;
  itf_attr = mono_custom_attrs_get_attr (cinfo, interface_type_attribute.59);
  D.20405 = cinfo->cached;
  if (D.20405 == 0) goto <D.20406>; else goto <D.20407>;
  <D.20406>:
  mono_custom_attrs_free (cinfo);
  <D.20407>:
  <D.20404>:
  if (itf_attr != 0B) goto <D.20409>; else goto <D.20408>;
  <D.20409>:
  D.20410 = itf_attr->intType;
  if (D.20410 == 1) goto <D.20411>; else goto <D.20408>;
  <D.20411>:
  D.20412 = 3;
  return D.20412;
  <D.20408>:
  D.20412 = 7;
  return D.20412;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.20414;
  long unsigned int D.20415;

  D.20415 = __builtin_object_size (__dest, 0);
  D.20414 = __builtin___memcpy_chk (__dest, __src, __len, D.20415);
  return D.20414;
}


cominterop_get_managed_wrapper_adjusted (struct MonoMethod * method)
{
  short unsigned int D.20417;
  int D.20418;
  struct MonoMethod * get_hr_for_exception.61;
  struct MonoClass * D.20422;
  struct MonoMethod * get_hr_for_exception.62;
  const char * D.20424;
  struct MonoClass * D.20425;
  short unsigned int D.20426;
  int D.20427;
  int D.20428;
  long unsigned int D.20429;
  long unsigned int D.20430;
  short unsigned int D.20431;
  sizetype D.20432;
  sizetype D.20433;
  sizetype D.20434;
  struct MonoMarshalSpec * * D.20435;
  long unsigned int D.20436;
  long unsigned int D.20437;
  struct MonoMarshalSpec * * D.20438;
  struct MonoMarshalSpec * D.20439;
  struct MonoMarshalSpec * * D.20440;
  struct MonoType * D.20443;
  int D.20444;
  long unsigned int D.20447;
  long unsigned int D.20448;
  struct MonoMarshalSpec * * D.20449;
  struct MonoMarshalSpec * D.20450;
  struct MonoClass * D.20453;
  struct MonoType * D.20454;
  int D.20456;
  int D.20459;
  unsigned int D.20460;
  int D.20463;
  int D.20466;
  unsigned int D.20467;
  int D.20468;
  unsigned int D.20469;
  int D.20470;
  int D.20471;
  unsigned char D.20476;
  unsigned char D.20477;
  unsigned int D.20481;
  unsigned char D.20482;
  int D.20483;
  unsigned int hr.63;
  unsigned int D.20486;
  int D.20487;
  unsigned int D.20488;
  unsigned int D.20489;
  unsigned int D.20490;
  struct MonoClass * D.20491;
  int D.20492;
  unsigned int D.20493;
  unsigned char D.20499;
  unsigned char D.20500;
  unsigned char D.20502;
  unsigned char D.20503;
  int D.20504;
  unsigned int D.20505;
  unsigned int D.20506;
  unsigned int D.20507;
  unsigned int pos_leave.64;
  int D.20512;
  _Bool D.20515;
  long int D.20516;
  long int D.20517;
  int D.20520;
  _Bool D.20523;
  long int D.20524;
  long int D.20525;
  struct MonoMethod * D.20530;
  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.20417 = method->iflags;
  D.20418 = (int) D.20417;
  preserve_sig = D.20418 & 128;
  get_hr_for_exception.61 = get_hr_for_exception;
  if (get_hr_for_exception.61 == 0B) goto <D.20420>; else goto <D.20421>;
  <D.20420>:
  D.20422 = mono_defaults.marshal_class;
  get_hr_for_exception.62 = mono_class_get_method_from_name (D.20422, "GetHRForException", -1);
  get_hr_for_exception = get_hr_for_exception.62;
  <D.20421>:
  sig = mono_method_signature (method);
  D.20424 = method->name;
  D.20425 = method->klass;
  mb = mono_mb_new (D.20425, D.20424, 27);
  sig_native = cominterop_method_signature (method);
  D.20426 = sig_native->param_count;
  D.20427 = (int) D.20426;
  D.20428 = D.20427 + 1;
  D.20429 = (long unsigned int) D.20428;
  D.20430 = D.20429 * 8;
  mspecs = monoeg_malloc0 (D.20430);
  mono_method_get_marshal_info (method, mspecs);
  D.20431 = sig->param_count;
  i = (int) D.20431;
  goto <D.19239>;
  <D.19238>:
  D.20432 = (sizetype) i;
  D.20433 = D.20432 + 1;
  D.20434 = D.20433 * 8;
  D.20435 = mspecs + D.20434;
  D.20436 = (long unsigned int) i;
  D.20437 = D.20436 * 8;
  D.20438 = mspecs + D.20437;
  D.20439 = *D.20438;
  *D.20435 = D.20439;
  i = i + -1;
  <D.19239>:
  if (i > 0) goto <D.19238>; else goto <D.19240>;
  <D.19240>:
  D.20440 = mspecs + 8;
  *D.20440 = 0B;
  if (preserve_sig == 0) goto <D.20441>; else goto <D.20442>;
  <D.20441>:
  D.20443 = sig->ret;
  D.20444 = mono_type_is_void (D.20443);
  if (D.20444 == 0) goto <D.20445>; else goto <D.20446>;
  <D.20445>:
  D.20426 = sig_native->param_count;
  D.20447 = (long unsigned int) D.20426;
  D.20448 = D.20447 * 8;
  D.20449 = mspecs + D.20448;
  D.20450 = *mspecs;
  *D.20449 = D.20450;
  <D.20446>:
  <D.20442>:
  *mspecs = 0B;
  if (preserve_sig == 0) goto <D.20451>; else goto <D.20452>;
  <D.20451>:
  D.20453 = mono_defaults.int32_class;
  D.20454 = &D.20453->byval_arg;
  hr = mono_mb_add_local (mb, D.20454);
  goto <D.20455>;
  <D.20452>:
  D.20443 = sig->ret;
  D.20456 = mono_type_is_void (D.20443);
  if (D.20456 == 0) goto <D.20457>; else goto <D.20458>;
  <D.20457>:
  D.20443 = sig->ret;
  hr = mono_mb_add_local (mb, D.20443);
  <D.20458>:
  <D.20455>:
  main_clause = monoeg_malloc0 (32);
  D.20459 = mono_mb_get_label (mb);
  D.20460 = (unsigned int) D.20459;
  main_clause->try_offset = D.20460;
  if (preserve_sig == 0) goto <D.20461>; else goto <D.20462>;
  <D.20461>:
  D.20443 = sig->ret;
  D.20463 = mono_type_is_void (D.20443);
  if (D.20463 == 0) goto <D.20464>; else goto <D.20465>;
  <D.20464>:
  D.20426 = sig_native->param_count;
  D.20427 = (int) D.20426;
  D.20466 = D.20427 + -1;
  D.20467 = (unsigned int) D.20466;
  mono_mb_emit_ldarg (mb, D.20467);
  <D.20465>:
  <D.20462>:
  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.19242>;
  <D.19241>:
  D.20468 = i + 1;
  D.20469 = (unsigned int) D.20468;
  mono_mb_emit_ldarg (mb, D.20469);
  i = i + 1;
  <D.19242>:
  D.20431 = sig->param_count;
  D.20470 = (int) D.20431;
  if (D.20470 > i) goto <D.19241>; else goto <D.19243>;
  <D.19243>:
  mono_mb_emit_managed_call (mb, method, 0B);
  D.20443 = sig->ret;
  D.20471 = mono_type_is_void (D.20443);
  if (D.20471 == 0) goto <D.20472>; else goto <D.20473>;
  <D.20472>:
  if (preserve_sig == 0) goto <D.20474>; else goto <D.20475>;
  <D.20474>:
  {
    struct MonoClass * rclass;

    D.20443 = sig->ret;
    rclass = mono_class_from_mono_type (D.20443);
    D.20476 = BIT_FIELD_REF <*rclass, 8, 256>;
    D.20477 = D.20476 & 8;
    if (D.20477 != 0) goto <D.20478>; else goto <D.20479>;
    <D.20478>:
    mono_mb_emit_op (mb, 129, rclass);
    goto <D.20480>;
    <D.20479>:
    D.20443 = sig->ret;
    D.20481 = mono_type_to_stind (D.20443);
    D.20482 = (unsigned char) D.20481;
    D.20483 = (int) D.20482;
    mono_mb_emit_byte (mb, D.20483);
    <D.20480>:
  }
  goto <D.20484>;
  <D.20475>:
  hr.63 = (unsigned int) hr;
  mono_mb_emit_stloc (mb, hr.63);
  <D.20484>:
  <D.20473>:
  D.20486 = mono_mb_emit_branch (mb, 221);
  pos_leave = (int) D.20486;
  main_clause->flags = 0;
  D.20487 = mono_mb_get_pos (mb);
  D.20488 = (unsigned int) D.20487;
  D.20489 = main_clause->try_offset;
  D.20490 = D.20488 - D.20489;
  main_clause->try_len = D.20490;
  D.20491 = mono_defaults.object_class;
  main_clause->data.catch_class = D.20491;
  D.20492 = mono_mb_get_label (mb);
  D.20493 = (unsigned int) D.20492;
  main_clause->handler_offset = D.20493;
  if (preserve_sig == 0) goto <D.20494>; else goto <D.20497>;
  <D.20497>:
  D.20443 = sig->ret;
  if (D.20443 != 0B) goto <D.20498>; else goto <D.20495>;
  <D.20498>:
  D.20443 = sig->ret;
  D.20499 = BIT_FIELD_REF <*D.20443, 8, 88>;
  D.20500 = D.20499 & 64;
  if (D.20500 == 0) goto <D.20501>; else goto <D.20495>;
  <D.20501>:
  D.20443 = sig->ret;
  D.20502 = D.20443->type;
  D.20503 = D.20502 + 248;
  if (D.20503 <= 1) goto <D.20494>; else goto <D.20495>;
  <D.20494>:
  get_hr_for_exception.61 = get_hr_for_exception;
  mono_mb_emit_managed_call (mb, get_hr_for_exception.61, 0B);
  hr.63 = (unsigned int) hr;
  mono_mb_emit_stloc (mb, hr.63);
  goto <D.20496>;
  <D.20495>:
  mono_mb_emit_byte (mb, 38);
  <D.20496>:
  mono_mb_emit_branch (mb, 221);
  D.20504 = mono_mb_get_pos (mb);
  D.20505 = (unsigned int) D.20504;
  D.20506 = main_clause->handler_offset;
  D.20507 = D.20505 - D.20506;
  main_clause->handler_len = D.20507;
  mono_mb_set_clauses (mb, 1, main_clause);
  pos_leave.64 = (unsigned int) pos_leave;
  mono_mb_patch_branch (mb, pos_leave.64);
  if (preserve_sig == 0) goto <D.20509>; else goto <D.20511>;
  <D.20511>:
  D.20443 = sig->ret;
  D.20512 = mono_type_is_void (D.20443);
  if (D.20512 == 0) goto <D.20509>; else goto <D.20510>;
  <D.20509>:
  hr.63 = (unsigned int) hr;
  mono_mb_emit_ldloc (mb, hr.63);
  <D.20510>:
  mono_mb_emit_byte (mb, 42);
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.20513>; else goto <D.20514>;
    <D.20513>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.20514>:
    D.20515 = ret != 0;
    D.20516 = (long int) D.20515;
    D.20517 = __builtin_expect (D.20516, 0);
    if (D.20517 != 0) goto <D.20518>; else goto <D.20519>;
    <D.20518>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2209, "ret == 0");
    <D.20519>:
  }
  D.20426 = sig_native->param_count;
  D.20427 = (int) D.20426;
  D.20520 = D.20427 + 16;
  res = mono_mb_create_method (mb, sig_native, D.20520);
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.20521>; else goto <D.20522>;
    <D.20521>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.20522>:
    D.20523 = ret != 0;
    D.20524 = (long int) D.20523;
    D.20525 = __builtin_expect (D.20524, 0);
    if (D.20525 != 0) goto <D.20526>; else goto <D.20527>;
    <D.20526>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2211, "ret == 0");
    <D.20527>:
  }
  mono_mb_free (mb);
  D.20426 = sig_native->param_count;
  i = (int) D.20426;
  goto <D.19248>;
  <D.19247>:
  D.20436 = (long unsigned int) i;
  D.20437 = D.20436 * 8;
  D.20438 = mspecs + D.20437;
  D.20439 = *D.20438;
  if (D.20439 != 0B) goto <D.20528>; else goto <D.20529>;
  <D.20528>:
  D.20436 = (long unsigned int) i;
  D.20437 = D.20436 * 8;
  D.20438 = mspecs + D.20437;
  D.20439 = *D.20438;
  mono_metadata_free_marshal_spec (D.20439);
  <D.20529>:
  i = i + -1;
  <D.19248>:
  if (i >= 0) goto <D.19247>; else goto <D.19249>;
  <D.19249>:
  monoeg_g_free (mspecs);
  D.20530 = res;
  return D.20530;
}


cominterop_method_signature (struct MonoMethod * method)
{
  struct MonoClass * D.20532;
  short unsigned int D.20533;
  int D.20534;
  short unsigned int D.20535;
  int D.20536;
  struct MonoType * D.20539;
  int D.20540;
  unsigned int param_count.65;
  long unsigned int D.20544;
  long unsigned int D.20545;
  unsigned int D.20546;
  unsigned int D.20547;
  long unsigned int D.20548;
  int D.20549;
  struct MonoType * D.20550;
  struct MonoClass * D.20551;
  struct MonoType * D.20552;
  int D.20556;
  int D.20559;
  struct MonoType * D.20560;
  struct MonoType * D.20561;
  struct MonoClass * D.20562;
  struct MonoType * D.20563;
  short unsigned int D.20564;
  struct MonoMethodSignature * D.20565;
  struct MonoMethodSignature * res;
  struct MonoImage * image;
  struct MonoMethodSignature * sig;
  gboolean preserve_sig;
  int sigsize;
  int i;
  int param_count;

  D.20532 = method->klass;
  image = D.20532->image;
  sig = mono_method_signature (method);
  D.20533 = method->iflags;
  D.20534 = (int) D.20533;
  preserve_sig = D.20534 & 128;
  D.20535 = sig->param_count;
  D.20536 = (int) D.20535;
  param_count = D.20536 + 1;
  if (preserve_sig == 0) goto <D.20537>; else goto <D.20538>;
  <D.20537>:
  D.20539 = sig->ret;
  D.20540 = mono_type_is_void (D.20539);
  if (D.20540 == 0) goto <D.20541>; else goto <D.20542>;
  <D.20541>:
  param_count = param_count + 1;
  <D.20542>:
  <D.20538>:
  param_count.65 = (unsigned int) param_count;
  res = mono_metadata_signature_alloc (image, param_count.65);
  D.20535 = sig->param_count;
  D.20544 = (long unsigned int) D.20535;
  D.20545 = D.20544 + 2;
  D.20546 = (unsigned int) D.20545;
  D.20547 = D.20546 * 8;
  sigsize = (int) D.20547;
  D.20548 = (long unsigned int) sigsize;
  memcpy (res, sig, D.20548);
  D.20535 = sig->param_count;
  D.20536 = (int) D.20535;
  i = D.20536 + -1;
  goto <D.18768>;
  <D.18767>:
  D.20549 = i + 1;
  D.20550 = sig->params[i];
  res->params[D.20549] = D.20550;
  i = i + -1;
  <D.18768>:
  if (i >= 0) goto <D.18767>; else goto <D.18769>;
  <D.18769>:
  D.20551 = mono_defaults.int_class;
  D.20552 = &D.20551->byval_arg;
  res->params[0] = D.20552;
  if (preserve_sig != 0) goto <D.20553>; else goto <D.20554>;
  <D.20553>:
  D.20539 = sig->ret;
  res->ret = D.20539;
  goto <D.20555>;
  <D.20554>:
  D.20539 = sig->ret;
  D.20556 = mono_type_is_void (D.20539);
  if (D.20556 == 0) goto <D.20557>; else goto <D.20558>;
  <D.20557>:
  D.20559 = param_count + -1;
  D.20539 = sig->ret;
  D.20560 = mono_metadata_type_dup (image, D.20539);
  res->params[D.20559] = D.20560;
  D.20559 = param_count + -1;
  D.20561 = res->params[D.20559];
  D.20561->byref = 1;
  D.20559 = param_count + -1;
  D.20561 = res->params[D.20559];
  D.20561->attrs = 2;
  <D.20558>:
  D.20562 = mono_defaults.int32_class;
  D.20563 = &D.20562->byval_arg;
  res->ret = D.20563;
  <D.20555>:
  res->pinvoke = 0;
  res->hasthis = 0;
  D.20564 = (short unsigned int) param_count;
  res->param_count = D.20564;
  res->call_convention = 1;
  D.20565 = res;
  return D.20565;
}


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

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


cominterop_object_is_rcw (struct MonoObject * obj)
{
  gboolean D.20571;
  struct MonoVTable * D.20572;
  struct MonoClass * D.20573;
  struct MonoVTable * D.20578;
  int iftmp.66;
  struct MonoClass * D.20583;
  struct MonoClass * klass;
  struct MonoRealProxy * real_proxy;

  klass = 0B;
  real_proxy = 0B;
  if (obj == 0B) goto <D.20569>; else goto <D.20570>;
  <D.20569>:
  D.20571 = 0;
  return D.20571;
  <D.20570>:
  D.20572 = obj->vtable;
  klass = D.20572->klass;
  D.20573 = mono_defaults.transparent_proxy_class;
  if (D.20573 != klass) goto <D.20574>; else goto <D.20575>;
  <D.20574>:
  D.20571 = 0;
  return D.20571;
  <D.20575>:
  real_proxy = MEM[(struct MonoTransparentProxy *)obj].rp;
  if (real_proxy == 0B) goto <D.20576>; else goto <D.20577>;
  <D.20576>:
  D.20571 = 0;
  return D.20571;
  <D.20577>:
  D.20578 = MEM[(struct MonoObject *)real_proxy].vtable;
  klass = D.20578->klass;
  if (klass != 0B) goto <D.20582>; else goto <D.20580>;
  <D.20582>:
  D.20583 = mono_class_get_interop_proxy_class ();
  if (D.20583 == klass) goto <D.20584>; else goto <D.20580>;
  <D.20584>:
  iftmp.66 = 1;
  goto <D.20581>;
  <D.20580>:
  iftmp.66 = 0;
  <D.20581>:
  D.20571 = iftmp.66;
  return D.20571;
}


cominterop_get_function_pointer (void * itf, int slot)
{
  void * * D.20586;
  long unsigned int D.20587;
  long unsigned int D.20588;
  void * * D.20589;
  void * D.20590;
  void * func;

  D.20586 = MEM[(void * * *)itf];
  D.20587 = (long unsigned int) slot;
  D.20588 = D.20587 * 8;
  D.20589 = D.20586 + D.20588;
  func = *D.20589;
  D.20590 = func;
  return D.20590;
}


cominterop_get_method_interface (struct MonoMethod * method)
{
  struct MonoClass * D.20592;
  unsigned int D.20593;
  unsigned int D.20594;
  unsigned char D.20597;
  int D.20602;
  _Bool D.20603;
  long int D.20604;
  long int D.20605;
  void * * D.20610;
  long unsigned int D.20611;
  long unsigned int D.20612;
  void * * D.20613;
  struct MonoMethod * * D.20614;
  int D.20615;
  long unsigned int D.20616;
  long unsigned int D.20617;
  struct MonoMethod * * D.20618;
  struct MonoMethod * D.20619;
  unsigned int j.67;
  unsigned int D.20623;
  unsigned int i.68;
  unsigned int D.20626;
  _Bool D.20629;
  long int D.20630;
  long int D.20631;
  int iftmp.69;
  unsigned int D.20637;
  unsigned int D.20638;
  unsigned char D.20640;
  _Bool D.20643;
  long int D.20644;
  long int D.20645;
  struct MonoClass * D.20648;
  struct MonoError error;
  struct MonoClass * ic;

  try
    {
      ic = method->klass;
      D.20592 = method->klass;
      D.20593 = D.20592->flags;
      D.20594 = D.20593 & 32;
      if (D.20594 == 0) goto <D.20595>; else goto <D.20596>;
      <D.20595>:
      D.20592 = method->klass;
      D.20597 = D.20592->byval_arg.type;
      if (D.20597 != 19) goto <D.20598>; else goto <D.20599>;
      <D.20598>:
      D.20592 = method->klass;
      D.20597 = D.20592->byval_arg.type;
      if (D.20597 != 30) goto <D.20600>; else goto <D.20601>;
      <D.20600>:
      {
        struct GPtrArray * ifaces;

        D.20592 = method->klass;
        ifaces = mono_class_get_implemented_interfaces (D.20592, &error);
        D.20602 = mono_error_ok (&error);
        D.20603 = D.20602 == 0;
        D.20604 = (long int) D.20603;
        D.20605 = __builtin_expect (D.20604, 0);
        if (D.20605 != 0) goto <D.20606>; else goto <D.20607>;
        <D.20606>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 315, "mono_error_ok (&error)");
        <D.20607>:
        if (ifaces != 0B) goto <D.20608>; else goto <D.20609>;
        <D.20608>:
        {
          int i;

          D.20592 = method->klass;
          mono_class_setup_vtable (D.20592);
          i = 0;
          goto <D.18801>;
          <D.18800>:
          {
            int j;
            int offset;
            gboolean found;

            found = 0;
            D.20610 = ifaces->pdata;
            D.20611 = (long unsigned int) i;
            D.20612 = D.20611 * 8;
            D.20613 = D.20610 + D.20612;
            ic = *D.20613;
            D.20592 = method->klass;
            offset = mono_class_interface_offset (D.20592, ic);
            j = 0;
            goto <D.18798>;
            <D.18797>:
            D.20592 = method->klass;
            D.20614 = D.20592->vtable;
            D.20615 = j + offset;
            D.20616 = (long unsigned int) D.20615;
            D.20617 = D.20616 * 8;
            D.20618 = D.20614 + D.20617;
            D.20619 = *D.20618;
            if (D.20619 == method) goto <D.20620>; else goto <D.20621>;
            <D.20620>:
            found = 1;
            goto <D.18796>;
            <D.20621>:
            j = j + 1;
            <D.18798>:
            j.67 = (unsigned int) j;
            D.20623 = ic->method.count;
            if (j.67 < D.20623) goto <D.18797>; else goto <D.18796>;
            <D.18796>:
            if (found != 0) goto <D.18799>; else goto <D.20624>;
            <D.20624>:
            ic = 0B;
          }
          i = i + 1;
          <D.18801>:
          i.68 = (unsigned int) i;
          D.20626 = ifaces->len;
          if (i.68 < D.20626) goto <D.18800>; else goto <D.18799>;
          <D.18799>:
          monoeg_g_ptr_array_free (ifaces, 1);
        }
        <D.20609>:
      }
      <D.20601>:
      <D.20599>:
      <D.20596>:
      if (ic == 0B) goto <D.20627>; else goto <D.20628>;
      <D.20627>:
      D.20629 = ic == 0B;
      D.20630 = (long int) D.20629;
      D.20631 = __builtin_expect (D.20630, 0);
      if (D.20631 != 0) goto <D.20632>; else goto <D.20633>;
      <D.20632>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 339, "ic");
      <D.20633>:
      <D.20628>:
      D.20637 = ic->flags;
      D.20638 = D.20637 & 32;
      if (D.20638 == 0) goto <D.20639>; else goto <D.20635>;
      <D.20639>:
      D.20640 = ic->byval_arg.type;
      if (D.20640 != 19) goto <D.20641>; else goto <D.20635>;
      <D.20641>:
      D.20640 = ic->byval_arg.type;
      if (D.20640 != 30) goto <D.20642>; else goto <D.20635>;
      <D.20642>:
      iftmp.69 = 1;
      goto <D.20636>;
      <D.20635>:
      iftmp.69 = 0;
      <D.20636>:
      D.20643 = iftmp.69 != 0;
      D.20644 = (long int) D.20643;
      D.20645 = __builtin_expect (D.20644, 0);
      if (D.20645 != 0) goto <D.20646>; else goto <D.20647>;
      <D.20646>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 340, "MONO_CLASS_IS_INTERFACE (ic)");
      <D.20647>:
      D.20648 = ic;
      return D.20648;
    }
  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.20651;

  mono_mb_emit_ldarg (mb, 0);
  D.20651 = cominterop_get_com_slot_for_method (method);
  mono_mb_emit_icon (mb, D.20651);
  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.20652;
  unsigned int D.20653;
  unsigned int D.20654;
  unsigned char D.20657;
  struct MonoClass * D.20662;
  _Bool D.20663;
  long int D.20664;
  long int D.20665;
  struct MonoMethod * * D.20668;
  int D.20669;
  long unsigned int D.20670;
  long unsigned int D.20671;
  struct MonoMethod * * D.20672;
  struct MonoMethod * D.20673;
  struct MonoMethod * * D.20676;
  long unsigned int D.20677;
  long unsigned int D.20678;
  struct MonoMethod * * D.20679;
  struct MonoMethod * D.20680;
  short int D.20681;
  unsigned int i.70;
  unsigned int D.20683;
  _Bool D.20684;
  long int D.20685;
  long int D.20686;
  int iftmp.71;
  _Bool D.20695;
  long int D.20696;
  long int D.20697;
  int D.20700;
  int D.20701;
  unsigned int D.20702;
  unsigned int D.20703;
  guint32 slot;
  struct MonoClass * ic;

  D.20652 = method->slot;
  slot = (guint32) D.20652;
  ic = method->klass;
  D.20653 = ic->flags;
  D.20654 = D.20653 & 32;
  if (D.20654 == 0) goto <D.20655>; else goto <D.20656>;
  <D.20655>:
  D.20657 = ic->byval_arg.type;
  if (D.20657 != 19) goto <D.20658>; else goto <D.20659>;
  <D.20658>:
  D.20657 = ic->byval_arg.type;
  if (D.20657 != 30) goto <D.20660>; else goto <D.20661>;
  <D.20660>:
  {
    int offset;
    int i;

    offset = 0;
    i = 0;
    ic = cominterop_get_method_interface (method);
    D.20662 = method->klass;
    offset = mono_class_interface_offset (D.20662, ic);
    D.20663 = offset < 0;
    D.20664 = (long int) D.20663;
    D.20665 = __builtin_expect (D.20664, 0);
    if (D.20665 != 0) goto <D.20666>; else goto <D.20667>;
    <D.20666>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 363, "offset >= 0");
    <D.20667>:
    i = 0;
    goto <D.18811>;
    <D.18810>:
    D.20662 = method->klass;
    D.20668 = D.20662->vtable;
    D.20669 = i + offset;
    D.20670 = (long unsigned int) D.20669;
    D.20671 = D.20670 * 8;
    D.20672 = D.20668 + D.20671;
    D.20673 = *D.20672;
    if (D.20673 == method) goto <D.20674>; else goto <D.20675>;
    <D.20674>:
    D.20676 = ic->methods;
    D.20677 = (long unsigned int) i;
    D.20678 = D.20677 * 8;
    D.20679 = D.20676 + D.20678;
    D.20680 = *D.20679;
    D.20681 = D.20680->slot;
    slot = (guint32) D.20681;
    goto <D.18809>;
    <D.20675>:
    i = i + 1;
    <D.18811>:
    i.70 = (unsigned int) i;
    D.20683 = ic->method.count;
    if (i.70 < D.20683) goto <D.18810>; else goto <D.18809>;
    <D.18809>:
  }
  <D.20661>:
  <D.20659>:
  <D.20656>:
  D.20684 = ic == 0B;
  D.20685 = (long int) D.20684;
  D.20686 = __builtin_expect (D.20685, 0);
  if (D.20686 != 0) goto <D.20687>; else goto <D.20688>;
  <D.20687>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 373, "ic");
  <D.20688>:
  D.20653 = ic->flags;
  D.20654 = D.20653 & 32;
  if (D.20654 == 0) goto <D.20692>; else goto <D.20690>;
  <D.20692>:
  D.20657 = ic->byval_arg.type;
  if (D.20657 != 19) goto <D.20693>; else goto <D.20690>;
  <D.20693>:
  D.20657 = ic->byval_arg.type;
  if (D.20657 != 30) goto <D.20694>; else goto <D.20690>;
  <D.20694>:
  iftmp.71 = 1;
  goto <D.20691>;
  <D.20690>:
  iftmp.71 = 0;
  <D.20691>:
  D.20695 = iftmp.71 != 0;
  D.20696 = (long int) D.20695;
  D.20697 = __builtin_expect (D.20696, 0);
  if (D.20697 != 0) goto <D.20698>; else goto <D.20699>;
  <D.20698>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 374, "MONO_CLASS_IS_INTERFACE (ic)");
  <D.20699>:
  D.20701 = cominterop_get_com_slot_begin (ic);
  D.20702 = (unsigned int) D.20701;
  D.20703 = D.20702 + slot;
  D.20700 = (int) D.20703;
  return D.20700;
}


mono_cominterop_emit_ptr_to_object_conv (struct MonoMethodBuilder * mb, struct MonoType * type, MonoMarshalConv conv, struct MonoMarshalSpec * mspec)
{
  struct MonoClass * com_interop_proxy_class.72;
  struct MonoImage * D.20708;
  struct MonoClass * com_interop_proxy_class.73;
  struct MonoMethod * com_interop_proxy_get_proxy.74;
  struct MonoMethod * com_interop_proxy_get_proxy.75;
  struct MonoMethod * get_transparent_proxy.76;
  struct MonoClass * D.20717;
  struct MonoMethod * get_transparent_proxy.77;
  struct MonoType * D.20719;
  struct MonoClass * D.20720;
  struct MonoType * D.20721;
  _Bool D.20724;
  long int D.20725;
  long int D.20726;

  switch (conv) <default: <D.18903>, case 25: <D.18891>, case 26: <D.18893>, case 27: <D.18892>>
  <D.18891>:
  <D.18892>:
  <D.18893>:
  {
    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.72 = com_interop_proxy_class;
    if (com_interop_proxy_class.72 == 0B) goto <D.20706>; else goto <D.20707>;
    <D.20706>:
    D.20708 = mono_defaults.corlib;
    com_interop_proxy_class.73 = mono_class_from_name (D.20708, "Mono.Interop", "ComInteropProxy");
    com_interop_proxy_class = com_interop_proxy_class.73;
    <D.20707>:
    com_interop_proxy_get_proxy.74 = com_interop_proxy_get_proxy;
    if (com_interop_proxy_get_proxy.74 == 0B) goto <D.20711>; else goto <D.20712>;
    <D.20711>:
    com_interop_proxy_class.72 = com_interop_proxy_class;
    com_interop_proxy_get_proxy.75 = mono_class_get_method_from_name_flags (com_interop_proxy_class.72, "GetProxy", 2, 1);
    com_interop_proxy_get_proxy = com_interop_proxy_get_proxy.75;
    <D.20712>:
    get_transparent_proxy.76 = get_transparent_proxy;
    if (get_transparent_proxy.76 == 0B) goto <D.20715>; else goto <D.20716>;
    <D.20715>:
    D.20717 = mono_defaults.real_proxy_class;
    get_transparent_proxy.77 = mono_class_get_method_from_name (D.20717, "GetTransparentProxy", 0);
    get_transparent_proxy = get_transparent_proxy.77;
    <D.20716>:
    com_interop_proxy_class.72 = com_interop_proxy_class;
    D.20719 = &com_interop_proxy_class.72->byval_arg;
    real_proxy = mono_mb_add_local (mb, D.20719);
    mono_mb_emit_ldloc (mb, 0);
    mono_mb_emit_byte (mb, 77);
    D.20720 = mono_class_get_com_object_class ();
    D.20721 = &D.20720->byval_arg;
    mono_mb_emit_ptr (mb, D.20721);
    mono_mb_emit_icall (mb, cominterop_type_from_handle);
    com_interop_proxy_get_proxy.74 = com_interop_proxy_get_proxy;
    mono_mb_emit_managed_call (mb, com_interop_proxy_get_proxy.74, 0B);
    get_transparent_proxy.76 = get_transparent_proxy;
    mono_mb_emit_managed_call (mb, get_transparent_proxy.76, 0B);
    if (conv == 25) goto <D.20722>; else goto <D.20723>;
    <D.20722>:
    D.20724 = klass == 0B;
    D.20725 = (long int) D.20724;
    D.20726 = __builtin_expect (D.20725, 0);
    if (D.20726 != 0) goto <D.20727>; else goto <D.20728>;
    <D.20727>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 631, "klass");
    <D.20728>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20723>:
    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.20729>; else goto <D.20730>;
    <D.20729>:
    D.20724 = klass == 0B;
    D.20725 = (long int) D.20724;
    D.20726 = __builtin_expect (D.20725, 0);
    if (D.20726 != 0) goto <D.20731>; else goto <D.20732>;
    <D.20731>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 645, "klass");
    <D.20732>:
    mono_mb_emit_op (mb, 116, klass);
    <D.20730>:
    mono_mb_emit_byte (mb, 81);
    mono_mb_patch_short_branch (mb, pos_end);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.18902>;
  }
  <D.18903>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 656);
  <D.18902>:
}


mono_cominterop_emit_object_to_ptr_conv (struct MonoMethodBuilder * mb, struct MonoType * type, MonoMarshalConv conv, struct MonoMarshalSpec * mspec)
{
  struct MonoClass * D.20735;
  struct MonoProperty * iunknown.78;
  struct MonoClass * D.20742;
  struct MonoProperty * iunknown.79;
  struct MonoMethod * D.20744;
  struct MonoProperty * idispatch.80;
  struct MonoClass * D.20751;
  struct MonoProperty * idispatch.81;
  struct MonoMethod * D.20753;
  struct MonoClass * D.20757;
  struct MonoClass * D.20761;
  struct MonoClass * D.20765;

  switch (conv) <default: <D.18919>, case 25: <D.18910>, case 26: <D.18911>, case 27: <D.18912>>
  <D.18910>:
  <D.18911>:
  <D.18912>:
  {
    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, 16);
    mono_mb_emit_byte (mb, 80);
    mono_mb_emit_ldflda (mb, 80);
    mono_mb_emit_byte (mb, 80);
    if (conv == 25) goto <D.20733>; else goto <D.20734>;
    <D.20733>:
    D.20735 = mono_type_get_class (type);
    mono_mb_emit_ptr (mb, D.20735);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_interface);
    goto <D.20736>;
    <D.20734>:
    if (conv == 27) goto <D.20737>; else goto <D.20738>;
    <D.20737>:
    {
      static struct MonoProperty * iunknown = 0B;

      iunknown.78 = iunknown;
      if (iunknown.78 == 0B) goto <D.20740>; else goto <D.20741>;
      <D.20740>:
      D.20742 = mono_class_get_com_object_class ();
      iunknown.79 = mono_class_get_property_from_name (D.20742, "IUnknown");
      iunknown = iunknown.79;
      <D.20741>:
      iunknown.78 = iunknown;
      D.20744 = iunknown.78->get;
      mono_mb_emit_managed_call (mb, D.20744, 0B);
    }
    goto <D.20745>;
    <D.20738>:
    if (conv == 26) goto <D.20746>; else goto <D.20747>;
    <D.20746>:
    {
      static struct MonoProperty * idispatch = 0B;

      idispatch.80 = idispatch;
      if (idispatch.80 == 0B) goto <D.20749>; else goto <D.20750>;
      <D.20749>:
      D.20751 = mono_class_get_com_object_class ();
      idispatch.81 = mono_class_get_property_from_name (D.20751, "IDispatch");
      idispatch = idispatch.81;
      <D.20750>:
      idispatch.80 = idispatch;
      D.20753 = idispatch.80->get;
      mono_mb_emit_managed_call (mb, D.20753, 0B);
    }
    goto <D.20754>;
    <D.20747>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 719);
    <D.20754>:
    <D.20745>:
    <D.20736>:
    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.20755>; else goto <D.20756>;
    <D.20755>:
    D.20757 = mono_type_get_class (type);
    mono_mb_emit_ptr (mb, D.20757);
    goto <D.20758>;
    <D.20756>:
    if (conv == 27) goto <D.20759>; else goto <D.20760>;
    <D.20759>:
    D.20761 = mono_class_get_iunknown_class ();
    mono_mb_emit_ptr (mb, D.20761);
    goto <D.20762>;
    <D.20760>:
    if (conv == 26) goto <D.20763>; else goto <D.20764>;
    <D.20763>:
    D.20765 = mono_class_get_idispatch_class ();
    mono_mb_emit_ptr (mb, D.20765);
    goto <D.20766>;
    <D.20764>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 739);
    <D.20766>:
    <D.20762>:
    <D.20758>:
    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.18918>;
  }
  <D.18919>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 748);
  <D.18918>:
}


mono_cominterop_get_native_wrapper (struct MonoMethod * method)
{
  _Bool D.20767;
  long int D.20768;
  long int D.20769;
  struct MonoClass * D.20772;
  struct MonoImage * D.20773;
  struct GHashTable * * D.20774;
  struct MonoMethod * D.20777;
  struct MonoMethod * * D.20778;
  struct MonoMethod * * D.20781;
  unsigned char D.20784;
  _Bool D.20785;
  long int D.20786;
  long int D.20787;
  const char * D.20790;
  unsigned int D.20791;
  unsigned int D.20792;
  int D.18956;
  int iftmp.82;
  int D.18955;
  const char[6] * D.20798;
  unsigned char D.20799;
  int D.20800;
  unsigned char D.20801;
  int D.20802;
  _Bool D.20803;
  _Bool D.20804;
  _Bool D.20805;
  const unsigned char * D.20808;
  unsigned char D.20809;
  int D.20810;
  const unsigned char * D.20811;
  unsigned char D.20812;
  int D.20813;
  _Bool D.20814;
  _Bool D.20815;
  const unsigned char * D.20818;
  unsigned char D.20819;
  int D.20820;
  const unsigned char * D.20821;
  unsigned char D.20822;
  int D.20823;
  _Bool D.20824;
  _Bool D.20825;
  const unsigned char * D.20828;
  unsigned char D.20829;
  int D.20830;
  const unsigned char * D.20831;
  unsigned char D.20832;
  int D.20833;
  struct MonoMethod * ctor.83;
  struct MonoClass * D.20840;
  struct MonoMethod * ctor.84;
  short unsigned int D.20843;
  int D.20844;
  struct MonoClass * D.20845;
  struct MonoType * D.20846;
  struct MonoType * D.20847;
  int D.20848;
  unsigned int ptr_this.85;
  unsigned int i.86;
  short unsigned int D.20853;
  int D.20854;
  int D.20855;
  unsigned int retval.87;
  struct MonoMethod * ThrowExceptionForHR.88;
  struct MonoClass * D.20866;
  struct MonoMethod * ThrowExceptionForHR.89;
  int D.20868;
  short unsigned int D.20872;
  int D.20873;
  int D.20874;
  struct MonoMethod * res;
  struct GHashTable * cache;
  struct MonoMethodBuilder * mb;
  struct MonoMethodSignature * sig;
  struct MonoMethodSignature * csig;

  D.20767 = method == 0B;
  D.20768 = (long int) D.20767;
  D.20769 = __builtin_expect (D.20768, 0);
  if (D.20769 != 0) goto <D.20770>; else goto <D.20771>;
  <D.20770>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 869, "method");
  <D.20771>:
  D.20772 = method->klass;
  D.20773 = D.20772->image;
  D.20774 = &D.20773->cominterop_wrapper_cache;
  cache = mono_marshal_get_cache (D.20774, mono_aligned_addr_hash, 0B);
  res = mono_marshal_find_in_cache (cache, method);
  if (res != 0B) goto <D.20775>; else goto <D.20776>;
  <D.20775>:
  D.20777 = res;
  return D.20777;
  <D.20776>:
  D.20772 = method->klass;
  D.20778 = D.20772->vtable;
  if (D.20778 == 0B) goto <D.20779>; else goto <D.20780>;
  <D.20779>:
  D.20772 = method->klass;
  mono_class_setup_vtable (D.20772);
  <D.20780>:
  D.20772 = method->klass;
  D.20781 = D.20772->methods;
  if (D.20781 == 0B) goto <D.20782>; else goto <D.20783>;
  <D.20782>:
  D.20772 = method->klass;
  mono_class_setup_methods (D.20772);
  <D.20783>:
  D.20772 = method->klass;
  D.20784 = D.20772->exception_type;
  D.20785 = D.20784 != 0;
  D.20786 = (long int) D.20785;
  D.20787 = __builtin_expect (D.20786, 0);
  if (D.20787 != 0) goto <D.20788>; else goto <D.20789>;
  <D.20788>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 880, "!method->klass->exception_type");
  <D.20789>:
  sig = mono_method_signature (method);
  D.20790 = method->name;
  D.20772 = method->klass;
  mb = mono_mb_new (D.20772, D.20790, 27);
  D.20772 = method->klass;
  D.20791 = D.20772->flags;
  D.20792 = D.20791 & 4096;
  if (D.20792 != 0) goto <D.20793>; else goto <D.20794>;
  <D.20793>:
  {
    size_t __s1_len;
    size_t __s2_len;

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

      __s2 = method->name;
      D.20798 = ".ctor";
      D.20799 = MEM[(const unsigned char *)D.20798];
      D.20800 = (int) D.20799;
      D.20801 = *__s2;
      D.20802 = (int) D.20801;
      __result = D.20800 - D.20802;
      {
        D.20803 = __s2_len != 0;
        D.20804 = __result == 0;
        D.20805 = D.20803 & D.20804;
        if (D.20805 != 0) goto <D.20806>; else goto <D.20807>;
        <D.20806>:
        D.20808 = &MEM[(void *)".ctor" + 1B];
        D.20809 = *D.20808;
        D.20810 = (int) D.20809;
        D.20811 = __s2 + 1;
        D.20812 = *D.20811;
        D.20813 = (int) D.20812;
        __result = D.20810 - D.20813;
        D.20814 = __s2_len > 1;
        D.20804 = __result == 0;
        D.20815 = D.20814 & D.20804;
        if (D.20815 != 0) goto <D.20816>; else goto <D.20817>;
        <D.20816>:
        D.20818 = &MEM[(void *)".ctor" + 2B];
        D.20819 = *D.20818;
        D.20820 = (int) D.20819;
        D.20821 = __s2 + 2;
        D.20822 = *D.20821;
        D.20823 = (int) D.20822;
        __result = D.20820 - D.20823;
        D.20824 = __s2_len > 2;
        D.20804 = __result == 0;
        D.20825 = D.20824 & D.20804;
        if (D.20825 != 0) goto <D.20826>; else goto <D.20827>;
        <D.20826>:
        D.20828 = &MEM[(void *)".ctor" + 3B];
        D.20829 = *D.20828;
        D.20830 = (int) D.20829;
        D.20831 = __s2 + 3;
        D.20832 = *D.20831;
        D.20833 = (int) D.20832;
        __result = D.20830 - D.20833;
        <D.20827>:
        <D.20817>:
        <D.20807>:
      }
      D.18955 = __result;
    }
    iftmp.82 = -D.18955;
    goto <D.20834>;
    <D.20797>:
    D.20790 = method->name;
    iftmp.82 = __builtin_strcmp (D.20790, ".ctor");
    <D.20834>:
    D.18956 = iftmp.82;
  }
  if (D.18956 == 0) goto <D.20835>; else goto <D.20836>;
  <D.20835>:
  {
    static struct MonoMethod * ctor = 0B;

    ctor.83 = ctor;
    if (ctor.83 == 0B) goto <D.20838>; else goto <D.20839>;
    <D.20838>:
    D.20840 = mono_class_get_com_object_class ();
    ctor.84 = mono_class_get_method_from_name (D.20840, ".ctor", 0);
    ctor = ctor.84;
    <D.20839>:
    mono_mb_emit_ldarg (mb, 0);
    ctor.83 = ctor;
    mono_mb_emit_managed_call (mb, ctor.83, 0B);
    mono_mb_emit_byte (mb, 42);
  }
  goto <D.20842>;
  <D.20836>:
  {
    static struct MonoMethod * ThrowExceptionForHR = 0B;
    struct MonoMethod * adjusted_method;
    int retval;
    int ptr_this;
    int i;
    gboolean preserve_sig;

    retval = 0;
    D.20843 = method->iflags;
    D.20844 = (int) D.20843;
    preserve_sig = D.20844 & 128;
    D.20845 = mono_defaults.int_class;
    D.20846 = &D.20845->byval_arg;
    ptr_this = mono_mb_add_local (mb, D.20846);
    D.20847 = sig->ret;
    D.20848 = mono_type_is_void (D.20847);
    if (D.20848 == 0) goto <D.20849>; else goto <D.20850>;
    <D.20849>:
    D.20847 = sig->ret;
    retval = mono_mb_add_local (mb, D.20847);
    <D.20850>:
    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.85 = (unsigned int) ptr_this;
    mono_mb_emit_stloc (mb, ptr_this.85);
    ptr_this.85 = (unsigned int) ptr_this;
    mono_mb_emit_ldloc (mb, ptr_this.85);
    i = 1;
    goto <D.18965>;
    <D.18964>:
    i.86 = (unsigned int) i;
    mono_mb_emit_ldarg (mb, i.86);
    i = i + 1;
    <D.18965>:
    D.20853 = sig->param_count;
    D.20854 = (int) D.20853;
    if (D.20854 >= i) goto <D.18964>; else goto <D.18966>;
    <D.18966>:
    D.20847 = sig->ret;
    D.20855 = mono_type_is_void (D.20847);
    if (D.20855 == 0) goto <D.20856>; else goto <D.20857>;
    <D.20856>:
    if (preserve_sig == 0) goto <D.20858>; else goto <D.20859>;
    <D.20858>:
    retval.87 = (unsigned int) retval;
    mono_mb_emit_ldloc_addr (mb, retval.87);
    <D.20859>:
    <D.20857>:
    adjusted_method = cominterop_get_native_wrapper_adjusted (method);
    mono_mb_emit_managed_call (mb, adjusted_method, 0B);
    if (preserve_sig == 0) goto <D.20861>; else goto <D.20862>;
    <D.20861>:
    ThrowExceptionForHR.88 = ThrowExceptionForHR;
    if (ThrowExceptionForHR.88 == 0B) goto <D.20864>; else goto <D.20865>;
    <D.20864>:
    D.20866 = mono_defaults.marshal_class;
    ThrowExceptionForHR.89 = mono_class_get_method_from_name (D.20866, "ThrowExceptionForHR", 1);
    ThrowExceptionForHR = ThrowExceptionForHR.89;
    <D.20865>:
    ThrowExceptionForHR.88 = ThrowExceptionForHR;
    mono_mb_emit_managed_call (mb, ThrowExceptionForHR.88, 0B);
    D.20847 = sig->ret;
    D.20868 = mono_type_is_void (D.20847);
    if (D.20868 == 0) goto <D.20869>; else goto <D.20870>;
    <D.20869>:
    retval.87 = (unsigned int) retval;
    mono_mb_emit_ldloc (mb, retval.87);
    <D.20870>:
    <D.20862>:
    mono_mb_emit_byte (mb, 42);
  }
  <D.20842>:
  goto <D.20871>;
  <D.20794>:
  {
    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.20871>:
  D.20772 = method->klass;
  D.20773 = D.20772->image;
  csig = mono_metadata_signature_dup_full (D.20773, sig);
  csig->pinvoke = 0;
  D.20872 = csig->param_count;
  D.20873 = (int) D.20872;
  D.20874 = D.20873 + 16;
  res = mono_mb_create_and_cache (cache, method, mb, csig, D.20874);
  mono_mb_free (mb);
  D.20777 = res;
  return D.20777;
}


cominterop_get_native_wrapper_adjusted (struct MonoMethod * method)
{
  const char * D.20876;
  struct MonoClass * D.20877;
  short unsigned int D.20878;
  int D.20879;
  int D.20880;
  long unsigned int D.20881;
  long unsigned int D.20882;
  short unsigned int D.20883;
  sizetype D.20884;
  sizetype D.20885;
  sizetype D.20886;
  struct MonoMarshalSpec * * D.20887;
  long unsigned int D.20888;
  long unsigned int D.20889;
  struct MonoMarshalSpec * * D.20890;
  struct MonoMarshalSpec * D.20891;
  struct MonoMarshalSpec * * D.20892;
  short unsigned int D.20893;
  int D.20894;
  int D.20895;
  struct MonoType * D.20898;
  int D.20899;
  long unsigned int D.20902;
  long unsigned int D.20903;
  struct MonoMarshalSpec * * D.20904;
  struct MonoMarshalSpec * D.20905;
  long unsigned int D.20906;
  long unsigned int D.20907;
  struct MonoMarshalSpec * * D.20908;
  struct MonoMarshalSpec * D.20909;
  struct MonoType * D.20912;
  unsigned char D.20913;
  void * D.20916;
  void * D.20920;
  void * D.20924;
  void * D.20928;
  int D.20931;
  unsigned char D.20936;
  void * D.20939;
  void * D.20943;
  void * D.20947;
  void * D.20951;
  void * D.20952;
  struct MonoImage * D.20953;
  int D.20954;
  struct MonoMethod * D.20957;
  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.20876 = method->name;
  D.20877 = method->klass;
  mb_native = mono_mb_new (D.20877, D.20876, 6);
  sig_native = cominterop_method_signature (method);
  D.20878 = sig_native->param_count;
  D.20879 = (int) D.20878;
  D.20880 = D.20879 + 1;
  D.20881 = (long unsigned int) D.20880;
  D.20882 = D.20881 * 8;
  mspecs = monoeg_malloc (D.20882);
  D.20878 = sig_native->param_count;
  D.20879 = (int) D.20878;
  D.20880 = D.20879 + 1;
  D.20881 = (long unsigned int) D.20880;
  D.20882 = D.20881 * 8;
  memset (mspecs, 0, D.20882);
  mono_method_get_marshal_info (method, mspecs);
  D.20883 = sig->param_count;
  i = (int) D.20883;
  goto <D.18931>;
  <D.18930>:
  D.20884 = (sizetype) i;
  D.20885 = D.20884 + 1;
  D.20886 = D.20885 * 8;
  D.20887 = mspecs + D.20886;
  D.20888 = (long unsigned int) i;
  D.20889 = D.20888 * 8;
  D.20890 = mspecs + D.20889;
  D.20891 = *D.20890;
  *D.20887 = D.20891;
  i = i + -1;
  <D.18931>:
  if (i > 0) goto <D.18930>; else goto <D.18932>;
  <D.18932>:
  D.20892 = mspecs + 8;
  *D.20892 = 0B;
  D.20893 = method->iflags;
  D.20894 = (int) D.20893;
  D.20895 = D.20894 & 128;
  if (D.20895 == 0) goto <D.20896>; else goto <D.20897>;
  <D.20896>:
  D.20898 = sig->ret;
  D.20899 = mono_type_is_void (D.20898);
  if (D.20899 == 0) goto <D.20900>; else goto <D.20901>;
  <D.20900>:
  D.20878 = sig_native->param_count;
  D.20902 = (long unsigned int) D.20878;
  D.20903 = D.20902 * 8;
  D.20904 = mspecs + D.20903;
  D.20905 = *mspecs;
  *D.20904 = D.20905;
  <D.20901>:
  *mspecs = 0B;
  <D.20897>:
  i = 1;
  goto <D.18935>;
  <D.18934>:
  {
    int mspec_index;

    mspec_index = i + 1;
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20909 = *D.20908;
    if (D.20909 == 0B) goto <D.20910>; else goto <D.20911>;
    <D.20910>:
    D.20912 = sig_native->params[i];
    D.20913 = D.20912->type;
    if (D.20913 == 28) goto <D.20914>; else goto <D.20915>;
    <D.20914>:
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20916 = monoeg_malloc0 (24);
    *D.20908 = D.20916;
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20909 = *D.20908;
    D.20909->native = 27;
    goto <D.20917>;
    <D.20915>:
    D.20912 = sig_native->params[i];
    D.20913 = D.20912->type;
    if (D.20913 == 14) goto <D.20918>; else goto <D.20919>;
    <D.20918>:
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20920 = monoeg_malloc0 (24);
    *D.20908 = D.20920;
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20909 = *D.20908;
    D.20909->native = 19;
    goto <D.20921>;
    <D.20919>:
    D.20912 = sig_native->params[i];
    D.20913 = D.20912->type;
    if (D.20913 == 18) goto <D.20922>; else goto <D.20923>;
    <D.20922>:
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20924 = monoeg_malloc0 (24);
    *D.20908 = D.20924;
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20909 = *D.20908;
    D.20909->native = 28;
    goto <D.20925>;
    <D.20923>:
    D.20912 = sig_native->params[i];
    D.20913 = D.20912->type;
    if (D.20913 == 2) goto <D.20926>; else goto <D.20927>;
    <D.20926>:
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20928 = monoeg_malloc0 (24);
    *D.20908 = D.20928;
    D.20906 = (long unsigned int) mspec_index;
    D.20907 = D.20906 * 8;
    D.20908 = mspecs + D.20907;
    D.20909 = *D.20908;
    D.20909->native = 37;
    <D.20927>:
    <D.20925>:
    <D.20921>:
    <D.20917>:
    <D.20911>:
  }
  i = i + 1;
  <D.18935>:
  D.20878 = sig_native->param_count;
  D.20879 = (int) D.20878;
  if (D.20879 > i) goto <D.18934>; else goto <D.18936>;
  <D.18936>:
  D.20893 = method->iflags;
  D.20894 = (int) D.20893;
  D.20895 = D.20894 & 128;
  if (D.20895 != 0) goto <D.20929>; else goto <D.20930>;
  <D.20929>:
  D.20898 = sig->ret;
  D.20931 = mono_type_is_void (D.20898);
  if (D.20931 == 0) goto <D.20932>; else goto <D.20933>;
  <D.20932>:
  D.20905 = *mspecs;
  if (D.20905 == 0B) goto <D.20934>; else goto <D.20935>;
  <D.20934>:
  D.20898 = sig->ret;
  D.20936 = D.20898->type;
  if (D.20936 == 28) goto <D.20937>; else goto <D.20938>;
  <D.20937>:
  D.20939 = monoeg_malloc0 (24);
  *mspecs = D.20939;
  D.20905 = *mspecs;
  D.20905->native = 27;
  goto <D.20940>;
  <D.20938>:
  D.20898 = sig->ret;
  D.20936 = D.20898->type;
  if (D.20936 == 14) goto <D.20941>; else goto <D.20942>;
  <D.20941>:
  D.20943 = monoeg_malloc0 (24);
  *mspecs = D.20943;
  D.20905 = *mspecs;
  D.20905->native = 19;
  goto <D.20944>;
  <D.20942>:
  D.20898 = sig->ret;
  D.20936 = D.20898->type;
  if (D.20936 == 18) goto <D.20945>; else goto <D.20946>;
  <D.20945>:
  D.20947 = monoeg_malloc0 (24);
  *mspecs = D.20947;
  D.20905 = *mspecs;
  D.20905->native = 28;
  goto <D.20948>;
  <D.20946>:
  D.20898 = sig->ret;
  D.20936 = D.20898->type;
  if (D.20936 == 2) goto <D.20949>; else goto <D.20950>;
  <D.20949>:
  D.20951 = monoeg_malloc0 (24);
  *mspecs = D.20951;
  D.20905 = *mspecs;
  D.20905->native = 37;
  <D.20950>:
  <D.20948>:
  <D.20944>:
  <D.20940>:
  <D.20935>:
  <D.20933>:
  <D.20930>:
  D.20952 = piinfo->addr;
  D.20877 = method->klass;
  D.20953 = D.20877->image;
  mono_marshal_emit_native_wrapper (D.20953, mb_native, sig_native, piinfo, mspecs, D.20952, 0, 1, 0);
  D.20878 = sig_native->param_count;
  D.20879 = (int) D.20878;
  D.20954 = D.20879 + 16;
  res = mono_mb_create_method (mb_native, sig_native, D.20954);
  mono_mb_free (mb_native);
  D.20878 = sig_native->param_count;
  i = (int) D.20878;
  goto <D.18938>;
  <D.18937>:
  D.20888 = (long unsigned int) i;
  D.20889 = D.20888 * 8;
  D.20890 = mspecs + D.20889;
  D.20891 = *D.20890;
  if (D.20891 != 0B) goto <D.20955>; else goto <D.20956>;
  <D.20955>:
  D.20888 = (long unsigned int) i;
  D.20889 = D.20888 * 8;
  D.20890 = mspecs + D.20889;
  D.20891 = *D.20890;
  mono_metadata_free_marshal_spec (D.20891);
  <D.20956>:
  i = i + -1;
  <D.18938>:
  if (i >= 0) goto <D.18937>; else goto <D.18939>;
  <D.18939>:
  monoeg_g_free (mspecs);
  D.20957 = res;
  return D.20957;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.20961;
  int D.20966;
  void * D.20968;
  long unsigned int D.20969;

  D.20961 = __builtin_constant_p (__len);
  if (D.20961 != 0) goto <D.20962>; else goto <D.20963>;
  <D.20962>:
  if (__len == 0) goto <D.20964>; else goto <D.20965>;
  <D.20964>:
  D.20966 = __builtin_constant_p (__ch);
  if (D.20966 == 0) goto <D.20959>; else goto <D.20967>;
  <D.20967>:
  if (__ch != 0) goto <D.20959>; else goto <D.20960>;
  <D.20959>:
  __warn_memset_zero_len ();
  D.20968 = __dest;
  return D.20968;
  <D.20960>:
  <D.20965>:
  <D.20963>:
  D.20969 = __builtin_object_size (__dest, 0);
  D.20968 = __builtin___memset_chk (__dest, __ch, __len, D.20969);
  return D.20968;
}


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

  if (str != 0B) goto <D.20971>; else goto <D.20972>;
  <D.20971>:
  D.20973 = __strdup (str);
  return D.20973;
  <D.20972>:
  D.20973 = 0B;
  return D.20973;
}


mono_cominterop_get_invoke (struct MonoMethod * method)
{
  struct MonoClass * D.20975;
  struct MonoImage * D.20976;
  struct GHashTable * * D.20977;
  _Bool D.20978;
  long int D.20979;
  long int D.20980;
  struct MonoMethod * D.20985;
  unsigned char D.20986;
  unsigned char D.20987;
  const char * D.20990;
  struct MonoClass * D.20991;
  struct MonoType * D.20992;
  unsigned int i.90;
  short unsigned int D.20994;
  int D.20995;
  short unsigned int D.20996;
  int D.20997;
  int D.20998;
  short unsigned int D.21002;
  int D.21003;
  int D.21004;
  int D.18989;
  int iftmp.91;
  int D.18988;
  const char[6] * D.21011;
  unsigned char D.21012;
  int D.21013;
  unsigned char D.21014;
  int D.21015;
  _Bool D.21016;
  _Bool D.21017;
  _Bool D.21018;
  const unsigned char * D.21021;
  unsigned char D.21022;
  int D.21023;
  const unsigned char * D.21024;
  unsigned char D.21025;
  int D.21026;
  _Bool D.21027;
  _Bool D.21028;
  const unsigned char * D.21031;
  unsigned char D.21032;
  int D.21033;
  const unsigned char * D.21034;
  unsigned char D.21035;
  int D.21036;
  _Bool D.21037;
  _Bool D.21038;
  const unsigned char * D.21041;
  unsigned char D.21042;
  int D.21043;
  const unsigned char * D.21044;
  unsigned char D.21045;
  int D.21046;
  struct MonoClass * com_interop_proxy_class.92;
  struct MonoImage * D.21053;
  struct MonoClass * com_interop_proxy_class.93;
  struct MonoMethod * cache_proxy.94;
  struct MonoMethod * cache_proxy.95;
  int D.21059;
  struct MonoMethodSignature * sig;
  struct MonoMethodBuilder * mb;
  struct MonoMethod * res;
  int i;
  int temp_obj;
  struct GHashTable * cache;

  D.20975 = method->klass;
  D.20976 = D.20975->image;
  D.20977 = &D.20976->cominterop_invoke_cache;
  cache = mono_marshal_get_cache (D.20977, mono_aligned_addr_hash, 0B);
  D.20978 = method == 0B;
  D.20979 = (long int) D.20978;
  D.20980 = __builtin_expect (D.20979, 0);
  if (D.20980 != 0) goto <D.20981>; else goto <D.20982>;
  <D.20981>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 982, "method");
  <D.20982>:
  res = mono_marshal_find_in_cache (cache, method);
  if (res != 0B) goto <D.20983>; else goto <D.20984>;
  <D.20983>:
  D.20985 = res;
  return D.20985;
  <D.20984>:
  sig = mono_signature_no_pinvoke (method);
  D.20986 = BIT_FIELD_REF <*sig, 8, 112>;
  D.20987 = D.20986 & 64;
  if (D.20987 == 0) goto <D.20988>; else goto <D.20989>;
  <D.20988>:
  D.20985 = method;
  return D.20985;
  <D.20989>:
  D.20990 = method->name;
  D.20975 = method->klass;
  mb = mono_mb_new (D.20975, D.20990, 26);
  D.20991 = mono_defaults.object_class;
  D.20992 = &D.20991->byval_arg;
  temp_obj = mono_mb_add_local (mb, D.20992);
  mono_mb_emit_ldarg (mb, 0);
  mono_mb_emit_ldflda (mb, 16);
  mono_mb_emit_byte (mb, 80);
  mono_mb_emit_ldflda (mb, 80);
  mono_mb_emit_byte (mb, 80);
  i = 1;
  goto <D.18978>;
  <D.18977>:
  i.90 = (unsigned int) i;
  mono_mb_emit_ldarg (mb, i.90);
  i = i + 1;
  <D.18978>:
  D.20994 = sig->param_count;
  D.20995 = (int) D.20994;
  if (D.20995 >= i) goto <D.18977>; else goto <D.18979>;
  <D.18979>:
  D.20996 = method->iflags;
  D.20997 = (int) D.20996;
  D.20998 = D.20997 & 4096;
  if (D.20998 != 0) goto <D.20999>; else goto <D.21000>;
  <D.20999>:
  {
    struct MonoMethod * native_wrapper;

    native_wrapper = mono_cominterop_get_native_wrapper (method);
    mono_mb_emit_managed_call (mb, native_wrapper, 0B);
  }
  goto <D.21001>;
  <D.21000>:
  D.21002 = method->flags;
  D.21003 = (int) D.21002;
  D.21004 = D.21003 & 64;
  if (D.21004 != 0) goto <D.21005>; else goto <D.21006>;
  <D.21005>:
  mono_mb_emit_op (mb, 111, method);
  goto <D.21007>;
  <D.21006>:
  mono_mb_emit_op (mb, 40, method);
  <D.21007>:
  <D.21001>:
  {
    size_t __s1_len;
    size_t __s2_len;

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

      __s2 = method->name;
      D.21011 = ".ctor";
      D.21012 = MEM[(const unsigned char *)D.21011];
      D.21013 = (int) D.21012;
      D.21014 = *__s2;
      D.21015 = (int) D.21014;
      __result = D.21013 - D.21015;
      {
        D.21016 = __s2_len != 0;
        D.21017 = __result == 0;
        D.21018 = D.21016 & D.21017;
        if (D.21018 != 0) goto <D.21019>; else goto <D.21020>;
        <D.21019>:
        D.21021 = &MEM[(void *)".ctor" + 1B];
        D.21022 = *D.21021;
        D.21023 = (int) D.21022;
        D.21024 = __s2 + 1;
        D.21025 = *D.21024;
        D.21026 = (int) D.21025;
        __result = D.21023 - D.21026;
        D.21027 = __s2_len > 1;
        D.21017 = __result == 0;
        D.21028 = D.21027 & D.21017;
        if (D.21028 != 0) goto <D.21029>; else goto <D.21030>;
        <D.21029>:
        D.21031 = &MEM[(void *)".ctor" + 2B];
        D.21032 = *D.21031;
        D.21033 = (int) D.21032;
        D.21034 = __s2 + 2;
        D.21035 = *D.21034;
        D.21036 = (int) D.21035;
        __result = D.21033 - D.21036;
        D.21037 = __s2_len > 2;
        D.21017 = __result == 0;
        D.21038 = D.21037 & D.21017;
        if (D.21038 != 0) goto <D.21039>; else goto <D.21040>;
        <D.21039>:
        D.21041 = &MEM[(void *)".ctor" + 3B];
        D.21042 = *D.21041;
        D.21043 = (int) D.21042;
        D.21044 = __s2 + 3;
        D.21045 = *D.21044;
        D.21046 = (int) D.21045;
        __result = D.21043 - D.21046;
        <D.21040>:
        <D.21030>:
        <D.21020>:
      }
      D.18988 = __result;
    }
    iftmp.91 = -D.18988;
    goto <D.21047>;
    <D.21010>:
    D.20990 = method->name;
    iftmp.91 = __builtin_strcmp (D.20990, ".ctor");
    <D.21047>:
    D.18989 = iftmp.91;
  }
  if (D.18989 == 0) goto <D.21048>; else goto <D.21049>;
  <D.21048>:
  {
    static struct MonoClass * com_interop_proxy_class = 0B;
    static struct MonoMethod * cache_proxy = 0B;

    com_interop_proxy_class.92 = com_interop_proxy_class;
    if (com_interop_proxy_class.92 == 0B) goto <D.21051>; else goto <D.21052>;
    <D.21051>:
    D.21053 = mono_defaults.corlib;
    com_interop_proxy_class.93 = mono_class_from_name (D.21053, "Mono.Interop", "ComInteropProxy");
    com_interop_proxy_class = com_interop_proxy_class.93;
    <D.21052>:
    cache_proxy.94 = cache_proxy;
    if (cache_proxy.94 == 0B) goto <D.21056>; else goto <D.21057>;
    <D.21056>:
    com_interop_proxy_class.92 = com_interop_proxy_class;
    cache_proxy.95 = mono_class_get_method_from_name (com_interop_proxy_class.92, "CacheProxy", 0);
    cache_proxy = cache_proxy.95;
    <D.21057>:
    mono_mb_emit_ldarg (mb, 0);
    mono_mb_emit_ldflda (mb, 16);
    mono_mb_emit_byte (mb, 80);
    cache_proxy.94 = cache_proxy;
    mono_mb_emit_managed_call (mb, cache_proxy.94, 0B);
  }
  <D.21049>:
  mono_marshal_emit_thread_interrupt_checkpoint (mb);
  mono_mb_emit_byte (mb, 42);
  D.20994 = sig->param_count;
  D.20995 = (int) D.20994;
  D.21059 = D.20995 + 16;
  res = mono_mb_create_and_cache (cache, method, mb, sig, D.21059);
  mono_mb_free (mb);
  D.20985 = res;
  return D.20985;
}


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.96;
  struct MonoClass * D.21064;
  struct MonoMethod * get_object_for_iunknown.97;
  struct MonoMethod * get_iunknown_for_object_internal.98;
  struct MonoMethod * get_iunknown_for_object_internal.99;
  struct MonoMethod * get_idispatch_for_object_internal.100;
  struct MonoMethod * get_idispatch_for_object_internal.101;
  struct MonoMethod * get_com_interface_for_object_internal.102;
  struct MonoMethod * get_com_interface_for_object_internal.103;
  struct MonoMethod * marshal_release.104;
  struct MonoMethod * marshal_release.105;
  struct MonoClass * D.21082;
  struct MonoType * D.21083;
  unsigned int conv_arg.106;
  unsigned char D.21085;
  unsigned char D.21086;
  short unsigned int D.21089;
  int D.21090;
  int D.21091;
  unsigned int argnum.107;
  struct MonoClass * D.21101;
  <unnamed type> D.21103;
  struct MonoType * D.21118;
  unsigned int ccw_obj.108;
  unsigned int ret_ptr.109;
  unsigned int ccw_obj.110;
  struct MonoType * D.21141;
  unsigned int ccw_obj.111;
  struct MonoMethod * AddRef.112;
  struct MonoMethod * AddRef.113;
  struct MonoMethod * AddRef.114;
  unsigned int ccw_obj.115;
  int D.21198;
  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.96 = get_object_for_iunknown;
  if (get_object_for_iunknown.96 == 0B) goto <D.21062>; else goto <D.21063>;
  <D.21062>:
  D.21064 = mono_defaults.marshal_class;
  get_object_for_iunknown.97 = mono_class_get_method_from_name (D.21064, "GetObjectForIUnknown", 1);
  get_object_for_iunknown = get_object_for_iunknown.97;
  <D.21063>:
  get_iunknown_for_object_internal.98 = get_iunknown_for_object_internal;
  if (get_iunknown_for_object_internal.98 == 0B) goto <D.21067>; else goto <D.21068>;
  <D.21067>:
  D.21064 = mono_defaults.marshal_class;
  get_iunknown_for_object_internal.99 = mono_class_get_method_from_name (D.21064, "GetIUnknownForObjectInternal", 1);
  get_iunknown_for_object_internal = get_iunknown_for_object_internal.99;
  <D.21068>:
  get_idispatch_for_object_internal.100 = get_idispatch_for_object_internal;
  if (get_idispatch_for_object_internal.100 == 0B) goto <D.21071>; else goto <D.21072>;
  <D.21071>:
  D.21064 = mono_defaults.marshal_class;
  get_idispatch_for_object_internal.101 = mono_class_get_method_from_name (D.21064, "GetIDispatchForObjectInternal", 1);
  get_idispatch_for_object_internal = get_idispatch_for_object_internal.101;
  <D.21072>:
  get_com_interface_for_object_internal.102 = get_com_interface_for_object_internal;
  if (get_com_interface_for_object_internal.102 == 0B) goto <D.21075>; else goto <D.21076>;
  <D.21075>:
  D.21064 = mono_defaults.marshal_class;
  get_com_interface_for_object_internal.103 = mono_class_get_method_from_name (D.21064, "GetComInterfaceForObjectInternal", 2);
  get_com_interface_for_object_internal = get_com_interface_for_object_internal.103;
  <D.21076>:
  marshal_release.104 = marshal_release;
  if (marshal_release.104 == 0B) goto <D.21079>; else goto <D.21080>;
  <D.21079>:
  D.21064 = mono_defaults.marshal_class;
  marshal_release.105 = mono_class_get_method_from_name (D.21064, "Release", 1);
  marshal_release = marshal_release.105;
  <D.21080>:
  switch (action) <default: <D.19037>, case 0: <D.19012>, case 1: <D.19020>, case 2: <D.19015>, case 3: <D.19021>, case 4: <D.19027>, case 5: <D.19032>, case 6: <D.19034>>
  <D.19012>:
  {
    guint32 pos_null;

    pos_null = 0;
    D.21082 = mono_defaults.int_class;
    D.21083 = &D.21082->byval_arg;
    *conv_arg_type = D.21083;
    D.21082 = mono_defaults.int_class;
    D.21083 = &D.21082->byval_arg;
    conv_arg = mono_mb_add_local (mb, D.21083);
    mono_mb_emit_ptr (mb, 0B);
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.106);
    D.21085 = BIT_FIELD_REF <*t, 8, 88>;
    D.21086 = D.21085 & 64;
    if (D.21086 != 0) goto <D.21087>; else goto <D.21088>;
    <D.21087>:
    D.21089 = t->attrs;
    D.21090 = (int) D.21089;
    D.21091 = D.21090 & 2;
    if (D.21091 != 0) goto <D.19014>; else goto <D.21092>;
    <D.21092>:
    <D.21088>:
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    D.21085 = BIT_FIELD_REF <*t, 8, 88>;
    D.21086 = D.21085 & 64;
    if (D.21086 != 0) goto <D.21094>; else goto <D.21095>;
    <D.21094>:
    mono_mb_emit_byte (mb, 80);
    <D.21095>:
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    D.21085 = BIT_FIELD_REF <*t, 8, 88>;
    D.21086 = D.21085 & 64;
    if (D.21086 != 0) goto <D.21096>; else goto <D.21097>;
    <D.21096>:
    mono_mb_emit_byte (mb, 80);
    <D.21097>:
    if (klass != 0B) goto <D.21100>; else goto <D.21098>;
    <D.21100>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21102>; else goto <D.21098>;
    <D.21102>:
    mono_mb_emit_ptr (mb, t);
    mono_mb_emit_icall (mb, cominterop_type_from_handle);
    get_com_interface_for_object_internal.102 = get_com_interface_for_object_internal;
    mono_mb_emit_managed_call (mb, get_com_interface_for_object_internal.102, 0B);
    goto <D.21099>;
    <D.21098>:
    D.21103 = spec->native;
    if (D.21103 == 25) goto <D.21104>; else goto <D.21105>;
    <D.21104>:
    get_iunknown_for_object_internal.98 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.98, 0B);
    goto <D.21106>;
    <D.21105>:
    D.21103 = spec->native;
    if (D.21103 == 26) goto <D.21107>; else goto <D.21108>;
    <D.21107>:
    get_idispatch_for_object_internal.100 = get_idispatch_for_object_internal;
    mono_mb_emit_managed_call (mb, get_idispatch_for_object_internal.100, 0B);
    goto <D.21109>;
    <D.21108>:
    if (klass == 0B) goto <D.21112>; else goto <D.21110>;
    <D.21112>:
    D.21103 = spec->native;
    if (D.21103 == 28) goto <D.21113>; else goto <D.21110>;
    <D.21113>:
    get_iunknown_for_object_internal.98 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.98, 0B);
    goto <D.21111>;
    <D.21110>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1128);
    <D.21111>:
    <D.21109>:
    <D.21106>:
    <D.21099>:
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.106);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.19014>;
  }
  <D.19015>:
  D.21085 = BIT_FIELD_REF <*t, 8, 88>;
  D.21086 = D.21085 & 64;
  if (D.21086 != 0) goto <D.21114>; else goto <D.21115>;
  <D.21114>:
  D.21089 = t->attrs;
  D.21090 = (int) D.21089;
  D.21091 = D.21090 & 2;
  if (D.21091 != 0) goto <D.21116>; else goto <D.21117>;
  <D.21116>:
  {
    int ccw_obj;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.21101 = mono_defaults.object_class;
    D.21118 = &D.21101->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.21118);
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    mono_mb_emit_byte (mb, 20);
    mono_mb_emit_byte (mb, 81);
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.106);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.106);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_ccw_object);
    ccw_obj.108 = (unsigned int) ccw_obj;
    mono_mb_emit_stloc (mb, ccw_obj.108);
    ccw_obj.108 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.108);
    pos_ccw = mono_mb_emit_short_branch (mb, 45);
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.106);
    get_object_for_iunknown.96 = get_object_for_iunknown;
    mono_mb_emit_managed_call (mb, get_object_for_iunknown.96, 0B);
    if (klass != 0B) goto <D.21120>; else goto <D.21121>;
    <D.21120>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21122>; else goto <D.21123>;
    <D.21122>:
    mono_mb_emit_op (mb, 116, klass);
    <D.21123>:
    <D.21121>:
    mono_mb_emit_byte (mb, 81);
    pos_end = mono_mb_emit_short_branch (mb, 43);
    mono_mb_patch_short_branch (mb, pos_ccw);
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    ccw_obj.108 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.108);
    if (klass != 0B) goto <D.21124>; else goto <D.21125>;
    <D.21124>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21126>; else goto <D.21127>;
    <D.21126>:
    mono_mb_emit_op (mb, 116, klass);
    <D.21127>:
    <D.21125>:
    mono_mb_emit_byte (mb, 81);
    mono_mb_patch_short_branch (mb, pos_end);
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.106);
    marshal_release.104 = marshal_release;
    mono_mb_emit_managed_call (mb, marshal_release.104, 0B);
    mono_mb_emit_byte (mb, 38);
    mono_mb_patch_short_branch (mb, pos_null);
  }
  <D.21117>:
  <D.21115>:
  goto <D.19014>;
  <D.19020>:
  D.21085 = BIT_FIELD_REF <*t, 8, 88>;
  D.21086 = D.21085 & 64;
  if (D.21086 != 0) goto <D.21128>; else goto <D.21129>;
  <D.21128>:
  conv_arg.106 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc_addr (mb, conv_arg.106);
  goto <D.21130>;
  <D.21129>:
  conv_arg.106 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc (mb, conv_arg.106);
  <D.21130>:
  goto <D.19014>;
  <D.19021>:
  {
    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.21101 = mono_defaults.object_class;
    D.21118 = &D.21101->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.21118);
    D.21082 = mono_defaults.int_class;
    D.21083 = &D.21082->byval_arg;
    ret_ptr = mono_mb_add_local (mb, D.21083);
    ret_ptr.109 = (unsigned int) ret_ptr;
    mono_mb_emit_stloc (mb, ret_ptr.109);
    ret_ptr.109 = (unsigned int) ret_ptr;
    mono_mb_emit_ldloc (mb, ret_ptr.109);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    ret_ptr.109 = (unsigned int) ret_ptr;
    mono_mb_emit_ldloc (mb, ret_ptr.109);
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_ccw_object);
    ccw_obj.110 = (unsigned int) ccw_obj;
    mono_mb_emit_stloc (mb, ccw_obj.110);
    ccw_obj.110 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.110);
    pos_ccw = mono_mb_emit_short_branch (mb, 45);
    ret_ptr.109 = (unsigned int) ret_ptr;
    mono_mb_emit_ldloc (mb, ret_ptr.109);
    get_object_for_iunknown.96 = get_object_for_iunknown;
    mono_mb_emit_managed_call (mb, get_object_for_iunknown.96, 0B);
    if (klass != 0B) goto <D.21133>; else goto <D.21134>;
    <D.21133>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21135>; else goto <D.21136>;
    <D.21135>:
    mono_mb_emit_op (mb, 116, klass);
    <D.21136>:
    <D.21134>:
    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.110 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.110);
    if (klass != 0B) goto <D.21137>; else goto <D.21138>;
    <D.21137>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21139>; else goto <D.21140>;
    <D.21139>:
    mono_mb_emit_op (mb, 116, klass);
    <D.21140>:
    <D.21138>:
    mono_mb_emit_stloc (mb, 3);
    mono_mb_patch_short_branch (mb, pos_end);
    ret_ptr.109 = (unsigned int) ret_ptr;
    mono_mb_emit_ldloc (mb, ret_ptr.109);
    marshal_release.104 = marshal_release;
    mono_mb_emit_managed_call (mb, marshal_release.104, 0B);
    mono_mb_emit_byte (mb, 38);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.19014>;
  }
  <D.19027>:
  {
    int ccw_obj;
    guint32 pos_null;
    guint32 pos_ccw;
    guint32 pos_end;

    pos_null = 0;
    pos_ccw = 0;
    pos_end = 0;
    D.21101 = mono_defaults.object_class;
    D.21118 = &D.21101->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.21118);
    klass = mono_class_from_mono_type (t);
    D.21141 = &klass->byval_arg;
    conv_arg = mono_mb_add_local (mb, D.21141);
    D.21082 = mono_defaults.int_class;
    D.21083 = &D.21082->byval_arg;
    *conv_arg_type = D.21083;
    mono_mb_emit_byte (mb, 20);
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.106);
    D.21089 = t->attrs;
    D.21090 = (int) D.21089;
    D.21091 = D.21090 & 2;
    if (D.21091 != 0) goto <D.19014>; else goto <D.21142>;
    <D.21142>:
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    D.21085 = BIT_FIELD_REF <*t, 8, 88>;
    D.21086 = D.21085 & 64;
    if (D.21086 != 0) goto <D.21143>; else goto <D.21144>;
    <D.21143>:
    mono_mb_emit_byte (mb, 80);
    <D.21144>:
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    D.21085 = BIT_FIELD_REF <*t, 8, 88>;
    D.21086 = D.21085 & 64;
    if (D.21086 != 0) goto <D.21145>; else goto <D.21146>;
    <D.21145>:
    mono_mb_emit_byte (mb, 80);
    <D.21146>:
    mono_mb_emit_icon (mb, 1);
    mono_mb_emit_icall (mb, cominterop_get_ccw_object);
    ccw_obj.111 = (unsigned int) ccw_obj;
    mono_mb_emit_stloc (mb, ccw_obj.111);
    ccw_obj.111 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.111);
    pos_ccw = mono_mb_emit_short_branch (mb, 45);
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    D.21085 = BIT_FIELD_REF <*t, 8, 88>;
    D.21086 = D.21085 & 64;
    if (D.21086 != 0) goto <D.21148>; else goto <D.21149>;
    <D.21148>:
    mono_mb_emit_byte (mb, 80);
    <D.21149>:
    get_object_for_iunknown.96 = get_object_for_iunknown;
    mono_mb_emit_managed_call (mb, get_object_for_iunknown.96, 0B);
    if (klass != 0B) goto <D.21150>; else goto <D.21151>;
    <D.21150>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21152>; else goto <D.21153>;
    <D.21152>:
    mono_mb_emit_op (mb, 116, klass);
    <D.21153>:
    <D.21151>:
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.106);
    pos_end = mono_mb_emit_short_branch (mb, 43);
    mono_mb_patch_short_branch (mb, pos_ccw);
    ccw_obj.111 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.111);
    if (klass != 0B) goto <D.21154>; else goto <D.21155>;
    <D.21154>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21156>; else goto <D.21157>;
    <D.21156>:
    mono_mb_emit_op (mb, 116, klass);
    <D.21157>:
    <D.21155>:
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_stloc (mb, conv_arg.106);
    mono_mb_patch_short_branch (mb, pos_end);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.19014>;
  }
  <D.19032>:
  D.21085 = BIT_FIELD_REF <*t, 8, 88>;
  D.21086 = D.21085 & 64;
  if (D.21086 != 0) goto <D.21158>; else goto <D.21159>;
  <D.21158>:
  D.21089 = t->attrs;
  D.21090 = (int) D.21089;
  D.21091 = D.21090 & 2;
  if (D.21091 != 0) goto <D.21160>; else goto <D.21161>;
  <D.21160>:
  {
    guint32 pos_null;

    pos_null = 0;
    AddRef.112 = AddRef;
    if (AddRef.112 == 0B) goto <D.21163>; else goto <D.21164>;
    <D.21163>:
    D.21064 = mono_defaults.marshal_class;
    AddRef.113 = mono_class_get_method_from_name (D.21064, "AddRef", 1);
    AddRef = AddRef.113;
    <D.21164>:
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    mono_mb_emit_byte (mb, 22);
    mono_mb_emit_byte (mb, 223);
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.106);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    conv_arg.106 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.106);
    if (klass != 0B) goto <D.21168>; else goto <D.21166>;
    <D.21168>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21169>; else goto <D.21166>;
    <D.21169>:
    mono_mb_emit_ptr (mb, t);
    mono_mb_emit_icall (mb, cominterop_type_from_handle);
    get_com_interface_for_object_internal.102 = get_com_interface_for_object_internal;
    mono_mb_emit_managed_call (mb, get_com_interface_for_object_internal.102, 0B);
    goto <D.21167>;
    <D.21166>:
    D.21103 = spec->native;
    if (D.21103 == 25) goto <D.21170>; else goto <D.21171>;
    <D.21170>:
    get_iunknown_for_object_internal.98 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.98, 0B);
    goto <D.21172>;
    <D.21171>:
    D.21103 = spec->native;
    if (D.21103 == 26) goto <D.21173>; else goto <D.21174>;
    <D.21173>:
    get_idispatch_for_object_internal.100 = get_idispatch_for_object_internal;
    mono_mb_emit_managed_call (mb, get_idispatch_for_object_internal.100, 0B);
    goto <D.21175>;
    <D.21174>:
    if (klass == 0B) goto <D.21178>; else goto <D.21176>;
    <D.21178>:
    D.21103 = spec->native;
    if (D.21103 == 28) goto <D.21179>; else goto <D.21176>;
    <D.21179>:
    get_iunknown_for_object_internal.98 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.98, 0B);
    goto <D.21177>;
    <D.21176>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1321);
    <D.21177>:
    <D.21175>:
    <D.21172>:
    <D.21167>:
    mono_mb_emit_byte (mb, 223);
    argnum.107 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.107);
    mono_mb_emit_byte (mb, 77);
    AddRef.112 = AddRef;
    mono_mb_emit_managed_call (mb, AddRef.112, 0B);
    mono_mb_emit_byte (mb, 38);
    mono_mb_patch_short_branch (mb, pos_null);
  }
  <D.21161>:
  <D.21159>:
  goto <D.19014>;
  <D.19034>:
  {
    guint32 pos_null;
    int ccw_obj;

    pos_null = 0;
    D.21101 = mono_defaults.object_class;
    D.21118 = &D.21101->byval_arg;
    ccw_obj = mono_mb_add_local (mb, D.21118);
    AddRef.112 = AddRef;
    if (AddRef.112 == 0B) goto <D.21180>; else goto <D.21181>;
    <D.21180>:
    D.21064 = mono_defaults.marshal_class;
    AddRef.114 = mono_class_get_method_from_name (D.21064, "AddRef", 1);
    AddRef = AddRef.114;
    <D.21181>:
    ccw_obj.115 = (unsigned int) ccw_obj;
    mono_mb_emit_stloc (mb, ccw_obj.115);
    ccw_obj.115 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.115);
    pos_null = mono_mb_emit_short_branch (mb, 44);
    ccw_obj.115 = (unsigned int) ccw_obj;
    mono_mb_emit_ldloc (mb, ccw_obj.115);
    if (klass != 0B) goto <D.21186>; else goto <D.21184>;
    <D.21186>:
    D.21101 = mono_defaults.object_class;
    if (D.21101 != klass) goto <D.21187>; else goto <D.21184>;
    <D.21187>:
    mono_mb_emit_ptr (mb, t);
    mono_mb_emit_icall (mb, cominterop_type_from_handle);
    get_com_interface_for_object_internal.102 = get_com_interface_for_object_internal;
    mono_mb_emit_managed_call (mb, get_com_interface_for_object_internal.102, 0B);
    goto <D.21185>;
    <D.21184>:
    D.21103 = spec->native;
    if (D.21103 == 25) goto <D.21188>; else goto <D.21189>;
    <D.21188>:
    get_iunknown_for_object_internal.98 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.98, 0B);
    goto <D.21190>;
    <D.21189>:
    D.21103 = spec->native;
    if (D.21103 == 26) goto <D.21191>; else goto <D.21192>;
    <D.21191>:
    get_idispatch_for_object_internal.100 = get_idispatch_for_object_internal;
    mono_mb_emit_managed_call (mb, get_idispatch_for_object_internal.100, 0B);
    goto <D.21193>;
    <D.21192>:
    if (klass == 0B) goto <D.21196>; else goto <D.21194>;
    <D.21196>:
    D.21103 = spec->native;
    if (D.21103 == 28) goto <D.21197>; else goto <D.21194>;
    <D.21197>:
    get_iunknown_for_object_internal.98 = get_iunknown_for_object_internal;
    mono_mb_emit_managed_call (mb, get_iunknown_for_object_internal.98, 0B);
    goto <D.21195>;
    <D.21194>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1364);
    <D.21195>:
    <D.21193>:
    <D.21190>:
    <D.21185>:
    mono_mb_emit_stloc (mb, 3);
    mono_mb_emit_ldloc (mb, 3);
    AddRef.112 = AddRef;
    mono_mb_emit_managed_call (mb, AddRef.112, 0B);
    mono_mb_emit_byte (mb, 38);
    mono_mb_patch_short_branch (mb, pos_null);
    goto <D.19014>;
  }
  <D.19037>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1376);
  <D.19014>:
  D.21198 = conv_arg;
  return D.21198;
}


ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (void * pUnk)
{
  _Bool D.21200;
  long int D.21201;
  long int D.21202;
  int D.21205;
  struct MonoIUnknown * D.21206;
  int (*<T31d0>) (void *) D.21207;

  D.21200 = pUnk == 0B;
  D.21201 = (long int) D.21200;
  D.21202 = __builtin_expect (D.21201, 0);
  if (D.21202 != 0) goto <D.21203>; else goto <D.21204>;
  <D.21203>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1399, "pUnk");
  <D.21204>:
  D.21206 = MEM[(struct MonoIUnknown * *)pUnk];
  D.21207 = D.21206->AddRef;
  D.21205 = D.21207 (pUnk);
  return D.21205;
}


ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (void * pUnk, void * riid, void * * ppv)
{
  _Bool D.21209;
  long int D.21210;
  long int D.21211;
  int D.21214;
  struct MonoIUnknown * D.21215;
  int (*<T2ff7>) (void *, void *, void * *) D.21216;

  D.21209 = pUnk == 0B;
  D.21210 = (long int) D.21209;
  D.21211 = __builtin_expect (D.21210, 0);
  if (D.21211 != 0) goto <D.21212>; else goto <D.21213>;
  <D.21212>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1406, "pUnk");
  <D.21213>:
  D.21215 = MEM[(struct MonoIUnknown * *)pUnk];
  D.21216 = D.21215->QueryInterface;
  D.21214 = D.21216 (pUnk, riid, ppv);
  return D.21214;
}


ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (void * pUnk)
{
  _Bool D.21218;
  long int D.21219;
  long int D.21220;
  int D.21223;
  struct MonoIUnknown * D.21224;
  int (*<T31d0>) (void *) D.21225;

  D.21218 = pUnk == 0B;
  D.21219 = (long int) D.21218;
  D.21220 = __builtin_expect (D.21219, 0);
  if (D.21220 != 0) goto <D.21221>; else goto <D.21222>;
  <D.21221>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1413, "pUnk");
  <D.21222>:
  D.21224 = MEM[(struct MonoIUnknown * *)pUnk];
  D.21225 = D.21224->Release;
  D.21223 = D.21225 (pUnk);
  return D.21223;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal (struct MonoObject * object)
{
  void * D.21229;
  int D.21230;
  struct MonoVTable * D.21235;
  struct MonoClass * D.21236;
  struct MonoVTable * D.21241;
  struct MonoClass * D.21242;
  struct MonoComObject * D.21245;
  struct MonoClass * D.21248;

  if (object == 0B) goto <D.21227>; else goto <D.21228>;
  <D.21227>:
  D.21229 = 0B;
  return D.21229;
  <D.21228>:
  D.21230 = cominterop_object_is_rcw (object);
  if (D.21230 != 0) goto <D.21231>; else goto <D.21232>;
  <D.21231>:
  {
    struct MonoClass * klass;
    struct MonoRealProxy * real_proxy;

    klass = 0B;
    real_proxy = 0B;
    if (object == 0B) goto <D.21233>; else goto <D.21234>;
    <D.21233>:
    D.21229 = 0B;
    return D.21229;
    <D.21234>:
    D.21235 = object->vtable;
    klass = D.21235->klass;
    D.21236 = mono_defaults.transparent_proxy_class;
    if (D.21236 != klass) goto <D.21237>; else goto <D.21238>;
    <D.21237>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1460);
    D.21229 = 0B;
    return D.21229;
    <D.21238>:
    real_proxy = MEM[(struct MonoTransparentProxy *)object].rp;
    if (real_proxy == 0B) goto <D.21239>; else goto <D.21240>;
    <D.21239>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1466);
    D.21229 = 0B;
    return D.21229;
    <D.21240>:
    D.21241 = MEM[(struct MonoObject *)real_proxy].vtable;
    klass = D.21241->klass;
    D.21242 = mono_class_get_interop_proxy_class ();
    if (D.21242 != klass) goto <D.21243>; else goto <D.21244>;
    <D.21243>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1472);
    D.21229 = 0B;
    return D.21229;
    <D.21244>:
    D.21245 = MEM[(struct MonoComInteropProxy *)real_proxy].com_object;
    if (D.21245 == 0B) goto <D.21246>; else goto <D.21247>;
    <D.21246>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 1477);
    D.21229 = 0B;
    return D.21229;
    <D.21247>:
    D.21245 = MEM[(struct MonoComInteropProxy *)real_proxy].com_object;
    D.21229 = D.21245->iunknown;
    return D.21229;
  }
  <D.21232>:
  D.21248 = mono_class_get_iunknown_class ();
  D.21229 = cominterop_get_ccw (object, D.21248);
  return D.21229;
}


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

  object = 0B;
  if (pUnk == 0B) goto <D.21250>; else goto <D.21251>;
  <D.21250>:
  D.21252 = 0B;
  return D.21252;
  <D.21251>:
  object = cominterop_get_ccw_object (pUnk, 1);
  D.21252 = object;
  return D.21252;
}


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

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


cominterop_get_idispatch_for_object (struct MonoObject * object)
{
  void * D.21258;
  int D.21259;
  struct MonoClass * D.21262;
  struct MonoRealProxy * D.21263;
  struct MonoComObject * D.21264;
  struct MonoVTable * D.21265;
  int D.21266;
  struct MonoClass * D.21269;

  if (object == 0B) goto <D.21256>; else goto <D.21257>;
  <D.21256>:
  D.21258 = 0B;
  return D.21258;
  <D.21257>:
  D.21259 = cominterop_object_is_rcw (object);
  if (D.21259 != 0) goto <D.21260>; else goto <D.21261>;
  <D.21260>:
  D.21262 = mono_class_get_idispatch_class ();
  D.21263 = MEM[(struct MonoTransparentProxy *)object].rp;
  D.21264 = MEM[(struct MonoComInteropProxy *)D.21263].com_object;
  D.21258 = cominterop_get_interface (D.21264, D.21262, 1);
  return D.21258;
  <D.21261>:
  {
    struct MonoClass * klass;

    D.21265 = object->vtable;
    klass = D.21265->klass;
    D.21266 = cominterop_can_support_dispatch (klass);
    if (D.21266 == 0) goto <D.21267>; else goto <D.21268>;
    <D.21267>:
    cominterop_raise_hr_exception (-2147467262);
    <D.21268>:
    D.21269 = mono_class_get_idispatch_class ();
    D.21258 = cominterop_get_ccw (object, D.21269);
    return D.21258;
  }
}


ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (struct MonoObject * object, struct MonoReflectionType * type)
{
  _Bool D.21271;
  long int D.21272;
  long int D.21273;
  struct MonoType * D.21276;
  _Bool D.21277;
  long int D.21278;
  long int D.21279;
  _Bool D.21282;
  long int D.21283;
  long int D.21284;
  int D.21287;
  struct MonoException * D.21290;
  _Bool D.21291;
  long int D.21292;
  long int D.21293;
  void * D.21296;
  struct MonoClass * klass;
  void * itf;

  klass = 0B;
  itf = 0B;
  D.21271 = type == 0B;
  D.21272 = (long int) D.21271;
  D.21273 = __builtin_expect (D.21272, 0);
  if (D.21273 != 0) goto <D.21274>; else goto <D.21275>;
  <D.21274>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1525, "type");
  <D.21275>:
  D.21276 = type->type;
  D.21277 = D.21276 == 0B;
  D.21278 = (long int) D.21277;
  D.21279 = __builtin_expect (D.21278, 0);
  if (D.21279 != 0) goto <D.21280>; else goto <D.21281>;
  <D.21280>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1526, "type->type");
  <D.21281>:
  D.21276 = type->type;
  klass = mono_type_get_class (D.21276);
  D.21282 = klass == 0B;
  D.21283 = (long int) D.21282;
  D.21284 = __builtin_expect (D.21283, 0);
  if (D.21284 != 0) goto <D.21285>; else goto <D.21286>;
  <D.21285>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1528, "klass");
  <D.21286>:
  D.21287 = mono_class_init (klass);
  if (D.21287 == 0) goto <D.21288>; else goto <D.21289>;
  <D.21288>:
  D.21290 = mono_class_get_exception_for_failure (klass);
  mono_raise_exception (D.21290);
  <D.21289>:
  itf = cominterop_get_ccw (object, klass);
  D.21291 = itf == 0B;
  D.21292 = (long int) D.21291;
  D.21293 = __builtin_expect (D.21292, 0);
  if (D.21293 != 0) goto <D.21294>; else goto <D.21295>;
  <D.21294>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1533, "itf");
  <D.21295>:
  D.21296 = itf;
  return D.21296;
}


ves_icall_System_Runtime_InteropServices_Marshal_IsComObject (struct MonoObject * object)
{
  MonoBoolean D.21298;
  int D.21299;

  D.21299 = cominterop_object_is_rcw (object);
  D.21298 = (MonoBoolean) D.21299;
  return D.21298;
}


ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal (struct MonoObject * object)
{
  _Bool D.21301;
  long int D.21302;
  long int D.21303;
  int D.21306;
  _Bool D.21307;
  long int D.21308;
  long int D.21309;
  _Bool D.21312;
  long int D.21313;
  long int D.21314;
  int D.21317;
  gint32 D.21320;
  gint32 * D.21321;
  _Bool D.21322;
  long int D.21323;
  long int D.21324;
  struct MonoComObject * D.21329;
  struct MonoComInteropProxy * proxy;
  gint32 ref_count;

  proxy = 0B;
  ref_count = 0;
  D.21301 = object == 0B;
  D.21302 = (long int) D.21301;
  D.21303 = __builtin_expect (D.21302, 0);
  if (D.21303 != 0) goto <D.21304>; else goto <D.21305>;
  <D.21304>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1558, "object");
  <D.21305>:
  D.21306 = cominterop_object_is_rcw (object);
  D.21307 = D.21306 == 0;
  D.21308 = (long int) D.21307;
  D.21309 = __builtin_expect (D.21308, 0);
  if (D.21309 != 0) goto <D.21310>; else goto <D.21311>;
  <D.21310>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1559, "cominterop_object_is_rcw (object)");
  <D.21311>:
  proxy = MEM[(struct MonoTransparentProxy *)object].rp;
  D.21312 = proxy == 0B;
  D.21313 = (long int) D.21312;
  D.21314 = __builtin_expect (D.21313, 0);
  if (D.21314 != 0) goto <D.21315>; else goto <D.21316>;
  <D.21315>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1562, "proxy");
  <D.21316>:
  D.21317 = proxy->ref_count;
  if (D.21317 == 0) goto <D.21318>; else goto <D.21319>;
  <D.21318>:
  D.21320 = -1;
  return D.21320;
  <D.21319>:
  D.21321 = &proxy->ref_count;
  ref_count = InterlockedDecrement (D.21321);
  D.21322 = ref_count < 0;
  D.21323 = (long int) D.21322;
  D.21324 = __builtin_expect (D.21323, 0);
  if (D.21324 != 0) goto <D.21325>; else goto <D.21326>;
  <D.21325>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1569, "ref_count >= 0");
  <D.21326>:
  if (ref_count == 0) goto <D.21327>; else goto <D.21328>;
  <D.21327>:
  D.21329 = proxy->com_object;
  ves_icall_System_ComObject_ReleaseInterfaces (D.21329);
  <D.21328>:
  D.21320 = ref_count;
  return D.21320;
}


ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal (struct MonoReflectionMethod * m)
{
  guint32 D.21331;
  struct MonoMethod * D.21332;
  int D.21333;

  D.21332 = m->method;
  D.21333 = cominterop_get_com_slot_for_method (D.21332);
  D.21331 = (guint32) D.21333;
  return D.21331;
}


ves_icall_System_ComObject_CreateRCW (struct MonoReflectionType * type)
{
  struct MonoVTable * D.21335;
  struct MonoType * D.21336;
  struct MonoVTable * D.21337;
  struct MonoObject * D.21338;
  struct MonoClass * klass;
  struct MonoDomain * domain;
  struct MonoObject * obj;

  D.21335 = MEM[(struct MonoObject *)type].vtable;
  domain = D.21335->domain;
  D.21336 = type->type;
  klass = mono_class_from_mono_type (D.21336);
  D.21337 = mono_class_vtable_full (domain, klass, 1);
  obj = mono_object_new_alloc_specific (D.21337);
  D.21338 = obj;
  return D.21338;
}


ves_icall_System_ComObject_ReleaseInterfaces (struct MonoComObject * obj)
{
  _Bool D.21340;
  long int D.21341;
  long int D.21342;
  struct GHashTable * D.21345;
  _Bool D.21350;
  long int D.21351;
  long int D.21352;
  void * D.21355;
  struct GHashTable * rcw_hash.116;
  void * D.21357;
  long int D.21358;
  _Bool D.21363;
  long int D.21364;
  long int D.21365;

  D.21340 = obj == 0B;
  D.21341 = (long int) D.21340;
  D.21342 = __builtin_expect (D.21341, 0);
  if (D.21342 != 0) goto <D.21343>; else goto <D.21344>;
  <D.21343>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1625, "obj");
  <D.21344>:
  D.21345 = obj->itf_hash;
  if (D.21345 != 0B) goto <D.21346>; else goto <D.21347>;
  <D.21346>:
  {
    guint32 gchandle;

    gchandle = 0;
    {
      int ret;

      ret = pthread_mutex_lock (&cominterop_mutex.mutex);
      if (ret != 0) goto <D.21348>; else goto <D.21349>;
      <D.21348>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
      <D.21349>:
      D.21350 = ret != 0;
      D.21351 = (long int) D.21350;
      D.21352 = __builtin_expect (D.21351, 0);
      if (D.21352 != 0) goto <D.21353>; else goto <D.21354>;
      <D.21353>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1628, "ret == 0");
      <D.21354>:
    }
    D.21355 = obj->iunknown;
    rcw_hash.116 = rcw_hash;
    D.21357 = monoeg_g_hash_table_lookup (rcw_hash.116, D.21355);
    D.21358 = (long int) D.21357;
    gchandle = (guint32) D.21358;
    if (gchandle != 0) goto <D.21359>; else goto <D.21360>;
    <D.21359>:
    mono_gchandle_free (gchandle);
    D.21355 = obj->iunknown;
    rcw_hash.116 = rcw_hash;
    monoeg_g_hash_table_remove (rcw_hash.116, D.21355);
    <D.21360>:
    D.21345 = obj->itf_hash;
    monoeg_g_hash_table_foreach_remove (D.21345, cominterop_rcw_interface_finalizer, 0B);
    D.21345 = obj->itf_hash;
    monoeg_g_hash_table_destroy (D.21345);
    D.21355 = obj->iunknown;
    ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (D.21355);
    obj->iunknown = 0B;
    obj->itf_hash = 0B;
    {
      int ret;

      ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
      if (ret != 0) goto <D.21361>; else goto <D.21362>;
      <D.21361>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
      <D.21362>:
      D.21363 = ret != 0;
      D.21364 = (long int) D.21363;
      D.21365 = __builtin_expect (D.21364, 0);
      if (D.21365 != 0) goto <D.21366>; else goto <D.21367>;
      <D.21366>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1639, "ret == 0");
      <D.21367>:
    }
  }
  <D.21347>:
}


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

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


cominterop_release_all_rcws ()
{
  struct GHashTable * rcw_hash.117;
  _Bool D.21375;
  long int D.21376;
  long int D.21377;
  _Bool D.21382;
  long int D.21383;
  long int D.21384;

  rcw_hash.117 = rcw_hash;
  if (rcw_hash.117 == 0B) goto <D.21371>; else goto <D.21372>;
  <D.21371>:
  return;
  <D.21372>:
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21373>; else goto <D.21374>;
    <D.21373>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21374>:
    D.21375 = ret != 0;
    D.21376 = (long int) D.21375;
    D.21377 = __builtin_expect (D.21376, 0);
    if (D.21377 != 0) goto <D.21378>; else goto <D.21379>;
    <D.21378>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1674, "ret == 0");
    <D.21379>:
  }
  rcw_hash.117 = rcw_hash;
  monoeg_g_hash_table_foreach_remove (rcw_hash.117, cominterop_rcw_finalizer, 0B);
  rcw_hash.117 = rcw_hash;
  monoeg_g_hash_table_destroy (rcw_hash.117);
  rcw_hash = 0B;
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21380>; else goto <D.21381>;
    <D.21380>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21381>:
    D.21382 = ret != 0;
    D.21383 = (long int) D.21382;
    D.21384 = __builtin_expect (D.21383, 0);
    if (D.21384 != 0) goto <D.21385>; else goto <D.21386>;
    <D.21385>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1680, "ret == 0");
    <D.21386>:
  }
}


cominterop_rcw_finalizer (void * key, void * value, void * user_data)
{
  long int value.118;
  struct MonoComObject * D.21393;
  struct GHashTable * D.21394;
  void * D.21397;
  gboolean D.21400;
  guint32 gchandle;

  gchandle = 0;
  value.118 = (long int) value;
  gchandle = (guint32) value.118;
  if (gchandle != 0) goto <D.21389>; else goto <D.21390>;
  <D.21389>:
  {
    struct MonoComInteropProxy * proxy;

    proxy = mono_gchandle_get_target (gchandle);
    if (proxy != 0B) goto <D.21391>; else goto <D.21392>;
    <D.21391>:
    D.21393 = proxy->com_object;
    D.21394 = D.21393->itf_hash;
    if (D.21394 != 0B) goto <D.21395>; else goto <D.21396>;
    <D.21395>:
    D.21393 = proxy->com_object;
    D.21394 = D.21393->itf_hash;
    monoeg_g_hash_table_foreach_remove (D.21394, cominterop_rcw_interface_finalizer, 0B);
    D.21393 = proxy->com_object;
    D.21394 = D.21393->itf_hash;
    monoeg_g_hash_table_destroy (D.21394);
    <D.21396>:
    D.21393 = proxy->com_object;
    D.21397 = D.21393->iunknown;
    if (D.21397 != 0B) goto <D.21398>; else goto <D.21399>;
    <D.21398>:
    D.21393 = proxy->com_object;
    D.21397 = D.21393->iunknown;
    ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (D.21397);
    <D.21399>:
    D.21393 = proxy->com_object;
    D.21393->iunknown = 0B;
    D.21393 = proxy->com_object;
    D.21393->itf_hash = 0B;
    <D.21392>:
    mono_gchandle_free (gchandle);
  }
  <D.21390>:
  D.21400 = 1;
  return D.21400;
}


ves_icall_System_ComObject_GetInterfaceInternal (struct MonoComObject * obj, struct MonoReflectionType * type, MonoBoolean throw_exception)
{
  struct MonoType * D.21402;
  int D.21403;
  struct MonoException * D.21406;
  void * D.21407;
  int D.21408;
  struct MonoClass * class;

  D.21402 = type->type;
  class = mono_type_get_class (D.21402);
  D.21403 = mono_class_init (class);
  if (D.21403 == 0) goto <D.21404>; else goto <D.21405>;
  <D.21404>:
  D.21406 = mono_class_get_exception_for_failure (class);
  mono_raise_exception (D.21406);
  <D.21405>:
  D.21408 = (int) throw_exception;
  D.21407 = cominterop_get_interface (obj, class, D.21408);
  return D.21407;
}


ves_icall_Mono_Interop_ComInteropProxy_AddProxy (void * pUnk, struct MonoComInteropProxy * proxy)
{
  struct GHashTable * rcw_hash.119;
  _Bool D.21415;
  long int D.21416;
  long int D.21417;
  struct GHashTable * rcw_hash.120;
  _Bool D.21423;
  long int D.21424;
  long int D.21425;
  _Bool D.21430;
  long int D.21431;
  long int D.21432;
  long unsigned int D.21435;
  void * D.21436;
  _Bool D.21439;
  long int D.21440;
  long int D.21441;
  guint32 gchandle;

  gchandle = 0;
  rcw_hash.119 = rcw_hash;
  if (rcw_hash.119 == 0B) goto <D.21411>; else goto <D.21412>;
  <D.21411>:
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21413>; else goto <D.21414>;
    <D.21413>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21414>:
    D.21415 = ret != 0;
    D.21416 = (long int) D.21415;
    D.21417 = __builtin_expect (D.21416, 0);
    if (D.21417 != 0) goto <D.21418>; else goto <D.21419>;
    <D.21418>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1703, "ret == 0");
    <D.21419>:
  }
  rcw_hash.120 = monoeg_g_hash_table_new (mono_aligned_addr_hash, 0B);
  rcw_hash = rcw_hash.120;
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21421>; else goto <D.21422>;
    <D.21421>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21422>:
    D.21423 = ret != 0;
    D.21424 = (long int) D.21423;
    D.21425 = __builtin_expect (D.21424, 0);
    if (D.21425 != 0) goto <D.21426>; else goto <D.21427>;
    <D.21426>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1705, "ret == 0");
    <D.21427>:
  }
  <D.21412>:
  gchandle = mono_gchandle_new_weakref (proxy, 0);
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21428>; else goto <D.21429>;
    <D.21428>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21429>:
    D.21430 = ret != 0;
    D.21431 = (long int) D.21430;
    D.21432 = __builtin_expect (D.21431, 0);
    if (D.21432 != 0) goto <D.21433>; else goto <D.21434>;
    <D.21433>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1710, "ret == 0");
    <D.21434>:
  }
  D.21435 = (long unsigned int) gchandle;
  D.21436 = (void *) D.21435;
  rcw_hash.119 = rcw_hash;
  monoeg_g_hash_table_insert_replace (rcw_hash.119, pUnk, D.21436, 0);
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21437>; else goto <D.21438>;
    <D.21437>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21438>:
    D.21439 = ret != 0;
    D.21440 = (long int) D.21439;
    D.21441 = __builtin_expect (D.21440, 0);
    if (D.21441 != 0) goto <D.21442>; else goto <D.21443>;
    <D.21442>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1712, "ret == 0");
    <D.21443>:
  }
}


ves_icall_Mono_Interop_ComInteropProxy_FindProxy (void * pUnk)
{
  _Bool D.21446;
  long int D.21447;
  long int D.21448;
  struct GHashTable * rcw_hash.121;
  void * D.21454;
  long int D.21455;
  _Bool D.21458;
  long int D.21459;
  long int D.21460;
  struct MonoComInteropProxy * D.21467;
  struct MonoComInteropProxy * proxy;
  guint32 gchandle;

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

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21444>; else goto <D.21445>;
    <D.21444>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21445>:
    D.21446 = ret != 0;
    D.21447 = (long int) D.21446;
    D.21448 = __builtin_expect (D.21447, 0);
    if (D.21448 != 0) goto <D.21449>; else goto <D.21450>;
    <D.21449>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1725, "ret == 0");
    <D.21450>:
  }
  rcw_hash.121 = rcw_hash;
  if (rcw_hash.121 != 0B) goto <D.21452>; else goto <D.21453>;
  <D.21452>:
  rcw_hash.121 = rcw_hash;
  D.21454 = monoeg_g_hash_table_lookup (rcw_hash.121, pUnk);
  D.21455 = (long int) D.21454;
  gchandle = (guint32) D.21455;
  <D.21453>:
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21456>; else goto <D.21457>;
    <D.21456>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21457>:
    D.21458 = ret != 0;
    D.21459 = (long int) D.21458;
    D.21460 = __builtin_expect (D.21459, 0);
    if (D.21460 != 0) goto <D.21461>; else goto <D.21462>;
    <D.21461>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 1728, "ret == 0");
    <D.21462>:
  }
  if (gchandle != 0) goto <D.21463>; else goto <D.21464>;
  <D.21463>:
  proxy = mono_gchandle_get_target (gchandle);
  if (proxy == 0B) goto <D.21465>; else goto <D.21466>;
  <D.21465>:
  mono_gchandle_free (gchandle);
  rcw_hash.121 = rcw_hash;
  monoeg_g_hash_table_remove (rcw_hash.121, pUnk);
  <D.21466>:
  <D.21464>:
  D.21467 = proxy;
  return D.21467;
}


mono_marshal_free_ccw (struct MonoObject * object)
{
  struct GHashTable * ccw_hash.122;
  unsigned int D.21473;
  gboolean D.21474;
  _Bool D.21477;
  long int D.21478;
  long int D.21479;
  int D.21482;
  long int D.21483;
  const void * D.21484;
  _Bool D.21487;
  long int D.21488;
  long int D.21489;
  unsigned int D.21494;
  _Bool D.21495;
  _Bool D.21496;
  _Bool D.21497;
  struct GHashTable * D.21500;
  struct GList * iftmp.123;
  struct GList * iftmp.124;
  unsigned int D.21510;
  int D.21513;
  long int D.21514;
  const void * D.21515;
  struct GList * ccw_list;
  struct GList * ccw_list_orig;
  struct GList * ccw_list_item;

  ccw_hash.122 = ccw_hash;
  if (ccw_hash.122 == 0B) goto <D.21469>; else goto <D.21472>;
  <D.21472>:
  ccw_hash.122 = ccw_hash;
  D.21473 = monoeg_g_hash_table_size (ccw_hash.122);
  if (D.21473 == 0) goto <D.21469>; else goto <D.21470>;
  <D.21469>:
  D.21474 = 0;
  return D.21474;
  <D.21470>:
  {
    int ret;

    ret = pthread_mutex_lock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21475>; else goto <D.21476>;
    <D.21475>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21476>:
    D.21477 = ret != 0;
    D.21478 = (long int) D.21477;
    D.21479 = __builtin_expect (D.21478, 0);
    if (D.21479 != 0) goto <D.21480>; else goto <D.21481>;
    <D.21480>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2050, "ret == 0");
    <D.21481>:
  }
  D.21482 = mono_object_hash (object);
  D.21483 = (long int) D.21482;
  D.21484 = (const void *) D.21483;
  ccw_hash.122 = ccw_hash;
  ccw_list_orig = monoeg_g_hash_table_lookup (ccw_hash.122, D.21484);
  ccw_list = ccw_list_orig;
  {
    int ret;

    ret = pthread_mutex_unlock (&cominterop_mutex.mutex);
    if (ret != 0) goto <D.21485>; else goto <D.21486>;
    <D.21485>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21486>:
    D.21487 = ret != 0;
    D.21488 = (long int) D.21487;
    D.21489 = __builtin_expect (D.21488, 0);
    if (D.21489 != 0) goto <D.21490>; else goto <D.21491>;
    <D.21490>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2052, "ret == 0");
    <D.21491>:
  }
  if (ccw_list == 0B) goto <D.21492>; else goto <D.21493>;
  <D.21492>:
  D.21474 = 0;
  return D.21474;
  <D.21493>:
  ccw_list_item = ccw_list;
  goto <D.19222>;
  <D.19221>:
  {
    struct MonoCCW * ccw_iter;
    struct MonoObject * handle_target;

    ccw_iter = ccw_list_item->data;
    D.21494 = ccw_iter->gc_handle;
    handle_target = mono_gchandle_get_target (D.21494);
    D.21495 = handle_target == 0B;
    D.21496 = handle_target == object;
    D.21497 = D.21495 | D.21496;
    if (D.21497 != 0) goto <D.21498>; else goto <D.21499>;
    <D.21498>:
    D.21500 = ccw_iter->vtable_hash;
    monoeg_g_hash_table_foreach_remove (D.21500, mono_marshal_free_ccw_entry, 0B);
    D.21500 = ccw_iter->vtable_hash;
    monoeg_g_hash_table_destroy (D.21500);
    if (ccw_list_item != 0B) goto <D.21502>; else goto <D.21503>;
    <D.21502>:
    iftmp.123 = ccw_list_item->next;
    goto <D.21504>;
    <D.21503>:
    iftmp.123 = 0B;
    <D.21504>:
    ccw_list_item = iftmp.123;
    ccw_list = monoeg_g_list_remove (ccw_list, ccw_iter);
    monoeg_g_free (ccw_iter);
    goto <D.21505>;
    <D.21499>:
    if (ccw_list_item != 0B) goto <D.21507>; else goto <D.21508>;
    <D.21507>:
    iftmp.124 = ccw_list_item->next;
    goto <D.21509>;
    <D.21508>:
    iftmp.124 = 0B;
    <D.21509>:
    ccw_list_item = iftmp.124;
    <D.21505>:
  }
  <D.19222>:
  if (ccw_list_item != 0B) goto <D.19221>; else goto <D.19223>;
  <D.19223>:
  D.21510 = monoeg_g_list_length (ccw_list);
  if (D.21510 == 0) goto <D.21511>; else goto <D.21512>;
  <D.21511>:
  D.21513 = mono_object_hash (object);
  D.21514 = (long int) D.21513;
  D.21515 = (const void *) D.21514;
  ccw_hash.122 = ccw_hash;
  monoeg_g_hash_table_remove (ccw_hash.122, D.21515);
  <D.21512>:
  D.21474 = 1;
  return D.21474;
}


mono_marshal_free_ccw_entry (void * key, void * value, void * user_data)
{
  struct GHashTable * ccw_interface_hash.125;
  _Bool D.21518;
  long int D.21519;
  long int D.21520;
  gboolean D.21523;

  ccw_interface_hash.125 = ccw_interface_hash;
  monoeg_g_hash_table_remove (ccw_interface_hash.125, value);
  D.21518 = value == 0B;
  D.21519 = (long int) D.21518;
  D.21520 = __builtin_expect (D.21519, 0);
  if (D.21520 != 0) goto <D.21521>; else goto <D.21522>;
  <D.21521>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2030, "value");
  <D.21522>:
  monoeg_g_free (value);
  D.21523 = 1;
  return D.21523;
}


mono_string_to_bstr (struct MonoString * string_obj)
{
  void * D.21527;
  <unnamed type> com_provider.126;
  int D.21531;
  long unsigned int D.21532;
  long unsigned int D.21533;
  long unsigned int D.21534;
  long unsigned int D.21537;
  long unsigned int D.21538;
  mono_unichar2 * D.21539;
  char * D.21540;
  unsigned int D.21541;
  unsigned int D.21542;
  long unsigned int D.21543;
  long unsigned int D.21544;
  char * D.21545;
  long unsigned int D.21546;
  char * D.21547;
  int D.21550;
  int D.21552;
  long int D.21553;
  mono_unichar2 * D.21554;
  void * (*<T33ca>) (gunichar *, guint32) sys_alloc_string_len_ms.127;

  if (string_obj == 0B) goto <D.21525>; else goto <D.21526>;
  <D.21525>:
  D.21527 = 0B;
  return D.21527;
  <D.21526>:
  com_provider.126 = com_provider;
  if (com_provider.126 == 0) goto <D.21529>; else goto <D.21530>;
  <D.21529>:
  {
    int slen;
    char * ret;

    slen = mono_string_length (string_obj);
    D.21531 = slen + 1;
    D.21532 = (long unsigned int) D.21531;
    D.21533 = D.21532 + 2;
    D.21534 = D.21533 * 2;
    ret = monoeg_malloc (D.21534);
    if (ret == 0B) goto <D.21535>; else goto <D.21536>;
    <D.21535>:
    D.21527 = 0B;
    return D.21527;
    <D.21536>:
    D.21537 = (long unsigned int) slen;
    D.21538 = D.21537 * 2;
    D.21539 = mono_string_chars (string_obj);
    D.21540 = ret + 4;
    memcpy (D.21540, D.21539, D.21538);
    D.21537 = (long unsigned int) slen;
    D.21541 = (unsigned int) D.21537;
    D.21542 = D.21541 * 2;
    MEM[(guint32 *)ret] = D.21542;
    D.21537 = (long unsigned int) slen;
    D.21543 = D.21537 + 2;
    D.21544 = D.21543 * 2;
    D.21545 = ret + D.21544;
    *D.21545 = 0;
    D.21537 = (long unsigned int) slen;
    D.21538 = D.21537 * 2;
    D.21546 = D.21538 + 5;
    D.21547 = ret + D.21546;
    *D.21547 = 0;
    D.21527 = ret + 4;
    return D.21527;
  }
  <D.21530>:
  com_provider.126 = com_provider;
  if (com_provider.126 == 1) goto <D.21549>; else goto <D.21548>;
  <D.21549>:
  D.21550 = init_com_provider_ms ();
  if (D.21550 != 0) goto <D.21551>; else goto <D.21548>;
  <D.21551>:
  {
    void * ret;
    gunichar * str;
    guint32 len;

    ret = 0B;
    str = 0B;
    D.21552 = mono_string_length (string_obj);
    len = (guint32) D.21552;
    D.21553 = (long int) len;
    D.21554 = mono_string_chars (string_obj);
    str = monoeg_g_utf16_to_ucs4 (D.21554, D.21553, 0B, 0B, 0B);
    sys_alloc_string_len_ms.127 = sys_alloc_string_len_ms;
    ret = sys_alloc_string_len_ms.127 (str, len);
    monoeg_g_free (str);
    D.21527 = ret;
    return D.21527;
  }
  <D.21548>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2605);
}


mono_string_from_bstr (void * bstr)
{
  struct MonoString * D.21559;
  <unnamed type> com_provider.128;
  guint32 * D.21563;
  unsigned int D.21564;
  unsigned int D.21565;
  int D.21566;
  struct MonoDomain * D.21567;
  int D.21570;
  guint32 (*<T1816>) (void *) sys_string_len_ms.129;
  unsigned int D.21573;
  long int D.21574;
  long int written.130;
  int D.21576;
  struct MonoDomain * D.21577;

  if (bstr == 0B) goto <D.21557>; else goto <D.21558>;
  <D.21557>:
  D.21559 = 0B;
  return D.21559;
  <D.21558>:
  com_provider.128 = com_provider;
  if (com_provider.128 == 0) goto <D.21561>; else goto <D.21562>;
  <D.21561>:
  D.21563 = bstr + 18446744073709551612;
  D.21564 = *D.21563;
  D.21565 = D.21564 / 2;
  D.21566 = (int) D.21565;
  D.21567 = mono_domain_get ();
  D.21559 = mono_string_new_utf16 (D.21567, bstr, D.21566);
  return D.21559;
  <D.21562>:
  com_provider.128 = com_provider;
  if (com_provider.128 == 1) goto <D.21569>; else goto <D.21568>;
  <D.21569>:
  D.21570 = init_com_provider_ms ();
  if (D.21570 != 0) goto <D.21571>; else goto <D.21568>;
  <D.21571>:
  {
    struct MonoString * str;
    glong written;
    gunichar2 * utf16;

    try
      {
        str = 0B;
        written = 0;
        utf16 = 0B;
        sys_string_len_ms.129 = sys_string_len_ms;
        D.21573 = sys_string_len_ms.129 (bstr);
        D.21574 = (long int) D.21573;
        utf16 = monoeg_g_ucs4_to_utf16 (bstr, D.21574, 0B, &written, 0B);
        written.130 = written;
        D.21576 = (int) written.130;
        D.21577 = mono_domain_get ();
        str = mono_string_new_utf16 (D.21577, utf16, D.21576);
        monoeg_g_free (utf16);
        D.21559 = str;
        return D.21559;
      }
    finally
      {
        written = {CLOBBER};
      }
  }
  <D.21568>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2630);
}


mono_free_bstr (void * bstr)
{
  <unnamed type> com_provider.131;
  void * D.21585;
  int D.21590;
  void (*<T33d2>) (gunichar *) sys_free_string_ms.132;

  if (bstr == 0B) goto <D.21580>; else goto <D.21581>;
  <D.21580>:
  return;
  <D.21581>:
  com_provider.131 = com_provider;
  if (com_provider.131 == 0) goto <D.21583>; else goto <D.21584>;
  <D.21583>:
  D.21585 = bstr + 18446744073709551612;
  monoeg_g_free (D.21585);
  goto <D.21586>;
  <D.21584>:
  com_provider.131 = com_provider;
  if (com_provider.131 == 1) goto <D.21589>; else goto <D.21587>;
  <D.21589>:
  D.21590 = init_com_provider_ms ();
  if (D.21590 != 0) goto <D.21591>; else goto <D.21587>;
  <D.21591>:
  sys_free_string_ms.132 = sys_free_string_ms;
  sys_free_string_ms.132 (bstr);
  goto <D.21588>;
  <D.21587>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2649);
  <D.21588>:
  <D.21586>:
}


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.21594;
  int D.21595;
  int D.21596;
  struct MonoClass * D.21599;
  struct MonoType * D.21600;
  struct MonoClass * D.21601;
  struct MonoType * D.21602;
  unsigned char D.21603;
  unsigned char D.21604;
  unsigned int argnum.133;
  unsigned int safearray_var.134;
  unsigned int indices_var.135;
  unsigned int empty_var.136;
  struct MonoClass * D.21612;
  struct MonoType * D.21613;
  unsigned int index_var.137;
  int D.21615;
  struct MonoMethod * get_value_impl.138;
  struct MonoClass * D.21619;
  struct MonoMethod * get_value_impl.139;
  _Bool D.21621;
  long int D.21622;
  long int D.21623;
  struct MonoMethod * get_native_variant_for_object.140;
  struct MonoClass * D.21632;
  struct MonoMethod * get_native_variant_for_object.141;
  _Bool D.21634;
  long int D.21635;
  long int D.21636;
  struct MonoClass * D.21639;
  struct MonoType * D.21640;
  unsigned int elem_var.142;
  struct MonoMethod * variant_clear.143;
  struct MonoClass * D.21645;
  struct MonoMethod * variant_clear.144;
  short unsigned int D.21647;
  int D.21648;
  unsigned int conv_arg.145;
  int D.21653;
  int iftmp.146;
  unsigned int result_var.147;
  unsigned int indices_var.148;
  unsigned int empty_var.149;
  unsigned int index_var.150;
  int D.21668;
  struct MonoMethod * get_object_for_native_variant.151;
  struct MonoMethod * get_object_for_native_variant.152;
  _Bool D.21675;
  long int D.21676;
  long int D.21677;
  struct MonoMethod * set_value_impl.153;
  struct MonoMethod * set_value_impl.154;
  _Bool D.21684;
  long int D.21685;
  long int D.21686;
  unsigned int elem_var.155;
  short unsigned int D.21692;
  int D.21693;
  int D.21696;
  struct MonoMethodBuilder * mb;

  mb = m->mb;
  switch (action) <default: <D.19443>, case 0: <D.19416>, case 1: <D.19429>, case 2: <D.19430>>
  <D.19416>:
  D.21594 = t->attrs;
  D.21595 = (int) D.21594;
  D.21596 = D.21595 & 1;
  if (D.21596 != 0) goto <D.21597>; else goto <D.21598>;
  <D.21597>:
  {
    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.21599 = mono_defaults.object_class;
    D.21600 = &D.21599->byval_arg;
    safearray_var = mono_mb_add_local (mb, D.21600);
    conv_arg = safearray_var;
    D.21601 = mono_defaults.int_class;
    D.21602 = &D.21601->byval_arg;
    indices_var = mono_mb_add_local (mb, D.21602);
    D.21601 = mono_defaults.int_class;
    D.21602 = &D.21601->byval_arg;
    empty_var = mono_mb_add_local (mb, D.21602);
    D.21603 = BIT_FIELD_REF <*t, 8, 88>;
    D.21604 = D.21603 & 64;
    if (D.21604 != 0) goto <D.21605>; else goto <D.21606>;
    <D.21605>:
    argnum.133 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.133);
    mono_mb_emit_byte (mb, 80);
    goto <D.21608>;
    <D.21606>:
    argnum.133 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.133);
    <D.21608>:
    safearray_var.134 = (unsigned int) safearray_var;
    mono_mb_emit_ldloc_addr (mb, safearray_var.134);
    indices_var.135 = (unsigned int) indices_var;
    mono_mb_emit_ldloc_addr (mb, indices_var.135);
    empty_var.136 = (unsigned int) empty_var;
    mono_mb_emit_ldloc_addr (mb, empty_var.136);
    mono_mb_emit_icall (mb, mono_marshal_safearray_create);
    label1 = mono_mb_emit_short_branch (mb, 44);
    empty_var.136 = (unsigned int) empty_var;
    mono_mb_emit_ldloc (mb, empty_var.136);
    label2 = mono_mb_emit_short_branch (mb, 45);
    D.21612 = mono_defaults.int32_class;
    D.21613 = &D.21612->byval_arg;
    index_var = mono_mb_add_local (mb, D.21613);
    mono_mb_emit_byte (mb, 22);
    index_var.137 = (unsigned int) index_var;
    mono_mb_emit_stloc (mb, index_var.137);
    D.21615 = mono_mb_get_label (mb);
    label3 = (guint32) D.21615;
    get_value_impl.138 = get_value_impl;
    if (get_value_impl.138 == 0B) goto <D.21617>; else goto <D.21618>;
    <D.21617>:
    D.21619 = mono_defaults.array_class;
    get_value_impl.139 = mono_class_get_method_from_name (D.21619, "GetValueImpl", 1);
    get_value_impl = get_value_impl.139;
    <D.21618>:
    get_value_impl.138 = get_value_impl;
    D.21621 = get_value_impl.138 == 0B;
    D.21622 = (long int) D.21621;
    D.21623 = __builtin_expect (D.21622, 0);
    if (D.21623 != 0) goto <D.21624>; else goto <D.21625>;
    <D.21624>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2725, "get_value_impl");
    <D.21625>:
    D.21603 = BIT_FIELD_REF <*t, 8, 88>;
    D.21604 = D.21603 & 64;
    if (D.21604 != 0) goto <D.21626>; else goto <D.21627>;
    <D.21626>:
    argnum.133 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.133);
    mono_mb_emit_byte (mb, 80);
    goto <D.21628>;
    <D.21627>:
    argnum.133 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.133);
    <D.21628>:
    index_var.137 = (unsigned int) index_var;
    mono_mb_emit_ldloc (mb, index_var.137);
    get_value_impl.138 = get_value_impl;
    mono_mb_emit_managed_call (mb, get_value_impl.138, 0B);
    get_native_variant_for_object.140 = get_native_variant_for_object;
    if (get_native_variant_for_object.140 == 0B) goto <D.21630>; else goto <D.21631>;
    <D.21630>:
    D.21632 = mono_defaults.marshal_class;
    get_native_variant_for_object.141 = mono_class_get_method_from_name (D.21632, "GetNativeVariantForObject", 2);
    get_native_variant_for_object = get_native_variant_for_object.141;
    <D.21631>:
    get_native_variant_for_object.140 = get_native_variant_for_object;
    D.21634 = get_native_variant_for_object.140 == 0B;
    D.21635 = (long int) D.21634;
    D.21636 = __builtin_expect (D.21635, 0);
    if (D.21636 != 0) goto <D.21637>; else goto <D.21638>;
    <D.21637>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2739, "get_native_variant_for_object");
    <D.21638>:
    D.21639 = mono_class_get_variant_class ();
    D.21640 = &D.21639->byval_arg;
    elem_var = mono_mb_add_local (mb, D.21640);
    elem_var.142 = (unsigned int) elem_var;
    mono_mb_emit_ldloc_addr (mb, elem_var.142);
    get_native_variant_for_object.140 = get_native_variant_for_object;
    mono_mb_emit_managed_call (mb, get_native_variant_for_object.140, 0B);
    safearray_var.134 = (unsigned int) safearray_var;
    mono_mb_emit_ldloc (mb, safearray_var.134);
    indices_var.135 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.135);
    elem_var.142 = (unsigned int) elem_var;
    mono_mb_emit_ldloc_addr (mb, elem_var.142);
    mono_mb_emit_icall (mb, mono_marshal_safearray_set_value);
    variant_clear.143 = variant_clear;
    if (variant_clear.143 == 0B) goto <D.21643>; else goto <D.21644>;
    <D.21643>:
    D.21645 = mono_class_get_variant_class ();
    variant_clear.144 = mono_class_get_method_from_name (D.21645, "Clear", 0);
    variant_clear = variant_clear.144;
    <D.21644>:
    elem_var.142 = (unsigned int) elem_var;
    mono_mb_emit_ldloc_addr (mb, elem_var.142);
    variant_clear.143 = variant_clear;
    mono_mb_emit_managed_call (mb, variant_clear.143, 0B);
    D.21647 = (short unsigned int) index_var;
    D.21648 = (int) D.21647;
    mono_mb_emit_add_to_local (mb, D.21648, 1);
    safearray_var.134 = (unsigned int) safearray_var;
    mono_mb_emit_ldloc (mb, safearray_var.134);
    indices_var.135 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.135);
    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.135 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.135);
    mono_mb_emit_icall (mb, mono_marshal_safearray_free_indices);
    mono_mb_patch_short_branch (mb, label1);
  }
  <D.21598>:
  goto <D.19428>;
  <D.19429>:
  D.21603 = BIT_FIELD_REF <*t, 8, 88>;
  D.21604 = D.21603 & 64;
  if (D.21604 != 0) goto <D.21649>; else goto <D.21650>;
  <D.21649>:
  conv_arg.145 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc_addr (mb, conv_arg.145);
  goto <D.21652>;
  <D.21650>:
  conv_arg.145 = (unsigned int) conv_arg;
  mono_mb_emit_ldloc (mb, conv_arg.145);
  <D.21652>:
  goto <D.19428>;
  <D.19430>:
  D.21594 = t->attrs;
  D.21595 = (int) D.21594;
  D.21653 = D.21595 & 2;
  if (D.21653 != 0) goto <D.21654>; else goto <D.21655>;
  <D.21654>:
  {
    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.21603 = BIT_FIELD_REF <*t, 8, 88>;
    D.21604 = D.21603 & 64;
    if (D.21604 == 0) goto <D.21659>; else goto <D.21657>;
    <D.21659>:
    D.21594 = t->attrs;
    D.21595 = (int) D.21594;
    D.21596 = D.21595 & 1;
    if (D.21596 != 0) goto <D.21660>; else goto <D.21657>;
    <D.21660>:
    iftmp.146 = 1;
    goto <D.21658>;
    <D.21657>:
    iftmp.146 = 0;
    <D.21658>:
    byValue = iftmp.146;
    D.21599 = mono_defaults.object_class;
    D.21600 = &D.21599->byval_arg;
    result_var = mono_mb_add_local (mb, D.21600);
    D.21601 = mono_defaults.int_class;
    D.21602 = &D.21601->byval_arg;
    indices_var = mono_mb_add_local (mb, D.21602);
    D.21601 = mono_defaults.int_class;
    D.21602 = &D.21601->byval_arg;
    empty_var = mono_mb_add_local (mb, D.21602);
    conv_arg.145 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.145);
    result_var.147 = (unsigned int) result_var;
    mono_mb_emit_ldloc_addr (mb, result_var.147);
    indices_var.148 = (unsigned int) indices_var;
    mono_mb_emit_ldloc_addr (mb, indices_var.148);
    empty_var.149 = (unsigned int) empty_var;
    mono_mb_emit_ldloc_addr (mb, empty_var.149);
    argnum.133 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.133);
    if (byValue != 0) goto <D.21664>; else goto <D.21665>;
    <D.21664>:
    mono_mb_emit_byte (mb, 22);
    goto <D.21666>;
    <D.21665>:
    mono_mb_emit_byte (mb, 23);
    <D.21666>:
    mono_mb_emit_icall (mb, mono_marshal_safearray_begin);
    label1 = mono_mb_emit_short_branch (mb, 44);
    empty_var.149 = (unsigned int) empty_var;
    mono_mb_emit_ldloc (mb, empty_var.149);
    label2 = mono_mb_emit_short_branch (mb, 45);
    D.21601 = mono_defaults.int_class;
    D.21602 = &D.21601->byval_arg;
    index_var = mono_mb_add_local (mb, D.21602);
    mono_mb_emit_byte (mb, 22);
    index_var.150 = (unsigned int) index_var;
    mono_mb_emit_stloc (mb, index_var.150);
    D.21668 = mono_mb_get_label (mb);
    label3 = (guint32) D.21668;
    if (byValue != 0) goto <D.21669>; else goto <D.21670>;
    <D.21669>:
    index_var.150 = (unsigned int) index_var;
    mono_mb_emit_ldloc (mb, index_var.150);
    argnum.133 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.133);
    mono_mb_emit_byte (mb, 142);
    label4 = mono_mb_emit_branch (mb, 60);
    <D.21670>:
    conv_arg.145 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.145);
    indices_var.148 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.148);
    mono_mb_emit_icall (mb, mono_marshal_safearray_get_value);
    get_object_for_native_variant.151 = get_object_for_native_variant;
    if (get_object_for_native_variant.151 == 0B) goto <D.21672>; else goto <D.21673>;
    <D.21672>:
    D.21632 = mono_defaults.marshal_class;
    get_object_for_native_variant.152 = mono_class_get_method_from_name (D.21632, "GetObjectForNativeVariant", 1);
    get_object_for_native_variant = get_object_for_native_variant.152;
    <D.21673>:
    get_object_for_native_variant.151 = get_object_for_native_variant;
    D.21675 = get_object_for_native_variant.151 == 0B;
    D.21676 = (long int) D.21675;
    D.21677 = __builtin_expect (D.21676, 0);
    if (D.21677 != 0) goto <D.21678>; else goto <D.21679>;
    <D.21678>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2854, "get_object_for_native_variant");
    <D.21679>:
    set_value_impl.153 = set_value_impl;
    if (set_value_impl.153 == 0B) goto <D.21681>; else goto <D.21682>;
    <D.21681>:
    D.21619 = mono_defaults.array_class;
    set_value_impl.154 = mono_class_get_method_from_name (D.21619, "SetValueImpl", 2);
    set_value_impl = set_value_impl.154;
    <D.21682>:
    set_value_impl.153 = set_value_impl;
    D.21684 = set_value_impl.153 == 0B;
    D.21685 = (long int) D.21684;
    D.21686 = __builtin_expect (D.21685, 0);
    if (D.21686 != 0) goto <D.21687>; else goto <D.21688>;
    <D.21687>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "cominterop.c", 2858, "set_value_impl");
    <D.21688>:
    D.21599 = mono_defaults.object_class;
    D.21600 = &D.21599->byval_arg;
    elem_var = mono_mb_add_local (mb, D.21600);
    get_object_for_native_variant.151 = get_object_for_native_variant;
    mono_mb_emit_managed_call (mb, get_object_for_native_variant.151, 0B);
    elem_var.155 = (unsigned int) elem_var;
    mono_mb_emit_stloc (mb, elem_var.155);
    result_var.147 = (unsigned int) result_var;
    mono_mb_emit_ldloc (mb, result_var.147);
    elem_var.155 = (unsigned int) elem_var;
    mono_mb_emit_ldloc (mb, elem_var.155);
    index_var.150 = (unsigned int) index_var;
    mono_mb_emit_ldloc (mb, index_var.150);
    set_value_impl.153 = set_value_impl;
    mono_mb_emit_managed_call (mb, set_value_impl.153, 0B);
    if (byValue != 0) goto <D.21690>; else goto <D.21691>;
    <D.21690>:
    mono_mb_patch_short_branch (mb, label4);
    <D.21691>:
    D.21692 = (short unsigned int) index_var;
    D.21693 = (int) D.21692;
    mono_mb_emit_add_to_local (mb, D.21693, 1);
    conv_arg.145 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.145);
    indices_var.148 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.148);
    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.145 = (unsigned int) conv_arg;
    mono_mb_emit_ldloc (mb, conv_arg.145);
    indices_var.148 = (unsigned int) indices_var;
    mono_mb_emit_ldloc (mb, indices_var.148);
    mono_mb_emit_icall (mb, mono_marshal_safearray_end);
    mono_mb_patch_short_branch (mb, label1);
    if (byValue == 0) goto <D.21694>; else goto <D.21695>;
    <D.21694>:
    argnum.133 = (unsigned int) argnum;
    mono_mb_emit_ldarg (mb, argnum.133);
    result_var.147 = (unsigned int) result_var;
    mono_mb_emit_ldloc (mb, result_var.147);
    mono_mb_emit_byte (mb, 81);
    <D.21695>:
  }
  <D.21655>:
  goto <D.19428>;
  <D.19443>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "cominterop.c", 2898);
  <D.19428>:
  D.21696 = conv_arg;
  return D.21696;
}


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

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


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

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


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


