; LLVM IR from lionsoul2014/friso :: src (friso_hash)

; 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.friso_hash_cdt = type { i32, i32, float, i32, ptr }
%struct.hash_entry = type { ptr, ptr, ptr }

; 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: nounwind uwtable
define dso_local void @free_hash_table(ptr noundef %0, ptr noundef %1) #1 {
  %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
  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 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %38, %2
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.friso_hash_cdt, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = icmp ult i32 %9, %12
  br i1 %13, label %14, label %41

14:                                               ; preds = %8
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.friso_hash_cdt, ptr %15, i32 0, i32 4
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds ptr, ptr %17, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  store ptr %21, ptr %6, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %34, %14
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %37

25:                                               ; preds = %22
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.hash_entry, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  store ptr %28, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %34

31:                                               ; preds = %25
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  call void %32(ptr noundef %33)
  br label %34

34:                                               ; preds = %31, %25
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %35) #3
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %36, ptr %6, align 8, !tbaa !5
  br label %22, !llvm.loop !17

37:                                               ; preds = %22
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = add i32 %39, 1
  store i32 %40, ptr %5, align 4, !tbaa !9
  br label %8, !llvm.loop !19

41:                                               ; preds = %8
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.friso_hash_cdt, ptr %42, i32 0, i32 4
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  call void @free(ptr noundef %44) #3
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %45) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !13, i64 8, !10, i64 12, !6, i64 16}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!16, !6, i64 16}
!16 = !{!"hash_entry", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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

; Function Attrs: nounwind uwtable
define dso_local void @free_hash_table(ptr nocapture noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %.not22 = icmp eq i32 %3, 0
  br i1 %.not22, label %._crit_edge21, label %.lr.ph20

.lr.ph20:                                         ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %.not15 = icmp eq ptr %1, null
  br i1 %.not15, label %.lr.ph20.split.us, label %.lr.ph20.split

.lr.ph20.split.us:                                ; preds = %.lr.ph20, %._crit_edge.split.us.us
  %5 = phi i32 [ %9, %._crit_edge.split.us.us ], [ %3, %.lr.ph20 ]
  %indvars.iv25 = phi i64 [ %indvars.iv.next26, %._crit_edge.split.us.us ], [ 0, %.lr.ph20 ]
  %6 = load ptr, ptr %4, align 8, !tbaa !12
  %7 = getelementptr inbounds ptr, ptr %6, i64 %indvars.iv25
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %.not16.us = icmp eq ptr %8, null
  br i1 %.not16.us, label %._crit_edge.split.us.us, label %.lr.ph.us

._crit_edge.split.us.us.loopexit:                 ; preds = %.lr.ph.us
  %.pre28 = load i32, ptr %0, align 8, !tbaa !5
  br label %._crit_edge.split.us.us

._crit_edge.split.us.us:                          ; preds = %._crit_edge.split.us.us.loopexit, %.lr.ph20.split.us
  %9 = phi i32 [ %.pre28, %._crit_edge.split.us.us.loopexit ], [ %5, %.lr.ph20.split.us ]
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %10 = zext i32 %9 to i64
  %11 = icmp ult i64 %indvars.iv.next26, %10
  br i1 %11, label %.lr.ph20.split.us, label %._crit_edge21, !llvm.loop !14

.lr.ph.us:                                        ; preds = %.lr.ph20.split.us, %.lr.ph.us
  %.01317.us.us = phi ptr [ %13, %.lr.ph.us ], [ %8, %.lr.ph20.split.us ]
  %12 = getelementptr inbounds i8, ptr %.01317.us.us, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  tail call void @free(ptr noundef nonnull %.01317.us.us) #2
  %.not.us.us = icmp eq ptr %13, null
  br i1 %.not.us.us, label %._crit_edge.split.us.us.loopexit, label %.lr.ph.us, !llvm.loop !18

.lr.ph20.split:                                   ; preds = %.lr.ph20, %._crit_edge.split
  %14 = phi i32 [ %20, %._crit_edge.split ], [ %3, %.lr.ph20 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge.split ], [ 0, %.lr.ph20 ]
  %15 = load ptr, ptr %4, align 8, !tbaa !12
  %16 = getelementptr inbounds ptr, ptr %15, i64 %indvars.iv
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %.not16 = icmp eq ptr %17, null
  br i1 %.not16, label %._crit_edge.split, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph20.split, %.lr.ph
  %.01317 = phi ptr [ %19, %.lr.ph ], [ %17, %.lr.ph20.split ]
  %18 = getelementptr inbounds i8, ptr %.01317, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  tail call void %1(ptr noundef nonnull %.01317) #2
  tail call void @free(ptr noundef nonnull %.01317) #2
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %._crit_edge.split.loopexit, label %.lr.ph, !llvm.loop !18

._crit_edge.split.loopexit:                       ; preds = %.lr.ph
  %.pre = load i32, ptr %0, align 8, !tbaa !5
  br label %._crit_edge.split

._crit_edge.split:                                ; preds = %._crit_edge.split.loopexit, %.lr.ph20.split
  %20 = phi i32 [ %.pre, %._crit_edge.split.loopexit ], [ %14, %.lr.ph20.split ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = zext i32 %20 to i64
  %22 = icmp ult i64 %indvars.iv.next, %21
  br i1 %22, label %.lr.ph20.split, label %._crit_edge21, !llvm.loop !14

._crit_edge21:                                    ; preds = %._crit_edge.split, %._crit_edge.split.us.us, %2
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  tail call void @free(ptr noundef %24) #2
  tail call void @free(ptr noundef nonnull %0) #2
  ret void
}

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

attributes #0 = { 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 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 #2 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 12, !11, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !11, i64 16}
!17 = !{!"hash_entry", !11, i64 0, !11, i64 8, !11, i64 16}
!18 = distinct !{!18, !15}


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