; 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._sparseMatrix = type { i32, i32, i32, i32, ptr }

@.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__.createMatrix = external hidden unnamed_addr constant [42 x i8], align 1

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

11:                                               ; preds = %3
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %11, %3
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %23

15:                                               ; preds = %12
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp slt i32 10, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %21

19:                                               ; preds = %15
  %20 = load i32, ptr %4, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %19, %18
  %22 = phi i32 [ 10, %18 ], [ %20, %19 ]
  store i32 %22, ptr %7, align 4, !tbaa !5
  br label %31

23:                                               ; preds = %12
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = icmp sgt i32 10, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %29

27:                                               ; preds = %23
  %28 = load i32, ptr %6, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %27, %26
  %30 = phi i32 [ 10, %26 ], [ %28, %27 ]
  store i32 %30, ptr %7, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %29, %21
  %32 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 24) #6
  %33 = icmp ne ptr %32, null
  br i1 %33, label %36, label %34

34:                                               ; preds = %31
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef 24, i32 noundef 20, ptr noundef @.str.1)
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 20, ptr noundef @__PRETTY_FUNCTION__.createMatrix) #7
  unreachable

36:                                               ; preds = %31
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = load ptr, ptr %8, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct._sparseMatrix, ptr %38, i32 0, i32 0
  store i32 %37, ptr %39, align 8, !tbaa !11
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct._sparseMatrix, ptr %41, i32 0, i32 3
  store i32 %40, ptr %42, align 4, !tbaa !13
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  %44 = load i32, ptr %7, align 4, !tbaa !5
  call void @resizeMatrix(ptr noundef %43, i32 noundef %44)
  br label %45

45:                                               ; preds = %48, %36
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %48, label %55

48:                                               ; preds = %45
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr %6, align 4, !tbaa !5
  %51 = load ptr, ptr %8, align 8, !tbaa !9
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = call ptr @createVector(i32 noundef %52, i32 noundef 2)
  %54 = call i32 @appendMatrix(ptr noundef %51, ptr noundef %53)
  br label %45, !llvm.loop !14

55:                                               ; preds = %45
  %56 = load ptr, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret ptr %56
}

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

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

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }
attributes #7 = { 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 = !{!"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 0}
!12 = !{!"_sparseMatrix", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16}
!13 = !{!12, !6, i64 12}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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 nofree norecurse noreturn nosync nounwind willreturn memory(none) uwtable
define dso_local noalias noundef nonnull ptr @createMatrix(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  unreachable
}

attributes #0 = { mustprogress nofree norecurse noreturn nosync nounwind willreturn memory(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" }

!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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass