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

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

@n = external dso_local global i64, align 8
@x = external dso_local global i64, align 8
@a = external dso_local global [100000 x i64], align 16
@sum = external dso_local global i64, align 8
@mn = external dso_local global i64, align 8
@MOD = external dso_local global i64, align 8
@res = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3expxx(i64 noundef, i64 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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
  store i32 0, ptr %1, align 4
  %6 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %13 = getelementptr i8, ptr %12, i64 -24
  %14 = load i64, ptr %13, align 8
  %15 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %14
  %16 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %15, ptr noundef null)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(8) @x)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %19

19:                                               ; preds = %36, %0
  %20 = load i32, ptr %2, align 4, !tbaa !8
  %21 = sext i32 %20 to i64
  %22 = load i64, ptr @n, align 8, !tbaa !11
  %23 = icmp slt i64 %21, %22
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %19
  %26 = load i32, ptr %2, align 4, !tbaa !8
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %27
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %28)
  %30 = load i32, ptr %2, align 4, !tbaa !8
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = load i64, ptr @sum, align 8, !tbaa !11
  %35 = add nsw i64 %34, %33
  store i64 %35, ptr @sum, align 8, !tbaa !11
  br label %36

36:                                               ; preds = %25
  %37 = load i32, ptr %2, align 4, !tbaa !8
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %2, align 4, !tbaa !8
  br label %19, !llvm.loop !13

39:                                               ; preds = %24
  %40 = load i64, ptr @n, align 8, !tbaa !11
  %41 = getelementptr inbounds i64, ptr @a, i64 %40
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @a, ptr noundef %41)
  %42 = load i64, ptr @sum, align 8, !tbaa !11
  %43 = load i64, ptr @n, align 8, !tbaa !11
  %44 = sub nsw i64 %43, 1
  %45 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = sub nsw i64 %42, %46
  store i64 %47, ptr @mn, align 8, !tbaa !11
  %48 = load i64, ptr @x, align 8, !tbaa !11
  %49 = load i64, ptr @mn, align 8, !tbaa !11
  %50 = call noundef i64 @_Z3expxx(i64 noundef %48, i64 noundef %49)
  store i64 %50, ptr @res, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %51 = load i64, ptr @n, align 8, !tbaa !11
  %52 = sub nsw i64 %51, 1
  %53 = trunc i64 %52 to i32
  store i32 %53, ptr %4, align 4, !tbaa !8
  br label %54

54:                                               ; preds = %126, %39
  %55 = load i32, ptr %4, align 4, !tbaa !8
  %56 = icmp sge i32 %55, 0
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  store i32 5, ptr %5, align 4
  br label %129

58:                                               ; preds = %54
  %59 = load i64, ptr @sum, align 8, !tbaa !11
  %60 = load i32, ptr %4, align 4, !tbaa !8
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !11
  %64 = sub nsw i64 %59, %63
  %65 = load i64, ptr @mn, align 8, !tbaa !11
  %66 = icmp eq i64 %64, %65
  br i1 %66, label %67, label %70

67:                                               ; preds = %58
  %68 = load i32, ptr %3, align 4, !tbaa !8
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %3, align 4, !tbaa !8
  br label %125

70:                                               ; preds = %58
  %71 = load i32, ptr %3, align 4, !tbaa !8
  %72 = sext i32 %71 to i64
  %73 = load i64, ptr @x, align 8, !tbaa !11
  %74 = srem i64 %72, %73
  %75 = icmp eq i64 %74, 0
  br i1 %75, label %76, label %123

76:                                               ; preds = %70
  br label %77

77:                                               ; preds = %106, %76
  %78 = load i32, ptr %3, align 4, !tbaa !8
  %79 = sext i32 %78 to i64
  %80 = load i64, ptr @x, align 8, !tbaa !11
  %81 = srem i64 %79, %80
  %82 = icmp eq i64 %81, 0
  br i1 %82, label %83, label %107

83:                                               ; preds = %77
  %84 = load i64, ptr @sum, align 8, !tbaa !11
  %85 = load i32, ptr %4, align 4, !tbaa !8
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !11
  %89 = sub nsw i64 %84, %88
  %90 = load i64, ptr @mn, align 8, !tbaa !11
  %91 = icmp sgt i64 %89, %90
  br i1 %91, label %92, label %105

92:                                               ; preds = %83
  %93 = load i64, ptr @x, align 8, !tbaa !11
  %94 = load i32, ptr %3, align 4, !tbaa !8
  %95 = sext i32 %94 to i64
  %96 = sdiv i64 %95, %93
  %97 = trunc i64 %96 to i32
  store i32 %97, ptr %3, align 4, !tbaa !8
  %98 = load i64, ptr @res, align 8, !tbaa !11
  %99 = load i64, ptr @x, align 8, !tbaa !11
  %100 = mul nsw i64 %98, %99
  %101 = load i64, ptr @MOD, align 8, !tbaa !11
  %102 = srem i64 %100, %101
  store i64 %102, ptr @res, align 8, !tbaa !11
  %103 = load i64, ptr @mn, align 8, !tbaa !11
  %104 = add nsw i64 %103, 1
  store i64 %104, ptr @mn, align 8, !tbaa !11
  br label %106

105:                                              ; preds = %83
  br label %107

106:                                              ; preds = %92
  br label %77, !llvm.loop !15

107:                                              ; preds = %105, %77
  %108 = load i32, ptr %4, align 4, !tbaa !8
  %109 = icmp sge i32 %108, 0
  br i1 %109, label %110, label %122

110:                                              ; preds = %107
  %111 = load i64, ptr @sum, align 8, !tbaa !11
  %112 = load i32, ptr %4, align 4, !tbaa !8
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !11
  %116 = sub nsw i64 %111, %115
  %117 = load i64, ptr @mn, align 8, !tbaa !11
  %118 = icmp eq i64 %116, %117
  br i1 %118, label %119, label %122

119:                                              ; preds = %110
  %120 = load i32, ptr %3, align 4, !tbaa !8
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %3, align 4, !tbaa !8
  br label %122

122:                                              ; preds = %119, %110, %107
  br label %124

123:                                              ; preds = %70
  store i32 5, ptr %5, align 4
  br label %129

124:                                              ; preds = %122
  br label %125

125:                                              ; preds = %124, %67
  br label %126

126:                                              ; preds = %125
  %127 = load i32, ptr %4, align 4, !tbaa !8
  %128 = add nsw i32 %127, -1
  store i32 %128, ptr %4, align 4, !tbaa !8
  br label %54, !llvm.loop !16

129:                                              ; preds = %123, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %137, %130
  %132 = load i32, ptr %3, align 4, !tbaa !8
  %133 = sext i32 %132 to i64
  %134 = load i64, ptr @x, align 8, !tbaa !11
  %135 = srem i64 %133, %134
  %136 = icmp eq i64 %135, 0
  br i1 %136, label %137, label %150

137:                                              ; preds = %131
  %138 = load i64, ptr @x, align 8, !tbaa !11
  %139 = load i32, ptr %3, align 4, !tbaa !8
  %140 = sext i32 %139 to i64
  %141 = sdiv i64 %140, %138
  %142 = trunc i64 %141 to i32
  store i32 %142, ptr %3, align 4, !tbaa !8
  %143 = load i64, ptr @res, align 8, !tbaa !11
  %144 = load i64, ptr @x, align 8, !tbaa !11
  %145 = mul nsw i64 %143, %144
  %146 = load i64, ptr @MOD, align 8, !tbaa !11
  %147 = srem i64 %145, %146
  store i64 %147, ptr @res, align 8, !tbaa !11
  %148 = load i64, ptr @mn, align 8, !tbaa !11
  %149 = add nsw i64 %148, 1
  store i64 %149, ptr @mn, align 8, !tbaa !11
  br label %131, !llvm.loop !17

150:                                              ; preds = %131
  %151 = load i64, ptr @mn, align 8, !tbaa !11
  %152 = load i64, ptr @sum, align 8, !tbaa !11
  %153 = icmp sle i64 %151, %152
  br i1 %153, label %154, label %158

154:                                              ; preds = %150
  %155 = load i64, ptr @res, align 8, !tbaa !11
  %156 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %155)
  %157 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %156, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %164

158:                                              ; preds = %150
  %159 = load i64, ptr @x, align 8, !tbaa !11
  %160 = load i64, ptr @sum, align 8, !tbaa !11
  %161 = call noundef i64 @_Z3expxx(i64 noundef %159, i64 noundef %160)
  %162 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %161)
  %163 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %162, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %164

164:                                              ; preds = %158, %154
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  %165 = load i32, ptr %1, align 4
  ret i32 %165
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #3

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) #5

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 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 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


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

@n = external dso_local global i64, align 8
@x = external dso_local global i64, align 8
@a = external dso_local global [100000 x i64], align 16
@sum = external dso_local local_unnamed_addr global i64, align 8
@mn = external dso_local local_unnamed_addr global i64, align 8
@MOD = external dso_local local_unnamed_addr global i64, align 8
@res = external dso_local local_unnamed_addr global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3expxx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %14 = load i64, ptr @n, align 8, !tbaa !8
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa23 = phi i64 [ %14, %0 ], [ %36, %.lr.ph ]
  %16 = getelementptr inbounds i64, ptr @a, i64 %.lcssa23
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %16)
  %17 = load i64, ptr @sum, align 8, !tbaa !8
  %18 = load i64, ptr @n, align 8, !tbaa !8
  %19 = add nsw i64 %18, -1
  %20 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !8
  %22 = sub nsw i64 %17, %21
  store i64 %22, ptr @mn, align 8, !tbaa !8
  %23 = load i64, ptr @x, align 8, !tbaa !8
  %24 = tail call noundef i64 @_Z3expxx(i64 noundef %23, i64 noundef %22)
  store i64 %24, ptr @res, align 8, !tbaa !8
  %25 = load i64, ptr @n, align 8, !tbaa !8
  %26 = trunc i64 %25 to i32
  %.045 = add i32 %26, -1
  %27 = icmp sgt i32 %.045, -1
  %.pre = load i64, ptr @x, align 8
  br i1 %27, label %.lr.ph51, label %._crit_edge52

.lr.ph51:                                         ; preds = %._crit_edge
  %mn.promoted31 = load i64, ptr @mn, align 8, !tbaa !8
  %28 = load i64, ptr @sum, align 8, !tbaa !8
  %29 = load i64, ptr @MOD, align 8
  %30 = zext nneg i32 %.045 to i64
  br label %38

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %31 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %indvars.iv
  %32 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %31)
  %33 = load i64, ptr %31, align 8, !tbaa !8
  %34 = load i64, ptr @sum, align 8, !tbaa !8
  %35 = add nsw i64 %34, %33
  store i64 %35, ptr @sum, align 8, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %36 = load i64, ptr @n, align 8, !tbaa !8
  %37 = icmp sgt i64 %36, %indvars.iv.next
  br i1 %37, label %.lr.ph, label %._crit_edge, !llvm.loop !11

38:                                               ; preds = %.lr.ph51, %62
  %res.promoted75 = phi i64 [ %24, %.lr.ph51 ], [ %res.promoted71, %62 ]
  %indvars.iv66 = phi i64 [ %30, %.lr.ph51 ], [ %indvars.iv.next67, %62 ]
  %.01848 = phi i32 [ 0, %.lr.ph51 ], [ %.2, %62 ]
  %mn.promoted3547 = phi i64 [ %mn.promoted31, %.lr.ph51 ], [ %mn.promoted32, %62 ]
  %res.promoted4046 = phi i64 [ %24, %.lr.ph51 ], [ %res.promoted37, %62 ]
  %39 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %indvars.iv66
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %41 = sub nsw i64 %28, %40
  %42 = icmp eq i64 %41, %mn.promoted3547
  br i1 %42, label %43, label %45

43:                                               ; preds = %38
  %44 = add nsw i32 %.01848, 1
  br label %62

45:                                               ; preds = %38
  %46 = sext i32 %.01848 to i64
  %47 = srem i64 %46, %.pre
  %48 = icmp eq i64 %47, 0
  br i1 %48, label %.lr.ph26.preheader, label %._crit_edge52.loopexit

.lr.ph26.preheader:                               ; preds = %45
  %49 = icmp sgt i64 %41, %mn.promoted3547
  br i1 %49, label %.lr.ph84, label %._crit_edge27

.lr.ph84:                                         ; preds = %.lr.ph26.preheader, %.lr.ph84
  %50 = phi i64 [ %55, %.lr.ph84 ], [ %46, %.lr.ph26.preheader ]
  %mn.promoted3483 = phi i64 [ %54, %.lr.ph84 ], [ %mn.promoted3547, %.lr.ph26.preheader ]
  %res.promoted3982 = phi i64 [ %53, %.lr.ph84 ], [ %res.promoted4046, %.lr.ph26.preheader ]
  %51 = sdiv i64 %50, %.pre
  %52 = mul nsw i64 %res.promoted3982, %.pre
  %53 = srem i64 %52, %29
  %54 = add nsw i64 %mn.promoted3483, 1
  %sext = shl i64 %51, 32
  %55 = ashr exact i64 %sext, 32
  %56 = srem i64 %55, %.pre
  %57 = icmp eq i64 %56, 0
  %58 = icmp sgt i64 %41, %54
  %or.cond = select i1 %57, i1 %58, i1 false
  br i1 %or.cond, label %.lr.ph84, label %._crit_edge27.loopexit, !llvm.loop !13

._crit_edge27.loopexit:                           ; preds = %.lr.ph84
  store i64 %53, ptr @res, align 8, !tbaa !8
  store i64 %54, ptr @mn, align 8, !tbaa !8
  %59 = trunc i64 %51 to i32
  br label %._crit_edge27

._crit_edge27:                                    ; preds = %._crit_edge27.loopexit, %.lr.ph26.preheader
  %res.promoted73 = phi i64 [ %res.promoted75, %.lr.ph26.preheader ], [ %53, %._crit_edge27.loopexit ]
  %res.promoted38.ph = phi i64 [ %res.promoted4046, %.lr.ph26.preheader ], [ %53, %._crit_edge27.loopexit ]
  %mn.promoted33.ph = phi i64 [ %mn.promoted3547, %.lr.ph26.preheader ], [ %54, %._crit_edge27.loopexit ]
  %.1.lcssa.ph = phi i32 [ %.01848, %.lr.ph26.preheader ], [ %59, %._crit_edge27.loopexit ]
  %60 = icmp eq i64 %41, %mn.promoted33.ph
  %61 = zext i1 %60 to i32
  %spec.select = add nsw i32 %.1.lcssa.ph, %61
  br label %62

62:                                               ; preds = %._crit_edge27, %43
  %res.promoted71 = phi i64 [ %res.promoted75, %43 ], [ %res.promoted73, %._crit_edge27 ]
  %res.promoted37 = phi i64 [ %res.promoted4046, %43 ], [ %res.promoted38.ph, %._crit_edge27 ]
  %mn.promoted32 = phi i64 [ %mn.promoted3547, %43 ], [ %mn.promoted33.ph, %._crit_edge27 ]
  %.2 = phi i32 [ %44, %43 ], [ %spec.select, %._crit_edge27 ]
  %indvars.iv.next67 = add nsw i64 %indvars.iv66, -1
  %63 = icmp sgt i64 %indvars.iv66, 0
  br i1 %63, label %38, label %._crit_edge52.loopexit, !llvm.loop !14

._crit_edge52.loopexit:                           ; preds = %45, %62
  %res.promoted70 = phi i64 [ %res.promoted71, %62 ], [ %res.promoted75, %45 ]
  %.018.lcssa.ph = phi i32 [ %.2, %62 ], [ %.01848, %45 ]
  %64 = sext i32 %.018.lcssa.ph to i64
  br label %._crit_edge52

._crit_edge52:                                    ; preds = %._crit_edge52.loopexit, %._crit_edge
  %res.promoted = phi i64 [ %24, %._crit_edge ], [ %res.promoted70, %._crit_edge52.loopexit ]
  %.018.lcssa = phi i64 [ 0, %._crit_edge ], [ %64, %._crit_edge52.loopexit ]
  %65 = srem i64 %.018.lcssa, %.pre
  %66 = icmp eq i64 %65, 0
  %mn.promoted = load i64, ptr @mn, align 8, !tbaa !8
  br i1 %66, label %.lr.ph57, label %._crit_edge52._crit_edge

.lr.ph57:                                         ; preds = %._crit_edge52
  %67 = load i64, ptr @MOD, align 8, !tbaa !8
  br label %68

68:                                               ; preds = %.lr.ph57, %68
  %69 = phi i64 [ %.018.lcssa, %.lr.ph57 ], [ %76, %68 ]
  %70 = phi i64 [ %res.promoted, %.lr.ph57 ], [ %74, %68 ]
  %71 = phi i64 [ %mn.promoted, %.lr.ph57 ], [ %75, %68 ]
  %72 = sdiv i64 %69, %.pre
  %73 = mul nsw i64 %70, %.pre
  %74 = srem i64 %73, %67
  %75 = add nsw i64 %71, 1
  %sext62 = shl i64 %72, 32
  %76 = ashr exact i64 %sext62, 32
  %77 = srem i64 %76, %.pre
  %78 = icmp eq i64 %77, 0
  br i1 %78, label %68, label %._crit_edge58, !llvm.loop !15

._crit_edge58:                                    ; preds = %68
  store i64 %74, ptr @res, align 8, !tbaa !8
  store i64 %75, ptr @mn, align 8, !tbaa !8
  br label %._crit_edge52._crit_edge

._crit_edge52._crit_edge:                         ; preds = %._crit_edge52, %._crit_edge58
  %79 = phi i64 [ %74, %._crit_edge58 ], [ %res.promoted, %._crit_edge52 ]
  %80 = phi i64 [ %75, %._crit_edge58 ], [ %mn.promoted, %._crit_edge52 ]
  %81 = load i64, ptr @sum, align 8, !tbaa !8
  %.not = icmp sgt i64 %80, %81
  br i1 %.not, label %82, label %84

82:                                               ; preds = %._crit_edge52._crit_edge
  %83 = tail call noundef i64 @_Z3expxx(i64 noundef %.pre, i64 noundef %81)
  br label %84

84:                                               ; preds = %._crit_edge52._crit_edge, %82
  %.sink79 = phi i64 [ %83, %82 ], [ %79, %._crit_edge52._crit_edge ]
  %85 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.sink79)
  %86 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %85, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) 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 #3 align 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 #3 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)) #4

attributes #0 = { 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 #1 = { 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 #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 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 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" }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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