; 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 ptr @hash_put_mapping(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  br label %21

15:                                               ; preds = %3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.friso_hash_cdt, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = call i32 @hash(ptr noundef %16, i32 noundef %19)
  br label %21

21:                                               ; preds = %15, %14
  %22 = phi i32 [ 0, %14 ], [ %20, %15 ]
  store i32 %22, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.friso_hash_cdt, ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = load i32, ptr %8, align 4, !tbaa !13
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds ptr, ptr %25, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  store ptr %29, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store ptr null, ptr %10, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %66, %21
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %70

33:                                               ; preds = %30
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.hash_entry, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !15
  %38 = icmp eq ptr %34, %37
  br i1 %38, label %54, label %39

39:                                               ; preds = %33
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %65

42:                                               ; preds = %39
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.hash_entry, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %65

47:                                               ; preds = %42
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.hash_entry, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  %52 = call i32 @strcmp(ptr noundef %48, ptr noundef %51) #5
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %65

54:                                               ; preds = %47, %33
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.hash_entry, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  store ptr %57, ptr %10, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.hash_entry, ptr %59, i32 0, i32 0
  store ptr %58, ptr %60, align 8, !tbaa !15
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.hash_entry, ptr %62, i32 0, i32 1
  store ptr %61, ptr %63, align 8, !tbaa !17
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %64, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %102

65:                                               ; preds = %47, %42, %39
  br label %66

66:                                               ; preds = %65
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.hash_entry, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !18
  store ptr %69, ptr %9, align 8, !tbaa !5
  br label %30, !llvm.loop !19

70:                                               ; preds = %30
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.friso_hash_cdt, ptr %73, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !14
  %76 = load i32, ptr %8, align 4, !tbaa !13
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds ptr, ptr %75, i64 %77
  %79 = load ptr, ptr %78, align 8, !tbaa !5
  %80 = call ptr @new_hash_entry(ptr noundef %71, ptr noundef %72, ptr noundef %79)
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.friso_hash_cdt, ptr %81, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !14
  %84 = load i32, ptr %8, align 4, !tbaa !13
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds ptr, ptr %83, i64 %85
  store ptr %80, ptr %86, align 8, !tbaa !5
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.friso_hash_cdt, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !21
  %90 = add i32 %89, 1
  store i32 %90, ptr %88, align 4, !tbaa !21
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.friso_hash_cdt, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !21
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.friso_hash_cdt, ptr %94, i32 0, i32 3
  %96 = load i32, ptr %95, align 4, !tbaa !22
  %97 = icmp uge i32 %93, %96
  br i1 %97, label %98, label %100

98:                                               ; preds = %70
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  call void @rebuild_hash(ptr noundef %99)
  br label %100

100:                                              ; preds = %98, %70
  %101 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %101, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %102

102:                                              ; preds = %100, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %103 = load ptr, ptr %4, align 8
  ret ptr %103
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @hash(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @new_hash_entry(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @rebuild_hash(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 = { 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 #3 = { nounwind willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !12, i64 8, !11, i64 12, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 16}
!15 = !{!16, !6, i64 0}
!16 = !{!"hash_entry", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!16, !6, i64 8}
!18 = !{!16, !6, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !11, i64 4}
!22 = !{!10, !11, i64 12}


; 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 ptr @hash_put_mapping(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %1, null
  br i1 %4, label %5, label %.thread

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.037 = load ptr, ptr %7, align 8, !tbaa !12
  %.not38 = icmp eq ptr %.037, null
  br i1 %.not38, label %._crit_edge, label %.lr.ph.split.us

.thread:                                          ; preds = %3
  %8 = load i32, ptr %0, align 8, !tbaa !13
  %9 = tail call i32 @hash(ptr noundef nonnull %1, i32 noundef %8)
  %10 = zext i32 %9 to i64
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds ptr, ptr %12, i64 %10
  %.03744 = load ptr, ptr %13, align 8, !tbaa !12
  %.not3845 = icmp eq ptr %.03744, null
  br i1 %.not3845, label %._crit_edge, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %5, %16
  %.039.us = phi ptr [ %.0.us, %16 ], [ %.037, %5 ]
  %14 = load ptr, ptr %.039.us, align 8, !tbaa !14
  %15 = icmp eq ptr %14, null
  br i1 %15, label %.split.us, label %16

16:                                               ; preds = %.lr.ph.split.us
  %17 = getelementptr inbounds i8, ptr %.039.us, i64 16
  %.0.us = load ptr, ptr %17, align 8, !tbaa !12
  %.not.us = icmp eq ptr %.0.us, null
  br i1 %.not.us, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !16

.lr.ph.split:                                     ; preds = %.thread, %26
  %.039 = phi ptr [ %.0, %26 ], [ %.03744, %.thread ]
  %18 = load ptr, ptr %.039, align 8, !tbaa !14
  %19 = icmp eq ptr %18, %1
  br i1 %19, label %.split.us, label %20

20:                                               ; preds = %.lr.ph.split
  %.not35 = icmp eq ptr %18, null
  br i1 %.not35, label %26, label %21

21:                                               ; preds = %20
  %22 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %18) #3
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %.split.us, label %26

.split.us:                                        ; preds = %.lr.ph.split, %21, %.lr.ph.split.us
  %.us-phi = phi ptr [ %.039.us, %.lr.ph.split.us ], [ %.039, %21 ], [ %.039, %.lr.ph.split ]
  %24 = getelementptr inbounds i8, ptr %.us-phi, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !18
  store ptr %1, ptr %.us-phi, align 8, !tbaa !14
  store ptr %2, ptr %24, align 8, !tbaa !18
  br label %39

26:                                               ; preds = %20, %21
  %27 = getelementptr inbounds i8, ptr %.039, i64 16
  %.0 = load ptr, ptr %27, align 8, !tbaa !12
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !16

._crit_edge:                                      ; preds = %26, %16, %.thread, %5
  %.03747 = phi ptr [ null, %.thread ], [ null, %5 ], [ %.037, %16 ], [ %.03744, %26 ]
  %28 = phi ptr [ %11, %.thread ], [ %6, %5 ], [ %6, %16 ], [ %11, %26 ]
  %29 = phi i64 [ %10, %.thread ], [ 0, %5 ], [ 0, %16 ], [ %10, %26 ]
  %30 = tail call ptr @new_hash_entry(ptr noundef %1, ptr noundef %2, ptr noundef %.03747)
  %31 = load ptr, ptr %28, align 8, !tbaa !5
  %32 = getelementptr inbounds ptr, ptr %31, i64 %29
  store ptr %30, ptr %32, align 8, !tbaa !12
  %33 = getelementptr inbounds i8, ptr %0, i64 4
  %34 = load i32, ptr %33, align 4, !tbaa !19
  %35 = add i32 %34, 1
  store i32 %35, ptr %33, align 4, !tbaa !19
  %36 = getelementptr inbounds i8, ptr %0, i64 12
  %37 = load i32, ptr %36, align 4, !tbaa !20
  %.not33 = icmp ult i32 %35, %37
  br i1 %.not33, label %39, label %38

38:                                               ; preds = %._crit_edge
  tail call void @rebuild_hash(ptr noundef nonnull %0)
  br label %39

39:                                               ; preds = %._crit_edge, %38, %.split.us
  %.030 = phi ptr [ %25, %.split.us ], [ null, %38 ], [ null, %._crit_edge ]
  ret ptr %.030
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @hash(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @new_hash_entry(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @rebuild_hash(ptr 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 = { 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 #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 16}
!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 = !{!11, !11, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !11, i64 0}
!15 = !{!"hash_entry", !11, i64 0, !11, i64 8, !11, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!15, !11, i64 8}
!19 = !{!6, !7, i64 4}
!20 = !{!6, !7, i64 12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass