; LLVM IR from tangjz/acm-icpc :: codeforces/gym (101205E)

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

@n = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@seq = external dso_local global [77 x i32], align 16
@e = external dso_local global [77 x %"class.std::bitset"], align 16
@cur = external dso_local global { [2 x i64] }, align 8
@fin = external dso_local global { [2 x i64] }, align 8
@msk = external dso_local global [77 x %"class.std::bitset"], align 16
@vis = external dso_local global [77 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsii(i32 noundef, i32 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
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::bitset<77>::reference", align 8
  %8 = alloca %"class.std::bitset<77>::reference", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"class.std::bitset", align 8
  %13 = alloca %"class.std::bitset", align 8
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %158, %0
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %161

19:                                               ; preds = %15
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @fin) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %59, %19
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %21
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE3setEmb(ptr noundef nonnull align 8 dereferenceable(16) @fin, i64 noundef %28, i1 noundef zeroext true)
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [77 x %"class.std::bitset"], ptr @e, i64 0, i64 %31
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) %32) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  br label %34

34:                                               ; preds = %49, %26
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %52

39:                                               ; preds = %34
  %40 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %6)
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = icmp ne i32 %41, 0
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #7
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [77 x %"class.std::bitset"], ptr @e, i64 0, i64 %44
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  call void @_ZNSt6bitsetILm77EEixEm(ptr dead_on_unwind writable sret(%"class.std::bitset<77>::reference") align 8 %7, ptr noundef nonnull align 8 dereferenceable(16) %45, i64 noundef %47)
  %48 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %7, i1 noundef zeroext %42) #7
  call void @_ZNSt6bitsetILm77EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #7
  br label %49

49:                                               ; preds = %39
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %5, align 4, !tbaa !5
  br label %34, !llvm.loop !9

52:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #7
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [77 x %"class.std::bitset"], ptr @e, i64 0, i64 %54
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  call void @_ZNSt6bitsetILm77EEixEm(ptr dead_on_unwind writable sret(%"class.std::bitset<77>::reference") align 8 %8, ptr noundef nonnull align 8 dereferenceable(16) %55, i64 noundef %57)
  %58 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %8, i1 noundef zeroext true) #7
  call void @_ZNSt6bitsetILm77EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #7
  br label %59

59:                                               ; preds = %52
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !11

62:                                               ; preds = %25
  %63 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @cur) #7
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 77, i1 false)
  store i32 0, ptr @ans, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %126, %62
  %65 = call noundef zeroext i1 @_ZNKSt6bitsetILm77EEneERKS0_(ptr noundef nonnull align 8 dereferenceable(16) @cur, ptr noundef nonnull align 8 dereferenceable(16) @fin) #7
  br i1 %65, label %66, label %129

66:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %109, %66
  %68 = load i32, ptr %10, align 4, !tbaa !5
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %112

72:                                               ; preds = %67
  %73 = load i32, ptr %10, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [77 x i8], ptr @vis, i64 0, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !12, !range !14, !noundef !15
  %77 = trunc i8 %76 to i1
  br i1 %77, label %108, label %78

78:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #7
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [77 x %"class.std::bitset"], ptr @e, i64 0, i64 %80
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #7
  %82 = call { i64, i64 } @_ZSteoILm77EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(16) @fin, ptr noundef nonnull align 8 dereferenceable(16) @cur) #7
  %83 = getelementptr inbounds %"class.std::bitset", ptr %13, i32 0, i32 0
  %84 = getelementptr inbounds %"struct.std::_Base_bitset", ptr %83, i32 0, i32 0
  %85 = getelementptr inbounds { i64, i64 }, ptr %84, i32 0, i32 0
  %86 = extractvalue { i64, i64 } %82, 0
  store i64 %86, ptr %85, align 8
  %87 = getelementptr inbounds { i64, i64 }, ptr %84, i32 0, i32 1
  %88 = extractvalue { i64, i64 } %82, 1
  store i64 %88, ptr %87, align 8
  %89 = call { i64, i64 } @_ZStanILm77EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(16) %81, ptr noundef nonnull align 8 dereferenceable(16) %13) #7
  %90 = getelementptr inbounds %"class.std::bitset", ptr %12, i32 0, i32 0
  %91 = getelementptr inbounds %"struct.std::_Base_bitset", ptr %90, i32 0, i32 0
  %92 = getelementptr inbounds { i64, i64 }, ptr %91, i32 0, i32 0
  %93 = extractvalue { i64, i64 } %89, 0
  store i64 %93, ptr %92, align 8
  %94 = getelementptr inbounds { i64, i64 }, ptr %91, i32 0, i32 1
  %95 = extractvalue { i64, i64 } %89, 1
  store i64 %95, ptr %94, align 8
  %96 = call noundef i64 @_ZNKSt6bitsetILm77EE5countEv(ptr noundef nonnull align 8 dereferenceable(16) %12) #7
  %97 = trunc i64 %96 to i32
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #7
  store i32 %97, ptr %11, align 4, !tbaa !5
  %98 = load i32, ptr %11, align 4, !tbaa !5
  %99 = load i32, ptr %9, align 4, !tbaa !5
  %100 = icmp sgt i32 %98, %99
  br i1 %100, label %101, label %107

101:                                              ; preds = %78
  %102 = load i32, ptr %10, align 4, !tbaa !5
  %103 = load i32, ptr @ans, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [77 x i32], ptr @seq, i64 0, i64 %104
  store i32 %102, ptr %105, align 4, !tbaa !5
  %106 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %106, ptr %9, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %101, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %108

108:                                              ; preds = %107, %72
  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 %67, !llvm.loop !16

112:                                              ; preds = %71
  %113 = load i32, ptr @ans, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [77 x i32], ptr @seq, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [77 x i8], ptr @vis, i64 0, i64 %117
  store i8 1, ptr %118, align 1, !tbaa !12
  %119 = load i32, ptr @ans, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [77 x i32], ptr @seq, i64 0, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [77 x %"class.std::bitset"], ptr @e, i64 0, i64 %123
  %125 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EEoRERKS0_(ptr noundef nonnull align 8 dereferenceable(16) @cur, ptr noundef nonnull align 8 dereferenceable(16) %124) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %126

126:                                              ; preds = %112
  %127 = load i32, ptr @ans, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr @ans, align 4, !tbaa !5
  br label %64, !llvm.loop !17

129:                                              ; preds = %64
  %130 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @msk) #7
  call void @_Z3dfsii(i32 noundef 0, i32 noundef 0)
  %131 = load i32, ptr %2, align 4, !tbaa !5
  %132 = load i32, ptr @ans, align 4, !tbaa !5
  %133 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %131, i32 noundef %132)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %154, %129
  %135 = load i32, ptr %14, align 4, !tbaa !5
  %136 = load i32, ptr @ans, align 4, !tbaa !5
  %137 = icmp slt i32 %135, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %157

139:                                              ; preds = %134
  %140 = load i32, ptr %14, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [77 x i32], ptr @seq, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  %145 = load i32, ptr %14, align 4, !tbaa !5
  %146 = load i32, ptr @ans, align 4, !tbaa !5
  %147 = sub nsw i32 %146, 1
  %148 = icmp eq i32 %145, %147
  %149 = zext i1 %148 to i64
  %150 = getelementptr inbounds [3 x i8], ptr @.str.4, i64 0, i64 %149
  %151 = load i8, ptr %150, align 1, !tbaa !18
  %152 = sext i8 %151 to i32
  %153 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %144, i32 noundef %152)
  br label %154

154:                                              ; preds = %139
  %155 = load i32, ptr %14, align 4, !tbaa !5
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %14, align 4, !tbaa !5
  br label %134, !llvm.loop !19

157:                                              ; preds = %138
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %2, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !20

161:                                              ; preds = %18
  ret i32 0
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE3setEmb(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i1 noundef zeroext) #0 align 2

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local { i64, i64 } @_ZStanILm77EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local { i64, i64 } @_ZSteoILm77EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #6

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

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

declare i32 @printf(ptr noundef, ...) #3

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 = { 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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { inlinehint 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 #7 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !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 { [2 x i64] }
%"class.std::bitset<77>::reference" = type { ptr, i64 }

@n = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@seq = external dso_local local_unnamed_addr global [77 x i32], align 16
@e = external dso_local global [77 x %"class.std::bitset"], align 16
@cur = external dso_local global { [2 x i64] }, align 8
@fin = external dso_local global { [2 x i64] }, align 8
@msk = external dso_local global [77 x %"class.std::bitset"], align 16
@vis = external dso_local local_unnamed_addr global [77 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::bitset<77>::reference", align 8
  %3 = alloca %"class.std::bitset<77>::reference", align 8
  %4 = alloca %"class.std::bitset", align 8
  %5 = alloca %"class.std::bitset", align 8
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %.lr.ph47, label %._crit_edge48

.lr.ph47:                                         ; preds = %0
  %8 = getelementptr inbounds i8, ptr %5, i64 8
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  br label %10

._crit_edge48:                                    ; preds = %._crit_edge44, %0
  ret i32 0

10:                                               ; preds = %.lr.ph47, %._crit_edge44
  %.02445 = phi i32 [ 1, %.lr.ph47 ], [ %73, %._crit_edge44 ]
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @fin) #7
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph34, label %._crit_edge35

._crit_edge35:                                    ; preds = %._crit_edge, %10
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @cur) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(77) @vis, i8 0, i64 77, i1 false)
  store i32 0, ptr @ans, align 4, !tbaa !5
  %15 = call noundef zeroext i1 @_ZNKSt6bitsetILm77EEneERKS0_(ptr noundef nonnull align 8 dereferenceable(16) @cur, ptr noundef nonnull align 8 dereferenceable(16) @fin) #7
  br i1 %15, label %.preheader, label %._crit_edge40

.lr.ph34:                                         ; preds = %10, %._crit_edge
  %indvars.iv50 = phi i64 [ %indvars.iv.next51, %._crit_edge ], [ 0, %10 ]
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE3setEmb(ptr noundef nonnull align 8 dereferenceable(16) @fin, i64 noundef %indvars.iv50, i1 noundef zeroext true)
  %17 = getelementptr inbounds [77 x %"class.std::bitset"], ptr @e, i64 0, i64 %indvars.iv50
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) %17) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph34
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  call void @_ZNSt6bitsetILm77EEixEm(ptr dead_on_unwind nonnull writable sret(%"class.std::bitset<77>::reference") align 8 %3, ptr noundef nonnull align 8 dereferenceable(16) %17, i64 noundef %indvars.iv50)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %3, i1 noundef zeroext true) #7
  call void @_ZNSt6bitsetILm77EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv.next51, %23
  br i1 %24, label %.lr.ph34, label %._crit_edge35, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph34, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph34 ]
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = icmp ne i32 %26, 0
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  call void @_ZNSt6bitsetILm77EEixEm(ptr dead_on_unwind nonnull writable sret(%"class.std::bitset<77>::reference") align 8 %2, ptr noundef nonnull align 8 dereferenceable(16) %17, i64 noundef %indvars.iv)
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %2, i1 noundef zeroext %27) #7
  call void @_ZNSt6bitsetILm77EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv.next, %30
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader:                                       ; preds = %._crit_edge35, %._crit_edge39
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph38, label %._crit_edge39

._crit_edge39:                                    ; preds = %64, %.preheader
  %34 = load i32, ptr @ans, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [77 x i32], ptr @seq, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [77 x i8], ptr @vis, i64 0, i64 %38
  store i8 1, ptr %39, align 1, !tbaa !12
  %40 = getelementptr inbounds [77 x %"class.std::bitset"], ptr @e, i64 0, i64 %38
  %41 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EEoRERKS0_(ptr noundef nonnull align 8 dereferenceable(16) @cur, ptr noundef nonnull align 8 dereferenceable(16) %40) #7
  %42 = load i32, ptr @ans, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr @ans, align 4, !tbaa !5
  %44 = call noundef zeroext i1 @_ZNKSt6bitsetILm77EEneERKS0_(ptr noundef nonnull align 8 dereferenceable(16) @cur, ptr noundef nonnull align 8 dereferenceable(16) @fin) #7
  br i1 %44, label %.preheader, label %._crit_edge40, !llvm.loop !14

.lr.ph38:                                         ; preds = %.preheader, %64
  %indvars.iv53 = phi i64 [ %indvars.iv.next54, %64 ], [ 0, %.preheader ]
  %.02636 = phi i32 [ %.2, %64 ], [ 0, %.preheader ]
  %45 = getelementptr inbounds [77 x i8], ptr @vis, i64 0, i64 %indvars.iv53
  %46 = load i8, ptr %45, align 1, !tbaa !12, !range !15, !noundef !16
  %47 = trunc nuw i8 %46 to i1
  br i1 %47, label %64, label %48

48:                                               ; preds = %.lr.ph38
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  %49 = getelementptr inbounds [77 x %"class.std::bitset"], ptr @e, i64 0, i64 %indvars.iv53
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #7
  %50 = call { i64, i64 } @_ZSteoILm77EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(16) @fin, ptr noundef nonnull align 8 dereferenceable(16) @cur) #7
  %51 = extractvalue { i64, i64 } %50, 0
  store i64 %51, ptr %5, align 8
  %52 = extractvalue { i64, i64 } %50, 1
  store i64 %52, ptr %8, align 8
  %53 = call { i64, i64 } @_ZStanILm77EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(16) %49, ptr noundef nonnull align 8 dereferenceable(16) %5) #7
  %54 = extractvalue { i64, i64 } %53, 0
  store i64 %54, ptr %4, align 8
  %55 = extractvalue { i64, i64 } %53, 1
  store i64 %55, ptr %9, align 8
  %56 = call noundef i64 @_ZNKSt6bitsetILm77EE5countEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #7
  %57 = trunc i64 %56 to i32
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  %58 = icmp slt i32 %.02636, %57
  br i1 %58, label %59, label %64

59:                                               ; preds = %48
  %60 = load i32, ptr @ans, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [77 x i32], ptr @seq, i64 0, i64 %61
  %63 = trunc nuw nsw i64 %indvars.iv53 to i32
  store i32 %63, ptr %62, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %48, %59, %.lr.ph38
  %.2 = phi i32 [ %.02636, %.lr.ph38 ], [ %57, %59 ], [ %.02636, %48 ]
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %65 = load i32, ptr @n, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = icmp slt i64 %indvars.iv.next54, %66
  br i1 %67, label %.lr.ph38, label %._crit_edge39, !llvm.loop !17

._crit_edge40:                                    ; preds = %._crit_edge39, %._crit_edge35
  %68 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @msk) #7
  call void @_Z3dfsii(i32 noundef 0, i32 noundef 0)
  %69 = load i32, ptr @ans, align 4, !tbaa !5
  %70 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.02445, i32 noundef %69)
  %71 = load i32, ptr @ans, align 4, !tbaa !5
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %.lr.ph43, label %._crit_edge44

._crit_edge44:                                    ; preds = %.lr.ph43, %._crit_edge40
  %73 = add nuw nsw i32 %.02445, 1
  %74 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %75 = icmp eq i32 %74, 1
  br i1 %75, label %10, label %._crit_edge48, !llvm.loop !18

.lr.ph43:                                         ; preds = %._crit_edge40, %.lr.ph43
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %.lr.ph43 ], [ 0, %._crit_edge40 ]
  %76 = phi i32 [ %88, %.lr.ph43 ], [ %71, %._crit_edge40 ]
  %77 = getelementptr inbounds [77 x i32], ptr @seq, i64 0, i64 %indvars.iv56
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  %80 = add nsw i32 %76, -1
  %81 = zext i32 %80 to i64
  %82 = icmp eq i64 %indvars.iv56, %81
  %83 = zext i1 %82 to i64
  %84 = getelementptr inbounds [3 x i8], ptr @.str.4, i64 0, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !19
  %86 = sext i8 %85 to i32
  %87 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %79, i32 noundef %86)
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %88 = load i32, ptr @ans, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = icmp slt i64 %indvars.iv.next57, %89
  br i1 %90, label %.lr.ph43, label %._crit_edge44, !llvm.loop !20
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm77EE9referenceaSEb(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 @_ZNSt6bitsetILm77EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local { i64, i64 } @_ZStanILm77EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local { i64, i64 } @_ZSteoILm77EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6bitsetILm77EE5countEv(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(16) ptr @_ZNSt6bitsetILm77EEoRERKS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4 align 2

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

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 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 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { inlinehint 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 #7 = { nounwind }

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

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


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