; LLVM IR from begeekmyfriend/bplustree :: lib (bplustree)

; 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.bplus_tree = type { ptr, [5 x i32], [1024 x i8], i32, i32, i64, i64, %struct.list_head }
%struct.list_head = type { ptr, ptr }
%struct.free_block = type { %struct.list_head, i64 }

@_block_size = external hidden global i32, align 4
@.str.4 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__.bplus_tree_deinit = external hidden unnamed_addr constant [44 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [50 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

declare i32 @open(ptr noundef, i32 noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @bplus_close(i32 noundef) #2

declare i32 @fsync(i32 noundef) #1

declare i32 @close(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @bplus_tree_deinit(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.bplus_tree, ptr %7, i32 0, i32 2
  %9 = getelementptr inbounds [1024 x i8], ptr %8, i64 0, i64 0
  %10 = call i32 (ptr, i32, ...) @open(ptr noundef %9, i32 noundef 66, i32 noundef 420)
  store i32 %10, ptr %3, align 4, !tbaa !9
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = icmp sge i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  br label %15

14:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.4, i32 noundef 1124, ptr noundef @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

15:                                               ; preds = %13
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.bplus_tree, ptr %17, i32 0, i32 5
  %19 = load i64, ptr %18, align 8, !tbaa !11
  %20 = call i64 @offset_store(i32 noundef %16, i64 noundef %19)
  %21 = icmp eq i64 %20, 16
  br i1 %21, label %22, label %23

22:                                               ; preds = %15
  br label %24

23:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.4, i32 noundef 1125, ptr noundef @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

24:                                               ; preds = %22
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = load i32, ptr @_block_size, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = call i64 @offset_store(i32 noundef %25, i64 noundef %27)
  %29 = icmp eq i64 %28, 16
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  br label %32

31:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.4, i32 noundef 1126, ptr noundef @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

32:                                               ; preds = %30
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.bplus_tree, ptr %34, i32 0, i32 6
  %36 = load i64, ptr %35, align 8, !tbaa !15
  %37 = call i64 @offset_store(i32 noundef %33, i64 noundef %36)
  %38 = icmp eq i64 %37, 16
  br i1 %38, label %39, label %40

39:                                               ; preds = %32
  br label %41

40:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.4, i32 noundef 1127, ptr noundef @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

41:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.bplus_tree, ptr %42, i32 0, i32 7
  %44 = getelementptr inbounds %struct.list_head, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  store ptr %45, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.list_head, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  store ptr %48, ptr %5, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %68, %41
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.bplus_tree, ptr %51, i32 0, i32 7
  %53 = icmp ne ptr %50, %52
  br i1 %53, label %54, label %73

54:                                               ; preds = %49
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  call void @list_del(ptr noundef %55)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 0
  store ptr %57, ptr %6, align 8, !tbaa !5
  %58 = load i32, ptr %3, align 4, !tbaa !9
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.free_block, ptr %59, i32 0, i32 1
  %61 = load i64, ptr %60, align 8, !tbaa !18
  %62 = call i64 @offset_store(i32 noundef %58, i64 noundef %61)
  %63 = icmp eq i64 %62, 16
  br i1 %63, label %64, label %65

64:                                               ; preds = %54
  br label %66

65:                                               ; preds = %54
  call void @__assert_fail(ptr noundef @.str.13, ptr noundef @.str.4, i32 noundef 1134, ptr noundef @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

66:                                               ; preds = %64
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %67) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %68

68:                                               ; preds = %66
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %69, ptr %4, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.list_head, ptr %70, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !17
  store ptr %72, ptr %5, align 8, !tbaa !5
  br label %49, !llvm.loop !20

73:                                               ; preds = %49
  %74 = load i32, ptr %3, align 4, !tbaa !9
  %75 = call i32 @fsync(i32 noundef %74)
  %76 = load i32, ptr %3, align 4, !tbaa !9
  %77 = call i32 @close(i32 noundef %76)
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.bplus_tree, ptr %78, i32 0, i32 3
  %80 = load i32, ptr %79, align 4, !tbaa !22
  call void @bplus_close(i32 noundef %80)
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.bplus_tree, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !23
  call void @free(ptr noundef %83) #6
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %84) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @offset_store(i32 noundef, i64 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @list_del(ptr noundef) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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 #4 = { inlinehint 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 = { 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 #6 = { nounwind }
attributes #7 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 1064}
!12 = !{!"bplus_tree", !6, i64 0, !7, i64 8, !7, i64 28, !10, i64 1052, !10, i64 1056, !13, i64 1064, !13, i64 1072, !14, i64 1080}
!13 = !{!"long", !7, i64 0}
!14 = !{!"list_head", !6, i64 0, !6, i64 8}
!15 = !{!12, !13, i64 1072}
!16 = !{!12, !6, i64 1088}
!17 = !{!14, !6, i64 8}
!18 = !{!19, !13, i64 16}
!19 = !{!"free_block", !14, i64 0, !13, i64 16}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !10, i64 1052}
!23 = !{!12, !6, 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"

@_block_size = external hidden local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__.bplus_tree_deinit = external hidden unnamed_addr constant [44 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @bplus_close(i32 noundef) local_unnamed_addr #1

declare i32 @fsync(i32 noundef) local_unnamed_addr #2

declare i32 @close(i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local void @bplus_tree_deinit(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 28
  %3 = tail call i32 (ptr, i32, ...) @open(ptr noundef nonnull %2, i32 noundef 66, i32 noundef 420) #6
  %4 = icmp sgt i32 %3, -1
  br i1 %4, label %6, label %5

5:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.4, i32 noundef 1124, ptr noundef nonnull @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 1064
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = tail call i64 @offset_store(i32 noundef %3, i64 noundef %8)
  %10 = icmp eq i64 %9, 16
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.4, i32 noundef 1125, ptr noundef nonnull @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

12:                                               ; preds = %6
  %13 = load i32, ptr @_block_size, align 4, !tbaa !13
  %14 = sext i32 %13 to i64
  %15 = tail call i64 @offset_store(i32 noundef %3, i64 noundef %14)
  %16 = icmp eq i64 %15, 16
  br i1 %16, label %18, label %17

17:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.4, i32 noundef 1126, ptr noundef nonnull @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 1072
  %20 = load i64, ptr %19, align 8, !tbaa !14
  %21 = tail call i64 @offset_store(i32 noundef %3, i64 noundef %20)
  %22 = icmp eq i64 %21, 16
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.4, i32 noundef 1127, ptr noundef nonnull @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

24:                                               ; preds = %18
  %25 = getelementptr inbounds i8, ptr %0, i64 1080
  %26 = getelementptr inbounds i8, ptr %0, i64 1088
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %.not26 = icmp eq ptr %27, %25
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %24, %33
  %.027 = phi ptr [ %.02228, %33 ], [ %27, %24 ]
  %.02228.in = getelementptr inbounds i8, ptr %.027, i64 8
  %.02228 = load ptr, ptr %.02228.in, align 8, !tbaa !16
  tail call void @list_del(ptr noundef nonnull %.027)
  %28 = getelementptr inbounds i8, ptr %.027, i64 16
  %29 = load i64, ptr %28, align 8, !tbaa !17
  %30 = tail call i64 @offset_store(i32 noundef %3, i64 noundef %29)
  %31 = icmp eq i64 %30, 16
  br i1 %31, label %33, label %32

32:                                               ; preds = %.lr.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.4, i32 noundef 1134, ptr noundef nonnull @__PRETTY_FUNCTION__.bplus_tree_deinit) #7
  unreachable

33:                                               ; preds = %.lr.ph
  tail call void @free(ptr noundef nonnull %.027) #6
  %.not = icmp eq ptr %.02228, %25
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %33, %24
  %34 = tail call i32 @fsync(i32 noundef %3) #6
  %35 = tail call i32 @close(i32 noundef %3) #6
  %36 = getelementptr inbounds i8, ptr %0, i64 1052
  %37 = load i32, ptr %36, align 4, !tbaa !21
  tail call void @bplus_close(i32 noundef %37)
  %38 = load ptr, ptr %0, align 8, !tbaa !22
  tail call void @free(ptr noundef %38) #6
  tail call void @free(ptr noundef %0) #6
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @offset_store(i32 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @list_del(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

attributes #0 = { nofree "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 = { 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 = { "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 "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 = { inlinehint 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #7 = { 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, !11, i64 1064}
!6 = !{!"bplus_tree", !7, i64 0, !8, i64 8, !8, i64 28, !10, i64 1052, !10, i64 1056, !11, i64 1064, !11, i64 1072, !12, i64 1080}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"list_head", !7, i64 0, !7, i64 8}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !11, i64 1072}
!15 = !{!6, !7, i64 1088}
!16 = !{!12, !7, i64 8}
!17 = !{!18, !11, i64 16}
!18 = !{!"free_block", !12, i64 0, !11, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!6, !10, i64 1052}
!22 = !{!6, !7, i64 0}


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