; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/src (alglibinternal)

; 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.alglib_impl::ae_matrix" = type { i64, i64, i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.0 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon.0 = type { ptr }

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

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

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

17:                                               ; preds = %5
  store i32 1, ptr %13, align 4
  br label %71

18:                                               ; preds = %5
  %19 = load i64, ptr %9, align 8, !tbaa !9
  %20 = icmp slt i64 %19, 0
  br i1 %20, label %21, label %25

21:                                               ; preds = %18
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %22, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !11
  store i64 %24, ptr %9, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %21, %18
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %67, %25
  %27 = load i64, ptr %11, align 8, !tbaa !9
  %28 = load i64, ptr %9, align 8, !tbaa !9
  %29 = sub nsw i64 %28, 1
  %30 = icmp sle i64 %27, %29
  br i1 %30, label %31, label %70

31:                                               ; preds = %26
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %32, i32 0, i32 6
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = getelementptr inbounds ptr, ptr %34, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load i64, ptr %11, align 8, !tbaa !9
  %39 = getelementptr inbounds double, ptr %37, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !16
  store double %40, ptr %12, align 8, !tbaa !16
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %41, i32 0, i32 6
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = load i64, ptr %8, align 8, !tbaa !9
  %45 = getelementptr inbounds ptr, ptr %43, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = load i64, ptr %11, align 8, !tbaa !9
  %48 = getelementptr inbounds double, ptr %46, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !16
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %50, i32 0, i32 6
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load i64, ptr %7, align 8, !tbaa !9
  %54 = getelementptr inbounds ptr, ptr %52, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = load i64, ptr %11, align 8, !tbaa !9
  %57 = getelementptr inbounds double, ptr %55, i64 %56
  store double %49, ptr %57, align 8, !tbaa !16
  %58 = load double, ptr %12, align 8, !tbaa !16
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %59, i32 0, i32 6
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = load i64, ptr %8, align 8, !tbaa !9
  %63 = getelementptr inbounds ptr, ptr %61, i64 %62
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = load i64, ptr %11, align 8, !tbaa !9
  %66 = getelementptr inbounds double, ptr %64, i64 %65
  store double %58, ptr %66, align 8, !tbaa !16
  br label %67

67:                                               ; preds = %31
  %68 = load i64, ptr %11, align 8, !tbaa !9
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr %11, align 8, !tbaa !9
  br label %26, !llvm.loop !18

70:                                               ; preds = %26
  store i32 0, ptr %13, align 4
  br label %71

71:                                               ; preds = %70, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  %72 = load i32, ptr %13, align 4
  switch i32 %72, label %74 [
    i32 0, label %73
    i32 1, label %73
  ]

73:                                               ; preds = %71, %71
  ret void

74:                                               ; preds = %71
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTSN11alglib_impl9ae_matrixE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !13, i64 32, !14, i64 40, !7, i64 72}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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 nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN11alglib_impl8swaprowsEPNS_9ae_matrixElllPNS_8ae_stateE(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef readnone %4) local_unnamed_addr #0 {
  %6 = icmp eq i64 %1, %2
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %5
  %8 = icmp slt i64 %3, 0
  br i1 %8, label %9, label %12

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %9, %7
  %.0 = phi i64 [ %11, %9 ], [ %3, %7 ]
  %.not.not23 = icmp sgt i64 %.0, 0
  br i1 %.not.not23, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %12
  %13 = getelementptr inbounds i8, ptr %0, i64 72
  %xtraiter = and i64 %.0, 1
  %14 = icmp eq i64 %.0, 1
  br i1 %14, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %.0, 9223372036854775806
  br label %15

15:                                               ; preds = %15, %.lr.ph.new
  %.01924 = phi i64 [ 0, %.lr.ph.new ], [ %43, %15 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %15 ]
  %16 = load ptr, ptr %13, align 8, !tbaa !13
  %17 = getelementptr inbounds ptr, ptr %16, i64 %1
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = getelementptr inbounds double, ptr %18, i64 %.01924
  %20 = load double, ptr %19, align 8, !tbaa !15
  %21 = getelementptr inbounds ptr, ptr %16, i64 %2
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = getelementptr inbounds double, ptr %22, i64 %.01924
  %24 = load double, ptr %23, align 8, !tbaa !15
  store double %24, ptr %19, align 8, !tbaa !15
  %25 = load ptr, ptr %13, align 8, !tbaa !13
  %26 = getelementptr inbounds ptr, ptr %25, i64 %2
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds double, ptr %27, i64 %.01924
  store double %20, ptr %28, align 8, !tbaa !15
  %29 = or disjoint i64 %.01924, 1
  %30 = load ptr, ptr %13, align 8, !tbaa !13
  %31 = getelementptr inbounds ptr, ptr %30, i64 %1
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = getelementptr inbounds double, ptr %32, i64 %29
  %34 = load double, ptr %33, align 8, !tbaa !15
  %35 = getelementptr inbounds ptr, ptr %30, i64 %2
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  %37 = getelementptr inbounds double, ptr %36, i64 %29
  %38 = load double, ptr %37, align 8, !tbaa !15
  store double %38, ptr %33, align 8, !tbaa !15
  %39 = load ptr, ptr %13, align 8, !tbaa !13
  %40 = getelementptr inbounds ptr, ptr %39, i64 %2
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = getelementptr inbounds double, ptr %41, i64 %29
  store double %34, ptr %42, align 8, !tbaa !15
  %43 = add nuw nsw i64 %.01924, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %15, !llvm.loop !17

.loopexit.loopexit.unr-lcssa:                     ; preds = %15, %.lr.ph
  %.01924.unr = phi i64 [ 0, %.lr.ph ], [ %43, %15 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.loopexit.loopexit.epilog-lcssa

.loopexit.loopexit.epilog-lcssa:                  ; preds = %.loopexit.loopexit.unr-lcssa
  %44 = load ptr, ptr %13, align 8, !tbaa !13
  %45 = getelementptr inbounds ptr, ptr %44, i64 %1
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = getelementptr inbounds double, ptr %46, i64 %.01924.unr
  %48 = load double, ptr %47, align 8, !tbaa !15
  %49 = getelementptr inbounds ptr, ptr %44, i64 %2
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds double, ptr %50, i64 %.01924.unr
  %52 = load double, ptr %51, align 8, !tbaa !15
  store double %52, ptr %47, align 8, !tbaa !15
  %53 = load ptr, ptr %13, align 8, !tbaa !13
  %54 = getelementptr inbounds ptr, ptr %53, i64 %2
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  %56 = getelementptr inbounds double, ptr %55, i64 %.01924.unr
  store double %48, ptr %56, align 8, !tbaa !15
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit.epilog-lcssa, %.loopexit.loopexit.unr-lcssa, %12, %5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: 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)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"_ZTSN11alglib_impl9ae_matrixE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !8, i64 72}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !8, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass