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

@.str = external hidden unnamed_addr constant [50 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@__PRETTY_FUNCTION__.dswapVector1 = external hidden unnamed_addr constant [54 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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: nounwind uwtable
declare dso_local i32 @lastIndex(ptr noundef) #6

; Function Attrs: nounwind uwtable
declare dso_local i32 @getDiagonalIndex(ptr noundef) #6

; Function Attrs: nounwind uwtable
declare dso_local double @putItem(ptr noundef, i32 noundef, double noundef) #6

; Function Attrs: nounwind uwtable
declare dso_local void @clearVector(ptr noundef, i32 noundef, i32 noundef) #6

; Function Attrs: nounwind uwtable
declare dso_local i32 @getVector(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i8 noundef zeroext) #6

; Function Attrs: nounwind uwtable
define dso_local void @dswapVector1(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #6 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store ptr null, ptr %12, align 8, !tbaa !5
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = icmp sle i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %4
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %15, %4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call i32 @lastIndex(ptr noundef %17)
  store i32 %18, ptr %11, align 4, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = icmp sle i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %16
  %22 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %22, ptr %8, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %21, %16
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = icmp sgt i32 %24, %25
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = load i32, ptr %8, align 4, !tbaa !9
  br label %31

29:                                               ; preds = %23
  %30 = load i32, ptr %11, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %29, %27
  %32 = phi i32 [ %28, %27 ], [ %30, %29 ]
  %33 = add nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = call noalias ptr @calloc(i64 noundef %34, i64 noundef 8) #8
  %36 = icmp ne ptr %35, null
  br i1 %36, label %63, label %37

37:                                               ; preds = %31
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = icmp sgt i32 %38, %39
  br i1 %40, label %41, label %43

41:                                               ; preds = %37
  %42 = load i32, ptr %8, align 4, !tbaa !9
  br label %45

43:                                               ; preds = %37
  %44 = load i32, ptr %11, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %43, %41
  %46 = phi i32 [ %42, %41 ], [ %44, %43 ]
  %47 = add nsw i32 %46, 1
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %63

49:                                               ; preds = %45
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = icmp sgt i32 %50, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %49
  %54 = load i32, ptr %8, align 4, !tbaa !9
  br label %57

55:                                               ; preds = %49
  %56 = load i32, ptr %11, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %55, %53
  %58 = phi i32 [ %54, %53 ], [ %56, %55 ]
  %59 = add nsw i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = mul i64 %60, 8
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %61, i32 noundef 862, ptr noundef @.str.1)
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 862, ptr noundef @__PRETTY_FUNCTION__.dswapVector1) #9
  unreachable

63:                                               ; preds = %45, %31
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = call i32 @getVector(ptr noundef %64, ptr noundef %65, i32 noundef %66, i32 noundef %67, i8 noundef zeroext 0)
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = call i32 @getDiagonalIndex(ptr noundef %69)
  store i32 %70, ptr %10, align 4, !tbaa !9
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !9
  call void @clearVector(ptr noundef %71, i32 noundef %72, i32 noundef %73)
  %74 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %74, ptr %9, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %96, %63
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = load i32, ptr %8, align 4, !tbaa !9
  %78 = icmp sle i32 %76, %77
  br i1 %78, label %79, label %99

79:                                               ; preds = %75
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = load i32, ptr %9, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds double, ptr %80, i64 %82
  %84 = load double, ptr %83, align 8, !tbaa !11
  %85 = fcmp une double %84, 0.000000e+00
  br i1 %85, label %86, label %95

86:                                               ; preds = %79
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = load i32, ptr %9, align 4, !tbaa !9
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load i32, ptr %9, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds double, ptr %89, i64 %91
  %93 = load double, ptr %92, align 8, !tbaa !11
  %94 = call double @putItem(ptr noundef %87, i32 noundef %88, double noundef %93)
  br label %95

95:                                               ; preds = %86, %79
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %9, align 4, !tbaa !9
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %9, align 4, !tbaa !9
  br label %75, !llvm.loop !13

99:                                               ; preds = %75
  %100 = load i32, ptr %8, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %9, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %123, %99
  %103 = load i32, ptr %9, align 4, !tbaa !9
  %104 = load i32, ptr %11, align 4, !tbaa !9
  %105 = icmp sle i32 %103, %104
  br i1 %105, label %106, label %126

106:                                              ; preds = %102
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  %108 = load i32, ptr %9, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds double, ptr %107, i64 %109
  %111 = load double, ptr %110, align 8, !tbaa !11
  %112 = fcmp une double %111, 0.000000e+00
  br i1 %112, label %113, label %122

113:                                              ; preds = %106
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = load i32, ptr %9, align 4, !tbaa !9
  %116 = load ptr, ptr %12, align 8, !tbaa !5
  %117 = load i32, ptr %9, align 4, !tbaa !9
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds double, ptr %116, i64 %118
  %120 = load double, ptr %119, align 8, !tbaa !11
  %121 = call double @putItem(ptr noundef %114, i32 noundef %115, double noundef %120)
  br label %122

122:                                              ; preds = %113, %106
  br label %123

123:                                              ; preds = %122
  %124 = load i32, ptr %9, align 4, !tbaa !9
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %9, align 4, !tbaa !9
  br label %102, !llvm.loop !15

126:                                              ; preds = %102
  %127 = load ptr, ptr %6, align 8, !tbaa !5
  %128 = load i32, ptr %7, align 4, !tbaa !9
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds double, ptr %127, i64 %129
  %131 = load ptr, ptr %12, align 8, !tbaa !5
  %132 = load i32, ptr %7, align 4, !tbaa !9
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds double, ptr %131, i64 %133
  %135 = load i32, ptr %8, align 4, !tbaa !9
  %136 = load i32, ptr %7, align 4, !tbaa !9
  %137 = sub nsw i32 %135, %136
  %138 = add nsw i32 %137, 1
  %139 = sext i32 %138 to i64
  %140 = mul i64 %139, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %130, ptr align 8 %134, i64 %140, i1 false)
  %141 = load ptr, ptr %12, align 8, !tbaa !5
  %142 = icmp ne ptr %141, null
  br i1 %142, label %143, label %145

143:                                              ; preds = %126
  %144 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %144) #7
  store ptr null, ptr %12, align 8, !tbaa !5
  br label %145

145:                                              ; preds = %143, %126
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0,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 = { "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 = { noreturn 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 #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { noreturn 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @lastIndex(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @getDiagonalIndex(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local double @putItem(ptr noundef, i32 noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @clearVector(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @getVector(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @dswapVector1(ptr noundef %0, ptr nocapture noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %2, i32 1)
  %5 = tail call i32 @lastIndex(ptr noundef %0)
  %6 = icmp slt i32 %3, 1
  %spec.select = select i1 %6, i32 %5, i32 %3
  %7 = tail call i32 @getVector(ptr noundef %0, ptr noundef null, i32 noundef %spec.store.select, i32 noundef %5, i8 noundef zeroext 0)
  %8 = tail call i32 @getDiagonalIndex(ptr noundef %0)
  tail call void @clearVector(ptr noundef %0, i32 noundef %spec.store.select, i32 noundef %5)
  %.not56 = icmp sgt i32 %spec.store.select, %spec.select
  %.pre = zext nneg i32 %spec.store.select to i64
  br i1 %.not56, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %9 = add nuw i32 %spec.select, 1
  %wide.trip.count = zext i32 %9 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %16
  %indvars.iv = phi i64 [ %.pre, %.lr.ph.preheader ], [ %indvars.iv.next, %16 ]
  %10 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = fcmp une double %11, 0.000000e+00
  br i1 %12, label %13, label %16

13:                                               ; preds = %.lr.ph
  %14 = trunc nuw nsw i64 %indvars.iv to i32
  %15 = tail call double @putItem(ptr noundef %0, i32 noundef %14, double noundef %11)
  br label %16

16:                                               ; preds = %.lr.ph, %13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %16, %4
  %.not55.not = icmp sge i32 %spec.select, %5
  tail call void @llvm.assume(i1 %.not55.not)
  %17 = getelementptr inbounds double, ptr %1, i64 %.pre
  %18 = getelementptr inbounds double, ptr null, i64 %.pre
  %reass.sub = sub i32 %spec.select, %spec.store.select
  %19 = add i32 %reass.sub, 1
  %20 = sext i32 %19 to i64
  %21 = shl nsw i64 %20, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %17, ptr nonnull align 8 %18, i64 %21, i1 false)
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #3

attributes #0 = { mustprogress nocallback nofree 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 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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