; LLVM IR from trustwallet/wallet-core :: trezor-crypto/crypto (cardano)

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

@ed25519_cardano_info = external dso_local constant %struct.curve_info, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @hdnode_private_ckd_cardano(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca [69 x i8], align 16
  %8 = alloca [64 x i8], align 16
  %9 = alloca [64 x i8], align 16
  %10 = alloca [64 x i8], align 16
  %11 = alloca i32, align 4
  %12 = alloca %struct._HMAC_SHA512_CTX, align 8
  %13 = alloca [32 x i8], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.HDNode, ptr %14, i32 0, i32 6
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp ne ptr %16, @ed25519_cardano_info
  br i1 %17, label %18, label %19

18:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %139

19:                                               ; preds = %2
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.HDNode, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = icmp uge i32 %22, 1048576
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  store i32 0, ptr %3, align 4
  br label %139

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 32, ptr %6, align 4, !tbaa !9
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = and i32 %26, -2147483648
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  store i32 64, ptr %6, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %29, %25
  call void @llvm.lifetime.start.p0(i64 69, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %10) #5
  %31 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %31, i64 %33
  %35 = getelementptr inbounds i8, ptr %34, i64 1
  %36 = load i32, ptr %5, align 4, !tbaa !9
  call void @write_le(ptr noundef %35, i32 noundef %36)
  %37 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.HDNode, ptr %38, i32 0, i32 3
  %40 = getelementptr inbounds [32 x i8], ptr %39, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %37, ptr align 8 %40, i64 32, i1 false)
  %41 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %42 = getelementptr inbounds i8, ptr %41, i64 32
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.HDNode, ptr %43, i32 0, i32 4
  %45 = getelementptr inbounds [32 x i8], ptr %44, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %42, ptr align 8 %45, i64 32, i1 false)
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 64
  br i1 %47, label %48, label %61

48:                                               ; preds = %30
  %49 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  store i8 0, ptr %49, align 16, !tbaa !14
  %50 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  %51 = getelementptr inbounds i8, ptr %50, i64 1
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.HDNode, ptr %52, i32 0, i32 3
  %54 = getelementptr inbounds [32 x i8], ptr %53, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %51, ptr align 8 %54, i64 32, i1 false)
  %55 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  %56 = getelementptr inbounds i8, ptr %55, i64 1
  %57 = getelementptr inbounds i8, ptr %56, i64 32
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.HDNode, ptr %58, i32 0, i32 4
  %60 = getelementptr inbounds [32 x i8], ptr %59, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %57, ptr align 8 %60, i64 32, i1 false)
  br label %74

61:                                               ; preds = %30
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = call i32 @hdnode_fill_public_key(ptr noundef %62)
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %61
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %138

66:                                               ; preds = %61
  %67 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  store i8 2, ptr %67, align 16, !tbaa !14
  %68 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  %69 = getelementptr inbounds i8, ptr %68, i64 1
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.HDNode, ptr %70, i32 0, i32 5
  %72 = getelementptr inbounds [33 x i8], ptr %71, i64 0, i64 0
  %73 = getelementptr inbounds i8, ptr %72, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %69, ptr align 1 %73, i64 32, i1 false)
  br label %74

74:                                               ; preds = %66, %48
  call void @llvm.lifetime.start.p0(i64 336, ptr %12) #5
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.HDNode, ptr %75, i32 0, i32 2
  %77 = getelementptr inbounds [32 x i8], ptr %76, i64 0, i64 0
  call void @hmac_sha512_Init(ptr noundef %12, ptr noundef %77, i32 noundef 32)
  %78 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  %79 = load i32, ptr %6, align 4, !tbaa !9
  %80 = add nsw i32 1, %79
  %81 = add nsw i32 %80, 4
  call void @hmac_sha512_Update(ptr noundef %12, ptr noundef %78, i32 noundef %81)
  %82 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void @hmac_sha512_Final(ptr noundef %12, ptr noundef %82)
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #5
  %83 = getelementptr inbounds [32 x i8], ptr %13, i64 0, i64 0
  call void @memzero(ptr noundef %83, i64 noundef 32)
  %84 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %85 = getelementptr inbounds [32 x i8], ptr %13, i64 0, i64 0
  call void @scalar_multiply8(ptr noundef %84, i32 noundef 28, ptr noundef %85)
  %86 = getelementptr inbounds [32 x i8], ptr %13, i64 0, i64 0
  %87 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %88 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  call void @scalar_add_256bits(ptr noundef %86, ptr noundef %87, ptr noundef %88)
  %89 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %90 = getelementptr inbounds i8, ptr %89, i64 32
  %91 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %92 = getelementptr inbounds i8, ptr %91, i64 32
  %93 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  %94 = getelementptr inbounds i8, ptr %93, i64 32
  call void @scalar_add_256bits(ptr noundef %90, ptr noundef %92, ptr noundef %94)
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.HDNode, ptr %95, i32 0, i32 3
  %97 = getelementptr inbounds [32 x i8], ptr %96, i64 0, i64 0
  %98 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %97, ptr align 16 %98, i64 32, i1 false)
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.HDNode, ptr %99, i32 0, i32 4
  %101 = getelementptr inbounds [32 x i8], ptr %100, i64 0, i64 0
  %102 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  %103 = getelementptr inbounds i8, ptr %102, i64 32
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %101, ptr align 1 %103, i64 32, i1 false)
  %104 = load i32, ptr %6, align 4, !tbaa !9
  %105 = icmp eq i32 %104, 64
  br i1 %105, label %106, label %108

106:                                              ; preds = %74
  %107 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  store i8 1, ptr %107, align 16, !tbaa !14
  br label %110

108:                                              ; preds = %74
  %109 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  store i8 3, ptr %109, align 16, !tbaa !14
  br label %110

110:                                              ; preds = %108, %106
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.HDNode, ptr %111, i32 0, i32 2
  %113 = getelementptr inbounds [32 x i8], ptr %112, i64 0, i64 0
  call void @hmac_sha512_Init(ptr noundef %12, ptr noundef %113, i32 noundef 32)
  %114 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  %115 = load i32, ptr %6, align 4, !tbaa !9
  %116 = add nsw i32 1, %115
  %117 = add nsw i32 %116, 4
  call void @hmac_sha512_Update(ptr noundef %12, ptr noundef %114, i32 noundef %117)
  %118 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void @hmac_sha512_Final(ptr noundef %12, ptr noundef %118)
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.HDNode, ptr %119, i32 0, i32 2
  %121 = getelementptr inbounds [32 x i8], ptr %120, i64 0, i64 0
  %122 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %123 = getelementptr inbounds i8, ptr %122, i64 32
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %121, ptr align 1 %123, i64 32, i1 false)
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.HDNode, ptr %124, i32 0, i32 0
  %126 = load i32, ptr %125, align 8, !tbaa !13
  %127 = add i32 %126, 1
  store i32 %127, ptr %125, align 8, !tbaa !13
  %128 = load i32, ptr %5, align 4, !tbaa !9
  %129 = load ptr, ptr %4, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.HDNode, ptr %129, i32 0, i32 1
  store i32 %128, ptr %130, align 4, !tbaa !15
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.HDNode, ptr %131, i32 0, i32 5
  %133 = getelementptr inbounds [33 x i8], ptr %132, i64 0, i64 0
  call void @memzero(ptr noundef %133, i64 noundef 33)
  %134 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void @memzero(ptr noundef %134, i64 noundef 64)
  %135 = getelementptr inbounds [69 x i8], ptr %7, i64 0, i64 0
  call void @memzero(ptr noundef %135, i64 noundef 69)
  %136 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  call void @memzero(ptr noundef %136, i64 noundef 64)
  %137 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  call void @memzero(ptr noundef %137, i64 noundef 64)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 336, ptr %12) #5
  br label %138

138:                                              ; preds = %110, %65
  call void @llvm.lifetime.end.p0(i64 64, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 69, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %139

139:                                              ; preds = %138, %24, %18
  %140 = load i32, ptr %3, align 4
  ret i32 %140
}

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

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

; 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) #3

declare i32 @hdnode_fill_public_key(ptr noundef) #4

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @scalar_multiply8(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @scalar_add_256bits(ptr noundef, ptr noundef, ptr noundef) #0

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 = !{!12, !6, i64 144}
!12 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 40, !7, i64 72, !7, i64 104, !6, i64 144}
!13 = !{!12, !10, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!12, !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.curve_info = type { ptr, ptr, i32, i32, i32, 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] }

@ed25519_cardano_info = external dso_local constant %struct.curve_info, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @hdnode_private_ckd_cardano(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca [69 x i8], align 16
  %4 = alloca [64 x i8], align 16
  %5 = alloca [64 x i8], align 16
  %6 = alloca [64 x i8], align 16
  %7 = alloca %struct._HMAC_SHA512_CTX, align 8
  %8 = alloca [32 x i8], align 16
  %9 = getelementptr inbounds i8, ptr %0, i64 144
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %.not = icmp eq ptr %10, @ed25519_cardano_info
  br i1 %.not, label %11, label %39

11:                                               ; preds = %2
  %12 = load i32, ptr %0, align 8, !tbaa !11
  %13 = icmp ugt i32 %12, 1048575
  br i1 %13, label %39, label %14

14:                                               ; preds = %11
  %.not24 = icmp sgt i32 %1, -1
  %spec.store.select = select i1 %.not24, i32 32, i32 64
  call void @llvm.lifetime.start.p0(i64 69, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #5
  %15 = zext nneg i32 %spec.store.select to i64
  %16 = getelementptr inbounds i8, ptr %3, i64 %15
  %17 = getelementptr inbounds i8, ptr %16, i64 1
  call void @write_le(ptr noundef nonnull %17, i32 noundef %1)
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %5, ptr noundef nonnull align 8 dereferenceable(32) %18, i64 32, i1 false)
  %19 = getelementptr inbounds i8, ptr %5, i64 32
  %20 = getelementptr inbounds i8, ptr %0, i64 72
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %19, ptr noundef nonnull align 8 dereferenceable(32) %20, i64 32, i1 false)
  br i1 %.not24, label %24, label %21

21:                                               ; preds = %14
  store i8 0, ptr %3, align 16, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %3, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) %22, ptr noundef nonnull align 8 dereferenceable(32) %18, i64 32, i1 false)
  %23 = getelementptr inbounds i8, ptr %3, i64 33
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) %23, ptr noundef nonnull align 8 dereferenceable(32) %20, i64 32, i1 false)
  br label %29

24:                                               ; preds = %14
  %25 = call i32 @hdnode_fill_public_key(ptr noundef nonnull %0) #5
  %.not25 = icmp eq i32 %25, 0
  br i1 %.not25, label %26, label %38

26:                                               ; preds = %24
  store i8 2, ptr %3, align 16, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %3, i64 1
  %28 = getelementptr inbounds i8, ptr %0, i64 105
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) %27, ptr noundef nonnull align 1 dereferenceable(32) %28, i64 32, i1 false)
  br label %29

29:                                               ; preds = %26, %21
  %. = phi i8 [ 3, %26 ], [ 1, %21 ]
  call void @llvm.lifetime.start.p0(i64 336, ptr nonnull %7) #5
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  call void @hmac_sha512_Init(ptr noundef nonnull %7, ptr noundef nonnull %30, i32 noundef 32) #5
  %31 = or disjoint i32 %spec.store.select, 5
  call void @hmac_sha512_Update(ptr noundef nonnull %7, ptr noundef nonnull %3, i32 noundef %31) #5
  call void @hmac_sha512_Final(ptr noundef nonnull %7, ptr noundef nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  call void @memzero(ptr noundef nonnull %8, i64 noundef 32) #5
  call void @scalar_multiply8(ptr noundef nonnull %4, i32 noundef 28, ptr noundef nonnull %8)
  call void @scalar_add_256bits(ptr noundef nonnull %8, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %32 = getelementptr inbounds i8, ptr %4, i64 32
  %33 = getelementptr inbounds i8, ptr %6, i64 32
  call void @scalar_add_256bits(ptr noundef nonnull %32, ptr noundef nonnull %19, ptr noundef nonnull %33)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %18, ptr noundef nonnull align 16 dereferenceable(32) %6, i64 32, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %20, ptr noundef nonnull align 16 dereferenceable(32) %33, i64 32, i1 false)
  store i8 %., ptr %3, align 16, !tbaa !12
  call void @hmac_sha512_Init(ptr noundef nonnull %7, ptr noundef nonnull %30, i32 noundef 32) #5
  call void @hmac_sha512_Update(ptr noundef nonnull %7, ptr noundef nonnull %3, i32 noundef %31) #5
  call void @hmac_sha512_Final(ptr noundef nonnull %7, ptr noundef nonnull %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %30, ptr noundef nonnull align 16 dereferenceable(32) %32, i64 32, i1 false)
  %34 = load i32, ptr %0, align 8, !tbaa !11
  %35 = add i32 %34, 1
  store i32 %35, ptr %0, align 8, !tbaa !11
  %36 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %1, ptr %36, align 4, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %0, i64 104
  call void @memzero(ptr noundef nonnull %37, i64 noundef 33) #5
  call void @memzero(ptr noundef nonnull %4, i64 noundef 64) #5
  call void @memzero(ptr noundef nonnull %3, i64 noundef 69) #5
  call void @memzero(ptr noundef nonnull %5, i64 noundef 64) #5
  call void @memzero(ptr noundef nonnull %6, i64 noundef 64) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 336, ptr nonnull %7) #5
  br label %38

38:                                               ; preds = %24, %29
  %.0 = phi i32 [ 1, %29 ], [ 0, %24 ]
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 69, ptr nonnull %3) #5
  br label %39

39:                                               ; preds = %11, %2, %38
  %.1 = phi i32 [ %.0, %38 ], [ 0, %2 ], [ 0, %11 ]
  ret i32 %.1
}

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

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

; 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) #3

declare i32 @hdnode_fill_public_key(ptr noundef) local_unnamed_addr #4

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @scalar_multiply8(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @scalar_add_256bits(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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, !10, i64 144}
!6 = !{!"", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 40, !8, i64 72, !8, i64 104, !10, i64 144}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!6, !7, i64 4}


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