; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/257 Div 1/D (D)

; 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 i32, align 4
@a = external dso_local global [1048576 x i32], align 16
@p = external dso_local global [1048576 x i64], align 16
@dp = external dso_local global [1048576 x i64], 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 i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %11 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %13
  %15 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  %16 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  store i64 1, ptr @p, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %37, %0
  %23 = load i32, ptr %2, align 4, !tbaa !11
  %24 = icmp slt i32 %23, 1048576
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %22
  %27 = load i32, ptr %2, align 4, !tbaa !11
  %28 = sub nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1048576 x i64], ptr @p, i64 0, i64 %29
  %31 = load i64, ptr %30, align 8, !tbaa !8
  %32 = mul nsw i64 %31, 2
  %33 = srem i64 %32, 1000000007
  %34 = load i32, ptr %2, align 4, !tbaa !11
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1048576 x i64], ptr @p, i64 0, i64 %35
  store i64 %33, ptr %36, align 8, !tbaa !8
  br label %37

37:                                               ; preds = %26
  %38 = load i32, ptr %2, align 4, !tbaa !11
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !11
  br label %22, !llvm.loop !13

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

41:                                               ; preds = %59, %40
  %42 = load i32, ptr %3, align 4, !tbaa !11
  %43 = load i32, ptr @n, align 4, !tbaa !11
  %44 = icmp sle i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %62

46:                                               ; preds = %41
  %47 = load i32, ptr %3, align 4, !tbaa !11
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1048576 x i32], ptr @a, i64 0, i64 %48
  %50 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %49)
  %51 = load i32, ptr %3, align 4, !tbaa !11
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1048576 x i32], ptr @a, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !8
  %58 = add nsw i64 %57, 1
  store i64 %58, ptr %56, align 8, !tbaa !8
  br label %59

59:                                               ; preds = %46
  %60 = load i32, ptr %3, align 4, !tbaa !11
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %3, align 4, !tbaa !11
  br label %41, !llvm.loop !15

62:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 19, ptr %4, align 4, !tbaa !11
  br label %63

63:                                               ; preds = %108, %62
  %64 = load i32, ptr %4, align 4, !tbaa !11
  %65 = icmp sge i32 %64, 0
  br i1 %65, label %67, label %66

66:                                               ; preds = %63
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %111

67:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1048575, ptr %6, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %104, %67
  %69 = load i32, ptr %6, align 4, !tbaa !11
  %70 = icmp sge i32 %69, 0
  br i1 %70, label %72, label %71

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

72:                                               ; preds = %68
  %73 = load i32, ptr %6, align 4, !tbaa !11
  %74 = load i32, ptr %4, align 4, !tbaa !11
  %75 = shl i32 1, %74
  %76 = and i32 %73, %75
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %103

78:                                               ; preds = %72
  %79 = load i32, ptr %6, align 4, !tbaa !11
  %80 = load i32, ptr %4, align 4, !tbaa !11
  %81 = shl i32 1, %80
  %82 = xor i32 %79, %81
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !8
  %86 = load i32, ptr %6, align 4, !tbaa !11
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %87
  %89 = load i64, ptr %88, align 8, !tbaa !8
  %90 = add nsw i64 %89, %85
  store i64 %90, ptr %88, align 8, !tbaa !8
  %91 = load i32, ptr %6, align 4, !tbaa !11
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !8
  %95 = icmp sge i64 %94, 1000000007
  br i1 %95, label %96, label %102

96:                                               ; preds = %78
  %97 = load i32, ptr %6, align 4, !tbaa !11
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %98
  %100 = load i64, ptr %99, align 8, !tbaa !8
  %101 = sub nsw i64 %100, 1000000007
  store i64 %101, ptr %99, align 8, !tbaa !8
  br label %102

102:                                              ; preds = %96, %78
  br label %103

103:                                              ; preds = %102, %72
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %6, align 4, !tbaa !11
  %106 = add nsw i32 %105, -1
  store i32 %106, ptr %6, align 4, !tbaa !11
  br label %68, !llvm.loop !16

107:                                              ; preds = %71
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %4, align 4, !tbaa !11
  %110 = add nsw i32 %109, -1
  store i32 %110, ptr %4, align 4, !tbaa !11
  br label %63, !llvm.loop !17

111:                                              ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %112

112:                                              ; preds = %153, %111
  %113 = load i32, ptr %8, align 4, !tbaa !11
  %114 = icmp slt i32 %113, 1048576
  br i1 %114, label %116, label %115

115:                                              ; preds = %112
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %156

116:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %117 = load i32, ptr %8, align 4, !tbaa !11
  %118 = call i32 @llvm.ctpop.i32(i32 %117)
  store i32 %118, ptr %9, align 4, !tbaa !11
  %119 = load i32, ptr %9, align 4, !tbaa !11
  %120 = srem i32 %119, 2
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %137

122:                                              ; preds = %116
  %123 = load i32, ptr %8, align 4, !tbaa !11
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %124
  %126 = load i64, ptr %125, align 8, !tbaa !8
  %127 = getelementptr inbounds [1048576 x i64], ptr @p, i64 0, i64 %126
  %128 = load i64, ptr %127, align 8, !tbaa !8
  %129 = load i64, ptr %7, align 8, !tbaa !8
  %130 = sub nsw i64 %129, %128
  store i64 %130, ptr %7, align 8, !tbaa !8
  %131 = load i64, ptr %7, align 8, !tbaa !8
  %132 = icmp slt i64 %131, 0
  br i1 %132, label %133, label %136

133:                                              ; preds = %122
  %134 = load i64, ptr %7, align 8, !tbaa !8
  %135 = add nsw i64 %134, 1000000007
  store i64 %135, ptr %7, align 8, !tbaa !8
  br label %136

136:                                              ; preds = %133, %122
  br label %152

137:                                              ; preds = %116
  %138 = load i32, ptr %8, align 4, !tbaa !11
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %139
  %141 = load i64, ptr %140, align 8, !tbaa !8
  %142 = getelementptr inbounds [1048576 x i64], ptr @p, i64 0, i64 %141
  %143 = load i64, ptr %142, align 8, !tbaa !8
  %144 = load i64, ptr %7, align 8, !tbaa !8
  %145 = add nsw i64 %144, %143
  store i64 %145, ptr %7, align 8, !tbaa !8
  %146 = load i64, ptr %7, align 8, !tbaa !8
  %147 = icmp sge i64 %146, 1000000007
  br i1 %147, label %148, label %151

148:                                              ; preds = %137
  %149 = load i64, ptr %7, align 8, !tbaa !8
  %150 = sub nsw i64 %149, 1000000007
  store i64 %150, ptr %7, align 8, !tbaa !8
  br label %151

151:                                              ; preds = %148, %137
  br label %152

152:                                              ; preds = %151, %136
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %8, align 4, !tbaa !11
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %8, align 4, !tbaa !11
  br label %112, !llvm.loop !18

156:                                              ; preds = %115
  %157 = load i64, ptr %7, align 8, !tbaa !8
  %158 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %157)
  %159 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %158, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  %160 = load i32, ptr %1, align 4
  ret i32 %160
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctpop.i32(i32) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #5 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) #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)) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #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 = !{!"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 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !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 i32, align 4
@a = external dso_local global [1048576 x i32], align 16
@p = external dso_local local_unnamed_addr global [1048576 x i64], align 16
@dp = external dso_local local_unnamed_addr global [1048576 x i64], 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 = 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 @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  store i64 1, ptr @p, align 16, !tbaa !8
  br label %14

.preheader47:                                     ; preds = %14
  %13 = load i32, ptr @n, align 4, !tbaa !11
  %.not49 = icmp slt i32 %13, 1
  br i1 %.not49, label %.preheader45.preheader, label %.lr.ph

14:                                               ; preds = %14, %0
  %15 = phi i64 [ 1, %0 ], [ %23, %14 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.2, %14 ]
  %16 = shl nsw i64 %15, 1
  %17 = srem i64 %16, 1000000007
  %18 = getelementptr inbounds [1048576 x i64], ptr @p, i64 0, i64 %indvars.iv
  store i64 %17, ptr %18, align 8, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = shl nsw i64 %17, 1
  %20 = srem i64 %19, 1000000007
  %21 = getelementptr inbounds [1048576 x i64], ptr @p, i64 0, i64 %indvars.iv.next
  store i64 %20, ptr %21, align 8, !tbaa !8
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %22 = shl nsw i64 %20, 1
  %23 = srem i64 %22, 1000000007
  %24 = getelementptr inbounds [1048576 x i64], ptr @p, i64 0, i64 %indvars.iv.next.1
  store i64 %23, ptr %24, align 8, !tbaa !8
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %exitcond.not.2 = icmp eq i64 %indvars.iv.next.2, 1048576
  br i1 %exitcond.not.2, label %.preheader47, label %14, !llvm.loop !13

.lr.ph:                                           ; preds = %.preheader47, %.lr.ph
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %.lr.ph ], [ 1, %.preheader47 ]
  %25 = getelementptr inbounds [1048576 x i32], ptr @a, i64 0, i64 %indvars.iv56
  %26 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %25)
  %27 = load i32, ptr %25, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !8
  %31 = add nsw i64 %30, 1
  store i64 %31, ptr %29, align 8, !tbaa !8
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %32 = load i32, ptr @n, align 4, !tbaa !11
  %33 = sext i32 %32 to i64
  %.not.not = icmp slt i64 %indvars.iv56, %33
  br i1 %.not.not, label %.lr.ph, label %.preheader45.preheader, !llvm.loop !15

.preheader45.preheader:                           ; preds = %.lr.ph, %.preheader47
  br label %.preheader45

.preheader45:                                     ; preds = %.preheader45.preheader, %35
  %.03552 = phi i32 [ %36, %35 ], [ 19, %.preheader45.preheader ]
  %34 = shl nuw i32 1, %.03552
  br label %37

35:                                               ; preds = %52
  %36 = add nsw i32 %.03552, -1
  %.not66 = icmp eq i32 %.03552, 0
  br i1 %.not66, label %.preheader, label %.preheader45, !llvm.loop !16

37:                                               ; preds = %.preheader45, %52
  %indvars.iv59 = phi i64 [ 1048575, %.preheader45 ], [ %indvars.iv.next60, %52 ]
  %38 = trunc nuw nsw i64 %indvars.iv59 to i32
  %39 = and i32 %34, %38
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %52

41:                                               ; preds = %37
  %42 = xor i32 %34, %38
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !8
  %46 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %indvars.iv59
  %47 = load i64, ptr %46, align 8, !tbaa !8
  %48 = add nsw i64 %47, %45
  store i64 %48, ptr %46, align 8, !tbaa !8
  %49 = icmp sgt i64 %48, 1000000006
  br i1 %49, label %50, label %52

50:                                               ; preds = %41
  %51 = add nsw i64 %48, -1000000007
  store i64 %51, ptr %46, align 8, !tbaa !8
  br label %52

52:                                               ; preds = %37, %50, %41
  %indvars.iv.next60 = add nsw i64 %indvars.iv59, -1
  %.not = icmp eq i64 %indvars.iv59, 0
  br i1 %.not, label %35, label %37, !llvm.loop !17

53:                                               ; preds = %71
  %54 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.1)
  %55 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %54, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.preheader:                                       ; preds = %35, %71
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %71 ], [ 0, %35 ]
  %.03353 = phi i64 [ %.1, %71 ], [ 0, %35 ]
  %56 = trunc nuw nsw i64 %indvars.iv62 to i32
  %57 = tail call range(i32 0, 21) i32 @llvm.ctpop.i32(i32 %56)
  %58 = and i32 %57, 1
  %.not43 = icmp eq i32 %58, 0
  %59 = getelementptr inbounds [1048576 x i64], ptr @dp, i64 0, i64 %indvars.iv62
  %60 = load i64, ptr %59, align 8, !tbaa !8
  %61 = getelementptr inbounds [1048576 x i64], ptr @p, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  br i1 %.not43, label %67, label %63

63:                                               ; preds = %.preheader
  %64 = sub nsw i64 %.03353, %62
  %65 = icmp slt i64 %64, 0
  %66 = add nsw i64 %64, 1000000007
  %spec.select = select i1 %65, i64 %66, i64 %64
  br label %71

67:                                               ; preds = %.preheader
  %68 = add nsw i64 %62, %.03353
  %69 = icmp sgt i64 %68, 1000000006
  %70 = add nsw i64 %68, -1000000007
  %spec.select44 = select i1 %69, i64 %70, i64 %68
  br label %71

71:                                               ; preds = %67, %63
  %.1 = phi i64 [ %spec.select, %63 ], [ %spec.select44, %67 ]
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %exitcond65.not = icmp eq i64 %indvars.iv.next63, 1048576
  br i1 %exitcond65.not, label %53, label %.preheader, !llvm.loop !18
}

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

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

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 #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctpop.i32(i32) #3

; 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 #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) local_unnamed_addr #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 norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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