; LLVM IR from ohler55/agoo :: ext/agoo (page)

; 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._slot = type { ptr, [1025 x i8], ptr, i64, i32 }

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

; Function Attrs: nounwind uwtable
declare hidden i64 @calc_hash(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #2

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

17:                                               ; preds = %52, %2
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp ne ptr null, %18
  br i1 %19, label %20, label %56

20:                                               ; preds = %17
  %21 = load i64, ptr %6, align 8, !tbaa !11
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._slot, ptr %22, i32 0, i32 3
  %24 = load i64, ptr %23, align 8, !tbaa !13
  %25 = icmp eq i64 %21, %24
  br i1 %25, label %26, label %51

26:                                               ; preds = %20
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._slot, ptr %28, i32 0, i32 4
  %30 = load i32, ptr %29, align 8, !tbaa !15
  %31 = icmp eq i32 %27, %30
  br i1 %31, label %32, label %51

32:                                               ; preds = %26
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = icmp sle i32 0, %33
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = icmp sle i32 %36, 9
  br i1 %37, label %47, label %38

38:                                               ; preds = %35, %32
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._slot, ptr %39, i32 0, i32 1
  %41 = getelementptr inbounds [1025 x i8], ptr %40, i64 0, i64 0
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = call i32 @strncmp(ptr noundef %41, ptr noundef %42, i64 noundef %44) #4
  %46 = icmp eq i32 0, %45
  br i1 %46, label %47, label %51

47:                                               ; preds = %38, %35
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._slot, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  store ptr %50, ptr %9, align 8, !tbaa !5
  br label %56

51:                                               ; preds = %38, %26, %20
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._slot, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  store ptr %55, ptr %8, align 8, !tbaa !5
  br label %17, !llvm.loop !18

56:                                               ; preds = %47, %17
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  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 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret ptr %57
}

; Function Attrs: nounwind uwtable
declare hidden ptr @get_bucketp(i64 noundef) #1

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 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 #3 = { nounwind }
attributes #4 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 1048}
!14 = !{!"_slot", !6, i64 0, !7, i64 8, !6, i64 1040, !12, i64 1048, !10, i64 1056}
!15 = !{!14, !10, i64 1056}
!16 = !{!14, !6, i64 1040}
!17 = !{!14, !6, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

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

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

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

; Function Attrs: mustprogress 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 @cache_get(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 %1, ptr %3, align 4, !tbaa !5
  %4 = call i64 @calc_hash(ptr noundef %0, ptr noundef nonnull %3)
  %5 = call ptr @get_bucketp(i64 noundef %4)
  %.01417 = load ptr, ptr %5, align 8, !tbaa !9
  %.not18 = icmp eq ptr %.01417, null
  br i1 %.not18, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %6 = load i32, ptr %3, align 4
  %.fr = freeze i32 %6
  %or.cond = icmp ult i32 %.fr, 10
  %7 = sext i32 %1 to i64
  br i1 %or.cond, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %15
  %.01419.us = phi ptr [ %.014.us, %15 ], [ %.01417, %.lr.ph ]
  %8 = getelementptr inbounds i8, ptr %.01419.us, i64 1048
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = icmp eq i64 %4, %9
  br i1 %10, label %11, label %15

11:                                               ; preds = %.lr.ph.split.us
  %12 = getelementptr inbounds i8, ptr %.01419.us, i64 1056
  %13 = load i32, ptr %12, align 8, !tbaa !14
  %14 = icmp eq i32 %.fr, %13
  br i1 %14, label %.split.us, label %15

15:                                               ; preds = %11, %.lr.ph.split.us
  %.014.us = load ptr, ptr %.01419.us, align 8, !tbaa !9
  %.not.us = icmp eq ptr %.014.us, null
  br i1 %.not.us, label %.loopexit, label %.lr.ph.split.us, !llvm.loop !15

.lr.ph.split:                                     ; preds = %.lr.ph, %29
  %.01419 = phi ptr [ %.014, %29 ], [ %.01417, %.lr.ph ]
  %16 = getelementptr inbounds i8, ptr %.01419, i64 1048
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = icmp eq i64 %4, %17
  br i1 %18, label %19, label %29

19:                                               ; preds = %.lr.ph.split
  %20 = getelementptr inbounds i8, ptr %.01419, i64 1056
  %21 = load i32, ptr %20, align 8, !tbaa !14
  %22 = icmp eq i32 %.fr, %21
  br i1 %22, label %23, label %29

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %.01419, i64 8
  %25 = call i32 @strncmp(ptr noundef nonnull %24, ptr noundef %0, i64 noundef %7) #4
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %.split.us, label %29

.split.us:                                        ; preds = %23, %11
  %.us-phi = phi ptr [ %.01419.us, %11 ], [ %.01419, %23 ]
  %27 = getelementptr inbounds i8, ptr %.us-phi, i64 1040
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  br label %.loopexit

29:                                               ; preds = %.lr.ph.split, %19, %23
  %.014 = load ptr, ptr %.01419, align 8, !tbaa !9
  %.not = icmp eq ptr %.014, null
  br i1 %.not, label %.loopexit, label %.lr.ph.split, !llvm.loop !15

.loopexit:                                        ; preds = %29, %15, %2, %.split.us
  %.0 = phi ptr [ %28, %.split.us ], [ null, %2 ], [ null, %15 ], [ null, %29 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden ptr @get_bucketp(i64 noundef) local_unnamed_addr #1

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


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