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

; 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::Eval" = type <{ ptr, i32, [4 x i8], %"class.NOMAD_4_3::BBOutput", %"class.std::vector", i8, [7 x i8] }>
%"class.NOMAD_4_3::BBOutput" = type <{ %"class.std::__cxx11::basic_string", %"class.NOMAD_4_3::ArrayOfDouble", i8, [7 x i8] }>
%"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] }
%"class.NOMAD_4_3::ArrayOfDouble" = type { ptr, i64, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<NOMAD_4_3::BBOutputType, std::allocator<NOMAD_4_3::BBOutputType>>::_Vector_impl" }
%"struct.std::_Vector_base<NOMAD_4_3::BBOutputType, std::allocator<NOMAD_4_3::BBOutputType>>::_Vector_impl" = type { %"struct.std::_Vector_base<NOMAD_4_3::BBOutputType, std::allocator<NOMAD_4_3::BBOutputType>>::_Vector_impl_data" }
%"struct.std::_Vector_base<NOMAD_4_3::BBOutputType, std::allocator<NOMAD_4_3::BBOutputType>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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 @_ZNK9NOMAD_4_34Eval16canBeReEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(105) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  store i8 0, ptr %3, align 1, !tbaa !9
  %5 = getelementptr inbounds %"class.NOMAD_4_3::Eval", ptr %4, i32 0, i32 1
  %6 = load i32, ptr %5, align 8, !tbaa !11
  %7 = icmp eq i32 %6, 4
  br i1 %7, label %20, label %8

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.NOMAD_4_3::Eval", ptr %4, i32 0, i32 1
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %20, label %12

12:                                               ; preds = %8
  %13 = getelementptr inbounds %"class.NOMAD_4_3::Eval", ptr %4, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp eq i32 %14, 3
  br i1 %15, label %20, label %16

16:                                               ; preds = %12
  %17 = getelementptr inbounds %"class.NOMAD_4_3::Eval", ptr %4, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp eq i32 %18, 2
  br i1 %19, label %20, label %21

20:                                               ; preds = %16, %12, %8, %1
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %21

21:                                               ; preds = %20, %16
  %22 = load i8, ptr %3, align 1, !tbaa !9, !range !23, !noundef !24
  %23 = trunc i8 %22 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  ret i1 %23
}

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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"_ZTSN9NOMAD_4_34EvalE", !13, i64 8, !14, i64 16, !19, i64 80, !10, i64 104}
!13 = !{!"_ZTSN9NOMAD_4_314EvalStatusTypeE", !7, i64 0}
!14 = !{!"_ZTSN9NOMAD_4_38BBOutputE", !15, i64 0, !18, i64 32, !10, i64 56}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSN9NOMAD_4_313ArrayOfDoubleE", !17, i64 8, !6, i64 16}
!19 = !{!"_ZTSSt6vectorIN9NOMAD_4_312BBOutputTypeESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIN9NOMAD_4_312BBOutputTypeESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_312BBOutputTypeESaIS1_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_312BBOutputTypeESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{i8 0, i8 2}
!24 = !{}


; 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(argmem: read) uwtable
define dso_local noundef zeroext i1 @_ZNK9NOMAD_4_34Eval16canBeReEvaluatedEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(105) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp ult i32 %3, 5
  %switch.cast = trunc i32 %3 to i5
  %switch.downshift = lshr i5 -3, %switch.cast
  %switch.masked = trunc i5 %switch.downshift to i1
  %.0 = select i1 %4, i1 %switch.masked, i1 false
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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_34EvalE", !7, i64 8, !10, i64 16, !17, i64 80, !16, i64 104}
!7 = !{!"_ZTSN9NOMAD_4_314EvalStatusTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN9NOMAD_4_38BBOutputE", !11, i64 0, !15, i64 32, !16, i64 56}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !14, i64 8, !8, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = !{!"_ZTSN9NOMAD_4_313ArrayOfDoubleE", !14, i64 8, !13, i64 16}
!16 = !{!"bool", !8, i64 0}
!17 = !{!"_ZTSSt6vectorIN9NOMAD_4_312BBOutputTypeESaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIN9NOMAD_4_312BBOutputTypeESaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_312BBOutputTypeESaIS1_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN9NOMAD_4_312BBOutputTypeESaIS1_EE17_Vector_impl_dataE", !13, i64 0, !13, i64 8, !13, i64 16}


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