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

; 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.Node__ = type { i32, ptr }
%struct.tag_____CallExpression__ = type { %struct.Node__, ptr, ptr, ptr, ptr, ptr }
%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: nounwind uwtable
define dso_local zeroext i8 @TypeChecker__checkRemainingArgs__(ptr noundef %0, ptr noundef %1, i32 noundef %2, i8 noundef zeroext %3) #2 {
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.tag_____Tag__, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca %struct.Node__, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i8 %3, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %17 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %17, ptr %10, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %39, %4
  %19 = load i32, ptr %10, align 4, !tbaa !9
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.tag_____CallExpression__, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = getelementptr inbounds %struct.tag_____List__Node____, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = icmp slt i32 %19, %24
  br i1 %25, label %26, label %58

26:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.tag_____CallExpression__, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  store ptr %29, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %30 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %30, ptr %12, align 4, !tbaa !9
  %31 = load i32, ptr %12, align 4, !tbaa !9
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.tag_____List__Node____, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !15
  %35 = icmp ult i32 %31, %34
  br i1 %35, label %39, label %36

36:                                               ; preds = %26
  %37 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  call void %38(i32 noundef -3)
  br label %39

39:                                               ; preds = %36, %26
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.tag_____List__Node____, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = load i32, ptr %12, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds %struct.Node__, ptr %43, i64 %45
  %47 = getelementptr inbounds { i32, ptr }, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8
  %49 = getelementptr inbounds { i32, ptr }, ptr %46, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8
  %51 = call { ptr, ptr } @TypeChecker__checkExpression__(ptr noundef %40, i32 %48, ptr %50)
  %52 = getelementptr inbounds { ptr, ptr }, ptr %13, i32 0, i32 0
  %53 = extractvalue { ptr, ptr } %51, 0
  store ptr %53, ptr %52, align 8
  %54 = getelementptr inbounds { ptr, ptr }, ptr %13, i32 0, i32 1
  %55 = extractvalue { ptr, ptr } %51, 1
  store ptr %55, ptr %54, align 8
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %18, !llvm.loop !18

58:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.tag_____CallExpression__, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !12
  %63 = getelementptr inbounds %struct.tag_____List__Node____, ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 8, !tbaa !15
  %65 = icmp eq i32 %59, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %58
  store i8 1, ptr %5, align 1
  br label %99

67:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %68 = load i8, ptr %9, align 1, !tbaa !11
  %69 = icmp ne i8 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %67
  store i32 1, ptr %14, align 4, !tbaa !9
  br label %72

71:                                               ; preds = %67
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %71, %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %73 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %73, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #3
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.tag_____CallExpression__, ptr %74, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !20
  %77 = getelementptr inbounds %struct.Node__, ptr %16, i32 0, i32 1
  store ptr %76, ptr %77, align 8, !tbaa !21
  %78 = getelementptr inbounds %struct.Node__, ptr %16, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !21
  %80 = icmp ne ptr %79, null
  %81 = zext i1 %80 to i64
  %82 = select i1 %80, i32 21, i32 0
  %83 = getelementptr inbounds %struct.Node__, ptr %16, i32 0, i32 0
  store i32 %82, ptr %83, align 8, !tbaa !22
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = load i32, ptr %15, align 4, !tbaa !9
  %87 = add nsw i32 %85, %86
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.tag_____CallExpression__, ptr %88, i32 0, i32 2
  %90 = load ptr, ptr %89, align 8, !tbaa !12
  %91 = getelementptr inbounds %struct.tag_____List__Node____, ptr %90, i32 0, i32 1
  %92 = load i32, ptr %91, align 8, !tbaa !15
  %93 = load i32, ptr %15, align 4, !tbaa !9
  %94 = add nsw i32 %92, %93
  %95 = getelementptr inbounds { i32, ptr }, ptr %16, i32 0, i32 0
  %96 = load i32, ptr %95, align 8
  %97 = getelementptr inbounds { i32, ptr }, ptr %16, i32 0, i32 1
  %98 = load ptr, ptr %97, align 8
  call void @TypeChecker__badArgs__(ptr noundef %84, i32 %96, ptr %98, i32 noundef %87, i32 noundef %94)
  store i8 0, ptr %5, align 1
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %99

99:                                               ; preds = %72, %66
  %100 = load i8, ptr %5, align 1
  ret i8 %100
}

; Function Attrs: nounwind uwtable
declare dso_local { ptr, ptr } @TypeChecker__checkExpression__(ptr noundef, i32, ptr) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"tag_____CallExpression__", !14, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!14 = !{!"", !10, i64 0, !6, i64 8}
!15 = !{!16, !10, i64 8}
!16 = !{!"tag_____List__Node____", !6, i64 0, !10, i64 8, !10, i64 12}
!17 = !{!16, !6, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!13, !6, i64 16}
!21 = !{!14, !6, i64 8}
!22 = !{!14, !10, 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 }

@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 zeroext range(i8 0, 2) i8 @TypeChecker__checkRemainingArgs__(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i8 noundef zeroext %3) local_unnamed_addr #1 {
  %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, %2
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %10 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  br label %11

11:                                               ; preds = %.lr.ph, %17
  %12 = phi i32 [ %8, %.lr.ph ], [ %28, %17 ]
  %13 = phi ptr [ %6, %.lr.ph ], [ %26, %17 ]
  %.02429 = phi i32 [ %2, %.lr.ph ], [ %25, %17 ]
  %14 = icmp ult i32 %.02429, %12
  br i1 %14, label %17, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %10, align 8, !tbaa !14
  tail call void %16(i32 noundef -3) #2
  br label %17

17:                                               ; preds = %15, %11
  %18 = load ptr, ptr %13, align 8, !tbaa !15
  %19 = zext i32 %.02429 to i64
  %20 = getelementptr inbounds %struct.Node__, ptr %18, i64 %19
  %21 = load i32, ptr %20, align 8
  %22 = getelementptr inbounds i8, ptr %20, i64 8
  %23 = load ptr, ptr %22, align 8
  %24 = tail call { ptr, ptr } @TypeChecker__checkExpression__(ptr noundef %0, i32 %21, ptr %23)
  %25 = add nsw i32 %.02429, 1
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !12
  %29 = icmp slt i32 %25, %28
  br i1 %29, label %11, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %17, %4
  %.lcssa = phi i32 [ %8, %4 ], [ %28, %17 ]
  %30 = icmp eq i32 %.lcssa, %2
  br i1 %30, label %37, label %31

31:                                               ; preds = %._crit_edge
  %.not = icmp ne i8 %3, 0
  %. = zext i1 %.not to i32
  %32 = getelementptr inbounds i8, ptr %1, i64 16
  %33 = load ptr, ptr %32, align 8, !tbaa !18
  %.not28 = icmp eq ptr %33, null
  %34 = select i1 %.not28, i32 0, i32 21
  %35 = add nsw i32 %., %2
  %36 = add nsw i32 %.lcssa, %.
  tail call void @TypeChecker__badArgs__(ptr noundef %0, i32 %34, ptr %33, i32 noundef %35, i32 noundef %36)
  br label %37

37:                                               ; preds = %._crit_edge, %31
  %.0 = phi i8 [ 0, %31 ], [ 1, %._crit_edge ]
  ret i8 %.0
}

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

; Function Attrs: nounwind uwtable
declare dso_local void @TypeChecker__badArgs__(ptr noundef, i32, ptr, i32 noundef, i32 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, !11, i64 24}
!6 = !{!"tag_____CallExpression__", !7, i64 0, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!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 = !{!11, !11, i64 0}
!15 = !{!13, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !11, i64 16}


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