; LLVM IR from rahulyesantharao/b-epsilon-tree :: src/be_tree/be_tree.ll (ZN6BeNode8AddPivotEjj)

; 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.BeNode = type { %class.Serializable, ptr, i32, ptr, ptr, ptr, ptr, ptr }
%class.Serializable = type { ptr }
%struct.BePivots = type { i32, [15 x i32], [16 x i32] }

@.str.11 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [89 x i8], align 1
@__PRETTY_FUNCTION__._ZN6BeNode8AddPivotEjj = external hidden unnamed_addr constant [42 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [11 x i8], align 1

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6BeNode4OpenEv(ptr noundef nonnull align 8 dereferenceable(64)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6BeNode10IndexOfKeyEj(ptr noundef nonnull align 8 dereferenceable(64), i32 noundef) #1 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6BeNode8AddPivotEjj(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  call void @_ZN6BeNode4OpenEv(ptr noundef nonnull align 8 dereferenceable(64) %9)
  %10 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 4
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp ne i32 %12, 0
  %14 = xor i1 %13, true
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  br label %18

16:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.12, i32 noundef 430, ptr noundef @__PRETTY_FUNCTION__._ZN6BeNode8AddPivotEjj) #3
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp ugt i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %24

22:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.34, ptr noundef @.str.12, i32 noundef 431, ptr noundef @__PRETTY_FUNCTION__._ZN6BeNode8AddPivotEjj) #3
  unreachable

23:                                               ; No predecessors!
  br label %24

24:                                               ; preds = %23, %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = call noundef i32 @_ZN6BeNode10IndexOfKeyEj(ptr noundef nonnull align 8 dereferenceable(64) %9, i32 noundef %25)
  store i32 %26, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %27 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = getelementptr inbounds %struct.BePivots, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 4, !tbaa !15
  %31 = sub i32 %30, 1
  store i32 %31, ptr %8, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %67, %24
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = icmp sge i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %70

37:                                               ; preds = %32
  %38 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = getelementptr inbounds %struct.BePivots, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [16 x i32], ptr %40, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %47 = load ptr, ptr %46, align 8, !tbaa !14
  %48 = getelementptr inbounds %struct.BePivots, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = add nsw i32 %49, 2
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [16 x i32], ptr %48, i64 0, i64 %51
  store i32 %45, ptr %52, align 4, !tbaa !9
  %53 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %54 = load ptr, ptr %53, align 8, !tbaa !14
  %55 = getelementptr inbounds %struct.BePivots, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [15 x i32], ptr %55, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %60 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %61 = load ptr, ptr %60, align 8, !tbaa !14
  %62 = getelementptr inbounds %struct.BePivots, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [15 x i32], ptr %62, i64 0, i64 %65
  store i32 %59, ptr %66, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %37
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = add nsw i32 %68, -1
  store i32 %69, ptr %8, align 4, !tbaa !9
  br label %32, !llvm.loop !17

70:                                               ; preds = %36
  %71 = load i32, ptr %5, align 4, !tbaa !9
  %72 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %73 = load ptr, ptr %72, align 8, !tbaa !14
  %74 = getelementptr inbounds %struct.BePivots, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [15 x i32], ptr %74, i64 0, i64 %76
  store i32 %71, ptr %77, align 4, !tbaa !9
  %78 = load i32, ptr %6, align 4, !tbaa !9
  %79 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %80 = load ptr, ptr %79, align 8, !tbaa !14
  %81 = getelementptr inbounds %struct.BePivots, ptr %80, i32 0, i32 2
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [16 x i32], ptr %81, i64 0, i64 %84
  store i32 %78, ptr %85, align 4, !tbaa !9
  %86 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %87 = load ptr, ptr %86, align 8, !tbaa !14
  %88 = getelementptr inbounds %struct.BePivots, ptr %87, i32 0, i32 0
  %89 = load i32, ptr %88, align 4, !tbaa !15
  %90 = add i32 %89, 1
  %91 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %92 = load ptr, ptr %91, align 8, !tbaa !14
  %93 = getelementptr inbounds %struct.BePivots, ptr %92, i32 0, i32 0
  store i32 %90, ptr %93, align 4, !tbaa !15
  %94 = getelementptr inbounds %class.BeNode, ptr %9, i32 0, i32 6
  %95 = load ptr, ptr %94, align 8, !tbaa !14
  %96 = getelementptr inbounds %struct.BePivots, ptr %95, i32 0, i32 0
  %97 = load i32, ptr %96, align 4, !tbaa !15
  %98 = icmp eq i32 %97, 15
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i1 %98
}

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 = { noreturn nounwind "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 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTS6BeNode", !13, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"_ZTS12Serializable"}
!14 = !{!12, !6, i64 48}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTS8BePivots", !10, i64 0, !7, i64 4, !7, i64 64}
!17 = distinct !{!17, !18}
!18 = !{!"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"

@.str.11 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [89 x i8], align 1
@__PRETTY_FUNCTION__._ZN6BeNode8AddPivotEjj = external hidden unnamed_addr constant [42 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6BeNode4OpenEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6BeNode10IndexOfKeyEj(ptr noundef nonnull align 8 dereferenceable(64), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6BeNode8AddPivotEjj(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  tail call void @_ZN6BeNode4OpenEv(ptr noundef nonnull align 8 dereferenceable(64) %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = load i32, ptr %5, align 4, !tbaa !12
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %8, label %7

7:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.12, i32 noundef 430, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6BeNode8AddPivotEjj) #2
  unreachable

8:                                                ; preds = %3
  %.not15 = icmp eq i32 %2, 0
  br i1 %.not15, label %9, label %10

9:                                                ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.12, i32 noundef 431, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6BeNode8AddPivotEjj) #2
  unreachable

10:                                               ; preds = %8
  %11 = tail call noundef i32 @_ZN6BeNode10IndexOfKeyEj(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1)
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %.017 = add i32 %14, -1
  %.not1618 = icmp slt i32 %.017, %11
  br i1 %.not1618, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %15 = getelementptr inbounds i8, ptr %13, i64 64
  %16 = getelementptr inbounds i8, ptr %13, i64 4
  br label %27

._crit_edge:                                      ; preds = %27, %10
  %17 = getelementptr inbounds i8, ptr %13, i64 4
  %18 = sext i32 %11 to i64
  %19 = getelementptr inbounds [15 x i32], ptr %17, i64 0, i64 %18
  store i32 %1, ptr %19, align 4, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %13, i64 64
  %21 = add nsw i32 %11, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [16 x i32], ptr %20, i64 0, i64 %22
  store i32 %2, ptr %23, align 4, !tbaa !12
  %24 = load i32, ptr %13, align 4, !tbaa !14
  %25 = add i32 %24, 1
  store i32 %25, ptr %13, align 4, !tbaa !14
  %26 = icmp eq i32 %25, 15
  ret i1 %26

27:                                               ; preds = %.lr.ph, %27
  %.020 = phi i32 [ %.017, %.lr.ph ], [ %.0, %27 ]
  %.0.in19 = phi i32 [ %14, %.lr.ph ], [ %.020, %27 ]
  %28 = sext i32 %.0.in19 to i64
  %29 = getelementptr inbounds [16 x i32], ptr %15, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !12
  %31 = add i32 %.0.in19, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [16 x i32], ptr %15, i64 0, i64 %32
  store i32 %30, ptr %33, align 4, !tbaa !12
  %34 = sext i32 %.020 to i64
  %35 = getelementptr inbounds [15 x i32], ptr %16, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !12
  %37 = getelementptr inbounds [15 x i32], ptr %16, i64 0, i64 %28
  store i32 %36, ptr %37, align 4, !tbaa !12
  %.0 = add i32 %.020, -1
  %.not16 = icmp slt i32 %.0, %11
  br i1 %.not16, label %._crit_edge, label %27, !llvm.loop !16
}

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 = { noreturn nounwind "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 = { noreturn 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, !8, i64 32}
!6 = !{!"_ZTS6BeNode", !7, i64 0, !8, i64 8, !11, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56}
!7 = !{!"_ZTS12Serializable"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!6, !8, i64 48}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTS8BePivots", !11, i64 0, !9, i64 4, !9, i64 64}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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