; 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_ec_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
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %17, label %11

11:                                               ; preds = %2
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = icmp ult i64 %12, 100
  br i1 %13, label %17, label %14

14:                                               ; preds = %11
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = icmp ugt i64 %15, 2048
  br i1 %16, label %17, label %18

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

18:                                               ; preds = %14
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store ptr %21, ptr %7, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ep11kblob_header, ptr %22, i32 0, i32 3
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = zext i8 %24 to i32
  %26 = icmp ne i32 %25, 7
  br i1 %26, label %27, label %28

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

28:                                               ; preds = %18
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ep11keytoken, ptr %29, i32 0, i32 4
  %31 = load i16, ptr %30, align 1, !tbaa !14
  %32 = zext i16 %31 to i32
  %33 = icmp ne i32 %32, 4660
  br i1 %33, label %34, label %35

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

35:                                               ; preds = %28
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %36

36:                                               ; preds = %35, %34, %27, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %37 = load i1, ptr %3, align 1
  ret i1 %37
}

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 4}
!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 = !{!15, !13, i64 64}
!15 = !{!"ep11keytoken", !7, i64 0, !7, i64 32, !16, i64 48, !16, i64 56, !13, i64 64, !7, i64 66, !7, i64 80, !7, i64 224, !7, i64 256}
!16 = !{!"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_ec_key_with_header(ptr noundef readonly %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = add i64 %1, -2049
  %5 = icmp ult i64 %4, -1949
  %or.cond3 = or i1 %3, %5
  br i1 %or.cond3, label %12, label %6

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

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = load i16, ptr %10, align 1, !tbaa !10
  %.not11 = icmp eq i16 %11, 4660
  br label %12

12:                                               ; preds = %9, %6, %2
  %.0 = phi i1 [ false, %2 ], [ false, %6 ], [ %.not11, %9 ]
  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 4}
!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 = !{!11, !9, i64 64}
!11 = !{!"ep11keytoken", !7, i64 0, !7, i64 32, !12, i64 48, !12, i64 56, !9, i64 64, !7, i64 66, !7, i64 80, !7, i64 224, !7, i64 256}
!12 = !{!"long long", !7, i64 0}


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