; LLVM IR from chdb-io/chdb :: contrib/libmetrohash/src/metrohash128.ll (ZN12MetroHash12822ImplementationVerifiedEv)

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

%class.MetroHash128 = type { %struct.anon, %struct.anon.0, i64 }
%struct.anon = type { [4 x i64] }
%struct.anon.0 = type { [32 x i8] }

@_ZN12MetroHash12811test_stringE = external dso_local global ptr, align 8
@_ZN12MetroHash12811test_seed_0E = external dso_local constant [16 x i8], align 16
@_ZN12MetroHash12811test_seed_1E = external dso_local constant [16 x i8], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN12MetroHash12810InitializeEm(ptr noundef nonnull align 8 dereferenceable(72), i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12MetroHash1286UpdateEPKhm(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef, i64 noundef) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12MetroHash1288FinalizeEPh(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12MetroHash1284HashEPKhmPhm(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN12MetroHash12822ImplementationVerifiedEv() #1 align 2 {
  %1 = alloca i1, align 1
  %2 = alloca [16 x i8], align 16
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %class.MetroHash128, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %6 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %9 = call i64 @strlen(ptr noundef %8) #5
  %10 = getelementptr inbounds [16 x i8], ptr %2, i64 0, i64 0
  call void @_ZN12MetroHash1284HashEPKhmPhm(ptr noundef %7, i64 noundef %9, ptr noundef %10, i64 noundef 0)
  %11 = getelementptr inbounds [16 x i8], ptr %2, i64 0, i64 0
  %12 = call i32 @memcmp(ptr noundef %11, ptr noundef @_ZN12MetroHash12811test_seed_0E, i64 noundef 16) #5
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %0
  store i1 false, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %44

15:                                               ; preds = %0
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %18 = call i64 @strlen(ptr noundef %17) #5
  %19 = getelementptr inbounds [16 x i8], ptr %2, i64 0, i64 0
  call void @_ZN12MetroHash1284HashEPKhmPhm(ptr noundef %16, i64 noundef %18, ptr noundef %19, i64 noundef 1)
  %20 = getelementptr inbounds [16 x i8], ptr %2, i64 0, i64 0
  %21 = call i32 @memcmp(ptr noundef %20, ptr noundef @_ZN12MetroHash12811test_seed_1E, i64 noundef 16) #5
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %15
  store i1 false, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %44

24:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 72, ptr %5) #4
  call void @_ZN12MetroHash128C1Em(ptr noundef nonnull align 8 dereferenceable(72) %5, i64 noundef 0)
  call void @_ZN12MetroHash12810InitializeEm(ptr noundef nonnull align 8 dereferenceable(72) %5, i64 noundef 0)
  %25 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %26 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %27 = call i64 @strlen(ptr noundef %26) #5
  call void @_ZN12MetroHash1286UpdateEPKhm(ptr noundef nonnull align 8 dereferenceable(72) %5, ptr noundef %25, i64 noundef %27)
  %28 = getelementptr inbounds [16 x i8], ptr %2, i64 0, i64 0
  call void @_ZN12MetroHash1288FinalizeEPh(ptr noundef nonnull align 8 dereferenceable(72) %5, ptr noundef %28)
  %29 = getelementptr inbounds [16 x i8], ptr %2, i64 0, i64 0
  %30 = call i32 @memcmp(ptr noundef %29, ptr noundef @_ZN12MetroHash12811test_seed_0E, i64 noundef 16) #5
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %24
  store i1 false, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %43

33:                                               ; preds = %24
  call void @_ZN12MetroHash12810InitializeEm(ptr noundef nonnull align 8 dereferenceable(72) %5, i64 noundef 1)
  %34 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %35 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %36 = call i64 @strlen(ptr noundef %35) #5
  call void @_ZN12MetroHash1286UpdateEPKhm(ptr noundef nonnull align 8 dereferenceable(72) %5, ptr noundef %34, i64 noundef %36)
  %37 = getelementptr inbounds [16 x i8], ptr %2, i64 0, i64 0
  call void @_ZN12MetroHash1288FinalizeEPh(ptr noundef nonnull align 8 dereferenceable(72) %5, ptr noundef %37)
  %38 = getelementptr inbounds [16 x i8], ptr %2, i64 0, i64 0
  %39 = call i32 @memcmp(ptr noundef %38, ptr noundef @_ZN12MetroHash12811test_seed_1E, i64 noundef 16) #5
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %33
  store i1 false, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %43

42:                                               ; preds = %33
  store i1 true, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %43

43:                                               ; preds = %42, %41, %32
  call void @llvm.lifetime.end.p0(i64 72, ptr %5) #4
  br label %44

44:                                               ; preds = %43, %23, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #4
  %45 = load i1, ptr %1, align 1
  ret i1 %45
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

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

declare void @_ZN12MetroHash128C1Em(ptr, i64)

attributes #0 = { mustprogress 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { 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++ TBAA"}


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

%class.MetroHash128 = type { %struct.anon, %struct.anon.0, i64 }
%struct.anon = type { [4 x i64] }
%struct.anon.0 = type { [32 x i8] }

@_ZN12MetroHash12811test_stringE = external dso_local local_unnamed_addr global ptr, align 8
@_ZN12MetroHash12811test_seed_0E = external dso_local constant [16 x i8], align 16
@_ZN12MetroHash12811test_seed_1E = external dso_local constant [16 x i8], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN12MetroHash12810InitializeEm(ptr noundef nonnull align 8 dereferenceable(72), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12MetroHash1286UpdateEPKhm(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef, i64 noundef) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12MetroHash1288FinalizeEPh(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12MetroHash1284HashEPKhmPhm(ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN12MetroHash12822ImplementationVerifiedEv() local_unnamed_addr #1 align 2 {
  %1 = alloca [16 x i8], align 16
  %2 = alloca %class.MetroHash128, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #5
  %3 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %3) #6
  call void @_ZN12MetroHash1284HashEPKhmPhm(ptr noundef %3, i64 noundef %4, ptr noundef nonnull %1, i64 noundef 0)
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %1, ptr noundef nonnull dereferenceable(16) @_ZN12MetroHash12811test_seed_0E, i64 16)
  %.not = icmp eq i32 %bcmp, 0
  br i1 %.not, label %5, label %15

5:                                                ; preds = %0
  %6 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %7 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %6) #6
  call void @_ZN12MetroHash1284HashEPKhmPhm(ptr noundef %3, i64 noundef %7, ptr noundef nonnull %1, i64 noundef 1)
  %bcmp3 = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %1, ptr noundef nonnull dereferenceable(16) @_ZN12MetroHash12811test_seed_1E, i64 16)
  %.not4 = icmp eq i32 %bcmp3, 0
  br i1 %.not4, label %8, label %15

8:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %2) #5
  call void @_ZN12MetroHash128C1Em(ptr noundef nonnull align 8 dereferenceable(72) %2, i64 noundef 0)
  call void @_ZN12MetroHash12810InitializeEm(ptr noundef nonnull align 8 dereferenceable(72) %2, i64 noundef 0)
  %9 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %10 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %9) #6
  call void @_ZN12MetroHash1286UpdateEPKhm(ptr noundef nonnull align 8 dereferenceable(72) %2, ptr noundef %9, i64 noundef %10)
  call void @_ZN12MetroHash1288FinalizeEPh(ptr noundef nonnull align 8 dereferenceable(72) %2, ptr noundef nonnull %1)
  %bcmp5 = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %1, ptr noundef nonnull dereferenceable(16) @_ZN12MetroHash12811test_seed_0E, i64 16)
  %.not6 = icmp eq i32 %bcmp5, 0
  br i1 %.not6, label %11, label %14

11:                                               ; preds = %8
  call void @_ZN12MetroHash12810InitializeEm(ptr noundef nonnull align 8 dereferenceable(72) %2, i64 noundef 1)
  %12 = load ptr, ptr @_ZN12MetroHash12811test_stringE, align 8, !tbaa !5
  %13 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %12) #6
  call void @_ZN12MetroHash1286UpdateEPKhm(ptr noundef nonnull align 8 dereferenceable(72) %2, ptr noundef %12, i64 noundef %13)
  call void @_ZN12MetroHash1288FinalizeEPh(ptr noundef nonnull align 8 dereferenceable(72) %2, ptr noundef nonnull %1)
  %bcmp7 = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %1, ptr noundef nonnull dereferenceable(16) @_ZN12MetroHash12811test_seed_1E, i64 16)
  %.not8 = icmp eq i32 %bcmp7, 0
  br label %14

14:                                               ; preds = %11, %8
  %.0 = phi i1 [ false, %8 ], [ %.not8, %11 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %2) #5
  br label %15

15:                                               ; preds = %5, %0, %14
  %.1 = phi i1 [ %.0, %14 ], [ false, %0 ], [ false, %5 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #5
  ret i1 %.1
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

declare void @_ZN12MetroHash128C1Em(ptr, i64) local_unnamed_addr

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #4

attributes #0 = { mustprogress 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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nofree nounwind willreturn memory(argmem: read) }
attributes #5 = { nounwind }
attributes #6 = { 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++ TBAA"}


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