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

; 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.tag_____Tag__ = type { ptr, 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__Ptr__FieldDef______ = type { ptr, i32, i32 }
%struct.tag_____FieldDef__ = type { ptr, ptr, %struct.Node__, ptr, %struct.tag_____Tag__ }
%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 }

; 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 { ptr, ptr } @TypeChecker__resolveType__(ptr noundef, i32, ptr, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkStructFields__(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 %struct.tag_____Tag__, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.tag_____Namespace__, ptr %9, i32 0, i32 3
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = or i32 %11, 262144
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.tag_____Namespace__, ptr %13, i32 0, i32 3
  store i32 %12, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tag_____Namespace__, ptr %15, i32 0, i32 7
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  store ptr %17, 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 !14
  br label %18

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

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.tag_____List__Ptr__FieldDef______, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = load i32, ptr %6, align 4, !tbaa !14
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds ptr, ptr %27, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.tag_____FieldDef__, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !18
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %35, i32 0, i32 5
  store ptr %34, ptr %36, align 8, !tbaa !22
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %38, i32 0, i32 6
  store ptr %37, ptr %39, align 8, !tbaa !24
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.tag_____FieldDef__, ptr %40, i32 0, i32 4
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tag_____FieldDef__, ptr %43, i32 0, i32 2
  %45 = getelementptr inbounds { i32, ptr }, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8
  %47 = getelementptr inbounds { i32, ptr }, ptr %44, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8
  %49 = call { ptr, ptr } @TypeChecker__resolveType__(ptr noundef %42, i32 %46, ptr %48, i32 noundef 1)
  %50 = getelementptr inbounds { ptr, ptr }, ptr %8, i32 0, i32 0
  %51 = extractvalue { ptr, ptr } %49, 0
  store ptr %51, ptr %50, align 8
  %52 = getelementptr inbounds { ptr, ptr }, ptr %8, i32 0, i32 1
  %53 = extractvalue { ptr, ptr } %49, 1
  store ptr %53, ptr %52, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %41, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.tag_____FieldDef__, ptr %57, i32 0, i32 4
  %59 = getelementptr inbounds { ptr, ptr }, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8
  %61 = getelementptr inbounds { ptr, ptr }, ptr %58, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8
  call void @TypeChecker__checkFieldCycles__(ptr noundef %54, ptr noundef %55, ptr noundef %56, ptr %60, ptr %62)
  %63 = load i32, ptr %6, align 4, !tbaa !14
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %18, !llvm.loop !26

65:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.tag_____Namespace__, ptr %66, i32 0, i32 3
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = and i32 %68, -262145
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.tag_____Namespace__, ptr %70, i32 0, i32 3
  store i32 %69, ptr %71, align 4, !tbaa !9
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.tag_____Namespace__, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 4, !tbaa !9
  %75 = or i32 %74, 524288
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.tag_____Namespace__, ptr %76, i32 0, i32 3
  store i32 %75, ptr %77, align 4, !tbaa !9
  ret void
}

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

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, !12, i64 28}
!10 = !{!"tag_____Namespace__", !11, i64 0, !6, i64 16, !12, i64 24, !12, 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, !12, i64 104}
!11 = !{!"", !6, i64 0, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 56}
!14 = !{!12, !12, i64 0}
!15 = !{!16, !12, i64 8}
!16 = !{!"tag_____List__Ptr__FieldDef______", !6, i64 0, !12, i64 8, !12, i64 12}
!17 = !{!16, !6, i64 0}
!18 = !{!19, !6, i64 0}
!19 = !{!"tag_____FieldDef__", !6, i64 0, !6, i64 8, !20, i64 16, !6, i64 32, !21, i64 40}
!20 = !{!"", !12, i64 0, !6, i64 8}
!21 = !{!"tag_____Tag__", !6, i64 0, !6, i64 8}
!22 = !{!23, !6, i64 40}
!23 = !{!"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, !12, i64 120, !12, i64 124, !6, i64 128, !12, i64 136, !7, i64 140}
!24 = !{!23, !6, i64 48}
!25 = !{i64 0, i64 8, !5, i64 8, i64 8, !5}
!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"

; Function Attrs: nounwind uwtable
declare dso_local { ptr, ptr } @TypeChecker__resolveType__(ptr noundef, i32, ptr, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkStructFields__(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 28
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = or i32 %4, 262144
  store i32 %5, ptr %3, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 56
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  br label %13

13:                                               ; preds = %.lr.ph, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %13 ]
  %14 = load ptr, ptr %7, align 8, !tbaa !15
  %15 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  store ptr %17, ptr %11, align 8, !tbaa !21
  store ptr %1, ptr %12, align 8, !tbaa !23
  %18 = getelementptr inbounds i8, ptr %16, i64 40
  %19 = getelementptr inbounds i8, ptr %16, i64 16
  %20 = load i32, ptr %19, align 8
  %21 = getelementptr inbounds i8, ptr %16, i64 24
  %22 = load ptr, ptr %21, align 8
  %23 = tail call { ptr, ptr } @TypeChecker__resolveType__(ptr noundef %0, i32 %20, ptr %22, i32 noundef 1)
  %24 = extractvalue { ptr, ptr } %23, 0
  %25 = extractvalue { ptr, ptr } %23, 1
  store ptr %24, ptr %18, align 8, !tbaa !16
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %16, i64 48
  store ptr %25, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !16
  tail call void @TypeChecker__checkFieldCycles__(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %16, ptr %24, ptr %25)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr %8, align 8, !tbaa !13
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %13, label %._crit_edge.loopexit, !llvm.loop !24

._crit_edge.loopexit:                             ; preds = %13
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %29 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %5, %2 ]
  %30 = and i32 %29, -786433
  %31 = or disjoint i32 %30, 524288
  store i32 %31, ptr %3, align 4, !tbaa !5
  ret void
}

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

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, !11, i64 28}
!6 = !{!"tag_____Namespace__", !7, i64 0, !8, i64 16, !11, i64 24, !11, i64 28, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !11, i64 104}
!7 = !{!"", !8, i64 0, !11, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!6, !8, i64 56}
!13 = !{!14, !11, i64 8}
!14 = !{!"tag_____List__Ptr__FieldDef______", !8, i64 0, !11, i64 8, !11, i64 12}
!15 = !{!14, !8, i64 0}
!16 = !{!8, !8, i64 0}
!17 = !{!18, !8, i64 0}
!18 = !{!"tag_____FieldDef__", !8, i64 0, !8, i64 8, !19, i64 16, !8, i64 32, !20, i64 40}
!19 = !{!"", !11, i64 0, !8, i64 8}
!20 = !{!"tag_____Tag__", !8, i64 0, !8, i64 8}
!21 = !{!22, !8, i64 40}
!22 = !{!"tag_____TypeCheckerContext__", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104, !8, i64 112, !11, i64 120, !11, i64 124, !8, i64 128, !11, i64 136, !9, i64 140}
!23 = !{!22, !8, i64 48}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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