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

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

%struct.typecheck_t = type { ptr, %struct.typecheck_stats_t, ptr }
%struct.typecheck_stats_t = type { i64, i64, i64, i64 }
%struct.typecheck_frame_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

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

declare ptr @ast_parent(ptr noundef) #1

declare i32 @ast_id(ptr noundef) #1

declare ptr @ast_sibling(ptr noundef) #1

declare ptr @ast_child(ptr noundef) #1

declare ptr @ast_childidx(ptr noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @is_method_result(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 i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.typecheck_t, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.typecheck_frame_t, ptr %11, i32 0, i32 7
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = icmp eq ptr %8, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  br label %74

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call ptr @ast_parent(ptr noundef %17)
  store ptr %18, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call i32 @ast_id(ptr noundef %19)
  switch i32 %20, label %68 [
    i32 175, label %21
    i32 108, label %27
    i32 116, label %27
    i32 122, label %27
    i32 109, label %27
    i32 110, label %34
    i32 120, label %34
    i32 181, label %34
    i32 118, label %46
    i32 180, label %53
    i32 111, label %53
    i32 107, label %53
    i32 178, label %53
    i32 124, label %54
    i32 125, label %54
    i32 206, label %61
  ]

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call ptr @ast_sibling(ptr noundef %22)
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %73

26:                                               ; preds = %21
  br label %69

27:                                               ; preds = %16, %16, %16, %16
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call ptr @ast_child(ptr noundef %28)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = icmp eq ptr %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %27
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %73

33:                                               ; preds = %27
  br label %69

34:                                               ; preds = %16, %16, %16
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = call ptr @ast_child(ptr noundef %35)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = icmp eq ptr %36, %37
  br i1 %38, label %44, label %39

39:                                               ; preds = %34
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = call ptr @ast_childidx(ptr noundef %40, i64 noundef 1)
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = icmp eq ptr %41, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %39, %34
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %73

45:                                               ; preds = %39
  br label %69

46:                                               ; preds = %16
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = call ptr @ast_childidx(ptr noundef %47, i64 noundef 1)
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = icmp eq ptr %48, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %46
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %73

52:                                               ; preds = %46
  br label %69

53:                                               ; preds = %16, %16, %16, %16
  br label %69

54:                                               ; preds = %16, %16
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = call ptr @ast_childidx(ptr noundef %55, i64 noundef 2)
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = icmp eq ptr %56, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %54
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %73

60:                                               ; preds = %54
  br label %69

61:                                               ; preds = %16
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = call ptr @ast_childidx(ptr noundef %62, i64 noundef 1)
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = icmp eq ptr %63, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %61
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %73

67:                                               ; preds = %61
  br label %69

68:                                               ; preds = %16
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %73

69:                                               ; preds = %67, %60, %53, %52, %45, %33, %26
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = call zeroext i1 @is_method_result(ptr noundef %70, ptr noundef %71)
  store i1 %72, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %73

73:                                               ; preds = %69, %68, %66, %59, %51, %44, %32, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %74

74:                                               ; preds = %73, %15
  %75 = load i1, ptr %3, align 1
  ret i1 %75
}

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, !6, i64 0}
!10 = !{!"typecheck_t", !6, i64 0, !11, i64 8, !6, i64 40}
!11 = !{!"typecheck_stats_t", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 56}
!14 = !{!"typecheck_frame_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200}


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

declare ptr @ast_parent(ptr noundef) local_unnamed_addr #0

declare i32 @ast_id(ptr noundef) local_unnamed_addr #0

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #0

declare ptr @ast_child(ptr noundef) local_unnamed_addr #0

declare ptr @ast_childidx(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @is_method_result(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 56
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %6 = icmp eq ptr %5, %1
  br i1 %6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %tailrecurse
  %.tr2122 = phi ptr [ %7, %tailrecurse ], [ %1, %2 ]
  %7 = tail call ptr @ast_parent(ptr noundef %.tr2122) #2
  %8 = tail call i32 @ast_id(ptr noundef %7) #2
  switch i32 %8, label %._crit_edge [
    i32 175, label %9
    i32 108, label %11
    i32 116, label %11
    i32 122, label %11
    i32 109, label %11
    i32 110, label %14
    i32 120, label %14
    i32 181, label %14
    i32 118, label %20
    i32 180, label %tailrecurse
    i32 111, label %tailrecurse
    i32 107, label %tailrecurse
    i32 178, label %tailrecurse
    i32 124, label %23
    i32 125, label %23
    i32 206, label %26
  ]

9:                                                ; preds = %.lr.ph
  %10 = tail call ptr @ast_sibling(ptr noundef %.tr2122) #2
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %tailrecurse, label %._crit_edge

11:                                               ; preds = %.lr.ph, %.lr.ph, %.lr.ph, %.lr.ph
  %12 = tail call ptr @ast_child(ptr noundef %7) #2
  %13 = icmp eq ptr %12, %.tr2122
  br i1 %13, label %._crit_edge, label %tailrecurse

14:                                               ; preds = %.lr.ph, %.lr.ph, %.lr.ph
  %15 = tail call ptr @ast_child(ptr noundef %7) #2
  %16 = icmp eq ptr %15, %.tr2122
  br i1 %16, label %._crit_edge, label %17

17:                                               ; preds = %14
  %18 = tail call ptr @ast_childidx(ptr noundef %7, i64 noundef 1) #2
  %19 = icmp eq ptr %18, %.tr2122
  br i1 %19, label %._crit_edge, label %tailrecurse

20:                                               ; preds = %.lr.ph
  %21 = tail call ptr @ast_childidx(ptr noundef %7, i64 noundef 1) #2
  %22 = icmp eq ptr %21, %.tr2122
  br i1 %22, label %._crit_edge, label %tailrecurse

23:                                               ; preds = %.lr.ph, %.lr.ph
  %24 = tail call ptr @ast_childidx(ptr noundef %7, i64 noundef 2) #2
  %25 = icmp eq ptr %24, %.tr2122
  br i1 %25, label %._crit_edge, label %tailrecurse

26:                                               ; preds = %.lr.ph
  %27 = tail call ptr @ast_childidx(ptr noundef %7, i64 noundef 1) #2
  %28 = icmp eq ptr %27, %.tr2122
  br i1 %28, label %._crit_edge, label %tailrecurse

tailrecurse:                                      ; preds = %26, %23, %.lr.ph, %.lr.ph, %.lr.ph, %.lr.ph, %20, %17, %11, %9
  %29 = load ptr, ptr %0, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 56
  %31 = load ptr, ptr %30, align 8, !tbaa !12
  %32 = icmp eq ptr %31, %7
  br i1 %32, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %tailrecurse, %.lr.ph, %26, %23, %20, %14, %17, %11, %9, %2
  %.1 = phi i1 [ true, %2 ], [ false, %9 ], [ false, %11 ], [ false, %17 ], [ false, %14 ], [ false, %20 ], [ false, %23 ], [ false, %26 ], [ false, %.lr.ph ], [ true, %tailrecurse ]
  ret i1 %.1
}

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 = !{!6, !7, i64 0}
!6 = !{!"typecheck_t", !7, i64 0, !10, i64 8, !7, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"typecheck_stats_t", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !7, i64 56}
!13 = !{!"typecheck_frame_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200}


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