; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_Parser (markBadToken__)

; 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_____Error__ = type { ptr, %struct.tag_____IntRange__, %struct.string__ }
%struct.tag_____IntRange__ = type { i32, i32 }
%struct.string__ = type { ptr, i32 }
%struct.tag_____ParserState__ = type { %struct.string__, i32, ptr, ptr, i32, i32, i32, i32, i32, ptr, %struct.tag_____IntRange__, i32, i32, ptr, i32, ptr, ptr, ptr }
%struct.tag_____Token__ = type { i32, %struct.string__, %struct.tag_____IntRange__, %struct.tag_____IntRange__, i32 }
%struct.tag_____List__Error____ = 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
declare dso_local void @List__add__Error____(ptr noundef, ptr noundef byval(%struct.tag_____Error__) align 8) #2

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @Parser__markBadToken__(ptr noundef %0, ptr noundef %1, ptr %2, i32 %3) #2 {
  %5 = alloca %struct.string__, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct.tag_____Error__, align 8
  %12 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 0
  store ptr %2, ptr %12, align 8
  %13 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 1
  store i32 %3, ptr %13, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.tag_____ParserState__, ptr %14, i32 0, i32 13
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  %18 = zext i1 %17 to i32
  %19 = trunc i32 %18 to i8
  store i8 %19, ptr %8, align 1, !tbaa !14
  %20 = load i8, ptr %8, align 1, !tbaa !14
  %21 = icmp ne i8 %20, 0
  br i1 %21, label %22, label %36

22:                                               ; preds = %4
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.tag_____ParserState__, ptr %23, i32 0, i32 13
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.tag_____Token__, ptr %25, i32 0, i32 3
  %27 = getelementptr inbounds %struct.tag_____IntRange__, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !15
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.tag_____Token__, ptr %29, i32 0, i32 3
  %31 = getelementptr inbounds %struct.tag_____IntRange__, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !17
  %33 = icmp eq i32 %28, %32
  %34 = zext i1 %33 to i32
  %35 = trunc i32 %34 to i8
  store i8 %35, ptr %8, align 1, !tbaa !14
  br label %36

36:                                               ; preds = %22, %4
  %37 = load i8, ptr %8, align 1, !tbaa !14
  %38 = icmp ne i8 %37, 0
  br i1 %38, label %39, label %67

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.tag_____ParserState__, ptr %40, i32 0, i32 9
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  store ptr %42, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tag_____ParserState__, ptr %43, i32 0, i32 14
  %45 = load i32, ptr %44, align 8, !tbaa !19
  store i32 %45, ptr %10, align 4, !tbaa !20
  %46 = load i32, ptr %10, align 4, !tbaa !20
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.tag_____List__Error____, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !21
  %50 = icmp ult i32 %46, %49
  br i1 %50, label %54, label %51

51:                                               ; preds = %39
  %52 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  call void %53(i32 noundef -3)
  br label %54

54:                                               ; preds = %51, %39
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.tag_____Token__, ptr %55, i32 0, i32 2
  %57 = getelementptr inbounds %struct.tag_____IntRange__, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !23
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.tag_____List__Error____, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !24
  %62 = load i32, ptr %10, align 4, !tbaa !20
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds %struct.tag_____Error__, ptr %61, i64 %63
  %65 = getelementptr inbounds %struct.tag_____Error__, ptr %64, i32 0, i32 1
  %66 = getelementptr inbounds %struct.tag_____IntRange__, ptr %65, i32 0, i32 1
  store i32 %58, ptr %66, align 4, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %89

67:                                               ; preds = %36
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.tag_____ParserState__, ptr %68, i32 0, i32 9
  %70 = load ptr, ptr %69, align 8, !tbaa !18
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.tag_____ParserState__, ptr %71, i32 0, i32 2
  %73 = load ptr, ptr %72, align 8, !tbaa !27
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.tag_____Token__, ptr %74, i32 0, i32 2
  %76 = load i64, ptr %75, align 8
  %77 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8
  %79 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 1
  %80 = load i32, ptr %79, align 8
  call void @Error__at__(ptr dead_on_unwind writable sret(%struct.tag_____Error__) align 8 %11, ptr noundef %73, i64 %76, ptr %78, i32 %80)
  call void @List__add__Error____(ptr noundef %70, ptr noundef byval(%struct.tag_____Error__) align 8 %11)
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.tag_____ParserState__, ptr %81, i32 0, i32 9
  %83 = load ptr, ptr %82, align 8, !tbaa !18
  %84 = getelementptr inbounds %struct.tag_____List__Error____, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 8, !tbaa !21
  %86 = sub nsw i32 %85, 1
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.tag_____ParserState__, ptr %87, i32 0, i32 14
  store i32 %86, ptr %88, align 8, !tbaa !19
  br label %89

89:                                               ; preds = %67, %54
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.tag_____ParserState__, ptr %91, i32 0, i32 13
  store ptr %90, ptr %92, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  ret void
}

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, !6, i64 88}
!10 = !{!"tag_____ParserState__", !11, i64 0, !12, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !6, i64 64, !13, i64 72, !12, i64 80, !12, i64 84, !6, i64 88, !12, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!11 = !{!"", !6, i64 0, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"tag_____IntRange__", !12, i64 0, !12, i64 4}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !12, i64 36}
!16 = !{!"tag_____Token__", !12, i64 0, !11, i64 8, !13, i64 24, !13, i64 32, !12, i64 40}
!17 = !{!16, !12, i64 32}
!18 = !{!10, !6, i64 64}
!19 = !{!10, !12, i64 96}
!20 = !{!12, !12, i64 0}
!21 = !{!22, !12, i64 8}
!22 = !{!"tag_____List__Error____", !6, i64 0, !12, i64 8, !12, i64 12}
!23 = !{!16, !12, i64 28}
!24 = !{!22, !6, i64 0}
!25 = !{!26, !12, i64 12}
!26 = !{!"tag_____Error__", !6, i64 0, !13, i64 8, !11, i64 16}
!27 = !{!10, !6, i64 24}


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

@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
declare dso_local void @List__add__Error____(ptr noundef, ptr noundef byval(%struct.tag_____Error__) align 8) local_unnamed_addr #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) local_unnamed_addr #1

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

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %7, i64 36
  %10 = load i32, ptr %9, align 4, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %1, i64 32
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %.not20 = icmp eq i32 %10, %12
  br i1 %.not20, label %13, label %.critedge

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %0, i64 96
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %15, i64 8
  %19 = load i32, ptr %18, align 8, !tbaa !18
  %20 = icmp ult i32 %17, %19
  br i1 %20, label %24, label %21

21:                                               ; preds = %13
  %22 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %23 = load ptr, ptr %22, align 8, !tbaa !20
  tail call void %23(i32 noundef -3) #2
  br label %24

24:                                               ; preds = %21, %13
  %25 = getelementptr inbounds i8, ptr %1, i64 28
  %26 = load i32, ptr %25, align 4, !tbaa !21
  %27 = load ptr, ptr %15, align 8, !tbaa !22
  %28 = zext i32 %17 to i64
  %29 = getelementptr inbounds %struct.tag_____Error__, ptr %27, i64 %28, i32 1, i32 1
  store i32 %26, ptr %29, align 4, !tbaa !23
  br label %41

.critedge:                                        ; preds = %4, %8
  %30 = getelementptr inbounds i8, ptr %0, i64 64
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = getelementptr inbounds i8, ptr %0, i64 24
  %33 = load ptr, ptr %32, align 8, !tbaa !25
  %34 = getelementptr inbounds i8, ptr %1, i64 24
  %35 = load i64, ptr %34, align 8
  call void @Error__at__(ptr dead_on_unwind nonnull writable sret(%struct.tag_____Error__) align 8 %5, ptr noundef %33, i64 %35, ptr %2, i32 %3)
  call void @List__add__Error____(ptr noundef %31, ptr noundef nonnull byval(%struct.tag_____Error__) align 8 %5)
  %36 = load ptr, ptr %30, align 8, !tbaa !16
  %37 = getelementptr inbounds i8, ptr %36, i64 8
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = add nsw i32 %38, -1
  %40 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %39, ptr %40, align 8, !tbaa !17
  br label %41

41:                                               ; preds = %.critedge, %24
  store ptr %1, ptr %6, align 8, !tbaa !5
  ret void
}

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, !8, i64 88}
!6 = !{!"tag_____ParserState__", !7, i64 0, !11, i64 16, !8, i64 24, !8, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !8, i64 64, !12, i64 72, !11, i64 80, !11, i64 84, !8, i64 88, !11, i64 96, !8, i64 104, !8, i64 112, !8, i64 120}
!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 = !{!"tag_____IntRange__", !11, i64 0, !11, i64 4}
!13 = !{!14, !11, i64 36}
!14 = !{!"tag_____Token__", !11, i64 0, !7, i64 8, !12, i64 24, !12, i64 32, !11, i64 40}
!15 = !{!14, !11, i64 32}
!16 = !{!6, !8, i64 64}
!17 = !{!6, !11, i64 96}
!18 = !{!19, !11, i64 8}
!19 = !{!"tag_____List__Error____", !8, i64 0, !11, i64 8, !11, i64 12}
!20 = !{!8, !8, i64 0}
!21 = !{!14, !11, i64 28}
!22 = !{!19, !8, i64 0}
!23 = !{!24, !11, i64 12}
!24 = !{!"tag_____Error__", !8, i64 0, !12, i64 8, !7, i64 16}
!25 = !{!6, !8, i64 24}


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