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

; 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_____Tag__ = type { ptr, ptr }
%struct.tag_____TypeArgsExpression__ = type { %struct.Node__, ptr, ptr, ptr, ptr }
%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 { ptr, ptr } @TypeChecker__resolveType__(ptr noundef, i32, ptr, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkNoTypeArgs__(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 %struct.Node__, align 8
  %8 = alloca %struct.tag_____Tag__, align 8
  %9 = alloca %struct.Node__, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %63

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.tag_____TypeArgsExpression__, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %16, 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 !13
  br label %17

17:                                               ; preds = %23, %13
  %18 = load i32, ptr %6, align 4, !tbaa !13
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.tag_____List__Node____, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !14
  %22 = icmp slt i32 %18, %21
  br i1 %22, label %23, label %42

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.tag_____List__Node____, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = load i32, ptr %6, align 4, !tbaa !13
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct.Node__, ptr %26, i64 %28
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %29, i64 16, i1 false), !tbaa.struct !17
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  %32 = load i32, ptr %31, align 8
  %33 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8
  %35 = call { ptr, ptr } @TypeChecker__resolveType__(ptr noundef %30, i32 %32, ptr %34, i32 noundef 0)
  %36 = getelementptr inbounds { ptr, ptr }, ptr %8, i32 0, i32 0
  %37 = extractvalue { ptr, ptr } %35, 0
  store ptr %37, ptr %36, align 8
  %38 = getelementptr inbounds { ptr, ptr }, ptr %8, i32 0, i32 1
  %39 = extractvalue { ptr, ptr } %35, 1
  store ptr %39, ptr %38, align 8
  %40 = load i32, ptr %6, align 4, !tbaa !13
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %6, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  br label %17, !llvm.loop !18

42:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tag_____TypeArgsExpression__, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 1
  store ptr %45, ptr %46, align 8, !tbaa !21
  %47 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !21
  %49 = icmp ne ptr %48, null
  %50 = zext i1 %49 to i64
  %51 = select i1 %49, i32 21, i32 0
  %52 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 0
  store i32 %51, ptr %52, align 8, !tbaa !22
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.tag_____TypeArgsExpression__, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.tag_____List__Node____, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !14
  %59 = getelementptr inbounds { i32, ptr }, ptr %9, i32 0, i32 0
  %60 = load i32, ptr %59, align 8
  %61 = getelementptr inbounds { i32, ptr }, ptr %9, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8
  call void @TypeChecker__badTypeArgs__(ptr noundef %53, i32 %60, ptr %62, i32 noundef 0, i32 noundef %58)
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  br label %63

63:                                               ; preds = %42, %12
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @TypeChecker__badTypeArgs__(ptr noundef, i32, ptr, i32 noundef, i32 noundef) #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, !6, i64 24}
!10 = !{!"tag_____TypeArgsExpression__", !11, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"", !12, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!15, !12, i64 8}
!15 = !{!"tag_____List__Node____", !6, i64 0, !12, i64 8, !12, i64 12}
!16 = !{!15, !6, i64 0}
!17 = !{i64 0, i64 4, !13, i64 8, i64 8, !5}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!10, !6, i64 16}
!21 = !{!11, !6, i64 8}
!22 = !{!11, !12, i64 0}


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

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkNoTypeArgs__(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %1, null
  br i1 %3, label %20, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !12
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %4 ]
  %10 = load ptr, ptr %6, align 8, !tbaa !14
  %11 = getelementptr inbounds %struct.Node__, ptr %10, i64 %indvars.iv
  %.sroa.04.0.copyload = load i32, ptr %11, align 8, !tbaa !15
  %.sroa.46.0..sroa_idx = getelementptr inbounds i8, ptr %11, i64 8
  %.sroa.46.0.copyload = load ptr, ptr %.sroa.46.0..sroa_idx, align 8, !tbaa !16
  %12 = tail call { ptr, ptr } @TypeChecker__resolveType__(ptr noundef %0, i32 %.sroa.04.0.copyload, ptr %.sroa.46.0.copyload, i32 noundef 0)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr %7, align 8, !tbaa !12
  %14 = sext i32 %13 to i64
  %15 = icmp slt i64 %indvars.iv.next, %14
  br i1 %15, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !17

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.pre, i64 8
  %.pre19 = load i32, ptr %.phi.trans.insert, align 8, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %4
  %16 = phi i32 [ %.pre19, %._crit_edge.loopexit ], [ %8, %4 ]
  %17 = getelementptr inbounds i8, ptr %1, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !19
  %.not = icmp eq ptr %18, null
  %19 = select i1 %.not, i32 0, i32 21
  tail call void @TypeChecker__badTypeArgs__(ptr noundef %0, i32 %19, ptr %18, i32 noundef 0, i32 noundef %16)
  br label %20

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

; Function Attrs: nounwind uwtable
declare dso_local void @TypeChecker__badTypeArgs__(ptr noundef, i32, ptr, i32 noundef, i32 noundef) 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 24}
!6 = !{!"tag_____TypeArgsExpression__", !7, i64 0, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!7 = !{!"", !8, i64 0, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!13, !8, i64 8}
!13 = !{!"tag_____List__Node____", !11, i64 0, !8, i64 8, !8, i64 12}
!14 = !{!13, !11, i64 0}
!15 = !{!8, !8, i64 0}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !11, i64 16}


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