; LLVM IR from sp-nitech/SPTK :: src/input (input_source_from_matrix)

; 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.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.sptk::InputSourceFromMatrix" = type <{ %"class.sptk::InputSourceInterface", i32, i32, ptr, i32, i8, [3 x i8] }>
%"class.sptk::InputSourceInterface" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4sptk21InputSourceFromMatrix3GetEPSt6vectorIdSaIdEE(ptr noundef nonnull align 8 dereferenceable(29) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp eq ptr null, %9
  br i1 %10, label %21, label %11

11:                                               ; preds = %2
  %12 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 5
  %13 = load i8, ptr %12, align 4, !tbaa !9, !range !14, !noundef !15
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %21

15:                                               ; preds = %11
  %16 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 2
  %17 = load i32, ptr %16, align 4, !tbaa !16
  %18 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 4
  %19 = load i32, ptr %18, align 8, !tbaa !17
  %20 = icmp sle i32 %17, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %15, %11, %2
  store i1 false, ptr %3, align 1
  br label %64

22:                                               ; preds = %15
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #3
  %25 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 1
  %26 = load i32, ptr %25, align 8, !tbaa !18
  %27 = sext i32 %26 to i64
  %28 = icmp ne i64 %24, %27
  br i1 %28, label %29, label %34

29:                                               ; preds = %22
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 1
  %32 = load i32, ptr %31, align 8, !tbaa !18
  %33 = sext i32 %32 to i64
  call void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %33)
  br label %34

34:                                               ; preds = %29, %22
  %35 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !19
  %37 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 4
  %38 = load i32, ptr %37, align 8, !tbaa !17
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds ptr, ptr %36, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = getelementptr inbounds double, ptr %41, i64 0
  %43 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 4
  %46 = load i32, ptr %45, align 8, !tbaa !17
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds ptr, ptr %44, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !18
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds double, ptr %49, i64 %52
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = call ptr @_ZNSt6vectorIdSaIdEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %54) #3
  %56 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  store ptr %55, ptr %56, align 8
  %57 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8
  %59 = call ptr @_ZSt4copyIPdN9__gnu_cxx17__normal_iteratorIS0_St6vectorIdSaIdEEEEET0_T_S8_S7_(ptr noundef %42, ptr noundef %53, ptr %58)
  %60 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %59, ptr %60, align 8
  %61 = getelementptr inbounds %"class.sptk::InputSourceFromMatrix", ptr %8, i32 0, i32 4
  %62 = load i32, ptr %61, align 8, !tbaa !17
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %61, align 8, !tbaa !17
  store i1 true, ptr %3, align 1
  br label %64

64:                                               ; preds = %34, %21
  %65 = load i1, ptr %3, align 1
  ret i1 %65
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4copyIPdN9__gnu_cxx17__normal_iteratorIS0_St6vectorIdSaIdEEEEET0_T_S8_S7_(ptr noundef, ptr noundef, ptr) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIdSaIdEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #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" }
attributes #2 = { inlinehint 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 #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, !13, i64 28}
!10 = !{!"_ZTSN4sptk21InputSourceFromMatrixE", !11, i64 0, !12, i64 8, !12, i64 12, !6, i64 16, !12, i64 24, !13, i64 28}
!11 = !{!"_ZTSN4sptk20InputSourceInterfaceE"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !12, i64 12}
!17 = !{!10, !12, i64 24}
!18 = !{!10, !12, i64 8}
!19 = !{!10, !6, i64 16}


; 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 uwtable
define dso_local noundef zeroext i1 @_ZN4sptk21InputSourceFromMatrix3GetEPSt6vectorIdSaIdEE(ptr nocapture noundef nonnull align 8 dereferenceable(29) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = icmp eq ptr %1, null
  br i1 %3, label %31, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 28
  %6 = load i8, ptr %5, align 4, !tbaa !5, !range !13, !noundef !14
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %31

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = load i32, ptr %9, align 4, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load i32, ptr %11, align 8, !tbaa !16
  %.not = icmp sgt i32 %10, %12
  br i1 %.not, label %13, label %31

13:                                               ; preds = %8
  %14 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !17
  %17 = sext i32 %16 to i64
  %.not9 = icmp eq i64 %14, %17
  br i1 %.not9, label %19, label %18

18:                                               ; preds = %13
  tail call void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %17)
  %.pre = load i32, ptr %15, align 8, !tbaa !17
  %.pre10 = sext i32 %.pre to i64
  br label %19

19:                                               ; preds = %18, %13
  %.pre-phi = phi i64 [ %.pre10, %18 ], [ %17, %13 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = load i32, ptr %11, align 8, !tbaa !16
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds ptr, ptr %21, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !19
  %26 = getelementptr inbounds double, ptr %25, i64 %.pre-phi
  %27 = tail call ptr @_ZNSt6vectorIdSaIdEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %28 = tail call ptr @_ZSt4copyIPdN9__gnu_cxx17__normal_iteratorIS0_St6vectorIdSaIdEEEEET0_T_S8_S7_(ptr noundef %25, ptr noundef %26, ptr %27)
  %29 = load i32, ptr %11, align 8, !tbaa !16
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %11, align 8, !tbaa !16
  br label %31

31:                                               ; preds = %2, %4, %8, %19
  %.0 = phi i1 [ true, %19 ], [ false, %8 ], [ false, %4 ], [ false, %2 ]
  ret i1 %.0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4copyIPdN9__gnu_cxx17__normal_iteratorIS0_St6vectorIdSaIdEEEEET0_T_S8_S7_(ptr noundef, ptr noundef, ptr) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIdSaIdEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #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" }
attributes #2 = { inlinehint 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 #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, !12, i64 28}
!6 = !{!"_ZTSN4sptk21InputSourceFromMatrixE", !7, i64 0, !8, i64 8, !8, i64 12, !11, i64 16, !8, i64 24, !12, i64 28}
!7 = !{!"_ZTSN4sptk20InputSourceInterfaceE"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !8, i64 12}
!16 = !{!6, !8, i64 24}
!17 = !{!6, !8, i64 8}
!18 = !{!6, !11, i64 16}
!19 = !{!11, !11, i64 0}


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