; LLVM IR from stan-dev/math :: lib/boost_1.84.0/libs/serialization/src (codecvt_null)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK5boost7archive12codecvt_nullIwE5do_inER11__mbstate_tPKcS6_RS6_PwS8_RS8_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef %5, ptr noundef %6, ptr noundef nonnull align 8 dereferenceable(8) %7) unnamed_addr #0 align 2 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  %18 = load ptr, ptr %10, align 8
  br label %19

19:                                               ; preds = %40, %8
  %20 = load ptr, ptr %15, align 8, !tbaa !5
  %21 = load ptr, ptr %16, align 8, !tbaa !5
  %22 = icmp ne ptr %20, %21
  br i1 %22, label %23, label %47

23:                                               ; preds = %19
  %24 = load ptr, ptr %12, align 8, !tbaa !5
  %25 = load ptr, ptr %13, align 8, !tbaa !5
  %26 = icmp eq ptr %24, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  br label %47

28:                                               ; preds = %23
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = ptrtoint ptr %29 to i64
  %32 = ptrtoint ptr %30 to i64
  %33 = sub i64 %31, %32
  %34 = icmp sgt i64 4, %33
  br i1 %34, label %35, label %40

35:                                               ; preds = %28
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %36, ptr %37, align 8, !tbaa !5
  %38 = load ptr, ptr %15, align 8, !tbaa !5
  %39 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %38, ptr %39, align 8, !tbaa !5
  store i32 1, ptr %9, align 4
  br label %52

40:                                               ; preds = %28
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = load ptr, ptr %15, align 8, !tbaa !5
  %44 = getelementptr inbounds i32, ptr %43, i32 1
  store ptr %44, ptr %15, align 8, !tbaa !5
  store i32 %42, ptr %43, align 4, !tbaa !9
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 4
  store ptr %46, ptr %12, align 8, !tbaa !5
  br label %19, !llvm.loop !11

47:                                               ; preds = %27, %19
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %48, ptr %49, align 8, !tbaa !5
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  %51 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %50, ptr %51, align 8, !tbaa !5
  store i32 0, ptr %9, align 4
  br label %52

52:                                               ; preds = %47, %35
  %53 = load i32, ptr %9, align 4
  ret i32 %53
}

attributes #0 = { 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" }

!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 = !{!"wchar_t", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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 noundef range(i32 0, 2) i32 @_ZNK5boost7archive12codecvt_nullIwE5do_inER11__mbstate_tPKcS6_RS6_PwS8_RS8_(ptr nocapture noundef nonnull readnone align 8 dereferenceable(24) %0, ptr nocapture noundef nonnull readnone align 4 dereferenceable(8) %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %4, ptr noundef %5, ptr noundef readnone %6, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %7) unnamed_addr #0 align 2 {
  %9 = ptrtoint ptr %3 to i64
  %.not21 = icmp eq ptr %5, %6
  %10 = icmp eq ptr %2, %3
  %or.cond22 = or i1 %.not21, %10
  br i1 %or.cond22, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8, %14
  %.01824 = phi ptr [ %17, %14 ], [ %2, %8 ]
  %.01923 = phi ptr [ %16, %14 ], [ %5, %8 ]
  %11 = ptrtoint ptr %.01824 to i64
  %12 = sub i64 %9, %11
  %13 = icmp slt i64 %12, 4
  br i1 %13, label %._crit_edge, label %14

14:                                               ; preds = %.lr.ph
  %15 = load i32, ptr %.01824, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %.01923, i64 4
  store i32 %15, ptr %.01923, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %.01824, i64 4
  %.not = icmp eq ptr %16, %6
  %18 = icmp eq ptr %17, %3
  %or.cond = select i1 %.not, i1 true, i1 %18
  br i1 %or.cond, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %14, %8
  %.019.lcssa = phi ptr [ %5, %8 ], [ %16, %14 ], [ %.01923, %.lr.ph ]
  %.018.lcssa = phi ptr [ %2, %8 ], [ %17, %14 ], [ %.01824, %.lr.ph ]
  %.0 = phi i32 [ 0, %8 ], [ 0, %14 ], [ 1, %.lr.ph ]
  store ptr %.018.lcssa, ptr %4, align 8, !tbaa !11
  store ptr %.019.lcssa, ptr %7, align 8, !tbaa !11
  ret i32 %.0
}

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, !6, i64 0}
!6 = !{!"wchar_t", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: IPSCCPPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass