; LLVM IR from ADJA/algos :: DP (LIS)

; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [105000 x i32], align 16
@d = external dso_local global [105000 x i32], align 16
@ind = external dso_local global [105000 x i32], align 16
@pr = external dso_local global [105000 x i32], align 16
@ansv = external dso_local global %"class.std::vector", align 8
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef getelementptr inbounds ([105000 x i32], ptr @a, i64 0, i64 1), ptr noundef @k, ptr noundef @b, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %30, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp sle i32 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %33

15:                                               ; preds = %10
  %16 = load i32, ptr @k, align 4, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sub nsw i32 %17, 1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = mul nsw i32 %16, %21
  %23 = load i32, ptr @b, align 4, !tbaa !5
  %24 = add nsw i32 %22, %23
  %25 = load i32, ptr @m, align 4, !tbaa !5
  %26 = srem i32 %24, %25
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %28
  store i32 %26, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %15
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !9

33:                                               ; preds = %14
  store i32 -1000000000, ptr @d, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %43, %33
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = icmp sle i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %46

39:                                               ; preds = %34
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [105000 x i32], ptr @d, i64 0, i64 %41
  store i32 1000000000, ptr %42, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %39
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !5
  br label %34, !llvm.loop !11

46:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %112, %46
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = icmp sle i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %115

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %53 = load i32, ptr @n, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr @d, i64 %54
  %56 = getelementptr inbounds i32, ptr %55, i64 1
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %58
  %60 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef getelementptr inbounds (i32, ptr @d, i64 1), ptr noundef %56, ptr noundef nonnull align 4 dereferenceable(4) %59)
  %61 = ptrtoint ptr %60 to i64
  %62 = sub i64 %61, ptrtoint (ptr @d to i64)
  %63 = sdiv exact i64 %62, 4
  %64 = trunc i64 %63 to i32
  store i32 %64, ptr %5, align 4, !tbaa !5
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [105000 x i32], ptr @d, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = icmp slt i32 %69, %73
  br i1 %74, label %75, label %111

75:                                               ; preds = %52
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [105000 x i32], ptr @d, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = icmp slt i32 %79, %83
  br i1 %84, label %85, label %111

85:                                               ; preds = %75
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [105000 x i32], ptr @d, i64 0, i64 %91
  store i32 %89, ptr %92, align 4, !tbaa !5
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [105000 x i32], ptr @ind, i64 0, i64 %95
  store i32 %93, ptr %96, align 4, !tbaa !5
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = sub nsw i32 %97, 1
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [105000 x i32], ptr @ind, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = load i32, ptr %4, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [105000 x i32], ptr @pr, i64 0, i64 %103
  store i32 %101, ptr %104, align 4, !tbaa !5
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = load i32, ptr @ans, align 4, !tbaa !5
  %107 = icmp sgt i32 %105, %106
  br i1 %107, label %108, label %110

108:                                              ; preds = %85
  %109 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %109, ptr @ans, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %108, %85
  br label %111

111:                                              ; preds = %110, %75, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %4, align 4, !tbaa !5
  br label %47, !llvm.loop !12

115:                                              ; preds = %51
  %116 = load i32, ptr @ans, align 4, !tbaa !5
  %117 = icmp eq i32 %116, 1
  br i1 %117, label %118, label %121

118:                                              ; preds = %115
  %119 = load i32, ptr getelementptr inbounds ([105000 x i32], ptr @a, i64 0, i64 1), align 4, !tbaa !5
  %120 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %119)
  br label %155

121:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %122 = load i32, ptr @ans, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [105000 x i32], ptr @ind, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  store i32 %125, ptr %6, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %129, %121
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %137

129:                                              ; preds = %126
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %131
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @ansv, ptr noundef nonnull align 4 dereferenceable(4) %132)
  %133 = load i32, ptr %6, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [105000 x i32], ptr @pr, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  store i32 %136, ptr %6, align 4, !tbaa !5
  br label %126, !llvm.loop !13

137:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %138 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @ansv) #6
  %139 = trunc i64 %138 to i32
  %140 = sub nsw i32 %139, 1
  store i32 %140, ptr %7, align 4, !tbaa !5
  br label %141

141:                                              ; preds = %151, %137
  %142 = load i32, ptr %7, align 4, !tbaa !5
  %143 = icmp sge i32 %142, 0
  br i1 %143, label %145, label %144

144:                                              ; preds = %141
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %154

145:                                              ; preds = %141
  %146 = load i32, ptr %7, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @ansv, i64 noundef %147) #6
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %149)
  br label %151

151:                                              ; preds = %145
  %152 = load i32, ptr %7, align 4, !tbaa !5
  %153 = add nsw i32 %152, -1
  store i32 %153, ptr %7, align 4, !tbaa !5
  br label %141, !llvm.loop !14

154:                                              ; preds = %144
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %155

155:                                              ; preds = %154, %118
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #4 align 2

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

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

attributes #0 = { mustprogress norecurse 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #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 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [105000 x i32], align 16
@d = external dso_local global [105000 x i32], align 16
@ind = external dso_local local_unnamed_addr global [105000 x i32], align 16
@pr = external dso_local local_unnamed_addr global [105000 x i32], align 16
@ansv = external dso_local global %"class.std::vector", align 8
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 4), ptr noundef nonnull @k, ptr noundef nonnull @b, ptr noundef nonnull @m)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not40 = icmp slt i32 %3, 2
  br i1 %.not40, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %4 = load i32, ptr @k, align 4, !tbaa !5
  %5 = load i32, ptr @b, align 4, !tbaa !5
  %6 = load i32, ptr @m, align 4, !tbaa !5
  %7 = add nuw i32 %3, 1
  %wide.trip.count = zext i32 %7 to i64
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  %xtraiter = and i64 %wide.trip.count, 1
  %8 = icmp eq i32 %7, 3
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %9 = and i64 %wide.trip.count, 4294967294
  %10 = add nsw i64 %9, -4
  br label %20

._crit_edge.loopexit.unr-lcssa:                   ; preds = %20, %.lr.ph
  %.unr = phi i32 [ %.pre, %.lr.ph ], [ %28, %20 ]
  %indvars.iv.unr = phi i64 [ 2, %.lr.ph ], [ %indvars.iv.next.1, %20 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %11 = mul nsw i32 %.unr, %4
  %12 = add nsw i32 %11, %5
  %13 = srem i32 %12, %6
  %14 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %indvars.iv.unr
  store i32 %13, ptr %14, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %0
  store i32 -1000000000, ptr @d, align 16, !tbaa !5
  %.not3642 = icmp slt i32 %3, 1
  br i1 %.not3642, label %._crit_edge49, label %.lr.ph45.preheader

.lr.ph45.preheader:                               ; preds = %._crit_edge
  %15 = add nuw i32 %3, 1
  %wide.trip.count63 = zext i32 %15 to i64
  %16 = zext nneg i32 %3 to i64
  %min.iters.check = icmp ult i32 %3, 8
  br i1 %min.iters.check, label %.lr.ph45.preheader71, label %vector.ph

.lr.ph45.preheader71:                             ; preds = %middle.block, %.lr.ph45.preheader
  %indvars.iv60.ph = phi i64 [ 1, %.lr.ph45.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph45

vector.ph:                                        ; preds = %.lr.ph45.preheader
  %n.vec = and i64 %16, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  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, 1
  %17 = getelementptr inbounds [105000 x i32], ptr @d, i64 0, i64 %offset.idx
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  store <4 x i32> <i32 1000000000, i32 1000000000, i32 1000000000, i32 1000000000>, ptr %17, align 4, !tbaa !5
  store <4 x i32> <i32 1000000000, i32 1000000000, i32 1000000000, i32 1000000000>, ptr %18, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %19 = icmp eq i64 %index.next, %n.vec
  br i1 %19, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %16
  br i1 %cmp.n, label %.preheader, label %.lr.ph45.preheader71

20:                                               ; preds = %20, %.lr.ph.new
  %21 = phi i32 [ %.pre, %.lr.ph.new ], [ %28, %20 ]
  %indvars.iv = phi i64 [ 2, %.lr.ph.new ], [ %indvars.iv.next.1, %20 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %20 ]
  %22 = mul nsw i32 %21, %4
  %23 = add nsw i32 %22, %5
  %24 = srem i32 %23, %6
  %25 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %indvars.iv
  store i32 %24, ptr %25, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %26 = mul nsw i32 %24, %4
  %27 = add nsw i32 %26, %5
  %28 = srem i32 %27, %6
  %29 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %indvars.iv.next
  store i32 %28, ptr %29, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter, %10
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %20, !llvm.loop !13

.preheader:                                       ; preds = %.lr.ph45, %middle.block
  br i1 %.not3642, label %._crit_edge49, label %.lr.ph48

.lr.ph45:                                         ; preds = %.lr.ph45.preheader71, %.lr.ph45
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %.lr.ph45 ], [ %indvars.iv60.ph, %.lr.ph45.preheader71 ]
  %30 = getelementptr inbounds [105000 x i32], ptr @d, i64 0, i64 %indvars.iv60
  store i32 1000000000, ptr %30, align 4, !tbaa !5
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %exitcond64.not = icmp eq i64 %indvars.iv.next61, %wide.trip.count63
  br i1 %exitcond64.not, label %.preheader, label %.lr.ph45, !llvm.loop !14

._crit_edge49:                                    ; preds = %61, %._crit_edge, %.preheader
  %31 = load i32, ptr @ans, align 4, !tbaa !5
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %64, label %67

.lr.ph48:                                         ; preds = %.preheader, %61
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %61 ], [ 1, %.preheader ]
  %33 = phi i32 [ %62, %61 ], [ %3, %.preheader ]
  %34 = sext i32 %33 to i64
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @d, i64 4), i64 %34
  %35 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %indvars.iv65
  %36 = tail call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @d, i64 4), ptr noundef nonnull %gep, ptr noundef nonnull align 4 dereferenceable(4) %35)
  %37 = ptrtoint ptr %36 to i64
  %38 = sub i64 %37, ptrtoint (ptr @d to i64)
  %39 = lshr exact i64 %38, 2
  %40 = trunc i64 %39 to i32
  %41 = shl i64 %38, 30
  %sext = add i64 %41, -4294967296
  %42 = ashr i64 %sext, 32
  %43 = getelementptr inbounds [105000 x i32], ptr @d, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %35, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %61

47:                                               ; preds = %.lr.ph48
  %48 = ashr i64 %41, 32
  %49 = getelementptr inbounds [105000 x i32], ptr @d, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = icmp slt i32 %45, %50
  br i1 %51, label %52, label %61

52:                                               ; preds = %47
  store i32 %45, ptr %49, align 4, !tbaa !5
  %53 = getelementptr inbounds [105000 x i32], ptr @ind, i64 0, i64 %48
  %54 = trunc nuw nsw i64 %indvars.iv65 to i32
  store i32 %54, ptr %53, align 4, !tbaa !5
  %55 = getelementptr inbounds [105000 x i32], ptr @ind, i64 0, i64 %42
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = getelementptr inbounds [105000 x i32], ptr @pr, i64 0, i64 %indvars.iv65
  store i32 %56, ptr %57, align 4, !tbaa !5
  %58 = load i32, ptr @ans, align 4, !tbaa !5
  %59 = icmp slt i32 %58, %40
  br i1 %59, label %60, label %61

60:                                               ; preds = %52
  store i32 %40, ptr @ans, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %52, %60, %47, %.lr.ph48
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %.not37.not = icmp slt i64 %indvars.iv65, %63
  br i1 %.not37.not, label %.lr.ph48, label %._crit_edge49, !llvm.loop !15

64:                                               ; preds = %._crit_edge49
  %65 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  %66 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %65)
  br label %.loopexit

67:                                               ; preds = %._crit_edge49
  %68 = sext i32 %31 to i64
  %69 = getelementptr inbounds [105000 x i32], ptr @ind, i64 0, i64 %68
  %.02850 = load i32, ptr %69, align 4, !tbaa !5
  %.not3851 = icmp eq i32 %.02850, 0
  br i1 %.not3851, label %._crit_edge55, label %.lr.ph54

.lr.ph54:                                         ; preds = %67, %.lr.ph54
  %.02852 = phi i32 [ %.028, %.lr.ph54 ], [ %.02850, %67 ]
  %70 = sext i32 %.02852 to i64
  %71 = getelementptr inbounds [105000 x i32], ptr @a, i64 0, i64 %70
  tail call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @ansv, ptr noundef nonnull align 4 dereferenceable(4) %71)
  %72 = getelementptr inbounds [105000 x i32], ptr @pr, i64 0, i64 %70
  %.028 = load i32, ptr %72, align 4, !tbaa !5
  %.not38 = icmp eq i32 %.028, 0
  br i1 %.not38, label %._crit_edge55, label %.lr.ph54, !llvm.loop !16

._crit_edge55:                                    ; preds = %.lr.ph54, %67
  %73 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @ansv) #5
  %74 = trunc i64 %73 to i32
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %.lr.ph58.preheader, label %.loopexit

.lr.ph58.preheader:                               ; preds = %._crit_edge55
  %76 = and i64 %73, 2147483647
  br label %.lr.ph58

.lr.ph58:                                         ; preds = %.lr.ph58.preheader, %.lr.ph58
  %indvars.iv68 = phi i64 [ %76, %.lr.ph58.preheader ], [ %indvars.iv.next69, %.lr.ph58 ]
  %indvars.iv.next69 = add nsw i64 %indvars.iv68, -1
  %77 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @ansv, i64 noundef %indvars.iv.next69) #5
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %78)
  %80 = icmp ugt i64 %indvars.iv68, 1
  br i1 %80, label %.lr.ph58, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %.lr.ph58, %._crit_edge55, %64
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

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

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

attributes #0 = { mustprogress norecurse 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 = { nofree 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 #2 = { 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 #3 = { 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 #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 = { 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, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !12, !11}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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