; LLVM IR from MRPT/mrpt :: 3rdparty/xspublic/xstypes (xsarray)

; 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.XsArray = type { ptr, i64, i64, i64, ptr }
%struct.XsArrayDescriptor = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @XsArray_construct(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %12, ptr %9, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.XsArray, ptr %14, i32 0, i32 4
  store ptr %13, ptr %15, align 8, !tbaa !5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.XsArray, ptr %17, i32 0, i32 1
  store i64 %16, ptr %18, align 8, !tbaa !9
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.XsArray, ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %23, label %139

23:                                               ; preds = %4
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.XsArray, ptr %24, i32 0, i32 1
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.XsArray, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !14
  %32 = mul i64 %26, %31
  %33 = call noalias ptr @malloc(i64 noundef %32) #5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.XsArray, ptr %34, i32 0, i32 0
  store ptr %33, ptr %35, align 8, !tbaa !5
  %36 = call i32 @XsArray_incAllocCount()
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %102

39:                                               ; preds = %23
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.XsArray, ptr %40, i32 0, i32 4
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %42, i32 0, i32 7
  %44 = load ptr, ptr %43, align 8, !tbaa !16
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %64

46:                                               ; preds = %39
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.XsArray, ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %49, i32 0, i32 7
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.XsArray, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.XsArray, ptr %56, i32 0, i32 1
  %58 = load i64, ptr %57, align 8, !tbaa !11
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.XsArray, ptr %59, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  %62 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %61, i32 0, i32 0
  %63 = load i64, ptr %62, align 8, !tbaa !14
  call void %51(ptr noundef %54, ptr noundef %55, i64 noundef %58, i64 noundef %63)
  br label %101

64:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %97, %64
  %66 = load i64, ptr %10, align 8, !tbaa !9
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.XsArray, ptr %67, i32 0, i32 1
  %69 = load i64, ptr %68, align 8, !tbaa !11
  %70 = icmp ult i64 %66, %69
  br i1 %70, label %71, label %100

71:                                               ; preds = %65
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.XsArray, ptr %72, i32 0, i32 4
  %74 = load ptr, ptr %73, align 8, !tbaa !13
  %75 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %74, i32 0, i32 3
  %76 = load ptr, ptr %75, align 8, !tbaa !18
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.XsArray, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !17
  %80 = load i64, ptr %10, align 8, !tbaa !9
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.XsArray, ptr %81, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !13
  %84 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %83, i32 0, i32 0
  %85 = load i64, ptr %84, align 8, !tbaa !14
  %86 = mul i64 %80, %85
  %87 = getelementptr inbounds i8, ptr %79, i64 %86
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = load i64, ptr %10, align 8, !tbaa !9
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.XsArray, ptr %90, i32 0, i32 4
  %92 = load ptr, ptr %91, align 8, !tbaa !13
  %93 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %92, i32 0, i32 0
  %94 = load i64, ptr %93, align 8, !tbaa !14
  %95 = mul i64 %89, %94
  %96 = getelementptr inbounds i8, ptr %88, i64 %95
  call void %76(ptr noundef %87, ptr noundef %96)
  br label %97

97:                                               ; preds = %71
  %98 = load i64, ptr %10, align 8, !tbaa !9
  %99 = add i64 %98, 1
  store i64 %99, ptr %10, align 8, !tbaa !9
  br label %65, !llvm.loop !19

100:                                              ; preds = %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %101

101:                                              ; preds = %100, %46
  br label %138

102:                                              ; preds = %23
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.XsArray, ptr %103, i32 0, i32 4
  %105 = load ptr, ptr %104, align 8, !tbaa !13
  %106 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %105, i32 0, i32 2
  %107 = load ptr, ptr %106, align 8, !tbaa !21
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %137

109:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %110

110:                                              ; preds = %133, %109
  %111 = load i64, ptr %11, align 8, !tbaa !9
  %112 = load ptr, ptr %9, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.XsArray, ptr %112, i32 0, i32 1
  %114 = load i64, ptr %113, align 8, !tbaa !11
  %115 = icmp ult i64 %111, %114
  br i1 %115, label %116, label %136

116:                                              ; preds = %110
  %117 = load ptr, ptr %9, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.XsArray, ptr %117, i32 0, i32 4
  %119 = load ptr, ptr %118, align 8, !tbaa !13
  %120 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %119, i32 0, i32 2
  %121 = load ptr, ptr %120, align 8, !tbaa !21
  %122 = load ptr, ptr %9, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.XsArray, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !17
  %125 = load i64, ptr %11, align 8, !tbaa !9
  %126 = load ptr, ptr %9, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.XsArray, ptr %126, i32 0, i32 4
  %128 = load ptr, ptr %127, align 8, !tbaa !13
  %129 = getelementptr inbounds %struct.XsArrayDescriptor, ptr %128, i32 0, i32 0
  %130 = load i64, ptr %129, align 8, !tbaa !14
  %131 = mul i64 %125, %130
  %132 = getelementptr inbounds i8, ptr %124, i64 %131
  call void %121(ptr noundef %132)
  br label %133

133:                                              ; preds = %116
  %134 = load i64, ptr %11, align 8, !tbaa !9
  %135 = add i64 %134, 1
  store i64 %135, ptr %11, align 8, !tbaa !9
  br label %110, !llvm.loop !22

136:                                              ; preds = %110
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %137

137:                                              ; preds = %136, %102
  br label %138

138:                                              ; preds = %137, %101
  br label %142

139:                                              ; preds = %4
  %140 = load ptr, ptr %9, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.XsArray, ptr %140, i32 0, i32 0
  store ptr null, ptr %141, align 8, !tbaa !5
  br label %142

142:                                              ; preds = %139, %138
  %143 = load ptr, ptr %9, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.XsArray, ptr %143, i32 0, i32 1
  %145 = load i64, ptr %144, align 8, !tbaa !11
  %146 = load ptr, ptr %9, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.XsArray, ptr %146, i32 0, i32 2
  store i64 %145, ptr %147, align 8, !tbaa !9
  %148 = load ptr, ptr %9, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.XsArray, ptr %148, i32 0, i32 3
  store i64 1, ptr %149, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

; 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)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @XsArray_incAllocCount() #3

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) "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 = { inlinehint 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"XsArray", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32}
!13 = !{!12, !6, i64 32}
!14 = !{!15, !10, i64 0}
!15 = !{!"XsArrayDescriptor", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!16 = !{!15, !6, i64 56}
!17 = !{!12, !6, i64 0}
!18 = !{!15, !6, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!15, !6, i64 16}
!22 = distinct !{!22, !20}


; 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
define dso_local void @XsArray_construct(ptr nocapture noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %2, ptr %6, align 8, !tbaa !9
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %45, label %7

7:                                                ; preds = %4
  %8 = load i64, ptr %1, align 8, !tbaa !11
  %9 = mul i64 %8, %2
  %10 = tail call noalias ptr @malloc(i64 noundef %9) #3
  store ptr %10, ptr %0, align 8, !tbaa !5
  %11 = tail call i32 @XsArray_incAllocCount()
  %.not41 = icmp eq ptr %3, null
  %12 = load ptr, ptr %5, align 8, !tbaa !13
  br i1 %.not41, label %32, label %13

13:                                               ; preds = %7
  %14 = getelementptr inbounds i8, ptr %12, i64 56
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %.not43 = icmp eq ptr %15, null
  br i1 %.not43, label %.preheader44, label %17

.preheader44:                                     ; preds = %13
  %16 = load i64, ptr %6, align 8, !tbaa !16
  %.not49 = icmp eq i64 %16, 0
  br i1 %.not49, label %.loopexit, label %.lr.ph

17:                                               ; preds = %13
  %18 = load ptr, ptr %0, align 8, !tbaa !17
  %19 = load i64, ptr %6, align 8, !tbaa !16
  %20 = load i64, ptr %12, align 8, !tbaa !11
  tail call void %15(ptr noundef %18, ptr noundef nonnull %3, i64 noundef %19, i64 noundef %20) #4
  %.pre = load i64, ptr %6, align 8, !tbaa !16
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader44, %.lr.ph
  %.03746 = phi i64 [ %29, %.lr.ph ], [ 0, %.preheader44 ]
  %21 = load ptr, ptr %5, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %21, i64 24
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  %24 = load ptr, ptr %0, align 8, !tbaa !17
  %25 = load i64, ptr %21, align 8, !tbaa !11
  %26 = mul i64 %25, %.03746
  %27 = getelementptr inbounds i8, ptr %24, i64 %26
  %28 = getelementptr inbounds i8, ptr %3, i64 %26
  tail call void %23(ptr noundef %27, ptr noundef nonnull %28) #4
  %29 = add nuw i64 %.03746, 1
  %30 = load i64, ptr %6, align 8, !tbaa !16
  %31 = icmp ult i64 %29, %30
  br i1 %31, label %.lr.ph, label %.loopexit, !llvm.loop !19

32:                                               ; preds = %7
  %33 = getelementptr inbounds i8, ptr %12, i64 16
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  %.not42 = icmp eq ptr %34, null
  %.pre52 = load i64, ptr %6, align 8, !tbaa !16
  br i1 %.not42, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %32
  %.not50 = icmp eq i64 %.pre52, 0
  br i1 %.not50, label %.loopexit, label %.lr.ph48

.lr.ph48:                                         ; preds = %.preheader, %.lr.ph48
  %.047 = phi i64 [ %42, %.lr.ph48 ], [ 0, %.preheader ]
  %35 = load ptr, ptr %5, align 8, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  %37 = load ptr, ptr %36, align 8, !tbaa !21
  %38 = load ptr, ptr %0, align 8, !tbaa !17
  %39 = load i64, ptr %35, align 8, !tbaa !11
  %40 = mul i64 %39, %.047
  %41 = getelementptr inbounds i8, ptr %38, i64 %40
  tail call void %37(ptr noundef %41) #4
  %42 = add nuw i64 %.047, 1
  %43 = load i64, ptr %6, align 8, !tbaa !16
  %44 = icmp ult i64 %42, %43
  br i1 %44, label %.lr.ph48, label %.loopexit, !llvm.loop !22

45:                                               ; preds = %4
  store ptr null, ptr %0, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph48, %.preheader44, %.preheader, %17, %32, %45
  %46 = phi i64 [ 0, %.preheader44 ], [ 0, %.preheader ], [ %.pre, %17 ], [ %.pre52, %32 ], [ 0, %45 ], [ %43, %.lr.ph48 ], [ %30, %.lr.ph ]
  %47 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %46, ptr %47, align 8, !tbaa !9
  %48 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 1, ptr %48, align 8, !tbaa !9
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @XsArray_incAllocCount() local_unnamed_addr #2

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { inlinehint 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 allocsize(0) }
attributes #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"XsArrayDescriptor", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!14, !6, i64 32}
!14 = !{!"XsArray", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32}
!15 = !{!12, !6, i64 56}
!16 = !{!14, !10, i64 8}
!17 = !{!14, !6, i64 0}
!18 = !{!12, !6, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!12, !6, i64 16}
!22 = distinct !{!22, !20}


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