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

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@__PRETTY_FUNCTION__.zhash_keys = external hidden unnamed_addr constant [38 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @zhash_iterator_init_const(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @zhash_iterator_next_volatile(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @zhash_keys(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.zhash_iterator, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  br label %11

10:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 409, ptr noundef @__PRETTY_FUNCTION__.zhash_keys) #4
  unreachable

11:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.zhash, ptr %12, i32 0, i32 0
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = call ptr @zarray_create(i64 noundef %14)
  store ptr %15, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #5
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  call void @zhash_iterator_init_const(ptr noundef %16, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  br label %17

17:                                               ; preds = %20, %11
  %18 = call i32 @zhash_iterator_next_volatile(ptr noundef %4, ptr noundef %5, ptr noundef %6)
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  call void @zarray_add(ptr noundef %21, ptr noundef %22)
  br label %17, !llvm.loop !13

23:                                               ; preds = %17
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret ptr %24
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @zarray_create(i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @zarray_add(ptr noundef, ptr noundef) #3

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

%struct.zhash_iterator = type { ptr, ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@__PRETTY_FUNCTION__.zhash_keys = external hidden unnamed_addr constant [38 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @zhash_iterator_init_const(ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @zhash_keys(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.zhash_iterator, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 409, ptr noundef nonnull @__PRETTY_FUNCTION__.zhash_keys) #4
  unreachable

6:                                                ; preds = %1
  %7 = load i64, ptr %0, align 8, !tbaa !5
  %8 = tail call ptr @zarray_create(i64 noundef %7)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #5
  call void @zhash_iterator_init_const(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %9 = call i32 @zhash_iterator_next_volatile(ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %.not56 = icmp eq i32 %9, 0
  br i1 %.not56, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6, %.lr.ph
  %10 = load ptr, ptr %3, align 8, !tbaa !12
  call void @zarray_add(ptr noundef %8, ptr noundef %10)
  %11 = call i32 @zhash_iterator_next_volatile(ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %.not5 = icmp eq i32 %11, 0
  br i1 %.not5, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  ret ptr %8
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @zarray_create(i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @zarray_add(ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #4 = { noreturn nounwind }
attributes #5 = { 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 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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