; LLVM IR from square/subzero :: core/trezor-crypto (bip32)

; 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.HDNode = type { i32, i32, [32 x i8], [32 x i8], [32 x i8], [33 x i8], ptr }
%struct.anon = type { i8, i64, [8 x i32], %struct.HDNode }

@private_ckd_cache_root_set = external hidden global i8, align 1
@private_ckd_cache_root = external hidden global %struct.HDNode, align 8
@private_ckd_cache_index = external hidden global i32, align 4
@private_ckd_cache = external hidden global [10 x %struct.anon], align 16

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare void @memzero(ptr noundef, i64 noundef) #2

; 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
declare dso_local i32 @hdnode_fingerprint(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @hdnode_private_ckd_cached(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %14 = load i64, ptr %8, align 8, !tbaa !9
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %4
  store i32 1, ptr %5, align 4
  br label %174

17:                                               ; preds = %4
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = icmp eq i64 %18, 1
  br i1 %19, label %20, label %36

20:                                               ; preds = %17
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %27

23:                                               ; preds = %20
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call i32 @hdnode_fingerprint(ptr noundef %24)
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %25, ptr %26, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %23, %20
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds i32, ptr %29, i64 0
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %32 = call i32 @hdnode_private_ckd(ptr noundef %28, i32 noundef %31)
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %27
  store i32 0, ptr %5, align 4
  br label %174

35:                                               ; preds = %27
  store i32 1, ptr %5, align 4
  br label %174

36:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  store i8 0, ptr %10, align 1, !tbaa !13
  %37 = load i8, ptr @private_ckd_cache_root_set, align 1, !tbaa !13, !range !15, !noundef !16
  %38 = trunc i8 %37 to i1
  br i1 %38, label %39, label %43

39:                                               ; preds = %36
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = call i32 @memcmp(ptr noundef @private_ckd_cache_root, ptr noundef %40, i64 noundef 152) #6
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %45

43:                                               ; preds = %39, %36
  store i32 0, ptr @private_ckd_cache_index, align 4, !tbaa !11
  call void @memzero(ptr noundef @private_ckd_cache, i64 noundef 2000)
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @private_ckd_cache_root, ptr align 8 %44, i64 152, i1 false)
  store i8 1, ptr @private_ckd_cache_root_set, align 1, !tbaa !13
  br label %99

45:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %95, %45
  %47 = load i32, ptr %11, align 4, !tbaa !11
  %48 = icmp slt i32 %47, 10
  br i1 %48, label %49, label %98

49:                                               ; preds = %46
  %50 = load i32, ptr %11, align 4, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.anon, ptr %52, i32 0, i32 0
  %54 = load i8, ptr %53, align 8, !tbaa !17, !range !15, !noundef !16
  %55 = trunc i8 %54 to i1
  br i1 %55, label %56, label %94

56:                                               ; preds = %49
  %57 = load i32, ptr %11, align 4, !tbaa !11
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %58
  %60 = getelementptr inbounds %struct.anon, ptr %59, i32 0, i32 1
  %61 = load i64, ptr %60, align 8, !tbaa !20
  %62 = load i64, ptr %8, align 8, !tbaa !9
  %63 = sub i64 %62, 1
  %64 = icmp eq i64 %61, %63
  br i1 %64, label %65, label %94

65:                                               ; preds = %56
  %66 = load i32, ptr %11, align 4, !tbaa !11
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.anon, ptr %68, i32 0, i32 2
  %70 = getelementptr inbounds [8 x i32], ptr %69, i64 0, i64 0
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load i64, ptr %8, align 8, !tbaa !9
  %73 = sub i64 %72, 1
  %74 = mul i64 %73, 4
  %75 = call i32 @memcmp(ptr noundef %70, ptr noundef %71, i64 noundef %74) #6
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %94

77:                                               ; preds = %65
  %78 = load i32, ptr %11, align 4, !tbaa !11
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.anon, ptr %80, i32 0, i32 3
  %82 = getelementptr inbounds %struct.HDNode, ptr %81, i32 0, i32 6
  %83 = load ptr, ptr %82, align 8, !tbaa !21
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.HDNode, ptr %84, i32 0, i32 6
  %86 = load ptr, ptr %85, align 8, !tbaa !22
  %87 = icmp eq ptr %83, %86
  br i1 %87, label %88, label %94

88:                                               ; preds = %77
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load i32, ptr %11, align 4, !tbaa !11
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %91
  %93 = getelementptr inbounds %struct.anon, ptr %92, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %89, ptr align 8 %93, i64 152, i1 false)
  store i8 1, ptr %10, align 1, !tbaa !13
  br label %98

94:                                               ; preds = %77, %65, %56, %49
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %11, align 4, !tbaa !11
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %11, align 4, !tbaa !11
  br label %46, !llvm.loop !23

98:                                               ; preds = %88, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %99

99:                                               ; preds = %98, %43
  %100 = load i8, ptr %10, align 1, !tbaa !13, !range !15, !noundef !16
  %101 = trunc i8 %100 to i1
  br i1 %101, label %155, label %102

102:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %103

103:                                              ; preds = %118, %102
  %104 = load i64, ptr %12, align 8, !tbaa !9
  %105 = load i64, ptr %8, align 8, !tbaa !9
  %106 = sub i64 %105, 1
  %107 = icmp ult i64 %104, %106
  br i1 %107, label %108, label %121

108:                                              ; preds = %103
  %109 = load ptr, ptr %6, align 8, !tbaa !5
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = load i64, ptr %12, align 8, !tbaa !9
  %112 = getelementptr inbounds i32, ptr %110, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !11
  %114 = call i32 @hdnode_private_ckd(ptr noundef %109, i32 noundef %113)
  %115 = icmp eq i32 %114, 0
  br i1 %115, label %116, label %117

116:                                              ; preds = %108
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %152

117:                                              ; preds = %108
  br label %118

118:                                              ; preds = %117
  %119 = load i64, ptr %12, align 8, !tbaa !9
  %120 = add i64 %119, 1
  store i64 %120, ptr %12, align 8, !tbaa !9
  br label %103, !llvm.loop !25

121:                                              ; preds = %103
  %122 = load i32, ptr @private_ckd_cache_index, align 4, !tbaa !11
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %123
  call void @memzero(ptr noundef %124, i64 noundef 200)
  %125 = load i32, ptr @private_ckd_cache_index, align 4, !tbaa !11
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %126
  %128 = getelementptr inbounds %struct.anon, ptr %127, i32 0, i32 0
  store i8 1, ptr %128, align 8, !tbaa !17
  %129 = load i64, ptr %8, align 8, !tbaa !9
  %130 = sub i64 %129, 1
  %131 = load i32, ptr @private_ckd_cache_index, align 4, !tbaa !11
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %132
  %134 = getelementptr inbounds %struct.anon, ptr %133, i32 0, i32 1
  store i64 %130, ptr %134, align 8, !tbaa !20
  %135 = load i32, ptr @private_ckd_cache_index, align 4, !tbaa !11
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %136
  %138 = getelementptr inbounds %struct.anon, ptr %137, i32 0, i32 2
  %139 = getelementptr inbounds [8 x i32], ptr %138, i64 0, i64 0
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = load i64, ptr %8, align 8, !tbaa !9
  %142 = sub i64 %141, 1
  %143 = mul i64 %142, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %139, ptr align 4 %140, i64 %143, i1 false)
  %144 = load i32, ptr @private_ckd_cache_index, align 4, !tbaa !11
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %145
  %147 = getelementptr inbounds %struct.anon, ptr %146, i32 0, i32 3
  %148 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %147, ptr align 8 %148, i64 152, i1 false)
  %149 = load i32, ptr @private_ckd_cache_index, align 4, !tbaa !11
  %150 = add nsw i32 %149, 1
  %151 = srem i32 %150, 10
  store i32 %151, ptr @private_ckd_cache_index, align 4, !tbaa !11
  store i32 0, ptr %13, align 4
  br label %152

152:                                              ; preds = %121, %116
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %153 = load i32, ptr %13, align 4
  switch i32 %153, label %173 [
    i32 0, label %154
  ]

154:                                              ; preds = %152
  br label %155

155:                                              ; preds = %154, %99
  %156 = load ptr, ptr %9, align 8, !tbaa !5
  %157 = icmp ne ptr %156, null
  br i1 %157, label %158, label %162

158:                                              ; preds = %155
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  %160 = call i32 @hdnode_fingerprint(ptr noundef %159)
  %161 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %160, ptr %161, align 4, !tbaa !11
  br label %162

162:                                              ; preds = %158, %155
  %163 = load ptr, ptr %6, align 8, !tbaa !5
  %164 = load ptr, ptr %7, align 8, !tbaa !5
  %165 = load i64, ptr %8, align 8, !tbaa !9
  %166 = sub i64 %165, 1
  %167 = getelementptr inbounds i32, ptr %164, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !11
  %169 = call i32 @hdnode_private_ckd(ptr noundef %163, i32 noundef %168)
  %170 = icmp eq i32 %169, 0
  br i1 %170, label %171, label %172

171:                                              ; preds = %162
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %173

172:                                              ; preds = %162
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %173

173:                                              ; preds = %172, %171, %152
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  br label %174

174:                                              ; preds = %173, %35, %34, %16
  %175 = load i32, ptr %5, align 4
  ret i32 %175
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 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 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !14, i64 0}
!18 = !{!"", !14, i64 0, !10, i64 8, !7, i64 16, !19, i64 48}
!19 = !{!"", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 40, !7, i64 72, !7, i64 104, !6, i64 144}
!20 = !{!18, !10, i64 8}
!21 = !{!18, !6, i64 192}
!22 = !{!19, !6, i64 144}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


; 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.HDNode = type { i32, i32, [32 x i8], [32 x i8], [32 x i8], [33 x i8], ptr }
%struct.anon = type { i8, i64, [8 x i32], %struct.HDNode }

@private_ckd_cache_root_set = external hidden local_unnamed_addr global i8, align 1
@private_ckd_cache_root = external hidden global %struct.HDNode, align 8
@private_ckd_cache_index = external hidden local_unnamed_addr global i32, align 4
@private_ckd_cache = external hidden global [10 x %struct.anon], align 16

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

declare void @memzero(ptr noundef, i64 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @hdnode_private_ckd_cached(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #2 {
  switch i64 %2, label %12 [
    i64 0, label %.thread
    i64 1, label %5
  ]

5:                                                ; preds = %4
  %.not52 = icmp eq ptr %3, null
  br i1 %.not52, label %8, label %6

6:                                                ; preds = %5
  %7 = tail call i32 @hdnode_fingerprint(ptr noundef %0)
  store i32 %7, ptr %3, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %6, %5
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = tail call i32 @hdnode_private_ckd(ptr noundef %0, i32 noundef %9)
  %11 = icmp ne i32 %10, 0
  br label %.thread

12:                                               ; preds = %4
  %13 = load i8, ptr @private_ckd_cache_root_set, align 1, !tbaa !9, !range !11, !noundef !12
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %15, label %.critedge

15:                                               ; preds = %12
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(152) @private_ckd_cache_root, ptr noundef nonnull dereferenceable(152) %0, i64 152)
  %.not = icmp eq i32 %bcmp, 0
  br i1 %.not, label %.preheader, label %.critedge

.preheader:                                       ; preds = %15
  %16 = add i64 %2, -1
  %17 = shl i64 %16, 2
  %18 = getelementptr inbounds i8, ptr %0, i64 144
  %19 = load i8, ptr @private_ckd_cache, align 16, !tbaa !13, !range !11, !noundef !12
  %20 = trunc nuw i8 %19 to i1
  %21 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 8), align 8
  %22 = icmp eq i64 %21, %16
  %or.cond = select i1 %20, i1 %22, i1 false
  br i1 %or.cond, label %23, label %31

.critedge:                                        ; preds = %15, %12
  store i32 0, ptr @private_ckd_cache_index, align 4, !tbaa !5
  tail call void @memzero(ptr noundef nonnull @private_ckd_cache, i64 noundef 2000) #4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(152) @private_ckd_cache_root, ptr noundef nonnull align 8 dereferenceable(152) %0, i64 152, i1 false)
  store i8 1, ptr @private_ckd_cache_root_set, align 1, !tbaa !9
  %.pre = add i64 %2, -1
  br label %.lr.ph.preheader

23:                                               ; preds = %.preheader
  %bcmp49 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 16), ptr %1, i64 %17)
  %24 = icmp eq i32 %bcmp49, 0
  br i1 %24, label %25, label %31

25:                                               ; preds = %23
  %26 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 192), align 16, !tbaa !18
  %27 = load ptr, ptr %18, align 8, !tbaa !19
  %28 = icmp eq ptr %26, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %126, %115, %104, %93, %82, %71, %60, %49, %38, %25
  %.lcssa = phi ptr [ @private_ckd_cache, %25 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 200), %38 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 400), %49 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 600), %60 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 800), %71 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1000), %82 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1200), %93 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1400), %104 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1600), %115 ], [ getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1800), %126 ]
  %30 = getelementptr inbounds i8, ptr %.lcssa, i64 48
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef nonnull align 8 dereferenceable(152) %30, i64 152, i1 false)
  br label %148

31:                                               ; preds = %.preheader, %23, %25
  %32 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 200), align 8, !tbaa !13, !range !11, !noundef !12
  %33 = trunc nuw i8 %32 to i1
  %34 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 208), align 16
  %35 = icmp eq i64 %34, %16
  %or.cond65 = select i1 %33, i1 %35, i1 false
  br i1 %or.cond65, label %36, label %42

36:                                               ; preds = %31
  %bcmp49.1 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 216), ptr %1, i64 %17)
  %37 = icmp eq i32 %bcmp49.1, 0
  br i1 %37, label %38, label %42

38:                                               ; preds = %36
  %39 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 392), align 8, !tbaa !18
  %40 = load ptr, ptr %18, align 8, !tbaa !19
  %41 = icmp eq ptr %39, %40
  br i1 %41, label %29, label %42

42:                                               ; preds = %38, %36, %31
  %43 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 400), align 16, !tbaa !13, !range !11, !noundef !12
  %44 = trunc nuw i8 %43 to i1
  %45 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 408), align 8
  %46 = icmp eq i64 %45, %16
  %or.cond67 = select i1 %44, i1 %46, i1 false
  br i1 %or.cond67, label %47, label %53

47:                                               ; preds = %42
  %bcmp49.2 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 416), ptr %1, i64 %17)
  %48 = icmp eq i32 %bcmp49.2, 0
  br i1 %48, label %49, label %53

49:                                               ; preds = %47
  %50 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 592), align 16, !tbaa !18
  %51 = load ptr, ptr %18, align 8, !tbaa !19
  %52 = icmp eq ptr %50, %51
  br i1 %52, label %29, label %53

53:                                               ; preds = %49, %47, %42
  %54 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 600), align 8, !tbaa !13, !range !11, !noundef !12
  %55 = trunc nuw i8 %54 to i1
  %56 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 608), align 16
  %57 = icmp eq i64 %56, %16
  %or.cond69 = select i1 %55, i1 %57, i1 false
  br i1 %or.cond69, label %58, label %64

58:                                               ; preds = %53
  %bcmp49.3 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 616), ptr %1, i64 %17)
  %59 = icmp eq i32 %bcmp49.3, 0
  br i1 %59, label %60, label %64

60:                                               ; preds = %58
  %61 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 792), align 8, !tbaa !18
  %62 = load ptr, ptr %18, align 8, !tbaa !19
  %63 = icmp eq ptr %61, %62
  br i1 %63, label %29, label %64

64:                                               ; preds = %60, %58, %53
  %65 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 800), align 16, !tbaa !13, !range !11, !noundef !12
  %66 = trunc nuw i8 %65 to i1
  %67 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 808), align 8
  %68 = icmp eq i64 %67, %16
  %or.cond71 = select i1 %66, i1 %68, i1 false
  br i1 %or.cond71, label %69, label %75

69:                                               ; preds = %64
  %bcmp49.4 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 816), ptr %1, i64 %17)
  %70 = icmp eq i32 %bcmp49.4, 0
  br i1 %70, label %71, label %75

71:                                               ; preds = %69
  %72 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 992), align 16, !tbaa !18
  %73 = load ptr, ptr %18, align 8, !tbaa !19
  %74 = icmp eq ptr %72, %73
  br i1 %74, label %29, label %75

75:                                               ; preds = %71, %69, %64
  %76 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1000), align 8, !tbaa !13, !range !11, !noundef !12
  %77 = trunc nuw i8 %76 to i1
  %78 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1008), align 16
  %79 = icmp eq i64 %78, %16
  %or.cond73 = select i1 %77, i1 %79, i1 false
  br i1 %or.cond73, label %80, label %86

80:                                               ; preds = %75
  %bcmp49.5 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1016), ptr %1, i64 %17)
  %81 = icmp eq i32 %bcmp49.5, 0
  br i1 %81, label %82, label %86

82:                                               ; preds = %80
  %83 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1192), align 8, !tbaa !18
  %84 = load ptr, ptr %18, align 8, !tbaa !19
  %85 = icmp eq ptr %83, %84
  br i1 %85, label %29, label %86

86:                                               ; preds = %82, %80, %75
  %87 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1200), align 16, !tbaa !13, !range !11, !noundef !12
  %88 = trunc nuw i8 %87 to i1
  %89 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1208), align 8
  %90 = icmp eq i64 %89, %16
  %or.cond75 = select i1 %88, i1 %90, i1 false
  br i1 %or.cond75, label %91, label %97

91:                                               ; preds = %86
  %bcmp49.6 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1216), ptr %1, i64 %17)
  %92 = icmp eq i32 %bcmp49.6, 0
  br i1 %92, label %93, label %97

93:                                               ; preds = %91
  %94 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1392), align 16, !tbaa !18
  %95 = load ptr, ptr %18, align 8, !tbaa !19
  %96 = icmp eq ptr %94, %95
  br i1 %96, label %29, label %97

97:                                               ; preds = %93, %91, %86
  %98 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1400), align 8, !tbaa !13, !range !11, !noundef !12
  %99 = trunc nuw i8 %98 to i1
  %100 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1408), align 16
  %101 = icmp eq i64 %100, %16
  %or.cond77 = select i1 %99, i1 %101, i1 false
  br i1 %or.cond77, label %102, label %108

102:                                              ; preds = %97
  %bcmp49.7 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1416), ptr %1, i64 %17)
  %103 = icmp eq i32 %bcmp49.7, 0
  br i1 %103, label %104, label %108

104:                                              ; preds = %102
  %105 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1592), align 8, !tbaa !18
  %106 = load ptr, ptr %18, align 8, !tbaa !19
  %107 = icmp eq ptr %105, %106
  br i1 %107, label %29, label %108

108:                                              ; preds = %104, %102, %97
  %109 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1600), align 16, !tbaa !13, !range !11, !noundef !12
  %110 = trunc nuw i8 %109 to i1
  %111 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1608), align 8
  %112 = icmp eq i64 %111, %16
  %or.cond79 = select i1 %110, i1 %112, i1 false
  br i1 %or.cond79, label %113, label %119

113:                                              ; preds = %108
  %bcmp49.8 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1616), ptr %1, i64 %17)
  %114 = icmp eq i32 %bcmp49.8, 0
  br i1 %114, label %115, label %119

115:                                              ; preds = %113
  %116 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1792), align 16, !tbaa !18
  %117 = load ptr, ptr %18, align 8, !tbaa !19
  %118 = icmp eq ptr %116, %117
  br i1 %118, label %29, label %119

119:                                              ; preds = %115, %113, %108
  %120 = load i8, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1800), align 8, !tbaa !13, !range !11, !noundef !12
  %121 = trunc nuw i8 %120 to i1
  %122 = load i64, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1808), align 16
  %123 = icmp eq i64 %122, %16
  %or.cond81 = select i1 %121, i1 %123, i1 false
  br i1 %or.cond81, label %124, label %.lr.ph.preheader

124:                                              ; preds = %119
  %bcmp49.9 = tail call i32 @bcmp(ptr nonnull getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1816), ptr %1, i64 %17)
  %125 = icmp eq i32 %bcmp49.9, 0
  br i1 %125, label %126, label %.lr.ph.preheader

126:                                              ; preds = %124
  %127 = load ptr, ptr getelementptr inbounds (i8, ptr @private_ckd_cache, i64 1992), align 8, !tbaa !18
  %128 = load ptr, ptr %18, align 8, !tbaa !19
  %129 = icmp eq ptr %127, %128
  br i1 %129, label %29, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.critedge, %126, %124, %119
  %.pre-phi = phi i64 [ %.pre, %.critedge ], [ %16, %126 ], [ %16, %124 ], [ %16, %119 ]
  br label %.lr.ph

130:                                              ; preds = %.lr.ph
  %131 = add nuw i64 %.03960, 1
  %exitcond.not = icmp eq i64 %131, %.pre-phi
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !20

.lr.ph:                                           ; preds = %.lr.ph.preheader, %130
  %.03960 = phi i64 [ %131, %130 ], [ 0, %.lr.ph.preheader ]
  %132 = getelementptr inbounds i32, ptr %1, i64 %.03960
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = tail call i32 @hdnode_private_ckd(ptr noundef %0, i32 noundef %133)
  %135 = icmp eq i32 %134, 0
  br i1 %135, label %.thread, label %130

._crit_edge:                                      ; preds = %130
  %136 = load i32, ptr @private_ckd_cache_index, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %137
  tail call void @memzero(ptr noundef nonnull %138, i64 noundef 200) #4
  %139 = load i32, ptr @private_ckd_cache_index, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %140
  store i8 1, ptr %141, align 8, !tbaa !13
  %142 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %140, i32 1
  store i64 %.pre-phi, ptr %142, align 8, !tbaa !22
  %143 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %140, i32 2
  %144 = shl i64 %.pre-phi, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %143, ptr nonnull align 4 %1, i64 %144, i1 false)
  %145 = getelementptr inbounds [10 x %struct.anon], ptr @private_ckd_cache, i64 0, i64 %140, i32 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(152) %145, ptr noundef nonnull align 8 dereferenceable(152) %0, i64 152, i1 false)
  %146 = add nsw i32 %139, 1
  %147 = srem i32 %146, 10
  store i32 %147, ptr @private_ckd_cache_index, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %._crit_edge, %29
  %.not51 = icmp eq ptr %3, null
  br i1 %.not51, label %151, label %149

149:                                              ; preds = %148
  %150 = tail call i32 @hdnode_fingerprint(ptr noundef nonnull %0)
  store i32 %150, ptr %3, align 4, !tbaa !5
  br label %151

151:                                              ; preds = %149, %148
  %152 = getelementptr i32, ptr %1, i64 %2
  %153 = getelementptr i8, ptr %152, i64 -4
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = tail call i32 @hdnode_private_ckd(ptr noundef nonnull %0, i32 noundef %154)
  %156 = icmp ne i32 %155, 0
  br label %.thread

.thread:                                          ; preds = %.lr.ph, %151, %8, %4
  %.2.shrunk = phi i1 [ true, %4 ], [ %11, %8 ], [ %156, %151 ], [ false, %.lr.ph ]
  %.2 = zext i1 %.2.shrunk to i32
  ret i32 %.2
}

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

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #4 = { 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 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !15, i64 8, !7, i64 16, !16, i64 48}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !6, i64 0, !6, i64 4, !7, i64 8, !7, i64 40, !7, i64 72, !7, i64 104, !17, i64 144}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!14, !17, i64 192}
!19 = !{!16, !17, i64 144}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!14, !15, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass