; LLVM IR from buresjan/optim_lbm :: nomad/src/Math/ArrayOfDouble.ll (ZNK9NOMAD_4_313ArrayOfDouble8inBoundsERKS0_S2_)

; 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.NOMAD_4_3::ArrayOfDouble" = type { ptr, i64, ptr }
%"class.NOMAD_4_3::Double" = type <{ ptr, double, i8, [7 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
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK9NOMAD_4_313ArrayOfDouble8inBoundsERKS0_S2_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  store i8 1, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %61, %3
  %11 = load i64, ptr %8, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.NOMAD_4_3::ArrayOfDouble", ptr %9, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %14 = icmp ult i64 %11, %13
  br i1 %14, label %15, label %18

15:                                               ; preds = %10
  %16 = load i8, ptr %7, align 1, !tbaa !9, !range !15, !noundef !16
  %17 = trunc i8 %16 to i1
  br label %18

18:                                               ; preds = %15, %10
  %19 = phi i1 [ false, %10 ], [ %17, %15 ]
  br i1 %19, label %21, label %20

20:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %64

21:                                               ; preds = %18
  %22 = getelementptr inbounds %"class.NOMAD_4_3::ArrayOfDouble", ptr %9, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  %24 = load i64, ptr %8, align 8, !tbaa !11
  %25 = getelementptr inbounds %"class.NOMAD_4_3::Double", ptr %23, i64 %24
  %26 = call noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17) %25)
  br i1 %26, label %28, label %27

27:                                               ; preds = %21
  store i8 0, ptr %7, align 1, !tbaa !9
  br label %60

28:                                               ; preds = %21
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i64, ptr %8, align 8, !tbaa !11
  %31 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %30)
  %32 = call noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17) %31)
  br i1 %32, label %33, label %43

33:                                               ; preds = %28
  %34 = getelementptr inbounds %"class.NOMAD_4_3::ArrayOfDouble", ptr %9, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = load i64, ptr %8, align 8, !tbaa !11
  %37 = getelementptr inbounds %"class.NOMAD_4_3::Double", ptr %35, i64 %36
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load i64, ptr %8, align 8, !tbaa !11
  %40 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef %39)
  %41 = call noundef zeroext i1 @_ZN9NOMAD_4_3ltERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17) %37, ptr noundef nonnull align 8 dereferenceable(17) %40)
  br i1 %41, label %42, label %43

42:                                               ; preds = %33
  store i8 0, ptr %7, align 1, !tbaa !9
  br label %59

43:                                               ; preds = %33, %28
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i64, ptr %8, align 8, !tbaa !11
  %46 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %44, i64 noundef %45)
  %47 = call noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17) %46)
  br i1 %47, label %48, label %58

48:                                               ; preds = %43
  %49 = getelementptr inbounds %"class.NOMAD_4_3::ArrayOfDouble", ptr %9, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = load i64, ptr %8, align 8, !tbaa !11
  %52 = getelementptr inbounds %"class.NOMAD_4_3::Double", ptr %50, i64 %51
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load i64, ptr %8, align 8, !tbaa !11
  %55 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %54)
  %56 = call noundef zeroext i1 @_ZN9NOMAD_4_3gtERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17) %52, ptr noundef nonnull align 8 dereferenceable(17) %55)
  br i1 %56, label %57, label %58

57:                                               ; preds = %48
  store i8 0, ptr %7, align 1, !tbaa !9
  br label %58

58:                                               ; preds = %57, %48, %43
  br label %59

59:                                               ; preds = %58, %42
  br label %60

60:                                               ; preds = %59, %27
  br label %61

61:                                               ; preds = %60
  %62 = load i64, ptr %8, align 8, !tbaa !11
  %63 = add i64 %62, 1
  store i64 %63, ptr %8, align 8, !tbaa !11
  br label %10, !llvm.loop !18

64:                                               ; preds = %20
  %65 = load i8, ptr %7, align 1, !tbaa !9, !range !15, !noundef !16
  %66 = trunc i8 %65 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  ret i1 %66
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9NOMAD_4_3ltERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9NOMAD_4_3gtERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) #3

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 = { 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 #3 = { 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 #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 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTSN9NOMAD_4_313ArrayOfDoubleE", !12, i64 8, !6, i64 16}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!14, !6, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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

%"class.NOMAD_4_3::Double" = type <{ ptr, double, i8, [7 x i8] }>

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK9NOMAD_4_313ArrayOfDouble8inBoundsERKS0_S2_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  br label %7

._crit_edge:                                      ; preds = %14, %7, %27, %3
  %.015.lcssa = phi i1 [ true, %3 ], [ false, %14 ], [ false, %7 ], [ %.1, %27 ]
  ret i1 %.015.lcssa

7:                                                ; preds = %.lr.ph, %27
  %.017 = phi i64 [ 0, %.lr.ph ], [ %28, %27 ]
  %8 = load ptr, ptr %6, align 8, !tbaa !11
  %9 = getelementptr inbounds %"class.NOMAD_4_3::Double", ptr %8, i64 %.017
  %10 = tail call noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17) %9)
  br i1 %10, label %11, label %._crit_edge

11:                                               ; preds = %7
  %12 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.017)
  %13 = tail call noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17) %12)
  br i1 %13, label %14, label %19

14:                                               ; preds = %11
  %15 = load ptr, ptr %6, align 8, !tbaa !11
  %16 = getelementptr inbounds %"class.NOMAD_4_3::Double", ptr %15, i64 %.017
  %17 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.017)
  %18 = tail call noundef zeroext i1 @_ZN9NOMAD_4_3ltERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17) %16, ptr noundef nonnull align 8 dereferenceable(17) %17)
  br i1 %18, label %._crit_edge, label %19

19:                                               ; preds = %14, %11
  %20 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.017)
  %21 = tail call noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17) %20)
  br i1 %21, label %22, label %27

22:                                               ; preds = %19
  %23 = load ptr, ptr %6, align 8, !tbaa !11
  %24 = getelementptr inbounds %"class.NOMAD_4_3::Double", ptr %23, i64 %.017
  %25 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.017)
  %26 = tail call noundef zeroext i1 @_ZN9NOMAD_4_3gtERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17) %24, ptr noundef nonnull align 8 dereferenceable(17) %25)
  %not. = xor i1 %26, true
  br label %27

27:                                               ; preds = %22, %19
  %.1 = phi i1 [ true, %19 ], [ %not., %22 ]
  %28 = add nuw i64 %.017, 1
  %29 = load i64, ptr %4, align 8, !tbaa !5
  %30 = icmp ult i64 %28, %29
  %31 = and i1 %30, %.1
  br i1 %31, label %7, label %._crit_edge, !llvm.loop !12
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9NOMAD_4_3ltERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9NOMAD_4_3gtERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #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" }

!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 8}
!6 = !{!"_ZTSN9NOMAD_4_313ArrayOfDoubleE", !7, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass