; LLVM IR from DanEngelbrecht/longtail :: lib/hashregistry (longtail_full_hash_registry)

; 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.Longtail_HashAPI = type { %struct.Longtail_API, ptr, ptr, ptr, ptr, ptr }
%struct.Longtail_API = type { ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @Longtail_CreateFullHashRegistry() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [3 x i32], align 4
  %6 = alloca [3 x ptr], align 16
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %9 = call ptr (...) @Longtail_CreateBlake2HashAPI()
  store ptr %9, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %10 = call ptr (...) @Longtail_CreateBlake3HashAPI()
  store ptr %10, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %11 = call ptr (...) @Longtail_CreateMeowHashAPI()
  store ptr %11, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #3
  %12 = call i32 (...) @Longtail_GetBlake2HashType()
  store i32 %12, ptr %5, align 4, !tbaa !9
  %13 = getelementptr inbounds i32, ptr %5, i64 1
  %14 = call i32 (...) @Longtail_GetBlake3HashType()
  store i32 %14, ptr %13, align 4, !tbaa !9
  %15 = getelementptr inbounds i32, ptr %5, i64 2
  %16 = call i32 (...) @Longtail_GetMeowHashType()
  store i32 %16, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #3
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %17, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds ptr, ptr %6, i64 1
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %19, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds ptr, ptr %6, i64 2
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %21, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %22 = getelementptr inbounds [3 x i32], ptr %5, i64 0, i64 0
  %23 = getelementptr inbounds [3 x ptr], ptr %6, i64 0, i64 0
  %24 = call ptr @Longtail_CreateDefaultHashRegistry(i32 noundef 3, ptr noundef %22, ptr noundef %23)
  store ptr %24, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %46, label %27

27:                                               ; preds = %0
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %33

30:                                               ; preds = %27
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Longtail_HashAPI, ptr %31, i32 0, i32 0
  call void @Longtail_DisposeAPI(ptr noundef %32)
  br label %33

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

36:                                               ; preds = %33
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.Longtail_HashAPI, ptr %37, i32 0, i32 0
  call void @Longtail_DisposeAPI(ptr noundef %38)
  br label %39

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

42:                                               ; preds = %39
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Longtail_HashAPI, ptr %43, i32 0, i32 0
  call void @Longtail_DisposeAPI(ptr noundef %44)
  br label %45

45:                                               ; preds = %42, %39
  store ptr null, ptr %1, align 8
  store i32 1, ptr %8, align 4
  br label %48

46:                                               ; preds = %0
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %47, ptr %1, align 8
  store i32 1, ptr %8, align 4
  br label %48

48:                                               ; preds = %46, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %49 = load ptr, ptr %1, align 8
  ret ptr %49
}

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

declare ptr @Longtail_CreateBlake2HashAPI(...) #2

declare ptr @Longtail_CreateBlake3HashAPI(...) #2

declare ptr @Longtail_CreateMeowHashAPI(...) #2

declare i32 @Longtail_GetBlake2HashType(...) #2

declare i32 @Longtail_GetBlake3HashType(...) #2

declare i32 @Longtail_GetMeowHashType(...) #2

declare ptr @Longtail_CreateDefaultHashRegistry(i32 noundef, ptr noundef, ptr noundef) #2

declare void @Longtail_DisposeAPI(ptr noundef) #2

; 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 = { "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}


; 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 @Longtail_CreateFullHashRegistry() local_unnamed_addr #0 {
  %1 = alloca [3 x i32], align 4
  %2 = alloca [3 x ptr], align 16
  %3 = tail call ptr (...) @Longtail_CreateBlake2HashAPI() #3
  %4 = tail call ptr (...) @Longtail_CreateBlake3HashAPI() #3
  %5 = tail call ptr (...) @Longtail_CreateMeowHashAPI() #3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #3
  %6 = tail call i32 (...) @Longtail_GetBlake2HashType() #3
  store i32 %6, ptr %1, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = tail call i32 (...) @Longtail_GetBlake3HashType() #3
  store i32 %8, ptr %7, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = tail call i32 (...) @Longtail_GetMeowHashType() #3
  store i32 %10, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #3
  store ptr %3, ptr %2, align 16, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %4, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %5, ptr %12, align 16, !tbaa !9
  %13 = call ptr @Longtail_CreateDefaultHashRegistry(i32 noundef 3, ptr noundef nonnull %1, ptr noundef nonnull %2) #3
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %14, label %20

14:                                               ; preds = %0
  %.not16 = icmp eq ptr %5, null
  br i1 %.not16, label %16, label %15

15:                                               ; preds = %14
  call void @Longtail_DisposeAPI(ptr noundef nonnull %5) #3
  br label %16

16:                                               ; preds = %15, %14
  %.not17 = icmp eq ptr %4, null
  br i1 %.not17, label %18, label %17

17:                                               ; preds = %16
  call void @Longtail_DisposeAPI(ptr noundef nonnull %4) #3
  br label %18

18:                                               ; preds = %17, %16
  %.not18 = icmp eq ptr %3, null
  br i1 %.not18, label %20, label %19

19:                                               ; preds = %18
  call void @Longtail_DisposeAPI(ptr noundef nonnull %3) #3
  br label %20

20:                                               ; preds = %0, %18, %19
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #3
  ret ptr %13
}

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

declare ptr @Longtail_CreateBlake2HashAPI(...) local_unnamed_addr #2

declare ptr @Longtail_CreateBlake3HashAPI(...) local_unnamed_addr #2

declare ptr @Longtail_CreateMeowHashAPI(...) local_unnamed_addr #2

declare i32 @Longtail_GetBlake2HashType(...) local_unnamed_addr #2

declare i32 @Longtail_GetBlake3HashType(...) local_unnamed_addr #2

declare i32 @Longtail_GetMeowHashType(...) local_unnamed_addr #2

declare ptr @Longtail_CreateDefaultHashRegistry(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @Longtail_DisposeAPI(ptr 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) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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}


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