; LLVM IR from suxiaojack/sapDecoder :: src/hrtf.ll (ZNK4HRTF15GetLeftFreqHRTFEv)

; 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.HRTFDataT = type { %"class.std::__cxx11::basic_string", i32, i32, i32, ptr, float, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%class.HRTF = type { ptr, i32, i32, ptr, i32, i8, float, float, i32, %"class.std::vector", %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<std::vector<float>, std::vector<float>>, std::allocator<std::pair<std::vector<float>, std::vector<float>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<std::vector<float>, std::vector<float>>, std::allocator<std::pair<std::vector<float>, std::vector<float>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<std::vector<float>, std::vector<float>>, std::allocator<std::pair<std::vector<float>, std::vector<float>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<std::vector<float>, std::vector<float>>, std::allocator<std::pair<std::vector<float>, std::vector<float>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { %"class.std::vector.13", %"class.std::vector.13" }
%"class.std::vector.13" = type { %"struct.std::_Vector_base.14" }
%"struct.std::_Vector_base.14" = 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 }

@_ZL12kHRTFDataSet = external hidden global %struct.HRTFDataT, align 8
@.str.2 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [57 x i8], align 1
@__PRETTY_FUNCTION__._ZNK4HRTF15GetLeftFreqHRTFEv = external hidden unnamed_addr constant [51 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorISt4pairIS_IfSaIfEES2_ESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK4HRTF15GetLeftFreqHRTFEv(ptr noundef nonnull align 8 dereferenceable(96) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.HRTF, ptr %3, i32 0, i32 4
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = icmp sge i32 %5, 0
  br i1 %6, label %7, label %12

7:                                                ; preds = %1
  %8 = getelementptr inbounds %class.HRTF, ptr %3, i32 0, i32 4
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = load i32, ptr getelementptr inbounds (%struct.HRTFDataT, ptr @_ZL12kHRTFDataSet, i32 0, i32 1), align 8, !tbaa !18
  %11 = icmp slt i32 %9, %10
  br label %12

12:                                               ; preds = %7, %1
  %13 = phi i1 [ false, %1 ], [ %11, %7 ]
  br i1 %13, label %14, label %15

14:                                               ; preds = %12
  br label %17

15:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 97, ptr noundef @__PRETTY_FUNCTION__._ZNK4HRTF15GetLeftFreqHRTFEv) #2
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  %18 = getelementptr inbounds %class.HRTF, ptr %3, i32 0, i32 5
  %19 = load i8, ptr %18, align 4, !tbaa !23, !range !24, !noundef !25
  %20 = trunc i8 %19 to i1
  br i1 %20, label %21, label %28

21:                                               ; preds = %17
  %22 = getelementptr inbounds %class.HRTF, ptr %3, i32 0, i32 10
  %23 = getelementptr inbounds %class.HRTF, ptr %3, i32 0, i32 4
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorISt4pairIS_IfSaIfEES2_ESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef %25) #3
  %27 = getelementptr inbounds %"struct.std::pair", ptr %26, i32 0, i32 1
  br label %35

28:                                               ; preds = %17
  %29 = getelementptr inbounds %class.HRTF, ptr %3, i32 0, i32 10
  %30 = getelementptr inbounds %class.HRTF, ptr %3, i32 0, i32 4
  %31 = load i32, ptr %30, align 8, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorISt4pairIS_IfSaIfEES2_ESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %32) #3
  %34 = getelementptr inbounds %"struct.std::pair", ptr %33, i32 0, i32 0
  br label %35

35:                                               ; preds = %28, %21
  %36 = phi ptr [ %27, %21 ], [ %34, %28 ]
  ret ptr %36
}

attributes #0 = { 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 #1 = { mustprogress 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 = { noreturn nounwind }
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++ TBAA"}
!9 = !{!10, !11, i64 24}
!10 = !{!"_ZTS4HRTF", !11, i64 8, !11, i64 12, !6, i64 16, !11, i64 24, !12, i64 28, !13, i64 32, !13, i64 36, !11, i64 40, !14, i64 48, !14, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_ZTSSt6vectorISt4pairIS_IfSaIfEES2_ESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseISt4pairISt6vectorIfSaIfEES3_ESaIS4_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt4pairISt6vectorIfSaIfEES3_ESaIS4_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt4pairISt6vectorIfSaIfEES3_ESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!19, !11, i64 32}
!19 = !{!"_ZTS9HRTFDataT", !20, i64 0, !11, i64 32, !11, i64 36, !11, i64 40, !6, i64 48, !13, i64 56, !6, i64 64}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !21, i64 0, !22, i64 8, !7, i64 16}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!10, !12, i64 28}
!24 = !{i8 0, i8 2}
!25 = !{}


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

%struct.HRTFDataT = type { %"class.std::__cxx11::basic_string", i32, i32, i32, ptr, float, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@_ZL12kHRTFDataSet = external hidden local_unnamed_addr global %struct.HRTFDataT, align 8
@.str.2 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [57 x i8], align 1
@__PRETTY_FUNCTION__._ZNK4HRTF15GetLeftFreqHRTFEv = external hidden unnamed_addr constant [51 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorISt4pairIS_IfSaIfEES2_ESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK4HRTF15GetLeftFreqHRTFEv(ptr noundef nonnull align 8 dereferenceable(96) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, -1
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL12kHRTFDataSet, i64 32), align 8
  %6 = icmp slt i32 %3, %5
  %or.cond = select i1 %4, i1 %6, i1 false
  br i1 %or.cond, label %7, label %.critedge

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

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 28
  %9 = load i8, ptr %8, align 4, !tbaa !17, !range !18, !noundef !19
  %10 = trunc nuw i8 %9 to i1
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  %12 = zext nneg i32 %3 to i64
  %13 = tail call noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorISt4pairIS_IfSaIfEES2_ESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %12) #3
  %.idx = select i1 %10, i64 24, i64 0
  %14 = getelementptr inbounds i8, ptr %13, i64 %.idx
  ret ptr %14
}

attributes #0 = { 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 #1 = { mustprogress 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 = { noreturn nounwind }
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, !7, i64 24}
!6 = !{!"_ZTS4HRTF", !7, i64 8, !7, i64 12, !10, i64 16, !7, i64 24, !11, i64 28, !12, i64 32, !12, i64 36, !7, i64 40, !13, i64 48, !13, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = !{!"_ZTSSt6vectorISt4pairIS_IfSaIfEES2_ESaIS3_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseISt4pairISt6vectorIfSaIfEES3_ESaIS4_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseISt4pairISt6vectorIfSaIfEES3_ESaIS4_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt4pairISt6vectorIfSaIfEES3_ESaIS4_EE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!17 = !{!6, !11, i64 28}
!18 = !{i8 0, i8 2}
!19 = !{}


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