; LLVM IR from DionysiosB/CodeForces :: 0400-0499 (429A-XorTree)

; 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.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsllRKSt6vectorIS_IlSaIlEESaIS1_EERSt3setIlSt4lessIlES0_ERKS_IiSaIiEEiii(i64 noundef %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) #0 {
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"struct.std::pair", align 8
  %19 = alloca i64, align 8
  %20 = alloca i32, align 4
  %21 = alloca i64, align 8
  store i64 %0, ptr %9, align 8, !tbaa !5
  store i64 %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !9
  store ptr %3, ptr %12, align 8, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !11
  store i32 %6, ptr %15, align 4, !tbaa !11
  store i32 %7, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %22 = load i32, ptr %14, align 4, !tbaa !11
  %23 = srem i32 %22, 2
  %24 = load i32, ptr %15, align 4, !tbaa !11
  %25 = and i32 %23, %24
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %37, label %27

27:                                               ; preds = %8
  %28 = load i32, ptr %14, align 4, !tbaa !11
  %29 = add nsw i32 %28, 1
  %30 = srem i32 %29, 2
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %27
  %33 = load i32, ptr %16, align 4, !tbaa !11
  %34 = icmp ne i32 %33, 0
  br label %35

35:                                               ; preds = %32, %27
  %36 = phi i1 [ false, %27 ], [ %34, %32 ]
  br label %37

37:                                               ; preds = %35, %8
  %38 = phi i1 [ true, %8 ], [ %36, %35 ]
  %39 = zext i1 %38 to i32
  store i32 %39, ptr %17, align 4, !tbaa !11
  %40 = load ptr, ptr %13, align 8, !tbaa !9
  %41 = load i64, ptr %9, align 8, !tbaa !5
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %41) #3
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = load i32, ptr %17, align 4, !tbaa !11
  %45 = xor i32 %43, %44
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %64

47:                                               ; preds = %37
  %48 = load ptr, ptr %12, align 8, !tbaa !9
  %49 = call { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48) %48, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %50 = getelementptr inbounds { ptr, i8 }, ptr %18, i32 0, i32 0
  %51 = extractvalue { ptr, i8 } %49, 0
  store ptr %51, ptr %50, align 8
  %52 = getelementptr inbounds { ptr, i8 }, ptr %18, i32 0, i32 1
  %53 = extractvalue { ptr, i8 } %49, 1
  store i8 %53, ptr %52, align 8
  %54 = load i32, ptr %14, align 4, !tbaa !11
  %55 = and i32 %54, 1
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %60

57:                                               ; preds = %47
  %58 = load i32, ptr %15, align 4, !tbaa !11
  %59 = sub nsw i32 1, %58
  store i32 %59, ptr %15, align 4, !tbaa !11
  br label %63

60:                                               ; preds = %47
  %61 = load i32, ptr %16, align 4, !tbaa !11
  %62 = sub nsw i32 1, %61
  store i32 %62, ptr %16, align 4, !tbaa !11
  br label %63

63:                                               ; preds = %60, %57
  br label %64

64:                                               ; preds = %63, %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  store i64 0, ptr %19, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %98, %64
  %66 = load i64, ptr %19, align 8, !tbaa !5
  %67 = load ptr, ptr %11, align 8, !tbaa !9
  %68 = load i64, ptr %9, align 8, !tbaa !5
  %69 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %67, i64 noundef %68) #3
  %70 = call noundef i64 @_ZNKSt6vectorIlSaIlEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %69) #3
  %71 = icmp ult i64 %66, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %65
  store i32 2, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  br label %101

73:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  %74 = load ptr, ptr %11, align 8, !tbaa !9
  %75 = load i64, ptr %9, align 8, !tbaa !5
  %76 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %74, i64 noundef %75) #3
  %77 = load i64, ptr %19, align 8, !tbaa !5
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %76, i64 noundef %77) #3
  %79 = load i64, ptr %78, align 8, !tbaa !5
  store i64 %79, ptr %21, align 8, !tbaa !5
  %80 = load i64, ptr %21, align 8, !tbaa !5
  %81 = load i64, ptr %10, align 8, !tbaa !5
  %82 = icmp eq i64 %80, %81
  br i1 %82, label %83, label %84

83:                                               ; preds = %73
  store i32 4, ptr %20, align 4
  br label %95

84:                                               ; preds = %73
  %85 = load i64, ptr %21, align 8, !tbaa !5
  %86 = load i64, ptr %9, align 8, !tbaa !5
  %87 = load ptr, ptr %11, align 8, !tbaa !9
  %88 = load ptr, ptr %12, align 8, !tbaa !9
  %89 = load ptr, ptr %13, align 8, !tbaa !9
  %90 = load i32, ptr %14, align 4, !tbaa !11
  %91 = add nsw i32 %90, 1
  %92 = srem i32 %91, 2
  %93 = load i32, ptr %15, align 4, !tbaa !11
  %94 = load i32, ptr %16, align 4, !tbaa !11
  call void @_Z3dfsllRKSt6vectorIS_IlSaIlEESaIS1_EERSt3setIlSt4lessIlES0_ERKS_IiSaIiEEiii(i64 noundef %85, i64 noundef %86, ptr noundef nonnull align 8 dereferenceable(24) %87, ptr noundef nonnull align 8 dereferenceable(48) %88, ptr noundef nonnull align 8 dereferenceable(24) %89, i32 noundef %92, i32 noundef %93, i32 noundef %94)
  store i32 0, ptr %20, align 4
  br label %95

95:                                               ; preds = %84, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  %96 = load i32, ptr %20, align 4
  switch i32 %96, label %102 [
    i32 0, label %97
    i32 4, label %98
  ]

97:                                               ; preds = %95
  br label %98

98:                                               ; preds = %97, %95
  %99 = load i64, ptr %19, align 8, !tbaa !5
  %100 = add nsw i64 %99, 1
  store i64 %100, ptr %19, align 8, !tbaa !5
  br label %65, !llvm.loop !13

101:                                              ; preds = %72
  store i32 1, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  ret void

102:                                              ; preds = %95
  unreachable
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsllRKSt6vectorIS_IlSaIlEESaIS1_EERSt3setIlSt4lessIlES0_ERKS_IiSaIiEEiii(i64 noundef %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) local_unnamed_addr #0 {
  %9 = alloca i64, align 8
  store i64 %0, ptr %9, align 8, !tbaa !5
  %10 = srem i32 %5, 2
  %11 = and i32 %10, %6
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %18

12:                                               ; preds = %8
  %13 = and i32 %5, 1
  %14 = icmp eq i32 %13, 0
  %15 = icmp ne i32 %7, 0
  %16 = and i1 %14, %15
  %17 = zext i1 %16 to i32
  br label %18

18:                                               ; preds = %12, %8
  %19 = phi i32 [ 1, %8 ], [ %17, %12 ]
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %0) #2
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %.not26 = icmp eq i32 %21, %19
  br i1 %.not26, label %29, label %22

22:                                               ; preds = %18
  %23 = call { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %24 = and i32 %5, 1
  %.not27 = icmp eq i32 %24, 0
  br i1 %.not27, label %27, label %25

25:                                               ; preds = %22
  %26 = sub nsw i32 1, %6
  br label %29

27:                                               ; preds = %22
  %28 = sub nsw i32 1, %7
  br label %29

29:                                               ; preds = %25, %27, %18
  %.024 = phi i32 [ %7, %25 ], [ %28, %27 ], [ %7, %18 ]
  %.0 = phi i32 [ %26, %25 ], [ %6, %27 ], [ %6, %18 ]
  %30 = load i64, ptr %9, align 8, !tbaa !5
  %31 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %30) #2
  %32 = call noundef i64 @_ZNKSt6vectorIlSaIlEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %31) #2
  %.not29 = icmp eq i64 %32, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %29
  %33 = add nsw i32 %5, 1
  %34 = srem i32 %33, 2
  br label %35

._crit_edge:                                      ; preds = %43, %29
  ret void

35:                                               ; preds = %.lr.ph, %43
  %.02328 = phi i64 [ 0, %.lr.ph ], [ %44, %43 ]
  %36 = load i64, ptr %9, align 8, !tbaa !5
  %37 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %36) #2
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %.02328) #2
  %39 = load i64, ptr %38, align 8, !tbaa !5
  %40 = icmp eq i64 %39, %1
  br i1 %40, label %43, label %41

41:                                               ; preds = %35
  %42 = load i64, ptr %9, align 8, !tbaa !5
  call void @_Z3dfsllRKSt6vectorIS_IlSaIlEESaIS1_EERSt3setIlSt4lessIlES0_ERKS_IiSaIiEEiii(i64 noundef %39, i64 noundef %42, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %34, i32 noundef %.0, i32 noundef %.024)
  br label %43

43:                                               ; preds = %35, %41
  %44 = add nuw nsw i64 %.02328, 1
  %45 = load i64, ptr %9, align 8, !tbaa !5
  %46 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %45) #2
  %47 = call noundef i64 @_ZNKSt6vectorIlSaIlEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %46) #2
  %48 = icmp ult i64 %44, %47
  br i1 %48, label %35, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IlSaIlEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIlSaIlEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIlSaIlEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 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 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 #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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