; LLVM IR from AnzoDK/RPAudio :: includes/minimp3/huffopt (huffopt)

; 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.huff_t = type { ptr, ptr, [2 x ptr], i32, i32, i32, %struct.anon, i32, i32, i32 }
%struct.anon = type { i32, i32, float }

@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__.huff_print_one = external hidden unnamed_addr constant [54 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1

; 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: nounwind uwtable
declare hidden i32 @is_leaf(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @huff_print_one(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = 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
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.huff_t, ptr %11, i32 0, i32 9
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %80

15:                                               ; preds = %4
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 @is_leaf(ptr noundef %16)
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %48

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.huff_t, ptr %20, i32 0, i32 4
  %22 = load i32, ptr %21, align 4, !tbaa !15
  %23 = shl i32 %22, 16
  %24 = lshr i32 %23, 16
  store i32 %24, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.huff_t, ptr %25, i32 0, i32 4
  %27 = load i32, ptr %26, align 4, !tbaa !15
  %28 = shl i32 %27, 0
  %29 = lshr i32 %28, 16
  store i32 %29, ptr %10, align 4, !tbaa !9
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  %33 = zext i1 %32 to i64
  %34 = select i1 %32, ptr @.str.6, ptr @.str.7
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.huff_t, ptr %35, i32 0, i32 3
  %37 = load i32, ptr %36, align 8, !tbaa !16
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = sub nsw i32 %37, %38
  %40 = mul nsw i32 %39, 256
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = shl i32 %41, 4
  %43 = add nsw i32 %40, %42
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = shl i32 %44, 0
  %46 = add nsw i32 %43, %45
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef %34, i32 noundef %46) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %79

48:                                               ; preds = %15
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.huff_t, ptr %49, i32 0, i32 8
  %51 = load i32, ptr %50, align 4, !tbaa !17
  %52 = icmp slt i32 %51, 8192
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  br label %55

54:                                               ; preds = %48
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.9, i32 noundef 216, ptr noundef @__PRETTY_FUNCTION__.huff_print_one) #5
  unreachable

55:                                               ; preds = %53
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.huff_t, ptr %56, i32 0, i32 8
  %58 = load i32, ptr %57, align 4, !tbaa !17
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  br label %62

61:                                               ; preds = %55
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.9, i32 noundef 217, ptr noundef @__PRETTY_FUNCTION__.huff_print_one) #5
  unreachable

62:                                               ; preds = %60
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = icmp ne i32 %64, 0
  %66 = zext i1 %65 to i64
  %67 = select i1 %65, ptr @.str.6, ptr @.str.7
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.huff_t, ptr %68, i32 0, i32 8
  %70 = load i32, ptr %69, align 4, !tbaa !17
  %71 = sub nsw i32 0, %70
  %72 = shl i32 %71, 3
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.huff_t, ptr %73, i32 0, i32 6
  %75 = getelementptr inbounds %struct.anon, ptr %74, i32 0, i32 0
  %76 = load i32, ptr %75, align 4, !tbaa !18
  %77 = or i32 %72, %76
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef %67, i32 noundef %77) #4
  br label %79

79:                                               ; preds = %62, %19
  br label %117

80:                                               ; preds = %4
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = call i32 @is_leaf(ptr noundef %81)
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %100

84:                                               ; preds = %80
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = icmp ne i32 %86, 0
  %88 = zext i1 %87 to i64
  %89 = select i1 %87, ptr @.str.6, ptr @.str.7
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.huff_t, ptr %90, i32 0, i32 4
  %92 = load i32, ptr %91, align 4, !tbaa !15
  %93 = mul i32 %92, 16
  %94 = add i32 %93, 8
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.huff_t, ptr %95, i32 0, i32 3
  %97 = load i32, ptr %96, align 8, !tbaa !16
  %98 = add i32 %94, %97
  %99 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef %89, i32 noundef %98) #4
  br label %116

100:                                              ; preds = %80
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = load i32, ptr %8, align 4, !tbaa !9
  %103 = icmp ne i32 %102, 0
  %104 = zext i1 %103 to i64
  %105 = select i1 %103, ptr @.str.6, ptr @.str.7
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.huff_t, ptr %106, i32 0, i32 8
  %108 = load i32, ptr %107, align 4, !tbaa !17
  %109 = shl i32 %108, 3
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.huff_t, ptr %110, i32 0, i32 6
  %112 = getelementptr inbounds %struct.anon, ptr %111, i32 0, i32 0
  %113 = load i32, ptr %112, align 4, !tbaa !18
  %114 = or i32 %109, %113
  %115 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef %105, i32 noundef %114) #4
  br label %116

116:                                              ; preds = %100, %84
  br label %117

117:                                              ; preds = %116, %79
  ret void
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { noreturn 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 #4 = { nounwind }
attributes #5 = { noreturn 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 64}
!12 = !{!"huff_t", !6, i64 0, !6, i64 8, !7, i64 16, !10, i64 32, !10, i64 36, !10, i64 40, !13, i64 44, !10, i64 56, !10, i64 60, !10, i64 64}
!13 = !{!"", !10, i64 0, !10, i64 4, !14, i64 8}
!14 = !{!"float", !7, i64 0}
!15 = !{!12, !10, i64 36}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !10, i64 60}
!18 = !{!12, !10, i64 44}


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

@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__.huff_print_one = external hidden unnamed_addr constant [54 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden i32 @is_leaf(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @huff_print_one(ptr noundef %0, ptr nocapture noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp eq i32 %6, 0
  %8 = tail call i32 @is_leaf(ptr noundef nonnull %0)
  %.not26 = icmp eq i32 %8, 0
  br i1 %7, label %9, label %37

9:                                                ; preds = %4
  br i1 %.not26, label %24, label %10

10:                                               ; preds = %9
  %11 = getelementptr inbounds i8, ptr %0, i64 36
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = lshr i32 %12, 16
  %.not29 = icmp eq i32 %3, 0
  %14 = select i1 %.not29, ptr @.str.7, ptr @.str.6
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = load i32, ptr %15, align 8, !tbaa !14
  %17 = sub nsw i32 %16, %2
  %18 = shl nsw i32 %17, 8
  %19 = shl i32 %12, 4
  %20 = and i32 %19, 1048560
  %21 = add nuw nsw i32 %20, %13
  %22 = add i32 %21, %18
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull %14, i32 noundef %22) #3
  br label %56

24:                                               ; preds = %9
  %25 = getelementptr inbounds i8, ptr %0, i64 60
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %27 = icmp slt i32 %26, 8192
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.9, i32 noundef 216, ptr noundef nonnull @__PRETTY_FUNCTION__.huff_print_one) #4
  unreachable

29:                                               ; preds = %24
  %.not27 = icmp eq i32 %26, 0
  br i1 %.not27, label %30, label %31

30:                                               ; preds = %29
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.9, i32 noundef 217, ptr noundef nonnull @__PRETTY_FUNCTION__.huff_print_one) #4
  unreachable

31:                                               ; preds = %29
  %.not28 = icmp eq i32 %3, 0
  %32 = select i1 %.not28, ptr @.str.7, ptr @.str.6
  %.neg = mul i32 %26, -8
  %33 = getelementptr inbounds i8, ptr %0, i64 44
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = or i32 %34, %.neg
  %36 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull %32, i32 noundef %35) #3
  br label %56

37:                                               ; preds = %4
  %.not24 = icmp eq i32 %3, 0
  %38 = select i1 %.not24, ptr @.str.7, ptr @.str.6
  br i1 %.not26, label %48, label %39

39:                                               ; preds = %37
  %40 = getelementptr inbounds i8, ptr %0, i64 36
  %41 = load i32, ptr %40, align 4, !tbaa !13
  %42 = shl i32 %41, 4
  %43 = or disjoint i32 %42, 8
  %44 = getelementptr inbounds i8, ptr %0, i64 32
  %45 = load i32, ptr %44, align 8, !tbaa !14
  %46 = add i32 %43, %45
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull %38, i32 noundef %46) #3
  br label %56

48:                                               ; preds = %37
  %49 = getelementptr inbounds i8, ptr %0, i64 60
  %50 = load i32, ptr %49, align 4, !tbaa !15
  %51 = shl i32 %50, 3
  %52 = getelementptr inbounds i8, ptr %0, i64 44
  %53 = load i32, ptr %52, align 4, !tbaa !16
  %54 = or i32 %51, %53
  %55 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull %38, i32 noundef %54) #3
  br label %56

56:                                               ; preds = %39, %48, %10, %31
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 = { 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 #2 = { noreturn 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 #3 = { nounwind }
attributes #4 = { noreturn 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 64}
!6 = !{!"huff_t", !7, i64 0, !7, i64 8, !8, i64 16, !10, i64 32, !10, i64 36, !10, i64 40, !11, i64 44, !10, i64 56, !10, i64 60, !10, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !10, i64 0, !10, i64 4, !12, i64 8}
!12 = !{!"float", !8, i64 0}
!13 = !{!6, !10, i64 36}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !10, i64 60}
!16 = !{!6, !10, i64 44}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass