; 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 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@__func__.viewpoint_lower = external hidden unnamed_addr constant [16 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

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

declare ptr @cap_fetch(ptr noundef) #1

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

declare void @ast_free_unattached(ptr noundef) #1

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

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

21:                                               ; preds = %1
  br label %23

22:                                               ; preds = %1
  call void @ponyint_assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 239, ptr noundef @__func__.viewpoint_lower)
  br label %23

23:                                               ; preds = %22, %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #3
  store ptr %4, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds ptr, ptr %6, i64 1
  store ptr %5, ptr %24, align 8, !tbaa !5
  %25 = getelementptr inbounds ptr, ptr %6, i64 2
  store ptr null, ptr %25, align 8, !tbaa !5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds [3 x ptr], ptr %6, i64 0, i64 0
  call void @ast_get_children(ptr noundef %26, i64 noundef 2, ptr noundef %27)
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %28, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call i32 @ast_id(ptr noundef %29)
  switch i32 %30, label %39 [
    i32 151, label %31
    i32 187, label %31
    i32 17, label %32
  ]

31:                                               ; preds = %23, %23
  br label %40

32:                                               ; preds = %23
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call ptr @viewpoint_lower(ptr noundef %33)
  store ptr %34, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %84

38:                                               ; preds = %32
  br label %40

39:                                               ; preds = %23
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 258, ptr noundef @__func__.viewpoint_lower)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %84

40:                                               ; preds = %38, %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 2, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 2, ptr %10, align 4, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call i32 @ast_id(ptr noundef %41)
  switch i32 %42, label %56 [
    i32 91, label %43
    i32 92, label %43
    i32 93, label %43
    i32 94, label %43
    i32 95, label %43
    i32 96, label %43
    i32 152, label %46
    i32 151, label %47
    i32 187, label %47
  ]

43:                                               ; preds = %40, %40, %40, %40, %40, %40
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = call i32 @ast_id(ptr noundef %44)
  store i32 %45, ptr %9, align 4, !tbaa !9
  br label %57

46:                                               ; preds = %40
  store i32 97, ptr %9, align 4, !tbaa !9
  br label %57

47:                                               ; preds = %40, %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = call ptr @cap_fetch(ptr noundef %48)
  store ptr %49, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = call ptr @ast_sibling(ptr noundef %50)
  store ptr %51, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = call i32 @ast_id(ptr noundef %52)
  store i32 %53, ptr %9, align 4, !tbaa !9
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = call i32 @ast_id(ptr noundef %54)
  store i32 %55, ptr %10, align 4, !tbaa !9
  store i32 3, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %57

56:                                               ; preds = %40
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 292, ptr noundef @__func__.viewpoint_lower)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %83

57:                                               ; preds = %47, %46, %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = call ptr @cap_fetch(ptr noundef %58)
  store ptr %59, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = call ptr @ast_sibling(ptr noundef %60)
  store ptr %61, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = call i32 @ast_id(ptr noundef %62)
  store i32 %63, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %64 = load ptr, ptr %14, align 8, !tbaa !5
  %65 = call i32 @ast_id(ptr noundef %64)
  store i32 %65, ptr %16, align 4, !tbaa !9
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = call zeroext i1 @cap_view_lower(i32 noundef %66, i32 noundef %67, ptr noundef %15, ptr noundef %16)
  br i1 %68, label %70, label %69

69:                                               ; preds = %57
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %82

70:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load i32, ptr %15, align 4, !tbaa !9
  %73 = load i32, ptr %16, align 4, !tbaa !9
  %74 = call ptr @set_cap_and_ephemeral(ptr noundef %71, i32 noundef %72, i32 noundef %73)
  store ptr %74, ptr %17, align 8, !tbaa !5
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = icmp ne ptr %75, %76
  br i1 %77, label %78, label %80

78:                                               ; preds = %70
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ast_free_unattached(ptr noundef %79)
  br label %80

80:                                               ; preds = %78, %70
  %81 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %81, ptr %2, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %82

82:                                               ; preds = %80, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %83

83:                                               ; preds = %82, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %84

84:                                               ; preds = %83, %39, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %85 = load ptr, ptr %2, align 8
  ret ptr %85
}

declare zeroext i1 @cap_view_lower(i32 noundef, i32 noundef, ptr noundef, ptr noundef) #1

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 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@__func__.viewpoint_lower = external hidden unnamed_addr constant [16 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

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

declare ptr @cap_fetch(ptr noundef) local_unnamed_addr #1

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

declare void @ast_free_unattached(ptr noundef) local_unnamed_addr #1

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

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

9:                                                ; preds = %1
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 239, ptr noundef nonnull @__func__.viewpoint_lower) #3
  br label %10

10:                                               ; preds = %1, %9
  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 !5
  %11 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %3, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr null, ptr %12, align 16, !tbaa !5
  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
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call i32 @ast_id(ptr noundef %13) #3
  switch i32 %14, label %19 [
    i32 151, label %20
    i32 187, label %20
    i32 17, label %15
  ]

15:                                               ; preds = %10
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = call ptr @viewpoint_lower(ptr noundef %16)
  %18 = icmp eq ptr %17, null
  br i1 %18, label %46, label %20

19:                                               ; preds = %10
  call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 258, ptr noundef nonnull @__func__.viewpoint_lower) #3
  br label %46

20:                                               ; preds = %15, %10, %10
  %.016 = phi ptr [ %17, %15 ], [ %13, %10 ], [ %13, %10 ]
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = call i32 @ast_id(ptr noundef %21) #3
  switch i32 %22, label %32 [
    i32 91, label %23
    i32 92, label %23
    i32 93, label %23
    i32 94, label %23
    i32 95, label %23
    i32 96, label %23
    i32 152, label %33
    i32 151, label %26
    i32 187, label %26
  ]

23:                                               ; preds = %20, %20, %20, %20, %20, %20
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = call i32 @ast_id(ptr noundef %24) #3
  br label %33

26:                                               ; preds = %20, %20
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = call ptr @cap_fetch(ptr noundef %27) #3
  %29 = call ptr @ast_sibling(ptr noundef %28) #3
  %30 = call i32 @ast_id(ptr noundef %28) #3
  %31 = call i32 @ast_id(ptr noundef %29) #3
  br label %33

32:                                               ; preds = %20
  call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 292, ptr noundef nonnull @__func__.viewpoint_lower) #3
  br label %46

33:                                               ; preds = %20, %26, %23
  %.018 = phi i32 [ %31, %26 ], [ 2, %23 ], [ 2, %20 ]
  %.017 = phi i32 [ %30, %26 ], [ %25, %23 ], [ 97, %20 ]
  %34 = call ptr @cap_fetch(ptr noundef %.016) #3
  %35 = call ptr @ast_sibling(ptr noundef %34) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %36 = call i32 @ast_id(ptr noundef %34) #3
  store i32 %36, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %37 = call i32 @ast_id(ptr noundef %35) #3
  store i32 %37, ptr %6, align 4, !tbaa !9
  %38 = call zeroext i1 @cap_view_lower(i32 noundef %.017, i32 noundef %.018, ptr noundef nonnull %5, ptr noundef nonnull %6) #3
  br i1 %38, label %39, label %45

39:                                               ; preds = %33
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = call ptr @set_cap_and_ephemeral(ptr noundef %.016, i32 noundef %40, i32 noundef %41) #3
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %.016, %43
  br i1 %.not, label %45, label %44

44:                                               ; preds = %39
  call void @ast_free_unattached(ptr noundef %.016) #3
  br label %45

45:                                               ; preds = %39, %44, %33
  %.0 = phi ptr [ null, %33 ], [ %42, %44 ], [ %42, %39 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  br label %46

46:                                               ; preds = %32, %45, %15, %19
  %.2 = phi ptr [ null, %19 ], [ null, %15 ], [ null, %32 ], [ %.0, %45 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret ptr %.2
}

declare zeroext i1 @cap_view_lower(i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass