; LLVM IR from nragland37/cpp-projects :: data_structures-II/09-Huffman-Algorithm/Decoding/main.ll (Z10printPathsP4NodeI5StockEPiii)

; 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.Node = type { %class.Stock, double, ptr, ptr }
%class.Stock = type { %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", double }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10printPathsP4NodeI5StockEPiii(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %48

11:                                               ; preds = %4
  %12 = load i32, ptr %8, align 4, !tbaa !9
  %13 = icmp ne i32 %12, -1
  br i1 %13, label %14, label %22

14:                                               ; preds = %11
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds i32, ptr %16, i64 %18
  store i32 %15, ptr %19, align 4, !tbaa !9
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %7, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %14, %11
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Node, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = icmp ne ptr %25, null
  br i1 %26, label %36, label %27

27:                                               ; preds = %22
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Node, ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = icmp ne ptr %30, null
  br i1 %31, label %36, label %32

32:                                               ; preds = %27
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_Z10printArrayPiiP4NodeI5StockE(ptr noundef %33, i32 noundef %34, ptr noundef %35)
  br label %47

36:                                               ; preds = %27, %22
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.Node, ptr %37, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !9
  call void @_Z10printPathsP4NodeI5StockEPiii(ptr noundef %39, ptr noundef %40, i32 noundef %41, i32 noundef 0)
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Node, ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i32, ptr %7, align 4, !tbaa !9
  call void @_Z10printPathsP4NodeI5StockEPiii(ptr noundef %44, ptr noundef %45, i32 noundef %46, i32 noundef 1)
  br label %47

47:                                               ; preds = %36, %32
  br label %48

48:                                               ; preds = %47, %4
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10printArrayPiiP4NodeI5StockE(ptr noundef, i32 noundef, ptr noundef) #0

attributes #0 = { mustprogress 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" }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"_ZTS4NodeI5StockE", !13, i64 0, !17, i64 72, !6, i64 80, !6, i64 88}
!13 = !{!"_ZTS5Stock", !14, i64 0, !14, i64 32, !17, i64 64}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!12, !6, i64 88}


; 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"

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10printPathsP4NodeI5StockEPiii(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %.not25 = icmp eq ptr %0, null
  br i1 %.not25, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %.not18.peel = icmp eq i32 %3, -1
  br i1 %.not18.peel, label %9, label %5

5:                                                ; preds = %.lr.ph.preheader
  %6 = sext i32 %2 to i64
  %7 = getelementptr inbounds i32, ptr %1, i64 %6
  store i32 %3, ptr %7, align 4, !tbaa !5
  %8 = add nsw i32 %2, 1
  br label %9

9:                                                ; preds = %5, %.lr.ph.preheader
  %.0.peel = phi i32 [ %8, %5 ], [ %2, %.lr.ph.preheader ]
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %.not19.peel = icmp eq ptr %11, null
  br i1 %.not19.peel, label %12, label %tailrecurse.peel

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %.not20.peel = icmp eq ptr %14, null
  br i1 %.not20.peel, label %.loopexit32, label %tailrecurse.peel

tailrecurse.peel:                                 ; preds = %12, %9
  tail call void @_Z10printPathsP4NodeI5StockEPiii(ptr noundef %11, ptr noundef %1, i32 noundef %.0.peel, i32 noundef 0)
  %15 = getelementptr inbounds i8, ptr %0, i64 88
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %.not.peel = icmp eq ptr %16, null
  br i1 %.not.peel, label %.loopexit, label %.lr.ph.peel.next

.lr.ph.peel.next:                                 ; preds = %tailrecurse.peel, %tailrecurse
  %.tr2227 = phi i32 [ %19, %tailrecurse ], [ %.0.peel, %tailrecurse.peel ]
  %.tr26 = phi ptr [ %26, %tailrecurse ], [ %16, %tailrecurse.peel ]
  %17 = sext i32 %.tr2227 to i64
  %18 = getelementptr inbounds i32, ptr %1, i64 %17
  store i32 1, ptr %18, align 4, !tbaa !5
  %19 = add nsw i32 %.tr2227, 1
  %20 = getelementptr inbounds i8, ptr %.tr26, i64 80
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %.not19 = icmp eq ptr %21, null
  br i1 %.not19, label %22, label %tailrecurse

22:                                               ; preds = %.lr.ph.peel.next
  %23 = getelementptr inbounds i8, ptr %.tr26, i64 88
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %.not20 = icmp eq ptr %24, null
  br i1 %.not20, label %.loopexit32, label %tailrecurse

.loopexit32:                                      ; preds = %22, %12
  %.0.lcssa = phi i32 [ %.0.peel, %12 ], [ %19, %22 ]
  %.tr26.lcssa = phi ptr [ %0, %12 ], [ %.tr26, %22 ]
  tail call void @_Z10printArrayPiiP4NodeI5StockE(ptr noundef %1, i32 noundef %.0.lcssa, ptr noundef nonnull %.tr26.lcssa)
  br label %.loopexit

tailrecurse:                                      ; preds = %22, %.lr.ph.peel.next
  tail call void @_Z10printPathsP4NodeI5StockEPiii(ptr noundef %21, ptr noundef nonnull %1, i32 noundef %19, i32 noundef 0)
  %25 = getelementptr inbounds i8, ptr %.tr26, i64 88
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %.not = icmp eq ptr %26, null
  br i1 %.not, label %.loopexit, label %.lr.ph.peel.next, !llvm.loop !18

.loopexit:                                        ; preds = %tailrecurse, %tailrecurse.peel, %4, %.loopexit32
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10printArrayPiiP4NodeI5StockE(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { mustprogress 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !14, i64 80}
!10 = !{!"_ZTS4NodeI5StockE", !11, i64 0, !16, i64 72, !14, i64 80, !14, i64 88}
!11 = !{!"_ZTS5Stock", !12, i64 0, !12, i64 32, !16, i64 64}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !15, i64 8, !7, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!10, !14, i64 88}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass