; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/WF/Easy Medium/NUMSET/A.ll (Z3prev)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@s = external dso_local global [1010 x i32], align 16
@l = external dso_local global [1010 x i32], align 16
@p = external dso_local global [1010 x i32], align 16
@id = external dso_local global %"class.std::map", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3prev() #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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  store i32 2, ptr %1, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %38, %0
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 1010
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  br label %41

12:                                               ; preds = %8
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %14
  store i32 1, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %33, %12
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = mul nsw i32 %17, %18
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = icmp sle i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %16
  store i32 5, ptr %2, align 4
  br label %36

23:                                               ; preds = %16
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = srem i32 %24, %25
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %32

28:                                               ; preds = %23
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %30
  store i32 0, ptr %31, align 4, !tbaa !5
  store i32 5, ptr %2, align 4
  br label %36

32:                                               ; preds = %23
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !5
  br label %16, !llvm.loop !9

36:                                               ; preds = %28, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %1, align 4, !tbaa !5
  br label %8, !llvm.loop !11

41:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 2, ptr %5, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %57, %41
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = icmp sle i32 %43, 31
  br i1 %44, label %46, label %45

45:                                               ; preds = %42
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %60

46:                                               ; preds = %42
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %56

52:                                               ; preds = %46
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %4, align 4, !tbaa !5
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @id, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store i32 %53, ptr %55, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %52, %46
  br label %57

57:                                               ; preds = %56
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %5, align 4, !tbaa !5
  br label %42, !llvm.loop !12

60:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 2, ptr %6, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %100, %60
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = icmp slt i32 %62, 1010
  br i1 %63, label %65, label %64

64:                                               ; preds = %61
  store i32 11, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %103

65:                                               ; preds = %61
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %72, label %71

71:                                               ; preds = %65
  br label %100

72:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %73 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %73, ptr %7, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %95, %72
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = icmp slt i32 %75, 1010
  br i1 %76, label %78, label %77

77:                                               ; preds = %74
  store i32 14, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %99

78:                                               ; preds = %74
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1010 x i32], ptr @l, i64 0, i64 %81
  store i32 %79, ptr %82, align 4, !tbaa !5
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = icmp sle i32 %83, 31
  br i1 %84, label %85, label %94

85:                                               ; preds = %78
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @id, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = shl i32 1, %87
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [1010 x i32], ptr @s, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = or i32 %92, %88
  store i32 %93, ptr %91, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %85, %78
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = add nsw i32 %97, %96
  store i32 %98, ptr %7, align 4, !tbaa !5
  br label %74, !llvm.loop !13

99:                                               ; preds = %77
  br label %100

100:                                              ; preds = %99, %71
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %6, align 4, !tbaa !5
  br label %61, !llvm.loop !14

103:                                              ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  ret void
}

; 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 uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) #0 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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}


; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@s = external dso_local local_unnamed_addr global [1010 x i32], align 16
@l = external dso_local local_unnamed_addr global [1010 x i32], align 16
@p = external dso_local local_unnamed_addr global [1010 x i32], align 16
@id = external dso_local global %"class.std::map", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3prev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  br label %4

3:                                                ; preds = %.loopexit23
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #2
  store i32 2, ptr %1, align 4, !tbaa !5
  br label %15

4:                                                ; preds = %0, %.loopexit23
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next, %.loopexit23 ]
  %5 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %indvars.iv
  store i32 1, ptr %5, align 4, !tbaa !5
  %.not2224 = icmp ult i64 %indvars.iv, 4
  br i1 %.not2224, label %.loopexit23, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %6 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.lr.ph

7:                                                ; preds = %.lr.ph
  %8 = add nuw nsw i32 %.01625, 1
  %9 = mul nuw nsw i32 %8, %8
  %10 = zext nneg i32 %9 to i64
  %.not22 = icmp ult i64 %indvars.iv, %10
  br i1 %.not22, label %.loopexit23, label %.lr.ph, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph.preheader, %7
  %.01625 = phi i32 [ %8, %7 ], [ 2, %.lr.ph.preheader ]
  %11 = urem i32 %6, %.01625
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %7

13:                                               ; preds = %.lr.ph
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %.loopexit23

.loopexit23:                                      ; preds = %7, %4, %13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1010
  br i1 %exitcond.not, label %3, label %4, !llvm.loop !11

14:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #2
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %27

15:                                               ; preds = %3, %22
  %.01529 = phi i32 [ 0, %3 ], [ %.1, %22 ]
  %storemerge28 = phi i32 [ 2, %3 ], [ %24, %22 ]
  %16 = sext i32 %storemerge28 to i64
  %17 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not21 = icmp eq i32 %18, 0
  br i1 %.not21, label %22, label %19

19:                                               ; preds = %15
  %20 = add nsw i32 %.01529, 1
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @id, ptr noundef nonnull align 4 dereferenceable(4) %1)
  store i32 %.01529, ptr %21, align 4, !tbaa !5
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %15, %19
  %23 = phi i32 [ %.pre, %19 ], [ %storemerge28, %15 ]
  %.1 = phi i32 [ %20, %19 ], [ %.01529, %15 ]
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %1, align 4, !tbaa !5
  %25 = icmp slt i32 %23, 31
  br i1 %25, label %15, label %14, !llvm.loop !12

26:                                               ; preds = %.loopexit
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #2
  ret void

27:                                               ; preds = %14, %.loopexit
  %28 = phi i32 [ 2, %14 ], [ %51, %.loopexit ]
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1010 x i32], ptr @p, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %.not.not = icmp eq i32 %31, 0
  br i1 %.not.not, label %.loopexit, label %.lr.ph31

.lr.ph31:                                         ; preds = %27
  %32 = icmp slt i32 %28, 32
  br i1 %32, label %.lr.ph31.split, label %.lr.ph31.split.us

.lr.ph31.split.us:                                ; preds = %.lr.ph31, %.lr.ph31.split.us
  %indvars.iv35 = phi i64 [ %indvars.iv.next36, %.lr.ph31.split.us ], [ %29, %.lr.ph31 ]
  %33 = getelementptr inbounds [1010 x i32], ptr @l, i64 0, i64 %indvars.iv35
  store i32 %28, ptr %33, align 4, !tbaa !5
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, %29
  %34 = icmp slt i64 %indvars.iv.next36, 1010
  br i1 %34, label %.lr.ph31.split.us, label %.loopexit, !llvm.loop !13

.lr.ph31.split:                                   ; preds = %.lr.ph31, %46
  %35 = phi i32 [ %47, %46 ], [ %28, %.lr.ph31 ]
  %.030 = phi i32 [ %48, %46 ], [ %28, %.lr.ph31 ]
  %36 = sext i32 %.030 to i64
  %37 = getelementptr inbounds [1010 x i32], ptr @l, i64 0, i64 %36
  store i32 %35, ptr %37, align 4, !tbaa !5
  %38 = icmp slt i32 %35, 32
  br i1 %38, label %39, label %46

39:                                               ; preds = %.lr.ph31.split
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @id, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = shl nuw i32 1, %41
  %43 = getelementptr inbounds [1010 x i32], ptr @s, i64 0, i64 %36
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = or i32 %44, %42
  store i32 %45, ptr %43, align 4, !tbaa !5
  %.pre38 = load i32, ptr %2, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %.lr.ph31.split, %39
  %47 = phi i32 [ %35, %.lr.ph31.split ], [ %.pre38, %39 ]
  %48 = add nsw i32 %47, %.030
  %49 = icmp slt i32 %48, 1010
  br i1 %49, label %.lr.ph31.split, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph31.split.us, %46, %27
  %50 = phi i32 [ %28, %27 ], [ %47, %46 ], [ %28, %.lr.ph31.split.us ]
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %2, align 4, !tbaa !5
  %52 = icmp slt i32 %50, 1009
  br i1 %52, label %27, label %26, !llvm.loop !17
}

; 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 uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = distinct !{!15, !10, !16}
!16 = !{!"llvm.loop.unswitch.partial.disable"}
!17 = distinct !{!17, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass