; 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 }

@.str.26 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [36 x i8], align 1

; 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
declare dso_local void @_ZN11alglib_impl8ae_breakEPNS_8ae_stateENS_13ae_error_typeEPKc(ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl10ae_int2strElPcPNS_8ae_stateE(i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEPKc(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl27ae_serializer_serialize_intEPNS_13ae_serializerElPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [14 x i8], align 1
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 14, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr @.str.26, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds [14 x i8], ptr %7, i64 0, i64 0
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl10ae_int2strElPcPNS_8ae_stateE(i64 noundef %11, ptr noundef %12, ptr noundef %13)
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %14, i32 0, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = add nsw i64 %16, 1
  store i64 %17, ptr %15, align 8, !tbaa !11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %18, i32 0, i32 2
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = srem i64 %20, 5
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %23, label %26

23:                                               ; preds = %3
  %24 = getelementptr inbounds [14 x i8], ptr %7, i64 0, i64 0
  %25 = call ptr @strcat(ptr noundef %24, ptr noundef @.str.27) #5
  br label %29

26:                                               ; preds = %3
  %27 = getelementptr inbounds [14 x i8], ptr %7, i64 0, i64 0
  %28 = call ptr @strcat(ptr noundef %27, ptr noundef @.str.28) #5
  br label %29

29:                                               ; preds = %26, %23
  %30 = getelementptr inbounds [14 x i8], ptr %7, i64 0, i64 0
  %31 = call i64 @strlen(ptr noundef %30) #6
  store i64 %31, ptr %9, align 8, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %32, i32 0, i32 4
  %34 = load i64, ptr %33, align 8, !tbaa !13
  %35 = load i64, ptr %9, align 8, !tbaa !9
  %36 = add nsw i64 %34, %35
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %37, i32 0, i32 3
  %39 = load i64, ptr %38, align 8, !tbaa !14
  %40 = icmp slt i64 %36, %39
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %40, ptr noundef %41, ptr noundef %42)
  %43 = load i64, ptr %9, align 8, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %44, i32 0, i32 4
  %46 = load i64, ptr %45, align 8, !tbaa !13
  %47 = add nsw i64 %46, %43
  store i64 %47, ptr %45, align 8, !tbaa !13
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %48, i32 0, i32 0
  %50 = load i64, ptr %49, align 8, !tbaa !15
  %51 = icmp eq i64 %50, 11
  br i1 %51, label %52, label %58

52:                                               ; preds = %29
  %53 = getelementptr inbounds [14 x i8], ptr %7, i64 0, i64 0
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %54, i32 0, i32 5
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  %57 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEPKc(ptr noundef nonnull align 8 dereferenceable(32) %56, ptr noundef %53)
  store i32 1, ptr %10, align 4
  br label %94

58:                                               ; preds = %29
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %59, i32 0, i32 0
  %61 = load i64, ptr %60, align 8, !tbaa !15
  %62 = icmp eq i64 %61, 10
  br i1 %62, label %63, label %74

63:                                               ; preds = %58
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %64, i32 0, i32 6
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = getelementptr inbounds [14 x i8], ptr %7, i64 0, i64 0
  %68 = call ptr @strcat(ptr noundef %66, ptr noundef %67) #5
  %69 = load i64, ptr %9, align 8, !tbaa !9
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %70, i32 0, i32 6
  %72 = load ptr, ptr %71, align 8, !tbaa !17
  %73 = getelementptr inbounds i8, ptr %72, i64 %69
  store ptr %73, ptr %71, align 8, !tbaa !17
  store i32 1, ptr %10, align 4
  br label %94

74:                                               ; preds = %58
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %75, i32 0, i32 0
  %77 = load i64, ptr %76, align 8, !tbaa !15
  %78 = icmp eq i64 %77, 12
  br i1 %78, label %79, label %91

79:                                               ; preds = %74
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %80, i32 0, i32 9
  %82 = load ptr, ptr %81, align 8, !tbaa !18
  %83 = getelementptr inbounds [14 x i8], ptr %7, i64 0, i64 0
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %84, i32 0, i32 8
  %86 = load i64, ptr %85, align 8, !tbaa !19
  %87 = call noundef signext i8 %82(ptr noundef %83, i64 noundef %86)
  %88 = sext i8 %87 to i32
  %89 = icmp eq i32 %88, 0
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %89, ptr noundef @.str.29, ptr noundef %90)
  store i32 1, ptr %10, align 4
  br label %94

91:                                               ; preds = %74
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN11alglib_impl8ae_breakEPNS_8ae_stateENS_13ae_error_typeEPKc(ptr noundef %92, i32 noundef 3, ptr noundef %93)
  store i32 0, ptr %10, align 4
  br label %94

94:                                               ; preds = %91, %79, %63, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 14, ptr %7) #5
  %95 = load i32, ptr %10, align 4
  switch i32 %95, label %97 [
    i32 0, label %96
    i32 1, label %96
  ]

96:                                               ; preds = %94, %94
  ret void

97:                                               ; preds = %94
  unreachable
}

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 = { 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 #3 = { nounwind willreturn memory(read) "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 "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 willreturn memory(read) }

!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 16}
!12 = !{!"_ZTSN11alglib_impl13ae_serializerE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !6, i64 80}
!13 = !{!12, !10, i64 32}
!14 = !{!12, !10, i64 24}
!15 = !{!12, !10, i64 0}
!16 = !{!12, !6, i64 40}
!17 = !{!12, !6, i64 48}
!18 = !{!12, !6, i64 72}
!19 = !{!12, !10, i64 64}


; 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"

@.str.26 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [36 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl8ae_breakEPNS_8ae_stateENS_13ae_error_typeEPKc(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl10ae_int2strElPcPNS_8ae_stateE(i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEPKc(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl27ae_serializer_serialize_intEPNS_13ae_serializerElPNS_8ae_stateE(ptr nocapture noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca [14 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 14, ptr nonnull %4) #5
  call void @_ZN11alglib_impl10ae_int2strElPcPNS_8ae_stateE(i64 noundef %1, ptr noundef nonnull %4, ptr noundef %2)
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = add nsw i64 %6, 1
  store i64 %7, ptr %5, align 8, !tbaa !5
  %8 = srem i64 %7, 5
  %.not = icmp eq i64 %8, 0
  %.str.28..str.27 = select i1 %.not, ptr @.str.28, ptr @.str.27
  %9 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) %.str.28..str.27) #5
  %10 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %4) #6
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load i64, ptr %11, align 8, !tbaa !11
  %13 = add nsw i64 %12, %10
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load i64, ptr %14, align 8, !tbaa !12
  %16 = icmp slt i64 %13, %15
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %16, ptr noundef nonnull @.str.26, ptr noundef %2)
  %17 = load i64, ptr %11, align 8, !tbaa !11
  %18 = add nsw i64 %17, %10
  store i64 %18, ptr %11, align 8, !tbaa !11
  %19 = load i64, ptr %0, align 8, !tbaa !13
  switch i64 %19, label %37 [
    i64 11, label %20
    i64 10, label %24
    i64 12, label %30
  ]

20:                                               ; preds = %3
  %21 = getelementptr inbounds i8, ptr %0, i64 40
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEPKc(ptr noundef nonnull align 8 dereferenceable(32) %22, ptr noundef nonnull %4)
  br label %38

24:                                               ; preds = %3
  %25 = getelementptr inbounds i8, ptr %0, i64 48
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %26, ptr noundef nonnull dereferenceable(1) %4) #5
  %28 = load ptr, ptr %25, align 8, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %28, i64 %10
  store ptr %29, ptr %25, align 8, !tbaa !15
  br label %38

30:                                               ; preds = %3
  %31 = getelementptr inbounds i8, ptr %0, i64 72
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %0, i64 64
  %34 = load i64, ptr %33, align 8, !tbaa !17
  %35 = call noundef signext i8 %32(ptr noundef nonnull %4, i64 noundef %34)
  %36 = icmp eq i8 %35, 0
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %36, ptr noundef nonnull @.str.29, ptr noundef %2)
  br label %38

37:                                               ; preds = %3
  call void @_ZN11alglib_impl8ae_breakEPNS_8ae_stateENS_13ae_error_typeEPKc(ptr noundef %2, i32 noundef 3, ptr noundef nonnull @.str.26)
  br label %38

38:                                               ; preds = %37, %30, %24, %20
  call void @llvm.lifetime.end.p0(i64 14, ptr nonnull %4) #5
  ret void
}

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

!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 16}
!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 32}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 40}
!15 = !{!6, !10, i64 48}
!16 = !{!6, !10, i64 72}
!17 = !{!6, !7, i64 64}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass