; LLVM IR from ImperialCollegeLondon/pnflow :: src/pnm/pnflow/Element.ll (ZNK6Throat9indexOrenEv)

; 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.Throat = type { %class.Elem, i32, [2 x ptr], %"struct.std::array", double }
%class.Elem = type { %class.Apex, [5 x %class.SlvrElm], i8, i32, ptr, double, double, i32, %"class.std::vector", ptr, double, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, %"struct.std::pair", %"struct.std::pair", %"struct.std::pair", i32, i32, i32, i32, %class.var3 }
%class.Apex = type { ptr, i8, double, double, ptr, i32, double, double, double, double, i8, i8, i8, i8, %"struct.std::pair" }
%class.SlvrElm = type { i8, i8, i8, double, double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl" }
%"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, double }
%class.var3 = type { double, double, double }
%"struct.std::array" = type { [2 x double] }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK6Throat9indexOrenEv(ptr noundef nonnull align 8 dereferenceable(456) %0) unnamed_addr #0 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.Throat, ptr %3, i32 0, i32 1
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %class.Elem, ptr %3, i32 0, i32 4
  %7 = load ptr, ptr %6, align 8, !tbaa !23
  %8 = call noundef i32 @_ZNK10CommonData8numPoresEv(ptr noundef nonnull align 8 dereferenceable(1972) %7)
  %9 = sub nsw i32 %5, %8
  %10 = sub nsw i32 %9, 1
  ret i32 %10
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK10CommonData8numPoresEv(ptr noundef nonnull align 8 dereferenceable(1972)) #1 align 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 = { 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" }

!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, !15, i64 408}
!10 = !{!"_ZTS6Throat", !11, i64 0, !15, i64 408, !7, i64 416, !22, i64 432, !14, i64 448}
!11 = !{!"_ZTS4Elem", !12, i64 0, !7, i64 104, !13, i64 224, !15, i64 228, !6, i64 232, !14, i64 240, !14, i64 248, !15, i64 256, !17, i64 264, !6, i64 288, !14, i64 296, !13, i64 304, !13, i64 305, !13, i64 306, !13, i64 307, !13, i64 308, !13, i64 309, !13, i64 310, !13, i64 311, !13, i64 312, !13, i64 313, !16, i64 320, !16, i64 336, !16, i64 352, !15, i64 368, !15, i64 372, !15, i64 376, !15, i64 380, !21, i64 384}
!12 = !{!"_ZTS4Apex", !13, i64 8, !14, i64 16, !14, i64 24, !6, i64 32, !15, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !13, i64 80, !13, i64 81, !13, i64 82, !13, i64 83, !16, i64 88}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSSt4pairIidE", !15, i64 0, !14, i64 8}
!17 = !{!"_ZTSSt6vectorIP4ElemSaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIP4ElemSaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIP4ElemSaIS1_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIP4ElemSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTS4var3IdE", !14, i64 0, !14, i64 8, !14, i64 16}
!22 = !{!"_ZTSSt5arrayIdLm2EE", !7, i64 0}
!23 = !{!11, !6, i64 232}


; 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 nounwind uwtable
define dso_local noundef range(i32 -2147483648, 2147483647) i32 @_ZNK6Throat9indexOrenEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(456) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 408
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 232
  %5 = load ptr, ptr %4, align 8, !tbaa !22
  %6 = tail call noundef i32 @_ZNK10CommonData8numPoresEv(ptr noundef nonnull align 8 dereferenceable(1972) %5)
  %7 = xor i32 %6, -1
  %8 = add i32 %3, %7
  ret i32 %8
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK10CommonData8numPoresEv(ptr noundef nonnull align 8 dereferenceable(1972)) local_unnamed_addr #0 align 2

attributes #0 = { 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" }

!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, !14, i64 408}
!6 = !{!"_ZTS6Throat", !7, i64 0, !14, i64 408, !10, i64 416, !21, i64 432, !12, i64 448}
!7 = !{!"_ZTS4Elem", !8, i64 0, !10, i64 104, !9, i64 224, !14, i64 228, !13, i64 232, !12, i64 240, !12, i64 248, !14, i64 256, !16, i64 264, !13, i64 288, !12, i64 296, !9, i64 304, !9, i64 305, !9, i64 306, !9, i64 307, !9, i64 308, !9, i64 309, !9, i64 310, !9, i64 311, !9, i64 312, !9, i64 313, !15, i64 320, !15, i64 336, !15, i64 352, !14, i64 368, !14, i64 372, !14, i64 376, !14, i64 380, !20, i64 384}
!8 = !{!"_ZTS4Apex", !9, i64 8, !12, i64 16, !12, i64 24, !13, i64 32, !14, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !9, i64 80, !9, i64 81, !9, i64 82, !9, i64 83, !15, i64 88}
!9 = !{!"bool", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"double", !10, i64 0}
!13 = !{!"any pointer", !10, i64 0}
!14 = !{!"int", !10, i64 0}
!15 = !{!"_ZTSSt4pairIidE", !14, i64 0, !12, i64 8}
!16 = !{!"_ZTSSt6vectorIP4ElemSaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIP4ElemSaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIP4ElemSaIS1_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIP4ElemSaIS1_EE17_Vector_impl_dataE", !13, i64 0, !13, i64 8, !13, i64 16}
!20 = !{!"_ZTS4var3IdE", !12, i64 0, !12, i64 8, !12, i64 16}
!21 = !{!"_ZTSSt5arrayIdLm2EE", !10, i64 0}
!22 = !{!7, !13, i64 232}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass