; LLVM IR from Softmotions/iowow :: src/utils (iwhmap)

; 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.iwhmap = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8 }
%struct.bucket_t = type { ptr, i32, i32 }
%struct.entry = type { ptr, ptr, ptr, i32 }
%struct.lru_node = type { ptr, ptr, ptr }

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

; 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: alwaysinline nounwind uwtable
declare hidden i32 @_n_buckets(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @iwhmap_destroy(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %1
  br label %99

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.iwhmap, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %16, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.iwhmap, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = call i32 @_n_buckets(ptr noundef %20)
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds %struct.bucket_t, ptr %19, i64 %22
  store ptr %23, ptr %4, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %77, %13
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = icmp ult ptr %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %80

29:                                               ; preds = %24
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.bucket_t, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %76

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.bucket_t, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  store ptr %37, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.bucket_t, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !13
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.bucket_t, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 8, !tbaa !15
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds %struct.entry, ptr %40, i64 %44
  store ptr %45, ptr %7, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %69, %34
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = icmp ult ptr %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %72

51:                                               ; preds = %46
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.iwhmap, ptr %52, i32 0, i32 5
  %54 = load ptr, ptr %53, align 8, !tbaa !16
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.iwhmap, ptr %55, i32 0, i32 10
  %57 = load i8, ptr %56, align 8, !tbaa !17, !range !18, !noundef !19
  %58 = trunc i8 %57 to i1
  br i1 %58, label %59, label %60

59:                                               ; preds = %51
  br label %64

60:                                               ; preds = %51
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.entry, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  br label %64

64:                                               ; preds = %60, %59
  %65 = phi ptr [ null, %59 ], [ %63, %60 ]
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.entry, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !22
  call void %54(ptr noundef %65, ptr noundef %68)
  br label %69

69:                                               ; preds = %64
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.entry, ptr %70, i32 1
  store ptr %71, ptr %6, align 8, !tbaa !5
  br label %46, !llvm.loop !23

72:                                               ; preds = %50
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.bucket_t, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !13
  call void @free(ptr noundef %75) #4
  br label %76

76:                                               ; preds = %72, %29
  br label %77

77:                                               ; preds = %76
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.bucket_t, ptr %78, i32 1
  store ptr %79, ptr %3, align 8, !tbaa !5
  br label %24, !llvm.loop !25

80:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.iwhmap, ptr %81, i32 0, i32 6
  %83 = load ptr, ptr %82, align 8, !tbaa !26
  store ptr %83, ptr %8, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %88, %80
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = icmp ne ptr %85, null
  br i1 %86, label %88, label %87

87:                                               ; preds = %84
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %94

88:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.lru_node, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !27
  store ptr %91, ptr %9, align 8, !tbaa !5
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %92) #4
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %93, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %84, !llvm.loop !29

94:                                               ; preds = %87
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.iwhmap, ptr %95, i32 0, i32 2
  %97 = load ptr, ptr %96, align 8, !tbaa !9
  call void @free(ptr noundef %97) #4
  %98 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %98) #4
  br label %99

99:                                               ; preds = %94, %12
  ret void
}

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"iwhmap", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !12, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !11, i64 8, !11, i64 12}
!15 = !{!14, !11, i64 8}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !12, i64 72}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!21, !6, i64 0}
!21 = !{!"entry", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!22 = !{!21, !6, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = !{!10, !6, i64 40}
!27 = !{!28, !6, i64 0}
!28 = !{!"lru_node", !6, i64 0, !6, i64 8, !6, i64 16}
!29 = distinct !{!29, !24}


; 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"

%struct.bucket_t = type { ptr, i32, i32 }
%struct.entry = type { ptr, ptr, ptr, i32 }

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @_n_buckets(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @iwhmap_destroy(ptr noundef %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %36, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call i32 @_n_buckets(ptr noundef nonnull %0)
  %6 = zext i32 %5 to i64
  %7 = getelementptr inbounds %struct.bucket_t, ptr %4, i64 %6
  %.not42 = icmp eq i32 %5, 0
  br i1 %.not42, label %._crit_edge36, label %.lr.ph35

.lr.ph35:                                         ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = getelementptr inbounds i8, ptr %0, i64 72
  br label %12

._crit_edge36:                                    ; preds = %31, %2
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %.not3037 = icmp eq ptr %11, null
  br i1 %.not3037, label %._crit_edge41, label %.lr.ph40

12:                                               ; preds = %.lr.ph35, %31
  %.033 = phi ptr [ %4, %.lr.ph35 ], [ %32, %31 ]
  %13 = load ptr, ptr %.033, align 8, !tbaa !13
  %.not31 = icmp eq ptr %13, null
  br i1 %.not31, label %31, label %14

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %.033, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds %struct.entry, ptr %13, i64 %17
  %.not43 = icmp eq i32 %16, 0
  br i1 %.not43, label %._crit_edge, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %25
  %.pre = load ptr, ptr %.033, align 8, !tbaa !13
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %14
  %19 = phi ptr [ %.pre, %._crit_edge.loopexit ], [ %13, %14 ]
  tail call void @free(ptr noundef %19) #3
  br label %31

.lr.ph:                                           ; preds = %14, %25
  %.02732 = phi ptr [ %29, %25 ], [ %13, %14 ]
  %20 = load ptr, ptr %8, align 8, !tbaa !16
  %21 = load i8, ptr %9, align 8, !tbaa !17, !range !18, !noundef !19
  %22 = trunc nuw i8 %21 to i1
  br i1 %22, label %25, label %23

23:                                               ; preds = %.lr.ph
  %24 = load ptr, ptr %.02732, align 8, !tbaa !20
  br label %25

25:                                               ; preds = %.lr.ph, %23
  %26 = phi ptr [ %24, %23 ], [ null, %.lr.ph ]
  %27 = getelementptr inbounds i8, ptr %.02732, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !22
  tail call void %20(ptr noundef %26, ptr noundef %28) #3
  %29 = getelementptr inbounds i8, ptr %.02732, i64 32
  %30 = icmp ult ptr %29, %18
  br i1 %30, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !23

31:                                               ; preds = %12, %._crit_edge
  %32 = getelementptr inbounds i8, ptr %.033, i64 16
  %33 = icmp ult ptr %32, %7
  br i1 %33, label %12, label %._crit_edge36, !llvm.loop !25

._crit_edge41:                                    ; preds = %.lr.ph40, %._crit_edge36
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void @free(ptr noundef %34) #3
  tail call void @free(ptr noundef %0) #3
  br label %36

.lr.ph40:                                         ; preds = %._crit_edge36, %.lr.ph40
  %.02638 = phi ptr [ %35, %.lr.ph40 ], [ %11, %._crit_edge36 ]
  %35 = load ptr, ptr %.02638, align 8, !tbaa !26
  tail call void @free(ptr noundef nonnull %.02638) #3
  %.not30 = icmp eq ptr %35, null
  br i1 %.not30, label %._crit_edge41, label %.lr.ph40, !llvm.loop !28

36:                                               ; preds = %1, %._crit_edge41
  ret void
}

attributes #0 = { 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 #1 = { alwaysinline 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 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, !10, i64 8}
!6 = !{!"iwhmap", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !11, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 40}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !7, i64 8, !7, i64 12}
!15 = !{!14, !7, i64 8}
!16 = !{!6, !10, i64 32}
!17 = !{!6, !11, i64 72}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!21, !10, i64 0}
!21 = !{!"entry", !10, i64 0, !10, i64 8, !10, i64 16, !7, i64 24}
!22 = !{!21, !10, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = !{!27, !10, i64 0}
!27 = !{!"lru_node", !10, i64 0, !10, i64 8, !10, i64 16}
!28 = distinct !{!28, !24}


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