; LLVM IR from ncduy0303/Competitive-Programming :: Dynamic Programming/Elevator Rides.ll (Z5solvev)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::array" = type { [2 x i32] }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca %"struct.std::array", align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::array", align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::array", align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = zext i32 %15 to i64
  %17 = call ptr @llvm.stacksave.p0()
  store ptr %17, ptr %3, align 8
  %18 = alloca i32, i64 %16, align 16
  store i64 %16, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %29, %0
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %32

24:                                               ; preds = %19
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr %18, i64 %26
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %27)
  br label %29

29:                                               ; preds = %24
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %5, align 4, !tbaa !5
  br label %19, !llvm.loop !9

32:                                               ; preds = %23
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = shl i32 1, %33
  %35 = zext i32 %34 to i64
  %36 = alloca %"struct.std::array", i64 %35, align 16
  store i64 %35, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %37 = getelementptr inbounds %"struct.std::array", ptr %7, i32 0, i32 0
  store i32 0, ptr %37, align 4, !tbaa !5
  %38 = getelementptr inbounds i32, ptr %37, i64 1
  store i32 0, ptr %38, align 4, !tbaa !5
  %39 = getelementptr inbounds %"struct.std::array", ptr %36, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %39, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %111, %32
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = load i32, ptr %1, align 4, !tbaa !5
  %43 = shl i32 1, %42
  %44 = icmp slt i32 %41, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %40
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %114

46:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %47 = getelementptr inbounds %"struct.std::array", ptr %10, i32 0, i32 0
  %48 = load i32, ptr %1, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %47, align 4, !tbaa !5
  %50 = getelementptr inbounds i32, ptr %47, i64 1
  store i32 0, ptr %50, align 4, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %"struct.std::array", ptr %36, i64 %52
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %53, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %107, %46
  %55 = load i32, ptr %11, align 4, !tbaa !5
  %56 = load i32, ptr %1, align 4, !tbaa !5
  %57 = icmp slt i32 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %110

59:                                               ; preds = %54
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = load i32, ptr %11, align 4, !tbaa !5
  %62 = shl i32 1, %61
  %63 = and i32 %60, %62
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %106

65:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = load i32, ptr %11, align 4, !tbaa !5
  %68 = shl i32 1, %67
  %69 = xor i32 %66, %68
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds %"struct.std::array", ptr %36, i64 %70
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 8 %71, i64 8, i1 false), !tbaa.struct !11
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %12, i64 noundef 1) #7
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = load i32, ptr %11, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr %18, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = add nsw i32 %73, %77
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = icmp sle i32 %78, %79
  br i1 %80, label %81, label %89

81:                                               ; preds = %65
  %82 = load i32, ptr %11, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i32, ptr %18, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %12, i64 noundef 1) #7
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = add nsw i32 %87, %85
  store i32 %88, ptr %86, align 4, !tbaa !5
  br label %98

89:                                               ; preds = %65
  %90 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %12, i64 noundef 0) #7
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %90, align 4, !tbaa !5
  %93 = load i32, ptr %11, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i32, ptr %18, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %12, i64 noundef 1) #7
  store i32 %96, ptr %97, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %89, %81
  %99 = load i32, ptr %8, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds %"struct.std::array", ptr %36, i64 %100
  %102 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZSt3minISt5arrayIiLm2EEERKT_S4_S4_(ptr noundef nonnull align 4 dereferenceable(8) %101, ptr noundef nonnull align 4 dereferenceable(8) %12)
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds %"struct.std::array", ptr %36, i64 %104
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %105, ptr align 4 %102, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %106

106:                                              ; preds = %98, %59
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %11, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %11, align 4, !tbaa !5
  br label %54, !llvm.loop !13

110:                                              ; preds = %58
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %8, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %8, align 4, !tbaa !5
  br label %40, !llvm.loop !14

114:                                              ; preds = %45
  %115 = load i32, ptr %1, align 4, !tbaa !5
  %116 = shl i32 1, %115
  %117 = sub nsw i32 %116, 1
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds %"struct.std::array", ptr %36, i64 %118
  %120 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %119, i64 noundef 0) #7
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = load i32, ptr %1, align 4, !tbaa !5
  %123 = shl i32 1, %122
  %124 = sub nsw i32 %123, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds %"struct.std::array", ptr %36, i64 %125
  %127 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %126, i64 noundef 1) #7
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = icmp sgt i32 %128, 0
  %130 = zext i1 %129 to i32
  %131 = add nsw i32 %121, %130
  %132 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %131)
  %133 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %133)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #7
  ret void
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8), i64 noundef) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZSt3minISt5arrayIiLm2EEERKT_S4_S4_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #6

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { inlinehint 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 #7 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{i64 0, i64 8, !12}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::array" = type { [2 x i32] }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::array", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %5 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = zext i32 %6 to i64
  %8 = call ptr @llvm.stacksave.p0()
  %9 = alloca i32, i64 %7, align 16
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %12 = phi i32 [ %10, %0 ], [ %26, %.lr.ph ]
  %13 = shl nuw i32 1, %12
  %14 = zext i32 %13 to i64
  %15 = alloca %"struct.std::array", i64 %14, align 16
  store i32 0, ptr %15, align 16
  %.sroa.415.0..sroa_idx = getelementptr inbounds i8, ptr %15, i64 4
  store i32 0, ptr %.sroa.415.0..sroa_idx, align 4, !tbaa !9
  %16 = icmp sgt i32 %13, 1
  br i1 %16, label %.lr.ph32, label %._crit_edge33

.lr.ph32:                                         ; preds = %._crit_edge
  %17 = icmp sgt i32 %12, 0
  br i1 %17, label %.lr.ph32.split, label %.peel.next

.peel.next:                                       ; preds = %.lr.ph32
  %wide.trip.count = zext nneg i32 %13 to i64
  %18 = add nsw i32 %12, 1
  %19 = getelementptr inbounds i8, ptr %15, i64 8
  store i32 %18, ptr %19, align 8
  %.sroa.4.0..sroa_idx.us.peel = getelementptr inbounds i8, ptr %15, i64 12
  store i32 0, ptr %.sroa.4.0..sroa_idx.us.peel, align 4, !tbaa !9
  %20 = add nsw i64 %wide.trip.count, -2
  %min.iters.check = icmp ult i64 %20, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.peel.next
  %n.vec = and i64 %20, -4
  %ind.end = or disjoint i64 %n.vec, 2
  %broadcast.splatinsert = insertelement <2 x i32> poison, i32 %18, i64 0
  %broadcast.splat = shufflevector <2 x i32> %broadcast.splatinsert, <2 x i32> poison, <2 x i32> zeroinitializer
  %invariant.gep = getelementptr i8, ptr %15, i64 32
  %interleaved.vec = shufflevector <2 x i32> %broadcast.splat, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 2
  %21 = getelementptr inbounds %"struct.std::array", ptr %15, i64 %offset.idx
  %gep = getelementptr %"struct.std::array", ptr %invariant.gep, i64 %index
  store <4 x i32> %interleaved.vec, ptr %21, align 16
  store <4 x i32> %interleaved.vec, ptr %gep, align 16
  %index.next = add nuw i64 %index, 4
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !10

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %20, %n.vec
  br i1 %cmp.n, label %._crit_edge33, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.peel.next
  %indvars.iv39.ph = phi i64 [ 2, %.peel.next ], [ %ind.end, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %scalar.ph ], [ %indvars.iv39.ph, %scalar.ph.preheader ]
  %23 = getelementptr inbounds %"struct.std::array", ptr %15, i64 %indvars.iv39
  store i32 %18, ptr %23, align 8
  %.sroa.4.0..sroa_idx.us = getelementptr inbounds i8, ptr %23, i64 4
  store i32 0, ptr %.sroa.4.0..sroa_idx.us, align 4, !tbaa !9
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge33, label %scalar.ph, !llvm.loop !15

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %24 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %24)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge33:                                    ; preds = %scalar.ph, %._crit_edge29, %middle.block, %._crit_edge
  %.lcssa = phi i32 [ %13, %._crit_edge ], [ %13, %middle.block ], [ %50, %._crit_edge29 ], [ %13, %scalar.ph ]
  %29 = sext i32 %.lcssa to i64
  %30 = getelementptr %"struct.std::array", ptr %15, i64 %29
  %31 = getelementptr i8, ptr %30, i64 -8
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %31, i64 noundef 0) #6
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = load i32, ptr %1, align 4, !tbaa !5
  %notmask = shl nsw i32 -1, %34
  %35 = xor i32 %notmask, -1
  %36 = zext nneg i32 %35 to i64
  %37 = getelementptr inbounds %"struct.std::array", ptr %15, i64 %36
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %37, i64 noundef 1) #6
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = icmp sgt i32 %39, 0
  %41 = zext i1 %40 to i32
  %42 = add nsw i32 %33, %41
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %42)
  call void @llvm.stackrestore.p0(ptr %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret void

.lr.ph32.split:                                   ; preds = %.lr.ph32, %._crit_edge29
  %44 = phi i32 [ %49, %._crit_edge29 ], [ %12, %.lr.ph32 ]
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %._crit_edge29 ], [ 1, %.lr.ph32 ]
  %45 = add nsw i32 %44, 1
  %46 = getelementptr inbounds %"struct.std::array", ptr %15, i64 %indvars.iv46
  store i32 %45, ptr %46, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %46, i64 4
  store i32 0, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !9
  %47 = icmp sgt i32 %44, 0
  br i1 %47, label %.lr.ph28.preheader, label %._crit_edge29

.lr.ph28.preheader:                               ; preds = %.lr.ph32.split
  %48 = trunc nuw nsw i64 %indvars.iv46 to i32
  br label %.lr.ph28

._crit_edge29:                                    ; preds = %82, %.lr.ph32.split
  %49 = phi i32 [ %44, %.lr.ph32.split ], [ %83, %82 ]
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %50 = shl nuw i32 1, %49
  %51 = sext i32 %50 to i64
  %52 = icmp slt i64 %indvars.iv.next47, %51
  br i1 %52, label %.lr.ph32.split, label %._crit_edge33, !llvm.loop !17

.lr.ph28:                                         ; preds = %.lr.ph28.preheader, %82
  %53 = phi i32 [ %44, %.lr.ph28.preheader ], [ %83, %82 ]
  %54 = phi i32 [ %44, %.lr.ph28.preheader ], [ %84, %82 ]
  %indvars.iv43 = phi i64 [ 0, %.lr.ph28.preheader ], [ %indvars.iv.next44, %82 ]
  %55 = trunc nuw nsw i64 %indvars.iv43 to i32
  %56 = shl nuw i32 1, %55
  %57 = and i32 %56, %48
  %.not = icmp eq i32 %57, 0
  br i1 %.not, label %82, label %58

58:                                               ; preds = %.lr.ph28
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %59 = xor i32 %56, %48
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %"struct.std::array", ptr %15, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !9
  store i64 %62, ptr %3, align 8, !tbaa !9
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %3, i64 noundef 1) #6
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv43
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = add nsw i32 %66, %64
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %.not23 = icmp sgt i32 %67, %68
  br i1 %.not23, label %73, label %69

69:                                               ; preds = %58
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %3, i64 noundef 1) #6
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = add nsw i32 %71, %66
  store i32 %72, ptr %70, align 4, !tbaa !5
  br label %79

73:                                               ; preds = %58
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %3, i64 noundef 0) #6
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %74, align 4, !tbaa !5
  %77 = load i32, ptr %65, align 4, !tbaa !5
  %78 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) %3, i64 noundef 1) #6
  store i32 %77, ptr %78, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %73, %69
  %80 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZSt3minISt5arrayIiLm2EEERKT_S4_S4_(ptr noundef nonnull align 4 dereferenceable(8) %46, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %81 = load i64, ptr %80, align 4, !tbaa !9
  store i64 %81, ptr %46, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %.lr.ph28, %79
  %83 = phi i32 [ %53, %.lr.ph28 ], [ %.pre, %79 ]
  %84 = phi i32 [ %54, %.lr.ph28 ], [ %.pre, %79 ]
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %85 = sext i32 %84 to i64
  %86 = icmp slt i64 %indvars.iv.next44, %85
  br i1 %86, label %.lr.ph28, label %._crit_edge29, !llvm.loop !19
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZSt3minISt5arrayIiLm2EEERKT_S4_S4_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { 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 #5 = { inlinehint 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 #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11, !12, !13, !14}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.peeled.count", i32 1}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !11, !12, !14, !13}
!16 = distinct !{!16, !11}
!17 = distinct !{!17, !11, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = distinct !{!19, !11}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass