; LLVM IR from opencryptoki/libzpc :: src/zkey (pkey)

; 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.ep11kblob_header = type { i8, i8, i16, i8, i8, i16, [8 x i8] }
%struct.ep11keytoken = type { %union.anon, [16 x i8], i64, i64, i16, [14 x i8], [144 x i8], [32 x i8], [64 x i8] }
%union.anon = type { %struct.anon, [24 x i8] }
%struct.anon = type { i8, i8, i16, i8, i8, i16 }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @is_ep11_aes_key_with_header(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr %11, ptr %7, align 8, !tbaa !5
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = icmp ult i64 %12, 272
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %59

15:                                               ; preds = %2
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ep11kblob_header, ptr %16, i32 0, i32 0
  %18 = load i8, ptr %17, align 1, !tbaa !11
  %19 = zext i8 %18 to i32
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %15
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %59

22:                                               ; preds = %15
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ep11kblob_header, ptr %23, i32 0, i32 1
  %25 = load i8, ptr %24, align 1, !tbaa !14
  %26 = zext i8 %25 to i32
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %22
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %59

29:                                               ; preds = %22
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ep11kblob_header, ptr %30, i32 0, i32 3
  %32 = load i8, ptr %31, align 1, !tbaa !15
  %33 = zext i8 %32 to i32
  %34 = icmp ne i32 %33, 6
  br i1 %34, label %35, label %36

35:                                               ; preds = %29
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %59

36:                                               ; preds = %29
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ep11kblob_header, ptr %37, i32 0, i32 2
  %39 = load i16, ptr %38, align 1, !tbaa !16
  %40 = zext i16 %39 to i64
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = icmp ugt i64 %40, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %36
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %59

44:                                               ; preds = %36
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ep11kblob_header, ptr %45, i32 0, i32 2
  %47 = load i16, ptr %46, align 1, !tbaa !16
  %48 = zext i16 %47 to i64
  %49 = icmp ult i64 %48, 272
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %59

51:                                               ; preds = %44
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ep11keytoken, ptr %52, i32 0, i32 4
  %54 = load i16, ptr %53, align 1, !tbaa !17
  %55 = zext i16 %54 to i32
  %56 = icmp ne i32 %55, 4660
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %59

58:                                               ; preds = %51
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %59

59:                                               ; preds = %58, %57, %50, %43, %35, %28, %21, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %60 = load i1, ptr %3, align 1
  ret i1 %60
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"ep11kblob_header", !7, i64 0, !7, i64 1, !13, i64 2, !7, i64 4, !7, i64 5, !13, i64 6, !7, i64 8}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !7, i64 1}
!15 = !{!12, !7, i64 4}
!16 = !{!12, !13, i64 2}
!17 = !{!18, !13, i64 64}
!18 = !{!"ep11keytoken", !7, i64 0, !7, i64 32, !19, i64 48, !19, i64 56, !13, i64 64, !7, i64 66, !7, i64 80, !7, i64 224, !7, i64 256}
!19 = !{!"long long", !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(argmem: read) uwtable
define dso_local zeroext i1 @is_ep11_aes_key_with_header(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp ult i64 %1, 272
  br i1 %3, label %21, label %4

4:                                                ; preds = %2
  %5 = load i8, ptr %0, align 1, !tbaa !5
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %6, label %21

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 1
  %8 = load i8, ptr %7, align 1, !tbaa !10
  %.not12 = icmp eq i8 %8, 0
  br i1 %.not12, label %9, label %21

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %.not13 = icmp eq i8 %11, 6
  br i1 %.not13, label %12, label %21

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 2
  %14 = load i16, ptr %13, align 1, !tbaa !12
  %15 = zext i16 %14 to i64
  %16 = icmp ugt i64 %15, %1
  %17 = icmp ult i16 %14, 272
  %or.cond = or i1 %17, %16
  br i1 %or.cond, label %21, label %18

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  %20 = load i16, ptr %19, align 1, !tbaa !13
  %.not14 = icmp eq i16 %20, 4660
  br label %21

21:                                               ; preds = %18, %12, %9, %6, %4, %2
  %.0 = phi i1 [ false, %2 ], [ false, %4 ], [ false, %6 ], [ false, %9 ], [ false, %12 ], [ %.not14, %18 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !7, i64 0}
!6 = !{!"ep11kblob_header", !7, i64 0, !7, i64 1, !9, i64 2, !7, i64 4, !7, i64 5, !9, i64 6, !7, i64 8}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"short", !7, i64 0}
!10 = !{!6, !7, i64 1}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !9, i64 2}
!13 = !{!14, !9, i64 64}
!14 = !{!"ep11keytoken", !7, i64 0, !7, i64 32, !15, i64 48, !15, i64 56, !9, i64 64, !7, i64 66, !7, i64 80, !7, i64 224, !7, i64 256}
!15 = !{!"long long", !7, i64 0}


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