; LLVM IR from UtkarshPathrabe/Competitive-Coding :: HackerRank Solutions/Algorithms/Warm Up (ACM ICPC Team)

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

@inp = external dso_local global [501 x [501 x i32]], align 16
@output = external dso_local global [501 x [501 x i32]], align 16
@in = external dso_local global [501 x i8], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; 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
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 -2147483648, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %47, %0
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %50

22:                                               ; preds = %17
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef @in)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sub nsw i32 %24, 1
  store i32 %25, ptr %9, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %43, %22
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = icmp sge i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %46

30:                                               ; preds = %26
  %31 = load i32, ptr %9, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [501 x i8], ptr @in, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = sext i8 %34 to i32
  %36 = sub nsw i32 %35, 48
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %38
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [501 x i32], ptr %39, i64 0, i64 %41
  store i32 %36, ptr %42, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %30
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = add nsw i32 %44, -1
  store i32 %45, ptr %9, align 4, !tbaa !5
  br label %26, !llvm.loop !10

46:                                               ; preds = %29
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %7, align 4, !tbaa !5
  br label %17, !llvm.loop !12

50:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %104, %50
  %52 = load i32, ptr %10, align 4, !tbaa !5
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %107

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %57 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %57, ptr %11, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %100, %56
  %59 = load i32, ptr %11, align 4, !tbaa !5
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

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

63:                                               ; preds = %58
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %87, %63
  %65 = load i32, ptr %12, align 4, !tbaa !5
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  store i32 14, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %90

69:                                               ; preds = %64
  %70 = load i32, ptr %10, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %71
  %73 = load i32, ptr %12, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [501 x i32], ptr %72, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = load i32, ptr %11, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %78
  %80 = load i32, ptr %12, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [501 x i32], ptr %79, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = or i32 %76, %83
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = add nsw i32 %85, %84
  store i32 %86, ptr %4, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %69
  %88 = load i32, ptr %12, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %12, align 4, !tbaa !5
  br label %64, !llvm.loop !13

90:                                               ; preds = %68
  %91 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %92 = load i32, ptr %91, align 4, !tbaa !5
  store i32 %92, ptr %5, align 4, !tbaa !5
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [501 x [501 x i32]], ptr @output, i64 0, i64 %95
  %97 = load i32, ptr %11, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [501 x i32], ptr %96, i64 0, i64 %98
  store i32 %93, ptr %99, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %90
  %101 = load i32, ptr %11, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %11, align 4, !tbaa !5
  br label %58, !llvm.loop !14

103:                                              ; preds = %62
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %10, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %10, align 4, !tbaa !5
  br label %51, !llvm.loop !15

107:                                              ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %138, %107
  %109 = load i32, ptr %13, align 4, !tbaa !5
  %110 = load i32, ptr %2, align 4, !tbaa !5
  %111 = icmp slt i32 %109, %110
  br i1 %111, label %113, label %112

112:                                              ; preds = %108
  store i32 17, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %141

113:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %114 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %114, ptr %14, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %134, %113
  %116 = load i32, ptr %14, align 4, !tbaa !5
  %117 = load i32, ptr %2, align 4, !tbaa !5
  %118 = icmp slt i32 %116, %117
  br i1 %118, label %120, label %119

119:                                              ; preds = %115
  store i32 20, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %137

120:                                              ; preds = %115
  %121 = load i32, ptr %13, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [501 x [501 x i32]], ptr @output, i64 0, i64 %122
  %124 = load i32, ptr %14, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [501 x i32], ptr %123, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = load i32, ptr %5, align 4, !tbaa !5
  %129 = icmp eq i32 %127, %128
  br i1 %129, label %130, label %133

130:                                              ; preds = %120
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %6, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %130, %120
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %14, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %14, align 4, !tbaa !5
  br label %115, !llvm.loop !16

137:                                              ; preds = %119
  br label %138

138:                                              ; preds = %137
  %139 = load i32, ptr %13, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %13, align 4, !tbaa !5
  br label %108, !llvm.loop !17

141:                                              ; preds = %112
  %142 = load i32, ptr %5, align 4, !tbaa !5
  %143 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %142)
  %144 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %143, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %145 = load i32, ptr %6, align 4, !tbaa !5
  %146 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %144, i32 noundef %145)
  %147 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %146, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %148 = load i32, ptr %1, align 4
  ret i32 %148
}

; 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: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) #3

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

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 = { 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 = { 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 = { inlinehint 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 = { 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}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}
!17 = distinct !{!17, !11}


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

@inp = external dso_local local_unnamed_addr global [501 x [501 x i32]], align 16
@output = external dso_local local_unnamed_addr global [501 x [501 x i32]], align 16
@in = external dso_local global [501 x i8], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  store i32 -2147483648, ptr %4, align 4, !tbaa !5
  %5 = 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)
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph43, label %._crit_edge57

.preheader39:                                     ; preds = %._crit_edge
  %9 = icmp sgt i32 %25, 0
  br i1 %9, label %.preheader38, label %._crit_edge57

.lr.ph43:                                         ; preds = %0, %._crit_edge
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %._crit_edge ], [ 0, %0 ]
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef @in)
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph43
  %13 = zext nneg i32 %11 to i64
  %min.iters.check = icmp ult i32 %11, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ %13, %.lr.ph ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %13, 2147483640
  %ind.end = and i64 %13, 7
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %14 = xor i64 %index, -1
  %15 = add i64 %14, %13
  %16 = getelementptr inbounds [501 x i8], ptr @in, i64 0, i64 %15
  %17 = getelementptr inbounds i8, ptr %16, i64 -3
  %18 = getelementptr inbounds i8, ptr %16, i64 -7
  %wide.load = load <4 x i8>, ptr %17, align 1, !tbaa !9
  %wide.load95 = load <4 x i8>, ptr %18, align 1, !tbaa !9
  %19 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %indvars.iv62, i64 %15
  %20 = getelementptr inbounds i8, ptr %19, i64 -12
  %21 = getelementptr inbounds i8, ptr %19, i64 -28
  %22 = sext <4 x i8> %wide.load to <4 x i32>
  %reverse97 = add nsw <4 x i32> %22, <i32 -48, i32 -48, i32 -48, i32 -48>
  store <4 x i32> %reverse97, ptr %20, align 4, !tbaa !5
  %23 = sext <4 x i8> %wide.load95 to <4 x i32>
  %reverse98 = add nsw <4 x i32> %23, <i32 -48, i32 -48, i32 -48, i32 -48>
  store <4 x i32> %reverse98, ptr %21, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %24 = icmp eq i64 %index.next, %n.vec
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !10

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

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %.lr.ph43
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = icmp slt i64 %indvars.iv.next63, %26
  br i1 %27, label %.lr.ph43, label %.preheader39, !llvm.loop !14

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %28 = getelementptr inbounds [501 x i8], ptr @in, i64 0, i64 %indvars.iv.next
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = sext i8 %29 to i32
  %31 = add nsw i32 %30, -48
  %32 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %indvars.iv62, i64 %indvars.iv.next
  store i32 %31, ptr %32, align 4, !tbaa !5
  %33 = icmp ugt i64 %indvars.iv, 1
  br i1 %33, label %scalar.ph, label %._crit_edge, !llvm.loop !15

.preheader38:                                     ; preds = %.preheader39, %._crit_edge51
  %34 = phi i32 [ %39, %._crit_edge51 ], [ -2147483648, %.preheader39 ]
  %35 = phi i32 [ %40, %._crit_edge51 ], [ %25, %.preheader39 ]
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %._crit_edge51 ], [ 0, %.preheader39 ]
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv68, %36
  br i1 %37, label %.lr.ph50, label %._crit_edge51

.preheader37:                                     ; preds = %._crit_edge51
  %38 = icmp sgt i32 %40, 0
  br i1 %38, label %.preheader.lr.ph, label %._crit_edge57

.preheader.lr.ph:                                 ; preds = %.preheader37
  %wide.trip.count82 = zext nneg i32 %40 to i64
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %39, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %.preheader

._crit_edge51.loopexit:                           ; preds = %54
  %.pre = sext i32 %59 to i64
  br label %._crit_edge51

._crit_edge51:                                    ; preds = %._crit_edge51.loopexit, %.preheader38
  %.pre-phi = phi i64 [ %.pre, %._crit_edge51.loopexit ], [ %36, %.preheader38 ]
  %39 = phi i32 [ %56, %._crit_edge51.loopexit ], [ %34, %.preheader38 ]
  %40 = phi i32 [ %59, %._crit_edge51.loopexit ], [ %35, %.preheader38 ]
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %41 = icmp slt i64 %indvars.iv.next69, %.pre-phi
  br i1 %41, label %.preheader38, label %.preheader37, !llvm.loop !16

.lr.ph50:                                         ; preds = %.preheader38, %54
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %54 ], [ %indvars.iv68, %.preheader38 ]
  store i32 0, ptr %3, align 4, !tbaa !5
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %.lr.ph46, label %54

.lr.ph46:                                         ; preds = %.lr.ph50
  %wide.trip.count = zext nneg i32 %42 to i64
  %min.iters.check101 = icmp ult i32 %42, 8
  br i1 %min.iters.check101, label %scalar.ph100.preheader, label %vector.ph102

scalar.ph100.preheader:                           ; preds = %middle.block99, %.lr.ph46
  %indvars.iv65.ph = phi i64 [ 0, %.lr.ph46 ], [ %n.vec104, %middle.block99 ]
  %.ph = phi i32 [ 0, %.lr.ph46 ], [ %53, %middle.block99 ]
  br label %scalar.ph100

vector.ph102:                                     ; preds = %.lr.ph46
  %n.vec104 = and i64 %wide.trip.count, 2147483640
  br label %vector.body106

vector.body106:                                   ; preds = %vector.body106, %vector.ph102
  %index107 = phi i64 [ 0, %vector.ph102 ], [ %index.next113, %vector.body106 ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph102 ], [ %50, %vector.body106 ]
  %vec.phi108 = phi <4 x i32> [ zeroinitializer, %vector.ph102 ], [ %51, %vector.body106 ]
  %44 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %indvars.iv68, i64 %index107
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  %wide.load109 = load <4 x i32>, ptr %44, align 4, !tbaa !5
  %wide.load110 = load <4 x i32>, ptr %45, align 4, !tbaa !5
  %46 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %indvars.iv70, i64 %index107
  %47 = getelementptr inbounds i8, ptr %46, i64 16
  %wide.load111 = load <4 x i32>, ptr %46, align 4, !tbaa !5
  %wide.load112 = load <4 x i32>, ptr %47, align 4, !tbaa !5
  %48 = or <4 x i32> %wide.load111, %wide.load109
  %49 = or <4 x i32> %wide.load112, %wide.load110
  %50 = add <4 x i32> %vec.phi, %48
  %51 = add <4 x i32> %vec.phi108, %49
  %index.next113 = add nuw i64 %index107, 8
  %52 = icmp eq i64 %index.next113, %n.vec104
  br i1 %52, label %middle.block99, label %vector.body106, !llvm.loop !17

middle.block99:                                   ; preds = %vector.body106
  %bin.rdx = add <4 x i32> %51, %50
  %53 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n114 = icmp eq i64 %n.vec104, %wide.trip.count
  br i1 %cmp.n114, label %._crit_edge47, label %scalar.ph100.preheader

._crit_edge47:                                    ; preds = %scalar.ph100, %middle.block99
  %.lcssa = phi i32 [ %53, %middle.block99 ], [ %68, %scalar.ph100 ]
  store i32 %.lcssa, ptr %3, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %._crit_edge47, %.lr.ph50
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %56 = load i32, ptr %55, align 4, !tbaa !5
  store i32 %56, ptr %4, align 4, !tbaa !5
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = getelementptr inbounds [501 x [501 x i32]], ptr @output, i64 0, i64 %indvars.iv68, i64 %indvars.iv70
  store i32 %57, ptr %58, align 4, !tbaa !5
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %59 = load i32, ptr %1, align 4, !tbaa !5
  %60 = trunc nuw i64 %indvars.iv.next71 to i32
  %61 = icmp sgt i32 %59, %60
  br i1 %61, label %.lr.ph50, label %._crit_edge51.loopexit, !llvm.loop !18

scalar.ph100:                                     ; preds = %scalar.ph100.preheader, %scalar.ph100
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %scalar.ph100 ], [ %indvars.iv65.ph, %scalar.ph100.preheader ]
  %62 = phi i32 [ %68, %scalar.ph100 ], [ %.ph, %scalar.ph100.preheader ]
  %63 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %indvars.iv68, i64 %indvars.iv65
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = getelementptr inbounds [501 x [501 x i32]], ptr @inp, i64 0, i64 %indvars.iv70, i64 %indvars.iv65
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = or i32 %66, %64
  %68 = add nsw i32 %62, %67
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next66, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge47, label %scalar.ph100, !llvm.loop !19

.preheader:                                       ; preds = %.preheader.lr.ph, %.loopexit
  %indvars.iv74 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next75, %.loopexit ]
  %.03655 = phi i32 [ 0, %.preheader.lr.ph ], [ %spec.select.lcssa, %.loopexit ]
  %69 = sub nsw i64 %wide.trip.count82, %indvars.iv74
  %min.iters.check117 = icmp ult i64 %69, 8
  br i1 %min.iters.check117, label %scalar.ph116.preheader, label %vector.ph118

scalar.ph116.preheader:                           ; preds = %middle.block115, %.preheader
  %indvars.iv76.ph = phi i64 [ %indvars.iv74, %.preheader ], [ %ind.end121, %middle.block115 ]
  %.153.ph = phi i32 [ %.03655, %.preheader ], [ %80, %middle.block115 ]
  br label %scalar.ph116

vector.ph118:                                     ; preds = %.preheader
  %n.vec120 = and i64 %69, -8
  %ind.end121 = add i64 %indvars.iv74, %n.vec120
  %70 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.03655, i64 0
  br label %vector.body123

vector.body123:                                   ; preds = %vector.body123, %vector.ph118
  %index124 = phi i64 [ 0, %vector.ph118 ], [ %index.next130, %vector.body123 ]
  %vec.phi125 = phi <4 x i32> [ %70, %vector.ph118 ], [ %77, %vector.body123 ]
  %vec.phi126 = phi <4 x i32> [ zeroinitializer, %vector.ph118 ], [ %78, %vector.body123 ]
  %offset.idx127 = add i64 %indvars.iv74, %index124
  %71 = getelementptr inbounds [501 x [501 x i32]], ptr @output, i64 0, i64 %indvars.iv74, i64 %offset.idx127
  %72 = getelementptr inbounds i8, ptr %71, i64 16
  %wide.load128 = load <4 x i32>, ptr %71, align 4, !tbaa !5
  %wide.load129 = load <4 x i32>, ptr %72, align 4, !tbaa !5
  %73 = icmp eq <4 x i32> %wide.load128, %broadcast.splat
  %74 = icmp eq <4 x i32> %wide.load129, %broadcast.splat
  %75 = zext <4 x i1> %73 to <4 x i32>
  %76 = zext <4 x i1> %74 to <4 x i32>
  %77 = add <4 x i32> %vec.phi125, %75
  %78 = add <4 x i32> %vec.phi126, %76
  %index.next130 = add nuw i64 %index124, 8
  %79 = icmp eq i64 %index.next130, %n.vec120
  br i1 %79, label %middle.block115, label %vector.body123, !llvm.loop !20

middle.block115:                                  ; preds = %vector.body123
  %bin.rdx131 = add <4 x i32> %78, %77
  %80 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx131)
  %cmp.n132 = icmp eq i64 %69, %n.vec120
  br i1 %cmp.n132, label %.loopexit, label %scalar.ph116.preheader

._crit_edge57:                                    ; preds = %.loopexit, %0, %.preheader39, %.preheader37
  %81 = phi i32 [ %39, %.preheader37 ], [ -2147483648, %.preheader39 ], [ -2147483648, %0 ], [ %39, %.loopexit ]
  %.036.lcssa = phi i32 [ 0, %.preheader37 ], [ 0, %.preheader39 ], [ 0, %0 ], [ %spec.select.lcssa, %.loopexit ]
  %82 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %81)
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %82, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %83, i32 noundef %.036.lcssa)
  %85 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %84, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0

.loopexit:                                        ; preds = %scalar.ph116, %middle.block115
  %spec.select.lcssa = phi i32 [ %80, %middle.block115 ], [ %spec.select, %scalar.ph116 ]
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %exitcond83.not = icmp eq i64 %indvars.iv.next75, %wide.trip.count82
  br i1 %exitcond83.not, label %._crit_edge57, label %.preheader, !llvm.loop !21

scalar.ph116:                                     ; preds = %scalar.ph116.preheader, %scalar.ph116
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %scalar.ph116 ], [ %indvars.iv76.ph, %scalar.ph116.preheader ]
  %.153 = phi i32 [ %spec.select, %scalar.ph116 ], [ %.153.ph, %scalar.ph116.preheader ]
  %86 = getelementptr inbounds [501 x [501 x i32]], ptr @output, i64 0, i64 %indvars.iv74, i64 %indvars.iv76
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = icmp eq i32 %87, %39
  %89 = zext i1 %88 to i32
  %spec.select = add nsw i32 %.153, %89
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %exitcond80.not = icmp eq i64 %indvars.iv.next77, %wide.trip.count82
  br i1 %exitcond80.not, label %.loopexit, label %scalar.ph116, !llvm.loop !22
}

; 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: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) local_unnamed_addr #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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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 uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #6

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 = { 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 = { 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 = { inlinehint 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11, !12, !13}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11, !13, !12}
!16 = distinct !{!16, !11}
!17 = distinct !{!17, !11, !12, !13}
!18 = distinct !{!18, !11}
!19 = distinct !{!19, !11, !13, !12}
!20 = distinct !{!20, !11, !12, !13}
!21 = distinct !{!21, !11}
!22 = distinct !{!22, !11, !13, !12}


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