; LLVM IR from openanolis/openssl :: crypto/lhash (lhash)

; 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.lhash_st = type { ptr, ptr, ptr, i32, i32, i32, i32, i64, i64, i64, i32 }
%struct.lhash_node_st = type { ptr, ptr, i64 }

@.str = external hidden unnamed_addr constant [73 x i8], align 1

; 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 @OPENSSL_LH_insert(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.lhash_st, ptr %11, i32 0, i32 10
  store i32 0, ptr %12, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.lhash_st, ptr %13, i32 0, i32 7
  %15 = load i64, ptr %14, align 8, !tbaa !13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.lhash_st, ptr %16, i32 0, i32 9
  %18 = load i64, ptr %17, align 8, !tbaa !14
  %19 = mul i64 %18, 256
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.lhash_st, ptr %20, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !15
  %23 = zext i32 %22 to i64
  %24 = udiv i64 %19, %23
  %25 = icmp ule i64 %15, %24
  br i1 %25, label %26, label %31

26:                                               ; preds = %2
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call i32 @expand(ptr noundef %27)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %72

31:                                               ; preds = %26, %2
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call ptr @getrn(ptr noundef %32, ptr noundef %33, ptr noundef %6)
  store ptr %34, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %61

38:                                               ; preds = %31
  %39 = call ptr @CRYPTO_malloc(i64 noundef 24, ptr noundef @.str, i32 noundef 114)
  store ptr %39, ptr %7, align 8, !tbaa !5
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %46

41:                                               ; preds = %38
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.lhash_st, ptr %42, i32 0, i32 10
  %44 = load i32, ptr %43, align 8, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %43, align 8, !tbaa !9
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %72

46:                                               ; preds = %38
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.lhash_node_st, ptr %48, i32 0, i32 0
  store ptr %47, ptr %49, align 8, !tbaa !16
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.lhash_node_st, ptr %50, i32 0, i32 1
  store ptr null, ptr %51, align 8, !tbaa !18
  %52 = load i64, ptr %6, align 8, !tbaa !19
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.lhash_node_st, ptr %53, i32 0, i32 2
  store i64 %52, ptr %54, align 8, !tbaa !20
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %55, ptr %56, align 8, !tbaa !5
  store ptr null, ptr %9, align 8, !tbaa !5
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.lhash_st, ptr %57, i32 0, i32 9
  %59 = load i64, ptr %58, align 8, !tbaa !14
  %60 = add i64 %59, 1
  store i64 %60, ptr %58, align 8, !tbaa !14
  br label %70

61:                                               ; preds = %31
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.lhash_node_st, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  store ptr %65, ptr %9, align 8, !tbaa !5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.lhash_node_st, ptr %68, i32 0, i32 0
  store ptr %66, ptr %69, align 8, !tbaa !16
  br label %70

70:                                               ; preds = %61, %46
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %71, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %72

72:                                               ; preds = %70, %41, %30
  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
  %73 = load ptr, ptr %3, align 8
  ret ptr %73
}

; Function Attrs: nounwind uwtable
declare hidden i32 @expand(ptr noundef) #1

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

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 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 = { "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, !11, i64 64}
!10 = !{!"lhash_st", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !12, i64 40, !12, i64 48, !12, i64 56, !11, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 40}
!14 = !{!10, !12, i64 56}
!15 = !{!10, !11, i64 24}
!16 = !{!17, !6, i64 0}
!17 = !{!"lhash_node_st", !6, i64 0, !6, i64 8, !12, i64 16}
!18 = !{!17, !6, i64 8}
!19 = !{!12, !12, i64 0}
!20 = !{!17, !12, i64 16}


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

@.str = external hidden unnamed_addr constant [73 x i8], align 1

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

; 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 @OPENSSL_LH_insert(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 0, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load i64, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = load i64, ptr %7, align 8, !tbaa !13
  %9 = shl i64 %8, 8
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = zext i32 %11 to i64
  %13 = udiv i64 %9, %12
  %.not = icmp ugt i64 %6, %13
  br i1 %.not, label %16, label %14

14:                                               ; preds = %2
  %15 = tail call i32 @expand(ptr noundef nonnull %0)
  %.not24 = icmp eq i32 %15, 0
  br i1 %.not24, label %34, label %16

16:                                               ; preds = %14, %2
  %17 = call ptr @getrn(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %3)
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %32

20:                                               ; preds = %16
  %21 = call ptr @CRYPTO_malloc(i64 noundef 24, ptr noundef nonnull @.str, i32 noundef 114) #3
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = load i32, ptr %4, align 8, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %4, align 8, !tbaa !5
  br label %34

26:                                               ; preds = %20
  store ptr %1, ptr %21, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %21, i64 8
  store ptr null, ptr %27, align 8, !tbaa !18
  %28 = load i64, ptr %3, align 8, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %21, i64 16
  store i64 %28, ptr %29, align 8, !tbaa !20
  store ptr %21, ptr %17, align 8, !tbaa !15
  %30 = load i64, ptr %7, align 8, !tbaa !13
  %31 = add i64 %30, 1
  store i64 %31, ptr %7, align 8, !tbaa !13
  br label %34

32:                                               ; preds = %16
  %33 = load ptr, ptr %18, align 8, !tbaa !16
  store ptr %1, ptr %18, align 8, !tbaa !16
  br label %34

34:                                               ; preds = %26, %32, %14, %23
  %.021 = phi ptr [ null, %23 ], [ null, %14 ], [ null, %26 ], [ %33, %32 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret ptr %.021
}

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

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

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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 = { "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, !10, i64 64}
!6 = !{!"lhash_st", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !10, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !11, i64 40}
!13 = !{!6, !11, i64 56}
!14 = !{!6, !10, i64 24}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !7, i64 0}
!17 = !{!"lhash_node_st", !7, i64 0, !7, i64 8, !11, i64 16}
!18 = !{!17, !7, i64 8}
!19 = !{!11, !11, i64 0}
!20 = !{!17, !11, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass