; LLVM IR from machinefi/psa-crypto-esp32 :: psa_layer (psa_crypto)

; 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: nounwind uwtable
define dso_local i32 @psa_mac_key_can_do(i32 noundef %0, i16 noundef zeroext %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i16, align 2
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = and i32 %6, 2143289344
  %8 = icmp eq i32 %7, 58720256
  br i1 %8, label %9, label %15

9:                                                ; preds = %2
  %10 = load i16, ptr %5, align 2, !tbaa !9
  %11 = zext i16 %10 to i32
  %12 = icmp eq i32 %11, 4352
  br i1 %12, label %13, label %14

13:                                               ; preds = %9
  store i32 0, ptr %3, align 4
  br label %43

14:                                               ; preds = %9
  br label %15

15:                                               ; preds = %14, %2
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = and i32 %16, 2143289344
  %18 = icmp eq i32 %17, 62914560
  br i1 %18, label %19, label %42

19:                                               ; preds = %15
  %20 = load i16, ptr %5, align 2, !tbaa !9
  %21 = zext i16 %20 to i32
  %22 = and i32 %21, 28672
  %23 = icmp eq i32 %22, 8192
  br i1 %23, label %24, label %41

24:                                               ; preds = %19
  %25 = load i16, ptr %5, align 2, !tbaa !9
  %26 = zext i16 %25 to i32
  %27 = and i32 %26, 28672
  %28 = icmp eq i32 %27, 8192
  br i1 %28, label %29, label %35

29:                                               ; preds = %24
  %30 = load i16, ptr %5, align 2, !tbaa !9
  %31 = zext i16 %30 to i32
  %32 = ashr i32 %31, 8
  %33 = and i32 %32, 7
  %34 = shl i32 1, %33
  br label %36

35:                                               ; preds = %24
  br label %36

36:                                               ; preds = %35, %29
  %37 = phi i32 [ %34, %29 ], [ 0, %35 ]
  %38 = icmp ugt i32 %37, 1
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  store i32 0, ptr %3, align 4
  br label %43

40:                                               ; preds = %36
  br label %41

41:                                               ; preds = %40, %19
  br label %42

42:                                               ; preds = %41, %15
  store i32 -135, ptr %3, align 4
  br label %43

43:                                               ; preds = %42, %39, %13
  %44 = load i32, ptr %3, align 4
  ret i32 %44
}

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local range(i32 -135, 1) i32 @psa_mac_key_can_do(i32 noundef %0, i16 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = and i32 %0, 2143289344
  %4 = icmp eq i32 %3, 58720256
  %5 = icmp eq i16 %1, 4352
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %12, label %6

6:                                                ; preds = %2
  %7 = zext i16 %1 to i32
  %8 = icmp ne i32 %3, 62914560
  %9 = and i32 %7, 28672
  %10 = icmp ne i32 %9, 8192
  %or.cond10.not14 = or i1 %8, %10
  %11 = and i32 %7, 1792
  %.not = icmp eq i32 %11, 0
  %or.cond11 = or i1 %.not, %or.cond10.not14
  %spec.select = select i1 %or.cond11, i32 -135, i32 0
  br label %12

12:                                               ; preds = %6, %2
  %.0 = phi i32 [ 0, %2 ], [ %spec.select, %6 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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" }

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


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