; 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__.dswapVector3 = external hidden unnamed_addr constant [60 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: nounwind uwtable
declare dso_local i32 @lastIndex(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @swapVector(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local i32 @firstIndex(ptr noundef) #5

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

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

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

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

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

14:                                               ; preds = %13, %4
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = icmp sle i32 %15, 0
  br i1 %16, label %17, label %31

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call i32 @lastIndex(ptr noundef %18)
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call i32 @lastIndex(ptr noundef %20)
  %22 = icmp sgt i32 %19, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %17
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i32 @lastIndex(ptr noundef %24)
  br label %29

26:                                               ; preds = %17
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call i32 @lastIndex(ptr noundef %27)
  br label %29

29:                                               ; preds = %26, %23
  %30 = phi i32 [ %25, %23 ], [ %28, %26 ]
  store i32 %30, ptr %8, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %29, %14
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call i32 @firstIndex(ptr noundef %33)
  %35 = icmp sle i32 %32, %34
  br i1 %35, label %36, label %54

36:                                               ; preds = %31
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call i32 @firstIndex(ptr noundef %38)
  %40 = icmp sle i32 %37, %39
  br i1 %40, label %41, label %54

41:                                               ; preds = %36
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call i32 @lastIndex(ptr noundef %43)
  %45 = icmp sge i32 %42, %44
  br i1 %45, label %46, label %54

46:                                               ; preds = %41
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call i32 @lastIndex(ptr noundef %48)
  %50 = icmp sge i32 %47, %49
  br i1 %50, label %51, label %54

51:                                               ; preds = %46
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  call void @swapVector(ptr noundef %52, ptr noundef %53)
  br label %121

54:                                               ; preds = %46, %41, %36, %31
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = call noalias ptr @calloc(i64 noundef %57, i64 noundef 8) #7
  %59 = icmp ne ptr %58, null
  br i1 %59, label %70, label %60

60:                                               ; preds = %54
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %70

64:                                               ; preds = %60
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = mul i64 %67, 8
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %68, i32 noundef 909, ptr noundef @.str.1)
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 909, ptr noundef @__PRETTY_FUNCTION__.dswapVector3) #8
  unreachable

70:                                               ; preds = %60, %54
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  %73 = sext i32 %72 to i64
  %74 = call noalias ptr @calloc(i64 noundef %73, i64 noundef 8) #7
  %75 = icmp ne ptr %74, null
  br i1 %75, label %86, label %76

76:                                               ; preds = %70
  %77 = load i32, ptr %8, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %86

80:                                               ; preds = %76
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  %83 = sext i32 %82 to i64
  %84 = mul i64 %83, 8
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %84, i32 noundef 910, ptr noundef @.str.1)
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 910, ptr noundef @__PRETTY_FUNCTION__.dswapVector3) #8
  unreachable

86:                                               ; preds = %76, %70
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = call i32 @getVector(ptr noundef %87, ptr noundef %88, i32 noundef %89, i32 noundef %90, i8 noundef zeroext 1)
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = call i32 @getVector(ptr noundef %92, ptr noundef %93, i32 noundef %94, i32 noundef %95, i8 noundef zeroext 1)
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = load i32, ptr %7, align 4, !tbaa !9
  %99 = load i32, ptr %8, align 4, !tbaa !9
  call void @clearVector(ptr noundef %97, i32 noundef %98, i32 noundef %99)
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = load i32, ptr %7, align 4, !tbaa !9
  %102 = load i32, ptr %8, align 4, !tbaa !9
  call void @clearVector(ptr noundef %100, i32 noundef %101, i32 noundef %102)
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = load i32, ptr %7, align 4, !tbaa !9
  %106 = load i32, ptr %8, align 4, !tbaa !9
  call void @putVector(ptr noundef %103, ptr noundef %104, i32 noundef %105, i32 noundef %106)
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = load ptr, ptr %9, align 8, !tbaa !5
  %109 = load i32, ptr %7, align 4, !tbaa !9
  %110 = load i32, ptr %8, align 4, !tbaa !9
  call void @putVector(ptr noundef %107, ptr noundef %108, i32 noundef %109, i32 noundef %110)
  %111 = load ptr, ptr %9, align 8, !tbaa !5
  %112 = icmp ne ptr %111, null
  br i1 %112, label %113, label %115

113:                                              ; preds = %86
  %114 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %114) #6
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %115

115:                                              ; preds = %113, %86
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = icmp ne ptr %116, null
  br i1 %117, label %118, label %120

118:                                              ; preds = %115
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %119) #6
  store ptr null, ptr %10, align 8, !tbaa !5
  br label %120

120:                                              ; preds = %118, %115
  br label %121

121:                                              ; preds = %120, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  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 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { 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}


; 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: nounwind uwtable
declare dso_local i32 @lastIndex(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @swapVector(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @dswapVector3(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %2, i32 1)
  %5 = icmp slt i32 %3, 1
  br i1 %5, label %.sink.split, label %10

.sink.split:                                      ; preds = %4
  %6 = tail call i32 @lastIndex(ptr noundef %0)
  %7 = tail call i32 @lastIndex(ptr noundef %1)
  %8 = icmp sgt i32 %6, %7
  %. = select i1 %8, ptr %0, ptr %1
  %9 = tail call i32 @lastIndex(ptr noundef %.)
  br label %10

10:                                               ; preds = %.sink.split, %4
  %.0 = phi i32 [ %3, %4 ], [ %9, %.sink.split ]
  %11 = tail call i32 @firstIndex(ptr noundef %0)
  %.not = icmp sgt i32 %spec.store.select, %11
  br i1 %.not, label %19, label %12

12:                                               ; preds = %10
  %13 = tail call i32 @firstIndex(ptr noundef %1)
  %.not48 = icmp sgt i32 %spec.store.select, %13
  br i1 %.not48, label %19, label %14

14:                                               ; preds = %12
  %15 = tail call i32 @lastIndex(ptr noundef %0)
  %.not49 = icmp slt i32 %.0, %15
  br i1 %.not49, label %19, label %16

16:                                               ; preds = %14
  %17 = tail call i32 @lastIndex(ptr noundef %1)
  %.not50 = icmp slt i32 %.0, %17
  br i1 %.not50, label %19, label %18

18:                                               ; preds = %16
  tail call void @swapVector(ptr noundef %0, ptr noundef %1)
  br label %22

19:                                               ; preds = %16, %14, %12, %10
  %20 = tail call i32 @getVector(ptr noundef %0, ptr noundef null, i32 noundef %spec.store.select, i32 noundef %.0, i8 noundef zeroext 1)
  %21 = tail call i32 @getVector(ptr noundef %1, ptr noundef null, i32 noundef %spec.store.select, i32 noundef %.0, i8 noundef zeroext 1)
  tail call void @clearVector(ptr noundef %0, i32 noundef %spec.store.select, i32 noundef %.0)
  tail call void @clearVector(ptr noundef %1, i32 noundef %spec.store.select, i32 noundef %.0)
  tail call void @putVector(ptr noundef %0, ptr noundef null, i32 noundef %spec.store.select, i32 noundef %.0)
  tail call void @putVector(ptr noundef %1, ptr noundef null, i32 noundef %spec.store.select, i32 noundef %.0)
  br label %22

22:                                               ; preds = %19, %18
  ret void
}

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

attributes #0 = { 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 #1 = { 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)"}


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