; LLVM IR from xtruan/FlipBIP :: lib/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.bignum256 = type { [9 x i32] }
%struct._HMAC_SHA512_CTX = type { [128 x i8], %struct._SHA512_CTX }
%struct._SHA512_CTX = type { [8 x i64], [2 x i64], [16 x i64] }
%struct.HDNode = type { i32, i32, [32 x i8], [32 x i8], [32 x i8], [33 x i8], ptr }
%struct.curve_info = type { ptr, ptr, i32, i32, i32, i32 }
%struct.ecdsa_curve = type { %struct.bignum256, %struct.curve_point, %struct.bignum256, %struct.bignum256, i32, %struct.bignum256 }
%struct.curve_point = type { %struct.bignum256, %struct.bignum256 }

@hdnode_private_ckd_bip32.data = external hidden global [37 x i8], align 16
@hdnode_private_ckd_bip32.I = external hidden global [64 x i8], align 16
@hdnode_private_ckd_bip32.a = external hidden global %struct.bignum256, align 4
@hdnode_private_ckd_bip32.b = external hidden global %struct.bignum256, align 4
@hdnode_private_ckd_bip32.ctx = external hidden global %struct._HMAC_SHA512_CTX, align 8

; 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

declare void @bn_read_be(ptr noundef, ptr noundef) #2

declare i32 @bn_is_zero(ptr noundef) #2

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

declare void @hmac_sha512_Init(ptr noundef, ptr noundef, i32 noundef) #2

declare void @hmac_sha512_Update(ptr noundef, ptr noundef, i32 noundef) #2

declare void @hmac_sha512_Final(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @hdnode_private_ckd_bip32(ptr noundef %0, i32 noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = and i32 %8, -2147483648
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %15

11:                                               ; preds = %2
  store i8 0, ptr @hdnode_private_ckd_bip32.data, align 16, !tbaa !11
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.HDNode, ptr %12, i32 0, i32 3
  %14 = getelementptr inbounds [32 x i8], ptr %13, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.data, i64 1), ptr align 8 %14, i64 32, i1 false)
  br label %32

15:                                               ; preds = %2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.HDNode, ptr %16, i32 0, i32 6
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = getelementptr inbounds %struct.curve_info, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %15
  store i32 0, ptr %3, align 4
  br label %101

23:                                               ; preds = %15
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call i32 @hdnode_fill_public_key(ptr noundef %24)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  store i32 0, ptr %3, align 4
  br label %101

28:                                               ; preds = %23
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.HDNode, ptr %29, i32 0, i32 5
  %31 = getelementptr inbounds [33 x i8], ptr %30, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @hdnode_private_ckd_bip32.data, ptr align 8 %31, i64 33, i1 false)
  br label %32

32:                                               ; preds = %28, %11
  %33 = load i32, ptr %5, align 4, !tbaa !9
  call void @write_be(ptr noundef getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.data, i64 33), i32 noundef %33)
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.HDNode, ptr %34, i32 0, i32 3
  %36 = getelementptr inbounds [32 x i8], ptr %35, i64 0, i64 0
  call void @bn_read_be(ptr noundef %36, ptr noundef @hdnode_private_ckd_bip32.a)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.HDNode, ptr %37, i32 0, i32 2
  %39 = getelementptr inbounds [32 x i8], ptr %38, i64 0, i64 0
  call void @hmac_sha512_Init(ptr noundef @hdnode_private_ckd_bip32.ctx, ptr noundef %39, i32 noundef 32)
  call void @hmac_sha512_Update(ptr noundef @hdnode_private_ckd_bip32.ctx, ptr noundef @hdnode_private_ckd_bip32.data, i32 noundef 37)
  call void @hmac_sha512_Final(ptr noundef @hdnode_private_ckd_bip32.ctx, ptr noundef @hdnode_private_ckd_bip32.I)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.HDNode, ptr %40, i32 0, i32 6
  %42 = load ptr, ptr %41, align 8, !tbaa !12
  %43 = getelementptr inbounds %struct.curve_info, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %83

46:                                               ; preds = %32
  br label %47

47:                                               ; preds = %81, %46
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #5
  store i8 0, ptr %6, align 1, !tbaa !16
  call void @bn_read_be(ptr noundef @hdnode_private_ckd_bip32.I, ptr noundef @hdnode_private_ckd_bip32.b)
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.HDNode, ptr %48, i32 0, i32 6
  %50 = load ptr, ptr %49, align 8, !tbaa !12
  %51 = getelementptr inbounds %struct.curve_info, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !14
  %53 = getelementptr inbounds %struct.ecdsa_curve, ptr %52, i32 0, i32 2
  %54 = call i32 @bn_is_less(ptr noundef @hdnode_private_ckd_bip32.b, ptr noundef %53)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %57, label %56

56:                                               ; preds = %47
  store i8 1, ptr %6, align 1, !tbaa !16
  br label %68

57:                                               ; preds = %47
  call void @bn_add(ptr noundef @hdnode_private_ckd_bip32.b, ptr noundef @hdnode_private_ckd_bip32.a)
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.HDNode, ptr %58, i32 0, i32 6
  %60 = load ptr, ptr %59, align 8, !tbaa !12
  %61 = getelementptr inbounds %struct.curve_info, ptr %60, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !14
  %63 = getelementptr inbounds %struct.ecdsa_curve, ptr %62, i32 0, i32 2
  call void @bn_mod(ptr noundef @hdnode_private_ckd_bip32.b, ptr noundef %63)
  %64 = call i32 @bn_is_zero(ptr noundef @hdnode_private_ckd_bip32.b)
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %57
  store i8 1, ptr %6, align 1, !tbaa !16
  br label %67

67:                                               ; preds = %66, %57
  br label %68

68:                                               ; preds = %67, %56
  %69 = load i8, ptr %6, align 1, !tbaa !16, !range !18, !noundef !19
  %70 = trunc i8 %69 to i1
  br i1 %70, label %75, label %71

71:                                               ; preds = %68
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.HDNode, ptr %72, i32 0, i32 3
  %74 = getelementptr inbounds [32 x i8], ptr %73, i64 0, i64 0
  call void @bn_write_be(ptr noundef @hdnode_private_ckd_bip32.b, ptr noundef %74)
  store i32 3, ptr %7, align 4
  br label %79

75:                                               ; preds = %68
  store i8 1, ptr @hdnode_private_ckd_bip32.data, align 16, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.data, i64 1), ptr align 1 getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.I, i64 32), i64 32, i1 false)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.HDNode, ptr %76, i32 0, i32 2
  %78 = getelementptr inbounds [32 x i8], ptr %77, i64 0, i64 0
  call void @hmac_sha512_Init(ptr noundef @hdnode_private_ckd_bip32.ctx, ptr noundef %78, i32 noundef 32)
  call void @hmac_sha512_Update(ptr noundef @hdnode_private_ckd_bip32.ctx, ptr noundef @hdnode_private_ckd_bip32.data, i32 noundef 37)
  call void @hmac_sha512_Final(ptr noundef @hdnode_private_ckd_bip32.ctx, ptr noundef @hdnode_private_ckd_bip32.I)
  store i32 0, ptr %7, align 4
  br label %79

79:                                               ; preds = %75, %71
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  %80 = load i32, ptr %7, align 4
  switch i32 %80, label %103 [
    i32 0, label %81
    i32 3, label %82
  ]

81:                                               ; preds = %79
  br label %47

82:                                               ; preds = %79
  br label %87

83:                                               ; preds = %32
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.HDNode, ptr %84, i32 0, i32 3
  %86 = getelementptr inbounds [32 x i8], ptr %85, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %86, ptr align 16 @hdnode_private_ckd_bip32.I, i64 32, i1 false)
  br label %87

87:                                               ; preds = %83, %82
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.HDNode, ptr %88, i32 0, i32 2
  %90 = getelementptr inbounds [32 x i8], ptr %89, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %90, ptr align 1 getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.I, i64 32), i64 32, i1 false)
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.HDNode, ptr %91, i32 0, i32 0
  %93 = load i32, ptr %92, align 8, !tbaa !20
  %94 = add i32 %93, 1
  store i32 %94, ptr %92, align 8, !tbaa !20
  %95 = load i32, ptr %5, align 4, !tbaa !9
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.HDNode, ptr %96, i32 0, i32 1
  store i32 %95, ptr %97, align 4, !tbaa !21
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.HDNode, ptr %98, i32 0, i32 5
  %100 = getelementptr inbounds [33 x i8], ptr %99, i64 0, i64 0
  call void @memzero(ptr noundef %100, i64 noundef 33)
  call void @memzero(ptr noundef @hdnode_private_ckd_bip32.a, i64 noundef 36)
  call void @memzero(ptr noundef @hdnode_private_ckd_bip32.b, i64 noundef 36)
  call void @memzero(ptr noundef @hdnode_private_ckd_bip32.I, i64 noundef 64)
  call void @memzero(ptr noundef @hdnode_private_ckd_bip32.data, i64 noundef 37)
  store i32 1, ptr %3, align 4
  br label %101

101:                                              ; preds = %87, %27, %22
  %102 = load i32, ptr %3, align 4
  ret i32 %102

103:                                              ; preds = %79
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @write_be(ptr noundef, i32 noundef) #4

declare void @bn_add(ptr noundef, ptr noundef) #2

declare void @bn_mod(ptr noundef, ptr noundef) #2

declare void @bn_write_be(ptr noundef, ptr noundef) #2

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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 144}
!13 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 40, !7, i64 72, !7, i64 104, !6, i64 144}
!14 = !{!15, !6, i64 8}
!15 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!16 = !{!17, !17, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!13, !10, i64 0}
!21 = !{!13, !10, i64 4}


; 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.bignum256 = type { [9 x i32] }
%struct._HMAC_SHA512_CTX = type { [128 x i8], %struct._SHA512_CTX }
%struct._SHA512_CTX = type { [8 x i64], [2 x i64], [16 x i64] }

@hdnode_private_ckd_bip32.data = external hidden global [37 x i8], align 16
@hdnode_private_ckd_bip32.I = external hidden global [64 x i8], align 16
@hdnode_private_ckd_bip32.a = external hidden global %struct.bignum256, align 4
@hdnode_private_ckd_bip32.b = external hidden global %struct.bignum256, align 4
@hdnode_private_ckd_bip32.ctx = external hidden global %struct._HMAC_SHA512_CTX, align 8

; 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

declare void @bn_read_be(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @bn_is_zero(ptr noundef) local_unnamed_addr #1

declare i32 @bn_is_less(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @hmac_sha512_Init(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @hmac_sha512_Update(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @hmac_sha512_Final(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @hdnode_private_ckd_bip32(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %.not = icmp sgt i32 %1, -1
  br i1 %.not, label %5, label %3

3:                                                ; preds = %2
  store i8 0, ptr @hdnode_private_ckd_bip32.data, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.data, i64 1), ptr noundef nonnull align 8 dereferenceable(32) %4, i64 32, i1 false)
  br label %14

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 144
  %7 = load ptr, ptr %6, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %.not23 = icmp eq ptr %9, null
  br i1 %.not23, label %39, label %10

10:                                               ; preds = %5
  %11 = tail call i32 @hdnode_fill_public_key(ptr noundef nonnull %0)
  %.not24 = icmp eq i32 %11, 0
  br i1 %.not24, label %12, label %39

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(33) @hdnode_private_ckd_bip32.data, ptr noundef nonnull align 8 dereferenceable(33) %13, i64 33, i1 false)
  br label %14

14:                                               ; preds = %12, %3
  tail call void @write_be(ptr noundef nonnull getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.data, i64 33), i32 noundef %1)
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @bn_read_be(ptr noundef nonnull %15, ptr noundef nonnull @hdnode_private_ckd_bip32.a) #4
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @hmac_sha512_Init(ptr noundef nonnull @hdnode_private_ckd_bip32.ctx, ptr noundef nonnull %16, i32 noundef 32) #4
  tail call void @hmac_sha512_Update(ptr noundef nonnull @hdnode_private_ckd_bip32.ctx, ptr noundef nonnull @hdnode_private_ckd_bip32.data, i32 noundef 37) #4
  tail call void @hmac_sha512_Final(ptr noundef nonnull @hdnode_private_ckd_bip32.ctx, ptr noundef nonnull @hdnode_private_ckd_bip32.I) #4
  %17 = getelementptr inbounds i8, ptr %0, i64 144
  %18 = load ptr, ptr %17, align 8, !tbaa !8
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %.not25 = icmp eq ptr %20, null
  br i1 %.not25, label %33, label %.preheader

.preheader:                                       ; preds = %14, %32
  tail call void @bn_read_be(ptr noundef nonnull @hdnode_private_ckd_bip32.I, ptr noundef nonnull @hdnode_private_ckd_bip32.b) #4
  %21 = load ptr, ptr %17, align 8, !tbaa !8
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !12
  %24 = getelementptr inbounds i8, ptr %23, i64 108
  %25 = tail call i32 @bn_is_less(ptr noundef nonnull @hdnode_private_ckd_bip32.b, ptr noundef nonnull %24) #4
  %.not26 = icmp eq i32 %25, 0
  br i1 %.not26, label %32, label %26

26:                                               ; preds = %.preheader
  tail call void @bn_add(ptr noundef nonnull @hdnode_private_ckd_bip32.b, ptr noundef nonnull @hdnode_private_ckd_bip32.a) #4
  %27 = load ptr, ptr %17, align 8, !tbaa !8
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  %30 = getelementptr inbounds i8, ptr %29, i64 108
  tail call void @bn_mod(ptr noundef nonnull @hdnode_private_ckd_bip32.b, ptr noundef nonnull %30) #4
  %31 = tail call i32 @bn_is_zero(ptr noundef nonnull @hdnode_private_ckd_bip32.b) #4
  %.not27.not = icmp eq i32 %31, 0
  br i1 %.not27.not, label %.thread, label %32

.thread:                                          ; preds = %26
  tail call void @bn_write_be(ptr noundef nonnull @hdnode_private_ckd_bip32.b, ptr noundef nonnull %15) #4
  br label %34

32:                                               ; preds = %26, %.preheader
  store i8 1, ptr @hdnode_private_ckd_bip32.data, align 16, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.data, i64 1), ptr noundef nonnull align 16 dereferenceable(32) getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.I, i64 32), i64 32, i1 false)
  tail call void @hmac_sha512_Init(ptr noundef nonnull @hdnode_private_ckd_bip32.ctx, ptr noundef nonnull %16, i32 noundef 32) #4
  tail call void @hmac_sha512_Update(ptr noundef nonnull @hdnode_private_ckd_bip32.ctx, ptr noundef nonnull @hdnode_private_ckd_bip32.data, i32 noundef 37) #4
  tail call void @hmac_sha512_Final(ptr noundef nonnull @hdnode_private_ckd_bip32.ctx, ptr noundef nonnull @hdnode_private_ckd_bip32.I) #4
  br label %.preheader

33:                                               ; preds = %14
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %15, ptr noundef nonnull align 16 dereferenceable(32) @hdnode_private_ckd_bip32.I, i64 32, i1 false)
  br label %34

34:                                               ; preds = %.thread, %33
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %16, ptr noundef nonnull align 16 dereferenceable(32) getelementptr inbounds (i8, ptr @hdnode_private_ckd_bip32.I, i64 32), i64 32, i1 false)
  %35 = load i32, ptr %0, align 8, !tbaa !14
  %36 = add i32 %35, 1
  store i32 %36, ptr %0, align 8, !tbaa !14
  %37 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %1, ptr %37, align 4, !tbaa !15
  %38 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @memzero(ptr noundef nonnull %38, i64 noundef 33) #4
  tail call void @memzero(ptr noundef nonnull @hdnode_private_ckd_bip32.a, i64 noundef 36) #4
  tail call void @memzero(ptr noundef nonnull @hdnode_private_ckd_bip32.b, i64 noundef 36) #4
  tail call void @memzero(ptr noundef nonnull @hdnode_private_ckd_bip32.I, i64 noundef 64) #4
  tail call void @memzero(ptr noundef nonnull @hdnode_private_ckd_bip32.data, i64 noundef 37) #4
  br label %39

39:                                               ; preds = %10, %5, %34
  %.022 = phi i32 [ 1, %34 ], [ 0, %5 ], [ 0, %10 ]
  ret i32 %.022
}

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

declare void @bn_add(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @bn_mod(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @bn_write_be(ptr noundef, ptr noundef) local_unnamed_addr #1

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 = { 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !11, i64 144}
!9 = !{!"", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 40, !6, i64 72, !6, i64 104, !11, i64 144}
!10 = !{!"int", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"", !11, i64 0, !11, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!14 = !{!9, !10, i64 0}
!15 = !{!9, !10, i64 4}


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