; LLVM IR from siconos/siconos :: externals/SOL/lumod-c (sparselib)

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

%struct._sparseVector = type { i32, i32, i32, 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: nounwind uwtable
define dso_local void @daxpyVector1(ptr noundef %0, double noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %16 = load double, ptr %7, align 8, !tbaa !9
  %17 = fcmp oeq double %16, 0.000000e+00
  br i1 %17, label %18, label %19

18:                                               ; preds = %5
  store i32 1, ptr %13, align 4
  br label %101

19:                                               ; preds = %5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._sparseVector, ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !13
  store i32 %22, ptr %12, align 4, !tbaa !11
  %23 = load i32, ptr %9, align 4, !tbaa !11
  %24 = icmp sle i32 %23, 0
  br i1 %24, label %25, label %31

25:                                               ; preds = %19
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._sparseVector, ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = getelementptr inbounds i32, ptr %28, i64 1
  %30 = load i32, ptr %29, align 4, !tbaa !11
  store i32 %30, ptr %9, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %25, %19
  %32 = load i32, ptr %10, align 4, !tbaa !11
  %33 = icmp sle i32 %32, 0
  br i1 %33, label %34, label %42

34:                                               ; preds = %31
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._sparseVector, ptr %35, i32 0, i32 3
  %37 = load ptr, ptr %36, align 8, !tbaa !15
  %38 = load i32, ptr %12, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %37, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !11
  store i32 %41, ptr %10, align 4, !tbaa !11
  br label %42

42:                                               ; preds = %34, %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  store i32 1, ptr %11, align 4, !tbaa !11
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._sparseVector, ptr %43, i32 0, i32 3
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = getelementptr inbounds i32, ptr %45, i64 1
  store ptr %46, ptr %14, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %59, %42
  %48 = load i32, ptr %11, align 4, !tbaa !11
  %49 = load i32, ptr %12, align 4, !tbaa !11
  %50 = icmp sle i32 %48, %49
  br i1 %50, label %51, label %56

51:                                               ; preds = %47
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = load i32, ptr %52, align 4, !tbaa !11
  %54 = load i32, ptr %9, align 4, !tbaa !11
  %55 = icmp slt i32 %53, %54
  br label %56

56:                                               ; preds = %51, %47
  %57 = phi i1 [ false, %47 ], [ %55, %51 ]
  br i1 %57, label %58, label %64

58:                                               ; preds = %56
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %11, align 4, !tbaa !11
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %11, align 4, !tbaa !11
  %62 = load ptr, ptr %14, align 8, !tbaa !5
  %63 = getelementptr inbounds i32, ptr %62, i32 1
  store ptr %63, ptr %14, align 8, !tbaa !5
  br label %47, !llvm.loop !16

64:                                               ; preds = %56
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._sparseVector, ptr %65, i32 0, i32 4
  %67 = load ptr, ptr %66, align 8, !tbaa !18
  %68 = load i32, ptr %11, align 4, !tbaa !11
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds double, ptr %67, i64 %69
  store ptr %70, ptr %15, align 8, !tbaa !5
  br label %71

71:                                               ; preds = %93, %64
  %72 = load i32, ptr %11, align 4, !tbaa !11
  %73 = load i32, ptr %12, align 4, !tbaa !11
  %74 = icmp sle i32 %72, %73
  br i1 %74, label %75, label %80

75:                                               ; preds = %71
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %78 = load i32, ptr %10, align 4, !tbaa !11
  %79 = icmp sle i32 %77, %78
  br label %80

80:                                               ; preds = %75, %71
  %81 = phi i1 [ false, %71 ], [ %79, %75 ]
  br i1 %81, label %82, label %100

82:                                               ; preds = %80
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  %84 = load double, ptr %83, align 8, !tbaa !9
  %85 = load double, ptr %7, align 8, !tbaa !9
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = load ptr, ptr %14, align 8, !tbaa !5
  %88 = load i32, ptr %87, align 4, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %86, i64 %89
  %91 = load double, ptr %90, align 8, !tbaa !9
  %92 = call double @llvm.fmuladd.f64(double %84, double %85, double %91)
  store double %92, ptr %90, align 8, !tbaa !9
  br label %93

93:                                               ; preds = %82
  %94 = load i32, ptr %11, align 4, !tbaa !11
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %11, align 4, !tbaa !11
  %96 = load ptr, ptr %14, align 8, !tbaa !5
  %97 = getelementptr inbounds i32, ptr %96, i32 1
  store ptr %97, ptr %14, align 8, !tbaa !5
  %98 = load ptr, ptr %15, align 8, !tbaa !5
  %99 = getelementptr inbounds double, ptr %98, i32 1
  store ptr %99, ptr %15, align 8, !tbaa !5
  br label %71, !llvm.loop !19

100:                                              ; preds = %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  store i32 0, ptr %13, align 4
  br label %101

101:                                              ; preds = %100, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  %102 = load i32, ptr %13, align 4
  switch i32 %102, label %104 [
    i32 0, label %103
    i32 1, label %103
  ]

103:                                              ; preds = %101, %101
  ret void

104:                                              ; preds = %101
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_sparseVector", !12, i64 0, !12, i64 4, !12, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!14, !6, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!14, !6, i64 24}
!19 = distinct !{!19, !17}


; 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: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @daxpyVector1(ptr nocapture noundef readonly %0, double noundef %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = fcmp oeq double %1, 0.000000e+00
  br i1 %6, label %.critedge2, label %7

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = icmp slt i32 %3, 1
  br i1 %10, label %11, label %16

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %13, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !12
  br label %16

16:                                               ; preds = %11, %7
  %.029 = phi i32 [ %15, %11 ], [ %3, %7 ]
  %17 = icmp slt i32 %4, 1
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  br i1 %17, label %20, label %._crit_edge

20:                                               ; preds = %16
  %21 = sext i32 %9 to i64
  %22 = getelementptr inbounds i32, ptr %19, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %16, %20
  %.032 = phi i32 [ %23, %20 ], [ %4, %16 ]
  %.02839 = getelementptr inbounds i8, ptr %19, i64 4
  %.not40 = icmp slt i32 %9, 1
  br i1 %.not40, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %._crit_edge
  %24 = add nuw i32 %9, 1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %27
  %.02842 = phi ptr [ %.028, %27 ], [ %.02839, %.lr.ph.preheader ]
  %.03041 = phi i32 [ %28, %27 ], [ 1, %.lr.ph.preheader ]
  %25 = load i32, ptr %.02842, align 4, !tbaa !12
  %26 = icmp slt i32 %25, %.029
  br i1 %26, label %27, label %.critedge

27:                                               ; preds = %.lr.ph
  %28 = add nuw i32 %.03041, 1
  %.028 = getelementptr inbounds i8, ptr %.02842, i64 4
  %exitcond.not = icmp eq i32 %.03041, %9
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !13

.critedge:                                        ; preds = %.lr.ph, %27, %._crit_edge
  %.030.lcssa = phi i32 [ 1, %._crit_edge ], [ %24, %27 ], [ %.03041, %.lr.ph ]
  %.028.lcssa = phi ptr [ %.02839, %._crit_edge ], [ %.028, %27 ], [ %.02842, %.lr.ph ]
  %.not3747 = icmp sgt i32 %.030.lcssa, %9
  br i1 %.not3747, label %.critedge2, label %.lr.ph51.preheader

.lr.ph51.preheader:                               ; preds = %.critedge
  %29 = getelementptr inbounds i8, ptr %0, i64 24
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = zext nneg i32 %.030.lcssa to i64
  %32 = getelementptr inbounds double, ptr %30, i64 %31
  br label %.lr.ph51

.lr.ph51:                                         ; preds = %.lr.ph51.preheader, %34
  %.050 = phi ptr [ %42, %34 ], [ %32, %.lr.ph51.preheader ]
  %.149 = phi ptr [ %41, %34 ], [ %.028.lcssa, %.lr.ph51.preheader ]
  %.13148 = phi i32 [ %40, %34 ], [ %.030.lcssa, %.lr.ph51.preheader ]
  %33 = load i32, ptr %.149, align 4, !tbaa !12
  %.not38 = icmp sgt i32 %33, %.032
  br i1 %.not38, label %.critedge2, label %34

34:                                               ; preds = %.lr.ph51
  %35 = load double, ptr %.050, align 8, !tbaa !16
  %36 = sext i32 %33 to i64
  %37 = getelementptr inbounds double, ptr %2, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !16
  %39 = tail call double @llvm.fmuladd.f64(double %35, double %1, double %38)
  store double %39, ptr %37, align 8, !tbaa !16
  %40 = add i32 %.13148, 1
  %41 = getelementptr inbounds i8, ptr %.149, i64 4
  %42 = getelementptr inbounds i8, ptr %.050, i64 8
  %exitcond53.not = icmp eq i32 %.13148, %9
  br i1 %exitcond53.not, label %.critedge2, label %.lr.ph51, !llvm.loop !18

.critedge2:                                       ; preds = %34, %.lr.ph51, %.critedge, %5
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"_sparseVector", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !10, i64 24}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !8, i64 0}
!18 = distinct !{!18, !14}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass