; LLVM IR from m-boutaleb/LZS :: src (hash_service)

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

@hash_table = external hidden global [696623 x ptr], align 16
@match_lengths = external hidden global [696623 x i16], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @is_match_table(ptr noundef %0, i16 noundef zeroext %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load i16, ptr %5, align 2, !tbaa !9
  %12 = call i32 @hash(ptr noundef %10, i16 noundef zeroext %11)
  store i32 %12, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %13 = load i32, ptr %6, align 4, !tbaa !11
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds [696623 x ptr], ptr @hash_table, i64 0, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %16, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %17

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

20:                                               ; preds = %17
  %21 = load i32, ptr %6, align 4, !tbaa !11
  %22 = load i32, ptr %8, align 4, !tbaa !11
  %23 = add i32 %21, %22
  %24 = urem i32 %23, 696623
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [696623 x i16], ptr @match_lengths, i64 0, i64 %25
  %27 = load i16, ptr %26, align 2, !tbaa !9
  %28 = zext i16 %27 to i32
  %29 = load i16, ptr %5, align 2, !tbaa !9
  %30 = zext i16 %29 to i32
  %31 = icmp eq i32 %28, %30
  br i1 %31, label %32, label %43

32:                                               ; preds = %20
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i16, ptr %5, align 2, !tbaa !9
  %36 = call zeroext i16 @compare_string(ptr noundef %33, ptr noundef %34, i16 noundef zeroext %35)
  %37 = icmp ne i16 %36, 0
  br i1 %37, label %43, label %38

38:                                               ; preds = %32
  %39 = load i32, ptr %6, align 4, !tbaa !11
  %40 = load i32, ptr %8, align 4, !tbaa !11
  %41 = add i32 %39, %40
  %42 = urem i32 %41, 696623
  store i32 %42, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %59

43:                                               ; preds = %32, %20
  %44 = load i32, ptr %6, align 4, !tbaa !11
  %45 = load i32, ptr %8, align 4, !tbaa !11
  %46 = add i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !11
  %47 = add i32 %44, %46
  %48 = urem i32 %47, 696623
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds [696623 x ptr], ptr @hash_table, i64 0, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  store ptr %51, ptr %7, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %43
  br label %17, !llvm.loop !13

53:                                               ; preds = %17
  %54 = load i32, ptr %6, align 4, !tbaa !11
  %55 = load i32, ptr %8, align 4, !tbaa !11
  %56 = add i32 %54, %55
  %57 = urem i32 %56, 696623
  %58 = add i32 %57, 696623
  store i32 %58, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %59

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

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

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

declare zeroext i16 @compare_string(ptr noundef, ptr noundef, i16 noundef zeroext) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@hash_table = external hidden local_unnamed_addr global [696623 x ptr], align 16
@match_lengths = external hidden local_unnamed_addr global [696623 x i16], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 1393246) i32 @is_match_table(ptr noundef %0, i16 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = tail call i32 @hash(ptr noundef %0, i16 noundef zeroext %1)
  %.pn20 = zext i32 %3 to i64
  %.016.in21 = getelementptr inbounds [696623 x ptr], ptr @hash_table, i64 0, i64 %.pn20
  %.01622 = load ptr, ptr %.016.in21, align 8, !tbaa !5
  %.not23 = icmp eq ptr %.01622, null
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %12
  %.01625 = phi ptr [ %.016, %12 ], [ %.01622, %2 ]
  %.024 = phi i32 [ %13, %12 ], [ 0, %2 ]
  %4 = add i32 %.024, %3
  %5 = urem i32 %4, 696623
  %6 = zext nneg i32 %5 to i64
  %7 = getelementptr inbounds [696623 x i16], ptr @match_lengths, i64 0, i64 %6
  %8 = load i16, ptr %7, align 2, !tbaa !9
  %9 = icmp eq i16 %8, %1
  br i1 %9, label %10, label %12

10:                                               ; preds = %.lr.ph
  %11 = tail call zeroext i16 @compare_string(ptr noundef %0, ptr noundef nonnull %.01625, i16 noundef zeroext %1) #3
  %.not18 = icmp eq i16 %11, 0
  br i1 %.not18, label %.loopexit, label %12

12:                                               ; preds = %10, %.lr.ph
  %13 = add i32 %.024, 1
  %14 = add i32 %13, %3
  %15 = urem i32 %14, 696623
  %.pn = zext nneg i32 %15 to i64
  %.016.in = getelementptr inbounds [696623 x ptr], ptr @hash_table, i64 0, i64 %.pn
  %.016 = load ptr, ptr %.016.in, align 8, !tbaa !5
  %.not = icmp eq ptr %.016, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %12, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %13, %12 ]
  %16 = add i32 %.0.lcssa, %3
  %17 = urem i32 %16, 696623
  %18 = add nuw nsw i32 %17, 696623
  br label %.loopexit

.loopexit:                                        ; preds = %10, %._crit_edge
  %.017 = phi i32 [ %18, %._crit_edge ], [ %5, %10 ]
  ret i32 %.017
}

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

declare zeroext i16 @compare_string(ptr noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

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 = { "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 = !{!"short", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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