; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (5902)

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

@a = external dso_local global [510 x i32], align 16
@ans = external dso_local global [1010 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 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
  %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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %14 = 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)
  br label %15

15:                                               ; preds = %149, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = add nsw i32 %16, -1
  store i32 %17, ptr %2, align 4, !tbaa !5
  %18 = icmp ne i32 %16, 0
  br i1 %18, label %19, label %151

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.memset.p0.i64(ptr align 16 @ans, i8 0, i64 4040, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %31, %19
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %34

26:                                               ; preds = %21
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [510 x i32], ptr @a, i64 0, i64 %28
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %29)
  br label %31

31:                                               ; preds = %26
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !9

34:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %65, %34
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 1
  %39 = icmp sle i32 %36, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %7, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %61, %41
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 10, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %64

49:                                               ; preds = %44
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [510 x i32], ptr @a, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [510 x i32], ptr @a, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %53, i32 noundef %57)
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %59
  store i32 1, ptr %60, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %49
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %7, align 4, !tbaa !5
  br label %44, !llvm.loop !11

64:                                               ; preds = %48
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %5, align 4, !tbaa !5
  br label %35, !llvm.loop !12

68:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %122, %68
  %70 = load i32, ptr %8, align 4, !tbaa !5
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %77

72:                                               ; preds = %69
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = load i32, ptr %3, align 4, !tbaa !5
  %75 = sub nsw i32 %74, 3
  %76 = icmp sle i32 %73, %75
  br label %77

77:                                               ; preds = %72, %69
  %78 = phi i1 [ false, %69 ], [ %76, %72 ]
  br i1 %78, label %79, label %123

79:                                               ; preds = %77
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %9, align 4, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %119, %79
  %83 = load i32, ptr %10, align 4, !tbaa !5
  %84 = icmp sle i32 %83, 1000
  br i1 %84, label %86, label %85

85:                                               ; preds = %82
  store i32 15, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %122

86:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %115, %86
  %88 = load i32, ptr %11, align 4, !tbaa !5
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = icmp sle i32 %88, %89
  br i1 %90, label %92, label %91

91:                                               ; preds = %87
  store i32 18, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %118

92:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %93 = load i32, ptr %11, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [510 x i32], ptr @a, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = load i32, ptr %10, align 4, !tbaa !5
  %98 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %96, i32 noundef %97)
  store i32 %98, ptr %12, align 4, !tbaa !5
  %99 = load i32, ptr %10, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %114

104:                                              ; preds = %92
  %105 = load i32, ptr %12, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = icmp eq i32 %108, 0
  br i1 %109, label %110, label %114

110:                                              ; preds = %104
  store i32 1, ptr %8, align 4, !tbaa !5
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %112
  store i32 1, ptr %113, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %110, %104, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %11, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %11, align 4, !tbaa !5
  br label %87, !llvm.loop !13

118:                                              ; preds = %91
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %10, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %10, align 4, !tbaa !5
  br label %82, !llvm.loop !14

122:                                              ; preds = %85
  br label %69, !llvm.loop !15

123:                                              ; preds = %77
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %146, %123
  %125 = load i32, ptr %13, align 4, !tbaa !5
  %126 = icmp sle i32 %125, 1000
  br i1 %126, label %128, label %127

127:                                              ; preds = %124
  store i32 21, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %149

128:                                              ; preds = %124
  %129 = load i32, ptr %13, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = icmp ne i32 %132, 0
  br i1 %133, label %134, label %145

134:                                              ; preds = %128
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = icmp ne i32 %135, 0
  br i1 %136, label %137, label %140

137:                                              ; preds = %134
  %138 = load i32, ptr %13, align 4, !tbaa !5
  %139 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %138)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %144

140:                                              ; preds = %134
  %141 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %142 = load i32, ptr %13, align 4, !tbaa !5
  %143 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %141, i32 noundef %142)
  br label %144

144:                                              ; preds = %140, %137
  br label %145

145:                                              ; preds = %144, %128
  br label %146

146:                                              ; preds = %145
  %147 = load i32, ptr %13, align 4, !tbaa !5
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %13, align 4, !tbaa !5
  br label %124, !llvm.loop !16

149:                                              ; preds = %127
  %150 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %15, !llvm.loop !17

151:                                              ; preds = %15
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %152 = load i32, ptr %1, align 4
  ret i32 %152
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: 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 i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef, i32 noundef) #4

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #6 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)) #5

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !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" }

@a = external dso_local global [510 x i32], align 16
@ans = external dso_local local_unnamed_addr global [1010 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; 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
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %3 = 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)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr %1, align 4, !tbaa !5
  %.not65 = icmp eq i32 %4, 0
  br i1 %.not65, label %._crit_edge68, label %.lr.ph67

.lr.ph67:                                         ; preds = %0, %53
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %6 = 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)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4040) @ans, i8 0, i64 4040, i1 false)
  %7 = load i32, ptr %2, align 4
  %.not3647 = icmp slt i32 %7, 1
  br i1 %.not3647, label %.preheader44.preheader, label %.lr.ph

.preheader46:                                     ; preds = %.lr.ph
  %.not37.not52 = icmp sgt i32 %10, 1
  br i1 %.not37.not52, label %.lr.ph54, label %.preheader44.preheader

.lr.ph:                                           ; preds = %.lr.ph67, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph67 ]
  %8 = getelementptr inbounds [510 x i32], ptr @a, i64 0, i64 %indvars.iv
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr %2, align 4
  %11 = sext i32 %10 to i64
  %.not36.not = icmp slt i64 %indvars.iv, %11
  br i1 %.not36.not, label %.lr.ph, label %.preheader46, !llvm.loop !9

.loopexit43:                                      ; preds = %17, %.lr.ph54
  %.pre-phi = phi i64 [ %15, %.lr.ph54 ], [ %25, %17 ]
  %12 = phi i32 [ %14, %.lr.ph54 ], [ %24, %17 ]
  %.not37.not = icmp slt i64 %indvars.iv.next77, %.pre-phi
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  br i1 %.not37.not, label %.lr.ph54, label %.preheader45, !llvm.loop !11

.preheader45:                                     ; preds = %.loopexit43
  %13 = icmp sgt i32 %12, 3
  br i1 %13, label %.lr.ph62, label %.preheader44.preheader

.preheader44.preheader:                           ; preds = %.lr.ph62, %.loopexit, %.lr.ph67, %.preheader46, %.preheader45
  br label %.preheader44

.lr.ph54:                                         ; preds = %.preheader46, %.loopexit43
  %14 = phi i32 [ %12, %.loopexit43 ], [ %10, %.preheader46 ]
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %.loopexit43 ], [ 1, %.preheader46 ]
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %.loopexit43 ], [ 2, %.preheader46 ]
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %15 = sext i32 %14 to i64
  %.not4249.not = icmp slt i64 %indvars.iv76, %15
  br i1 %.not4249.not, label %.lr.ph51, label %.loopexit43

.lr.ph51:                                         ; preds = %.lr.ph54
  %16 = getelementptr inbounds [510 x i32], ptr @a, i64 0, i64 %indvars.iv76
  br label %17

17:                                               ; preds = %.lr.ph51, %17
  %indvars.iv73 = phi i64 [ %indvars.iv71, %.lr.ph51 ], [ %indvars.iv.next74, %17 ]
  %18 = load i32, ptr %16, align 4, !tbaa !5
  %19 = getelementptr inbounds [510 x i32], ptr @a, i64 0, i64 %indvars.iv73
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %18, i32 noundef %20)
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %22
  store i32 1, ptr %23, align 4, !tbaa !5
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %24 = load i32, ptr %2, align 4
  %25 = sext i32 %24 to i64
  %.not42.not = icmp slt i64 %indvars.iv73, %25
  br i1 %.not42.not, label %17, label %.loopexit43, !llvm.loop !12

.loopexit:                                        ; preds = %._crit_edge
  %26 = icmp ne i32 %.2.lcssa, 0
  %27 = add nsw i32 %37, -3
  %28 = icmp slt i32 %.03161, %27
  %29 = select i1 %26, i1 %28, i1 false
  br i1 %29, label %.lr.ph62, label %.preheader44.preheader, !llvm.loop !13

.lr.ph62:                                         ; preds = %.preheader45, %.loopexit
  %30 = phi i32 [ %37, %.loopexit ], [ %12, %.preheader45 ]
  %.03161 = phi i32 [ %31, %.loopexit ], [ 1, %.preheader45 ]
  %31 = add nuw nsw i32 %.03161, 1
  %32 = icmp slt i32 %30, 1
  br i1 %32, label %.preheader44.preheader, label %.preheader

.preheader:                                       ; preds = %.lr.ph62, %._crit_edge
  %33 = phi i32 [ %37, %._crit_edge ], [ %30, %.lr.ph62 ]
  %34 = phi i32 [ %38, %._crit_edge ], [ %30, %.lr.ph62 ]
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %._crit_edge ], [ 1, %.lr.ph62 ]
  %.159 = phi i32 [ %.2.lcssa, %._crit_edge ], [ 0, %.lr.ph62 ]
  %.not4055 = icmp slt i32 %34, 1
  br i1 %.not4055, label %._crit_edge, label %.lr.ph58

.lr.ph58:                                         ; preds = %.preheader
  %35 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %indvars.iv82
  %36 = trunc nuw nsw i64 %indvars.iv82 to i32
  br label %39

._crit_edge:                                      ; preds = %50, %.preheader
  %37 = phi i32 [ %33, %.preheader ], [ %51, %50 ]
  %38 = phi i32 [ %34, %.preheader ], [ %51, %50 ]
  %.2.lcssa = phi i32 [ %.159, %.preheader ], [ %.3, %50 ]
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next83, 1001
  br i1 %exitcond.not, label %.loopexit, label %.preheader, !llvm.loop !14

39:                                               ; preds = %.lr.ph58, %50
  %indvars.iv79 = phi i64 [ 1, %.lr.ph58 ], [ %indvars.iv.next80, %50 ]
  %.256 = phi i32 [ %.159, %.lr.ph58 ], [ %.3, %50 ]
  %40 = getelementptr inbounds [510 x i32], ptr @a, i64 0, i64 %indvars.iv79
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %41, i32 noundef %36)
  %43 = load i32, ptr %35, align 4, !tbaa !5
  %.not41 = icmp eq i32 %43, 0
  br i1 %.not41, label %50, label %44

44:                                               ; preds = %39
  %45 = sext i32 %42 to i64
  %46 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %44
  store i32 1, ptr %46, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %49, %44, %39
  %.3 = phi i32 [ 1, %49 ], [ %.256, %44 ], [ %.256, %39 ]
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %51 = load i32, ptr %2, align 4
  %52 = sext i32 %51 to i64
  %.not40.not = icmp slt i64 %indvars.iv79, %52
  br i1 %.not40.not, label %39, label %._crit_edge, !llvm.loop !16

53:                                               ; preds = %64
  %54 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %55 = load i32, ptr %1, align 4, !tbaa !5
  %56 = add nsw i32 %55, -1
  store i32 %56, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %55, 0
  br i1 %.not, label %._crit_edge68, label %.lr.ph67, !llvm.loop !17

.preheader44:                                     ; preds = %.preheader44.preheader, %64
  %indvars.iv85 = phi i64 [ %indvars.iv.next86, %64 ], [ 1, %.preheader44.preheader ]
  %.463 = phi i32 [ %.5, %64 ], [ 1, %.preheader44.preheader ]
  %57 = getelementptr inbounds [1010 x i32], ptr @ans, i64 0, i64 %indvars.iv85
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %.not38 = icmp eq i32 %58, 0
  br i1 %.not38, label %64, label %59

59:                                               ; preds = %.preheader44
  %.not39 = icmp eq i32 %.463, 0
  br i1 %.not39, label %60, label %.sink.split

60:                                               ; preds = %59
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  br label %.sink.split

.sink.split:                                      ; preds = %59, %60
  %.sink = phi ptr [ %61, %60 ], [ @_ZSt4cout, %59 ]
  %62 = trunc nuw nsw i64 %indvars.iv85 to i32
  %63 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %.sink, i32 noundef %62)
  br label %64

64:                                               ; preds = %.sink.split, %.preheader44
  %.5 = phi i32 [ %.463, %.preheader44 ], [ 0, %.sink.split ]
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %exitcond88.not = icmp eq i64 %indvars.iv.next86, 1001
  br i1 %exitcond88.not, label %53, label %.preheader44, !llvm.loop !18

._crit_edge68:                                    ; preds = %53, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef, i32 noundef) 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #5

; 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 #6 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)) #5

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !15}
!15 = !{!"llvm.loop.unswitch.partial.disable"}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass