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

; 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::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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK7SGTELIB6Matrix6is_symEv(ptr noundef nonnull align 8 dereferenceable(56) %0) #1 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %"class.SGTELIB::Matrix", ptr %7, i32 0, i32 3
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = getelementptr inbounds %"class.SGTELIB::Matrix", ptr %7, i32 0, i32 2
  %11 = load i32, ptr %10, align 8, !tbaa !15
  %12 = icmp ne i32 %9, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %61

14:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %4, align 4, !tbaa !16
  br label %15

15:                                               ; preds = %56, %14
  %16 = load i32, ptr %4, align 4, !tbaa !16
  %17 = getelementptr inbounds %"class.SGTELIB::Matrix", ptr %7, i32 0, i32 2
  %18 = load i32, ptr %17, align 8, !tbaa !15
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %20, label %59

20:                                               ; preds = %15
  %21 = load i32, ptr %4, align 4, !tbaa !16
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %5, align 4, !tbaa !16
  br label %23

23:                                               ; preds = %52, %20
  %24 = load i32, ptr %5, align 4, !tbaa !16
  %25 = getelementptr inbounds %"class.SGTELIB::Matrix", ptr %7, i32 0, i32 3
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %28, label %55

28:                                               ; preds = %23
  %29 = getelementptr inbounds %"class.SGTELIB::Matrix", ptr %7, i32 0, i32 4
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = load i32, ptr %4, align 4, !tbaa !16
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds ptr, ptr %30, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = load i32, ptr %5, align 4, !tbaa !16
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds double, ptr %34, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !18
  %39 = getelementptr inbounds %"class.SGTELIB::Matrix", ptr %7, i32 0, i32 4
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  %41 = load i32, ptr %5, align 4, !tbaa !16
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds ptr, ptr %40, i64 %42
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = load i32, ptr %4, align 4, !tbaa !16
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds double, ptr %44, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !18
  %49 = fcmp une double %38, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %28
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %60

51:                                               ; preds = %28
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %5, align 4, !tbaa !16
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !16
  br label %23, !llvm.loop !20

55:                                               ; preds = %23
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %4, align 4, !tbaa !16
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %4, align 4, !tbaa !16
  br label %15, !llvm.loop !22

59:                                               ; preds = %15
  store i1 true, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %60

60:                                               ; preds = %59, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %61

61:                                               ; preds = %60, %13
  %62 = load i1, ptr %2, align 1
  ret i1 %62
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !14, i64 44}
!10 = !{!"_ZTSN7SGTELIB6MatrixE", !11, i64 8, !14, i64 40, !14, i64 44, !6, i64 48}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !13, i64 8, !7, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !14, i64 40}
!16 = !{!14, !14, i64 0}
!17 = !{!10, !6, i64 48}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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 nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_ZNK7SGTELIB6Matrix6is_symEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(56) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 44
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i32, ptr %4, align 8, !tbaa !14
  %.not = icmp eq i32 %3, %5
  br i1 %.not, label %.preheader, label %.loopexit13

.preheader:                                       ; preds = %1
  %.not1216 = icmp sgt i32 %3, 0
  br i1 %.not1216, label %.lr.ph18, label %.loopexit13

.lr.ph18:                                         ; preds = %.preheader
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load ptr, ptr %6, align 8
  %8 = zext nneg i32 %3 to i64
  %wide.trip.count26 = zext nneg i32 %3 to i64
  br label %9

.loopexit:                                        ; preds = %13, %9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond27.not = icmp eq i64 %indvars.iv.next24, %wide.trip.count26
  br i1 %exitcond27.not, label %.loopexit13, label %9, !llvm.loop !15

9:                                                ; preds = %.lr.ph18, %.loopexit
  %indvars.iv23 = phi i64 [ 0, %.lr.ph18 ], [ %indvars.iv.next24, %.loopexit ]
  %indvars.iv = phi i64 [ 1, %.lr.ph18 ], [ %indvars.iv.next, %.loopexit ]
  %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
  %10 = icmp ult i64 %indvars.iv.next24, %8
  br i1 %10, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %9
  %11 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv23
  %12 = load ptr, ptr %11, align 8, !tbaa !17
  br label %14

13:                                               ; preds = %14
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next21, %wide.trip.count26
  br i1 %exitcond.not, label %.loopexit, label %14, !llvm.loop !18

14:                                               ; preds = %.lr.ph, %13
  %indvars.iv20 = phi i64 [ %indvars.iv, %.lr.ph ], [ %indvars.iv.next21, %13 ]
  %15 = getelementptr inbounds double, ptr %12, i64 %indvars.iv20
  %16 = load double, ptr %15, align 8, !tbaa !19
  %17 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv20
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = getelementptr inbounds double, ptr %18, i64 %indvars.iv23
  %20 = load double, ptr %19, align 8, !tbaa !19
  %21 = fcmp une double %16, %20
  br i1 %21, label %.loopexit13, label %13

.loopexit13:                                      ; preds = %.loopexit, %14, %.preheader, %1
  %.1 = phi i1 [ false, %1 ], [ true, %.preheader ], [ false, %14 ], [ true, %.loopexit ]
  ret i1 %.1
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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, !13, i64 44}
!6 = !{!"_ZTSN7SGTELIB6MatrixE", !7, i64 8, !13, i64 40, !13, i64 44, !9, i64 48}
!7 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !8, i64 0, !12, i64 8, !10, i64 16}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!6, !13, i64 40}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!9, !9, i64 0}
!18 = distinct !{!18, !16}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass