; LLVM IR from buresjan/optim_lbm :: nomad/src/Eval/EvalPoint.ll (ZNK9NOMAD_4_39EvalPoint6toEvalEsNS_8EvalTypeE)

; 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::EvalPoint" = type { %"class.NOMAD_4_3::Point", [3 x %"class.std::unique_ptr"], i32, i32, i16, %"class.std::shared_ptr", %"class.std::vector", %"class.std::shared_ptr.8", %"class.NOMAD_4_3::Double", %"class.std::shared_ptr.11" }
%"class.NOMAD_4_3::Point" = type { %"class.NOMAD_4_3::ArrayOfDouble" }
%"class.NOMAD_4_3::ArrayOfDouble" = type { ptr, i64, ptr }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.4" }
%"struct.std::_Head_base.4" = type { ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<NOMAD_4_3::StepType, std::allocator<NOMAD_4_3::StepType>>::_Vector_impl" }
%"struct.std::_Vector_base<NOMAD_4_3::StepType, std::allocator<NOMAD_4_3::StepType>>::_Vector_impl" = type { %"struct.std::_Vector_base<NOMAD_4_3::StepType, std::allocator<NOMAD_4_3::StepType>>::_Vector_impl_data" }
%"struct.std::_Vector_base<NOMAD_4_3::StepType, std::allocator<NOMAD_4_3::StepType>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::shared_ptr.8" = type { %"class.std::__shared_ptr.9" }
%"class.std::__shared_ptr.9" = type { ptr, %"class.std::__shared_count" }
%"class.NOMAD_4_3::Double" = type <{ ptr, double, i8, [7 x i8] }>
%"class.std::shared_ptr.11" = type { %"class.std::__shared_ptr.12" }
%"class.std::__shared_ptr.12" = type { ptr, %"class.std::__shared_count" }

; 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
declare dso_local noundef ptr @_ZNK9NOMAD_4_39EvalPoint7getEvalENS_8EvalTypeE(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9NOMAD_4_34Eval13getEvalStatusEv(ptr noundef nonnull align 8 dereferenceable(105)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK9NOMAD_4_39EvalPoint6toEvalEsNS_8EvalTypeE(ptr noundef nonnull align 8 dereferenceable(160) %0, i16 noundef signext %1, i32 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  store i8 0, ptr %7, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %10 = load i32, ptr %6, align 4, !tbaa !11
  %11 = call noundef ptr @_ZNK9NOMAD_4_39EvalPoint7getEvalENS_8EvalTypeE(ptr noundef nonnull align 8 dereferenceable(160) %9, i32 noundef %10)
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = icmp eq ptr null, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  store i8 1, ptr %7, align 1, !tbaa !13
  br label %47

15:                                               ; preds = %3
  %16 = load i32, ptr %6, align 4, !tbaa !11
  %17 = icmp eq i32 1, %16
  br i1 %17, label %21, label %18

18:                                               ; preds = %15
  %19 = load i32, ptr %6, align 4, !tbaa !11
  %20 = icmp eq i32 2, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %18, %15
  store i8 0, ptr %7, align 1, !tbaa !13
  br label %46

22:                                               ; preds = %18
  %23 = getelementptr inbounds %"class.NOMAD_4_3::EvalPoint", ptr %9, i32 0, i32 4
  %24 = load i16, ptr %23, align 8, !tbaa !15
  %25 = sext i16 %24 to i32
  %26 = load i16, ptr %5, align 2, !tbaa !9
  %27 = sext i16 %26 to i32
  %28 = icmp sge i32 %25, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %22
  store i8 0, ptr %7, align 1, !tbaa !13
  br label %45

30:                                               ; preds = %22
  %31 = getelementptr inbounds %"class.NOMAD_4_3::EvalPoint", ptr %9, i32 0, i32 4
  %32 = load i16, ptr %31, align 8, !tbaa !15
  %33 = sext i16 %32 to i32
  %34 = icmp sge i32 %33, 1
  br i1 %34, label %35, label %40

35:                                               ; preds = %30
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = call noundef i32 @_ZNK9NOMAD_4_34Eval13getEvalStatusEv(ptr noundef nonnull align 8 dereferenceable(105) %36)
  %38 = icmp eq i32 4, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  store i8 0, ptr %7, align 1, !tbaa !13
  br label %44

40:                                               ; preds = %35, %30
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call noundef zeroext i1 @_ZNK9NOMAD_4_34Eval16canBeReEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(105) %41)
  %43 = zext i1 %42 to i8
  store i8 %43, ptr %7, align 1, !tbaa !13
  br label %44

44:                                               ; preds = %40, %39
  br label %45

45:                                               ; preds = %44, %29
  br label %46

46:                                               ; preds = %45, %21
  br label %47

47:                                               ; preds = %46, %14
  %48 = load i8, ptr %7, align 1, !tbaa !13, !range !34, !noundef !35
  %49 = trunc i8 %48 to i1
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  ret i1 %49
}

declare noundef zeroext i1 @_ZNK9NOMAD_4_34Eval16canBeReEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(105)) #3

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 = { 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 = { "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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN9NOMAD_4_38EvalTypeE", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!16, !10, i64 56}
!16 = !{!"_ZTSN9NOMAD_4_39EvalPointE", !17, i64 0, !7, i64 24, !20, i64 48, !20, i64 52, !10, i64 56, !21, i64 64, !24, i64 80, !28, i64 104, !30, i64 120, !32, i64 144}
!17 = !{!"_ZTSN9NOMAD_4_35PointE", !18, i64 0}
!18 = !{!"_ZTSN9NOMAD_4_313ArrayOfDoubleE", !19, i64 8, !6, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_39EvalPointEE", !22, i64 0}
!22 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_39EvalPointELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !23, i64 8}
!23 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!24 = !{!"_ZTSSt6vectorIN9NOMAD_4_38StepTypeESaIS1_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIN9NOMAD_4_38StepTypeESaIS1_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_38StepTypeESaIS1_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_38StepTypeESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_39DirectionEE", !29, i64 0}
!29 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_39DirectionELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !23, i64 8}
!30 = !{!"_ZTSN9NOMAD_4_36DoubleE", !31, i64 8, !14, i64 16}
!31 = !{!"double", !7, i64 0}
!32 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_38MeshBaseEE", !33, i64 0}
!33 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_38MeshBaseELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !23, i64 8}
!34 = !{i8 0, i8 2}
!35 = !{}


; 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK9NOMAD_4_39EvalPoint7getEvalENS_8EvalTypeE(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9NOMAD_4_34Eval13getEvalStatusEv(ptr noundef nonnull align 8 dereferenceable(105)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK9NOMAD_4_39EvalPoint6toEvalEsNS_8EvalTypeE(ptr noundef nonnull align 8 dereferenceable(160) %0, i16 noundef signext %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = tail call noundef ptr @_ZNK9NOMAD_4_39EvalPoint7getEvalENS_8EvalTypeE(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %2)
  %5 = icmp eq ptr %4, null
  br i1 %5, label %18, label %6

6:                                                ; preds = %3
  %7 = add i32 %2, -1
  %or.cond = icmp ult i32 %7, 2
  br i1 %or.cond, label %18, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = load i16, ptr %9, align 8, !tbaa !5
  %.not = icmp slt i16 %10, %1
  br i1 %.not, label %11, label %18

11:                                               ; preds = %8
  %12 = icmp sgt i16 %10, 0
  br i1 %12, label %13, label %16

13:                                               ; preds = %11
  %14 = tail call noundef i32 @_ZNK9NOMAD_4_34Eval13getEvalStatusEv(ptr noundef nonnull align 8 dereferenceable(105) %4)
  %15 = icmp eq i32 %14, 4
  br i1 %15, label %18, label %16

16:                                               ; preds = %13, %11
  %17 = tail call noundef zeroext i1 @_ZNK9NOMAD_4_34Eval16canBeReEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(105) %4)
  br label %18

18:                                               ; preds = %13, %8, %6, %3, %16
  %.0 = phi i1 [ %17, %16 ], [ true, %3 ], [ false, %6 ], [ false, %8 ], [ false, %13 ]
  ret i1 %.0
}

declare noundef zeroext i1 @_ZNK9NOMAD_4_34Eval16canBeReEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(105)) local_unnamed_addr #2

attributes #0 = { 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 #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" }

!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, !14, i64 56}
!6 = !{!"_ZTSN9NOMAD_4_39EvalPointE", !7, i64 0, !10, i64 24, !13, i64 48, !13, i64 52, !14, i64 56, !15, i64 64, !18, i64 80, !22, i64 104, !24, i64 120, !27, i64 144}
!7 = !{!"_ZTSN9NOMAD_4_35PointE", !8, i64 0}
!8 = !{!"_ZTSN9NOMAD_4_313ArrayOfDoubleE", !9, i64 8, !12, i64 16}
!9 = !{!"long", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"any pointer", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"short", !10, i64 0}
!15 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_39EvalPointEE", !16, i64 0}
!16 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_39EvalPointELN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0, !17, i64 8}
!17 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0}
!18 = !{!"_ZTSSt6vectorIN9NOMAD_4_38StepTypeESaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIN9NOMAD_4_38StepTypeESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_38StepTypeESaIS1_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_38StepTypeESaIS1_EE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!22 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_39DirectionEE", !23, i64 0}
!23 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_39DirectionELN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0, !17, i64 8}
!24 = !{!"_ZTSN9NOMAD_4_36DoubleE", !25, i64 8, !26, i64 16}
!25 = !{!"double", !10, i64 0}
!26 = !{!"bool", !10, i64 0}
!27 = !{!"_ZTSSt10shared_ptrIN9NOMAD_4_38MeshBaseEE", !28, i64 0}
!28 = !{!"_ZTSSt12__shared_ptrIN9NOMAD_4_38MeshBaseELN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0, !17, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass