; LLVM IR from cvanaret/Uno :: uno/ingredients/constraint_relaxation_strategies (l1RelaxedProblem)

; 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.uno::OptimizationProblem" = type { ptr, ptr, i64, i64 }
%"class.uno::l1RelaxedProblem" = type { %"class.uno::OptimizationProblem", i64, double, double, double, ptr, %"class.uno::Concatenation", %"class.uno::Concatenation" }
%"class.uno::Concatenation" = type { %"class.uno::Collection", ptr, %"class.uno::Range" }
%"class.uno::Collection" = type { ptr }
%"class.uno::Range" = type { %"class.uno::Collection", i64, i64 }
%"class.uno::Model" = type { ptr, %"class.std::__cxx11::basic_string", i64, i64, double }
%"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 uwtable
define dso_local noundef i64 @_ZNK3uno16l1RelaxedProblem23number_hessian_nonzerosERKNS_12HessianModelE(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %"class.uno::OptimizationProblem", ptr %6, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %7, align 8, !tbaa !12
  %11 = getelementptr inbounds ptr, ptr %10, i64 3
  %12 = load ptr, ptr %11, align 8
  %13 = call noundef i64 %12(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(64) %9)
  store i64 %13, ptr %5, align 8, !tbaa !14
  %14 = getelementptr inbounds %"class.uno::l1RelaxedProblem", ptr %6, i32 0, i32 5
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %28

17:                                               ; preds = %2
  %18 = getelementptr inbounds %"class.uno::l1RelaxedProblem", ptr %6, i32 0, i32 4
  %19 = load double, ptr %18, align 8, !tbaa !21
  %20 = fcmp une double %19, 0.000000e+00
  br i1 %20, label %21, label %28

21:                                               ; preds = %17
  %22 = getelementptr inbounds %"class.uno::OptimizationProblem", ptr %6, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"class.uno::Model", ptr %23, i32 0, i32 2
  %25 = load i64, ptr %24, align 8, !tbaa !22
  %26 = load i64, ptr %5, align 8, !tbaa !14
  %27 = add i64 %26, %25
  store i64 %27, ptr %5, align 8, !tbaa !14
  br label %28

28:                                               ; preds = %21, %17, %2
  %29 = load i64, ptr %5, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret i64 %29
}

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 = { 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, !6, i64 8}
!10 = !{!"_ZTSN3uno19OptimizationProblemE", !6, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"vtable pointer", !8, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !6, i64 64}
!16 = !{!"_ZTSN3uno16l1RelaxedProblemE", !10, i64 0, !11, i64 32, !17, i64 40, !17, i64 48, !17, i64 56, !6, i64 64, !18, i64 72, !18, i64 112}
!17 = !{!"double", !7, i64 0}
!18 = !{!"_ZTSN3uno13ConcatenationIRKNS_10CollectionImEENS_5RangeILNS_14RangeDirectionE0EEEEE", !19, i64 0, !6, i64 8, !20, i64 16}
!19 = !{!"_ZTSN3uno10CollectionImEE"}
!20 = !{!"_ZTSN3uno5RangeILNS_14RangeDirectionE0EEE", !19, i64 0, !11, i64 8, !11, i64 16}
!21 = !{!16, !17, i64 56}
!22 = !{!23, !11, i64 40}
!23 = !{!"_ZTSN3uno5ModelE", !24, i64 8, !11, i64 40, !11, i64 48, !17, i64 56}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !25, i64 0, !11, i64 8, !7, i64 16}
!25 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}


; 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 uwtable
define dso_local noundef i64 @_ZNK3uno16l1RelaxedProblem23number_hessian_nonzerosERKNS_12HessianModelE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(152) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %1, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %5, i64 24
  %7 = load ptr, ptr %6, align 8
  %8 = tail call noundef i64 %7(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(64) %4)
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %.not = icmp ne ptr %10, null
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  %12 = load double, ptr %11, align 8
  %13 = fcmp une double %12, 0.000000e+00
  %or.cond = select i1 %.not, i1 %13, i1 false
  br i1 %or.cond, label %14, label %19

14:                                               ; preds = %2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 40
  %17 = load i64, ptr %16, align 8, !tbaa !19
  %18 = add i64 %17, %8
  br label %19

19:                                               ; preds = %14, %2
  %.0 = phi i64 [ %18, %14 ], [ %8, %2 ]
  ret i64 %.0
}

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

!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 = !{!"_ZTSN3uno19OptimizationProblemE", !7, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !9, i64 0}
!13 = !{!14, !7, i64 64}
!14 = !{!"_ZTSN3uno16l1RelaxedProblemE", !6, i64 0, !10, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !7, i64 64, !16, i64 72, !16, i64 112}
!15 = !{!"double", !8, i64 0}
!16 = !{!"_ZTSN3uno13ConcatenationIRKNS_10CollectionImEENS_5RangeILNS_14RangeDirectionE0EEEEE", !17, i64 0, !7, i64 8, !18, i64 16}
!17 = !{!"_ZTSN3uno10CollectionImEE"}
!18 = !{!"_ZTSN3uno5RangeILNS_14RangeDirectionE0EEE", !17, i64 0, !10, i64 8, !10, i64 16}
!19 = !{!20, !10, i64 40}
!20 = !{!"_ZTSN3uno5ModelE", !21, i64 8, !10, i64 40, !10, i64 48, !15, i64 56}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !22, i64 0, !10, i64 8, !8, i64 16}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !7, i64 0}


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