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

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

@__const.AstPrinter__printDescAnyList__.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__printAny__(ptr noundef, i32, ptr) #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__printDescAnyList__(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 %struct.Node__, 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__printDescAnyList__.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 %63

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__Node____, 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 %61

47:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.tag_____List__Node____, 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 %struct.Node__, ptr %50, i64 %52
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %53, i64 16, i1 false), !tbaa.struct !14
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds { i32, ptr }, ptr %14, i32 0, i32 0
  %56 = load i32, ptr %55, align 8
  %57 = getelementptr inbounds { i32, ptr }, ptr %14, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8
  call void @AstPrinter__printAny__(ptr noundef %54, i32 %56, ptr %58)
  %59 = load i32, ptr %13, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  br label %41, !llvm.loop !15

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

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

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

66:                                               ; preds = %63
  unreachable
}

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__Node____", !6, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !6, i64 0}
!14 = !{i64 0, i64 4, !9, i64 8, i64 8, !5}
!15 = distinct !{!15, !16}
!16 = !{!"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 }
%struct.Node__ = type { i32, ptr }

@__const.AstPrinter__printDescAnyList__.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__printAny__(ptr noundef, i32, ptr) 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__printDescAnyList__(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.06.0.copyload = load ptr, ptr @__const.AstPrinter__printDescAnyList__.local1, align 8
  %.sroa.47.0.copyload = load i32, ptr getelementptr inbounds (i8, ptr @__const.AstPrinter__printDescAnyList__.local1, i64 8), align 8
  call void @StringBuilder__write__(ptr noundef nonnull %5, ptr %.sroa.06.0.copyload, i32 %.sroa.47.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 %19, 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 %struct.Node__, ptr %14, i64 %indvars.iv
  %.sroa.0.0.copyload = load i32, ptr %15, align 8, !tbaa !12
  %.sroa.41.0..sroa_idx = getelementptr inbounds i8, ptr %15, i64 8
  %.sroa.41.0.copyload = load ptr, ptr %.sroa.41.0..sroa_idx, align 8, !tbaa !13
  call void @AstPrinter__printAny__(ptr noundef %0, i32 %.sroa.0.0.copyload, ptr %.sroa.41.0.copyload)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr %11, align 8, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !14

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

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

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__Node____", !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 = !{!10, !10, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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