; LLVM IR from dbry/wavpack-stream :: src (entropy_utils)

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @wp_exp2s(i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @wp_exp2_schar(i8 noundef signext %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  store i8 %0, ptr %3, align 1, !tbaa !5
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %5 = sext i8 %4 to i32
  %6 = icmp slt i32 %5, 0
  br i1 %6, label %7, label %22

7:                                                ; preds = %1
  %8 = load i8, ptr %3, align 1, !tbaa !5
  %9 = sext i8 %8 to i32
  %10 = icmp sge i32 %9, -16
  br i1 %10, label %11, label %14

11:                                               ; preds = %7
  %12 = load i8, ptr %3, align 1, !tbaa !5
  %13 = sext i8 %12 to i32
  br label %20

14:                                               ; preds = %7
  %15 = load i8, ptr %3, align 1, !tbaa !5
  %16 = sext i8 %15 to i32
  %17 = sub nsw i32 %16, 4
  %18 = mul nsw i32 %17, 64
  %19 = call i32 @wp_exp2s(i32 noundef %18)
  br label %20

20:                                               ; preds = %14, %11
  %21 = phi i32 [ %13, %11 ], [ %19, %14 ]
  store i32 %21, ptr %2, align 4
  br label %37

22:                                               ; preds = %1
  %23 = load i8, ptr %3, align 1, !tbaa !5
  %24 = sext i8 %23 to i32
  %25 = icmp sle i32 %24, 16
  br i1 %25, label %26, label %29

26:                                               ; preds = %22
  %27 = load i8, ptr %3, align 1, !tbaa !5
  %28 = sext i8 %27 to i32
  br label %35

29:                                               ; preds = %22
  %30 = load i8, ptr %3, align 1, !tbaa !5
  %31 = sext i8 %30 to i32
  %32 = add nsw i32 %31, 4
  %33 = mul nsw i32 %32, 64
  %34 = call i32 @wp_exp2s(i32 noundef %33)
  br label %35

35:                                               ; preds = %29, %26
  %36 = phi i32 [ %28, %26 ], [ %34, %29 ]
  store i32 %36, ptr %2, align 4
  br label %37

37:                                               ; preds = %35, %20
  %38 = load i32, ptr %2, align 4
  ret i32 %38
}

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

!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/C++ TBAA"}


; 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: nounwind uwtable
declare dso_local i32 @wp_exp2s(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @wp_exp2_schar(i8 noundef signext %0) local_unnamed_addr #0 {
  %2 = sext i8 %0 to i32
  %3 = icmp slt i8 %0, 0
  br i1 %3, label %4, label %6

4:                                                ; preds = %1
  %5 = icmp ugt i8 %0, -17
  br i1 %5, label %11, label %.sink.split

6:                                                ; preds = %1
  %7 = icmp ult i8 %0, 17
  br i1 %7, label %11, label %.sink.split

.sink.split:                                      ; preds = %6, %4
  %.sink10 = phi i32 [ -256, %4 ], [ 256, %6 ]
  %8 = shl nsw i32 %2, 6
  %9 = add nsw i32 %8, %.sink10
  %10 = tail call i32 @wp_exp2s(i32 noundef %9)
  br label %11

11:                                               ; preds = %.sink.split, %6, %4
  %.0 = phi i32 [ %2, %4 ], [ %2, %6 ], [ %10, %.sink.split ]
  ret i32 %.0
}

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

!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)"}


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