; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_AstPrinter (printDescTokenList__)

; 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_____StringBuilder__ = type { ptr, i32, i32 }
%struct.tag_____List__Ptr__Token______ = type { ptr, i32, i32 }

@__const.AstPrinter__printDescTokenList__.local1 = external hidden unnamed_addr constant %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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; 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 @StringBuilder__write__(ptr noundef, ptr, i32) #3

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @AstPrinter__indent__(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @AstPrinter__unIndent__(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @AstPrinter__printDescTokenList__(ptr noundef %0, ptr %1, i32 %2, ptr noundef %3) #3 {
  %5 = alloca %struct.string__, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.tag_____StringBuilder__, align 8
  %9 = alloca %struct.string__, align 8
  %10 = alloca %struct.string__, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 0
  store ptr %1, ptr %15, align 8
  %16 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 1
  store i32 %2, ptr %16, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %3, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 16, i1 false)
  %17 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8
  %19 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 1
  %20 = load i32, ptr %19, align 8
  call void @StringBuilder__write__(ptr noundef %8, ptr %18, i32 %20)
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 @__const.AstPrinter__printDescTokenList__.local1, i64 16, i1 false)
  %21 = getelementptr inbounds { ptr, i32 }, ptr %9, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8
  %23 = getelementptr inbounds { ptr, i32 }, ptr %9, i32 0, i32 1
  %24 = load i32, ptr %23, align 8
  call void @StringBuilder__write__(ptr noundef %8, ptr %22, i32 %24)
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = call { ptr, i32 } @StringBuilder__compactToString__(ptr noundef %8)
  %27 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 0
  %28 = extractvalue { ptr, i32 } %26, 0
  store ptr %28, ptr %27, align 8
  %29 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 1
  %30 = extractvalue { ptr, i32 } %26, 1
  store i32 %30, ptr %29, align 8
  %31 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8
  %33 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 1
  %34 = load i32, ptr %33, align 8
  call void @AstPrinter__printLine__(ptr noundef %25, ptr %32, i32 %34)
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %38

37:                                               ; preds = %4
  store i32 1, ptr %11, align 4
  br label %61

38:                                               ; preds = %4
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  call void @AstPrinter__indent__(ptr noundef %39)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %40, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %47, %38
  %42 = load i32, ptr %13, align 4, !tbaa !9
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tag_____List__Ptr__Token______, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !11
  %46 = icmp slt i32 %42, %45
  br i1 %46, label %47, label %59

47:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.tag_____List__Ptr__Token______, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds ptr, ptr %50, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  store ptr %54, ptr %14, align 8, !tbaa !5
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %14, align 8, !tbaa !5
  call void @AstPrinter__printToken__(ptr noundef %55, ptr noundef %56)
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %41, !llvm.loop !14

59:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  call void @AstPrinter__unIndent__(ptr noundef %60)
  store i32 0, ptr %11, align 4
  br label %61

61:                                               ; preds = %59, %37
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  %62 = load i32, ptr %11, align 4
  switch i32 %62, label %64 [
    i32 0, label %63
    i32 1, label %63
  ]

63:                                               ; preds = %61, %61
  ret void

64:                                               ; preds = %61
  unreachable
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"tag_____List__Ptr__Token______", !6, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !6, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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

@__const.AstPrinter__printDescTokenList__.local1 = external hidden unnamed_addr constant %struct.string__, align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 @StringBuilder__write__(ptr noundef, ptr, i32) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local { ptr, i32 } @StringBuilder__compactToString__(ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @AstPrinter__printDescTokenList__(ptr noundef %0, ptr %1, i32 %2, ptr noundef readonly %3) local_unnamed_addr #2 {
  %5 = alloca %struct.tag_____StringBuilder__, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  call void @StringBuilder__write__(ptr noundef nonnull %5, ptr %1, i32 %2)
  %.sroa.05.0.copyload = load ptr, ptr @__const.AstPrinter__printDescTokenList__.local1, align 8
  %.sroa.4.0.copyload = load i32, ptr getelementptr inbounds (i8, ptr @__const.AstPrinter__printDescTokenList__.local1, i64 8), align 8
  call void @StringBuilder__write__(ptr noundef nonnull %5, ptr %.sroa.05.0.copyload, i32 %.sroa.4.0.copyload)
  %6 = call { ptr, i32 } @StringBuilder__compactToString__(ptr noundef nonnull %5)
  %7 = extractvalue { ptr, i32 } %6, 0
  %8 = extractvalue { ptr, i32 } %6, 1
  call void @AstPrinter__printLine__(ptr noundef %0, ptr %7, i32 %8)
  %9 = icmp eq ptr %3, null
  br i1 %9, label %20, label %10

10:                                               ; preds = %4
  call void @AstPrinter__indent__(ptr noundef %0)
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %10 ]
  %14 = load ptr, ptr %3, align 8, !tbaa !11
  %15 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  call void @AstPrinter__printToken__(ptr noundef %0, ptr noundef %16)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr %11, align 8, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %10
  call void @AstPrinter__unIndent__(ptr noundef %0)
  br label %20

20:                                               ; preds = %4, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  ret void
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 8}
!6 = !{!"tag_____List__Ptr__Token______", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass