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

; 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 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__func__.alias = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @alias(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [3 x ptr], align 16
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call i32 @ast_id(ptr noundef %17)
  switch i32 %18, label %112 [
    i32 149, label %19
    i32 56, label %19
    i32 150, label %19
    i32 151, label %38
    i32 187, label %38
    i32 17, label %41
    i32 154, label %110
    i32 155, label %110
    i32 153, label %110
    i32 157, label %110
    i32 158, label %110
    i32 156, label %110
  ]

19:                                               ; preds = %1, %1, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call i32 @ast_id(ptr noundef %21)
  %23 = call ptr @ast_from(ptr noundef %20, i32 noundef %22)
  store ptr %23, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call ptr @ast_child(ptr noundef %24)
  store ptr %25, ptr %5, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %29, %19
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %36

29:                                               ; preds = %26
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call ptr @alias(ptr noundef %31)
  %33 = call ptr @ast_append(ptr noundef %30, ptr noundef %32)
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call ptr @ast_sibling(ptr noundef %34)
  store ptr %35, ptr %5, align 8, !tbaa !5
  br label %26, !llvm.loop !9

36:                                               ; preds = %26
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %37, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %114

38:                                               ; preds = %1, %1
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = call ptr @alias_single(ptr noundef %39)
  store ptr %40, ptr %2, align 8
  br label %114

41:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #3
  store ptr %6, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds ptr, ptr %8, i64 1
  store ptr %7, ptr %42, align 8, !tbaa !5
  %43 = getelementptr inbounds ptr, ptr %8, i64 2
  store ptr null, ptr %43, align 8, !tbaa !5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds [3 x ptr], ptr %8, i64 0, i64 0
  call void @ast_get_children(ptr noundef %44, i64 noundef 2, ptr noundef %45)
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %46, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store ptr null, ptr %13, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = call ptr @ast_from(ptr noundef %47, i32 noundef 17)
  store ptr %48, ptr %13, align 8, !tbaa !5
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = icmp eq ptr %49, null
  br i1 %50, label %51, label %53

51:                                               ; preds = %41
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %52, ptr %11, align 8, !tbaa !5
  br label %65

53:                                               ; preds = %41
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = call ptr @ast_add(ptr noundef %57, ptr noundef %58)
  store ptr %59, ptr %12, align 8, !tbaa !5
  br label %64

60:                                               ; preds = %53
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = call ptr @ast_add_sibling(ptr noundef %61, ptr noundef %62)
  store ptr %63, ptr %12, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %60, %56
  br label %65

65:                                               ; preds = %64, %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %66, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  store ptr null, ptr %16, align 8, !tbaa !5
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = icmp eq ptr %67, null
  br i1 %68, label %69, label %71

69:                                               ; preds = %65
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %70, ptr %14, align 8, !tbaa !5
  br label %83

71:                                               ; preds = %65
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = icmp eq ptr %72, null
  br i1 %73, label %74, label %78

74:                                               ; preds = %71
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = call ptr @ast_add(ptr noundef %75, ptr noundef %76)
  store ptr %77, ptr %15, align 8, !tbaa !5
  br label %82

78:                                               ; preds = %71
  %79 = load ptr, ptr %15, align 8, !tbaa !5
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = call ptr @ast_add_sibling(ptr noundef %79, ptr noundef %80)
  store ptr %81, ptr %15, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %78, %74
  br label %83

83:                                               ; preds = %82, %69
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = icmp eq ptr %84, null
  br i1 %85, label %86, label %89

86:                                               ; preds = %83
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = call ptr @alias(ptr noundef %87)
  store ptr %88, ptr %14, align 8, !tbaa !5
  br label %103

89:                                               ; preds = %83
  %90 = load ptr, ptr %15, align 8, !tbaa !5
  %91 = icmp eq ptr %90, null
  br i1 %91, label %92, label %97

92:                                               ; preds = %89
  %93 = load ptr, ptr %14, align 8, !tbaa !5
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = call ptr @alias(ptr noundef %94)
  %96 = call ptr @ast_add(ptr noundef %93, ptr noundef %95)
  store ptr %96, ptr %15, align 8, !tbaa !5
  br label %102

97:                                               ; preds = %89
  %98 = load ptr, ptr %15, align 8, !tbaa !5
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = call ptr @alias(ptr noundef %99)
  %101 = call ptr @ast_add_sibling(ptr noundef %98, ptr noundef %100)
  store ptr %101, ptr %15, align 8, !tbaa !5
  br label %102

102:                                              ; preds = %97, %92
  br label %103

103:                                              ; preds = %102, %86
  %104 = load ptr, ptr %14, align 8, !tbaa !5
  call void @ast_inheritflags(ptr noundef %104)
  %105 = load ptr, ptr %14, align 8, !tbaa !5
  %106 = load ptr, ptr %15, align 8, !tbaa !5
  %107 = load ptr, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %108 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %108, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %109, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %114

110:                                              ; preds = %1, %1, %1, %1, %1, %1
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %111, ptr %2, align 8
  br label %114

112:                                              ; preds = %1
  br label %113

113:                                              ; preds = %112
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 293, ptr noundef @__func__.alias)
  store ptr null, ptr %2, align 8
  br label %114

114:                                              ; preds = %113, %110, %103, %38, %36
  %115 = load ptr, ptr %2, align 8
  ret ptr %115
}

declare i32 @ast_id(ptr noundef) #1

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

declare ptr @ast_from(ptr noundef, i32 noundef) #1

declare ptr @ast_child(ptr noundef) #1

declare ptr @ast_append(ptr noundef, ptr noundef) #1

declare ptr @ast_sibling(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @alias_single(ptr noundef) #0

declare void @ast_get_children(ptr noundef, i64 noundef, ptr noundef) #1

declare ptr @ast_add(ptr noundef, ptr noundef) #1

declare ptr @ast_add_sibling(ptr noundef, ptr noundef) #1

declare void @ast_inheritflags(ptr noundef) #1

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

attributes #0 = { 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 #1 = { "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"}


; 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 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__func__.alias = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @alias(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca [3 x ptr], align 16
  %5 = tail call i32 @ast_id(ptr noundef %0) #3
  switch i32 %5, label %37 [
    i32 149, label %6
    i32 56, label %6
    i32 150, label %6
    i32 151, label %13
    i32 187, label %13
    i32 17, label %15
    i32 154, label %.loopexit
    i32 155, label %.loopexit
    i32 153, label %.loopexit
    i32 157, label %.loopexit
    i32 158, label %.loopexit
    i32 156, label %.loopexit
  ]

6:                                                ; preds = %1, %1, %1
  %7 = tail call i32 @ast_id(ptr noundef %0) #3
  %8 = tail call ptr @ast_from(ptr noundef %0, i32 noundef %7) #3
  %9 = tail call ptr @ast_child(ptr noundef %0) #3
  %.not51 = icmp eq ptr %9, null
  br i1 %.not51, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %6, %.lr.ph
  %.04152 = phi ptr [ %12, %.lr.ph ], [ %9, %6 ]
  %10 = tail call ptr @alias(ptr noundef nonnull %.04152)
  %11 = tail call ptr @ast_append(ptr noundef %8, ptr noundef %10) #3
  %12 = tail call ptr @ast_sibling(ptr noundef nonnull %.04152) #3
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !5

13:                                               ; preds = %1, %1
  %14 = tail call ptr @alias_single(ptr noundef %0)
  br label %.loopexit

15:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  store ptr %2, ptr %4, align 16, !tbaa !7
  %16 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %3, ptr %16, align 8, !tbaa !7
  %17 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr null, ptr %17, align 16, !tbaa !7
  call void @ast_get_children(ptr noundef %0, i64 noundef 2, ptr noundef nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  %18 = call ptr @ast_from(ptr noundef %0, i32 noundef 17) #3
  %19 = icmp eq ptr %18, null
  %20 = load ptr, ptr %2, align 8, !tbaa !7
  br i1 %19, label %21, label %26

21:                                               ; preds = %15
  %22 = icmp eq ptr %20, null
  br i1 %22, label %23, label %.thread47

23:                                               ; preds = %21
  %24 = load ptr, ptr %3, align 8, !tbaa !7
  %25 = call ptr @alias(ptr noundef %24)
  br label %36

26:                                               ; preds = %15
  %27 = call ptr @ast_add(ptr noundef nonnull %18, ptr noundef %20) #3
  %28 = icmp eq ptr %27, null
  br i1 %28, label %.thread47, label %32

.thread47:                                        ; preds = %21, %26
  %.0384550 = phi ptr [ %18, %26 ], [ %20, %21 ]
  %29 = load ptr, ptr %3, align 8, !tbaa !7
  %30 = call ptr @alias(ptr noundef %29)
  %31 = call ptr @ast_add(ptr noundef nonnull %.0384550, ptr noundef %30) #3
  br label %36

32:                                               ; preds = %26
  %33 = load ptr, ptr %3, align 8, !tbaa !7
  %34 = call ptr @alias(ptr noundef %33)
  %35 = call ptr @ast_add_sibling(ptr noundef nonnull %27, ptr noundef %34) #3
  br label %36

36:                                               ; preds = %.thread47, %32, %23
  %.139 = phi ptr [ %25, %23 ], [ %.0384550, %.thread47 ], [ %18, %32 ]
  call void @ast_inheritflags(ptr noundef %.139) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  br label %.loopexit

37:                                               ; preds = %1
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 293, ptr noundef nonnull @__func__.alias) #3
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %6, %1, %1, %1, %1, %1, %1, %37, %36, %13
  %.0 = phi ptr [ null, %37 ], [ %18, %36 ], [ %14, %13 ], [ %0, %1 ], [ %0, %1 ], [ %0, %1 ], [ %0, %1 ], [ %0, %1 ], [ %0, %1 ], [ %8, %6 ], [ %8, %.lr.ph ]
  ret ptr %.0
}

declare i32 @ast_id(ptr noundef) local_unnamed_addr #1

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

declare ptr @ast_from(ptr noundef, i32 noundef) local_unnamed_addr #1

declare ptr @ast_child(ptr noundef) local_unnamed_addr #1

declare ptr @ast_append(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @alias_single(ptr noundef) local_unnamed_addr #0

declare void @ast_get_children(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ast_add(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ast_add_sibling(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @ast_inheritflags(ptr noundef) local_unnamed_addr #1

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

attributes #0 = { 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 #1 = { "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 = { mustprogress 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass