; LLVM IR from jgaeddert/liquid-dsp :: src/audio/src (cvsd)

; 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.cvsd_s = type { i32, i8, i8, float, float, float, float, float, float, float, ptr, ptr }

; 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

declare i32 @iirfilt_rrrf_execute(ptr noundef, float noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local float @cvsd_decode(ptr noundef %0, i8 noundef zeroext %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.cvsd_s, ptr %6, i32 0, i32 1
  %8 = load i8, ptr %7, align 4, !tbaa !10
  %9 = zext i8 %8 to i32
  %10 = shl i32 %9, 1
  %11 = trunc i32 %10 to i8
  store i8 %11, ptr %7, align 4, !tbaa !10
  %12 = load i8, ptr %4, align 1, !tbaa !9
  %13 = zext i8 %12 to i32
  %14 = and i32 %13, 1
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.cvsd_s, ptr %15, i32 0, i32 1
  %17 = load i8, ptr %16, align 4, !tbaa !10
  %18 = zext i8 %17 to i32
  %19 = or i32 %18, %14
  %20 = trunc i32 %19 to i8
  store i8 %20, ptr %16, align 4, !tbaa !10
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.cvsd_s, ptr %21, i32 0, i32 2
  %23 = load i8, ptr %22, align 1, !tbaa !14
  %24 = zext i8 %23 to i32
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.cvsd_s, ptr %25, i32 0, i32 1
  %27 = load i8, ptr %26, align 4, !tbaa !10
  %28 = zext i8 %27 to i32
  %29 = and i32 %28, %24
  %30 = trunc i32 %29 to i8
  store i8 %30, ptr %26, align 4, !tbaa !10
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.cvsd_s, ptr %31, i32 0, i32 1
  %33 = load i8, ptr %32, align 4, !tbaa !10
  %34 = zext i8 %33 to i32
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %46, label %36

36:                                               ; preds = %2
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.cvsd_s, ptr %37, i32 0, i32 1
  %39 = load i8, ptr %38, align 4, !tbaa !10
  %40 = zext i8 %39 to i32
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.cvsd_s, ptr %41, i32 0, i32 2
  %43 = load i8, ptr %42, align 1, !tbaa !14
  %44 = zext i8 %43 to i32
  %45 = icmp eq i32 %40, %44
  br i1 %45, label %46, label %54

46:                                               ; preds = %36, %2
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.cvsd_s, ptr %47, i32 0, i32 4
  %49 = load float, ptr %48, align 4, !tbaa !15
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.cvsd_s, ptr %50, i32 0, i32 5
  %52 = load float, ptr %51, align 8, !tbaa !16
  %53 = fmul float %52, %49
  store float %53, ptr %51, align 8, !tbaa !16
  br label %62

54:                                               ; preds = %36
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.cvsd_s, ptr %55, i32 0, i32 4
  %57 = load float, ptr %56, align 4, !tbaa !15
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.cvsd_s, ptr %58, i32 0, i32 5
  %60 = load float, ptr %59, align 8, !tbaa !16
  %61 = fdiv float %60, %57
  store float %61, ptr %59, align 8, !tbaa !16
  br label %62

62:                                               ; preds = %54, %46
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.cvsd_s, ptr %63, i32 0, i32 5
  %65 = load float, ptr %64, align 8, !tbaa !16
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.cvsd_s, ptr %66, i32 0, i32 7
  %68 = load float, ptr %67, align 8, !tbaa !17
  %69 = fcmp ogt float %65, %68
  br i1 %69, label %70, label %74

70:                                               ; preds = %62
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.cvsd_s, ptr %71, i32 0, i32 7
  %73 = load float, ptr %72, align 8, !tbaa !17
  br label %78

74:                                               ; preds = %62
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.cvsd_s, ptr %75, i32 0, i32 5
  %77 = load float, ptr %76, align 8, !tbaa !16
  br label %78

78:                                               ; preds = %74, %70
  %79 = phi float [ %73, %70 ], [ %77, %74 ]
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.cvsd_s, ptr %80, i32 0, i32 5
  store float %79, ptr %81, align 8, !tbaa !16
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.cvsd_s, ptr %82, i32 0, i32 5
  %84 = load float, ptr %83, align 8, !tbaa !16
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.cvsd_s, ptr %85, i32 0, i32 6
  %87 = load float, ptr %86, align 4, !tbaa !18
  %88 = fcmp olt float %84, %87
  br i1 %88, label %89, label %93

89:                                               ; preds = %78
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.cvsd_s, ptr %90, i32 0, i32 6
  %92 = load float, ptr %91, align 4, !tbaa !18
  br label %97

93:                                               ; preds = %78
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.cvsd_s, ptr %94, i32 0, i32 5
  %96 = load float, ptr %95, align 8, !tbaa !16
  br label %97

97:                                               ; preds = %93, %89
  %98 = phi float [ %92, %89 ], [ %96, %93 ]
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.cvsd_s, ptr %99, i32 0, i32 5
  store float %98, ptr %100, align 8, !tbaa !16
  %101 = load i8, ptr %4, align 1, !tbaa !9
  %102 = zext i8 %101 to i32
  %103 = and i32 %102, 1
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %105, label %109

105:                                              ; preds = %97
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.cvsd_s, ptr %106, i32 0, i32 5
  %108 = load float, ptr %107, align 8, !tbaa !16
  br label %114

109:                                              ; preds = %97
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.cvsd_s, ptr %110, i32 0, i32 5
  %112 = load float, ptr %111, align 8, !tbaa !16
  %113 = fneg float %112
  br label %114

114:                                              ; preds = %109, %105
  %115 = phi float [ %108, %105 ], [ %113, %109 ]
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.cvsd_s, ptr %116, i32 0, i32 3
  %118 = load float, ptr %117, align 8, !tbaa !19
  %119 = fadd float %118, %115
  store float %119, ptr %117, align 8, !tbaa !19
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.cvsd_s, ptr %120, i32 0, i32 3
  %122 = load float, ptr %121, align 8, !tbaa !19
  %123 = fcmp ogt float %122, 1.000000e+00
  br i1 %123, label %124, label %125

124:                                              ; preds = %114
  br label %129

125:                                              ; preds = %114
  %126 = load ptr, ptr %3, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.cvsd_s, ptr %126, i32 0, i32 3
  %128 = load float, ptr %127, align 8, !tbaa !19
  br label %129

129:                                              ; preds = %125, %124
  %130 = phi float [ 1.000000e+00, %124 ], [ %128, %125 ]
  %131 = load ptr, ptr %3, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.cvsd_s, ptr %131, i32 0, i32 3
  store float %130, ptr %132, align 8, !tbaa !19
  %133 = load ptr, ptr %3, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.cvsd_s, ptr %133, i32 0, i32 3
  %135 = load float, ptr %134, align 8, !tbaa !19
  %136 = fcmp olt float %135, -1.000000e+00
  br i1 %136, label %137, label %138

137:                                              ; preds = %129
  br label %142

138:                                              ; preds = %129
  %139 = load ptr, ptr %3, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.cvsd_s, ptr %139, i32 0, i32 3
  %141 = load float, ptr %140, align 8, !tbaa !19
  br label %142

142:                                              ; preds = %138, %137
  %143 = phi float [ -1.000000e+00, %137 ], [ %141, %138 ]
  %144 = load ptr, ptr %3, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.cvsd_s, ptr %144, i32 0, i32 3
  store float %143, ptr %145, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %146 = load ptr, ptr %3, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.cvsd_s, ptr %146, i32 0, i32 11
  %148 = load ptr, ptr %147, align 8, !tbaa !20
  %149 = load ptr, ptr %3, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.cvsd_s, ptr %149, i32 0, i32 3
  %151 = load float, ptr %150, align 8, !tbaa !19
  %152 = call i32 @iirfilt_rrrf_execute(ptr noundef %148, float noundef %151, ptr noundef %5)
  %153 = load float, ptr %5, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret float %153
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 4}
!11 = !{!"cvsd_s", !12, i64 0, !7, i64 4, !7, i64 5, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !6, i64 40, !6, i64 48}
!12 = !{!"int", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!11, !7, i64 5}
!15 = !{!11, !13, i64 12}
!16 = !{!11, !13, i64 16}
!17 = !{!11, !13, i64 24}
!18 = !{!11, !13, i64 20}
!19 = !{!11, !13, i64 8}
!20 = !{!11, !6, i64 48}
!21 = !{!13, !13, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

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

declare i32 @iirfilt_rrrf_execute(ptr noundef, float noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local float @cvsd_decode(ptr nocapture noundef %0, i8 noundef zeroext %1) local_unnamed_addr #2 {
  %3 = alloca float, align 4
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i8, ptr %4, align 4, !tbaa !5
  %6 = shl i8 %5, 1
  %7 = and i8 %1, 1
  %8 = or disjoint i8 %6, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 5
  %10 = load i8, ptr %9, align 1, !tbaa !12
  %11 = and i8 %8, %10
  store i8 %11, ptr %4, align 4, !tbaa !5
  %12 = icmp eq i8 %11, 0
  %13 = icmp eq i8 %11, %10
  %or.cond = or i1 %12, %13
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  %15 = load float, ptr %14, align 4, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load float, ptr %16, align 8, !tbaa !14
  %18 = fdiv float %17, %15
  %19 = fmul float %15, %17
  %20 = select i1 %or.cond, float %19, float %18
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load float, ptr %22, align 8, !tbaa !15
  %24 = fcmp ogt float %20, %23
  %. = select i1 %24, float %23, float %20
  %25 = getelementptr inbounds i8, ptr %0, i64 20
  %26 = load float, ptr %25, align 4, !tbaa !16
  %27 = fcmp olt float %., %26
  %28 = select i1 %27, float %26, float %.
  store float %28, ptr %21, align 8, !tbaa !14
  %.not = icmp eq i8 %7, 0
  %29 = fneg float %28
  %30 = select i1 %.not, float %29, float %28
  %31 = getelementptr inbounds i8, ptr %0, i64 8
  %32 = load float, ptr %31, align 8, !tbaa !17
  %33 = fadd float %32, %30
  %34 = fcmp ogt float %33, 1.000000e+00
  %35 = select i1 %34, float 1.000000e+00, float %33
  %36 = fcmp olt float %35, -1.000000e+00
  %37 = select i1 %36, float -1.000000e+00, float %35
  store float %37, ptr %31, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %38 = getelementptr inbounds i8, ptr %0, i64 48
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  %40 = call i32 @iirfilt_rrrf_execute(ptr noundef %39, float noundef %37, ptr noundef nonnull %3) #3
  %41 = load float, ptr %3, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret float %41
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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, !8, i64 4}
!6 = !{!"cvsd_s", !7, i64 0, !8, i64 4, !8, i64 5, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !11, i64 40, !11, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !8, i64 5}
!13 = !{!6, !10, i64 12}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 24}
!16 = !{!6, !10, i64 20}
!17 = !{!6, !10, i64 8}
!18 = !{!6, !11, i64 48}
!19 = !{!10, !10, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass