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

@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @printf(ptr noundef, ...) #1

; 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 @printVector(i32 noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  store i32 1, ptr %10, align 4
  br label %103

14:                                               ; preds = %3
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = icmp sle i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  store i32 5, ptr %6, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %17, %14
  store i32 1, ptr %7, align 4, !tbaa !5
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %90, %18
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %23, label %95

23:                                               ; preds = %19
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct._sparseVector, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = icmp sle i32 %24, %27
  br i1 %28, label %29, label %37

29:                                               ; preds = %23
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct._sparseVector, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i32, ptr %32, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  store i32 %36, ptr %9, align 4, !tbaa !5
  br label %40

37:                                               ; preds = %23
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %9, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %37, %29
  br label %41

41:                                               ; preds = %56, %40
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %45, label %59

45:                                               ; preds = %41
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = call i32 @mod(i32 noundef %46, i32 noundef %47)
  %49 = icmp eq i32 %48, 1
  br i1 %49, label %50, label %53

50:                                               ; preds = %45
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %51, double noundef 0.000000e+00)
  br label %56

53:                                               ; preds = %45
  %54 = load i32, ptr %8, align 4, !tbaa !5
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i32 noundef %54, double noundef 0.000000e+00)
  br label %56

56:                                               ; preds = %53, %50
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %8, align 4, !tbaa !5
  br label %41, !llvm.loop !14

59:                                               ; preds = %41
  %60 = load i32, ptr %9, align 4, !tbaa !5
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = icmp sle i32 %60, %61
  br i1 %62, label %63, label %89

63:                                               ; preds = %59
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = call i32 @mod(i32 noundef %64, i32 noundef %65)
  %67 = icmp eq i32 %66, 1
  br i1 %67, label %68, label %78

68:                                               ; preds = %63
  %69 = load i32, ptr %9, align 4, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct._sparseVector, ptr %70, i32 0, i32 4
  %72 = load ptr, ptr %71, align 8, !tbaa !16
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds double, ptr %72, i64 %74
  %76 = load double, ptr %75, align 8, !tbaa !17
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %69, double noundef %76)
  br label %88

78:                                               ; preds = %63
  %79 = load i32, ptr %9, align 4, !tbaa !5
  %80 = load ptr, ptr %5, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct._sparseVector, ptr %80, i32 0, i32 4
  %82 = load ptr, ptr %81, align 8, !tbaa !16
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds double, ptr %82, i64 %84
  %86 = load double, ptr %85, align 8, !tbaa !17
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i32 noundef %79, double noundef %86)
  br label %88

88:                                               ; preds = %78, %68
  br label %89

89:                                               ; preds = %88, %59
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %7, align 4, !tbaa !5
  %93 = load i32, ptr %8, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %8, align 4, !tbaa !5
  br label %19, !llvm.loop !19

95:                                               ; preds = %19
  %96 = load i32, ptr %8, align 4, !tbaa !5
  %97 = load i32, ptr %6, align 4, !tbaa !5
  %98 = call i32 @mod(i32 noundef %96, i32 noundef %97)
  %99 = icmp ne i32 %98, 0
  br i1 %99, label %100, label %102

100:                                              ; preds = %95
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %102

102:                                              ; preds = %100, %95
  store i32 0, ptr %10, align 4
  br label %103

103:                                              ; preds = %102, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %104 = load i32, ptr %10, align 4
  switch i32 %104, label %106 [
    i32 0, label %105
    i32 1, label %105
  ]

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

106:                                              ; preds = %103
  unreachable
}

declare i32 @mod(i32 noundef, i32 noundef) #1

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


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

@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @printVector(i32 noundef %0, ptr noundef readonly %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = icmp eq ptr %1, null
  br i1 %4, label %35, label %5

5:                                                ; preds = %3
  %6 = icmp slt i32 %2, 1
  %spec.store.select = select i1 %6, i32 5, i32 %2
  %.not37 = icmp slt i32 %0, 1
  br i1 %.not37, label %._crit_edge42, label %.lr.ph41

.lr.ph41:                                         ; preds = %5
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = add nuw nsw i32 %0, 1
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  br label %11

11:                                               ; preds = %.lr.ph41, %30
  %indvars.iv = phi i64 [ 1, %.lr.ph41 ], [ %indvars.iv.next, %30 ]
  %.02939 = phi i32 [ 1, %.lr.ph41 ], [ %31, %30 ]
  %12 = load i32, ptr %7, align 8, !tbaa !5
  %13 = sext i32 %12 to i64
  %.not34 = icmp sgt i64 %indvars.iv, %13
  br i1 %.not34, label %18, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr %8, align 8, !tbaa !11
  %16 = getelementptr inbounds i32, ptr %15, i64 %indvars.iv
  %17 = load i32, ptr %16, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %11, %14
  %.0 = phi i32 [ %17, %14 ], [ %9, %11 ]
  %19 = icmp slt i32 %.02939, %.0
  br i1 %19, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %18, %.lr.ph
  %.136 = phi i32 [ %23, %.lr.ph ], [ %.02939, %18 ]
  %20 = tail call i32 @mod(i32 noundef %.136, i32 noundef %spec.store.select) #3
  %21 = icmp eq i32 %20, 1
  %.str.7..str.8 = select i1 %21, ptr @.str.7, ptr @.str.8
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.7..str.8, i32 noundef %.136, double noundef 0.000000e+00)
  %23 = add i32 %.136, 1
  %exitcond.not = icmp eq i32 %23, %.0
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %18
  %.1.lcssa = phi i32 [ %.02939, %18 ], [ %.0, %.lr.ph ]
  %.not35 = icmp sgt i32 %.0, %0
  br i1 %.not35, label %30, label %.sink.split

.sink.split:                                      ; preds = %._crit_edge
  %24 = tail call i32 @mod(i32 noundef %.1.lcssa, i32 noundef %spec.store.select) #3
  %25 = icmp eq i32 %24, 1
  %26 = load ptr, ptr %10, align 8, !tbaa !15
  %27 = getelementptr inbounds double, ptr %26, i64 %indvars.iv
  %28 = load double, ptr %27, align 8, !tbaa !16
  %.str.7..str.847 = select i1 %25, ptr @.str.7, ptr @.str.8
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.7..str.847, i32 noundef %.0, double noundef %28)
  br label %30

30:                                               ; preds = %.sink.split, %._crit_edge
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %31 = add nsw i32 %.1.lcssa, 1
  %.not.not = icmp slt i32 %.1.lcssa, %0
  br i1 %.not.not, label %11, label %._crit_edge42, !llvm.loop !18

._crit_edge42:                                    ; preds = %30, %5
  %.029.lcssa = phi i32 [ 1, %5 ], [ %31, %30 ]
  %32 = tail call i32 @mod(i32 noundef %.029.lcssa, i32 noundef %spec.store.select) #3
  %.not33 = icmp eq i32 %32, 0
  br i1 %.not33, label %35, label %33

33:                                               ; preds = %._crit_edge42
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %35

35:                                               ; preds = %._crit_edge42, %33, %3
  ret void
}

declare i32 @mod(i32 noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { nofree nounwind "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 = { 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 = { "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 = { 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, !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: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass