; LLVM IR from openxrlab/xrsfm :: 3rdparty/apriltag/common (zhash)

; 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.zhash = type { i64, i64, i32, ptr, ptr, i32, ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.zhash_copy = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @zhash_create_capacity(i64 noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; 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: nounwind uwtable
declare dso_local i32 @zhash_put(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @zhash_copy(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.zhash, ptr %7, i32 0, i32 0
  %9 = load i64, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.zhash, ptr %10, i32 0, i32 1
  %12 = load i64, ptr %11, align 8, !tbaa !13
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.zhash, ptr %13, i32 0, i32 3
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.zhash, ptr %16, i32 0, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.zhash, ptr %19, i32 0, i32 5
  %21 = load i32, ptr %20, align 8, !tbaa !16
  %22 = call ptr @zhash_create_capacity(i64 noundef %9, i64 noundef %12, ptr noundef %15, ptr noundef %18, i32 noundef %21)
  store ptr %22, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !17
  br label %23

23:                                               ; preds = %78, %1
  %24 = load i32, ptr %4, align 4, !tbaa !17
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.zhash, ptr %25, i32 0, i32 7
  %27 = load i32, ptr %26, align 8, !tbaa !18
  %28 = icmp slt i32 %24, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %81

30:                                               ; preds = %23
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.zhash, ptr %31, i32 0, i32 6
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  %34 = load i32, ptr %4, align 4, !tbaa !17
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.zhash, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 8, !tbaa !20
  %38 = mul nsw i32 %34, %37
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %33, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !21
  %42 = icmp ne i8 %41, 0
  br i1 %42, label %43, label %77

43:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.zhash, ptr %44, i32 0, i32 6
  %46 = load ptr, ptr %45, align 8, !tbaa !19
  %47 = load i32, ptr %4, align 4, !tbaa !17
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.zhash, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %49, align 8, !tbaa !20
  %51 = mul nsw i32 %47, %50
  %52 = add nsw i32 %51, 1
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i8, ptr %46, i64 %53
  store ptr %54, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.zhash, ptr %55, i32 0, i32 6
  %57 = load ptr, ptr %56, align 8, !tbaa !19
  %58 = load i32, ptr %4, align 4, !tbaa !17
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.zhash, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %60, align 8, !tbaa !20
  %62 = mul nsw i32 %58, %61
  %63 = add nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.zhash, ptr %65, i32 0, i32 0
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = add i64 %64, %67
  %69 = getelementptr inbounds i8, ptr %57, i64 %68
  store ptr %69, ptr %6, align 8, !tbaa !5
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = call i32 @zhash_put(ptr noundef %70, ptr noundef %71, ptr noundef %72, ptr noundef null, ptr noundef null)
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %43
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 256, ptr noundef @__PRETTY_FUNCTION__.zhash_copy) #4
  unreachable

76:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %77

77:                                               ; preds = %76, %30
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %4, align 4, !tbaa !17
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %4, align 4, !tbaa !17
  br label %23, !llvm.loop !22

81:                                               ; preds = %29
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %82
}

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 = { noreturn nounwind "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 }
attributes #4 = { noreturn 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 0}
!10 = !{!"zhash", !11, i64 0, !11, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !6, i64 48, !12, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !6, i64 24}
!15 = !{!10, !6, i64 32}
!16 = !{!10, !12, i64 40}
!17 = !{!12, !12, i64 0}
!18 = !{!10, !12, i64 56}
!19 = !{!10, !6, i64 48}
!20 = !{!10, !12, i64 16}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.zhash_copy = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @zhash_create_capacity(i64 noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @zhash_put(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @zhash_copy(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = load i32, ptr %9, align 8, !tbaa !15
  %11 = tail call ptr @zhash_create_capacity(i64 noundef %2, i64 noundef %4, ptr noundef %6, ptr noundef %8, i32 noundef %10)
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = load i32, ptr %12, align 8, !tbaa !16
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  br label %17

._crit_edge:                                      ; preds = %34, %1
  ret ptr %11

17:                                               ; preds = %.lr.ph, %34
  %18 = phi i32 [ %13, %.lr.ph ], [ %35, %34 ]
  %.022 = phi i32 [ 0, %.lr.ph ], [ %36, %34 ]
  %19 = load ptr, ptr %15, align 8, !tbaa !17
  %20 = load i32, ptr %16, align 8, !tbaa !18
  %21 = mul nsw i32 %20, %.022
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %19, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !19
  %.not = icmp eq i8 %24, 0
  br i1 %.not, label %34, label %25

25:                                               ; preds = %17
  %26 = add nsw i32 %21, 1
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %19, i64 %27
  %29 = load i64, ptr %0, align 8, !tbaa !5
  %30 = getelementptr i8, ptr %19, i64 %29
  %31 = getelementptr i8, ptr %30, i64 %27
  %32 = tail call i32 @zhash_put(ptr noundef %11, ptr noundef %28, ptr noundef %31, ptr noundef null, ptr noundef null)
  %.not21 = icmp eq i32 %32, 0
  br i1 %.not21, label %._crit_edge23, label %33

._crit_edge23:                                    ; preds = %25
  %.pre = load i32, ptr %12, align 8, !tbaa !16
  br label %34

33:                                               ; preds = %25
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 256, ptr noundef nonnull @__PRETTY_FUNCTION__.zhash_copy) #2
  unreachable

34:                                               ; preds = %._crit_edge23, %17
  %35 = phi i32 [ %.pre, %._crit_edge23 ], [ %18, %17 ]
  %36 = add nuw nsw i32 %.022, 1
  %37 = icmp slt i32 %36, %35
  br i1 %37, label %17, label %._crit_edge, !llvm.loop !20
}

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 = { noreturn nounwind "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 = { noreturn 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, !7, i64 0}
!6 = !{!"zhash", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !11, i64 32, !10, i64 40, !11, i64 48, !10, i64 56}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !11, i64 24}
!14 = !{!6, !11, i64 32}
!15 = !{!6, !10, i64 40}
!16 = !{!6, !10, i64 56}
!17 = !{!6, !11, i64 48}
!18 = !{!6, !10, i64 16}
!19 = !{!8, !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass