; LLVM IR from ADJA/algos :: DataStructures/SegmentTree(Assign-Sum).ll (Z6assigniiiiii)

; 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<node, std::allocator<node>>::_Vector_impl" }
%"struct.std::_Vector_base<node, std::allocator<node>>::_Vector_impl" = type { %"struct.std::_Vector_base<node, std::allocator<node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<node, std::allocator<node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.node = type { i64, i32, i32 }

@tree = external dso_local global %"class.std::vector", align 8

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

; 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 nounwind uwtable
declare dso_local void @_Z4pushi(i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6assigniiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !5
  %15 = load i32, ptr %10, align 4, !tbaa !5
  %16 = load i32, ptr %11, align 4, !tbaa !5
  %17 = icmp sgt i32 %15, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %6
  br label %100

19:                                               ; preds = %6
  %20 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z4pushi(i32 noundef %20)
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = load i32, ptr %10, align 4, !tbaa !5
  %23 = icmp eq i32 %21, %22
  br i1 %23, label %24, label %48

24:                                               ; preds = %19
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = load i32, ptr %11, align 4, !tbaa !5
  %27 = icmp eq i32 %25, %26
  br i1 %27, label %28, label %48

28:                                               ; preds = %24
  %29 = load i32, ptr %12, align 4, !tbaa !5
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %31) #4
  %33 = getelementptr inbounds %struct.node, ptr %32, i32 0, i32 1
  store i32 %29, ptr %33, align 8, !tbaa !9
  %34 = load i32, ptr %12, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = mul nsw i64 1, %35
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %38) #4
  %40 = getelementptr inbounds %struct.node, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 4, !tbaa !12
  %42 = sext i32 %41 to i64
  %43 = mul nsw i64 %36, %42
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %45) #4
  %47 = getelementptr inbounds %struct.node, ptr %46, i32 0, i32 0
  store i64 %43, ptr %47, align 8, !tbaa !13
  br label %98

48:                                               ; preds = %24, %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = sub nsw i32 %50, %51
  %53 = sdiv i32 %52, 2
  %54 = add nsw i32 %49, %53
  store i32 %54, ptr %13, align 4, !tbaa !5
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = mul nsw i32 2, %55
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = load i32, ptr %13, align 4, !tbaa !5
  %59 = load i32, ptr %10, align 4, !tbaa !5
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z6assigniiiiii(i32 noundef %56, i32 noundef %57, i32 noundef %58, i32 noundef %59, i32 noundef %61, i32 noundef %62)
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = mul nsw i32 2, %63
  %65 = add nsw i32 %64, 1
  %66 = load i32, ptr %13, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  %68 = load i32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %69 = load i32, ptr %13, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %14, align 4, !tbaa !5
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z6assigniiiiii(i32 noundef %65, i32 noundef %67, i32 noundef %68, i32 noundef %72, i32 noundef %73, i32 noundef %74)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = mul nsw i32 2, %75
  call void @_Z4pushi(i32 noundef %76)
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = mul nsw i32 2, %77
  %79 = add nsw i32 %78, 1
  call void @_Z4pushi(i32 noundef %79)
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = mul nsw i32 2, %80
  %82 = sext i32 %81 to i64
  %83 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %82) #4
  %84 = getelementptr inbounds %struct.node, ptr %83, i32 0, i32 0
  %85 = load i64, ptr %84, align 8, !tbaa !13
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = mul nsw i32 2, %86
  %88 = add nsw i32 %87, 1
  %89 = sext i32 %88 to i64
  %90 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %89) #4
  %91 = getelementptr inbounds %struct.node, ptr %90, i32 0, i32 0
  %92 = load i64, ptr %91, align 8, !tbaa !13
  %93 = add nsw i64 %85, %92
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %95) #4
  %97 = getelementptr inbounds %struct.node, ptr %96, i32 0, i32 0
  store i64 %93, ptr %97, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %98

98:                                               ; preds = %48, %28
  %99 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z4pushi(i32 noundef %99)
  br label %100

100:                                              ; preds = %98, %18
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #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, !6, i64 8}
!10 = !{!"_ZTS4node", !11, i64 0, !6, i64 8, !6, i64 12}
!11 = !{!"long long", !7, i64 0}
!12 = !{!10, !6, i64 12}
!13 = !{!10, !11, i64 0}


; 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<node, std::allocator<node>>::_Vector_impl" }
%"struct.std::_Vector_base<node, std::allocator<node>>::_Vector_impl" = type { %"struct.std::_Vector_base<node, std::allocator<node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<node, std::allocator<node>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@tree = external dso_local global %"class.std::vector", align 8

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

; 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 nounwind uwtable
declare dso_local void @_Z4pushi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6assigniiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %3, ptr %7, align 4, !tbaa !5
  store i32 %4, ptr %8, align 4, !tbaa !5
  %11 = icmp sgt i32 %3, %4
  br i1 %11, label %49, label %12

12:                                               ; preds = %6
  tail call void @_Z4pushi(i32 noundef %0)
  %13 = icmp eq i32 %3, %1
  %14 = icmp eq i32 %4, %2
  %or.cond = and i1 %13, %14
  br i1 %or.cond, label %15, label %26

15:                                               ; preds = %12
  %16 = sext i32 %0 to i64
  %17 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %16) #3
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  store i32 %5, ptr %18, align 8, !tbaa !9
  %19 = sext i32 %5 to i64
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %16) #3
  %21 = getelementptr inbounds i8, ptr %20, i64 12
  %22 = load i32, ptr %21, align 4, !tbaa !12
  %23 = sext i32 %22 to i64
  %24 = mul nsw i64 %23, %19
  %25 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %16) #3
  store i64 %24, ptr %25, align 8, !tbaa !13
  br label %48

26:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  %27 = sub nsw i32 %2, %1
  %28 = sdiv i32 %27, 2
  %29 = add nsw i32 %28, %1
  store i32 %29, ptr %9, align 4, !tbaa !5
  %30 = shl nsw i32 %0, 1
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %32 = load i32, ptr %31, align 4, !tbaa !5
  call void @_Z6assigniiiiii(i32 noundef %30, i32 noundef %1, i32 noundef %29, i32 noundef %3, i32 noundef %32, i32 noundef %5)
  %33 = or disjoint i32 %30, 1
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  store i32 %35, ptr %10, align 4, !tbaa !5
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z6assigniiiiii(i32 noundef %33, i32 noundef %35, i32 noundef %2, i32 noundef %37, i32 noundef %38, i32 noundef %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  call void @_Z4pushi(i32 noundef %30)
  call void @_Z4pushi(i32 noundef %33)
  %39 = sext i32 %30 to i64
  %40 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %39) #3
  %41 = load i64, ptr %40, align 8, !tbaa !13
  %42 = sext i32 %33 to i64
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %42) #3
  %44 = load i64, ptr %43, align 8, !tbaa !13
  %45 = add nsw i64 %44, %41
  %46 = sext i32 %0 to i64
  %47 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorI4nodeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @tree, i64 noundef %46) #3
  store i64 %45, ptr %47, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  br label %48

48:                                               ; preds = %26, %15
  call void @_Z4pushi(i32 noundef %0)
  br label %49

49:                                               ; preds = %6, %48
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 8}
!10 = !{!"_ZTS4node", !11, i64 0, !6, i64 8, !6, i64 12}
!11 = !{!"long long", !7, i64 0}
!12 = !{!10, !6, i64 12}
!13 = !{!10, !11, i64 0}


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