; LLVM IR from ponylang/ponyc :: src/libponyrt/lang (posix_except)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@landing_pad = external hidden thread_local global i64, align 8

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @ponyint_personality_v0(i32 noundef %0, i32 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !11
  %12 = load i32, ptr %7, align 4, !tbaa !5
  %13 = icmp ne i32 %12, 1
  br i1 %13, label %20, label %14

14:                                               ; preds = %5
  %15 = load ptr, ptr %10, align 8, !tbaa !11
  %16 = icmp eq ptr %15, null
  br i1 %16, label %20, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %11, align 8, !tbaa !11
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17, %14, %5
  store i32 3, ptr %6, align 4
  br label %48

21:                                               ; preds = %17
  %22 = load i64, ptr %9, align 8, !tbaa !9
  %23 = icmp ne i64 %22, 5795972711419215872
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  store i32 8, ptr %6, align 4
  br label %48

25:                                               ; preds = %21
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = and i32 %26, 1
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %35

29:                                               ; preds = %25
  %30 = load ptr, ptr %11, align 8, !tbaa !11
  %31 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @landing_pad)
  %32 = call zeroext i1 @ponyint_lsda_scan(ptr noundef %30, ptr noundef %31)
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 8, ptr %6, align 4
  br label %48

34:                                               ; preds = %29
  store i32 6, ptr %6, align 4
  br label %48

35:                                               ; preds = %25
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = and i32 %36, 2
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %47

39:                                               ; preds = %35
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = and i32 %40, 4
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  store i32 8, ptr %6, align 4
  br label %48

44:                                               ; preds = %39
  %45 = load ptr, ptr %10, align 8, !tbaa !11
  %46 = load ptr, ptr %11, align 8, !tbaa !11
  call void @set_registers(ptr noundef %45, ptr noundef %46)
  store i32 7, ptr %6, align 4
  br label %48

47:                                               ; preds = %35
  store i32 3, ptr %6, align 4
  br label %48

48:                                               ; preds = %47, %44, %43, %34, %33, %24, %20
  %49 = load i32, ptr %6, align 4
  ret i32 %49
}

declare zeroext i1 @ponyint_lsda_scan(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @set_registers(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@landing_pad = external hidden thread_local global i64, align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 3, 9) i32 @ponyint_personality_v0(i32 noundef %0, i32 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = icmp ne i32 %0, 1
  %7 = icmp eq ptr %3, null
  %or.cond = or i1 %6, %7
  %8 = icmp eq ptr %4, null
  %or.cond3 = or i1 %or.cond, %8
  br i1 %or.cond3, label %20, label %9

9:                                                ; preds = %5
  %.not = icmp eq i64 %2, 5795972711419215872
  br i1 %.not, label %10, label %20

10:                                               ; preds = %9
  %11 = and i32 %1, 1
  %.not15 = icmp eq i32 %11, 0
  br i1 %.not15, label %15, label %12

12:                                               ; preds = %10
  %13 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @landing_pad)
  %14 = tail call zeroext i1 @ponyint_lsda_scan(ptr noundef nonnull %4, ptr noundef nonnull %13) #3
  %. = select i1 %14, i32 6, i32 8
  br label %20

15:                                               ; preds = %10
  %16 = and i32 %1, 2
  %.not16 = icmp eq i32 %16, 0
  br i1 %.not16, label %20, label %17

17:                                               ; preds = %15
  %18 = and i32 %1, 4
  %.not17 = icmp eq i32 %18, 0
  br i1 %.not17, label %20, label %19

19:                                               ; preds = %17
  tail call void @set_registers(ptr noundef nonnull %3, ptr noundef nonnull %4)
  br label %20

20:                                               ; preds = %15, %17, %12, %9, %5, %19
  %.0 = phi i32 [ 7, %19 ], [ 3, %5 ], [ 8, %9 ], [ %., %12 ], [ 8, %17 ], [ 3, %15 ]
  ret i32 %.0
}

declare zeroext i1 @ponyint_lsda_scan(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @set_registers(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass