; LLVM IR from TheAlgorithms/C-Plus-Plus :: greedy_algorithms/huffman.ll (Z12HuffmanCodesPKcPKii)

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

%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<MinHeapNode *, std::allocator<MinHeapNode *>>::_Vector_impl" }
%"struct.std::_Vector_base<MinHeapNode *, std::allocator<MinHeapNode *>>::_Vector_impl" = type { %"struct.std::_Vector_base<MinHeapNode *, std::allocator<MinHeapNode *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<MinHeapNode *, std::allocator<MinHeapNode *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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] }
%"class.std::allocator" = type { i8 }
%struct.MinHeapNode = type { i8, i32, ptr, ptr }

@.str.4 = external hidden unnamed_addr constant [1 x i8], align 1

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10printCodesP11MinHeapNodeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) #0

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12HuffmanCodesPKcPKii(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %"class.std::priority_queue", align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca %"class.std::__cxx11::basic_string", align 8
  %16 = alloca %"class.std::allocator", align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #6
  call void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %37, %3
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %49

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %23 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #7
          to label %24 unwind label %40

24:                                               ; preds = %22
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %25, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %30, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !9
  invoke void @_ZN11MinHeapNodeC2Ecj(ptr noundef nonnull align 8 dereferenceable(24) %23, i8 noundef signext %29, i32 noundef %34)
          to label %35 unwind label %44

35:                                               ; preds = %24
  store ptr %23, ptr %11, align 8, !tbaa !5
  invoke void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %9, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %36 unwind label %40

36:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %10, align 4, !tbaa !9
  br label %17, !llvm.loop !12

40:                                               ; preds = %35, %22
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %12, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %13, align 4
  br label %48

44:                                               ; preds = %24
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %12, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %13, align 4
  call void @_ZdlPvm(ptr noundef %23, i64 noundef 24) #8
  br label %48

48:                                               ; preds = %44, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %112

49:                                               ; preds = %21
  br label %50

50:                                               ; preds = %79, %49
  %51 = invoke noundef i64 @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
          to label %52 unwind label %80

52:                                               ; preds = %50
  %53 = icmp ne i64 %51, 1
  br i1 %53, label %54, label %93

54:                                               ; preds = %52
  %55 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
          to label %56 unwind label %80

56:                                               ; preds = %54
  %57 = load ptr, ptr %55, align 8, !tbaa !5
  store ptr %57, ptr %7, align 8, !tbaa !5
  invoke void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
          to label %58 unwind label %80

58:                                               ; preds = %56
  %59 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
          to label %60 unwind label %80

60:                                               ; preds = %58
  %61 = load ptr, ptr %59, align 8, !tbaa !5
  store ptr %61, ptr %8, align 8, !tbaa !5
  invoke void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
          to label %62 unwind label %80

62:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %63 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #7
          to label %64 unwind label %84

64:                                               ; preds = %62
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.MinHeapNode, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 4, !tbaa !14
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.MinHeapNode, ptr %68, i32 0, i32 1
  %70 = load i32, ptr %69, align 4, !tbaa !14
  %71 = add i32 %67, %70
  invoke void @_ZN11MinHeapNodeC2Ecj(ptr noundef nonnull align 8 dereferenceable(24) %63, i8 noundef signext 36, i32 noundef %71)
          to label %72 unwind label %88

72:                                               ; preds = %64
  store ptr %63, ptr %14, align 8, !tbaa !5
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.MinHeapNode, ptr %74, i32 0, i32 2
  store ptr %73, ptr %75, align 8, !tbaa !16
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.MinHeapNode, ptr %77, i32 0, i32 3
  store ptr %76, ptr %78, align 8, !tbaa !17
  invoke void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(25) %9, ptr noundef nonnull align 8 dereferenceable(8) %14)
          to label %79 unwind label %84

79:                                               ; preds = %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %50, !llvm.loop !18

80:                                               ; preds = %100, %98, %93, %60, %58, %56, %54, %50
  %81 = landingpad { ptr, i32 }
          cleanup
  %82 = extractvalue { ptr, i32 } %81, 0
  store ptr %82, ptr %12, align 8
  %83 = extractvalue { ptr, i32 } %81, 1
  store i32 %83, ptr %13, align 4
  br label %112

84:                                               ; preds = %72, %62
  %85 = landingpad { ptr, i32 }
          cleanup
  %86 = extractvalue { ptr, i32 } %85, 0
  store ptr %86, ptr %12, align 8
  %87 = extractvalue { ptr, i32 } %85, 1
  store i32 %87, ptr %13, align 4
  br label %92

88:                                               ; preds = %64
  %89 = landingpad { ptr, i32 }
          cleanup
  %90 = extractvalue { ptr, i32 } %89, 0
  store ptr %90, ptr %12, align 8
  %91 = extractvalue { ptr, i32 } %89, 1
  store i32 %91, ptr %13, align 4
  call void @_ZdlPvm(ptr noundef %63, i64 noundef 24) #8
  br label %92

92:                                               ; preds = %88, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %112

93:                                               ; preds = %52
  %94 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
          to label %95 unwind label %80

95:                                               ; preds = %93
  %96 = load ptr, ptr %94, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %16) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %15, ptr noundef @.str.4, ptr noundef nonnull align 1 dereferenceable(1) %16)
          to label %97 unwind label %103

97:                                               ; preds = %95
  invoke void @_Z10printCodesP11MinHeapNodeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %96, ptr noundef nonnull align 8 dereferenceable(32) %15)
          to label %98 unwind label %107

98:                                               ; preds = %97
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %15) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %16) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #6
  %99 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
          to label %100 unwind label %80

100:                                              ; preds = %98
  %101 = load ptr, ptr %99, align 8, !tbaa !5
  invoke void @_Z9deleteAllPK11MinHeapNode(ptr noundef %101)
          to label %102 unwind label %80

102:                                              ; preds = %100
  call void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %9) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret void

103:                                              ; preds = %95
  %104 = landingpad { ptr, i32 }
          cleanup
  %105 = extractvalue { ptr, i32 } %104, 0
  store ptr %105, ptr %12, align 8
  %106 = extractvalue { ptr, i32 } %104, 1
  store i32 %106, ptr %13, align 4
  br label %111

107:                                              ; preds = %97
  %108 = landingpad { ptr, i32 }
          cleanup
  %109 = extractvalue { ptr, i32 } %108, 0
  store ptr %109, ptr %12, align 8
  %110 = extractvalue { ptr, i32 } %108, 1
  store i32 %110, ptr %13, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %15) #6
  br label %111

111:                                              ; preds = %107, %103
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %16) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #6
  br label %112

112:                                              ; preds = %111, %92, %80, %48
  call void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %9) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %113

113:                                              ; preds = %112
  %114 = load ptr, ptr %12, align 8
  %115 = load i32, ptr %13, align 4
  %116 = insertvalue { ptr, i32 } poison, ptr %114, 0
  %117 = insertvalue { ptr, i32 } %116, i32 %115, 1
  resume { ptr, i32 } %117
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11MinHeapNodeC2Ecj(ptr noundef nonnull align 8 dereferenceable(24), i8 noundef signext, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3 align 2

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" }
attributes #1 = { nobuiltin nounwind "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 = { nobuiltin allocsize(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 = { inlinehint mustprogress 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !10, i64 4}
!15 = !{!"_ZTS11MinHeapNode", !7, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!16 = !{!15, !6, i64 8}
!17 = !{!15, !6, i64 16}
!18 = distinct !{!18, !13}


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

%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<MinHeapNode *, std::allocator<MinHeapNode *>>::_Vector_impl" }
%"struct.std::_Vector_base<MinHeapNode *, std::allocator<MinHeapNode *>>::_Vector_impl" = type { %"struct.std::_Vector_base<MinHeapNode *, std::allocator<MinHeapNode *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<MinHeapNode *, std::allocator<MinHeapNode *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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] }
%"class.std::allocator" = type { i8 }

@.str.4 = external hidden unnamed_addr constant [1 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10printCodesP11MinHeapNodeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12HuffmanCodesPKcPKii(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::priority_queue", align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.std::__cxx11::basic_string", align 8
  %8 = alloca %"class.std::allocator", align 1
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #5
  call void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %9 = icmp sgt i32 %2, 0
  br i1 %9, label %.lr.ph.preheader, label %.preheader

.lr.ph.preheader:                                 ; preds = %3
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.lr.ph

.preheader:                                       ; preds = %17, %3
  %10 = call noundef i64 @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %.not19 = icmp eq i64 %10, 1
  br i1 %.not19, label %._crit_edge, label %.lr.ph20

.lr.ph:                                           ; preds = %.lr.ph.preheader, %17
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %17 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %11 = invoke noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #6
          to label %12 unwind label %18

12:                                               ; preds = %.lr.ph
  %13 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %16 = load i32, ptr %15, align 4, !tbaa !8
  call void @_ZN11MinHeapNodeC2Ecj(ptr noundef nonnull align 8 dereferenceable(24) %11, i8 noundef signext %14, i32 noundef %16)
  store ptr %11, ptr %5, align 8, !tbaa !10
  invoke void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %17 unwind label %18

17:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !12

18:                                               ; preds = %12, %.lr.ph
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br label %51

.lr.ph20:                                         ; preds = %.preheader, %35
  %20 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %21 = load ptr, ptr %20, align 8, !tbaa !10
  invoke void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %22 unwind label %.loopexit

22:                                               ; preds = %.lr.ph20
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %24 = load ptr, ptr %23, align 8, !tbaa !10
  invoke void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %25 unwind label %.loopexit

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %26 = invoke noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #6
          to label %27 unwind label %37

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %21, i64 4
  %29 = load i32, ptr %28, align 4, !tbaa !14
  %30 = getelementptr inbounds i8, ptr %24, i64 4
  %31 = load i32, ptr %30, align 4, !tbaa !14
  %32 = add i32 %31, %29
  call void @_ZN11MinHeapNodeC2Ecj(ptr noundef nonnull align 8 dereferenceable(24) %26, i8 noundef signext 36, i32 noundef %32)
  store ptr %26, ptr %6, align 8, !tbaa !10
  %33 = getelementptr inbounds i8, ptr %26, i64 8
  store ptr %21, ptr %33, align 8, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %26, i64 16
  store ptr %24, ptr %34, align 8, !tbaa !17
  invoke void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(25) %4, ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %35 unwind label %37

35:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  %36 = call noundef i64 @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %.not = icmp eq i64 %36, 1
  br i1 %.not, label %._crit_edge, label %.lr.ph20, !llvm.loop !18

.loopexit:                                        ; preds = %.lr.ph20, %22
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %51

.loopexit.split-lp:                               ; preds = %42
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %51

37:                                               ; preds = %27, %25
  %38 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  br label %51

._crit_edge:                                      ; preds = %35, %.preheader
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %40 = load ptr, ptr %39, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %8) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %8) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull @.str.4, ptr noundef nonnull align 1 dereferenceable(1) %8)
          to label %41 unwind label %46

41:                                               ; preds = %._crit_edge
  invoke void @_Z10printCodesP11MinHeapNodeRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %40, ptr noundef nonnull align 8 dereferenceable(32) %7)
          to label %42 unwind label %48

42:                                               ; preds = %41
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #5
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  %44 = load ptr, ptr %43, align 8, !tbaa !10
  invoke void @_Z9deleteAllPK11MinHeapNode(ptr noundef %44)
          to label %45 unwind label %.loopexit.split-lp

45:                                               ; preds = %42
  call void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #5
  ret void

46:                                               ; preds = %._crit_edge
  %47 = landingpad { ptr, i32 }
          cleanup
  br label %50

48:                                               ; preds = %41
  %49 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #5
  br label %50

50:                                               ; preds = %48, %46
  %.pn = phi { ptr, i32 } [ %49, %48 ], [ %47, %46 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #5
  br label %51

51:                                               ; preds = %.loopexit, %.loopexit.split-lp, %50, %37, %18
  %.pn16 = phi { ptr, i32 } [ %19, %18 ], [ %38, %37 ], [ %.pn, %50 ], [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  call void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #5
  resume { ptr, i32 } %.pn16
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11MinHeapNodeC2Ecj(ptr noundef nonnull align 8 dereferenceable(24), i8 noundef signext, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueIP11MinHeapNodeSt6vectorIS1_SaIS1_EE7compareED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { nobuiltin allocsize(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 = { inlinehint mustprogress 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 }
attributes #6 = { builtin allocsize(0) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !9, i64 4}
!15 = !{!"_ZTS11MinHeapNode", !6, i64 0, !9, i64 4, !11, i64 8, !11, i64 16}
!16 = !{!15, !11, i64 8}
!17 = !{!15, !11, i64 16}
!18 = distinct !{!18, !13}


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