; 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
@.str.25 = external hidden unnamed_addr constant [13 x i8], align 1
@__func__.is_bare = external hidden unnamed_addr constant [8 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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) #1

declare ptr @ast_data(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @is_bare(ptr noundef %0) #2 {
  %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
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  store i1 false, ptr %2, align 1
  br label %40

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call i32 @ast_id(ptr noundef %11)
  switch i32 %12, label %38 [
    i32 149, label %13
    i32 56, label %13
    i32 150, label %13
    i32 151, label %28
    i32 17, label %33
    i32 187, label %37
    i32 153, label %37
    i32 157, label %37
    i32 158, label %37
    i32 156, label %37
  ]

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

16:                                               ; preds = %23, %13
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %26

19:                                               ; preds = %16
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call zeroext i1 @is_bare(ptr noundef %20)
  br i1 %21, label %22, label %23

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

23:                                               ; preds = %19
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call ptr @ast_sibling(ptr noundef %24)
  store ptr %25, ptr %4, align 8, !tbaa !5
  br label %16, !llvm.loop !9

26:                                               ; preds = %16
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %27

27:                                               ; preds = %26, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %40

28:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = call ptr @ast_data(ptr noundef %29)
  store ptr %30, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call zeroext i1 @ast_has_annotation(ptr noundef %31, ptr noundef @.str.25)
  store i1 %32, ptr %2, align 1
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %40

33:                                               ; preds = %10
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = call ptr @ast_childidx(ptr noundef %34, i64 noundef 1)
  %36 = call zeroext i1 @is_bare(ptr noundef %35)
  store i1 %36, ptr %2, align 1
  br label %40

37:                                               ; preds = %10, %10, %10, %10, %10
  store i1 false, ptr %2, align 1
  br label %40

38:                                               ; preds = %10
  br label %39

39:                                               ; preds = %38
  call void @ponyint_assert_fail(ptr noundef @.str.24, ptr noundef @.str.1, i64 noundef 2069, ptr noundef @__func__.is_bare)
  store i1 false, ptr %2, align 1
  br label %40

40:                                               ; preds = %39, %37, %33, %28, %27, %9
  %41 = load i1, ptr %2, align 1
  ret i1 %41
}

declare zeroext i1 @ast_has_annotation(ptr noundef, 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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"}


; 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
@.str.25 = external hidden unnamed_addr constant [13 x i8], align 1
@__func__.is_bare = external hidden unnamed_addr constant [8 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

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

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

.lr.ph:                                           ; preds = %1, %tailrecurse
  %.tr16 = phi ptr [ %12, %tailrecurse ], [ %0, %1 ]
  %3 = tail call i32 @ast_id(ptr noundef nonnull %.tr16) #2
  switch i32 %3, label %14 [
    i32 149, label %4
    i32 56, label %4
    i32 150, label %4
    i32 151, label %9
    i32 17, label %tailrecurse
    i32 187, label %.loopexit
    i32 153, label %.loopexit
    i32 157, label %.loopexit
    i32 158, label %.loopexit
    i32 156, label %.loopexit
  ]

4:                                                ; preds = %.lr.ph, %.lr.ph, %.lr.ph
  %5 = tail call ptr @ast_child(ptr noundef nonnull %.tr16) #2
  %.not.not21 = icmp eq ptr %5, null
  br i1 %.not.not21, label %.loopexit, label %.lr.ph23

.lr.ph23:                                         ; preds = %4, %7
  %.01022 = phi ptr [ %8, %7 ], [ %5, %4 ]
  %6 = tail call zeroext i1 @is_bare(ptr noundef nonnull %.01022)
  br i1 %6, label %.loopexit, label %7

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

9:                                                ; preds = %.lr.ph
  %10 = tail call ptr @ast_data(ptr noundef nonnull %.tr16) #2
  %11 = tail call zeroext i1 @ast_has_annotation(ptr noundef %10, ptr noundef nonnull @.str.25) #2
  br label %.loopexit

tailrecurse:                                      ; preds = %.lr.ph
  %12 = tail call ptr @ast_childidx(ptr noundef nonnull %.tr16, i64 noundef 1) #2
  %13 = icmp eq ptr %12, null
  br i1 %13, label %.loopexit, label %.lr.ph

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

.loopexit:                                        ; preds = %tailrecurse, %.lr.ph, %.lr.ph, %.lr.ph, %.lr.ph, %.lr.ph, %7, %.lr.ph23, %1, %4, %14, %9
  %.1 = phi i1 [ false, %14 ], [ %11, %9 ], [ false, %4 ], [ false, %1 ], [ %6, %.lr.ph23 ], [ %6, %7 ], [ false, %.lr.ph ], [ false, %.lr.ph ], [ false, %.lr.ph ], [ false, %.lr.ph ], [ false, %.lr.ph ], [ false, %tailrecurse ]
  ret i1 %.1
}

declare zeroext i1 @ast_has_annotation(ptr noundef, 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"}


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