; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (2527（哈夫曼树）)

; 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::__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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_Z3strB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@k = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@fa = external dso_local global [123456 x i32], align 16
@Left = external dso_local global [123456 x i32], align 16
@Right = external dso_local global [123456 x i32], align 16
@tot = external dso_local global i32, align 4
@weight = external dso_local global [123456 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7Huffmanv() #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [34 x i32], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 136, ptr %4) #5
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %96, %59, %0
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr %3, align 4, !tbaa !5
  %12 = icmp ne i32 %10, 0
  br i1 %12, label %13, label %97

13:                                               ; preds = %9
  %14 = getelementptr inbounds [34 x i32], ptr %4, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %14, i8 0, i64 136, i1 false)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %36, %13
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11, i64 noundef %19)
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %22 = icmp ne i8 %21, 0
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %17
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11, i64 noundef %26)
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %29 = sext i8 %28 to i32
  %30 = sub nsw i32 %29, 97
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [34 x i32], ptr %4, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %32, align 4, !tbaa !5
  %35 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %35, ptr %5, align 4, !tbaa !5
  br label %36

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

39:                                               ; preds = %23
  %40 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11, i64 noundef 0)
  %41 = load i8, ptr %40, align 1, !tbaa !9
  %42 = sext i8 %41 to i32
  %43 = sub nsw i32 %42, 97
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [34 x i32], ptr %4, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  %49 = icmp eq i32 %46, %48
  br i1 %49, label %50, label %60

50:                                               ; preds = %39
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = icmp sle i32 %52, %53
  br i1 %54, label %55, label %57

55:                                               ; preds = %50
  %56 = call i32 @puts(ptr noundef @.str)
  br label %59

57:                                               ; preds = %50
  %58 = call i32 @puts(ptr noundef @.str.3)
  br label %59

59:                                               ; preds = %57, %55
  br label %9, !llvm.loop !12

60:                                               ; preds = %39
  store i32 0, ptr @k, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %81, %60
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = icmp slt i32 %62, 26
  br i1 %63, label %65, label %64

64:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %84

65:                                               ; preds = %61
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [34 x i32], ptr %4, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %80

71:                                               ; preds = %65
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [34 x i32], ptr %4, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = load i32, ptr @k, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr @k, align 4, !tbaa !5
  %78 = sext i32 %76 to i64
  %79 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %78
  store i32 %75, ptr %79, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %71, %65
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %7, align 4, !tbaa !5
  br label %61, !llvm.loop !13

84:                                               ; preds = %64
  call void @llvm.memset.p0.i64(ptr align 16 @fa, i8 -1, i64 493824, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @Left, i8 -1, i64 493824, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @Right, i8 -1, i64 493824, i1 false)
  %85 = load i32, ptr @k, align 4, !tbaa !5
  %86 = load i32, ptr @k, align 4, !tbaa !5
  %87 = add nsw i32 %85, %86
  %88 = sub nsw i32 %87, 1
  store i32 %88, ptr @m, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @_Z7Huffmanv()
  %89 = load i32, ptr @tot, align 4, !tbaa !5
  %90 = load i32, ptr %2, align 4, !tbaa !5
  %91 = icmp sle i32 %89, %90
  br i1 %91, label %92, label %94

92:                                               ; preds = %84
  %93 = call i32 @puts(ptr noundef @.str)
  br label %96

94:                                               ; preds = %84
  %95 = call i32 @puts(ptr noundef @.str.3)
  br label %96

96:                                               ; preds = %94, %92
  br label %9, !llvm.loop !12

97:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 136, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #0 align 2

declare i32 @puts(ptr noundef) #3

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


; 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::__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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_Z3strB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@k = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@fa = external dso_local local_unnamed_addr global [123456 x i32], align 16
@Left = external dso_local local_unnamed_addr global [123456 x i32], align 16
@Right = external dso_local local_unnamed_addr global [123456 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@weight = external dso_local local_unnamed_addr global [123456 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7Huffmanv() 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

; 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [34 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 136, ptr nonnull %3) #6
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr %2, align 4, !tbaa !5
  %.not21 = icmp eq i32 %5, 0
  br i1 %.not21, label %._crit_edge25, label %.lr.ph24.preheader

.lr.ph24.preheader:                               ; preds = %0
  %7 = getelementptr inbounds i8, ptr %3, i64 4
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = getelementptr inbounds i8, ptr %3, i64 12
  %10 = getelementptr inbounds i8, ptr %3, i64 16
  %11 = getelementptr inbounds i8, ptr %3, i64 20
  %12 = getelementptr inbounds i8, ptr %3, i64 24
  %13 = getelementptr inbounds i8, ptr %3, i64 28
  %14 = getelementptr inbounds i8, ptr %3, i64 32
  %15 = getelementptr inbounds i8, ptr %3, i64 36
  %16 = getelementptr inbounds i8, ptr %3, i64 40
  %17 = getelementptr inbounds i8, ptr %3, i64 44
  %18 = getelementptr inbounds i8, ptr %3, i64 48
  %19 = getelementptr inbounds i8, ptr %3, i64 52
  %20 = getelementptr inbounds i8, ptr %3, i64 56
  %21 = getelementptr inbounds i8, ptr %3, i64 60
  %22 = getelementptr inbounds i8, ptr %3, i64 64
  %23 = getelementptr inbounds i8, ptr %3, i64 68
  %24 = getelementptr inbounds i8, ptr %3, i64 72
  %25 = getelementptr inbounds i8, ptr %3, i64 76
  %26 = getelementptr inbounds i8, ptr %3, i64 80
  %27 = getelementptr inbounds i8, ptr %3, i64 84
  %28 = getelementptr inbounds i8, ptr %3, i64 88
  %29 = getelementptr inbounds i8, ptr %3, i64 92
  %30 = getelementptr inbounds i8, ptr %3, i64 96
  %31 = getelementptr inbounds i8, ptr %3, i64 100
  br label %.lr.ph24

.lr.ph24:                                         ; preds = %.lr.ph24.preheader, %.backedge
  %.01122 = phi i32 [ %.1.lcssa, %.backedge ], [ 0, %.lr.ph24.preheader ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(136) %3, i8 0, i64 136, i1 false)
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) %32, ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11)
  %34 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11, i64 noundef 0)
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %.not1418 = icmp eq i8 %35, 0
  br i1 %.not1418, label %._crit_edge, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %36 = trunc nuw nsw i64 %indvars.iv to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph24
  %.1.lcssa = phi i32 [ %.01122, %.lr.ph24 ], [ %36, %._crit_edge.loopexit ]
  %37 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11, i64 noundef 0)
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = sext i8 %38 to i64
  %40 = add nsw i64 %39, -97
  %41 = getelementptr inbounds [34 x i32], ptr %3, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = add nsw i32 %.1.lcssa, 1
  %44 = icmp eq i32 %42, %43
  br i1 %44, label %54, label %59

.lr.ph:                                           ; preds = %.lr.ph24, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph24 ]
  %45 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11, i64 noundef %indvars.iv)
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = sext i8 %46 to i64
  %48 = add nsw i64 %47, -97
  %49 = getelementptr inbounds [34 x i32], ptr %3, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %49, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %52 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3strB5cxx11, i64 noundef %indvars.iv.next)
  %53 = load i8, ptr %52, align 1, !tbaa !9
  %.not14 = icmp eq i8 %53, 0
  br i1 %.not14, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !10

54:                                               ; preds = %._crit_edge
  %55 = load i32, ptr %1, align 4, !tbaa !5
  %.not17.not = icmp slt i32 %.1.lcssa, %55
  %.str..str.3 = select i1 %.not17.not, ptr @.str, ptr @.str.3
  br label %.backedge

.backedge:                                        ; preds = %54, %237
  %.str.sink = phi ptr [ %.str.3..str, %237 ], [ %.str..str.3, %54 ]
  %56 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.sink)
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %57, 0
  br i1 %.not, label %._crit_edge25, label %.lr.ph24, !llvm.loop !12

59:                                               ; preds = %._crit_edge
  store i32 0, ptr @k, align 4, !tbaa !5
  %60 = load i32, ptr %3, align 16, !tbaa !5
  %.not16 = icmp eq i32 %60, 0
  br i1 %.not16, label %62, label %61

61:                                               ; preds = %59
  store i32 1, ptr @k, align 4, !tbaa !5
  store i32 %60, ptr @weight, align 16, !tbaa !5
  br label %62

62:                                               ; preds = %59, %61
  %63 = phi i32 [ 0, %59 ], [ 1, %61 ]
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %.not16.1 = icmp eq i32 %64, 0
  br i1 %.not16.1, label %69, label %65

65:                                               ; preds = %62
  %66 = add nuw nsw i32 %63, 1
  store i32 %66, ptr @k, align 4, !tbaa !5
  %67 = zext nneg i32 %63 to i64
  %68 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %67
  store i32 %64, ptr %68, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %65, %62
  %70 = phi i32 [ %63, %62 ], [ %66, %65 ]
  %71 = load i32, ptr %8, align 8, !tbaa !5
  %.not16.2 = icmp eq i32 %71, 0
  br i1 %.not16.2, label %76, label %72

72:                                               ; preds = %69
  %73 = add nuw nsw i32 %70, 1
  store i32 %73, ptr @k, align 4, !tbaa !5
  %74 = zext nneg i32 %70 to i64
  %75 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %74
  store i32 %71, ptr %75, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %72, %69
  %77 = phi i32 [ %70, %69 ], [ %73, %72 ]
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %.not16.3 = icmp eq i32 %78, 0
  br i1 %.not16.3, label %83, label %79

79:                                               ; preds = %76
  %80 = add nuw nsw i32 %77, 1
  store i32 %80, ptr @k, align 4, !tbaa !5
  %81 = zext nneg i32 %77 to i64
  %82 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %81
  store i32 %78, ptr %82, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %79, %76
  %84 = phi i32 [ %77, %76 ], [ %80, %79 ]
  %85 = load i32, ptr %10, align 16, !tbaa !5
  %.not16.4 = icmp eq i32 %85, 0
  br i1 %.not16.4, label %90, label %86

86:                                               ; preds = %83
  %87 = add nuw nsw i32 %84, 1
  store i32 %87, ptr @k, align 4, !tbaa !5
  %88 = zext nneg i32 %84 to i64
  %89 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %88
  store i32 %85, ptr %89, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %86, %83
  %91 = phi i32 [ %84, %83 ], [ %87, %86 ]
  %92 = load i32, ptr %11, align 4, !tbaa !5
  %.not16.5 = icmp eq i32 %92, 0
  br i1 %.not16.5, label %97, label %93

93:                                               ; preds = %90
  %94 = add nuw nsw i32 %91, 1
  store i32 %94, ptr @k, align 4, !tbaa !5
  %95 = zext nneg i32 %91 to i64
  %96 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %95
  store i32 %92, ptr %96, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %93, %90
  %98 = phi i32 [ %91, %90 ], [ %94, %93 ]
  %99 = load i32, ptr %12, align 8, !tbaa !5
  %.not16.6 = icmp eq i32 %99, 0
  br i1 %.not16.6, label %104, label %100

100:                                              ; preds = %97
  %101 = add nuw nsw i32 %98, 1
  store i32 %101, ptr @k, align 4, !tbaa !5
  %102 = zext nneg i32 %98 to i64
  %103 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %102
  store i32 %99, ptr %103, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %100, %97
  %105 = phi i32 [ %98, %97 ], [ %101, %100 ]
  %106 = load i32, ptr %13, align 4, !tbaa !5
  %.not16.7 = icmp eq i32 %106, 0
  br i1 %.not16.7, label %111, label %107

107:                                              ; preds = %104
  %108 = add nuw nsw i32 %105, 1
  store i32 %108, ptr @k, align 4, !tbaa !5
  %109 = zext nneg i32 %105 to i64
  %110 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %109
  store i32 %106, ptr %110, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %107, %104
  %112 = phi i32 [ %105, %104 ], [ %108, %107 ]
  %113 = load i32, ptr %14, align 16, !tbaa !5
  %.not16.8 = icmp eq i32 %113, 0
  br i1 %.not16.8, label %118, label %114

114:                                              ; preds = %111
  %115 = add nuw nsw i32 %112, 1
  store i32 %115, ptr @k, align 4, !tbaa !5
  %116 = zext nneg i32 %112 to i64
  %117 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %116
  store i32 %113, ptr %117, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %114, %111
  %119 = phi i32 [ %112, %111 ], [ %115, %114 ]
  %120 = load i32, ptr %15, align 4, !tbaa !5
  %.not16.9 = icmp eq i32 %120, 0
  br i1 %.not16.9, label %125, label %121

121:                                              ; preds = %118
  %122 = add nuw nsw i32 %119, 1
  store i32 %122, ptr @k, align 4, !tbaa !5
  %123 = zext nneg i32 %119 to i64
  %124 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %123
  store i32 %120, ptr %124, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %121, %118
  %126 = phi i32 [ %119, %118 ], [ %122, %121 ]
  %127 = load i32, ptr %16, align 8, !tbaa !5
  %.not16.10 = icmp eq i32 %127, 0
  br i1 %.not16.10, label %132, label %128

128:                                              ; preds = %125
  %129 = add nuw nsw i32 %126, 1
  store i32 %129, ptr @k, align 4, !tbaa !5
  %130 = zext nneg i32 %126 to i64
  %131 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %130
  store i32 %127, ptr %131, align 4, !tbaa !5
  br label %132

132:                                              ; preds = %128, %125
  %133 = phi i32 [ %126, %125 ], [ %129, %128 ]
  %134 = load i32, ptr %17, align 4, !tbaa !5
  %.not16.11 = icmp eq i32 %134, 0
  br i1 %.not16.11, label %139, label %135

135:                                              ; preds = %132
  %136 = add nuw nsw i32 %133, 1
  store i32 %136, ptr @k, align 4, !tbaa !5
  %137 = zext nneg i32 %133 to i64
  %138 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %137
  store i32 %134, ptr %138, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %135, %132
  %140 = phi i32 [ %133, %132 ], [ %136, %135 ]
  %141 = load i32, ptr %18, align 16, !tbaa !5
  %.not16.12 = icmp eq i32 %141, 0
  br i1 %.not16.12, label %146, label %142

142:                                              ; preds = %139
  %143 = add nuw nsw i32 %140, 1
  store i32 %143, ptr @k, align 4, !tbaa !5
  %144 = zext nneg i32 %140 to i64
  %145 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %144
  store i32 %141, ptr %145, align 4, !tbaa !5
  br label %146

146:                                              ; preds = %142, %139
  %147 = phi i32 [ %140, %139 ], [ %143, %142 ]
  %148 = load i32, ptr %19, align 4, !tbaa !5
  %.not16.13 = icmp eq i32 %148, 0
  br i1 %.not16.13, label %153, label %149

149:                                              ; preds = %146
  %150 = add nuw nsw i32 %147, 1
  store i32 %150, ptr @k, align 4, !tbaa !5
  %151 = zext nneg i32 %147 to i64
  %152 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %151
  store i32 %148, ptr %152, align 4, !tbaa !5
  br label %153

153:                                              ; preds = %149, %146
  %154 = phi i32 [ %147, %146 ], [ %150, %149 ]
  %155 = load i32, ptr %20, align 8, !tbaa !5
  %.not16.14 = icmp eq i32 %155, 0
  br i1 %.not16.14, label %160, label %156

156:                                              ; preds = %153
  %157 = add nuw nsw i32 %154, 1
  store i32 %157, ptr @k, align 4, !tbaa !5
  %158 = zext nneg i32 %154 to i64
  %159 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %158
  store i32 %155, ptr %159, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %156, %153
  %161 = phi i32 [ %154, %153 ], [ %157, %156 ]
  %162 = load i32, ptr %21, align 4, !tbaa !5
  %.not16.15 = icmp eq i32 %162, 0
  br i1 %.not16.15, label %167, label %163

163:                                              ; preds = %160
  %164 = add nuw nsw i32 %161, 1
  store i32 %164, ptr @k, align 4, !tbaa !5
  %165 = zext nneg i32 %161 to i64
  %166 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %165
  store i32 %162, ptr %166, align 4, !tbaa !5
  br label %167

167:                                              ; preds = %163, %160
  %168 = phi i32 [ %161, %160 ], [ %164, %163 ]
  %169 = load i32, ptr %22, align 16, !tbaa !5
  %.not16.16 = icmp eq i32 %169, 0
  br i1 %.not16.16, label %174, label %170

170:                                              ; preds = %167
  %171 = add nuw nsw i32 %168, 1
  store i32 %171, ptr @k, align 4, !tbaa !5
  %172 = zext nneg i32 %168 to i64
  %173 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %172
  store i32 %169, ptr %173, align 4, !tbaa !5
  br label %174

174:                                              ; preds = %170, %167
  %175 = phi i32 [ %168, %167 ], [ %171, %170 ]
  %176 = load i32, ptr %23, align 4, !tbaa !5
  %.not16.17 = icmp eq i32 %176, 0
  br i1 %.not16.17, label %181, label %177

177:                                              ; preds = %174
  %178 = add nuw nsw i32 %175, 1
  store i32 %178, ptr @k, align 4, !tbaa !5
  %179 = zext nneg i32 %175 to i64
  %180 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %179
  store i32 %176, ptr %180, align 4, !tbaa !5
  br label %181

181:                                              ; preds = %177, %174
  %182 = phi i32 [ %175, %174 ], [ %178, %177 ]
  %183 = load i32, ptr %24, align 8, !tbaa !5
  %.not16.18 = icmp eq i32 %183, 0
  br i1 %.not16.18, label %188, label %184

184:                                              ; preds = %181
  %185 = add nuw nsw i32 %182, 1
  store i32 %185, ptr @k, align 4, !tbaa !5
  %186 = zext nneg i32 %182 to i64
  %187 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %186
  store i32 %183, ptr %187, align 4, !tbaa !5
  br label %188

188:                                              ; preds = %184, %181
  %189 = phi i32 [ %182, %181 ], [ %185, %184 ]
  %190 = load i32, ptr %25, align 4, !tbaa !5
  %.not16.19 = icmp eq i32 %190, 0
  br i1 %.not16.19, label %195, label %191

191:                                              ; preds = %188
  %192 = add nuw nsw i32 %189, 1
  store i32 %192, ptr @k, align 4, !tbaa !5
  %193 = zext nneg i32 %189 to i64
  %194 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %193
  store i32 %190, ptr %194, align 4, !tbaa !5
  br label %195

195:                                              ; preds = %191, %188
  %196 = phi i32 [ %189, %188 ], [ %192, %191 ]
  %197 = load i32, ptr %26, align 16, !tbaa !5
  %.not16.20 = icmp eq i32 %197, 0
  br i1 %.not16.20, label %202, label %198

198:                                              ; preds = %195
  %199 = add nuw nsw i32 %196, 1
  store i32 %199, ptr @k, align 4, !tbaa !5
  %200 = zext nneg i32 %196 to i64
  %201 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %200
  store i32 %197, ptr %201, align 4, !tbaa !5
  br label %202

202:                                              ; preds = %198, %195
  %203 = phi i32 [ %196, %195 ], [ %199, %198 ]
  %204 = load i32, ptr %27, align 4, !tbaa !5
  %.not16.21 = icmp eq i32 %204, 0
  br i1 %.not16.21, label %209, label %205

205:                                              ; preds = %202
  %206 = add nuw nsw i32 %203, 1
  store i32 %206, ptr @k, align 4, !tbaa !5
  %207 = zext nneg i32 %203 to i64
  %208 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %207
  store i32 %204, ptr %208, align 4, !tbaa !5
  br label %209

209:                                              ; preds = %205, %202
  %210 = phi i32 [ %203, %202 ], [ %206, %205 ]
  %211 = load i32, ptr %28, align 8, !tbaa !5
  %.not16.22 = icmp eq i32 %211, 0
  br i1 %.not16.22, label %216, label %212

212:                                              ; preds = %209
  %213 = add nuw nsw i32 %210, 1
  store i32 %213, ptr @k, align 4, !tbaa !5
  %214 = zext nneg i32 %210 to i64
  %215 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %214
  store i32 %211, ptr %215, align 4, !tbaa !5
  br label %216

216:                                              ; preds = %212, %209
  %217 = phi i32 [ %210, %209 ], [ %213, %212 ]
  %218 = load i32, ptr %29, align 4, !tbaa !5
  %.not16.23 = icmp eq i32 %218, 0
  br i1 %.not16.23, label %223, label %219

219:                                              ; preds = %216
  %220 = add nuw nsw i32 %217, 1
  store i32 %220, ptr @k, align 4, !tbaa !5
  %221 = zext nneg i32 %217 to i64
  %222 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %221
  store i32 %218, ptr %222, align 4, !tbaa !5
  br label %223

223:                                              ; preds = %219, %216
  %224 = phi i32 [ %217, %216 ], [ %220, %219 ]
  %225 = load i32, ptr %30, align 16, !tbaa !5
  %.not16.24 = icmp eq i32 %225, 0
  br i1 %.not16.24, label %230, label %226

226:                                              ; preds = %223
  %227 = add nuw nsw i32 %224, 1
  store i32 %227, ptr @k, align 4, !tbaa !5
  %228 = zext nneg i32 %224 to i64
  %229 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %228
  store i32 %225, ptr %229, align 4, !tbaa !5
  br label %230

230:                                              ; preds = %226, %223
  %231 = phi i32 [ %224, %223 ], [ %227, %226 ]
  %232 = load i32, ptr %31, align 4, !tbaa !5
  %.not16.25 = icmp eq i32 %232, 0
  br i1 %.not16.25, label %237, label %233

233:                                              ; preds = %230
  %234 = add nuw nsw i32 %231, 1
  store i32 %234, ptr @k, align 4, !tbaa !5
  %235 = zext nneg i32 %231 to i64
  %236 = getelementptr inbounds [123456 x i32], ptr @weight, i64 0, i64 %235
  store i32 %232, ptr %236, align 4, !tbaa !5
  br label %237

237:                                              ; preds = %233, %230
  %238 = phi i32 [ %234, %233 ], [ %231, %230 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(493824) @fa, i8 -1, i64 493824, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(493824) @Left, i8 -1, i64 493824, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(493824) @Right, i8 -1, i64 493824, i1 false)
  %239 = shl nuw nsw i32 %238, 1
  %240 = add nsw i32 %239, -1
  store i32 %240, ptr @m, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @_Z7Huffmanv()
  %241 = load i32, ptr @tot, align 4, !tbaa !5
  %242 = load i32, ptr %1, align 4, !tbaa !5
  %.not15 = icmp sgt i32 %241, %242
  %.str.3..str = select i1 %.not15, ptr @.str.3, ptr @.str
  br label %.backedge

._crit_edge25:                                    ; preds = %.backedge, %0
  call void @llvm.lifetime.end.p0(i64 136, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass