; LLVM IR from suxiaojack/sapDecoder :: src/sapdecoder.ll (ZN10SAPDecoder12SetDirectionEfff)

; 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.SAPDecoder = type { ptr, float, float, float, float, i32, i32, [2 x float], %"class.std::vector", %"class.std::vector", ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__._ZN10SAPDecoder12SetDirectionEfff = external hidden unnamed_addr constant [51 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: mustprogress uwtable
define dso_local void @_ZN10SAPDecoder12SetDirectionEfff(ptr noundef nonnull align 8 dereferenceable(144) %0, float noundef %1, float noundef %2, float noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8
  %11 = load float, ptr %6, align 4, !tbaa !9
  %12 = getelementptr inbounds %class.SAPDecoder, ptr %10, i32 0, i32 1
  store float %11, ptr %12, align 8, !tbaa !11
  %13 = load float, ptr %7, align 4, !tbaa !9
  %14 = getelementptr inbounds %class.SAPDecoder, ptr %10, i32 0, i32 2
  store float %13, ptr %14, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %15 = getelementptr inbounds %class.SAPDecoder, ptr %10, i32 0, i32 10
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  %17 = call noundef float @_ZNK4HRTF11GetDistanceEv(ptr noundef nonnull align 8 dereferenceable(96) %16)
  store float %17, ptr %9, align 4, !tbaa !9
  %18 = load float, ptr %8, align 4, !tbaa !9
  %19 = load float, ptr %9, align 4, !tbaa !9
  %20 = fcmp ogt float %18, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %4
  %22 = load float, ptr %8, align 4, !tbaa !9
  br label %25

23:                                               ; preds = %4
  %24 = load float, ptr %9, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %23, %21
  %26 = phi float [ %22, %21 ], [ %24, %23 ]
  %27 = getelementptr inbounds %class.SAPDecoder, ptr %10, i32 0, i32 3
  store float %26, ptr %27, align 8, !tbaa !20
  %28 = load float, ptr %9, align 4, !tbaa !9
  %29 = getelementptr inbounds %class.SAPDecoder, ptr %10, i32 0, i32 3
  %30 = load float, ptr %29, align 8, !tbaa !20
  %31 = fdiv float %28, %30
  %32 = getelementptr inbounds %class.SAPDecoder, ptr %10, i32 0, i32 4
  store float %31, ptr %32, align 4, !tbaa !21
  %33 = getelementptr inbounds %class.SAPDecoder, ptr %10, i32 0, i32 4
  %34 = load float, ptr %33, align 4, !tbaa !21
  %35 = fcmp oge float %34, 0.000000e+00
  br i1 %35, label %36, label %40

36:                                               ; preds = %25
  %37 = getelementptr inbounds %class.SAPDecoder, ptr %10, i32 0, i32 4
  %38 = load float, ptr %37, align 4, !tbaa !21
  %39 = fcmp ole float %38, 1.000000e+00
  br label %40

40:                                               ; preds = %36, %25
  %41 = phi i1 [ false, %25 ], [ %39, %36 ]
  br i1 %41, label %42, label %43

42:                                               ; preds = %40
  br label %45

43:                                               ; preds = %40
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 103, ptr noundef @__PRETTY_FUNCTION__._ZN10SAPDecoder12SetDirectionEfff) #5
  unreachable

44:                                               ; No predecessors!
  br label %45

45:                                               ; preds = %44, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

declare noundef float @_ZNK4HRTF11GetDistanceEv(ptr noundef nonnull align 8 dereferenceable(96)) #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 = { mustprogress 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 = { "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS10SAPDecoder", !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 28, !7, i64 32, !14, i64 40, !14, i64 64, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSSt6vectorIfSaIfEE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!12, !10, i64 12}
!19 = !{!12, !6, i64 88}
!20 = !{!12, !10, i64 16}
!21 = !{!12, !10, i64 20}


; 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 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__._ZN10SAPDecoder12SetDirectionEfff = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10SAPDecoder12SetDirectionEfff(ptr nocapture noundef nonnull align 8 dereferenceable(144) %0, float noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store float %1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  store float %2, ptr %6, align 4, !tbaa !16
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  %8 = load ptr, ptr %7, align 8, !tbaa !17
  %9 = tail call noundef float @_ZNK4HRTF11GetDistanceEv(ptr noundef nonnull align 8 dereferenceable(96) %8)
  %10 = fcmp olt float %9, %3
  %11 = select i1 %10, float %3, float %9
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  store float %11, ptr %12, align 8, !tbaa !18
  %13 = fdiv float %9, %11
  %14 = getelementptr inbounds i8, ptr %0, i64 20
  store float %13, ptr %14, align 4, !tbaa !19
  %15 = fcmp ult float %13, 0.000000e+00
  %16 = fcmp ugt float %13, 1.000000e+00
  %or.cond = or i1 %15, %16
  br i1 %or.cond, label %.critedge, label %17

.critedge:                                        ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 103, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN10SAPDecoder12SetDirectionEfff) #3
  unreachable

17:                                               ; preds = %4
  ret void
}

declare noundef float @_ZNK4HRTF11GetDistanceEv(ptr noundef nonnull align 8 dereferenceable(96)) 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 = { mustprogress 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 = { "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 = { 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, !7, i64 8}
!6 = !{!"_ZTS10SAPDecoder", !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 28, !8, i64 32, !11, i64 40, !11, i64 64, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112, !15, i64 120, !15, i64 128, !15, i64 136}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSSt6vectorIfSaIfEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!6, !7, i64 12}
!17 = !{!6, !15, i64 88}
!18 = !{!6, !7, i64 16}
!19 = !{!6, !7, i64 20}


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