; LLVM IR from xtruan/FlipBIP :: lib/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"

; 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: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mnemonic_check(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca [33 x i8], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 33, ptr %4) #4
  call void @llvm.memset.p0.i64(ptr align 16 %4, i8 0, i64 33, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds [33 x i8], ptr %4, i64 0, i64 0
  %11 = call i32 @mnemonic_to_bits(ptr noundef %9, ptr noundef %10)
  store i32 %11, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp ne i32 %12, 132
  br i1 %13, label %14, label %21

14:                                               ; preds = %1
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 198
  br i1 %16, label %17, label %21

17:                                               ; preds = %14
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = icmp ne i32 %18, 264
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %76

21:                                               ; preds = %17, %14, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = sdiv i32 %22, 11
  store i32 %23, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = mul nsw i32 %24, 4
  %26 = sdiv i32 %25, 3
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [33 x i8], ptr %4, i64 0, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !11
  store i8 %29, ptr %8, align 1, !tbaa !11
  %30 = getelementptr inbounds [33 x i8], ptr %4, i64 0, i64 0
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = mul nsw i32 %31, 4
  %33 = sdiv i32 %32, 3
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [33 x i8], ptr %4, i64 0, i64 0
  call void @sha256_Raw(ptr noundef %30, i64 noundef %34, ptr noundef %35)
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = icmp eq i32 %36, 12
  br i1 %37, label %38, label %48

38:                                               ; preds = %21
  %39 = getelementptr inbounds [33 x i8], ptr %4, i64 0, i64 0
  %40 = load i8, ptr %39, align 16, !tbaa !11
  %41 = zext i8 %40 to i32
  %42 = and i32 %41, 240
  %43 = load i8, ptr %8, align 1, !tbaa !11
  %44 = zext i8 %43 to i32
  %45 = and i32 %44, 240
  %46 = icmp eq i32 %42, %45
  %47 = zext i1 %46 to i32
  store i32 %47, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %75

48:                                               ; preds = %21
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = icmp eq i32 %49, 18
  br i1 %50, label %51, label %61

51:                                               ; preds = %48
  %52 = getelementptr inbounds [33 x i8], ptr %4, i64 0, i64 0
  %53 = load i8, ptr %52, align 16, !tbaa !11
  %54 = zext i8 %53 to i32
  %55 = and i32 %54, 252
  %56 = load i8, ptr %8, align 1, !tbaa !11
  %57 = zext i8 %56 to i32
  %58 = and i32 %57, 252
  %59 = icmp eq i32 %55, %58
  %60 = zext i1 %59 to i32
  store i32 %60, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %75

61:                                               ; preds = %48
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = icmp eq i32 %62, 24
  br i1 %63, label %64, label %72

64:                                               ; preds = %61
  %65 = getelementptr inbounds [33 x i8], ptr %4, i64 0, i64 0
  %66 = load i8, ptr %65, align 16, !tbaa !11
  %67 = zext i8 %66 to i32
  %68 = load i8, ptr %8, align 1, !tbaa !11
  %69 = zext i8 %68 to i32
  %70 = icmp eq i32 %67, %69
  %71 = zext i1 %70 to i32
  store i32 %71, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %75

72:                                               ; preds = %61
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %75

75:                                               ; preds = %74, %64, %51, %38
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %76

76:                                               ; preds = %75, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 33, ptr %4) #4
  %77 = load i32, ptr %2, align 4
  ret i32 %77
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!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}


; 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"

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

declare void @sha256_Raw(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @mnemonic_check(ptr noundef %0) local_unnamed_addr #3 {
  %2 = alloca [33 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 33, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(33) %2, i8 0, i64 33, i1 false)
  %3 = call i32 @mnemonic_to_bits(ptr noundef %0, ptr noundef nonnull %2)
  switch i32 %3, label %27 [
    i32 264, label %4
    i32 198, label %4
    i32 132, label %4
  ]

4:                                                ; preds = %1, %1, %1
  %.lhs.trunc = trunc i32 %3 to i16
  %5 = udiv i16 %.lhs.trunc, 11
  %.tr = trunc i16 %5 to i8
  %.lhs.trunc19 = shl nuw nsw i8 %.tr, 2
  %6 = udiv i8 %.lhs.trunc19, 3
  %7 = zext nneg i8 %6 to i64
  %8 = getelementptr inbounds [33 x i8], ptr %2, i64 0, i64 %7
  %9 = load i8, ptr %8, align 1, !tbaa !5
  call void @sha256_Raw(ptr noundef nonnull %2, i64 noundef %7, ptr noundef nonnull %2) #4
  %.off = add nsw i32 %3, -132
  %10 = icmp ult i32 %.off, 11
  br i1 %10, label %11, label %15

11:                                               ; preds = %4
  %12 = load i8, ptr %2, align 16, !tbaa !5
  %13 = xor i8 %12, %9
  %14 = icmp ult i8 %13, 16
  br label %26

15:                                               ; preds = %4
  %.off17 = add nsw i32 %3, -198
  %16 = icmp ult i32 %.off17, 11
  br i1 %16, label %17, label %21

17:                                               ; preds = %15
  %18 = load i8, ptr %2, align 16, !tbaa !5
  %19 = xor i8 %18, %9
  %20 = icmp ult i8 %19, 4
  br label %26

21:                                               ; preds = %15
  %.off18 = add nsw i32 %3, -264
  %22 = icmp ult i32 %.off18, 11
  br i1 %22, label %23, label %26

23:                                               ; preds = %21
  %24 = load i8, ptr %2, align 16, !tbaa !5
  %25 = icmp eq i8 %24, %9
  br label %26

26:                                               ; preds = %21, %23, %17, %11
  %.0.shrunk = phi i1 [ %14, %11 ], [ %20, %17 ], [ %25, %23 ], [ false, %21 ]
  %.0 = zext i1 %.0.shrunk to i32
  br label %27

27:                                               ; preds = %1, %26
  %.1 = phi i32 [ %.0, %26 ], [ 0, %1 ]
  call void @llvm.lifetime.end.p0(i64 33, ptr nonnull %2) #4
  ret i32 %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!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"}


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