; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_TypeCheckerFirstPass (checkIndexableAttribute__)

; 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.string__ = type { ptr, i32 }
%struct.tag_____Error__ = type { ptr, %struct.tag_____IntRange__, %struct.string__ }
%struct.tag_____IntRange__ = type { i32, i32 }
%struct.tag_____Namespace__ = type { %struct.string__, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%struct.tag_____TypeCheckerContext__ = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i8 }
%struct.tag_____Attribute__ = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.tag_____Token__ = type { i32, %struct.string__, %struct.tag_____IntRange__, %struct.tag_____IntRange__, i32 }
%struct.tag_____List__Ptr__Namespace______ = type { ptr, i32, i32 }

@mu_____string102 = external dso_local global %struct.string__, align 8
@mu_____string108 = external dso_local global %struct.string__, 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @List__add__Error____(ptr noundef, ptr noundef byval(%struct.tag_____Error__) align 8) #1

; Function Attrs: nounwind uwtable
declare dso_local void @Error__at__(ptr dead_on_unwind noalias writable sret(%struct.tag_____Error__) align 8, ptr noundef, i64, ptr, i32) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @TypeCheckerFirstPass__checkIndexableAttribute__(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.tag_____Error__, align 8
  %8 = alloca i8, align 1
  %9 = alloca %struct.tag_____Error__, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.tag_____Namespace__, ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = icmp ne i32 %13, 1
  br i1 %14, label %15, label %29

15:                                               ; preds = %3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %19, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.tag_____Attribute__, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds %struct.tag_____Token__, ptr %24, i32 0, i32 2
  %26 = load i64, ptr %25, align 8
  %27 = load ptr, ptr @mu_____string102, align 8
  %28 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string102, i32 0, i32 1), align 8
  call void @Error__at__(ptr dead_on_unwind writable sret(%struct.tag_____Error__) align 8 %7, ptr noundef %21, i64 %26, ptr %27, i32 %28)
  call void @List__add__Error____(ptr noundef %18, ptr noundef byval(%struct.tag_____Error__) align 8 %7)
  br label %85

29:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.tag_____Namespace__, ptr %30, i32 0, i32 9
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  %33 = icmp eq ptr %32, null
  %34 = zext i1 %33 to i32
  %35 = trunc i32 %34 to i8
  store i8 %35, ptr %8, align 1, !tbaa !19
  %36 = load i8, ptr %8, align 1, !tbaa !19
  %37 = icmp ne i8 %36, 0
  br i1 %37, label %47, label %38

38:                                               ; preds = %29
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.tag_____Namespace__, ptr %39, i32 0, i32 9
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  %42 = getelementptr inbounds %struct.tag_____List__Ptr__Namespace______, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 8, !tbaa !20
  %44 = icmp ne i32 %43, 1
  %45 = zext i1 %44 to i32
  %46 = trunc i32 %45 to i8
  store i8 %46, ptr %8, align 1, !tbaa !19
  br label %47

47:                                               ; preds = %38, %29
  %48 = load i8, ptr %8, align 1, !tbaa !19
  %49 = icmp ne i8 %48, 0
  br i1 %49, label %50, label %64

50:                                               ; preds = %47
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %54, i32 0, i32 5
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.tag_____Attribute__, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !16
  %60 = getelementptr inbounds %struct.tag_____Token__, ptr %59, i32 0, i32 2
  %61 = load i64, ptr %60, align 8
  %62 = load ptr, ptr @mu_____string108, align 8
  %63 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string108, i32 0, i32 1), align 8
  call void @Error__at__(ptr dead_on_unwind writable sret(%struct.tag_____Error__) align 8 %9, ptr noundef %56, i64 %61, ptr %62, i32 %63)
  call void @List__add__Error____(ptr noundef %53, ptr noundef byval(%struct.tag_____Error__) align 8 %9)
  store i32 1, ptr %10, align 4
  br label %83

64:                                               ; preds = %47
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.tag_____Namespace__, ptr %65, i32 0, i32 3
  %67 = load i32, ptr %66, align 4, !tbaa !22
  %68 = and i32 %67, 1024
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %73

70:                                               ; preds = %64
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  call void @TypeCheckerFirstPass__redundantAttribute__(ptr noundef %71, ptr noundef %72)
  store i32 1, ptr %10, align 4
  br label %83

73:                                               ; preds = %64
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = call zeroext i8 @TypeCheckerFirstPass__checkAttributeArgCount__(ptr noundef %74, ptr noundef %75, i32 noundef 0)
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.tag_____Namespace__, ptr %77, i32 0, i32 3
  %79 = load i32, ptr %78, align 4, !tbaa !22
  %80 = or i32 %79, 1024
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.tag_____Namespace__, ptr %81, i32 0, i32 3
  store i32 %80, ptr %82, align 4, !tbaa !22
  store i32 0, ptr %10, align 4
  br label %83

83:                                               ; preds = %73, %70, %50
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  %84 = load i32, ptr %10, align 4
  switch i32 %84, label %86 [
    i32 0, label %85
    i32 1, label %85
  ]

85:                                               ; preds = %83, %83, %15
  ret void

86:                                               ; preds = %83
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 24}
!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 = !{!14, !6, i64 16}
!14 = !{!"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}
!15 = !{!14, !6, i64 40}
!16 = !{!17, !6, i64 8}
!17 = !{!"tag_____Attribute__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!18 = !{!10, !6, i64 72}
!19 = !{!7, !7, i64 0}
!20 = !{!21, !12, i64 8}
!21 = !{!"tag_____List__Ptr__Namespace______", !6, i64 0, !12, i64 8, !12, i64 12}
!22 = !{!10, !12, i64 28}


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

@mu_____string102 = external dso_local local_unnamed_addr global %struct.string__, align 8
@mu_____string108 = external dso_local local_unnamed_addr global %struct.string__, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @List__add__Error____(ptr noundef, ptr noundef byval(%struct.tag_____Error__) align 8) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @TypeCheckerFirstPass__checkIndexableAttribute__(ptr noundef %0, ptr nocapture noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.tag_____Error__, align 8
  %5 = alloca %struct.tag_____Error__, align 8
  %6 = getelementptr inbounds i8, ptr %1, i64 24
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i32 %7, 1
  br i1 %.not, label %19, label %8

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %2, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %14, i64 24
  %16 = load i64, ptr %15, align 8
  %17 = load ptr, ptr @mu_____string102, align 8
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string102, i64 8), align 8
  call void @Error__at__(ptr dead_on_unwind nonnull writable sret(%struct.tag_____Error__) align 8 %4, ptr noundef %12, i64 %16, ptr %17, i32 %18)
  call void @List__add__Error____(ptr noundef %10, ptr noundef nonnull byval(%struct.tag_____Error__) align 8 %4)
  br label %45

19:                                               ; preds = %3
  %20 = getelementptr inbounds i8, ptr %1, i64 72
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = icmp eq ptr %21, null
  br i1 %22, label %.critedge, label %23

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %21, i64 8
  %25 = load i32, ptr %24, align 8, !tbaa !18
  %.not19 = icmp eq i32 %25, 1
  br i1 %.not19, label %36, label %.critedge

.critedge:                                        ; preds = %19, %23
  %26 = getelementptr inbounds i8, ptr %0, i64 16
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = getelementptr inbounds i8, ptr %2, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %31, i64 24
  %33 = load i64, ptr %32, align 8
  %34 = load ptr, ptr @mu_____string108, align 8
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string108, i64 8), align 8
  call void @Error__at__(ptr dead_on_unwind nonnull writable sret(%struct.tag_____Error__) align 8 %5, ptr noundef %29, i64 %33, ptr %34, i32 %35)
  call void @List__add__Error____(ptr noundef %27, ptr noundef nonnull byval(%struct.tag_____Error__) align 8 %5)
  br label %45

36:                                               ; preds = %23
  %37 = getelementptr inbounds i8, ptr %1, i64 28
  %38 = load i32, ptr %37, align 4, !tbaa !20
  %39 = and i32 %38, 1024
  %.not20 = icmp eq i32 %39, 0
  br i1 %.not20, label %41, label %40

40:                                               ; preds = %36
  tail call void @TypeCheckerFirstPass__redundantAttribute__(ptr noundef %0, ptr noundef %2)
  br label %45

41:                                               ; preds = %36
  %42 = tail call zeroext i8 @TypeCheckerFirstPass__checkAttributeArgCount__(ptr noundef %0, ptr noundef %2, i32 noundef 0)
  %43 = load i32, ptr %37, align 4, !tbaa !20
  %44 = or i32 %43, 1024
  store i32 %44, ptr %37, align 4, !tbaa !20
  br label %45

45:                                               ; preds = %.critedge, %40, %41, %8
  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_____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 = !{!13, !8, i64 16}
!13 = !{!"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}
!14 = !{!13, !8, i64 40}
!15 = !{!16, !8, i64 8}
!16 = !{!"tag_____Attribute__", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40}
!17 = !{!6, !8, i64 72}
!18 = !{!19, !11, i64 8}
!19 = !{!"tag_____List__Ptr__Namespace______", !8, i64 0, !11, i64 8, !11, i64 12}
!20 = !{!6, !11, i64 28}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass