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

; 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_____IAllocator__ = type { ptr, ptr, ptr, ptr }
%struct.tag_____List__Ptr__Token______ = type { ptr, i32, 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_____IntRange__ = type { i32, i32 }
%struct.tag_____Token__ = type { i32, %struct.string__, %struct.tag_____IntRange__, %struct.tag_____IntRange__, i32 }
%struct.tag_____ForEachStatement__ = type { ptr, ptr, ptr, ptr, ptr, %struct.Node__, ptr, ptr }
%struct.Node__ = type { i32, ptr }

@mu_____string311 = external dso_local global %struct.string__, align 8
@top_____currentAllocator__ = external dso_local thread_local global %struct.tag_____IAllocator__, 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: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @Parser__parseBlockStatement__(ptr noundef) #4

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

20:                                               ; preds = %2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.tag_____ParserState__, ptr %21, i32 0, i32 3
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.tag_____Token__, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !17
  %26 = icmp ne i32 %25, 7
  %27 = zext i1 %26 to i32
  %28 = trunc i32 %27 to i8
  store i8 %28, ptr %5, align 1, !tbaa !16
  br label %29

29:                                               ; preds = %20, %2
  %30 = load i8, ptr %5, align 1, !tbaa !16
  %31 = icmp ne i8 %30, 0
  br i1 %31, label %32, label %83

32:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %33 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____currentAllocator__)
  %34 = getelementptr inbounds %struct.tag_____IAllocator__, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  %36 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____currentAllocator__)
  %37 = getelementptr inbounds %struct.tag_____IAllocator__, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = call ptr %35(ptr noundef %38, i64 noundef 16)
  store ptr %39, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 16, i1 false)
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %40, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !21
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.tag_____ForEachStatement__, ptr %42, i32 0, i32 6
  store ptr %41, ptr %43, align 8, !tbaa !23
  br label %44

44:                                               ; preds = %81, %32
  br label %45

45:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.tag_____ParserState__, ptr %46, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.tag_____Token__, ptr %48, i32 0, i32 4
  %50 = load i32, ptr %49, align 8, !tbaa !14
  %51 = icmp eq i32 %50, 2147483647
  %52 = zext i1 %51 to i32
  %53 = trunc i32 %52 to i8
  store i8 %53, ptr %8, align 1, !tbaa !16
  %54 = load i8, ptr %8, align 1, !tbaa !16
  %55 = icmp ne i8 %54, 0
  br i1 %55, label %56, label %65

56:                                               ; preds = %45
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.tag_____ParserState__, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.tag_____Token__, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !17
  %62 = icmp ne i32 %61, 7
  %63 = zext i1 %62 to i32
  %64 = trunc i32 %63 to i8
  store i8 %64, ptr %8, align 1, !tbaa !16
  br label %65

65:                                               ; preds = %56, %45
  %66 = load i8, ptr %8, align 1, !tbaa !16
  %67 = icmp ne i8 %66, 0
  br i1 %67, label %69, label %68

68:                                               ; preds = %65
  store i32 3, ptr %9, align 4
  br label %79

69:                                               ; preds = %65
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.tag_____ForEachStatement__, ptr %70, i32 0, i32 6
  %72 = load ptr, ptr %71, align 8, !tbaa !23
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.tag_____ParserState__, ptr %73, i32 0, i32 3
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  call void @List__add__Ptr__Token______(ptr noundef %72, ptr noundef %75)
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = load ptr, ptr @mu_____string311, align 8
  %78 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string311, i32 0, i32 1), align 8
  call void @Parser__badToken__(ptr noundef %76, ptr %77, i32 %78)
  store i32 0, ptr %9, align 4
  br label %79

79:                                               ; preds = %69, %68
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  %80 = load i32, ptr %9, align 4
  switch i32 %80, label %89 [
    i32 0, label %81
    i32 3, label %82
  ]

81:                                               ; preds = %79
  br label %44

82:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %83

83:                                               ; preds = %82, %29
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = call ptr @Parser__parseBlockStatement__(ptr noundef %84)
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.tag_____ForEachStatement__, ptr %86, i32 0, i32 7
  store ptr %85, ptr %87, align 8, !tbaa !26
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #5
  ret ptr %88

89:                                               ; preds = %79
  unreachable
}

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: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 32}
!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 = !{!15, !12, i64 40}
!15 = !{!"tag_____Token__", !12, i64 0, !11, i64 8, !13, i64 24, !13, i64 32, !12, i64 40}
!16 = !{!7, !7, i64 0}
!17 = !{!15, !12, i64 0}
!18 = !{!19, !6, i64 8}
!19 = !{!"tag_____IAllocator__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!19, !6, i64 0}
!21 = !{i64 0, i64 8, !5, i64 8, i64 4, !22, i64 12, i64 4, !22}
!22 = !{!12, !12, i64 0}
!23 = !{!24, !6, i64 56}
!24 = !{!"tag_____ForEachStatement__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !25, i64 40, !6, i64 56, !6, i64 64}
!25 = !{!"", !12, i64 0, !6, i64 8}
!26 = !{!24, !6, i64 64}


; 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_____IAllocator__ = type { ptr, ptr, ptr, ptr }

@mu_____string311 = external dso_local local_unnamed_addr global %struct.string__, align 8
@top_____currentAllocator__ = external dso_local thread_local local_unnamed_addr global %struct.tag_____IAllocator__, 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @Parser__parseBlockStatement__(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @Parser__parseForEachStatementTail__(ptr noundef %0, ptr noundef returned %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 40
  %6 = load i32, ptr %5, align 8, !tbaa !13
  %7 = icmp eq i32 %6, 2147483647
  br i1 %7, label %8, label %.critedge

8:                                                ; preds = %2
  %9 = load i32, ptr %4, align 8, !tbaa !15
  %.not = icmp eq i32 %9, 7
  br i1 %.not, label %.critedge, label %10

10:                                               ; preds = %8
  %11 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____currentAllocator__)
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %14 = load ptr, ptr %11, align 8, !tbaa !18
  %15 = tail call ptr %13(ptr noundef %14, i64 noundef 16) #3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %15, i8 0, i64 16, i1 false)
  %16 = getelementptr inbounds i8, ptr %1, i64 56
  store ptr %15, ptr %16, align 8, !tbaa !19
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 40
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = icmp eq i32 %19, 2147483647
  br i1 %20, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %10, %23
  %21 = phi ptr [ %27, %23 ], [ %17, %10 ]
  %22 = load i32, ptr %21, align 8, !tbaa !15
  %.not27 = icmp eq i32 %22, 7
  br i1 %.not27, label %.critedge, label %23

23:                                               ; preds = %.lr.ph
  %24 = load ptr, ptr %16, align 8, !tbaa !19
  tail call void @List__add__Ptr__Token______(ptr noundef %24, ptr noundef nonnull %21)
  %25 = load ptr, ptr @mu_____string311, align 8
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string311, i64 8), align 8
  tail call void @Parser__badToken__(ptr noundef nonnull %0, ptr %25, i32 %26)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 40
  %29 = load i32, ptr %28, align 8, !tbaa !13
  %30 = icmp eq i32 %29, 2147483647
  br i1 %30, label %.lr.ph, label %.critedge

.critedge:                                        ; preds = %23, %.lr.ph, %10, %2, %8
  %31 = tail call ptr @Parser__parseBlockStatement__(ptr noundef nonnull %0)
  %32 = getelementptr inbounds i8, ptr %1, i64 64
  store ptr %31, ptr %32, align 8, !tbaa !22
  ret ptr %1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !8, i64 32}
!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 40}
!14 = !{!"tag_____Token__", !11, i64 0, !7, i64 8, !12, i64 24, !12, i64 32, !11, i64 40}
!15 = !{!14, !11, i64 0}
!16 = !{!17, !8, i64 8}
!17 = !{!"tag_____IAllocator__", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!18 = !{!17, !8, i64 0}
!19 = !{!20, !8, i64 56}
!20 = !{!"tag_____ForEachStatement__", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !21, i64 40, !8, i64 56, !8, i64 64}
!21 = !{!"", !11, i64 0, !8, i64 8}
!22 = !{!20, !8, i64 64}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass