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

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

@top_____currentAllocator__ = external dso_local thread_local global %struct.tag_____IAllocator__, align 8
@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: 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 { i32, ptr } @Parser__tryParseType__(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local ptr @Parser__parseTaggedPointerOptionTail__(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.Node__, align 8
  %6 = alloca %struct.Node__, align 8
  %7 = alloca %struct.Node__, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.Node__, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %struct.tag_____TaggedPointerOptionDef__, align 8
  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 16, ptr %5) #5
  %13 = getelementptr inbounds %struct.Node__, ptr %5, i32 0, i32 1
  store ptr null, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.Node__, ptr %5, i32 0, i32 0
  store i32 0, ptr %14, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !13
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %25

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call { i32, ptr } @Parser__parseTypeTail__(ptr noundef %18, ptr noundef %19)
  %21 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  %22 = extractvalue { i32, ptr } %20, 0
  store i32 %22, ptr %21, align 8
  %23 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  %24 = extractvalue { i32, ptr } %20, 1
  store ptr %24, ptr %23, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  br label %52

25:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.tag_____ParserState__, ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  store ptr %28, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.tag_____ParserState__, ptr %29, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds %struct.tag_____Token__, ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 8, !tbaa !19
  store i32 %33, ptr %9, align 4, !tbaa !14
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.tag_____Token__, ptr %34, i32 0, i32 4
  store i32 2147483647, ptr %35, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #5
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = call { i32, ptr } @Parser__tryParseType__(ptr noundef %36)
  %38 = getelementptr inbounds { i32, ptr }, ptr %10, i32 0, i32 0
  %39 = extractvalue { i32, ptr } %37, 0
  store i32 %39, ptr %38, align 8
  %40 = getelementptr inbounds { i32, ptr }, ptr %10, i32 0, i32 1
  %41 = extractvalue { i32, ptr } %37, 1
  store ptr %41, ptr %40, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  %42 = load i32, ptr %9, align 4, !tbaa !14
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tag_____Token__, ptr %43, i32 0, i32 4
  store i32 %42, ptr %44, align 8, !tbaa !19
  %45 = getelementptr inbounds %struct.Node__, ptr %6, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = icmp ne ptr %46, null
  br i1 %47, label %51, label %48

48:                                               ; preds = %25
  %49 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  call void %50(i32 noundef -2)
  br label %51

51:                                               ; preds = %48, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %52

52:                                               ; preds = %51, %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %53 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____currentAllocator__)
  %54 = getelementptr inbounds %struct.tag_____IAllocator__, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !21
  %56 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____currentAllocator__)
  %57 = getelementptr inbounds %struct.tag_____IAllocator__, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !23
  %59 = call ptr %55(ptr noundef %58, i64 noundef 16)
  store ptr %59, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 16, i1 false)
  %60 = getelementptr inbounds %struct.tag_____TaggedPointerOptionDef__, ptr %12, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %60, ptr align 8 %6, i64 16, i1 false), !tbaa.struct !13
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %61, ptr align 8 %12, i64 16, i1 false), !tbaa.struct !13
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #5
  ret ptr %62
}

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

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

@top_____currentAllocator__ = external dso_local thread_local local_unnamed_addr global %struct.tag_____IAllocator__, align 8
@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 { i32, ptr } @Parser__tryParseType__(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @Parser__parseTaggedPointerOptionTail__(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %6, label %3

3:                                                ; preds = %2
  %4 = tail call { i32, ptr } @Parser__parseTypeTail__(ptr noundef %0, ptr noundef nonnull %1)
  %5 = extractvalue { i32, ptr } %4, 1
  br label %16

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 40
  %10 = load i32, ptr %9, align 8, !tbaa !13
  store i32 2147483647, ptr %9, align 8, !tbaa !13
  %11 = tail call { i32, ptr } @Parser__tryParseType__(ptr noundef %0)
  %12 = extractvalue { i32, ptr } %11, 1
  store i32 %10, ptr %9, align 8, !tbaa !13
  %.not20 = icmp eq ptr %12, null
  br i1 %.not20, label %13, label %16

13:                                               ; preds = %6
  %14 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  tail call void %15(i32 noundef -2) #2
  br label %16

16:                                               ; preds = %6, %13, %3
  %.pn = phi { i32, ptr } [ %4, %3 ], [ %11, %13 ], [ %11, %6 ]
  %.sroa.8.0 = phi ptr [ %5, %3 ], [ null, %13 ], [ %12, %6 ]
  %.sroa.09.0 = extractvalue { i32, ptr } %.pn, 0
  %17 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____currentAllocator__)
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = load ptr, ptr %17, align 8, !tbaa !18
  %21 = tail call ptr %19(ptr noundef %20, i64 noundef 16) #2
  store i32 %.sroa.09.0, ptr %21, align 8, !tbaa !19
  %.sroa.0.sroa.6.0..0..sroa_idx = getelementptr inbounds i8, ptr %21, i64 8
  store ptr %.sroa.8.0, ptr %.sroa.0.sroa.6.0..0..sroa_idx, align 8, !tbaa !15
  ret ptr %21
}

; Function Attrs: nounwind uwtable
declare dso_local { i32, ptr } @Parser__parseTypeTail__(ptr noundef, ptr 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, !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 = !{!8, !8, 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 = !{!11, !11, i64 0}


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