; LLVM IR from tangjz/acm-icpc :: 51nod (1356)

; 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::bitset" = type { %"struct.std::_Base_bitset" }
%"struct.std::_Base_bitset" = type { [63 x i64] }
%"class.std::bitset<4000>::reference" = type { ptr, i64 }

@a = external dso_local global [500 x %"class.std::bitset"], align 16
@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5indexi(i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %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 %"class.std::bitset<4000>::reference", align 8
  %8 = alloca %"class.std::bitset<4000>::reference", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"class.std::bitset<4000>::reference", align 8
  %13 = alloca i1, align 1
  %14 = alloca i1, align 1
  %15 = alloca %"class.std::bitset<4000>::reference", align 8
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %17

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

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

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 2, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  br label %24

24:                                               ; preds = %63, %22
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = sdiv i32 %26, %27
  %29 = icmp sle i32 %25, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %24
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %66

31:                                               ; preds = %24
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = srem i32 %32, %33
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %62

36:                                               ; preds = %31
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %43, %36
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = srem i32 %38, %39
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %49

42:                                               ; preds = %37
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sdiv i32 %45, %44
  store i32 %46, ptr %4, align 4, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %6, align 4, !tbaa !5
  br label %37, !llvm.loop !9

49:                                               ; preds = %37
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = and i32 %50, 1
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %61

53:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %55
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = call noundef i32 @_Z5indexi(i32 noundef %57)
  %59 = sext i32 %58 to i64
  call void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind writable sret(%"class.std::bitset<4000>::reference") align 8 %7, ptr noundef nonnull align 8 dereferenceable(504) %56, i64 noundef %59)
  %60 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm4000EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %7, i1 noundef zeroext true) #5
  call void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  br label %61

61:                                               ; preds = %53, %49
  br label %62

62:                                               ; preds = %61, %31
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %5, align 4, !tbaa !5
  br label %24, !llvm.loop !11

66:                                               ; preds = %30
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = icmp sgt i32 %67, 1
  br i1 %68, label %69, label %77

69:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %70 = load i32, ptr %2, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %71
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = call noundef i32 @_Z5indexi(i32 noundef %73)
  %75 = sext i32 %74 to i64
  call void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind writable sret(%"class.std::bitset<4000>::reference") align 8 %8, ptr noundef nonnull align 8 dereferenceable(504) %72, i64 noundef %75)
  %76 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm4000EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %8, i1 noundef zeroext true) #5
  call void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  br label %77

77:                                               ; preds = %69, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !12

81:                                               ; preds = %21
  store i32 1, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  br label %82

82:                                               ; preds = %152, %81
  %83 = load i32, ptr %9, align 4, !tbaa !5
  %84 = load i32, ptr @n, align 4, !tbaa !5
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %155

87:                                               ; preds = %82
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %109, %87
  %89 = load i32, ptr %10, align 4, !tbaa !5
  %90 = load i32, ptr @tot, align 4, !tbaa !5
  %91 = icmp slt i32 %89, %90
  store i1 false, ptr %13, align 1
  store i1 false, ptr %14, align 1
  br i1 %91, label %92, label %100

92:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  store i1 true, ptr %13, align 1
  %93 = load i32, ptr %9, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %94
  %96 = load i32, ptr %10, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  call void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind writable sret(%"class.std::bitset<4000>::reference") align 8 %12, ptr noundef nonnull align 8 dereferenceable(504) %95, i64 noundef %97)
  store i1 true, ptr %14, align 1
  %98 = call noundef zeroext i1 @_ZNKSt6bitsetILm4000EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %12) #5
  %99 = xor i1 %98, true
  br label %100

100:                                              ; preds = %92, %88
  %101 = phi i1 [ false, %88 ], [ %99, %92 ]
  %102 = load i1, ptr %14, align 1
  br i1 %102, label %103, label %104

103:                                              ; preds = %100
  call void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %12) #5
  br label %104

104:                                              ; preds = %103, %100
  %105 = load i1, ptr %13, align 1
  br i1 %105, label %106, label %107

106:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  br label %107

107:                                              ; preds = %106, %104
  br i1 %101, label %108, label %112

108:                                              ; preds = %107
  br label %109

109:                                              ; preds = %108
  %110 = load i32, ptr %10, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %10, align 4, !tbaa !5
  br label %88, !llvm.loop !13

112:                                              ; preds = %107
  %113 = load i32, ptr %10, align 4, !tbaa !5
  %114 = load i32, ptr @tot, align 4, !tbaa !5
  %115 = icmp eq i32 %113, %114
  br i1 %115, label %116, label %117

116:                                              ; preds = %112
  br label %152

117:                                              ; preds = %112
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %11, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %140, %117
  %121 = load i32, ptr %11, align 4, !tbaa !5
  %122 = load i32, ptr @n, align 4, !tbaa !5
  %123 = icmp slt i32 %121, %122
  br i1 %123, label %124, label %143

124:                                              ; preds = %120
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #5
  %125 = load i32, ptr %11, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %126
  %128 = load i32, ptr %10, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  call void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind writable sret(%"class.std::bitset<4000>::reference") align 8 %15, ptr noundef nonnull align 8 dereferenceable(504) %127, i64 noundef %129)
  %130 = call noundef zeroext i1 @_ZNKSt6bitsetILm4000EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %15) #5
  call void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %15) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #5
  br i1 %130, label %131, label %139

131:                                              ; preds = %124
  %132 = load i32, ptr %9, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %133
  %135 = load i32, ptr %11, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %136
  %138 = call noundef nonnull align 8 dereferenceable(504) ptr @_ZNSt6bitsetILm4000EEeOERKS0_(ptr noundef nonnull align 8 dereferenceable(504) %137, ptr noundef nonnull align 8 dereferenceable(504) %134) #5
  br label %139

139:                                              ; preds = %131, %124
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %11, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %11, align 4, !tbaa !5
  br label %120, !llvm.loop !14

143:                                              ; preds = %120
  %144 = load i32, ptr @ans, align 4, !tbaa !5
  %145 = shl i32 %144, 1
  store i32 %145, ptr @ans, align 4, !tbaa !5
  %146 = load i32, ptr @ans, align 4, !tbaa !5
  %147 = icmp sge i32 %146, 1000000007
  br i1 %147, label %148, label %151

148:                                              ; preds = %143
  %149 = load i32, ptr @ans, align 4, !tbaa !5
  %150 = sub nsw i32 %149, 1000000007
  store i32 %150, ptr @ans, align 4, !tbaa !5
  br label %151

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

152:                                              ; preds = %151, %116
  %153 = load i32, ptr %9, align 4, !tbaa !5
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %9, align 4, !tbaa !5
  br label %82, !llvm.loop !15

155:                                              ; preds = %86
  %156 = load i32, ptr @ans, align 4, !tbaa !5
  %157 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %156)
  ret i32 0
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind noalias writable sret(%"class.std::bitset<4000>::reference") align 8, ptr noundef nonnull align 8 dereferenceable(504), i64 noundef) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm4000EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16), i1 noundef zeroext) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6bitsetILm4000EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(504) ptr @_ZNSt6bitsetILm4000EEeOERKS0_(ptr noundef nonnull align 8 dereferenceable(504), ptr noundef nonnull align 8 dereferenceable(504)) #4 align 2

declare i32 @printf(ptr noundef, ...) #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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}


; 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::bitset" = type { %"struct.std::_Base_bitset" }
%"struct.std::_Base_bitset" = type { [63 x i64] }
%"class.std::bitset<4000>::reference" = type { ptr, i64 }

@a = external dso_local global [500 x %"class.std::bitset"], align 16
@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5indexi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::bitset<4000>::reference", align 8
  %3 = alloca %"class.std::bitset<4000>::reference", align 8
  %4 = alloca %"class.std::bitset<4000>::reference", align 8
  %5 = alloca %"class.std::bitset<4000>::reference", align 8
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph49, label %._crit_edge50.thread

._crit_edge50.thread:                             ; preds = %0
  store i32 1, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge60

._crit_edge50:                                    ; preds = %38
  store i32 1, ptr @ans, align 4, !tbaa !5
  %9 = icmp sgt i32 %39, 0
  br i1 %9, label %.preheader37, label %._crit_edge60

.lr.ph49:                                         ; preds = %0, %38
  %indvars.iv = phi i64 [ %indvars.iv.next, %38 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %.not41 = icmp slt i32 %11, 4
  br i1 %.not41, label %._crit_edge45, label %.lr.ph44

.lr.ph44:                                         ; preds = %.lr.ph49
  %12 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %indvars.iv
  br label %14

._crit_edge45:                                    ; preds = %29, %.lr.ph49
  %.lcssa = phi i32 [ %11, %.lr.ph49 ], [ %30, %29 ]
  %13 = icmp sgt i32 %.lcssa, 1
  br i1 %13, label %33, label %38

14:                                               ; preds = %.lr.ph44, %29
  %15 = phi i32 [ %11, %.lr.ph44 ], [ %30, %29 ]
  %.03342 = phi i32 [ 2, %.lr.ph44 ], [ %31, %29 ]
  %16 = srem i32 %15, %.03342
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %.lr.ph, label %29

.lr.ph:                                           ; preds = %14, %.lr.ph
  %.03239 = phi i32 [ %20, %.lr.ph ], [ 0, %14 ]
  %18 = phi i32 [ %19, %.lr.ph ], [ %15, %14 ]
  %19 = sdiv i32 %18, %.03342
  %20 = add nuw nsw i32 %.03239, 1
  %21 = srem i32 %19, %.03342
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %.lr.ph, label %23, !llvm.loop !9

23:                                               ; preds = %.lr.ph
  store i32 %19, ptr %1, align 4, !tbaa !5
  %24 = and i32 %.03239, 1
  %.not36.not = icmp eq i32 %24, 0
  br i1 %.not36.not, label %25, label %29

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  %26 = call noundef i32 @_Z5indexi(i32 noundef %.03342)
  %27 = sext i32 %26 to i64
  call void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind nonnull writable sret(%"class.std::bitset<4000>::reference") align 8 %2, ptr noundef nonnull align 8 dereferenceable(504) %12, i64 noundef %27)
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm4000EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %2, i1 noundef zeroext true) #5
  call void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %14, %25, %23
  %30 = phi i32 [ %15, %14 ], [ %.pre, %25 ], [ %19, %23 ]
  %31 = add nuw nsw i32 %.03342, 1
  %32 = sdiv i32 %30, %31
  %.not.not = icmp slt i32 %.03342, %32
  br i1 %.not.not, label %14, label %._crit_edge45, !llvm.loop !11

33:                                               ; preds = %._crit_edge45
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  %34 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %indvars.iv
  %35 = call noundef i32 @_Z5indexi(i32 noundef %.lcssa)
  %36 = sext i32 %35 to i64
  call void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind nonnull writable sret(%"class.std::bitset<4000>::reference") align 8 %3, ptr noundef nonnull align 8 dereferenceable(504) %34, i64 noundef %36)
  %37 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm4000EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %3, i1 noundef zeroext true) #5
  call void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  br label %38

38:                                               ; preds = %33, %._crit_edge45
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = icmp slt i64 %indvars.iv.next, %40
  br i1 %41, label %.lr.ph49, label %._crit_edge50, !llvm.loop !12

.preheader37:                                     ; preds = %._crit_edge50, %.critedge.thread._crit_edge
  %.pre8083 = phi i32 [ %.pre8084, %.critedge.thread._crit_edge ], [ %39, %._crit_edge50 ]
  %indvars.iv74 = phi i64 [ %.pre86, %.critedge.thread._crit_edge ], [ 0, %._crit_edge50 ]
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.critedge.thread._crit_edge ], [ 1, %._crit_edge50 ]
  %42 = load i32, ptr @tot, align 4, !tbaa !5
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %.critedge.lr.ph, label %.critedge.thread

.critedge.lr.ph:                                  ; preds = %.preheader37
  %44 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %indvars.iv74
  br label %.critedge

._crit_edge60.loopexit:                           ; preds = %.critedge.thread._crit_edge
  %.pre81 = load i32, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge60

._crit_edge60:                                    ; preds = %._crit_edge50.thread, %._crit_edge60.loopexit, %._crit_edge50
  %45 = phi i32 [ %.pre81, %._crit_edge60.loopexit ], [ 1, %._crit_edge50 ], [ 1, %._crit_edge50.thread ]
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %45)
  ret i32 0

.critedge:                                        ; preds = %.critedge.lr.ph, %48
  %indvars.iv65 = phi i64 [ 0, %.critedge.lr.ph ], [ %indvars.iv.next66, %48 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  call void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind nonnull writable sret(%"class.std::bitset<4000>::reference") align 8 %4, ptr noundef nonnull align 8 dereferenceable(504) %44, i64 noundef %indvars.iv65)
  %47 = call noundef zeroext i1 @_ZNKSt6bitsetILm4000EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #5
  call void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  %.pre79.pre = load i32, ptr @tot, align 4, !tbaa !5
  br i1 %47, label %.critedge.thread.loopexit, label %48

48:                                               ; preds = %.critedge
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %49 = sext i32 %.pre79.pre to i64
  %50 = icmp slt i64 %indvars.iv.next66, %49
  br i1 %50, label %.critedge, label %.critedge.thread.loopexit, !llvm.loop !13

.critedge.thread.loopexit:                        ; preds = %48, %.critedge
  %.030.lcssa.ph.in = phi i64 [ %indvars.iv65, %.critedge ], [ %indvars.iv.next66, %48 ]
  %.030.lcssa.ph = trunc i64 %.030.lcssa.ph.in to i32
  %.pre80.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %.critedge.thread.loopexit, %.preheader37
  %.pre80 = phi i32 [ %.pre8083, %.preheader37 ], [ %.pre80.pre, %.critedge.thread.loopexit ]
  %51 = phi i32 [ %42, %.preheader37 ], [ %.pre79.pre, %.critedge.thread.loopexit ]
  %.030.lcssa = phi i32 [ 0, %.preheader37 ], [ %.030.lcssa.ph, %.critedge.thread.loopexit ]
  %52 = icmp eq i32 %.030.lcssa, %51
  %.pre86 = add nuw nsw i64 %indvars.iv74, 1
  br i1 %52, label %.critedge.thread._crit_edge, label %.preheader

.preheader:                                       ; preds = %.critedge.thread
  %53 = sext i32 %.pre80 to i64
  %54 = icmp slt i64 %.pre86, %53
  br i1 %54, label %.lr.ph56, label %._crit_edge57

.lr.ph56:                                         ; preds = %.preheader
  %55 = zext nneg i32 %.030.lcssa to i64
  %56 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %indvars.iv74
  br label %57

57:                                               ; preds = %.lr.ph56, %62
  %indvars.iv70 = phi i64 [ %indvars.iv68, %.lr.ph56 ], [ %indvars.iv.next71, %62 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  %58 = getelementptr inbounds [500 x %"class.std::bitset"], ptr @a, i64 0, i64 %indvars.iv70
  call void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind nonnull writable sret(%"class.std::bitset<4000>::reference") align 8 %5, ptr noundef nonnull align 8 dereferenceable(504) %58, i64 noundef %55)
  %59 = call noundef zeroext i1 @_ZNKSt6bitsetILm4000EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #5
  call void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  br i1 %59, label %60, label %62

60:                                               ; preds = %57
  %61 = call noundef nonnull align 8 dereferenceable(504) ptr @_ZNSt6bitsetILm4000EEeOERKS0_(ptr noundef nonnull align 8 dereferenceable(504) %58, ptr noundef nonnull align 8 dereferenceable(504) %56) #5
  br label %62

62:                                               ; preds = %57, %60
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = trunc nuw i64 %indvars.iv.next71 to i32
  %65 = icmp sgt i32 %63, %64
  br i1 %65, label %57, label %._crit_edge57, !llvm.loop !14

._crit_edge57:                                    ; preds = %62, %.preheader
  %.pre8082 = phi i32 [ %.pre80, %.preheader ], [ %63, %62 ]
  %66 = load i32, ptr @ans, align 4, !tbaa !5
  %67 = shl i32 %66, 1
  store i32 %67, ptr @ans, align 4, !tbaa !5
  %68 = icmp sgt i32 %67, 1000000006
  br i1 %68, label %69, label %.critedge.thread._crit_edge

69:                                               ; preds = %._crit_edge57
  %70 = add nsw i32 %67, -1000000007
  store i32 %70, ptr @ans, align 4, !tbaa !5
  br label %.critedge.thread._crit_edge

.critedge.thread._crit_edge:                      ; preds = %.critedge.thread, %._crit_edge57, %69
  %.pre8084 = phi i32 [ %.pre8082, %._crit_edge57 ], [ %.pre8082, %69 ], [ %.pre80, %.critedge.thread ]
  %71 = sext i32 %.pre8084 to i64
  %72 = icmp slt i64 %.pre86, %71
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  br i1 %72, label %.preheader37, label %._crit_edge60.loopexit, !llvm.loop !15
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6bitsetILm4000EEixEm(ptr dead_on_unwind noalias writable sret(%"class.std::bitset<4000>::reference") align 8, ptr noundef nonnull align 8 dereferenceable(504), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm4000EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16), i1 noundef zeroext) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6bitsetILm4000EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6bitsetILm4000EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(504) ptr @_ZNSt6bitsetILm4000EEeOERKS0_(ptr noundef nonnull align 8 dereferenceable(504), ptr noundef nonnull align 8 dereferenceable(504)) local_unnamed_addr #4 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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}


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