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

; 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_serializer" = type { i64, i64, i64, i64, i64, ptr, ptr, ptr, i64, ptr, 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 noundef i64 @_ZN11alglib_impl28ae_serializer_get_alloc_sizeEPNS_13ae_serializerE(ptr noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %8, i32 0, i32 0
  store i64 2, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %10, i32 0, i32 1
  %12 = load i64, ptr %11, align 8, !tbaa !12
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %14, label %20

14:                                               ; preds = %1
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %15, i32 0, i32 3
  store i64 4, ptr %16, align 8, !tbaa !13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %17, i32 0, i32 3
  %19 = load i64, ptr %18, align 8, !tbaa !13
  store i64 %19, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %64

20:                                               ; preds = %1
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %21, i32 0, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !12
  %24 = sdiv i64 %23, 5
  store i64 %24, ptr %4, align 8, !tbaa !14
  store i64 5, ptr %5, align 8, !tbaa !14
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %25, i32 0, i32 1
  %27 = load i64, ptr %26, align 8, !tbaa !12
  %28 = srem i64 %27, 5
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %37

30:                                               ; preds = %20
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %31, i32 0, i32 1
  %33 = load i64, ptr %32, align 8, !tbaa !12
  %34 = srem i64 %33, 5
  store i64 %34, ptr %5, align 8, !tbaa !14
  %35 = load i64, ptr %4, align 8, !tbaa !14
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %4, align 8, !tbaa !14
  br label %37

37:                                               ; preds = %30, %20
  %38 = load i64, ptr %4, align 8, !tbaa !14
  %39 = sub nsw i64 %38, 1
  %40 = mul nsw i64 %39, 5
  %41 = load i64, ptr %5, align 8, !tbaa !14
  %42 = add nsw i64 %40, %41
  %43 = mul nsw i64 %42, 11
  store i64 %43, ptr %6, align 8, !tbaa !14
  %44 = load i64, ptr %4, align 8, !tbaa !14
  %45 = sub nsw i64 %44, 1
  %46 = mul nsw i64 %45, 4
  %47 = load i64, ptr %5, align 8, !tbaa !14
  %48 = sub nsw i64 %47, 1
  %49 = add nsw i64 %46, %48
  %50 = load i64, ptr %6, align 8, !tbaa !14
  %51 = add nsw i64 %50, %49
  store i64 %51, ptr %6, align 8, !tbaa !14
  %52 = load i64, ptr %4, align 8, !tbaa !14
  %53 = mul nsw i64 %52, 2
  %54 = load i64, ptr %6, align 8, !tbaa !14
  %55 = add nsw i64 %54, %53
  store i64 %55, ptr %6, align 8, !tbaa !14
  %56 = load i64, ptr %6, align 8, !tbaa !14
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %6, align 8, !tbaa !14
  %58 = load i64, ptr %6, align 8, !tbaa !14
  %59 = add nsw i64 %58, 1
  store i64 %59, ptr %6, align 8, !tbaa !14
  %60 = load i64, ptr %6, align 8, !tbaa !14
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %61, i32 0, i32 3
  store i64 %60, ptr %62, align 8, !tbaa !13
  %63 = load i64, ptr %6, align 8, !tbaa !14
  store i64 %63, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %64

64:                                               ; preds = %37, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %65 = load i64, ptr %2, align 8
  ret i64 %65
}

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, !11, i64 0}
!10 = !{!"_ZTSN11alglib_impl13ae_serializerE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !6, i64 72, !6, i64 80}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 24}
!14 = !{!11, !11, 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef range(i64 -9223372036854775806, -9223372036854775808) i64 @_ZN11alglib_impl28ae_serializer_get_alloc_sizeEPNS_13ae_serializerE(ptr nocapture noundef %0) local_unnamed_addr #0 {
  store i64 2, ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i64, ptr %2, align 8, !tbaa !11
  %4 = icmp eq i64 %3, 0
  br i1 %4, label %19, label %5

5:                                                ; preds = %1
  %6 = sdiv i64 %3, 5
  %7 = srem i64 %3, 5
  %.not = icmp ne i64 %7, 0
  %8 = zext i1 %.not to i64
  %spec.select = add nsw i64 %6, %8
  %spec.select24 = select i1 %.not, i64 %7, i64 5
  %9 = add nsw i64 %spec.select, -1
  %10 = mul nsw i64 %9, 5
  %11 = add nsw i64 %10, %spec.select24
  %12 = mul nsw i64 %11, 11
  %13 = shl nsw i64 %9, 2
  %14 = shl nsw i64 %spec.select, 1
  %15 = add nsw i64 %spec.select24, 1
  %16 = add i64 %15, %14
  %17 = add i64 %16, %13
  %18 = add i64 %17, %12
  br label %19

19:                                               ; preds = %1, %5
  %.sink = phi i64 [ %18, %5 ], [ 4, %1 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %.sink, ptr %20, align 8
  ret i64 %.sink
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 0}
!6 = !{!"_ZTSN11alglib_impl13ae_serializerE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !10, i64 72, !10, i64 80}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass