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

; 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 ptr @iotex_cipher_info_from_psa(i32 noundef %0, i16 noundef zeroext %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i16, align 2
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i16 %1, ptr %7, align 2, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !11
  store ptr %3, ptr %9, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = and i32 %13, 2130706432
  %15 = icmp eq i32 %14, 83886080
  br i1 %15, label %16, label %20

16:                                               ; preds = %4
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = and i32 %17, -4161537
  %19 = or i32 %18, 0
  store i32 %19, ptr %6, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %16, %4
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = and i32 %21, 2130706432
  %23 = icmp eq i32 %22, 67108864
  br i1 %23, label %28, label %24

24:                                               ; preds = %20
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = and i32 %25, 2130706432
  %27 = icmp eq i32 %26, 83886080
  br i1 %27, label %28, label %36

28:                                               ; preds = %24, %20
  %29 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %29, label %34 [
    i32 79695872, label %30
    i32 71320576, label %31
    i32 71319552, label %32
    i32 71319808, label %33
  ]

30:                                               ; preds = %28
  store i32 5, ptr %10, align 4, !tbaa !5
  br label %35

31:                                               ; preds = %28
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %35

32:                                               ; preds = %28
  store i32 2, ptr %10, align 4, !tbaa !5
  br label %35

33:                                               ; preds = %28
  store i32 2, ptr %10, align 4, !tbaa !5
  br label %35

34:                                               ; preds = %28
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %59

35:                                               ; preds = %33, %32, %31, %30
  br label %42

36:                                               ; preds = %24
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 62915072
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %41

40:                                               ; preds = %36
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %59

41:                                               ; preds = %39
  br label %42

42:                                               ; preds = %41, %35
  %43 = load i16, ptr %7, align 2, !tbaa !9
  %44 = zext i16 %43 to i32
  switch i32 %44, label %46 [
    i32 9216, label %45
  ]

45:                                               ; preds = %42
  store i32 2, ptr %11, align 4, !tbaa !5
  br label %47

46:                                               ; preds = %42
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %59

47:                                               ; preds = %45
  %48 = load ptr, ptr %9, align 8, !tbaa !13
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %53

50:                                               ; preds = %47
  %51 = load i32, ptr %11, align 4, !tbaa !5
  %52 = load ptr, ptr %9, align 8, !tbaa !13
  store i32 %51, ptr %52, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %50, %47
  %54 = load i32, ptr %11, align 4, !tbaa !5
  %55 = load i64, ptr %8, align 8, !tbaa !11
  %56 = trunc i64 %55 to i32
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = call ptr @iotex_cipher_info_from_values(i32 noundef %54, i32 noundef %56, i32 noundef %57)
  store ptr %58, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %59

59:                                               ; preds = %53, %46, %40, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %60 = load ptr, ptr %5, align 8
  ret ptr %60
}

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

declare ptr @iotex_cipher_info_from_values(i32 noundef, i32 noundef, i32 noundef) #2

; 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 = { "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 }

!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}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !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: nounwind uwtable
define dso_local ptr @iotex_cipher_info_from_psa(i32 noundef %0, i16 noundef zeroext %1, i64 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #0 {
  %5 = and i32 %0, 2130706432
  %6 = icmp eq i32 %5, 83886080
  %7 = and i32 %0, -2050981889
  %spec.select = select i1 %6, i32 %7, i32 %0
  %8 = and i32 %spec.select, 2130706432
  switch i32 %8, label %13 [
    i32 67108864, label %9
    i32 83886080, label %9
  ]

9:                                                ; preds = %4, %4
  switch i32 %spec.select, label %21 [
    i32 79695872, label %15
    i32 71320576, label %10
    i32 71319552, label %11
    i32 71319808, label %12
  ]

10:                                               ; preds = %9
  br label %15

11:                                               ; preds = %9
  br label %15

12:                                               ; preds = %9
  br label %15

13:                                               ; preds = %4
  %14 = icmp eq i32 %spec.select, 62915072
  br i1 %14, label %15, label %21

15:                                               ; preds = %13, %9, %10, %11, %12
  %.013 = phi i32 [ 2, %12 ], [ 2, %11 ], [ 1, %10 ], [ 5, %9 ], [ 1, %13 ]
  %cond = icmp eq i16 %1, 9216
  br i1 %cond, label %16, label %21

16:                                               ; preds = %15
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %18, label %17

17:                                               ; preds = %16
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %17, %16
  %19 = trunc i64 %2 to i32
  %20 = tail call ptr @iotex_cipher_info_from_values(i32 noundef 2, i32 noundef %19, i32 noundef %.013) #2
  br label %21

21:                                               ; preds = %15, %13, %9, %18
  %.0 = phi ptr [ %20, %18 ], [ null, %9 ], [ null, %13 ], [ null, %15 ]
  ret ptr %.0
}

declare ptr @iotex_cipher_info_from_values(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 = { "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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