; LLVM IR from godzilla-foundation/godzilla-community :: core/deps/nanomsg-1.1.5/src/utils (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.nn_hash = type { i32, i32, ptr }
%struct.nn_list = type { ptr, ptr }
%struct.nn_hash_item = type { i32, %struct.nn_list_item }
%struct.nn_list_item = type { 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
declare hidden i32 @nn_hash_key(i32 noundef) #1

declare ptr @nn_list_begin(ptr noundef) #2

declare ptr @nn_list_end(ptr noundef) #2

declare ptr @nn_list_next(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @nn_hash_get(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = call i32 @nn_hash_key(i32 noundef %10)
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.nn_hash, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = urem i32 %11, %14
  store i32 %15, ptr %6, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.nn_hash, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds %struct.nn_list, ptr %18, i64 %20
  %22 = call ptr @nn_list_begin(ptr noundef %21)
  store ptr %22, ptr %7, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %50, %2
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.nn_hash, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds %struct.nn_list, ptr %27, i64 %29
  %31 = call ptr @nn_list_end(ptr noundef %30)
  %32 = icmp ne ptr %24, %31
  br i1 %32, label %33, label %59

33:                                               ; preds = %23
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %39

36:                                               ; preds = %33
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 -8
  br label %40

39:                                               ; preds = %33
  br label %40

40:                                               ; preds = %39, %36
  %41 = phi ptr [ %38, %36 ], [ null, %39 ]
  store ptr %41, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.nn_hash_item, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !14
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = icmp eq i32 %44, %45
  br i1 %46, label %47, label %49

47:                                               ; preds = %40
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %48, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %60

49:                                               ; preds = %40
  br label %50

50:                                               ; preds = %49
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.nn_hash, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds %struct.nn_list, ptr %53, i64 %55
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = call ptr @nn_list_next(ptr noundef %56, ptr noundef %57)
  store ptr %58, ptr %7, align 8, !tbaa !5
  br label %23, !llvm.loop !17

59:                                               ; preds = %23
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %60

60:                                               ; preds = %59, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %61 = load ptr, ptr %3, align 8
  ret ptr %61
}

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 = { "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 = !{!"nn_hash", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !10, i64 0}
!15 = !{!"nn_hash_item", !10, i64 0, !16, i64 8}
!16 = !{!"nn_list_item", !6, i64 0, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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.nn_list = type { ptr, ptr }

; Function Attrs: nounwind uwtable
declare hidden i32 @nn_hash_key(i32 noundef) local_unnamed_addr #0

declare ptr @nn_list_begin(ptr noundef) local_unnamed_addr #1

declare ptr @nn_list_end(ptr noundef) local_unnamed_addr #1

declare ptr @nn_list_next(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @nn_hash_get(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @nn_hash_key(i32 noundef %1)
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = urem i32 %3, %4
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = zext i32 %5 to i64
  %9 = getelementptr inbounds %struct.nn_list, ptr %7, i64 %8
  %10 = tail call ptr @nn_list_begin(ptr noundef %9) #2
  %11 = load ptr, ptr %6, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.nn_list, ptr %11, i64 %8
  %13 = tail call ptr @nn_list_end(ptr noundef %12) #2
  %.not19 = icmp eq ptr %10, %13
  br i1 %.not19, label %.split.loop.exit, label %.lr.ph

.lr.ph:                                           ; preds = %2, %17
  %.01520 = phi ptr [ %20, %17 ], [ %10, %2 ]
  %14 = getelementptr inbounds i8, ptr %.01520, i64 -8
  %15 = load i32, ptr %14, align 8, !tbaa !12
  %16 = icmp eq i32 %15, %1
  br i1 %16, label %.split.loop.exit.loopexit.split.loop.exit, label %17

17:                                               ; preds = %.lr.ph
  %18 = load ptr, ptr %6, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.nn_list, ptr %18, i64 %8
  %20 = tail call ptr @nn_list_next(ptr noundef %19, ptr noundef nonnull %.01520) #2
  %21 = load ptr, ptr %6, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct.nn_list, ptr %21, i64 %8
  %23 = tail call ptr @nn_list_end(ptr noundef %22) #2
  %.not = icmp eq ptr %20, %23
  br i1 %.not, label %.split.loop.exit, label %.lr.ph, !llvm.loop !15

.split.loop.exit.loopexit.split.loop.exit:        ; preds = %.lr.ph
  %24 = getelementptr inbounds i8, ptr %.01520, i64 -8
  br label %.split.loop.exit

.split.loop.exit:                                 ; preds = %17, %.split.loop.exit.loopexit.split.loop.exit, %2
  %.0 = phi ptr [ null, %2 ], [ %24, %.split.loop.exit.loopexit.split.loop.exit ], [ null, %17 ]
  ret ptr %.0
}

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


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