; LLVM IR from square/subzero :: core/trezor-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 = external hidden global [4 x %struct.anon], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@mnemonic_to_seed.pctx = external hidden global %struct._PBKDF2_HMAC_SHA512_CTX, align 8
@bip39_cache_index = external hidden global i32, align 4

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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) #2

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mnemonic_to_seed(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #5 {
  %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 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) #6
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call i64 @strlen(ptr noundef %15) #7
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call i64 @strnlen(ptr noundef %18, i64 noundef 256) #7
  %20 = trunc i64 %19 to i32
  store i32 %20, ptr %10, align 4, !tbaa !9
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = icmp slt i32 %21, 256
  br i1 %22, label %23, label %72

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

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

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

30:                                               ; preds = %27
  store i32 2, ptr %12, align 4
  br label %69

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

38:                                               ; preds = %31
  br label %66

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

48:                                               ; preds = %39
  br label %66

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

58:                                               ; preds = %49
  br label %66

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

66:                                               ; preds = %58, %48, %38
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %11, align 4, !tbaa !9
  br label %27, !llvm.loop !16

69:                                               ; preds = %59, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  %70 = load i32, ptr %12, align 4
  switch i32 %70, label %143 [
    i32 2, label %71
  ]

71:                                               ; preds = %69
  br label %72

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

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

88:                                               ; preds = %86, %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %89

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

92:                                               ; preds = %89
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %106

93:                                               ; preds = %89
  call void @pbkdf2_hmac_sha512_Update(ptr noundef @mnemonic_to_seed.pctx, i32 noundef 128)
  %94 = load ptr, ptr %8, align 8, !tbaa !5
  %95 = icmp ne ptr %94, null
  br i1 %95, label %96, label %102

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

102:                                              ; preds = %96, %93
  br label %103

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

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

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

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

142:                                              ; preds = %114, %111, %106
  call void @llvm.lifetime.end.p0(i64 264, ptr %13) #6
  store i32 0, ptr %12, align 4
  br label %143

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

145:                                              ; preds = %143, %143
  ret void

146:                                              ; preds = %143
  unreachable
}

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

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

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

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

attributes #0 = { nocallback nofree nosync 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 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 #6 = { nounwind }
attributes #7 = { 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 = external hidden global [4 x %struct.anon], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@mnemonic_to_seed.pctx = external hidden global %struct._PBKDF2_HMAC_SHA512_CTX, align 8
@bip39_cache_index = external hidden local_unnamed_addr global i32, align 4

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

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

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

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

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

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

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

; 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 #5 {
  %5 = alloca [264 x i8], align 16
  %6 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #6
  %7 = trunc i64 %6 to i32
  %8 = tail call i64 @strnlen(ptr noundef nonnull dereferenceable(1) %1, i64 noundef 256) #6
  %9 = trunc i64 %8 to i32
  %10 = icmp slt i32 %7, 256
  %11 = icmp slt i32 %9, 64
  %or.cond = select i1 %10, i1 %11, i1 false
  br i1 %or.cond, label %.preheader.preheader, label %.critedge

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

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

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

18:                                               ; preds = %36, %30, %24, %16
  %.lcssa = phi ptr [ @bip39_cache, %16 ], [ getelementptr inbounds (i8, ptr @bip39_cache, i64 385), %24 ], [ getelementptr inbounds (i8, ptr @bip39_cache, i64 770), %30 ], [ getelementptr inbounds (i8, ptr @bip39_cache, i64 1155), %36 ]
  %19 = 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) %19, i64 64, i1 false)
  br label %54

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

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

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

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

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

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

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

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

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

.critedge:                                        ; preds = %.preheader.3, %34, %36, %4
  call void @llvm.lifetime.start.p0(i64 264, ptr nonnull %5) #7
  %38 = load i64, ptr @.str, align 1
  store i64 %38, ptr %5, align 16
  %39 = getelementptr inbounds i8, ptr %5, i64 8
  %sext = shl i64 %8, 32
  %40 = ashr exact i64 %sext, 32
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %39, ptr align 1 %1, i64 %40, i1 false)
  %41 = add nsw i32 %9, 8
  call void @pbkdf2_hmac_sha512_Init(ptr noundef nonnull @mnemonic_to_seed.pctx, ptr noundef %0, i32 noundef %7, ptr noundef nonnull %5, i32 noundef %41, i32 noundef 1) #7
  %.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 @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  call void @pbkdf2_hmac_sha512_Update(ptr noundef nonnull @mnemonic_to_seed.pctx, i32 noundef 128) #7
  br label %.split42.us

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

.split42.us:                                      ; preds = %.split, %.split.us.preheader
  call void @pbkdf2_hmac_sha512_Final(ptr noundef nonnull @mnemonic_to_seed.pctx, ptr noundef %2) #7
  call void @memzero(ptr noundef nonnull %5, i64 noundef 264) #7
  br i1 %or.cond, label %42, label %53

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

53:                                               ; preds = %42, %.split42.us
  call void @llvm.lifetime.end.p0(i64 264, ptr nonnull %5) #7
  br label %54

54:                                               ; preds = %18, %53
  ret void
}

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { 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 #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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