; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_TypeChecker (checkCodeUnit__)

; 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_____TypeCheckerContext__ = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i8 }
%struct.tag_____CodeUnit__ = type { %struct.string__, i32, %struct.string__, ptr }
%struct.string__ = type { ptr, i32 }
%struct.tag_____List__Node____ = type { ptr, i32, i32 }
%struct.tag_____FunctionDef__ = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.Node__, ptr, ptr, ptr, ptr, i32, ptr, %struct.string__, %struct.string__, %struct.tag_____Tag__, i32, ptr, ptr, ptr, ptr, %struct.string__ }
%struct.tag_____Tag__ = type { ptr, ptr }

@top_____abandonFn__ = external dso_local thread_local global ptr, align 8

; 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 speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkCodeUnit__(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.Node__, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %13, i32 0, i32 5
  store ptr %12, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tag_____CodeUnit__, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  store ptr %17, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %18

18:                                               ; preds = %72, %2
  %19 = load i32, ptr %6, align 4, !tbaa !15
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.tag_____List__Node____, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %24, label %75

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.tag_____List__Node____, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = load i32, ptr %6, align 4, !tbaa !15
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %struct.Node__, ptr %27, i64 %29
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %30, i64 16, i1 false), !tbaa.struct !19
  %31 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !20
  switch i32 %32, label %69 [
    i32 31, label %33
    i32 34, label %38
    i32 1, label %55
    i32 21, label %65
    i32 0, label %68
  ]

33:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %34 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !22
  store ptr %35, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  call void @TypeChecker__checkNamespace__(ptr noundef %36, ptr noundef %37)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %72

38:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %39 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !22
  store ptr %40, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.tag_____FunctionDef__, ptr %41, i32 0, i32 12
  %43 = load i32, ptr %42, align 8, !tbaa !23
  %44 = and i32 %43, 8
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %54

46:                                               ; preds = %38
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %47, i32 0, i32 3
  %49 = load ptr, ptr %48, align 8, !tbaa !26
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %50, i32 0, i32 6
  store ptr %49, ptr %51, align 8, !tbaa !27
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  call void @TypeChecker__checkFunction__(ptr noundef %52, ptr noundef %53)
  br label %54

54:                                               ; preds = %46, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %72

55:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %56 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !22
  store ptr %57, ptr %10, align 8, !tbaa !5
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !26
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %61, i32 0, i32 6
  store ptr %60, ptr %62, align 8, !tbaa !27
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  call void @TypeChecker__checkStaticField__(ptr noundef %63, ptr noundef %64)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %72

65:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %66 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !22
  store ptr %67, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %72

68:                                               ; preds = %24
  br label %69

69:                                               ; preds = %68, %24
  %70 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  call void %71(i32 noundef -5)
  br label %72

72:                                               ; preds = %69, %65, %55, %54, %33
  %73 = load i32, ptr %6, align 4, !tbaa !15
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %6, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  br label %18, !llvm.loop !28

75:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 40}
!10 = !{!"tag_____TypeCheckerContext__", !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, !11, i64 120, !11, i64 124, !6, i64 128, !11, i64 136, !7, i64 140}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 40}
!13 = !{!"tag_____CodeUnit__", !14, i64 0, !11, i64 16, !14, i64 24, !6, i64 40}
!14 = !{!"", !6, i64 0, !11, i64 8}
!15 = !{!11, !11, i64 0}
!16 = !{!17, !11, i64 8}
!17 = !{!"tag_____List__Node____", !6, i64 0, !11, i64 8, !11, i64 12}
!18 = !{!17, !6, i64 0}
!19 = !{i64 0, i64 4, !15, i64 8, i64 8, !5}
!20 = !{!21, !11, i64 0}
!21 = !{!"", !11, i64 0, !6, i64 8}
!22 = !{!21, !6, i64 8}
!23 = !{!24, !11, i64 104}
!24 = !{!"tag_____FunctionDef__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !21, i64 56, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !11, i64 104, !6, i64 112, !14, i64 120, !14, i64 136, !25, i64 152, !11, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !14, i64 208}
!25 = !{!"tag_____Tag__", !6, i64 0, !6, i64 8}
!26 = !{!10, !6, i64 24}
!27 = !{!10, !6, i64 48}
!28 = distinct !{!28, !29}
!29 = !{!"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"

%struct.Node__ = type { i32, ptr }

@top_____abandonFn__ = external dso_local thread_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkCodeUnit__(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %1, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 40
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !14
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  br label %12

12:                                               ; preds = %.lr.ph, %27
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %27 ]
  %13 = load ptr, ptr %5, align 8, !tbaa !16
  %14 = getelementptr inbounds %struct.Node__, ptr %13, i64 %indvars.iv
  %.sroa.0.0.copyload = load i32, ptr %14, align 8, !tbaa !17
  %.sroa.44.0..sroa_idx = getelementptr inbounds i8, ptr %14, i64 8
  %.sroa.44.0.copyload = load ptr, ptr %.sroa.44.0..sroa_idx, align 8, !tbaa !18
  switch i32 %.sroa.0.0.copyload, label %25 [
    i32 31, label %15
    i32 34, label %16
    i32 1, label %23
    i32 21, label %27
  ]

15:                                               ; preds = %12
  tail call void @TypeChecker__checkNamespace__(ptr noundef %0, ptr noundef %.sroa.44.0.copyload)
  br label %27

16:                                               ; preds = %12
  %17 = getelementptr inbounds i8, ptr %.sroa.44.0.copyload, i64 104
  %18 = load i32, ptr %17, align 8, !tbaa !19
  %19 = and i32 %18, 8
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %27

21:                                               ; preds = %16
  %22 = load ptr, ptr %9, align 8, !tbaa !23
  store ptr %22, ptr %10, align 8, !tbaa !24
  tail call void @TypeChecker__checkFunction__(ptr noundef %0, ptr noundef nonnull %.sroa.44.0.copyload)
  br label %27

23:                                               ; preds = %12
  %24 = load ptr, ptr %9, align 8, !tbaa !23
  store ptr %24, ptr %10, align 8, !tbaa !24
  tail call void @TypeChecker__checkStaticField__(ptr noundef %0, ptr noundef %.sroa.44.0.copyload)
  br label %27

25:                                               ; preds = %12
  %26 = load ptr, ptr %11, align 8, !tbaa !18
  tail call void %26(i32 noundef -5) #2
  br label %27

27:                                               ; preds = %12, %16, %21, %25, %23, %15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr %6, align 8, !tbaa !14
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next, %29
  br i1 %30, label %12, label %._crit_edge, !llvm.loop !25

._crit_edge:                                      ; preds = %27, %2
  ret void
}

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 40}
!6 = !{!"tag_____TypeCheckerContext__", !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, !10, i64 120, !10, i64 124, !7, i64 128, !10, i64 136, !8, i64 140}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 40}
!12 = !{!"tag_____CodeUnit__", !13, i64 0, !10, i64 16, !13, i64 24, !7, i64 40}
!13 = !{!"", !7, i64 0, !10, i64 8}
!14 = !{!15, !10, i64 8}
!15 = !{!"tag_____List__Node____", !7, i64 0, !10, i64 8, !10, i64 12}
!16 = !{!15, !7, i64 0}
!17 = !{!10, !10, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !10, i64 104}
!20 = !{!"tag_____FunctionDef__", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !21, i64 56, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !10, i64 104, !7, i64 112, !13, i64 120, !13, i64 136, !22, i64 152, !10, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !13, i64 208}
!21 = !{!"", !10, i64 0, !7, i64 8}
!22 = !{!"tag_____Tag__", !7, i64 0, !7, i64 8}
!23 = !{!6, !7, i64 24}
!24 = !{!6, !7, i64 48}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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