; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/tests (test_c)

; 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.rec4serialization = type { %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector" }
%"struct.alglib_impl::ae_vector" = type { i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon = 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 uwtable
define dso_local void @_Z22rec4serializationallocPN11alglib_impl13ae_serializerEP17rec4serializationPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %8)
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %19, %3
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.rec4serialization, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %12, i32 0, i32 0
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = sub nsw i64 %14, 1
  %16 = icmp sle i64 %10, %15
  br i1 %16, label %17, label %22

17:                                               ; preds = %9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %18)
  br label %19

19:                                               ; preds = %17
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = add nsw i64 %20, 1
  store i64 %21, ptr %7, align 8, !tbaa !9
  br label %9, !llvm.loop !16

22:                                               ; preds = %9
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %23)
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %34, %22
  %25 = load i64, ptr %7, align 8, !tbaa !9
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.rec4serialization, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %27, i32 0, i32 0
  %29 = load i64, ptr %28, align 8, !tbaa !18
  %30 = sub nsw i64 %29, 1
  %31 = icmp sle i64 %25, %30
  br i1 %31, label %32, label %37

32:                                               ; preds = %24
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %33)
  br label %34

34:                                               ; preds = %32
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %7, align 8, !tbaa !9
  br label %24, !llvm.loop !19

37:                                               ; preds = %24
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %38)
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %49, %37
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.rec4serialization, ptr %41, i32 0, i32 2
  %43 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %42, i32 0, i32 0
  %44 = load i64, ptr %43, align 8, !tbaa !20
  %45 = sub nsw i64 %44, 1
  %46 = icmp sle i64 %40, %45
  br i1 %46, label %47, label %52

47:                                               ; preds = %39
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %48)
  br label %49

49:                                               ; preds = %47
  %50 = load i64, ptr %7, align 8, !tbaa !9
  %51 = add nsw i64 %50, 1
  store i64 %51, ptr %7, align 8, !tbaa !9
  br label %39, !llvm.loop !21

52:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

declare void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef) #2

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

!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 0}
!12 = !{!"_ZTS17rec4serialization", !13, i64 0, !13, i64 64, !13, i64 128}
!13 = !{!"_ZTSN11alglib_impl9ae_vectorE", !10, i64 0, !10, i64 8, !14, i64 16, !15, i64 24, !7, i64 56}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !10, i64 64}
!19 = distinct !{!19, !17}
!20 = !{!12, !10, i64 128}
!21 = distinct !{!21, !17}


; 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 uwtable
define dso_local void @_Z22rec4serializationallocPN11alglib_impl13ae_serializerEP17rec4serializationPNS_8ae_stateE(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readnone %2) local_unnamed_addr #0 {
  tail call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %0)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %.not.not16 = icmp sgt i64 %4, 0
  br i1 %.not.not16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.017 = phi i64 [ %5, %.lr.ph ], [ 0, %3 ]
  tail call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %0)
  %5 = add nuw nsw i64 %.017, 1
  %6 = load i64, ptr %1, align 8, !tbaa !5
  %.not.not = icmp slt i64 %5, %6
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %3
  tail call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %0)
  %7 = getelementptr inbounds i8, ptr %1, i64 64
  %8 = load i64, ptr %7, align 8, !tbaa !16
  %.not.not1418 = icmp sgt i64 %8, 0
  br i1 %.not.not1418, label %.lr.ph21, label %._crit_edge22

.lr.ph21:                                         ; preds = %._crit_edge, %.lr.ph21
  %.119 = phi i64 [ %9, %.lr.ph21 ], [ 0, %._crit_edge ]
  tail call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %0)
  %9 = add nuw nsw i64 %.119, 1
  %10 = load i64, ptr %7, align 8, !tbaa !16
  %.not.not14 = icmp slt i64 %9, %10
  br i1 %.not.not14, label %.lr.ph21, label %._crit_edge22, !llvm.loop !17

._crit_edge22:                                    ; preds = %.lr.ph21, %._crit_edge
  tail call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %0)
  %11 = getelementptr inbounds i8, ptr %1, i64 128
  %12 = load i64, ptr %11, align 8, !tbaa !18
  %.not.not1523 = icmp sgt i64 %12, 0
  br i1 %.not.not1523, label %.lr.ph26, label %._crit_edge27

.lr.ph26:                                         ; preds = %._crit_edge22, %.lr.ph26
  %.224 = phi i64 [ %13, %.lr.ph26 ], [ 0, %._crit_edge22 ]
  tail call void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef %0)
  %13 = add nuw nsw i64 %.224, 1
  %14 = load i64, ptr %11, align 8, !tbaa !18
  %.not.not15 = icmp slt i64 %13, %14
  br i1 %.not.not15, label %.lr.ph26, label %._crit_edge27, !llvm.loop !19

._crit_edge27:                                    ; preds = %.lr.ph26, %._crit_edge22
  ret void
}

declare void @_ZN11alglib_impl25ae_serializer_alloc_entryEPNS_13ae_serializerE(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { "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, !8, i64 0}
!6 = !{!"_ZTS17rec4serialization", !7, i64 0, !7, i64 64, !7, i64 128}
!7 = !{!"_ZTSN11alglib_impl9ae_vectorE", !8, i64 0, !8, i64 8, !11, i64 16, !12, i64 24, !9, i64 56}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!13 = !{!"any pointer", !9, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!6, !8, i64 64}
!17 = distinct !{!17, !15}
!18 = !{!6, !8, i64 128}
!19 = distinct !{!19, !15}


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