__attribute__((visibility ("hidden")))
mono_threads_pthread_create (pthread_t * new_thread, const union pthread_attr_t * attr, void * (*<T10fb>) (void *) start_routine, void * arg)
{
  int D.12801;
  union MonoSemType * D.12802;
  struct MonoThreadInfoCallbacks * D.12803;
  int (*<T1d7f>) (pthread_t *, const union pthread_attr_t *, void * (*<T10fb>) (void *), void *) D.12804;
  int D.12807;
  struct ThreadStartInfo * start_info;
  int result;

  start_info = monoeg_malloc0 (56);
  if (start_info == 0B) goto <D.12799>; else goto <D.12800>;
  <D.12799>:
  D.12801 = 12;
  return D.12801;
  <D.12800>:
  D.12802 = &start_info->registered;
  sem_init (D.12802, 0, 0);
  start_info->arg = arg;
  start_info->start_routine = start_routine;
  D.12803 = mono_threads_get_callbacks ();
  D.12804 = D.12803->mono_gc_pthread_create;
  result = D.12804 (new_thread, attr, inner_start_thread, start_info);
  if (result == 0) goto <D.12805>; else goto <D.12806>;
  <D.12805>:
  goto <D.12732>;
  <D.12731>:
  <D.12732>:
  D.12802 = &start_info->registered;
  D.12807 = mono_sem_wait (D.12802, 0);
  if (D.12807 != 0) goto <D.12731>; else goto <D.12733>;
  <D.12733>:
  <D.12806>:
  D.12802 = &start_info->registered;
  sem_destroy (D.12802);
  monoeg_g_free (start_info);
  D.12801 = result;
  return D.12801;
}


inner_start_thread (void * arg)
{
  struct MonoThreadInfo * D.12809;
  union MonoSemType * D.12810;
  _Bool D.12811;
  long int D.12812;
  long int D.12813;
  void * result.0;
  struct MonoDomain * D.12817;
  _Bool D.12818;
  long int D.12819;
  long int D.12820;
  void * D.12823;
  struct ThreadStartInfo * start_info;
  void * t_arg;
  int post_result;
  void * (*<T10fb>) (void *) start_func;
  void * result;

  try
    {
      start_info = arg;
      t_arg = start_info->arg;
      start_func = start_info->start_routine;
      D.12809 = mono_thread_info_attach (&result);
      D.12809->runtime_thread = 1;
      D.12810 = &start_info->registered;
      post_result = mono_sem_post (D.12810);
      D.12811 = post_result != 0;
      D.12812 = (long int) D.12811;
      D.12813 = __builtin_expect (D.12812, 0);
      if (D.12813 != 0) goto <D.12814>; else goto <D.12815>;
      <D.12814>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mono-threads-posix.c", 47, "!post_result");
      <D.12815>:
      result.0 = start_func (t_arg);
      result = result.0;
      D.12817 = mono_domain_get ();
      D.12818 = D.12817 != 0B;
      D.12819 = (long int) D.12818;
      D.12820 = __builtin_expect (D.12819, 0);
      if (D.12820 != 0) goto <D.12821>; else goto <D.12822>;
      <D.12821>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mono-threads-posix.c", 50, "!mono_domain_get ()");
      <D.12822>:
      mono_thread_info_dettach ();
      D.12823 = result;
      return D.12823;
    }
  finally
    {
      result = {CLOBBER};
    }
}


__attribute__((visibility ("hidden")))
mono_threads_init_platform ()
{
  int D.12826;
  int D.12829;

  D.12826 = mono_thread_info_new_interrupt_enabled ();
  if (D.12826 != 0) goto <D.12827>; else goto <D.12828>;
  <D.12827>:
  D.12829 = mono_thread_get_abort_signal ();
  mono_posix_add_signal_handler (D.12829, suspend_signal_handler);
  <D.12828>:
}


suspend_signal_handler (int _dummy, struct siginfo_t * info, void * context)
{
  int D.12830;
  struct MonoThreadInfoRuntimeCallbacks * D.12833;
  gboolean (*<T1d8c>) (struct MonoThreadUnwindState *, void *) D.12834;
  struct MonoThreadUnwindState * D.12835;
  union MonoSemType * D.12836;
  union MonoSemType * D.12839;
  int D.12840;
  void (*<Tc6>) (void *) D.12841;
  struct MonoThreadInfoRuntimeCallbacks * D.12844;
  void (*<T1d86>) (struct MonoContext *, void (*<Tc6>) (void *), void *) D.12845;
  void * D.12846;
  union MonoSemType * D.12847;
  struct MonoThreadInfo * current;
  gboolean ret;

  current = mono_thread_info_current ();
  D.12830 = current->syscall_break_signal;
  if (D.12830 != 0) goto <D.12831>; else goto <D.12832>;
  <D.12831>:
  current->syscall_break_signal = 0;
  return;
  <D.12832>:
  D.12833 = mono_threads_get_runtime_callbacks ();
  D.12834 = D.12833->thread_state_init_from_sigctx;
  D.12835 = &current->suspend_state;
  ret = D.12834 (D.12835, context);
  current->suspend_can_continue = ret;
  D.12836 = &current->begin_suspend_semaphore;
  mono_sem_post (D.12836);
  if (ret == 0) goto <D.12837>; else goto <D.12838>;
  <D.12837>:
  return;
  <D.12838>:
  goto <D.12742>;
  <D.12741>:
  <D.12742>:
  D.12839 = &current->resume_semaphore;
  D.12840 = mono_sem_wait (D.12839, 0);
  if (D.12840 != 0) goto <D.12741>; else goto <D.12743>;
  <D.12743>:
  D.12841 = current->async_target;
  if (D.12841 != 0B) goto <D.12842>; else goto <D.12843>;
  <D.12842>:
  {
    struct MonoContext tmp;

    try
      {
        tmp = current->suspend_state.ctx;
        D.12844 = mono_threads_get_runtime_callbacks ();
        D.12845 = D.12844->setup_async_callback;
        D.12841 = current->async_target;
        D.12846 = current->user_data;
        D.12845 (&tmp, D.12841, D.12846);
        current->user_data = 0B;
        current->async_target = 0B;
        mono_monoctx_to_sigctx (&tmp, context);
      }
    finally
      {
        tmp = {CLOBBER};
      }
  }
  <D.12843>:
  D.12847 = &current->finish_resume_semaphore;
  mono_sem_post (D.12847);
}


mono_posix_add_signal_handler (int signo, void * handler)
{
  void (*<T1c1b>) (int, struct siginfo_t *, void *) handler.1;
  _Bool D.12850;
  long int D.12851;
  long int D.12852;
  struct sigaction sa;
  struct sigaction previous_sa;
  int ret;

  try
    {
      handler.1 = (void (*<T1c1b>) (int, struct siginfo_t *, void *)) handler;
      sa.__sigaction_handler.sa_sigaction = handler.1;
      sigemptyset (&sa.sa_mask);
      sa.sa_flags = 4;
      ret = sigaction (signo, &sa, &previous_sa);
      D.12850 = ret == -1;
      D.12851 = (long int) D.12850;
      D.12852 = __builtin_expect (D.12851, 0);
      if (D.12852 != 0) goto <D.12853>; else goto <D.12854>;
      <D.12853>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mono-threads-posix.c", 139, "ret != -1");
      <D.12854>:
    }
  finally
    {
      sa = {CLOBBER};
      previous_sa = {CLOBBER};
    }
}


__attribute__((visibility ("hidden")))
mono_threads_core_interrupt (struct MonoThreadInfo * info)
{

}


__attribute__((visibility ("hidden")))
mono_threads_pthread_kill (struct MonoThreadInfo * info, int signum)
{
  int D.12855;
  long unsigned int D.12856;

  D.12856 = info->node.key;
  D.12855 = pthread_kill (D.12856, signum);
  return D.12855;
}


__attribute__((visibility ("hidden")))
mono_threads_core_abort_syscall (struct MonoThreadInfo * info)
{
  int D.12858;

  info->syscall_break_signal = 1;
  D.12858 = mono_thread_get_abort_signal ();
  mono_threads_pthread_kill (info, D.12858);
}


__attribute__((visibility ("hidden")))
mono_threads_core_needs_abort_syscall ()
{
  gboolean D.12859;

  D.12859 = 1;
  return D.12859;
}


__attribute__((visibility ("hidden")))
mono_threads_core_suspend (struct MonoThreadInfo * info)
{
  int D.12861;
  union MonoSemType * D.12862;
  int D.12863;
  gboolean D.12864;

  D.12861 = mono_thread_get_abort_signal ();
  mono_threads_pthread_kill (info, D.12861);
  goto <D.12772>;
  <D.12771>:
  <D.12772>:
  D.12862 = &info->begin_suspend_semaphore;
  D.12863 = mono_sem_wait (D.12862, 0);
  if (D.12863 != 0) goto <D.12771>; else goto <D.12773>;
  <D.12773>:
  D.12864 = info->suspend_can_continue;
  return D.12864;
}


__attribute__((visibility ("hidden")))
mono_threads_core_resume (struct MonoThreadInfo * info)
{
  union MonoSemType * D.12866;
  union MonoSemType * D.12867;
  int D.12868;
  gboolean D.12869;

  D.12866 = &info->resume_semaphore;
  mono_sem_post (D.12866);
  goto <D.12778>;
  <D.12777>:
  <D.12778>:
  D.12867 = &info->finish_resume_semaphore;
  D.12868 = mono_sem_wait (D.12867, 0);
  if (D.12868 != 0) goto <D.12777>; else goto <D.12779>;
  <D.12779>:
  D.12869 = 1;
  return D.12869;
}


__attribute__((visibility ("hidden")))
mono_threads_platform_register (struct MonoThreadInfo * info)
{
  union MonoSemType * D.12871;

  D.12871 = &info->begin_suspend_semaphore;
  sem_init (D.12871, 0, 0);
}


__attribute__((visibility ("hidden")))
mono_threads_platform_free (struct MonoThreadInfo * info)
{
  union MonoSemType * D.12872;

  D.12872 = &info->begin_suspend_semaphore;
  sem_destroy (D.12872);
}


__attribute__((visibility ("hidden")))
mono_native_thread_id_get ()
{
  MonoNativeThreadId D.12873;

  D.12873 = pthread_self ();
  return D.12873;
}


__attribute__((visibility ("hidden")))
mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2)
{
  gboolean D.12875;

  D.12875 = pthread_equal (id1, id2);
  return D.12875;
}


__attribute__((__gnu_inline__, const, __leaf__, __nothrow__))
pthread_equal (pthread_t __thread1, pthread_t __thread2)
{
  int D.12877;
  _Bool D.12878;

  D.12878 = __thread1 == __thread2;
  D.12877 = (int) D.12878;
  return D.12877;
}


__attribute__((visibility ("hidden")))
mono_native_thread_create (MonoNativeThreadId * tid, void * func, void * arg)
{
  gboolean D.12880;
  void * (*<T10fb>) (void *) func.2;
  int D.12882;
  _Bool D.12883;

  func.2 = (void * (*<T10fb>) (void *)) func;
  D.12882 = pthread_create (tid, 0B, func.2, arg);
  D.12883 = D.12882 == 0;
  D.12880 = (gboolean) D.12883;
  return D.12880;
}


