; LLVM IR from buresjan/optim_lbm :: nomad/src/Math/Point.ll (ZNK9NOMAD_4_35Point8hasFixedERKS0_)

; 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

declare noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK9NOMAD_4_313ArrayOfDouble4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9NOMAD_4_3neERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) #3

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

9:                                                ; preds = %38, %2
  %10 = load i64, ptr %6, align 8, !tbaa !11
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call noundef i64 @_ZNK9NOMAD_4_313ArrayOfDouble4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %13 = icmp ult i64 %10, %12
  br i1 %13, label %14, label %19

14:                                               ; preds = %9
  %15 = load i64, ptr %6, align 8, !tbaa !11
  %16 = getelementptr inbounds %"class.NOMAD_4_3::ArrayOfDouble", ptr %8, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = icmp ult i64 %15, %17
  br label %19

19:                                               ; preds = %14, %9
  %20 = phi i1 [ false, %9 ], [ %18, %14 ]
  br i1 %20, label %22, label %21

21:                                               ; preds = %19
  store i32 2, ptr %7, align 4
  br label %41

22:                                               ; preds = %19
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load i64, ptr %6, align 8, !tbaa !11
  %25 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %23, i64 noundef %24)
  %26 = call noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17) %25)
  br i1 %26, label %27, label %37

27:                                               ; preds = %22
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i64, ptr %6, align 8, !tbaa !11
  %30 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %29)
  %31 = getelementptr inbounds %"class.NOMAD_4_3::ArrayOfDouble", ptr %8, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = load i64, ptr %6, align 8, !tbaa !11
  %34 = getelementptr inbounds %"class.NOMAD_4_3::Double", ptr %32, i64 %33
  %35 = call noundef zeroext i1 @_ZN9NOMAD_4_3neERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17) %30, ptr noundef nonnull align 8 dereferenceable(17) %34)
  br i1 %35, label %36, label %37

36:                                               ; preds = %27
  store i8 0, ptr %5, align 1, !tbaa !9
  store i32 2, ptr %7, align 4
  br label %41

37:                                               ; preds = %27, %22
  br label %38

38:                                               ; preds = %37
  %39 = load i64, ptr %6, align 8, !tbaa !11
  %40 = add i64 %39, 1
  store i64 %40, ptr %6, align 8, !tbaa !11
  br label %9, !llvm.loop !16

41:                                               ; preds = %36, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %42

42:                                               ; preds = %41
  %43 = load i8, ptr %5, align 1, !tbaa !9, !range !18, !noundef !19
  %44 = trunc i8 %43 to i1
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #5
  ret i1 %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 #5 = { 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 = !{!14, !6, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{i8 0, i8 2}
!19 = !{}


; 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] }>

declare noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK9NOMAD_4_313ArrayOfDouble4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9NOMAD_4_3neERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK9NOMAD_4_35Point8hasFixedERKS0_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #3 align 2 {
  %3 = tail call noundef i64 @_ZNK9NOMAD_4_313ArrayOfDouble4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %4 = icmp eq i64 %3, 0
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %5, align 8
  %7 = icmp eq i64 %6, 0
  %or.cond.not14 = select i1 %4, i1 true, i1 %7
  br i1 %or.cond.not14, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  br label %9

9:                                                ; preds = %.lr.ph, %17
  %.015 = phi i64 [ 0, %.lr.ph ], [ %18, %17 ]
  %10 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.015)
  %11 = tail call noundef zeroext i1 @_ZNK9NOMAD_4_36Double9isDefinedEv(ptr noundef nonnull align 8 dereferenceable(17) %10)
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  %13 = tail call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK9NOMAD_4_313ArrayOfDoubleixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.015)
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.NOMAD_4_3::Double", ptr %14, i64 %.015
  %16 = tail call noundef zeroext i1 @_ZN9NOMAD_4_3neERKNS_6DoubleES2_(ptr noundef nonnull align 8 dereferenceable(17) %13, ptr noundef nonnull align 8 dereferenceable(17) %15)
  br i1 %16, label %.critedge, label %17

17:                                               ; preds = %9, %12
  %18 = add nuw i64 %.015, 1
  %19 = tail call noundef i64 @_ZNK9NOMAD_4_313ArrayOfDouble4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %20 = icmp uge i64 %18, %19
  %21 = load i64, ptr %5, align 8
  %22 = icmp uge i64 %18, %21
  %or.cond.not = select i1 %20, i1 true, i1 %22
  br i1 %or.cond.not, label %.critedge, label %9, !llvm.loop !11

.critedge:                                        ; preds = %17, %12, %2
  %or.cond.not.lcssa = phi i1 [ true, %2 ], [ false, %12 ], [ true, %17 ]
  ret i1 %or.cond.not.lcssa
}

attributes #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 = { 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, !10, i64 16}
!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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