; LLVM IR from Izaron/ACM-ICPC :: Timus Online Judge/Volume 2/1158. Censored!.ll (Z2dpii)

; 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.my_int = type { %"class.std::vector.11" }
%"class.std::vector.11" = type { %"struct.std::_Vector_base.12" }
%"struct.std::_Vector_base.12" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@ans = external dso_local global [150 x [150 x %struct.my_int]], align 16
@used = external dso_local global [150 x [150 x i8]], align 16

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5transii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z3badi(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4zerov(ptr dead_on_unwind noalias writable sret(%struct.my_int) align 8) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6my_intD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3onev(ptr dead_on_unwind noalias writable sret(%struct.my_int) align 8) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3addR6my_intS_(ptr dead_on_unwind noalias writable sret(%struct.my_int) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6my_intC2ERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2dpii(ptr dead_on_unwind noalias writable sret(%struct.my_int) align 8 %0, i32 noundef %1, i32 noundef %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.my_int, align 8
  %9 = alloca %struct.my_int, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = call noundef zeroext i1 @_Z3badi(i32 noundef %12)
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  call void @_Z4zerov(ptr dead_on_unwind writable sret(%struct.my_int) align 8 %0)
  br label %75

15:                                               ; preds = %3
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = icmp eq i32 %16, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %15
  call void @_Z3onev(ptr dead_on_unwind writable sret(%struct.my_int) align 8 %0)
  br label %75

20:                                               ; preds = %15
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [150 x [150 x i8]], ptr @used, i64 0, i64 %22
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [150 x i8], ptr %23, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !9, !range !11, !noundef !12
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %36

29:                                               ; preds = %20
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [150 x [150 x %struct.my_int]], ptr @ans, i64 0, i64 %31
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [150 x %struct.my_int], ptr %32, i64 0, i64 %34
  call void @_ZN6my_intC2ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %35)
  br label %75

36:                                               ; preds = %20
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [150 x [150 x i8]], ptr @used, i64 0, i64 %38
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [150 x i8], ptr %39, i64 0, i64 %41
  store i8 1, ptr %42, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %61, %36
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %68

48:                                               ; preds = %43
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [150 x [150 x %struct.my_int]], ptr @ans, i64 0, i64 %50
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [150 x %struct.my_int], ptr %51, i64 0, i64 %53
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = call noundef i32 @_Z5transii(i32 noundef %57, i32 noundef %58)
  call void @_Z2dpii(ptr dead_on_unwind writable sret(%struct.my_int) align 8 %9, i32 noundef %56, i32 noundef %59)
  invoke void @_Z3addR6my_intS_(ptr dead_on_unwind writable sret(%struct.my_int) align 8 %8, ptr noundef nonnull align 8 dereferenceable(24) %54, ptr noundef %9)
          to label %60 unwind label %64

60:                                               ; preds = %48
  call void @_ZN6my_intD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #4
  call void @_ZN6my_intD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9) #4
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %7, align 4, !tbaa !5
  br label %43, !llvm.loop !13

64:                                               ; preds = %48
  %65 = landingpad { ptr, i32 }
          cleanup
  %66 = extractvalue { ptr, i32 } %65, 0
  store ptr %66, ptr %10, align 8
  %67 = extractvalue { ptr, i32 } %65, 1
  store i32 %67, ptr %11, align 4
  call void @_ZN6my_intD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %76

68:                                               ; preds = %47
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [150 x [150 x %struct.my_int]], ptr @ans, i64 0, i64 %70
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [150 x %struct.my_int], ptr %71, i64 0, i64 %73
  call void @_ZN6my_intC2ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %74)
  br label %75

75:                                               ; preds = %68, %29, %19, %14
  ret void

76:                                               ; preds = %64
  %77 = load ptr, ptr %10, align 8
  %78 = load i32, ptr %11, align 4
  %79 = insertvalue { ptr, i32 } poison, ptr %77, 0
  %80 = insertvalue { ptr, i32 } %79, i32 %78, 1
  resume { ptr, i32 } %80
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { inlinehint 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 #4 = { 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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!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"

%struct.my_int = type { %"class.std::vector.11" }
%"class.std::vector.11" = type { %"struct.std::_Vector_base.12" }
%"struct.std::_Vector_base.12" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local global [150 x [150 x %struct.my_int]], align 16
@used = external dso_local local_unnamed_addr global [150 x [150 x i8]], align 16

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4zerov(ptr dead_on_unwind noalias writable sret(%struct.my_int) align 8) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6my_intD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3onev(ptr dead_on_unwind noalias writable sret(%struct.my_int) align 8) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3addR6my_intS_(ptr dead_on_unwind noalias writable sret(%struct.my_int) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6my_intC2ERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2dpii(ptr dead_on_unwind noalias writable sret(%struct.my_int) align 8 %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca %struct.my_int, align 8
  %5 = alloca %struct.my_int, align 8
  %6 = tail call noundef zeroext i1 @_Z3badi(i32 noundef %2)
  br i1 %6, label %7, label %8

7:                                                ; preds = %3
  tail call void @_Z4zerov(ptr dead_on_unwind writable sret(%struct.my_int) align 8 %0)
  br label %34

8:                                                ; preds = %3
  %9 = load i32, ptr @m, align 4, !tbaa !5
  %10 = icmp eq i32 %9, %1
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  tail call void @_Z3onev(ptr dead_on_unwind writable sret(%struct.my_int) align 8 %0)
  br label %34

12:                                               ; preds = %8
  %13 = sext i32 %1 to i64
  %14 = sext i32 %2 to i64
  %15 = getelementptr inbounds [150 x [150 x i8]], ptr @used, i64 0, i64 %13, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !9, !range !11, !noundef !12
  %17 = trunc nuw i8 %16 to i1
  br i1 %17, label %18, label %20

18:                                               ; preds = %12
  %19 = getelementptr inbounds [150 x [150 x %struct.my_int]], ptr @ans, i64 0, i64 %13, i64 %14
  tail call void @_ZN6my_intC2ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %19)
  br label %34

20:                                               ; preds = %12
  store i8 1, ptr %15, align 1, !tbaa !9
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %20
  %23 = getelementptr inbounds [150 x [150 x %struct.my_int]], ptr @ans, i64 0, i64 %13, i64 %14
  %24 = add nsw i32 %1, 1
  br label %26

._crit_edge:                                      ; preds = %28, %20
  %25 = getelementptr inbounds [150 x [150 x %struct.my_int]], ptr @ans, i64 0, i64 %13, i64 %14
  call void @_ZN6my_intC2ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %25)
  br label %34

26:                                               ; preds = %.lr.ph, %28
  %.019 = phi i32 [ 0, %.lr.ph ], [ %29, %28 ]
  %27 = call noundef i32 @_Z5transii(i32 noundef %2, i32 noundef %.019)
  call void @_Z2dpii(ptr dead_on_unwind nonnull writable sret(%struct.my_int) align 8 %5, i32 noundef %24, i32 noundef %27)
  invoke void @_Z3addR6my_intS_(ptr dead_on_unwind nonnull writable sret(%struct.my_int) align 8 %4, ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull %5)
          to label %28 unwind label %32

28:                                               ; preds = %26
  call void @_ZN6my_intD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  call void @_ZN6my_intD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #3
  %29 = add nuw nsw i32 %.019, 1
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %26, label %._crit_edge, !llvm.loop !13

32:                                               ; preds = %26
  %33 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN6my_intD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #3
  resume { ptr, i32 } %33

34:                                               ; preds = %._crit_edge, %18, %11, %7
  ret void
}

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 = { 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 #2 = { inlinehint 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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