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

; 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_____ResolveResult__ = type { %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.Node__, i8 }
%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: 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__recordTag__(ptr noundef, i32, ptr, ptr, ptr) #3

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @TypeChecker__checkRemainingArgs__(ptr noundef, ptr noundef, i32 noundef, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare dso_local void @TypeChecker__resolveIndex__(ptr dead_on_unwind noalias writable sret(%struct.tag_____ResolveResult__) align 8, ptr noundef, i32, ptr, i32, ptr) #3

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__resolveUncheckedIndex__(ptr dead_on_unwind noalias writable sret(%struct.tag_____ResolveResult__) align 8 %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.Node__, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.Node__, align 8
  %10 = alloca %struct.Node__, align 8
  %11 = alloca %struct.Node__, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %struct.Node__, align 8
  %15 = alloca %struct.Node__, align 8
  %16 = alloca %struct.Node__, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.tag_____CallExpression__, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.tag_____List__Node____, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %42

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

32:                                               ; preds = %23
  %33 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  call void %34(i32 noundef -3)
  br label %35

35:                                               ; preds = %32, %23
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.tag_____List__Node____, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  %39 = load i32, ptr %8, align 4, !tbaa !15
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds %struct.Node__, ptr %38, i64 %40
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %41, i64 16, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %45

42:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  %43 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 1
  store ptr null, ptr %43, align 8, !tbaa !18
  %44 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 0
  store i32 0, ptr %44, align 8, !tbaa !19
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  br label %45

45:                                               ; preds = %42, %35
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %6, i64 16, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.tag_____CallExpression__, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.tag_____List__Node____, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = icmp sgt i32 %50, 1
  br i1 %51, label %52, label %71

52:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.tag_____CallExpression__, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  store ptr %55, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 1, ptr %13, align 4, !tbaa !15
  %56 = load i32, ptr %13, align 4, !tbaa !15
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.tag_____List__Node____, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 8, !tbaa !13
  %60 = icmp ult i32 %56, %59
  br i1 %60, label %64, label %61

61:                                               ; preds = %52
  %62 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  call void %63(i32 noundef -3)
  br label %64

64:                                               ; preds = %61, %52
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.tag_____List__Node____, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !16
  %68 = load i32, ptr %13, align 4, !tbaa !15
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds %struct.Node__, ptr %67, i64 %69
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %70, i64 16, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %74

71:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  %72 = getelementptr inbounds %struct.Node__, ptr %14, i32 0, i32 1
  store ptr null, ptr %72, align 8, !tbaa !18
  %73 = getelementptr inbounds %struct.Node__, ptr %14, i32 0, i32 0
  store i32 0, ptr %73, align 8, !tbaa !19
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %14, i64 16, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  br label %74

74:                                               ; preds = %71, %64
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %11, i64 16, i1 false), !tbaa.struct !17
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds { i32, ptr }, ptr %10, i32 0, i32 0
  %77 = load i32, ptr %76, align 8
  %78 = getelementptr inbounds { i32, ptr }, ptr %10, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8
  %80 = getelementptr inbounds { i32, ptr }, ptr %15, i32 0, i32 0
  %81 = load i32, ptr %80, align 8
  %82 = getelementptr inbounds { i32, ptr }, ptr %15, i32 0, i32 1
  %83 = load ptr, ptr %82, align 8
  call void @TypeChecker__resolveIndex__(ptr dead_on_unwind writable sret(%struct.tag_____ResolveResult__) align 8 %0, ptr noundef %75, i32 %77, ptr %79, i32 %81, ptr %83)
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = call zeroext i8 @TypeChecker__checkRemainingArgs__(ptr noundef %84, ptr noundef %85, i32 noundef 2, i8 noundef zeroext 0)
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.Node__, ptr %16, i32 0, i32 1
  store ptr %87, ptr %88, align 8, !tbaa !18
  %89 = getelementptr inbounds %struct.Node__, ptr %16, i32 0, i32 1
  %90 = load ptr, ptr %89, align 8, !tbaa !18
  %91 = icmp ne ptr %90, null
  %92 = zext i1 %91 to i64
  %93 = select i1 %91, i32 14, i32 0
  %94 = getelementptr inbounds %struct.Node__, ptr %16, i32 0, i32 0
  store i32 %93, ptr %94, align 8, !tbaa !19
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.tag_____ResolveResult__, ptr %0, i32 0, i32 0
  %97 = getelementptr inbounds { i32, ptr }, ptr %16, i32 0, i32 0
  %98 = load i32, ptr %97, align 8
  %99 = getelementptr inbounds { i32, ptr }, ptr %16, i32 0, i32 1
  %100 = load ptr, ptr %99, align 8
  %101 = getelementptr inbounds { ptr, ptr }, ptr %96, i32 0, i32 0
  %102 = load ptr, ptr %101, align 8
  %103 = getelementptr inbounds { ptr, ptr }, ptr %96, i32 0, i32 1
  %104 = load ptr, ptr %103, align 8
  call void @TypeChecker__recordTag__(ptr noundef %95, i32 %98, ptr %100, ptr %102, ptr %104)
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  ret void
}

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 24}
!10 = !{!"tag_____CallExpression__", !11, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"", !12, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"tag_____List__Node____", !6, i64 0, !12, i64 8, !12, i64 12}
!15 = !{!12, !12, i64 0}
!16 = !{!14, !6, i64 0}
!17 = !{i64 0, i64 4, !15, i64 8, i64 8, !5}
!18 = !{!11, !6, i64 8}
!19 = !{!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.tag_____ResolveResult__ = type { %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.Node__, i8 }
%struct.tag_____Tag__ = type { ptr, ptr }
%struct.Node__ = type { i32, ptr }

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @TypeChecker__checkRemainingArgs__(ptr noundef, ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @TypeChecker__resolveIndex__(ptr dead_on_unwind noalias writable sret(%struct.tag_____ResolveResult__) align 8, ptr noundef, i32, ptr, i32, ptr) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__resolveUncheckedIndex__(ptr dead_on_unwind noalias writable sret(%struct.tag_____ResolveResult__) align 8 %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %2, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %9, label %.thread

9:                                                ; preds = %3
  %10 = load ptr, ptr %5, align 8, !tbaa !14
  %.sroa.022.0.copyload = load i32, ptr %10, align 8, !tbaa !15
  %.sroa.724.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 8
  %.sroa.724.0.copyload = load ptr, ptr %.sroa.724.0..sroa_idx, align 8, !tbaa !16
  %.not = icmp eq i32 %7, 1
  br i1 %.not, label %.thread, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %10, i64 16
  %.sroa.011.0.copyload = load i32, ptr %12, align 8, !tbaa !15
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 24
  %.sroa.7.0.copyload = load ptr, ptr %.sroa.7.0..sroa_idx, align 8, !tbaa !16
  br label %.thread

.thread:                                          ; preds = %3, %9, %11
  %.sroa.724.037 = phi ptr [ %.sroa.724.0.copyload, %11 ], [ %.sroa.724.0.copyload, %9 ], [ null, %3 ]
  %.sroa.022.036 = phi i32 [ %.sroa.022.0.copyload, %11 ], [ %.sroa.022.0.copyload, %9 ], [ 0, %3 ]
  %.sroa.011.0 = phi i32 [ %.sroa.011.0.copyload, %11 ], [ 0, %9 ], [ 0, %3 ]
  %.sroa.7.0 = phi ptr [ %.sroa.7.0.copyload, %11 ], [ null, %9 ], [ null, %3 ]
  tail call void @TypeChecker__resolveIndex__(ptr dead_on_unwind writable sret(%struct.tag_____ResolveResult__) align 8 %0, ptr noundef %1, i32 %.sroa.022.036, ptr %.sroa.724.037, i32 %.sroa.011.0, ptr %.sroa.7.0)
  %13 = tail call zeroext i8 @TypeChecker__checkRemainingArgs__(ptr noundef %1, ptr noundef nonnull %2, i32 noundef 2, i8 noundef zeroext 0)
  %14 = load ptr, ptr %0, align 8
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8
  tail call void @TypeChecker__recordTag__(ptr noundef %1, i32 14, ptr nonnull %2, ptr %14, ptr %16)
  ret void
}

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_____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 = !{!13, !11, i64 0}
!15 = !{!8, !8, i64 0}
!16 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass