; LLVM IR from ponylang/ponyc :: src/libponyc/type (subtype)

; 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"

@.str.1 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.is_constructable = external hidden unnamed_addr constant [17 x i8], align 1

declare i32 @ast_id(ptr noundef) #0

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #0

declare ptr @ast_childidx(ptr noundef, i64 noundef) #0

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

11:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %69

12:                                               ; preds = %1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call i32 @ast_id(ptr noundef %13)
  switch i32 %14, label %67 [
    i32 149, label %15
    i32 150, label %15
    i32 56, label %16
    i32 151, label %31
    i32 187, label %59
    i32 17, label %63
  ]

15:                                               ; preds = %12, %12
  store i1 false, ptr %2, align 1
  br label %69

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call ptr @ast_child(ptr noundef %17)
  store ptr %18, ptr %4, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %26, %16
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %29

22:                                               ; preds = %19
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call zeroext i1 @is_constructable(ptr noundef %23)
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %30

26:                                               ; preds = %22
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call ptr @ast_sibling(ptr noundef %27)
  store ptr %28, ptr %4, align 8, !tbaa !5
  br label %19, !llvm.loop !9

29:                                               ; preds = %19
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %30

30:                                               ; preds = %29, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %69

31:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call ptr @ast_data(ptr noundef %32)
  store ptr %33, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call i32 @ast_id(ptr noundef %34)
  switch i32 %35, label %55 [
    i32 72, label %36
    i32 73, label %36
    i32 74, label %54
    i32 75, label %54
    i32 76, label %54
    i32 77, label %54
  ]

36:                                               ; preds = %31, %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call ptr @ast_childidx(ptr noundef %37, i64 noundef 4)
  store ptr %38, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = call ptr @ast_child(ptr noundef %39)
  store ptr %40, ptr %8, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %49, %36
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %52

44:                                               ; preds = %41
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = call i32 @ast_id(ptr noundef %45)
  %47 = icmp eq i32 %46, 88
  br i1 %47, label %48, label %49

48:                                               ; preds = %44
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %53

49:                                               ; preds = %44
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = call ptr @ast_sibling(ptr noundef %50)
  store ptr %51, ptr %8, align 8, !tbaa !5
  br label %41, !llvm.loop !11

52:                                               ; preds = %41
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %53

53:                                               ; preds = %52, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %57

54:                                               ; preds = %31, %31, %31, %31
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %57

55:                                               ; preds = %31
  br label %56

56:                                               ; preds = %55
  store i32 2, ptr %5, align 4
  br label %57

57:                                               ; preds = %56, %54, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %58 = load i32, ptr %5, align 4
  switch i32 %58, label %71 [
    i32 1, label %69
    i32 2, label %68
  ]

59:                                               ; preds = %12
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = call ptr @typeparam_constraint(ptr noundef %60)
  %62 = call zeroext i1 @is_constructable(ptr noundef %61)
  store i1 %62, ptr %2, align 1
  br label %69

63:                                               ; preds = %12
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = call ptr @ast_childidx(ptr noundef %64, i64 noundef 1)
  %66 = call zeroext i1 @is_constructable(ptr noundef %65)
  store i1 %66, ptr %2, align 1
  br label %69

67:                                               ; preds = %12
  br label %68

68:                                               ; preds = %67, %57
  call void @ponyint_assert_fail(ptr noundef @.str.24, ptr noundef @.str.1, i64 noundef 1903, ptr noundef @__func__.is_constructable)
  store i1 false, ptr %2, align 1
  br label %69

69:                                               ; preds = %68, %63, %59, %57, %30, %15, %11
  %70 = load i1, ptr %2, align 1
  ret i1 %70

71:                                               ; preds = %57
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

declare ptr @ast_child(ptr noundef) #0

declare ptr @ast_sibling(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

declare ptr @ast_data(ptr noundef) #0

declare ptr @typeparam_constraint(ptr noundef) #0

attributes #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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; 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"

@.str.1 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.is_constructable = external hidden unnamed_addr constant [17 x i8], align 1

declare i32 @ast_id(ptr noundef) local_unnamed_addr #0

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @ast_childidx(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @is_constructable(ptr noundef %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %1, %tailrecurse.backedge
  %.tr32 = phi ptr [ %.tr.be, %tailrecurse.backedge ], [ %0, %1 ]
  %3 = tail call i32 @ast_id(ptr noundef nonnull %.tr32) #2
  switch i32 %3, label %.loopexit [
    i32 149, label %.thread
    i32 150, label %.thread
    i32 56, label %4
    i32 151, label %9
    i32 187, label %19
    i32 17, label %22
  ]

4:                                                ; preds = %.lr.ph
  %5 = tail call ptr @ast_child(ptr noundef nonnull %.tr32) #2
  %.not21.not39 = icmp eq ptr %5, null
  br i1 %.not21.not39, label %.thread, label %.lr.ph41

.lr.ph41:                                         ; preds = %4, %7
  %.01740 = phi ptr [ %8, %7 ], [ %5, %4 ]
  %6 = tail call zeroext i1 @is_constructable(ptr noundef nonnull %.01740)
  br i1 %6, label %.thread, label %7

7:                                                ; preds = %.lr.ph41
  %8 = tail call ptr @ast_sibling(ptr noundef nonnull %.01740) #2
  %.not21.not = icmp eq ptr %8, null
  br i1 %.not21.not, label %.thread, label %.lr.ph41, !llvm.loop !5

9:                                                ; preds = %.lr.ph
  %10 = tail call ptr @ast_data(ptr noundef nonnull %.tr32) #2
  %11 = tail call i32 @ast_id(ptr noundef %10) #2
  switch i32 %11, label %.loopexit [
    i32 72, label %12
    i32 73, label %12
    i32 74, label %.thread
    i32 75, label %.thread
    i32 76, label %.thread
    i32 77, label %.thread
  ]

12:                                               ; preds = %9, %9
  %13 = tail call ptr @ast_childidx(ptr noundef %10, i64 noundef 4) #2
  %14 = tail call ptr @ast_child(ptr noundef %13) #2
  %.not.not34 = icmp eq ptr %14, null
  br i1 %.not.not34, label %.thread, label %.lr.ph36

.lr.ph36:                                         ; preds = %12, %17
  %.035 = phi ptr [ %18, %17 ], [ %14, %12 ]
  %15 = tail call i32 @ast_id(ptr noundef nonnull %.035) #2
  %16 = icmp eq i32 %15, 88
  br i1 %16, label %.thread, label %17

17:                                               ; preds = %.lr.ph36
  %18 = tail call ptr @ast_sibling(ptr noundef nonnull %.035) #2
  %.not.not = icmp eq ptr %18, null
  br i1 %.not.not, label %.thread, label %.lr.ph36, !llvm.loop !7

19:                                               ; preds = %.lr.ph
  %20 = tail call ptr @typeparam_constraint(ptr noundef nonnull %.tr32) #2
  br label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %19, %22
  %.tr.be = phi ptr [ %20, %19 ], [ %23, %22 ]
  %21 = icmp eq ptr %.tr.be, null
  br i1 %21, label %.thread, label %.lr.ph

22:                                               ; preds = %.lr.ph
  %23 = tail call ptr @ast_childidx(ptr noundef nonnull %.tr32, i64 noundef 1) #2
  br label %tailrecurse.backedge

.loopexit:                                        ; preds = %.lr.ph, %9
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i64 noundef 1903, ptr noundef nonnull @__func__.is_constructable) #2
  br label %.thread

.thread:                                          ; preds = %tailrecurse.backedge, %.lr.ph, %.lr.ph, %17, %.lr.ph36, %7, %.lr.ph41, %1, %12, %4, %9, %9, %9, %9, %.loopexit
  %.3 = phi i1 [ false, %.loopexit ], [ true, %9 ], [ true, %9 ], [ true, %9 ], [ true, %9 ], [ false, %4 ], [ false, %12 ], [ false, %1 ], [ %6, %.lr.ph41 ], [ %6, %7 ], [ %16, %.lr.ph36 ], [ %16, %17 ], [ false, %.lr.ph ], [ false, %.lr.ph ], [ false, %tailrecurse.backedge ]
  ret i1 %.3
}

declare ptr @ast_child(ptr noundef) local_unnamed_addr #0

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #0

declare ptr @ast_data(ptr noundef) local_unnamed_addr #0

declare ptr @typeparam_constraint(ptr noundef) local_unnamed_addr #0

attributes #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 #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 = { 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)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass