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

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

@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__checkTaggedPointerOptions__(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkNamespaceDefStructs__(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.Node__, align 8
  %9 = 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
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.tag_____NamespaceDef__, ptr %10, i32 0, i32 10
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.tag_____NamespaceDef__, ptr %13, i32 0, i32 9
  %15 = load i32, ptr %14, align 8, !tbaa !12
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %27

17:                                               ; preds = %2
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.tag_____Namespace__, ptr %18, i32 0, i32 3
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = and i32 %20, 524288
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %26

23:                                               ; preds = %17
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  call void @TypeChecker__checkStructFields__(ptr noundef %24, ptr noundef %25)
  br label %26

26:                                               ; preds = %23, %17
  br label %42

27:                                               ; preds = %2
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.tag_____NamespaceDef__, ptr %28, i32 0, i32 9
  %30 = load i32, ptr %29, align 8, !tbaa !12
  %31 = icmp eq i32 %30, 3
  br i1 %31, label %32, label %41

32:                                               ; preds = %27
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.tag_____Namespace__, ptr %33, i32 0, i32 8
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %40

37:                                               ; preds = %32
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  call void @TypeChecker__checkTaggedPointerOptions__(ptr noundef %38, ptr noundef %39)
  br label %40

40:                                               ; preds = %37, %32
  br label %41

41:                                               ; preds = %40, %27
  br label %42

42:                                               ; preds = %41, %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tag_____NamespaceDef__, ptr %43, i32 0, i32 7
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  store ptr %45, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !18
  br label %46

46:                                               ; preds = %70, %42
  %47 = load i32, ptr %7, align 4, !tbaa !18
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.tag_____List__Node____, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !19
  %51 = icmp slt i32 %47, %50
  br i1 %51, label %52, label %73

52:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.tag_____List__Node____, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !21
  %56 = load i32, ptr %7, align 4, !tbaa !18
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds %struct.Node__, ptr %55, i64 %57
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %58, i64 16, i1 false), !tbaa.struct !22
  %59 = getelementptr inbounds %struct.Node__, ptr %8, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !23
  switch i32 %60, label %66 [
    i32 31, label %61
    i32 0, label %67
  ]

61:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %62 = getelementptr inbounds %struct.Node__, ptr %8, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !25
  store ptr %63, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  call void @TypeChecker__checkNamespaceDefStructs__(ptr noundef %64, ptr noundef %65)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %70

66:                                               ; preds = %52
  br label %70

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

70:                                               ; preds = %67, %66, %61
  %71 = load i32, ptr %7, align 4, !tbaa !18
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %7, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  br label %46, !llvm.loop !26

73:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, 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__checkStructFields__(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 80}
!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 = !{!10, !11, i64 72}
!13 = !{!14, !11, i64 28}
!14 = !{!"tag_____Namespace__", !15, i64 0, !6, i64 16, !11, i64 24, !11, i64 28, !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, !11, i64 104}
!15 = !{!"", !6, i64 0, !11, i64 8}
!16 = !{!14, !6, i64 64}
!17 = !{!10, !6, i64 56}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !11, i64 8}
!20 = !{!"tag_____List__Node____", !6, i64 0, !11, i64 8, !11, i64 12}
!21 = !{!20, !6, i64 0}
!22 = !{i64 0, i64 4, !18, i64 8, i64 8, !5}
!23 = !{!24, !11, i64 0}
!24 = !{!"", !11, i64 0, !6, i64 8}
!25 = !{!24, !6, i64 8}
!26 = distinct !{!26, !27}
!27 = !{!"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__checkTaggedPointerOptions__(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkNamespaceDefStructs__(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 80
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 72
  %6 = load i32, ptr %5, align 8, !tbaa !11
  switch i32 %6, label %18 [
    i32 1, label %7
    i32 3, label %13
  ]

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %4, i64 28
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = and i32 %9, 524288
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %18

12:                                               ; preds = %7
  tail call void @TypeChecker__checkStructFields__(ptr noundef %0, ptr noundef nonnull %4)
  br label %18

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %4, i64 64
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  tail call void @TypeChecker__checkTaggedPointerOptions__(ptr noundef %0, ptr noundef nonnull %1)
  br label %18

18:                                               ; preds = %2, %17, %13, %7, %12
  %19 = getelementptr inbounds i8, ptr %1, i64 56
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load i32, ptr %21, align 8, !tbaa !17
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %18
  %24 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  br label %25

25:                                               ; preds = %.lr.ph, %31
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %31 ]
  %26 = load ptr, ptr %20, align 8, !tbaa !19
  %27 = getelementptr inbounds %struct.Node__, ptr %26, i64 %indvars.iv
  %.sroa.0.0.copyload = load i32, ptr %27, align 8, !tbaa !20
  switch i32 %.sroa.0.0.copyload, label %31 [
    i32 31, label %28
    i32 0, label %29
  ]

28:                                               ; preds = %25
  %.sroa.41.0..sroa_idx = getelementptr inbounds i8, ptr %27, i64 8
  %.sroa.41.0.copyload = load ptr, ptr %.sroa.41.0..sroa_idx, align 8, !tbaa !21
  tail call void @TypeChecker__checkNamespaceDefStructs__(ptr noundef %0, ptr noundef %.sroa.41.0.copyload)
  br label %31

29:                                               ; preds = %25
  %30 = load ptr, ptr %24, align 8, !tbaa !21
  tail call void %30(i32 noundef -5) #2
  br label %31

31:                                               ; preds = %25, %29, %28
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = load i32, ptr %21, align 8, !tbaa !17
  %33 = sext i32 %32 to i64
  %34 = icmp slt i64 %indvars.iv.next, %33
  br i1 %34, label %25, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %31, %18
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @TypeChecker__checkStructFields__(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 80}
!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 = !{!6, !10, i64 72}
!12 = !{!13, !10, i64 28}
!13 = !{!"tag_____Namespace__", !14, i64 0, !7, i64 16, !10, i64 24, !10, i64 28, !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, !10, i64 104}
!14 = !{!"", !7, i64 0, !10, i64 8}
!15 = !{!13, !7, i64 64}
!16 = !{!6, !7, i64 56}
!17 = !{!18, !10, i64 8}
!18 = !{!"tag_____List__Node____", !7, i64 0, !10, i64 8, !10, i64 12}
!19 = !{!18, !7, i64 0}
!20 = !{!10, !10, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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