; LLVM IR from fmela/libdict :: src (hb_tree)

; 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.hb_tree = type { ptr, i64, ptr, i64 }
%struct.hb_node = type { ptr, ptr, %union.anon, ptr, ptr }
%union.anon = type { i64 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@dict_free_func = external global ptr, align 8
@__func__.hb_tree_clear = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @abort() #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @hb_tree_clear(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.hb_tree, ptr %8, i32 0, i32 1
  %10 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %10, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.hb_tree, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  store ptr %13, ptr %6, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %80, %40, %2
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %83

17:                                               ; preds = %14
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.hb_node, ptr %18, i32 0, i32 3
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = icmp ne ptr %20, null
  br i1 %21, label %27, label %22

22:                                               ; preds = %17
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.hb_node, ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %42

27:                                               ; preds = %22, %17
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.hb_node, ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %36

32:                                               ; preds = %27
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.hb_node, ptr %33, i32 0, i32 3
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  br label %40

36:                                               ; preds = %27
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.hb_node, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  br label %40

40:                                               ; preds = %36, %32
  %41 = phi ptr [ %35, %32 ], [ %39, %36 ]
  store ptr %41, ptr %6, align 8, !tbaa !5
  br label %14, !llvm.loop !17

42:                                               ; preds = %22
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %53

45:                                               ; preds = %42
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.hb_node, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !19
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.hb_node, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  call void %46(ptr noundef %49, ptr noundef %52)
  br label %53

53:                                               ; preds = %45, %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.hb_node, ptr %54, i32 0, i32 2
  %56 = load i64, ptr %55, align 8, !tbaa !21
  %57 = and i64 %56, -4
  %58 = inttoptr i64 %57 to ptr
  store ptr %58, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr @dict_free_func, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  call void %59(ptr noundef %60)
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %77

63:                                               ; preds = %53
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.hb_node, ptr %64, i32 0, i32 3
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = icmp eq ptr %66, %67
  br i1 %68, label %69, label %72

69:                                               ; preds = %63
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.hb_node, ptr %70, i32 0, i32 3
  br label %75

72:                                               ; preds = %63
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.hb_node, ptr %73, i32 0, i32 4
  br label %75

75:                                               ; preds = %72, %69
  %76 = phi ptr [ %71, %69 ], [ %74, %72 ]
  br label %80

77:                                               ; preds = %53
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.hb_tree, ptr %78, i32 0, i32 0
  br label %80

80:                                               ; preds = %77, %75
  %81 = phi ptr [ %76, %75 ], [ %79, %77 ]
  store ptr null, ptr %81, align 8, !tbaa !5
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %82, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %14, !llvm.loop !17

83:                                               ; preds = %14
  br label %84

84:                                               ; preds = %83
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.hb_tree, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !13
  %88 = icmp eq ptr %87, null
  %89 = zext i1 %88 to i32
  %90 = sext i32 %89 to i64
  %91 = call i64 @llvm.expect.i64(i64 %90, i64 1)
  %92 = icmp ne i64 %91, 0
  br i1 %92, label %96, label %93

93:                                               ; preds = %84
  %94 = load ptr, ptr @stderr, align 8, !tbaa !5
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 160, ptr noundef @__func__.hb_tree_clear, ptr noundef @.str.3) #5
  call void @abort() #6
  unreachable

96:                                               ; preds = %84
  br label %97

97:                                               ; preds = %96
  br label %98

98:                                               ; preds = %97
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.hb_tree, ptr %99, i32 0, i32 1
  store i64 0, ptr %100, align 8, !tbaa !9
  %101 = load i64, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i64 %101
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { 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 "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 }
attributes #6 = { 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, !11, i64 8}
!10 = !{!"hb_tree", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 0}
!14 = !{!15, !6, i64 24}
!15 = !{!"hb_node", !6, i64 0, !6, i64 8, !7, i64 16, !6, i64 24, !6, i64 32}
!16 = !{!15, !6, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!15, !6, i64 0}
!20 = !{!15, !6, i64 8}
!21 = !{!7, !7, 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@dict_free_func = external local_unnamed_addr global ptr, align 8
@__func__.hb_tree_clear = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @hb_tree_clear(ptr nocapture noundef %0, ptr noundef readonly %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %0, align 8, !tbaa !11
  %.not31 = icmp eq ptr %5, null
  br i1 %.not31, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %.not28 = icmp eq ptr %1, null
  br i1 %.not28, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.backedge.us
  %.032.us = phi ptr [ %.0.be.us, %.backedge.us ], [ %5, %.lr.ph ]
  %6 = getelementptr inbounds i8, ptr %.032.us, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %.not26.us = icmp eq ptr %7, null
  br i1 %.not26.us, label %8, label %.backedge.us

8:                                                ; preds = %.lr.ph.split.us
  %9 = getelementptr inbounds i8, ptr %.032.us, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %.not27.us = icmp eq ptr %10, null
  br i1 %.not27.us, label %11, label %.backedge.us

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %.032.us, i64 16
  %13 = load i64, ptr %12, align 8, !tbaa !15
  %14 = and i64 %13, -4
  %15 = inttoptr i64 %14 to ptr
  %16 = load ptr, ptr @dict_free_func, align 8, !tbaa !16
  tail call void %16(ptr noundef nonnull %.032.us) #3
  %.not29.us = icmp eq i64 %14, 0
  br i1 %.not29.us, label %23, label %17

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %15, i64 24
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = icmp eq ptr %19, %.032.us
  %21 = getelementptr inbounds i8, ptr %15, i64 32
  %22 = select i1 %20, ptr %18, ptr %21
  br label %23

23:                                               ; preds = %17, %11
  %24 = phi ptr [ %22, %17 ], [ %0, %11 ]
  store ptr null, ptr %24, align 8, !tbaa !16
  br label %.backedge.us

.backedge.us:                                     ; preds = %8, %.lr.ph.split.us, %23
  %.0.be.us = phi ptr [ %15, %23 ], [ %7, %.lr.ph.split.us ], [ %10, %8 ]
  %.not.us = icmp eq ptr %.0.be.us, null
  br i1 %.not.us, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !17

.lr.ph.split:                                     ; preds = %.lr.ph, %.backedge
  %.032 = phi ptr [ %.0.be, %.backedge ], [ %5, %.lr.ph ]
  %25 = getelementptr inbounds i8, ptr %.032, i64 24
  %26 = load ptr, ptr %25, align 8, !tbaa !12
  %.not26 = icmp eq ptr %26, null
  br i1 %.not26, label %27, label %.backedge

27:                                               ; preds = %.lr.ph.split
  %28 = getelementptr inbounds i8, ptr %.032, i64 32
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %.not27 = icmp eq ptr %29, null
  br i1 %.not27, label %30, label %.backedge

.backedge:                                        ; preds = %27, %.lr.ph.split, %45
  %.0.be = phi ptr [ %37, %45 ], [ %26, %.lr.ph.split ], [ %29, %27 ]
  %.not = icmp eq ptr %.0.be, null
  br i1 %.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !17

30:                                               ; preds = %27
  %31 = load ptr, ptr %.032, align 8, !tbaa !19
  %32 = getelementptr inbounds i8, ptr %.032, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !20
  tail call void %1(ptr noundef %31, ptr noundef %33) #3
  %34 = getelementptr inbounds i8, ptr %.032, i64 16
  %35 = load i64, ptr %34, align 8, !tbaa !15
  %36 = and i64 %35, -4
  %37 = inttoptr i64 %36 to ptr
  %38 = load ptr, ptr @dict_free_func, align 8, !tbaa !16
  tail call void %38(ptr noundef nonnull %.032) #3
  %.not29 = icmp eq i64 %36, 0
  br i1 %.not29, label %45, label %39

39:                                               ; preds = %30
  %40 = getelementptr inbounds i8, ptr %37, i64 24
  %41 = load ptr, ptr %40, align 8, !tbaa !12
  %42 = icmp eq ptr %41, %.032
  %43 = getelementptr inbounds i8, ptr %37, i64 32
  %44 = select i1 %42, ptr %40, ptr %43
  br label %45

45:                                               ; preds = %30, %39
  %46 = phi ptr [ %44, %39 ], [ %0, %30 ]
  store ptr null, ptr %46, align 8, !tbaa !16
  br label %.backedge

._crit_edge:                                      ; preds = %.backedge, %.backedge.us
  %.pr = load ptr, ptr %0, align 8, !tbaa !11
  %47 = icmp eq ptr %.pr, null
  br i1 %47, label %._crit_edge.thread, label %48, !prof !21

48:                                               ; preds = %._crit_edge
  %49 = load ptr, ptr @stderr, align 8, !tbaa !16
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 160, ptr noundef nonnull @__func__.hb_tree_clear, ptr noundef nonnull @.str.3) #4
  tail call void @abort() #5
  unreachable

._crit_edge.thread:                               ; preds = %2, %._crit_edge
  store i64 0, ptr %3, align 8, !tbaa !5
  ret i64 %4
}

attributes #0 = { nofree 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 #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 = { 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 }
attributes #4 = { cold nounwind }
attributes #5 = { 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, !10, i64 8}
!6 = !{!"hb_tree", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 24}
!13 = !{!"hb_node", !7, i64 0, !7, i64 8, !8, i64 16, !7, i64 24, !7, i64 32}
!14 = !{!13, !7, i64 32}
!15 = !{!8, !8, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!13, !7, i64 0}
!20 = !{!13, !7, i64 8}
!21 = !{!"branch_weights", !"expected", i32 2145766520, i32 1717128}


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