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

; 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.anon = type { i8, [256 x i8], [64 x i8], [64 x i8] }
%struct._PBKDF2_HMAC_SHA512_CTX = type { [8 x i64], [8 x i64], [8 x i64], [16 x i64], i8 }

@bip39_cache_index = external dso_local global i32, align 4
@bip39_cache = external dso_local global [4 x %struct.anon], align 16
@.str.2048 = external hidden unnamed_addr constant [9 x i8], align 1

declare void @memzero(ptr noundef, i64 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; 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

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #5

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local void @mnemonic_to_seed(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #6 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [264 x i8], align 16
  %14 = alloca %struct._PBKDF2_HMAC_SHA512_CTX, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i64 @strlen(ptr noundef %16) #8
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call i64 @strnlen(ptr noundef %19, i64 noundef 256) #8
  %21 = trunc i64 %20 to i32
  store i32 %21, ptr %10, align 4, !tbaa !9
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 256
  br i1 %23, label %24, label %73

24:                                               ; preds = %4
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 64
  br i1 %26, label %27, label %73

27:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %67, %27
  %29 = load i32, ptr %11, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 4
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 2, ptr %12, align 4
  br label %70

32:                                               ; preds = %28
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.anon, ptr %35, i32 0, i32 0
  %37 = load i8, ptr %36, align 1, !tbaa !11, !range !14, !noundef !15
  %38 = trunc i8 %37 to i1
  br i1 %38, label %40, label %39

39:                                               ; preds = %32
  br label %67

40:                                               ; preds = %32
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.anon, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds [256 x i8], ptr %44, i64 0, i64 0
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call i32 @strcmp(ptr noundef %45, ptr noundef %46) #8
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %40
  br label %67

50:                                               ; preds = %40
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %52
  %54 = getelementptr inbounds %struct.anon, ptr %53, i32 0, i32 2
  %55 = getelementptr inbounds [64 x i8], ptr %54, i64 0, i64 0
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = call i32 @strcmp(ptr noundef %55, ptr noundef %56) #8
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %50
  br label %67

60:                                               ; preds = %50
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.anon, ptr %64, i32 0, i32 3
  %66 = getelementptr inbounds [64 x i8], ptr %65, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %61, ptr align 1 %66, i64 64, i1 false)
  store i32 1, ptr %12, align 4
  br label %70

67:                                               ; preds = %59, %49, %39
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %11, align 4, !tbaa !9
  br label %28, !llvm.loop !16

70:                                               ; preds = %60, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  %71 = load i32, ptr %12, align 4
  switch i32 %71, label %144 [
    i32 2, label %72
  ]

72:                                               ; preds = %70
  br label %73

73:                                               ; preds = %72, %24, %4
  call void @llvm.lifetime.start.p0(i64 264, ptr %13) #7
  call void @llvm.memset.p0.i64(ptr align 16 %13, i8 0, i64 264, i1 false)
  %74 = getelementptr inbounds [264 x i8], ptr %13, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %74, ptr align 1 @.str.2048, i64 8, i1 false)
  %75 = getelementptr inbounds [264 x i8], ptr %13, i64 0, i64 0
  %76 = getelementptr inbounds i8, ptr %75, i64 8
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = load i32, ptr %10, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %76, ptr align 1 %77, i64 %79, i1 false)
  call void @llvm.lifetime.start.p0(i64 328, ptr %14) #7
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load i32, ptr %9, align 4, !tbaa !9
  %82 = getelementptr inbounds [264 x i8], ptr %13, i64 0, i64 0
  %83 = load i32, ptr %10, align 4, !tbaa !9
  %84 = add nsw i32 %83, 8
  call void @pbkdf2_hmac_sha512_Init(ptr noundef %14, ptr noundef %80, i32 noundef %81, ptr noundef %82, i32 noundef %84, i32 noundef 1)
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = icmp ne ptr %85, null
  br i1 %86, label %87, label %89

87:                                               ; preds = %73
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  call void %88(i32 noundef 0, i32 noundef 2048)
  br label %89

89:                                               ; preds = %87, %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %104, %89
  %91 = load i32, ptr %15, align 4, !tbaa !9
  %92 = icmp slt i32 %91, 16
  br i1 %92, label %94, label %93

93:                                               ; preds = %90
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %107

94:                                               ; preds = %90
  call void @pbkdf2_hmac_sha512_Update(ptr noundef %14, i32 noundef 128)
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = icmp ne ptr %95, null
  br i1 %96, label %97, label %103

97:                                               ; preds = %94
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = load i32, ptr %15, align 4, !tbaa !9
  %100 = add nsw i32 %99, 1
  %101 = mul nsw i32 %100, 2048
  %102 = sdiv i32 %101, 16
  call void %98(i32 noundef %102, i32 noundef 2048)
  br label %103

103:                                              ; preds = %97, %94
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %15, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %15, align 4, !tbaa !9
  br label %90, !llvm.loop !18

107:                                              ; preds = %93
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  call void @pbkdf2_hmac_sha512_Final(ptr noundef %14, ptr noundef %108)
  %109 = getelementptr inbounds [264 x i8], ptr %13, i64 0, i64 0
  call void @memzero(ptr noundef %109, i64 noundef 264)
  %110 = load i32, ptr %9, align 4, !tbaa !9
  %111 = icmp slt i32 %110, 256
  br i1 %111, label %112, label %143

112:                                              ; preds = %107
  %113 = load i32, ptr %10, align 4, !tbaa !9
  %114 = icmp slt i32 %113, 64
  br i1 %114, label %115, label %143

115:                                              ; preds = %112
  %116 = load i32, ptr @bip39_cache_index, align 4, !tbaa !9
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %117
  %119 = getelementptr inbounds %struct.anon, ptr %118, i32 0, i32 0
  store i8 1, ptr %119, align 1, !tbaa !11
  %120 = load i32, ptr @bip39_cache_index, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %121
  %123 = getelementptr inbounds %struct.anon, ptr %122, i32 0, i32 1
  %124 = getelementptr inbounds [256 x i8], ptr %123, i64 0, i64 0
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = call ptr @strcpy(ptr noundef %124, ptr noundef %125) #7
  %127 = load i32, ptr @bip39_cache_index, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %128
  %130 = getelementptr inbounds %struct.anon, ptr %129, i32 0, i32 2
  %131 = getelementptr inbounds [64 x i8], ptr %130, i64 0, i64 0
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = call ptr @strcpy(ptr noundef %131, ptr noundef %132) #7
  %134 = load i32, ptr @bip39_cache_index, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %135
  %137 = getelementptr inbounds %struct.anon, ptr %136, i32 0, i32 3
  %138 = getelementptr inbounds [64 x i8], ptr %137, i64 0, i64 0
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %138, ptr align 1 %139, i64 64, i1 false)
  %140 = load i32, ptr @bip39_cache_index, align 4, !tbaa !9
  %141 = add nsw i32 %140, 1
  %142 = srem i32 %141, 4
  store i32 %142, ptr @bip39_cache_index, align 4, !tbaa !9
  br label %143

143:                                              ; preds = %115, %112, %107
  call void @llvm.lifetime.end.p0(i64 328, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 264, ptr %13) #7
  store i32 0, ptr %12, align 4
  br label %144

144:                                              ; preds = %143, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  %145 = load i32, ptr %12, align 4
  switch i32 %145, label %147 [
    i32 0, label %146
    i32 1, label %146
  ]

146:                                              ; preds = %144, %144
  ret void

147:                                              ; preds = %144
  unreachable
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strnlen(ptr noundef, i64 noundef) #5

declare void @pbkdf2_hmac_sha512_Init(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) #0

declare void @pbkdf2_hmac_sha512_Update(ptr noundef, i32 noundef) #0

declare void @pbkdf2_hmac_sha512_Final(ptr noundef, ptr noundef) #0

attributes #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !7, i64 1, !7, i64 257, !7, i64 321}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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.anon = type { i8, [256 x i8], [64 x i8], [64 x i8] }
%struct._PBKDF2_HMAC_SHA512_CTX = type { [8 x i64], [8 x i64], [8 x i64], [16 x i64], i8 }

@bip39_cache_index = external dso_local local_unnamed_addr global i32, align 4
@bip39_cache = external dso_local global [4 x %struct.anon], align 16
@.str.2048 = external hidden unnamed_addr constant [9 x i8], align 1

declare void @memzero(ptr noundef, i64 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; 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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local void @mnemonic_to_seed(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef readonly %3) local_unnamed_addr #6 {
  %5 = alloca [264 x i8], align 16
  %6 = alloca %struct._PBKDF2_HMAC_SHA512_CTX, align 8
  %7 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #7
  %8 = trunc i64 %7 to i32
  %9 = tail call i64 @strnlen(ptr noundef nonnull dereferenceable(1) %1, i64 noundef 256) #7
  %10 = trunc i64 %9 to i32
  %11 = icmp slt i32 %8, 256
  %12 = icmp slt i32 %10, 64
  %or.cond = select i1 %11, i1 %12, i1 false
  br i1 %or.cond, label %.preheader.preheader, label %.critedge

.preheader.preheader:                             ; preds = %4
  %13 = load i8, ptr @bip39_cache, align 16, !tbaa !5, !range !10, !noundef !11
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %15, label %.preheader.1

15:                                               ; preds = %.preheader.preheader
  %16 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @bip39_cache, i64 1), ptr noundef nonnull dereferenceable(1) %0) #7
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %17, label %.preheader.1

17:                                               ; preds = %15
  %18 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @bip39_cache, i64 257), ptr noundef nonnull dereferenceable(1) %1) #7
  %.not37 = icmp eq i32 %18, 0
  br i1 %.not37, label %19, label %.preheader.1

19:                                               ; preds = %37, %31, %25, %17
  %.lcssa = phi ptr [ @bip39_cache, %17 ], [ getelementptr inbounds (i8, ptr @bip39_cache, i64 385), %25 ], [ getelementptr inbounds (i8, ptr @bip39_cache, i64 770), %31 ], [ getelementptr inbounds (i8, ptr @bip39_cache, i64 1155), %37 ]
  %20 = getelementptr inbounds i8, ptr %.lcssa, i64 321
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(64) %2, ptr noundef nonnull align 1 dereferenceable(64) %20, i64 64, i1 false)
  br label %55

.preheader.1:                                     ; preds = %17, %15, %.preheader.preheader
  %21 = load i8, ptr getelementptr inbounds (i8, ptr @bip39_cache, i64 385), align 1, !tbaa !5, !range !10, !noundef !11
  %22 = trunc nuw i8 %21 to i1
  br i1 %22, label %23, label %.preheader.2

23:                                               ; preds = %.preheader.1
  %24 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @bip39_cache, i64 386), ptr noundef nonnull dereferenceable(1) %0) #7
  %.not.1 = icmp eq i32 %24, 0
  br i1 %.not.1, label %25, label %.preheader.2

25:                                               ; preds = %23
  %26 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @bip39_cache, i64 642), ptr noundef nonnull dereferenceable(1) %1) #7
  %.not37.1 = icmp eq i32 %26, 0
  br i1 %.not37.1, label %19, label %.preheader.2

.preheader.2:                                     ; preds = %25, %23, %.preheader.1
  %27 = load i8, ptr getelementptr inbounds (i8, ptr @bip39_cache, i64 770), align 2, !tbaa !5, !range !10, !noundef !11
  %28 = trunc nuw i8 %27 to i1
  br i1 %28, label %29, label %.preheader.3

29:                                               ; preds = %.preheader.2
  %30 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @bip39_cache, i64 771), ptr noundef nonnull dereferenceable(1) %0) #7
  %.not.2 = icmp eq i32 %30, 0
  br i1 %.not.2, label %31, label %.preheader.3

31:                                               ; preds = %29
  %32 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @bip39_cache, i64 1027), ptr noundef nonnull dereferenceable(1) %1) #7
  %.not37.2 = icmp eq i32 %32, 0
  br i1 %.not37.2, label %19, label %.preheader.3

.preheader.3:                                     ; preds = %31, %29, %.preheader.2
  %33 = load i8, ptr getelementptr inbounds (i8, ptr @bip39_cache, i64 1155), align 1, !tbaa !5, !range !10, !noundef !11
  %34 = trunc nuw i8 %33 to i1
  br i1 %34, label %35, label %.critedge

35:                                               ; preds = %.preheader.3
  %36 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @bip39_cache, i64 1156), ptr noundef nonnull dereferenceable(1) %0) #7
  %.not.3 = icmp eq i32 %36, 0
  br i1 %.not.3, label %37, label %.critedge

37:                                               ; preds = %35
  %38 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @bip39_cache, i64 1412), ptr noundef nonnull dereferenceable(1) %1) #7
  %.not37.3 = icmp eq i32 %38, 0
  br i1 %.not37.3, label %19, label %.critedge

.critedge:                                        ; preds = %.preheader.3, %35, %37, %4
  call void @llvm.lifetime.start.p0(i64 264, ptr nonnull %5) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(264) %5, i8 0, i64 264, i1 false)
  %39 = load i64, ptr @.str.2048, align 1
  store i64 %39, ptr %5, align 16
  %40 = getelementptr inbounds i8, ptr %5, i64 8
  %sext = shl i64 %9, 32
  %41 = ashr exact i64 %sext, 32
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %40, ptr align 1 %1, i64 %41, i1 false)
  call void @llvm.lifetime.start.p0(i64 328, ptr nonnull %6) #8
  %42 = add nsw i32 %10, 8
  call void @pbkdf2_hmac_sha512_Init(ptr noundef nonnull %6, ptr noundef %0, i32 noundef %8, ptr noundef nonnull %5, i32 noundef %42, i32 noundef 1) #8
  %.not38 = icmp eq ptr %3, null
  br i1 %.not38, label %.split.us.preheader, label %.split

.split.us.preheader:                              ; preds = %.critedge
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  br label %.split42.us

.split:                                           ; preds = %.critedge
  call void %3(i32 noundef 0, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 128, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 256, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 384, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 512, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 640, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 768, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 896, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 1024, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 1152, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 1280, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 1408, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 1536, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 1664, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 1792, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 1920, i32 noundef 2048) #8
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull %6, i32 noundef 128) #8
  call void %3(i32 noundef 2048, i32 noundef 2048) #8
  br label %.split42.us

.split42.us:                                      ; preds = %.split, %.split.us.preheader
  call void @pbkdf2_hmac_sha512_Final(ptr noundef nonnull %6, ptr noundef %2) #8
  call void @memzero(ptr noundef nonnull %5, i64 noundef 264) #8
  br i1 %or.cond, label %43, label %54

43:                                               ; preds = %.split42.us
  %44 = load i32, ptr @bip39_cache_index, align 4, !tbaa !12
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %45
  store i8 1, ptr %46, align 1, !tbaa !5
  %47 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %45, i32 1
  %48 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %47, ptr noundef nonnull dereferenceable(1) %0) #8
  %49 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %45, i32 2
  %50 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %49, ptr noundef nonnull dereferenceable(1) %1) #8
  %51 = getelementptr inbounds [4 x %struct.anon], ptr @bip39_cache, i64 0, i64 %45, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(64) %51, ptr noundef nonnull align 1 dereferenceable(64) %2, i64 64, i1 false)
  %52 = add nsw i32 %44, 1
  %53 = srem i32 %52, 4
  store i32 %53, ptr @bip39_cache_index, align 4, !tbaa !12
  br label %54

54:                                               ; preds = %43, %.split42.us
  call void @llvm.lifetime.end.p0(i64 328, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 264, ptr nonnull %5) #8
  br label %55

55:                                               ; preds = %19, %54
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strnlen(ptr nocapture noundef, i64 noundef) local_unnamed_addr #5

declare void @pbkdf2_hmac_sha512_Init(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare void @pbkdf2_hmac_sha512_Update(ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @pbkdf2_hmac_sha512_Final(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #6 = { 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 #7 = { nounwind willreturn memory(read) }
attributes #8 = { 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 = !{!"", !7, i64 0, !8, i64 1, !8, i64 257, !8, i64 321}
!7 = !{!"_Bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{i8 0, i8 2}
!11 = !{}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}


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