; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/346 Division 2/Problem G (G)

; 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_ostream" = type { ptr, %"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 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@n = external dso_local global i32, align 4
@h = external dso_local global [1001000 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

9:                                                ; preds = %31, %0
  %10 = load i32, ptr %3, align 4, !tbaa !9
  %11 = load i32, ptr @n, align 4, !tbaa !9
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %9
  %15 = load i32, ptr %3, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %16
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %17)
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr %21, align 4, !tbaa !9
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %14
  store i8 1, ptr %2, align 1, !tbaa !5
  br label %30

30:                                               ; preds = %29, %14
  br label %31

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

34:                                               ; preds = %13
  %35 = load i8, ptr %2, align 1, !tbaa !5, !range !13, !noundef !14
  %36 = trunc i8 %35 to i1
  br i1 %36, label %39, label %37

37:                                               ; preds = %34
  %38 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %150

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

40:                                               ; preds = %143, %39
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = load i32, ptr @n, align 4, !tbaa !9
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

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

45:                                               ; preds = %40
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %52, label %51

51:                                               ; preds = %45
  store i64 0, ptr %6, align 8, !tbaa !15
  br label %143

52:                                               ; preds = %45
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  call void @_Z3addRxx(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef %57)
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %60, label %81

60:                                               ; preds = %52
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !9
  %70 = icmp sgt i32 %64, %69
  br i1 %70, label %71, label %81

71:                                               ; preds = %60
  %72 = load i64, ptr %6, align 8, !tbaa !15
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = sub nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = mul nsw i64 %72, %78
  %80 = srem i64 %79, 1000000007
  call void @_Z3addRxx(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef %80)
  br label %81

81:                                               ; preds = %71, %60, %52
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = icmp sgt i32 %82, 0
  br i1 %83, label %84, label %104

84:                                               ; preds = %81
  %85 = load i32, ptr %7, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = sub nsw i32 %89, 1
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !9
  %94 = icmp sle i32 %88, %93
  br i1 %94, label %95, label %104

95:                                               ; preds = %84
  %96 = load i64, ptr %6, align 8, !tbaa !15
  %97 = load i32, ptr %7, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = mul nsw i64 %96, %101
  %103 = srem i64 %102, 1000000007
  call void @_Z3addRxx(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef %103)
  br label %104

104:                                              ; preds = %95, %84, %81
  %105 = load i32, ptr %7, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  %107 = load i32, ptr @n, align 4, !tbaa !9
  %108 = icmp slt i32 %106, %107
  br i1 %108, label %109, label %142

109:                                              ; preds = %104
  %110 = load i32, ptr %7, align 4, !tbaa !9
  %111 = add nsw i32 %110, 1
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !9
  %115 = load i32, ptr %7, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !9
  %119 = icmp sgt i32 %114, %118
  br i1 %119, label %120, label %130

120:                                              ; preds = %109
  %121 = load i64, ptr %6, align 8, !tbaa !15
  %122 = add nsw i64 %121, 1
  %123 = load i32, ptr %7, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !9
  %127 = sext i32 %126 to i64
  %128 = mul nsw i64 %122, %127
  %129 = srem i64 %128, 1000000007
  store i64 %129, ptr %6, align 8, !tbaa !15
  br label %141

130:                                              ; preds = %109
  %131 = load i64, ptr %6, align 8, !tbaa !15
  %132 = add nsw i64 %131, 1
  %133 = load i32, ptr %7, align 4, !tbaa !9
  %134 = add nsw i32 %133, 1
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = mul nsw i64 %132, %138
  %140 = srem i64 %139, 1000000007
  store i64 %140, ptr %6, align 8, !tbaa !15
  store i64 %140, ptr %6, align 8, !tbaa !15
  br label %141

141:                                              ; preds = %130, %120
  br label %142

142:                                              ; preds = %141, %104
  br label %143

143:                                              ; preds = %142, %51
  %144 = load i32, ptr %7, align 4, !tbaa !9
  %145 = add nsw i32 %144, 1
  store i32 %145, ptr %7, align 4, !tbaa !9
  br label %40, !llvm.loop !17

146:                                              ; preds = %44
  %147 = load i64, ptr %5, align 8, !tbaa !15
  %148 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %147)
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %148, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %150

150:                                              ; preds = %146, %37
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #6
  %151 = load i32, ptr %1, align 4
  ret i32 %151
}

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

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

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

declare i32 @puts(ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 2

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = distinct !{!17, !12}


; 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_ostream" = type { ptr, %"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 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@n = external dso_local global i32, align 4
@h = external dso_local global [1001000 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; 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 #0 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)) #1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i64, align 8
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.critedge49

._crit_edge:                                      ; preds = %.lr.ph
  br i1 %spec.select, label %13, label %.critedge49

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %.03042 = phi i1 [ %spec.select, %.lr.ph ], [ false, %0 ]
  %5 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %indvars.iv
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %5)
  %7 = load i32, ptr %5, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr %5, align 4, !tbaa !5
  %.not41 = icmp ne i32 %8, 0
  %spec.select = select i1 %.not41, i1 true, i1 %.03042
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = icmp slt i64 %indvars.iv.next, %10
  br i1 %11, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.critedge49:                                      ; preds = %0, %._crit_edge
  %12 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %76

13:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  store i64 0, ptr %1, align 8, !tbaa !11
  %14 = icmp sgt i32 %9, 0
  br i1 %14, label %.lr.ph47.preheader, label %._crit_edge48

.lr.ph47.preheader:                               ; preds = %13
  %15 = load i32, ptr @h, align 16, !tbaa !5
  %.not.peel = icmp eq i32 %15, 0
  br i1 %.not.peel, label %28, label %.critedge.peel

.critedge.peel:                                   ; preds = %.lr.ph47.preheader
  %16 = sext i32 %15 to i64
  call void @_Z3addRxx(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %16)
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = icmp sgt i32 %17, 1
  br i1 %19, label %20, label %28

20:                                               ; preds = %.critedge.peel
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @h, i64 4), align 4, !tbaa !5
  %22 = load i32, ptr @h, align 16, !tbaa !5
  %23 = icmp sgt i32 %21, %22
  br i1 %23, label %26, label %24

24:                                               ; preds = %20
  %25 = srem i32 %21, 1000000007
  %.sext60 = sext i32 %25 to i64
  br label %28

26:                                               ; preds = %20
  %27 = srem i32 %22, 1000000007
  %.sext = sext i32 %27 to i64
  br label %28

28:                                               ; preds = %26, %24, %.critedge.peel, %.lr.ph47.preheader
  %.pre-phi = phi i64 [ %18, %26 ], [ %18, %24 ], [ %18, %.critedge.peel ], [ %10, %.lr.ph47.preheader ]
  %29 = phi i32 [ %17, %26 ], [ %17, %24 ], [ %17, %.critedge.peel ], [ %9, %.lr.ph47.preheader ]
  %.1.peel = phi i64 [ %.sext, %26 ], [ %.sext60, %24 ], [ 0, %.critedge.peel ], [ 0, %.lr.ph47.preheader ]
  %30 = icmp sgt i64 %.pre-phi, 1
  br i1 %30, label %.lr.ph47, label %._crit_edge48.loopexit

._crit_edge48.loopexit:                           ; preds = %73, %28
  %.pre55 = load i64, ptr %1, align 8, !tbaa !11
  br label %._crit_edge48

._crit_edge48:                                    ; preds = %._crit_edge48.loopexit, %13
  %31 = phi i64 [ %.pre55, %._crit_edge48.loopexit ], [ 0, %13 ]
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %31)
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %32, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  br label %76

.lr.ph47:                                         ; preds = %28, %73
  %34 = phi i32 [ %74, %73 ], [ %29, %28 ]
  %indvars.iv50 = phi i64 [ %indvars.iv.next51.pre-phi, %73 ], [ 1, %28 ]
  %.02844 = phi i64 [ %.1, %73 ], [ %.1.peel, %28 ]
  %35 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %indvars.iv50
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %.not = icmp eq i32 %36, 0
  br i1 %.not, label %.lr.ph47._crit_edge, label %37

.lr.ph47._crit_edge:                              ; preds = %.lr.ph47
  %.pre56 = add nuw nsw i64 %indvars.iv50, 1
  %.pre57 = sext i32 %34 to i64
  br label %73

37:                                               ; preds = %.lr.ph47
  %38 = sext i32 %36 to i64
  call void @_Z3addRxx(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %38)
  %39 = load i32, ptr %35, align 4, !tbaa !5
  %40 = add nsw i64 %indvars.iv50, -1
  %41 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = icmp sgt i32 %39, %42
  br i1 %43, label %44, label %48

44:                                               ; preds = %37
  %45 = sext i32 %42 to i64
  %46 = mul nsw i64 %.02844, %45
  %47 = srem i64 %46, 1000000007
  call void @_Z3addRxx(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %47)
  %.pre = load i32, ptr %35, align 4, !tbaa !5
  %.pre54 = load i32, ptr %41, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %37, %44
  %49 = phi i32 [ %42, %37 ], [ %.pre54, %44 ]
  %50 = phi i32 [ %39, %37 ], [ %.pre, %44 ]
  %.not40 = icmp sgt i32 %50, %49
  br i1 %.not40, label %.critedge, label %51

51:                                               ; preds = %48
  %52 = sext i32 %50 to i64
  %53 = mul nsw i64 %.02844, %52
  %54 = srem i64 %53, 1000000007
  call void @_Z3addRxx(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %54)
  br label %.critedge

.critedge:                                        ; preds = %51, %48
  %55 = add nuw nsw i64 %indvars.iv50, 1
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = icmp slt i64 %55, %57
  br i1 %58, label %59, label %73

59:                                               ; preds = %.critedge
  %60 = getelementptr inbounds [1001000 x i32], ptr @h, i64 0, i64 %55
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = load i32, ptr %35, align 4, !tbaa !5
  %63 = icmp sgt i32 %61, %62
  %64 = add nsw i64 %.02844, 1
  br i1 %63, label %65, label %69

65:                                               ; preds = %59
  %66 = sext i32 %62 to i64
  %67 = mul nsw i64 %64, %66
  %68 = srem i64 %67, 1000000007
  br label %73

69:                                               ; preds = %59
  %70 = sext i32 %61 to i64
  %71 = mul nsw i64 %64, %70
  %72 = srem i64 %71, 1000000007
  br label %73

73:                                               ; preds = %.lr.ph47._crit_edge, %.critedge, %69, %65
  %.pre-phi58 = phi i64 [ %.pre57, %.lr.ph47._crit_edge ], [ %57, %.critedge ], [ %57, %69 ], [ %57, %65 ]
  %indvars.iv.next51.pre-phi = phi i64 [ %.pre56, %.lr.ph47._crit_edge ], [ %55, %.critedge ], [ %55, %69 ], [ %55, %65 ]
  %74 = phi i32 [ %34, %.lr.ph47._crit_edge ], [ %56, %.critedge ], [ %56, %69 ], [ %56, %65 ]
  %.1 = phi i64 [ 0, %.lr.ph47._crit_edge ], [ %.02844, %.critedge ], [ %72, %69 ], [ %68, %65 ]
  %75 = icmp slt i64 %indvars.iv.next51.pre-phi, %.pre-phi58
  br i1 %75, label %.lr.ph47, label %._crit_edge48.loopexit, !llvm.loop !13

76:                                               ; preds = %._crit_edge48, %.critedge49
  ret i32 0
}

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { 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 #5 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10, !14}
!14 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass