; 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_impl11ae_bool2strEbPcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl28ae_serializer_serialize_boolEPNS_13ae_serializerEbPNS_8ae_stateE(ptr noundef %0, i1 noundef zeroext %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %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
  %11 = zext i1 %1 to i8
  store i8 %11, ptr %5, align 1, !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
  %12 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %13 = trunc i8 %12 to i1
  %14 = getelementptr inbounds [14 x i8], ptr %7, i64 0, i64 0
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl11ae_bool2strEbPcPNS_8ae_stateE(i1 noundef zeroext %13, ptr noundef %14, ptr noundef %15)
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !13
  %19 = add nsw i64 %18, 1
  store i64 %19, ptr %17, align 8, !tbaa !13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %20, i32 0, i32 2
  %22 = load i64, ptr %21, align 8, !tbaa !13
  %23 = srem i64 %22, 5
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %28

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

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

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

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

60:                                               ; preds = %31
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %61, i32 0, i32 0
  %63 = load i64, ptr %62, align 8, !tbaa !19
  %64 = icmp eq i64 %63, 10
  br i1 %64, label %65, label %76

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

76:                                               ; preds = %60
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.alglib_impl::ae_serializer", ptr %77, i32 0, i32 0
  %79 = load i64, ptr %78, align 8, !tbaa !19
  %80 = icmp eq i64 %79, 12
  br i1 %80, label %81, label %93

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

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

96:                                               ; preds = %93, %81, %65, %54
  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
  %97 = load i32, ptr %10, align 4
  switch i32 %97, label %99 [
    i32 0, label %98
    i32 1, label %98
  ]

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

99:                                               ; preds = %96
  unreachable
}

; 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

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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !15, i64 16}
!14 = !{!"_ZTSN11alglib_impl13ae_serializerE", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !15, i64 64, !6, i64 72, !6, i64 80}
!15 = !{!"long", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!14, !15, i64 32}
!18 = !{!14, !15, i64 24}
!19 = !{!14, !15, i64 0}
!20 = !{!14, !6, i64 40}
!21 = !{!14, !6, i64 48}
!22 = !{!14, !6, i64 72}
!23 = !{!14, !15, 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_impl11ae_bool2strEbPcPNS_8ae_stateE(i1 noundef zeroext, 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 uwtable
define dso_local void @_ZN11alglib_impl28ae_serializer_serialize_boolEPNS_13ae_serializerEbPNS_8ae_stateE(ptr nocapture noundef %0, i1 noundef zeroext %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_impl11ae_bool2strEbPcPNS_8ae_stateE(i1 noundef zeroext %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
}

; 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

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