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

; 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 [78 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.viewpoint_reifypair = external hidden unnamed_addr constant [20 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1

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

declare i32 @ast_id(ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @viewpoint_reifytypeparam(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @viewpoint_reifythis(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @viewpoint_reifypair(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca [3 x ptr], align 16
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call i32 @ast_id(ptr noundef %17)
  %19 = icmp eq i32 %18, 17
  br i1 %19, label %20, label %21

20:                                               ; preds = %4
  br label %22

21:                                               ; preds = %4
  call void @ponyint_assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i64 noundef 515, ptr noundef @__func__.viewpoint_reifypair)
  br label %22

22:                                               ; preds = %21, %20
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = call i32 @ast_id(ptr noundef %23)
  %25 = icmp eq i32 %24, 17
  br i1 %25, label %26, label %27

26:                                               ; preds = %22
  br label %28

27:                                               ; preds = %22
  call void @ponyint_assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i64 noundef 516, ptr noundef @__func__.viewpoint_reifypair)
  br label %28

28:                                               ; preds = %27, %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %29, ptr %10, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %69, %28
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = call i32 @ast_id(ptr noundef %31)
  %33 = icmp eq i32 %32, 17
  br i1 %33, label %34, label %70

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  store ptr %11, ptr %13, align 8, !tbaa !5
  %35 = getelementptr inbounds ptr, ptr %13, i64 1
  store ptr %12, ptr %35, align 8, !tbaa !5
  %36 = getelementptr inbounds ptr, ptr %13, i64 2
  store ptr null, ptr %36, align 8, !tbaa !5
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds [3 x ptr], ptr %13, i64 0, i64 0
  call void @ast_get_children(ptr noundef %37, i64 noundef 2, ptr noundef %38)
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #3
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = call i32 @ast_id(ptr noundef %39)
  switch i32 %40, label %64 [
    i32 152, label %41
    i32 187, label %48
  ]

41:                                               ; preds = %34
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = call ptr @viewpoint_reifythis(ptr noundef %42)
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %43, ptr %44, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = call ptr @viewpoint_reifythis(ptr noundef %45)
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %46, ptr %47, align 8, !tbaa !5
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %67

48:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = call ptr @viewpoint_reifytypeparam(ptr noundef %49, ptr noundef %50)
  store ptr %51, ptr %15, align 8, !tbaa !5
  %52 = load ptr, ptr %15, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %48
  store i32 4, ptr %14, align 4
  br label %62

55:                                               ; preds = %48
  %56 = load ptr, ptr %15, align 8, !tbaa !5
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %56, ptr %57, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = call ptr @viewpoint_reifytypeparam(ptr noundef %58, ptr noundef %59)
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %60, ptr %61, align 8, !tbaa !5
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %62

62:                                               ; preds = %55, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  %63 = load i32, ptr %14, align 4
  switch i32 %63, label %67 [
    i32 4, label %65
  ]

64:                                               ; preds = %34
  br label %65

65:                                               ; preds = %64, %62
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %66, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %14, align 4
  br label %67

67:                                               ; preds = %65, %62, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %68 = load i32, ptr %14, align 4
  switch i32 %68, label %90 [
    i32 0, label %69
  ]

69:                                               ; preds = %67
  br label %30, !llvm.loop !9

70:                                               ; preds = %30
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = call i32 @ast_id(ptr noundef %71)
  %73 = icmp eq i32 %72, 187
  br i1 %73, label %74, label %89

74:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = call ptr @viewpoint_reifytypeparam(ptr noundef %75, ptr noundef %76)
  store ptr %77, ptr %16, align 8, !tbaa !5
  %78 = load ptr, ptr %16, align 8, !tbaa !5
  %79 = icmp eq ptr %78, null
  br i1 %79, label %80, label %81

80:                                               ; preds = %74
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %88

81:                                               ; preds = %74
  %82 = load ptr, ptr %16, align 8, !tbaa !5
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %82, ptr %83, align 8, !tbaa !5
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  %86 = call ptr @viewpoint_reifytypeparam(ptr noundef %84, ptr noundef %85)
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %86, ptr %87, align 8, !tbaa !5
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %88

88:                                               ; preds = %81, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %90

89:                                               ; preds = %70
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %90

90:                                               ; preds = %89, %88, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %91 = load i1, ptr %5, align 1
  ret i1 %91
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 [78 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.viewpoint_reifypair = external hidden unnamed_addr constant [20 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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.end.p0(i64 immarg, ptr nocapture) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @viewpoint_reifytypeparam(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @viewpoint_reifythis(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @viewpoint_reifypair(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [3 x ptr], align 16
  %8 = tail call i32 @ast_id(ptr noundef %0) #3
  %9 = icmp eq i32 %8, 17
  br i1 %9, label %11, label %10

10:                                               ; preds = %4
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i64 noundef 515, ptr noundef nonnull @__func__.viewpoint_reifypair) #3
  br label %11

11:                                               ; preds = %4, %10
  %12 = tail call i32 @ast_id(ptr noundef %1) #3
  %13 = icmp eq i32 %12, 17
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i64 noundef 516, ptr noundef nonnull @__func__.viewpoint_reifypair) #3
  br label %15

15:                                               ; preds = %11, %14
  %16 = tail call i32 @ast_id(ptr noundef %0) #3
  %17 = icmp eq i32 %16, 17
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %15
  %18 = getelementptr inbounds i8, ptr %7, i64 8
  %19 = getelementptr inbounds i8, ptr %7, i64 16
  br label %20

20:                                               ; preds = %.lr.ph, %33
  %.02737 = phi ptr [ %0, %.lr.ph ], [ %34, %33 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  store ptr %5, ptr %7, align 16, !tbaa !5
  store ptr %6, ptr %18, align 8, !tbaa !5
  store ptr null, ptr %19, align 16, !tbaa !5
  call void @ast_get_children(ptr noundef %.02737, i64 noundef 2, ptr noundef nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call i32 @ast_id(ptr noundef %21) #3
  switch i32 %22, label %33 [
    i32 152, label %23
    i32 187, label %26
  ]

23:                                               ; preds = %20
  %24 = call ptr @viewpoint_reifythis(ptr noundef %0)
  store ptr %24, ptr %2, align 8, !tbaa !5
  %25 = call ptr @viewpoint_reifythis(ptr noundef %1)
  br label %.thread

26:                                               ; preds = %20
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call ptr @viewpoint_reifytypeparam(ptr noundef %0, ptr noundef %27)
  %29 = icmp eq ptr %28, null
  br i1 %29, label %33, label %30

30:                                               ; preds = %26
  store ptr %28, ptr %2, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call ptr @viewpoint_reifytypeparam(ptr noundef %1, ptr noundef %31)
  br label %.thread

.thread:                                          ; preds = %30, %23
  %storemerge = phi ptr [ %32, %30 ], [ %25, %23 ]
  store ptr %storemerge, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  br label %43

33:                                               ; preds = %20, %26
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  %35 = call i32 @ast_id(ptr noundef %34) #3
  %36 = icmp eq i32 %35, 17
  br i1 %36, label %20, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %33, %15
  %.027.lcssa = phi ptr [ %0, %15 ], [ %34, %33 ]
  %37 = call i32 @ast_id(ptr noundef %.027.lcssa) #3
  %38 = icmp eq i32 %37, 187
  br i1 %38, label %39, label %43

39:                                               ; preds = %._crit_edge
  %40 = call ptr @viewpoint_reifytypeparam(ptr noundef %0, ptr noundef %.027.lcssa)
  %.not = icmp eq ptr %40, null
  br i1 %.not, label %43, label %41

41:                                               ; preds = %39
  store ptr %40, ptr %2, align 8, !tbaa !5
  %42 = call ptr @viewpoint_reifytypeparam(ptr noundef %1, ptr noundef %.027.lcssa)
  store ptr %42, ptr %3, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %.thread, %._crit_edge, %41, %39
  %.5 = phi i1 [ false, %39 ], [ true, %41 ], [ false, %._crit_edge ], [ true, %.thread ]
  ret i1 %.5
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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"}


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