; LLVM IR from buresjan/optim_lbm :: nomad/ext/sgtelib/src/TrainingSet.ll (ZN7SGTELIB11TrainingSet19check_singular_dataEv)

; 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.SGTELIB::TrainingSet" = type { ptr, i32, i32, i32, i8, ptr, i8, i32, double, double, i32, %"class.SGTELIB::Matrix", %"class.SGTELIB::Matrix", %"class.SGTELIB::Matrix", %"class.SGTELIB::Matrix", %"class.SGTELIB::Matrix", i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, double }
%"class.SGTELIB::Matrix" = type { ptr, %"class.std::__cxx11::basic_string", i32, i32, 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] }

; 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 noundef zeroext i1 @_ZN7SGTELIB11TrainingSet19check_singular_dataEv(ptr noundef nonnull align 8 dereferenceable(504) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  store i8 0, ptr %5, align 1, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %8

8:                                                ; preds = %31, %1
  %9 = load i32, ptr %4, align 4, !tbaa !11
  %10 = getelementptr inbounds %"class.SGTELIB::TrainingSet", ptr %7, i32 0, i32 2
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = icmp slt i32 %9, %11
  br i1 %12, label %13, label %34

13:                                               ; preds = %8
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %27, %13
  %15 = load i32, ptr %3, align 4, !tbaa !11
  %16 = getelementptr inbounds %"class.SGTELIB::TrainingSet", ptr %7, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !20
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %19, label %30

19:                                               ; preds = %14
  %20 = getelementptr inbounds %"class.SGTELIB::TrainingSet", ptr %7, i32 0, i32 11
  %21 = load i32, ptr %3, align 4, !tbaa !11
  %22 = load i32, ptr %4, align 4, !tbaa !11
  %23 = call noundef double @_ZNK7SGTELIB6Matrix3getEii(ptr noundef nonnull align 8 dereferenceable(56) %20, i32 noundef %21, i32 noundef %22)
  %24 = call noundef zeroext i1 @_ZN7SGTELIB5isdefEd(double noundef %23)
  br i1 %24, label %26, label %25

25:                                               ; preds = %19
  store i8 1, ptr %5, align 1, !tbaa !9
  br label %26

26:                                               ; preds = %25, %19
  br label %27

27:                                               ; preds = %26
  %28 = load i32, ptr %3, align 4, !tbaa !11
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %3, align 4, !tbaa !11
  br label %14, !llvm.loop !21

30:                                               ; preds = %14
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %4, align 4, !tbaa !11
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !11
  br label %8, !llvm.loop !23

34:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %35

35:                                               ; preds = %66, %34
  %36 = load i32, ptr %4, align 4, !tbaa !11
  %37 = getelementptr inbounds %"class.SGTELIB::TrainingSet", ptr %7, i32 0, i32 3
  %38 = load i32, ptr %37, align 8, !tbaa !24
  %39 = icmp slt i32 %36, %38
  br i1 %39, label %40, label %69

40:                                               ; preds = %35
  store i8 0, ptr %6, align 1, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %41

41:                                               ; preds = %54, %40
  %42 = load i32, ptr %3, align 4, !tbaa !11
  %43 = getelementptr inbounds %"class.SGTELIB::TrainingSet", ptr %7, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !20
  %45 = icmp slt i32 %42, %44
  br i1 %45, label %46, label %57

46:                                               ; preds = %41
  %47 = getelementptr inbounds %"class.SGTELIB::TrainingSet", ptr %7, i32 0, i32 12
  %48 = load i32, ptr %3, align 4, !tbaa !11
  %49 = load i32, ptr %4, align 4, !tbaa !11
  %50 = call noundef double @_ZNK7SGTELIB6Matrix3getEii(ptr noundef nonnull align 8 dereferenceable(56) %47, i32 noundef %48, i32 noundef %49)
  %51 = call noundef zeroext i1 @_ZN7SGTELIB5isdefEd(double noundef %50)
  br i1 %51, label %52, label %53

52:                                               ; preds = %46
  store i8 1, ptr %6, align 1, !tbaa !9
  br label %57

53:                                               ; preds = %46
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %3, align 4, !tbaa !11
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %3, align 4, !tbaa !11
  br label %41, !llvm.loop !25

57:                                               ; preds = %52, %41
  %58 = getelementptr inbounds %"class.SGTELIB::TrainingSet", ptr %7, i32 0, i32 1
  %59 = load i32, ptr %58, align 8, !tbaa !20
  %60 = icmp sgt i32 %59, 10
  br i1 %60, label %61, label %65

61:                                               ; preds = %57
  %62 = load i8, ptr %6, align 1, !tbaa !9, !range !26, !noundef !27
  %63 = trunc i8 %62 to i1
  br i1 %63, label %65, label %64

64:                                               ; preds = %61
  store i8 1, ptr %5, align 1, !tbaa !9
  br label %65

65:                                               ; preds = %64, %61, %57
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %4, align 4, !tbaa !11
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %4, align 4, !tbaa !11
  br label %35, !llvm.loop !28

69:                                               ; preds = %35
  %70 = load i8, ptr %5, align 1, !tbaa !9, !range !26, !noundef !27
  %71 = trunc i8 %70 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i1 %71
}

declare noundef zeroext i1 @_ZN7SGTELIB5isdefEd(double noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7SGTELIB6Matrix3getEii(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef, i32 noundef) #3 align 2

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 = { inlinehint 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 #4 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 12}
!14 = !{!"_ZTSN7SGTELIB11TrainingSetE", !12, i64 8, !12, i64 12, !12, i64 16, !10, i64 20, !6, i64 24, !10, i64 32, !12, i64 36, !15, i64 40, !15, i64 48, !12, i64 56, !16, i64 64, !16, i64 120, !16, i64 176, !16, i64 232, !16, i64 288, !12, i64 344, !12, i64 348, !12, i64 352, !6, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !6, i64 392, !6, i64 400, !6, i64 408, !12, i64 416, !12, i64 420, !6, i64 424, !6, i64 432, !6, i64 440, !6, i64 448, !6, i64 456, !6, i64 464, !6, i64 472, !6, i64 480, !6, i64 488, !15, i64 496}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_ZTSN7SGTELIB6MatrixE", !17, i64 8, !12, i64 40, !12, i64 44, !6, i64 48}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !18, i64 0, !19, i64 8, !7, i64 16}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!14, !12, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = !{!14, !12, i64 16}
!25 = distinct !{!25, !22}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = distinct !{!28, !22}


; 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 @_ZN7SGTELIB11TrainingSet19check_singular_dataEv(ptr noundef nonnull align 8 dereferenceable(504) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.preheader21.lr.ph, label %.preheader20

.preheader21.lr.ph:                               ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = getelementptr inbounds i8, ptr %0, i64 64
  %7 = load i32, ptr %5, align 8, !tbaa !17
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.preheader21, label %.preheader20

.preheader21:                                     ; preds = %.preheader21.lr.ph, %._crit_edge
  %9 = phi i32 [ %24, %._crit_edge ], [ %3, %.preheader21.lr.ph ]
  %10 = phi i32 [ %25, %._crit_edge ], [ %7, %.preheader21.lr.ph ]
  %.01425 = phi i1 [ %.1.lcssa, %._crit_edge ], [ false, %.preheader21.lr.ph ]
  %.01524 = phi i32 [ %26, %._crit_edge ], [ 0, %.preheader21.lr.ph ]
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.preheader20:                                     ; preds = %._crit_edge, %.preheader21.lr.ph, %1
  %.014.lcssa = phi i1 [ false, %1 ], [ false, %.preheader21.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load i32, ptr %12, align 8, !tbaa !18
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.preheader.lr.ph, label %._crit_edge35

.preheader.lr.ph:                                 ; preds = %.preheader20
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = getelementptr inbounds i8, ptr %0, i64 120
  %17 = load i32, ptr %15, align 8, !tbaa !17
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.preheader, label %._crit_edge35

.lr.ph:                                           ; preds = %.preheader21, %.lr.ph
  %.123 = phi i1 [ %spec.select, %.lr.ph ], [ %.01425, %.preheader21 ]
  %.01722 = phi i32 [ %21, %.lr.ph ], [ 0, %.preheader21 ]
  %19 = tail call noundef double @_ZNK7SGTELIB6Matrix3getEii(ptr noundef nonnull align 8 dereferenceable(56) %6, i32 noundef %.01722, i32 noundef %.01524)
  %20 = tail call noundef zeroext i1 @_ZN7SGTELIB5isdefEd(double noundef %19)
  %not. = xor i1 %20, true
  %spec.select = select i1 %not., i1 true, i1 %.123
  %21 = add nuw nsw i32 %.01722, 1
  %22 = load i32, ptr %5, align 8, !tbaa !17
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader21
  %24 = phi i32 [ %9, %.preheader21 ], [ %.pre, %._crit_edge.loopexit ]
  %25 = phi i32 [ %10, %.preheader21 ], [ %22, %._crit_edge.loopexit ]
  %.1.lcssa = phi i1 [ %.01425, %.preheader21 ], [ %spec.select, %._crit_edge.loopexit ]
  %26 = add nuw nsw i32 %.01524, 1
  %27 = icmp slt i32 %26, %24
  br i1 %27, label %.preheader21, label %.preheader20, !llvm.loop !21

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge29
  %28 = phi i32 [ %36, %._crit_edge29 ], [ %13, %.preheader.lr.ph ]
  %29 = phi i32 [ %37, %._crit_edge29 ], [ %17, %.preheader.lr.ph ]
  %.334 = phi i1 [ %.4, %._crit_edge29 ], [ %.014.lcssa, %.preheader.lr.ph ]
  %.11633 = phi i32 [ %39, %._crit_edge29 ], [ 0, %.preheader.lr.ph ]
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %.lr.ph28, label %._crit_edge29

31:                                               ; preds = %.lr.ph28
  %32 = add nuw nsw i32 %.11827, 1
  %33 = icmp slt i32 %32, %.pre40.pre
  br i1 %33, label %.lr.ph28, label %._crit_edge29.loopexit, !llvm.loop !23

.lr.ph28:                                         ; preds = %.preheader, %31
  %.11827 = phi i32 [ %32, %31 ], [ 0, %.preheader ]
  %34 = tail call noundef double @_ZNK7SGTELIB6Matrix3getEii(ptr noundef nonnull align 8 dereferenceable(56) %16, i32 noundef %.11827, i32 noundef %.11633)
  %35 = tail call noundef zeroext i1 @_ZN7SGTELIB5isdefEd(double noundef %34)
  %.pre40.pre = load i32, ptr %15, align 8, !tbaa !17
  br i1 %35, label %._crit_edge29.loopexit, label %31

._crit_edge29.loopexit:                           ; preds = %.lr.ph28, %31
  %spec.select19.ph = phi i1 [ true, %31 ], [ %.334, %.lr.ph28 ]
  %.pre41 = load i32, ptr %12, align 8, !tbaa !18
  br label %._crit_edge29

._crit_edge29:                                    ; preds = %._crit_edge29.loopexit, %.preheader
  %36 = phi i32 [ %28, %.preheader ], [ %.pre41, %._crit_edge29.loopexit ]
  %37 = phi i32 [ %29, %.preheader ], [ %.pre40.pre, %._crit_edge29.loopexit ]
  %spec.select19 = phi i1 [ true, %.preheader ], [ %spec.select19.ph, %._crit_edge29.loopexit ]
  %38 = icmp sgt i32 %37, 10
  %.4 = select i1 %38, i1 %spec.select19, i1 %.334
  %39 = add nuw nsw i32 %.11633, 1
  %40 = icmp slt i32 %39, %36
  br i1 %40, label %.preheader, label %._crit_edge35, !llvm.loop !24

._crit_edge35:                                    ; preds = %._crit_edge29, %.preheader.lr.ph, %.preheader20
  %.3.lcssa = phi i1 [ %.014.lcssa, %.preheader20 ], [ %.014.lcssa, %.preheader.lr.ph ], [ %.4, %._crit_edge29 ]
  ret i1 %.3.lcssa
}

declare noundef zeroext i1 @_ZN7SGTELIB5isdefEd(double noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7SGTELIB6Matrix3getEii(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef, i32 noundef) local_unnamed_addr #2 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 = { "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 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, !7, i64 12}
!6 = !{!"_ZTSN7SGTELIB11TrainingSetE", !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 20, !11, i64 24, !10, i64 32, !7, i64 36, !12, i64 40, !12, i64 48, !7, i64 56, !13, i64 64, !13, i64 120, !13, i64 176, !13, i64 232, !13, i64 288, !7, i64 344, !7, i64 348, !7, i64 352, !11, i64 360, !11, i64 368, !11, i64 376, !11, i64 384, !11, i64 392, !11, i64 400, !11, i64 408, !7, i64 416, !7, i64 420, !11, i64 424, !11, i64 432, !11, i64 440, !11, i64 448, !11, i64 456, !11, i64 464, !11, i64 472, !11, i64 480, !11, i64 488, !12, i64 496}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!"_ZTSN7SGTELIB6MatrixE", !14, i64 8, !7, i64 40, !7, i64 44, !11, i64 48}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !8, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !11, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!6, !7, i64 8}
!18 = !{!6, !7, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20, !22}
!22 = !{!"llvm.loop.unswitch.partial.disable"}
!23 = distinct !{!23, !20}
!24 = distinct !{!24, !20, !22}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass