; LLVM IR from AnneLivia/Competitive-Programming :: Online Judges/HackerEarth/Help Ashu.ll (Z6updateiiiix)

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

@v = external dso_local global %"class.std::vector", align 8
@st = external dso_local global %"class.std::vector.0", align 8

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6middleii(i32 noundef, i32 noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6golefti(i32 noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7gorighti(i32 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateiiiix(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i64 noundef %4) #5 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca %struct.Data, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.Data, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i64 %4, ptr %10, align 8, !tbaa !9
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = icmp eq i32 %14, %15
  br i1 %16, label %17, label %37

17:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 8, i1 false)
  %18 = load i64, ptr %10, align 8, !tbaa !9
  %19 = and i64 %18, 1
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %25

21:                                               ; preds = %17
  %22 = getelementptr inbounds %struct.Data, ptr %11, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %22, align 4, !tbaa !11
  br label %29

25:                                               ; preds = %17
  %26 = getelementptr inbounds %struct.Data, ptr %11, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %26, align 4, !tbaa !13
  br label %29

29:                                               ; preds = %25, %21
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = load i32, ptr %9, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @v, i64 noundef %32) #6
  store i64 %30, ptr %33, align 8, !tbaa !9
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %35) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %36, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %91

37:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = call noundef i32 @_Z6middleii(i32 noundef %38, i32 noundef %39)
  store i32 %40, ptr %12, align 4, !tbaa !5
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = load i32, ptr %12, align 4, !tbaa !5
  %43 = icmp sle i32 %41, %42
  br i1 %43, label %44, label %51

44:                                               ; preds = %37
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = call noundef i32 @_Z6golefti(i32 noundef %45)
  %47 = load i32, ptr %7, align 4, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !5
  %49 = load i32, ptr %9, align 4, !tbaa !5
  %50 = load i64, ptr %10, align 8, !tbaa !9
  call void @_Z6updateiiiix(i32 noundef %46, i32 noundef %47, i32 noundef %48, i32 noundef %49, i64 noundef %50)
  br label %59

51:                                               ; preds = %37
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = call noundef i32 @_Z7gorighti(i32 noundef %52)
  %54 = load i32, ptr %12, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  %56 = load i32, ptr %8, align 4, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = load i64, ptr %10, align 8, !tbaa !9
  call void @_Z6updateiiiix(i32 noundef %53, i32 noundef %55, i32 noundef %56, i32 noundef %57, i64 noundef %58)
  br label %59

59:                                               ; preds = %51, %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = call noundef i32 @_Z6golefti(i32 noundef %60)
  %62 = sext i32 %61 to i64
  %63 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %62) #6
  %64 = getelementptr inbounds %struct.Data, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = call noundef i32 @_Z7gorighti(i32 noundef %66)
  %68 = sext i32 %67 to i64
  %69 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %68) #6
  %70 = getelementptr inbounds %struct.Data, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = add nsw i32 %65, %71
  %73 = getelementptr inbounds %struct.Data, ptr %13, i32 0, i32 0
  store i32 %72, ptr %73, align 4, !tbaa !11
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = call noundef i32 @_Z6golefti(i32 noundef %74)
  %76 = sext i32 %75 to i64
  %77 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %76) #6
  %78 = getelementptr inbounds %struct.Data, ptr %77, i32 0, i32 1
  %79 = load i32, ptr %78, align 4, !tbaa !13
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = call noundef i32 @_Z7gorighti(i32 noundef %80)
  %82 = sext i32 %81 to i64
  %83 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %82) #6
  %84 = getelementptr inbounds %struct.Data, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !13
  %86 = add nsw i32 %79, %85
  %87 = getelementptr inbounds %struct.Data, ptr %13, i32 0, i32 1
  store i32 %86, ptr %87, align 4, !tbaa !13
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %89) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %90, ptr align 4 %13, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %91

91:                                               ; preds = %59, %29
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #6 = { 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 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Data", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, i64 4}
!14 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}


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

@v = external dso_local global %"class.std::vector", align 8
@st = external dso_local global %"class.std::vector.0", align 8

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6middleii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6golefti(i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7gorighti(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6updateiiiix(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  %6 = icmp eq i32 %1, %2
  br i1 %6, label %7, label %11

7:                                                ; preds = %5
  %8 = trunc i64 %4 to i32
  %. = and i32 %8, 1
  %.31 = xor i32 %., 1
  %9 = sext i32 %3 to i64
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @v, i64 noundef %9) #2
  store i64 %4, ptr %10, align 8, !tbaa !5
  br label %39

11:                                               ; preds = %5
  %12 = tail call noundef i32 @_Z6middleii(i32 noundef %1, i32 noundef %2)
  %.not = icmp slt i32 %12, %3
  br i1 %.not, label %15, label %13

13:                                               ; preds = %11
  %14 = tail call noundef i32 @_Z6golefti(i32 noundef %0)
  tail call void @_Z6updateiiiix(i32 noundef %14, i32 noundef %1, i32 noundef %12, i32 noundef %3, i64 noundef %4)
  br label %18

15:                                               ; preds = %11
  %16 = tail call noundef i32 @_Z7gorighti(i32 noundef %0)
  %17 = add nsw i32 %12, 1
  tail call void @_Z6updateiiiix(i32 noundef %16, i32 noundef %17, i32 noundef %2, i32 noundef %3, i64 noundef %4)
  br label %18

18:                                               ; preds = %15, %13
  %19 = tail call noundef i32 @_Z6golefti(i32 noundef %0)
  %20 = sext i32 %19 to i64
  %21 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %20) #2
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = tail call noundef i32 @_Z7gorighti(i32 noundef %0)
  %24 = sext i32 %23 to i64
  %25 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %24) #2
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = add nsw i32 %26, %22
  %28 = tail call noundef i32 @_Z6golefti(i32 noundef %0)
  %29 = sext i32 %28 to i64
  %30 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %29) #2
  %31 = getelementptr inbounds i8, ptr %30, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !12
  %33 = tail call noundef i32 @_Z7gorighti(i32 noundef %0)
  %34 = sext i32 %33 to i64
  %35 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %34) #2
  %36 = getelementptr inbounds i8, ptr %35, i64 4
  %37 = load i32, ptr %36, align 4, !tbaa !12
  %38 = add nsw i32 %37, %32
  br label %39

39:                                               ; preds = %18, %7
  %.sink34 = phi i32 [ %27, %18 ], [ %.31, %7 ]
  %.sink = phi i32 [ %38, %18 ], [ %., %7 ]
  %40 = sext i32 %0 to i64
  %41 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI4DataSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @st, i64 noundef %40) #2
  store i32 %.sink34, ptr %41, align 4, !tbaa !13
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %41, i64 4
  store i32 %.sink, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !13
  ret void
}

attributes #0 = { 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 #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 = { 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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS4Data", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass