; LLVM IR from ponylang/ponyc :: src/libponyc/pass (refer)

; 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.7 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.refer_dot = external hidden unnamed_addr constant [10 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

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

declare i32 @ast_id(ptr noundef) #1

declare ptr @ast_parent(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @refer_dot(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i1, align 1
  %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 i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call i32 @ast_id(ptr noundef %10)
  %12 = icmp eq i32 %11, 19
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  br label %15

14:                                               ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str.8, ptr noundef @.str.7, i64 noundef 670, ptr noundef @__func__.refer_dot)
  br label %15

15:                                               ; preds = %14, %13
  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
  %16 = getelementptr inbounds ptr, ptr %8, i64 1
  store ptr %7, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds ptr, ptr %8, i64 2
  store ptr null, ptr %17, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds [3 x ptr], ptr %8, i64 0, i64 0
  call void @ast_get_children(ptr noundef %18, i64 noundef 2, ptr noundef %19)
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call i32 @ast_id(ptr noundef %20)
  switch i32 %21, label %49 [
    i32 185, label %22
    i32 102, label %26
    i32 198, label %30
    i32 196, label %30
    i32 197, label %30
    i32 19, label %30
  ]

22:                                               ; preds = %15
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call zeroext i1 @refer_packageref_dot(ptr noundef %23, ptr noundef %24)
  store i1 %25, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %51

26:                                               ; preds = %15
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call zeroext i1 @refer_this_dot(ptr noundef %27, ptr noundef %28)
  store i1 %29, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %51

30:                                               ; preds = %15, %15, %15, %15
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call i32 @ast_checkflag(ptr noundef %31, i32 noundef 33554432)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %48

34:                                               ; preds = %30
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call ptr @ast_parent(ptr noundef %35)
  %37 = call i32 @ast_id(ptr noundef %36)
  %38 = icmp ne i32 %37, 177
  br i1 %38, label %39, label %48

39:                                               ; preds = %34
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = call ptr @ast_parent(ptr noundef %40)
  %42 = call i32 @ast_id(ptr noundef %41)
  %43 = icmp ne i32 %42, 176
  br i1 %43, label %44, label %48

44:                                               ; preds = %39
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call zeroext i1 @refer_multi_dot(ptr noundef %45, ptr noundef %46)
  store i1 %47, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %51

48:                                               ; preds = %39, %34, %30
  br label %49

49:                                               ; preds = %48, %15
  br label %50

50:                                               ; preds = %49
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %51

51:                                               ; preds = %50, %44, %26, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %52 = load i1, ptr %3, align 1
  ret i1 %52
}

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 hidden zeroext i1 @refer_packageref_dot(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @refer_this_dot(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @refer_multi_dot(ptr noundef, ptr noundef) #2

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


; 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.7 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.refer_dot = external hidden unnamed_addr constant [10 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

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

declare i32 @ast_id(ptr noundef) local_unnamed_addr #1

declare ptr @ast_parent(ptr noundef) local_unnamed_addr #1

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

8:                                                ; preds = %2
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.7, i64 noundef 670, ptr noundef nonnull @__func__.refer_dot) #3
  br label %9

9:                                                ; preds = %2, %8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  store ptr %3, ptr %5, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %4, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr null, ptr %11, align 16, !tbaa !5
  call void @ast_get_children(ptr noundef %1, i64 noundef 2, ptr noundef nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = call i32 @ast_id(ptr noundef %12) #3
  switch i32 %13, label %28 [
    i32 185, label %14
    i32 102, label %16
    i32 198, label %18
    i32 196, label %18
    i32 197, label %18
    i32 19, label %18
  ]

14:                                               ; preds = %9
  %15 = call zeroext i1 @refer_packageref_dot(ptr noundef %0, ptr noundef %1)
  br label %28

16:                                               ; preds = %9
  %17 = call zeroext i1 @refer_this_dot(ptr noundef %0, ptr noundef %1)
  br label %28

18:                                               ; preds = %9, %9, %9, %9
  %19 = call i32 @ast_checkflag(ptr noundef %1, i32 noundef 33554432) #3
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %28, label %20

20:                                               ; preds = %18
  %21 = call ptr @ast_parent(ptr noundef %1) #3
  %22 = call i32 @ast_id(ptr noundef %21) #3
  %.not12 = icmp eq i32 %22, 177
  br i1 %.not12, label %28, label %23

23:                                               ; preds = %20
  %24 = call ptr @ast_parent(ptr noundef %1) #3
  %25 = call i32 @ast_id(ptr noundef %24) #3
  %.not13 = icmp eq i32 %25, 176
  br i1 %.not13, label %28, label %26

26:                                               ; preds = %23
  %27 = call zeroext i1 @refer_multi_dot(ptr noundef %0, ptr noundef %1)
  br label %28

28:                                               ; preds = %18, %20, %23, %9, %26, %16, %14
  %.0 = phi i1 [ %27, %26 ], [ %17, %16 ], [ %15, %14 ], [ true, %9 ], [ true, %23 ], [ true, %20 ], [ true, %18 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i1 %.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 hidden zeroext i1 @refer_packageref_dot(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @refer_this_dot(ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @refer_multi_dot(ptr noundef, ptr noundef) local_unnamed_addr #2

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


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