; LLVM IR from tangjz/acm-icpc :: TDL_training/2016-05-22/upsolved (F - Equation - tjz)

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

%struct.Bitset = type { [1567 x i64] }

@hbit = external dso_local global [65536 x i32], align 16
@A = external dso_local global [2 x %struct.Bitset], align 16
@B = external dso_local global [2 x %struct.Bitset], align 16
@R = external dso_local global [2 x %struct.Bitset], align 16
@tmp = external dso_local global %struct.Bitset, align 8
@t = external dso_local global i32, align 4
@pre = external dso_local global i32, align 4
@cur = external dso_local global i32, align 4
@deg = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1

; 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 i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.Bitset, align 8
  %12 = alloca %struct.Bitset, align 8
  %13 = alloca %struct.Bitset, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %28, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 65536
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %31

18:                                               ; preds = %14
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = ashr i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [65536 x i32], ptr @hbit, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [65536 x i32], ptr @hbit, i64 0, i64 %26
  store i32 %24, ptr %27, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %18
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

31:                                               ; preds = %17
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %33

33:                                               ; preds = %187, %31
  %34 = load i32, ptr @t, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr @t, align 4, !tbaa !5
  %36 = icmp ne i32 %34, 0
  br i1 %36, label %37, label %194

37:                                               ; preds = %33
  %38 = load i32, ptr @cur, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %39
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %40, i32 noundef 1567)
  %41 = load i32, ptr @cur, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.Bitset, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds [1567 x i64], ptr %44, i64 0, i64 0
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = or i64 %46, 1
  store i64 %47, ptr %45, align 8, !tbaa !11
  %48 = load i32, ptr @cur, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %49
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %50, i32 noundef 1567)
  %51 = load i32, ptr @cur, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %52
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %53, i32 noundef 1567)
  %54 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @deg)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  br label %55

55:                                               ; preds = %80, %37
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = load i32, ptr @deg, align 4, !tbaa !5
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %83

60:                                               ; preds = %55
  %61 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %4)
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = icmp eq i32 %62, 1
  br i1 %63, label %64, label %79

64:                                               ; preds = %60
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = and i32 %65, 63
  %67 = zext i32 %66 to i64
  %68 = shl i64 1, %67
  %69 = load i32, ptr @cur, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.Bitset, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = ashr i32 %73, 6
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1567 x i64], ptr %72, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !11
  %78 = or i64 %77, %68
  store i64 %78, ptr %76, align 8, !tbaa !11
  br label %79

79:                                               ; preds = %64, %60
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %3, align 4, !tbaa !5
  br label %55, !llvm.loop !13

83:                                               ; preds = %59
  %84 = load i32, ptr @pre, align 4, !tbaa !5
  %85 = xor i32 %84, 1
  store i32 %85, ptr @pre, align 4, !tbaa !5
  %86 = load i32, ptr @cur, align 4, !tbaa !5
  %87 = xor i32 %86, 1
  store i32 %87, ptr @cur, align 4, !tbaa !5
  %88 = load i32, ptr @cur, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %89
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %90, i32 noundef 1567)
  %91 = load i32, ptr @cur, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %92
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %93, i32 noundef 1567)
  %94 = load i32, ptr @cur, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.Bitset, ptr %96, i32 0, i32 0
  %98 = getelementptr inbounds [1567 x i64], ptr %97, i64 0, i64 0
  %99 = load i64, ptr %98, align 8, !tbaa !11
  %100 = or i64 %99, 1
  store i64 %100, ptr %98, align 8, !tbaa !11
  %101 = load i32, ptr @cur, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %102
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %103, i32 noundef 1567)
  %104 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @deg)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  br label %105

105:                                              ; preds = %130, %83
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = load i32, ptr @deg, align 4, !tbaa !5
  %108 = icmp sle i32 %106, %107
  br i1 %108, label %110, label %109

109:                                              ; preds = %105
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %133

110:                                              ; preds = %105
  %111 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6)
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = icmp eq i32 %112, 1
  br i1 %113, label %114, label %129

114:                                              ; preds = %110
  %115 = load i32, ptr %5, align 4, !tbaa !5
  %116 = and i32 %115, 63
  %117 = zext i32 %116 to i64
  %118 = shl i64 1, %117
  %119 = load i32, ptr @cur, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %120
  %122 = getelementptr inbounds %struct.Bitset, ptr %121, i32 0, i32 0
  %123 = load i32, ptr %5, align 4, !tbaa !5
  %124 = ashr i32 %123, 6
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [1567 x i64], ptr %122, i64 0, i64 %125
  %127 = load i64, ptr %126, align 8, !tbaa !11
  %128 = or i64 %127, %118
  store i64 %128, ptr %126, align 8, !tbaa !11
  br label %129

129:                                              ; preds = %114, %110
  br label %130

130:                                              ; preds = %129
  %131 = load i32, ptr %5, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %5, align 4, !tbaa !5
  br label %105, !llvm.loop !14

133:                                              ; preds = %109
  br label %134

134:                                              ; preds = %186, %133
  %135 = load i32, ptr @pre, align 4, !tbaa !5
  %136 = xor i32 %135, 1
  store i32 %136, ptr @pre, align 4, !tbaa !5
  %137 = load i32, ptr @cur, align 4, !tbaa !5
  %138 = xor i32 %137, 1
  store i32 %138, ptr @cur, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %139 = load i32, ptr @pre, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %140
  %142 = call noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536) %141)
  store i32 %142, ptr %7, align 4, !tbaa !5
  %143 = load i32, ptr %7, align 4, !tbaa !5
  %144 = icmp eq i32 %143, -1
  br i1 %144, label %145, label %146

145:                                              ; preds = %134
  store i32 14, ptr %8, align 4
  br label %184

146:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %147 = load i32, ptr @cur, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %148
  %150 = call noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536) %149)
  store i32 %150, ptr %9, align 4, !tbaa !5
  br label %151

151:                                              ; preds = %178, %146
  %152 = load i32, ptr %9, align 4, !tbaa !5
  %153 = load i32, ptr %7, align 4, !tbaa !5
  %154 = icmp sge i32 %152, %153
  br i1 %154, label %156, label %155

155:                                              ; preds = %151
  store i32 15, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %183

156:                                              ; preds = %151
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %157 = load i32, ptr %9, align 4, !tbaa !5
  %158 = load i32, ptr %7, align 4, !tbaa !5
  %159 = sub nsw i32 %157, %158
  store i32 %159, ptr %10, align 4, !tbaa !5
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) @tmp, i32 noundef 1567)
  %160 = load i32, ptr @pre, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %161
  call void @_ZNK6Bitset5shiftERKiRS_(ptr noundef nonnull align 8 dereferenceable(12536) %162, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  %163 = load i32, ptr @cur, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %164
  call void @llvm.lifetime.start.p0(i64 12536, ptr %11) #5
  call void @_ZN6BitseteOERKS_(ptr dead_on_unwind writable sret(%struct.Bitset) align 8 %11, ptr noundef nonnull align 8 dereferenceable(12536) %165, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  call void @llvm.lifetime.end.p0(i64 12536, ptr %11) #5
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) @tmp, i32 noundef 1567)
  %166 = load i32, ptr @pre, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %167
  call void @_ZNK6Bitset5shiftERKiRS_(ptr noundef nonnull align 8 dereferenceable(12536) %168, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  %169 = load i32, ptr @cur, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %170
  call void @llvm.lifetime.start.p0(i64 12536, ptr %12) #5
  call void @_ZN6BitseteOERKS_(ptr dead_on_unwind writable sret(%struct.Bitset) align 8 %12, ptr noundef nonnull align 8 dereferenceable(12536) %171, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  call void @llvm.lifetime.end.p0(i64 12536, ptr %12) #5
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) @tmp, i32 noundef 1567)
  %172 = load i32, ptr @pre, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %173
  call void @_ZNK6Bitset5shiftERKiRS_(ptr noundef nonnull align 8 dereferenceable(12536) %174, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  %175 = load i32, ptr @cur, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %176
  call void @llvm.lifetime.start.p0(i64 12536, ptr %13) #5
  call void @_ZN6BitseteOERKS_(ptr dead_on_unwind writable sret(%struct.Bitset) align 8 %13, ptr noundef nonnull align 8 dereferenceable(12536) %177, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  call void @llvm.lifetime.end.p0(i64 12536, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %178

178:                                              ; preds = %156
  %179 = load i32, ptr @cur, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %180
  %182 = call noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536) %181)
  store i32 %182, ptr %9, align 4, !tbaa !5
  br label %151, !llvm.loop !15

183:                                              ; preds = %155
  store i32 0, ptr %8, align 4
  br label %184

184:                                              ; preds = %183, %145
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  %185 = load i32, ptr %8, align 4
  switch i32 %185, label %195 [
    i32 0, label %186
    i32 14, label %187
  ]

186:                                              ; preds = %184
  br label %134, !llvm.loop !16

187:                                              ; preds = %184
  %188 = load i32, ptr @cur, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %189
  call void @_ZNK6Bitset5printEv(ptr noundef nonnull align 8 dereferenceable(12536) %190)
  %191 = load i32, ptr @cur, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %192
  call void @_ZNK6Bitset5printEv(ptr noundef nonnull align 8 dereferenceable(12536) %193)
  br label %33, !llvm.loop !17

194:                                              ; preds = %33
  ret i32 0

195:                                              ; preds = %184
  unreachable
}

; 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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536), i32 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK6Bitset5shiftERKiRS_(ptr noundef nonnull align 8 dereferenceable(12536), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(12536)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BitseteOERKS_(ptr dead_on_unwind noalias writable sret(%struct.Bitset) align 8, ptr noundef nonnull align 8 dereferenceable(12536), ptr noundef nonnull align 8 dereferenceable(12536)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6Bitset5printEv(ptr noundef nonnull align 8 dereferenceable(12536)) #4 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 #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 = { nounwind }

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

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

%struct.Bitset = type { [1567 x i64] }

@hbit = external dso_local local_unnamed_addr global [65536 x i32], align 16
@A = external dso_local global [2 x %struct.Bitset], align 16
@B = external dso_local global [2 x %struct.Bitset], align 16
@R = external dso_local global [2 x %struct.Bitset], align 16
@tmp = external dso_local global %struct.Bitset, align 8
@t = external dso_local global i32, align 4
@pre = external dso_local local_unnamed_addr global i32, align 4
@cur = external dso_local local_unnamed_addr global i32, align 4
@deg = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %struct.Bitset, align 8
  %5 = alloca %struct.Bitset, align 8
  %6 = alloca %struct.Bitset, align 8
  br label %11

7:                                                ; preds = %11
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %9 = load i32, ptr @t, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @t, align 4, !tbaa !5
  %.not43 = icmp eq i32 %9, 0
  br i1 %.not43, label %._crit_edge46, label %.lr.ph45

11:                                               ; preds = %11, %0
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next.1, %11 ]
  %12 = lshr exact i64 %indvars.iv, 1
  %13 = getelementptr inbounds [65536 x i32], ptr @hbit, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = add nsw i32 %14, 1
  %16 = getelementptr inbounds [65536 x i32], ptr @hbit, i64 0, i64 %indvars.iv
  store i32 %15, ptr %16, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %17 = lshr exact i64 %indvars.iv, 1
  %18 = getelementptr inbounds [65536 x i32], ptr @hbit, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  %21 = getelementptr inbounds [65536 x i32], ptr @hbit, i64 0, i64 %indvars.iv.next
  store i32 %20, ptr %21, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 65536
  br i1 %exitcond.not.1, label %7, label %11, !llvm.loop !9

.lr.ph45:                                         ; preds = %7, %._crit_edge42
  %22 = load i32, ptr @cur, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %23
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %24, i32 noundef 1567)
  %25 = load i32, ptr @cur, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = or i64 %28, 1
  store i64 %29, ptr %27, align 8, !tbaa !11
  %30 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %26
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %30, i32 noundef 1567)
  %31 = load i32, ptr @cur, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %32
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %33, i32 noundef 1567)
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @deg)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %35 = load i32, ptr @deg, align 4, !tbaa !5
  %.not2329 = icmp slt i32 %35, 0
  br i1 %.not2329, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %68, %.lr.ph45
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %36 = load i32, ptr @pre, align 4, !tbaa !5
  %37 = xor i32 %36, 1
  store i32 %37, ptr @pre, align 4, !tbaa !5
  %38 = load i32, ptr @cur, align 4, !tbaa !5
  %39 = xor i32 %38, 1
  store i32 %39, ptr @cur, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %40
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %41, i32 noundef 1567)
  %42 = load i32, ptr @cur, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %43
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %44, i32 noundef 1567)
  %45 = load i32, ptr @cur, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !11
  %49 = or i64 %48, 1
  store i64 %49, ptr %47, align 8, !tbaa !11
  %50 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %46
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) %50, i32 noundef 1567)
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @deg)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %52 = load i32, ptr @deg, align 4, !tbaa !5
  %.not2431 = icmp slt i32 %52, 0
  br i1 %.not2431, label %._crit_edge35, label %.lr.ph34

.lr.ph:                                           ; preds = %.lr.ph45, %68
  %.02130 = phi i32 [ %69, %68 ], [ 0, %.lr.ph45 ]
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %54 = load i32, ptr %1, align 4, !tbaa !5
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %68

56:                                               ; preds = %.lr.ph
  %57 = and i32 %.02130, 63
  %58 = zext nneg i32 %57 to i64
  %59 = shl nuw i64 1, %58
  %60 = load i32, ptr @cur, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %61
  %63 = lshr i32 %.02130, 6
  %64 = zext nneg i32 %63 to i64
  %65 = getelementptr inbounds [1567 x i64], ptr %62, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !11
  %67 = or i64 %66, %59
  store i64 %67, ptr %65, align 8, !tbaa !11
  br label %68

68:                                               ; preds = %.lr.ph, %56
  %69 = add nuw nsw i32 %.02130, 1
  %70 = load i32, ptr @deg, align 4, !tbaa !5
  %.not23.not = icmp slt i32 %.02130, %70
  br i1 %.not23.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge35:                                    ; preds = %94, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %71 = load i32, ptr @pre, align 4, !tbaa !5
  %72 = xor i32 %71, 1
  store i32 %72, ptr @pre, align 4, !tbaa !5
  %73 = load i32, ptr @cur, align 4, !tbaa !5
  %74 = xor i32 %73, 1
  store i32 %74, ptr @cur, align 4, !tbaa !5
  %75 = sext i32 %72 to i64
  %76 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %75
  %77 = call noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536) %76)
  %78 = icmp eq i32 %77, -1
  br i1 %78, label %._crit_edge42, label %.lr.ph41

.lr.ph34:                                         ; preds = %._crit_edge, %94
  %.02032 = phi i32 [ %95, %94 ], [ 0, %._crit_edge ]
  %79 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = icmp eq i32 %80, 1
  br i1 %81, label %82, label %94

82:                                               ; preds = %.lr.ph34
  %83 = and i32 %.02032, 63
  %84 = zext nneg i32 %83 to i64
  %85 = shl nuw i64 1, %84
  %86 = load i32, ptr @cur, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %87
  %89 = lshr i32 %.02032, 6
  %90 = zext nneg i32 %89 to i64
  %91 = getelementptr inbounds [1567 x i64], ptr %88, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !11
  %93 = or i64 %92, %85
  store i64 %93, ptr %91, align 8, !tbaa !11
  br label %94

94:                                               ; preds = %.lr.ph34, %82
  %95 = add nuw nsw i32 %.02032, 1
  %96 = load i32, ptr @deg, align 4, !tbaa !5
  %.not24.not = icmp slt i32 %.02032, %96
  br i1 %.not24.not, label %.lr.ph34, label %._crit_edge35, !llvm.loop !14

.loopexit:                                        ; preds = %.lr.ph39, %.lr.ph41
  %97 = load i32, ptr @pre, align 4, !tbaa !5
  %98 = xor i32 %97, 1
  store i32 %98, ptr @pre, align 4, !tbaa !5
  %99 = load i32, ptr @cur, align 4, !tbaa !5
  %100 = xor i32 %99, 1
  store i32 %100, ptr @cur, align 4, !tbaa !5
  %101 = sext i32 %98 to i64
  %102 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %101
  %103 = call noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536) %102)
  %104 = icmp eq i32 %103, -1
  br i1 %104, label %._crit_edge42, label %.lr.ph41

.lr.ph41:                                         ; preds = %._crit_edge35, %.loopexit
  %105 = phi i32 [ %103, %.loopexit ], [ %77, %._crit_edge35 ]
  %106 = load i32, ptr @cur, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %107
  %109 = call noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536) %108)
  %.not2536 = icmp slt i32 %109, %105
  br i1 %.not2536, label %.loopexit, label %.lr.ph39

.lr.ph39:                                         ; preds = %.lr.ph41, %.lr.ph39
  %.037 = phi i32 [ %132, %.lr.ph39 ], [ %109, %.lr.ph41 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %110 = sub nsw i32 %.037, %105
  store i32 %110, ptr %3, align 4, !tbaa !5
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) @tmp, i32 noundef 1567)
  %111 = load i32, ptr @pre, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %112
  call void @_ZNK6Bitset5shiftERKiRS_(ptr noundef nonnull align 8 dereferenceable(12536) %113, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  %114 = load i32, ptr @cur, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %115
  call void @llvm.lifetime.start.p0(i64 12536, ptr nonnull %4) #5
  call void @_ZN6BitseteOERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Bitset) align 8 %4, ptr noundef nonnull align 8 dereferenceable(12536) %116, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  call void @llvm.lifetime.end.p0(i64 12536, ptr nonnull %4) #5
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) @tmp, i32 noundef 1567)
  %117 = load i32, ptr @pre, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %118
  call void @_ZNK6Bitset5shiftERKiRS_(ptr noundef nonnull align 8 dereferenceable(12536) %119, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  %120 = load i32, ptr @cur, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %121
  call void @llvm.lifetime.start.p0(i64 12536, ptr nonnull %5) #5
  call void @_ZN6BitseteOERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Bitset) align 8 %5, ptr noundef nonnull align 8 dereferenceable(12536) %122, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  call void @llvm.lifetime.end.p0(i64 12536, ptr nonnull %5) #5
  call void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536) @tmp, i32 noundef 1567)
  %123 = load i32, ptr @pre, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %124
  call void @_ZNK6Bitset5shiftERKiRS_(ptr noundef nonnull align 8 dereferenceable(12536) %125, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  %126 = load i32, ptr @cur, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %127
  call void @llvm.lifetime.start.p0(i64 12536, ptr nonnull %6) #5
  call void @_ZN6BitseteOERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Bitset) align 8 %6, ptr noundef nonnull align 8 dereferenceable(12536) %128, ptr noundef nonnull align 8 dereferenceable(12536) @tmp)
  call void @llvm.lifetime.end.p0(i64 12536, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %129 = load i32, ptr @cur, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [2 x %struct.Bitset], ptr @R, i64 0, i64 %130
  %132 = call noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536) %131)
  %.not25 = icmp slt i32 %132, %105
  br i1 %.not25, label %.loopexit, label %.lr.ph39, !llvm.loop !15

._crit_edge42:                                    ; preds = %.loopexit, %._crit_edge35
  %133 = load i32, ptr @cur, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [2 x %struct.Bitset], ptr @A, i64 0, i64 %134
  call void @_ZNK6Bitset5printEv(ptr noundef nonnull align 8 dereferenceable(12536) %135)
  %136 = load i32, ptr @cur, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [2 x %struct.Bitset], ptr @B, i64 0, i64 %137
  call void @_ZNK6Bitset5printEv(ptr noundef nonnull align 8 dereferenceable(12536) %138)
  %139 = load i32, ptr @t, align 4, !tbaa !5
  %140 = add nsw i32 %139, -1
  store i32 %140, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %139, 0
  br i1 %.not, label %._crit_edge46, label %.lr.ph45, !llvm.loop !16

._crit_edge46:                                    ; preds = %._crit_edge42, %7
  ret i32 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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6Bitset5clearEi(ptr noundef nonnull align 8 dereferenceable(12536), i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6Bitset7highbitEv(ptr noundef nonnull align 8 dereferenceable(12536)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK6Bitset5shiftERKiRS_(ptr noundef nonnull align 8 dereferenceable(12536), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(12536)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BitseteOERKS_(ptr dead_on_unwind noalias writable sret(%struct.Bitset) align 8, ptr noundef nonnull align 8 dereferenceable(12536), ptr noundef nonnull align 8 dereferenceable(12536)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6Bitset5printEv(ptr noundef nonnull align 8 dereferenceable(12536)) local_unnamed_addr #4 align 2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 = { nounwind }

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

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


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