; LLVM IR from samtupy/b32tts_wrapper :: src (sonic)

; 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 void @sonicSetSpeed(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @sonicSetPitch(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @sonicSetRate(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @sonicSetVolume(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @sonicDestroyStream(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sonicCreateStream(i32 noundef, i32 noundef) #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: nounwind uwtable
declare dso_local i32 @sonicReadFloatFromStream(ptr noundef, ptr noundef, i32 noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sonicWriteFloatToStream(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @sonicChangeFloatSpeed(ptr noundef %0, i32 noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8) #0 {
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  store ptr %0, ptr %10, align 8, !tbaa !5
  store i32 %1, ptr %11, align 4, !tbaa !9
  store float %2, ptr %12, align 4, !tbaa !11
  store float %3, ptr %13, align 4, !tbaa !11
  store float %4, ptr %14, align 4, !tbaa !11
  store float %5, ptr %15, align 4, !tbaa !11
  store i32 %6, ptr %16, align 4, !tbaa !9
  store i32 %7, ptr %17, align 4, !tbaa !9
  store i32 %8, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #2
  %20 = load float, ptr %12, align 4, !tbaa !11
  %21 = fpext float %20 to double
  %22 = fcmp olt double %21, 5.000000e-02
  br i1 %22, label %23, label %24

23:                                               ; preds = %9
  br label %34

24:                                               ; preds = %9
  %25 = load float, ptr %12, align 4, !tbaa !11
  %26 = fpext float %25 to double
  %27 = fcmp ogt double %26, 2.000000e+01
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  br label %32

29:                                               ; preds = %24
  %30 = load float, ptr %12, align 4, !tbaa !11
  %31 = fpext float %30 to double
  br label %32

32:                                               ; preds = %29, %28
  %33 = phi double [ 2.000000e+01, %28 ], [ %31, %29 ]
  br label %34

34:                                               ; preds = %32, %23
  %35 = phi double [ 5.000000e-02, %23 ], [ %33, %32 ]
  %36 = fptrunc double %35 to float
  store float %36, ptr %12, align 4, !tbaa !11
  %37 = load float, ptr %13, align 4, !tbaa !11
  %38 = fpext float %37 to double
  %39 = fcmp olt double %38, 5.000000e-02
  br i1 %39, label %40, label %41

40:                                               ; preds = %34
  br label %51

41:                                               ; preds = %34
  %42 = load float, ptr %13, align 4, !tbaa !11
  %43 = fpext float %42 to double
  %44 = fcmp ogt double %43, 2.000000e+01
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  br label %49

46:                                               ; preds = %41
  %47 = load float, ptr %13, align 4, !tbaa !11
  %48 = fpext float %47 to double
  br label %49

49:                                               ; preds = %46, %45
  %50 = phi double [ 2.000000e+01, %45 ], [ %48, %46 ]
  br label %51

51:                                               ; preds = %49, %40
  %52 = phi double [ 5.000000e-02, %40 ], [ %50, %49 ]
  %53 = fptrunc double %52 to float
  store float %53, ptr %13, align 4, !tbaa !11
  %54 = load float, ptr %14, align 4, !tbaa !11
  %55 = fpext float %54 to double
  %56 = fcmp olt double %55, 5.000000e-02
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  br label %68

58:                                               ; preds = %51
  %59 = load float, ptr %14, align 4, !tbaa !11
  %60 = fpext float %59 to double
  %61 = fcmp ogt double %60, 2.000000e+01
  br i1 %61, label %62, label %63

62:                                               ; preds = %58
  br label %66

63:                                               ; preds = %58
  %64 = load float, ptr %14, align 4, !tbaa !11
  %65 = fpext float %64 to double
  br label %66

66:                                               ; preds = %63, %62
  %67 = phi double [ 2.000000e+01, %62 ], [ %65, %63 ]
  br label %68

68:                                               ; preds = %66, %57
  %69 = phi double [ 5.000000e-02, %57 ], [ %67, %66 ]
  %70 = fptrunc double %69 to float
  store float %70, ptr %14, align 4, !tbaa !11
  %71 = load float, ptr %15, align 4, !tbaa !11
  %72 = fpext float %71 to double
  %73 = fcmp olt double %72, 1.000000e-02
  br i1 %73, label %74, label %75

74:                                               ; preds = %68
  br label %85

75:                                               ; preds = %68
  %76 = load float, ptr %15, align 4, !tbaa !11
  %77 = fpext float %76 to double
  %78 = fcmp ogt double %77, 1.000000e+02
  br i1 %78, label %79, label %80

79:                                               ; preds = %75
  br label %83

80:                                               ; preds = %75
  %81 = load float, ptr %15, align 4, !tbaa !11
  %82 = fpext float %81 to double
  br label %83

83:                                               ; preds = %80, %79
  %84 = phi double [ 1.000000e+02, %79 ], [ %82, %80 ]
  br label %85

85:                                               ; preds = %83, %74
  %86 = phi double [ 1.000000e-02, %74 ], [ %84, %83 ]
  %87 = fptrunc double %86 to float
  store float %87, ptr %15, align 4, !tbaa !11
  %88 = load i32, ptr %17, align 4, !tbaa !9
  %89 = icmp slt i32 %88, 1000
  br i1 %89, label %90, label %91

90:                                               ; preds = %85
  br label %99

91:                                               ; preds = %85
  %92 = load i32, ptr %17, align 4, !tbaa !9
  %93 = icmp sgt i32 %92, 500000
  br i1 %93, label %94, label %95

94:                                               ; preds = %91
  br label %97

95:                                               ; preds = %91
  %96 = load i32, ptr %17, align 4, !tbaa !9
  br label %97

97:                                               ; preds = %95, %94
  %98 = phi i32 [ 500000, %94 ], [ %96, %95 ]
  br label %99

99:                                               ; preds = %97, %90
  %100 = phi i32 [ 1000, %90 ], [ %98, %97 ]
  store i32 %100, ptr %17, align 4, !tbaa !9
  %101 = load i32, ptr %18, align 4, !tbaa !9
  %102 = icmp slt i32 %101, 1
  br i1 %102, label %103, label %104

103:                                              ; preds = %99
  br label %112

104:                                              ; preds = %99
  %105 = load i32, ptr %18, align 4, !tbaa !9
  %106 = icmp sgt i32 %105, 32
  br i1 %106, label %107, label %108

107:                                              ; preds = %104
  br label %110

108:                                              ; preds = %104
  %109 = load i32, ptr %18, align 4, !tbaa !9
  br label %110

110:                                              ; preds = %108, %107
  %111 = phi i32 [ 32, %107 ], [ %109, %108 ]
  br label %112

112:                                              ; preds = %110, %103
  %113 = phi i32 [ 1, %103 ], [ %111, %110 ]
  store i32 %113, ptr %18, align 4, !tbaa !9
  %114 = load i32, ptr %17, align 4, !tbaa !9
  %115 = load i32, ptr %18, align 4, !tbaa !9
  %116 = call ptr @sonicCreateStream(i32 noundef %114, i32 noundef %115)
  store ptr %116, ptr %19, align 8, !tbaa !5
  %117 = load ptr, ptr %19, align 8, !tbaa !5
  %118 = load float, ptr %12, align 4, !tbaa !11
  call void @sonicSetSpeed(ptr noundef %117, float noundef %118)
  %119 = load ptr, ptr %19, align 8, !tbaa !5
  %120 = load float, ptr %13, align 4, !tbaa !11
  call void @sonicSetPitch(ptr noundef %119, float noundef %120)
  %121 = load ptr, ptr %19, align 8, !tbaa !5
  %122 = load float, ptr %14, align 4, !tbaa !11
  call void @sonicSetRate(ptr noundef %121, float noundef %122)
  %123 = load ptr, ptr %19, align 8, !tbaa !5
  %124 = load float, ptr %15, align 4, !tbaa !11
  call void @sonicSetVolume(ptr noundef %123, float noundef %124)
  %125 = load ptr, ptr %19, align 8, !tbaa !5
  %126 = load ptr, ptr %10, align 8, !tbaa !5
  %127 = load i32, ptr %11, align 4, !tbaa !9
  %128 = call i32 @sonicWriteFloatToStream(ptr noundef %125, ptr noundef %126, i32 noundef %127)
  %129 = load ptr, ptr %19, align 8, !tbaa !5
  %130 = call i32 @sonicFlushStream(ptr noundef %129)
  %131 = load ptr, ptr %19, align 8, !tbaa !5
  %132 = call i32 @sonicSamplesAvailable(ptr noundef %131)
  store i32 %132, ptr %11, align 4, !tbaa !9
  %133 = load ptr, ptr %19, align 8, !tbaa !5
  %134 = load ptr, ptr %10, align 8, !tbaa !5
  %135 = load i32, ptr %11, align 4, !tbaa !9
  %136 = call i32 @sonicReadFloatFromStream(ptr noundef %133, ptr noundef %134, i32 noundef %135)
  %137 = load ptr, ptr %19, align 8, !tbaa !5
  call void @sonicDestroyStream(ptr noundef %137)
  %138 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #2
  ret i32 %138
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !12, i64 0}
!12 = !{!"float", !7, 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: nounwind uwtable
declare dso_local void @sonicSetSpeed(ptr noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @sonicSetPitch(ptr noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @sonicSetRate(ptr noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @sonicSetVolume(ptr noundef, float noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @sonicCreateStream(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @sonicReadFloatFromStream(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sonicWriteFloatToStream(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @sonicChangeFloatSpeed(ptr noundef %0, i32 noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8) local_unnamed_addr #0 {
  %10 = fpext float %2 to double
  %11 = fcmp olt double %10, 5.000000e-02
  %12 = fcmp ogt float %2, 2.000000e+01
  %narrow.sel = select i1 %12, float 2.000000e+01, float %2
  %13 = select i1 %11, float 0x3FA99999A0000000, float %narrow.sel
  %14 = fpext float %3 to double
  %15 = fcmp olt double %14, 5.000000e-02
  %16 = fcmp ogt float %3, 2.000000e+01
  %narrow.sel40 = select i1 %16, float 2.000000e+01, float %3
  %17 = select i1 %15, float 0x3FA99999A0000000, float %narrow.sel40
  %18 = fpext float %4 to double
  %19 = fcmp olt double %18, 5.000000e-02
  %20 = fcmp ogt float %4, 2.000000e+01
  %narrow.sel41 = select i1 %20, float 2.000000e+01, float %4
  %21 = select i1 %19, float 0x3FA99999A0000000, float %narrow.sel41
  %22 = fpext float %5 to double
  %23 = fcmp olt double %22, 1.000000e-02
  %24 = fcmp ogt float %5, 1.000000e+02
  %narrow.sel42 = select i1 %24, float 1.000000e+02, float %5
  %25 = select i1 %23, float 0x3F847AE140000000, float %narrow.sel42
  %26 = tail call i32 @llvm.smin.i32(i32 %7, i32 500000)
  %27 = tail call i32 @llvm.smax.i32(i32 %26, i32 1000)
  %28 = tail call i32 @llvm.smin.i32(i32 %8, i32 32)
  %29 = tail call i32 @llvm.smax.i32(i32 %28, i32 1)
  %30 = tail call ptr @sonicCreateStream(i32 noundef %27, i32 noundef %29)
  tail call void @sonicSetSpeed(ptr noundef %30, float noundef %13)
  tail call void @sonicSetPitch(ptr noundef %30, float noundef %17)
  tail call void @sonicSetRate(ptr noundef %30, float noundef %21)
  tail call void @sonicSetVolume(ptr noundef %30, float noundef %25)
  %31 = tail call i32 @sonicWriteFloatToStream(ptr noundef %30, ptr noundef %0, i32 noundef %1)
  %32 = tail call i32 @sonicFlushStream(ptr noundef %30)
  %33 = tail call i32 @sonicSamplesAvailable(ptr noundef %30)
  %34 = tail call i32 @sonicReadFloatFromStream(ptr noundef %30, ptr noundef %0, i32 noundef %33)
  tail call void @sonicDestroyStream(ptr noundef %30)
  ret i32 %33
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass