; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_RangeFinder (checkMatchStatement__)

; 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.Node__ = type { i32, ptr }
%struct.tag_____MatchStatement__ = type { ptr, %struct.Node__, ptr, ptr, ptr, ptr, ptr }
%struct.tag_____List__Ptr__Token______ = type { ptr, i32, i32 }
%struct.tag_____List__Node____ = type { ptr, i32, i32 }

; 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @RangeFinder__checkMatchStatement__(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.Node__, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.tag_____MatchStatement__, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  call void @RangeFinder__checkToken__(ptr noundef %11, ptr noundef %14)
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tag_____MatchStatement__, ptr %15, i32 0, i32 1
  %17 = getelementptr inbounds %struct.Node__, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %28

20:                                               ; preds = %2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.tag_____MatchStatement__, ptr %22, i32 0, i32 1
  %24 = getelementptr inbounds { i32, ptr }, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8
  %26 = getelementptr inbounds { i32, ptr }, ptr %23, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8
  call void @RangeFinder__checkAny__(ptr noundef %21, i32 %25, ptr %27)
  br label %28

28:                                               ; preds = %20, %2
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.tag_____MatchStatement__, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !14
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %56

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.tag_____MatchStatement__, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  store ptr %36, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %37

37:                                               ; preds = %43, %33
  %38 = load i32, ptr %6, align 4, !tbaa !15
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.tag_____List__Ptr__Token______, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !16
  %42 = icmp slt i32 %38, %41
  br i1 %42, label %43, label %55

43:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.tag_____List__Ptr__Token______, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = load i32, ptr %6, align 4, !tbaa !15
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds ptr, ptr %46, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  store ptr %50, ptr %7, align 8, !tbaa !5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  call void @RangeFinder__checkToken__(ptr noundef %51, ptr noundef %52)
  %53 = load i32, ptr %6, align 4, !tbaa !15
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %6, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %37, !llvm.loop !19

55:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %56

56:                                               ; preds = %55, %28
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.tag_____MatchStatement__, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  call void @RangeFinder__checkToken__(ptr noundef %57, ptr noundef %60)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.tag_____MatchStatement__, ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !22
  store ptr %63, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !15
  br label %64

64:                                               ; preds = %70, %56
  %65 = load i32, ptr %9, align 4, !tbaa !15
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.tag_____List__Node____, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 8, !tbaa !23
  %69 = icmp slt i32 %65, %68
  br i1 %69, label %70, label %84

70:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #3
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.tag_____List__Node____, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !25
  %74 = load i32, ptr %9, align 4, !tbaa !15
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds %struct.Node__, ptr %73, i64 %75
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %76, i64 16, i1 false), !tbaa.struct !26
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds { i32, ptr }, ptr %10, i32 0, i32 0
  %79 = load i32, ptr %78, align 8
  %80 = getelementptr inbounds { i32, ptr }, ptr %10, i32 0, i32 1
  %81 = load ptr, ptr %80, align 8
  call void @RangeFinder__checkAny__(ptr noundef %77, i32 %79, ptr %81)
  %82 = load i32, ptr %9, align 4, !tbaa !15
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %9, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #3
  br label %64, !llvm.loop !27

84:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.tag_____MatchStatement__, ptr %86, i32 0, i32 6
  %88 = load ptr, ptr %87, align 8, !tbaa !28
  call void @RangeFinder__checkToken__(ptr noundef %85, ptr noundef %88)
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"tag_____MatchStatement__", !6, i64 0, !11, i64 8, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"", !12, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 16}
!14 = !{!10, !6, i64 24}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !12, i64 8}
!17 = !{!"tag_____List__Ptr__Token______", !6, i64 0, !12, i64 8, !12, i64 12}
!18 = !{!17, !6, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !6, i64 32}
!22 = !{!10, !6, i64 48}
!23 = !{!24, !12, i64 8}
!24 = !{!"tag_____List__Node____", !6, i64 0, !12, i64 8, !12, i64 12}
!25 = !{!24, !6, i64 0}
!26 = !{i64 0, i64 4, !15, i64 8, i64 8, !5}
!27 = distinct !{!27, !20}
!28 = !{!10, !6, i64 56}


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

%struct.Node__ = type { i32, ptr }

; Function Attrs: nounwind uwtable
declare dso_local void @RangeFinder__checkToken__(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @RangeFinder__checkAny__(ptr noundef, i32, ptr) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @RangeFinder__checkMatchStatement__(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @RangeFinder__checkToken__(ptr noundef %0, ptr noundef %3)
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  %5 = load ptr, ptr %4, align 8
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %9, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load i32, ptr %7, align 8
  tail call void @RangeFinder__checkAny__(ptr noundef %0, i32 %8, ptr nonnull %5)
  br label %9

9:                                                ; preds = %6, %2
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %.not28 = icmp eq ptr %11, null
  br i1 %.not28, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %9
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %15 = load ptr, ptr %11, align 8, !tbaa !15
  %16 = getelementptr inbounds ptr, ptr %15, i64 %indvars.iv
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  tail call void @RangeFinder__checkToken__(ptr noundef %0, ptr noundef %17)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr %12, align 8, !tbaa !13
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %9
  %21 = getelementptr inbounds i8, ptr %1, i64 32
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  tail call void @RangeFinder__checkToken__(ptr noundef %0, ptr noundef %22)
  %23 = getelementptr inbounds i8, ptr %1, i64 48
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  %26 = load i32, ptr %25, align 8, !tbaa !21
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.lr.ph31, label %._crit_edge

.lr.ph31:                                         ; preds = %.loopexit, %.lr.ph31
  %indvars.iv33 = phi i64 [ %indvars.iv.next34, %.lr.ph31 ], [ 0, %.loopexit ]
  %28 = load ptr, ptr %24, align 8, !tbaa !23
  %29 = getelementptr inbounds %struct.Node__, ptr %28, i64 %indvars.iv33
  %.sroa.0.0.copyload = load i32, ptr %29, align 8, !tbaa !24
  %.sroa.41.0..sroa_idx = getelementptr inbounds i8, ptr %29, i64 8
  %.sroa.41.0.copyload = load ptr, ptr %.sroa.41.0..sroa_idx, align 8, !tbaa !16
  tail call void @RangeFinder__checkAny__(ptr noundef %0, i32 %.sroa.0.0.copyload, ptr %.sroa.41.0.copyload)
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %30 = load i32, ptr %25, align 8, !tbaa !21
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %indvars.iv.next34, %31
  br i1 %32, label %.lr.ph31, label %._crit_edge, !llvm.loop !25

._crit_edge:                                      ; preds = %.lr.ph31, %.loopexit
  %33 = getelementptr inbounds i8, ptr %1, i64 56
  %34 = load ptr, ptr %33, align 8, !tbaa !26
  tail call void @RangeFinder__checkToken__(ptr noundef %0, ptr noundef %34)
  ret void
}

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

!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 = !{!"tag_____MatchStatement__", !7, i64 0, !10, i64 8, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !7, i64 8}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 24}
!13 = !{!14, !11, i64 8}
!14 = !{!"tag_____List__Ptr__Token______", !7, i64 0, !11, i64 8, !11, i64 12}
!15 = !{!14, !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !7, i64 32}
!20 = !{!6, !7, i64 48}
!21 = !{!22, !11, i64 8}
!22 = !{!"tag_____List__Node____", !7, i64 0, !11, i64 8, !11, i64 12}
!23 = !{!22, !7, i64 0}
!24 = !{!11, !11, i64 0}
!25 = distinct !{!25, !18}
!26 = !{!6, !7, i64 56}


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