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

; 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_____NamespaceDef__ = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr }
%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 }
%struct.string__ = type { ptr, i32 }
%struct.tag_____TypeCheckerContext__ = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i8 }

@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
declare dso_local void @TypeChecker__checkStaticField__(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkNamespace__(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
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  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_____NamespaceDef__, ptr %15, i32 0, i32 7
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  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 !12
  br label %18

18:                                               ; preds = %81, %2
  %19 = load i32, ptr %6, align 4, !tbaa !12
  %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 !13
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %24, label %84

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 !15
  %28 = load i32, ptr %6, align 4, !tbaa !12
  %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 !16
  %31 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !17
  switch i32 %32, label %78 [
    i32 34, label %33
    i32 1, label %50
    i32 31, label %60
    i32 36, label %65
    i32 2, label %68
    i32 21, label %71
    i32 32, label %74
    i32 0, label %77
  ]

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 !19
  store ptr %35, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.tag_____FunctionDef__, ptr %36, i32 0, i32 12
  %38 = load i32, ptr %37, align 8, !tbaa !20
  %39 = and i32 %38, 8
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %49

41:                                               ; preds = %33
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.tag_____NamespaceDef__, ptr %42, i32 0, i32 10
  %44 = load ptr, ptr %43, align 8, !tbaa !24
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %45, i32 0, i32 6
  store ptr %44, ptr %46, align 8, !tbaa !25
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  call void @TypeChecker__checkFunction__(ptr noundef %47, ptr noundef %48)
  br label %49

49:                                               ; preds = %41, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %81

50:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %51 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !19
  store ptr %52, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.tag_____NamespaceDef__, ptr %53, i32 0, i32 10
  %55 = load ptr, ptr %54, align 8, !tbaa !24
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %56, i32 0, i32 6
  store ptr %55, ptr %57, align 8, !tbaa !25
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  call void @TypeChecker__checkStaticField__(ptr noundef %58, ptr noundef %59)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %81

60:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %61 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !19
  store ptr %62, ptr %10, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  call void @TypeChecker__checkNamespace__(ptr noundef %63, ptr noundef %64)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %81

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 !19
  store ptr %67, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %81

68:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %69 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  store ptr %70, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %81

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

74:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %75 = getelementptr inbounds %struct.Node__, ptr %7, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !19
  store ptr %76, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %81

77:                                               ; preds = %24
  br label %78

78:                                               ; preds = %77, %24
  %79 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  call void %80(i32 noundef -5)
  br label %81

81:                                               ; preds = %78, %74, %71, %68, %65, %60, %50, %49
  %82 = load i32, ptr %6, align 4, !tbaa !12
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  br label %18, !llvm.loop !27

84:                                               ; 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__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 56}
!10 = !{!"tag_____NamespaceDef__", !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, !11, i64 72, !6, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 8}
!14 = !{!"tag_____List__Node____", !6, i64 0, !11, i64 8, !11, i64 12}
!15 = !{!14, !6, i64 0}
!16 = !{i64 0, i64 4, !12, i64 8, i64 8, !5}
!17 = !{!18, !11, i64 0}
!18 = !{!"", !11, i64 0, !6, i64 8}
!19 = !{!18, !6, i64 8}
!20 = !{!21, !11, i64 104}
!21 = !{!"tag_____FunctionDef__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !18, i64 56, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !11, i64 104, !6, i64 112, !22, i64 120, !22, i64 136, !23, i64 152, !11, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !22, i64 208}
!22 = !{!"", !6, i64 0, !11, i64 8}
!23 = !{!"tag_____Tag__", !6, i64 0, !6, i64 8}
!24 = !{!10, !6, i64 80}
!25 = !{!26, !6, i64 48}
!26 = !{!"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}
!27 = distinct !{!27, !28}
!28 = !{!"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
declare dso_local void @TypeChecker__checkStaticField__(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

11:                                               ; preds = %.lr.ph, %26
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %12 = load ptr, ptr %4, align 8, !tbaa !13
  %13 = getelementptr inbounds %struct.Node__, ptr %12, i64 %indvars.iv
  %.sroa.0.0.copyload = load i32, ptr %13, align 8, !tbaa !14
  %.sroa.44.0..sroa_idx = getelementptr inbounds i8, ptr %13, i64 8
  %.sroa.44.0.copyload = load ptr, ptr %.sroa.44.0..sroa_idx, align 8, !tbaa !15
  switch i32 %.sroa.0.0.copyload, label %24 [
    i32 34, label %14
    i32 1, label %21
    i32 31, label %23
    i32 36, label %26
    i32 2, label %26
    i32 21, label %26
    i32 32, label %26
  ]

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

19:                                               ; preds = %14
  %20 = load ptr, ptr %8, align 8, !tbaa !21
  store ptr %20, ptr %9, align 8, !tbaa !22
  tail call void @TypeChecker__checkFunction__(ptr noundef %0, ptr noundef nonnull %.sroa.44.0.copyload)
  br label %26

21:                                               ; preds = %11
  %22 = load ptr, ptr %8, align 8, !tbaa !21
  store ptr %22, ptr %9, align 8, !tbaa !22
  tail call void @TypeChecker__checkStaticField__(ptr noundef %0, ptr noundef %.sroa.44.0.copyload)
  br label %26

23:                                               ; preds = %11
  tail call void @TypeChecker__checkNamespace__(ptr noundef %0, ptr noundef %.sroa.44.0.copyload)
  br label %26

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

26:                                               ; preds = %11, %11, %11, %11, %14, %19, %24, %23, %21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr %5, align 8, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %indvars.iv.next, %28
  br i1 %29, label %11, label %._crit_edge, !llvm.loop !24

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

; 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 56}
!6 = !{!"tag_____NamespaceDef__", !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, !10, i64 72, !7, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"tag_____List__Node____", !7, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !7, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !10, i64 104}
!17 = !{!"tag_____FunctionDef__", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !18, i64 56, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !10, i64 104, !7, i64 112, !19, i64 120, !19, i64 136, !20, i64 152, !10, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !19, i64 208}
!18 = !{!"", !10, i64 0, !7, i64 8}
!19 = !{!"", !7, i64 0, !10, i64 8}
!20 = !{!"tag_____Tag__", !7, i64 0, !7, i64 8}
!21 = !{!6, !7, i64 80}
!22 = !{!23, !7, i64 48}
!23 = !{!"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}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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