; LLVM IR from specinfo-ua/UAPKI :: library/cm-pkcs12/src/storage/file-storage.ll (ZN11FileStorage14checkCipherOidEPKcS1_)

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

@OID_DES_EDE3_CBC = external global ptr, align 8
@_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS = external hidden global [6 x ptr], align 16
@_ZGVZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS = external hidden global i64, align 8
@OID_GOST28147_ECB = external global ptr, align 8
@OID_GOST28147_CFB = external global ptr, align 8
@OID_AES128_CBC_PAD = external global ptr, align 8
@OID_AES192_CBC_PAD = external global ptr, align 8
@OID_AES256_CBC_PAD = external global ptr, align 8

; 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

declare zeroext i1 @oid_is_equal(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11FileStorage14checkCipherOidEPKcS1_(ptr noundef %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load atomic i8, ptr @_ZGVZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS acquire, align 8
  %9 = icmp eq i8 %8, 0
  br i1 %9, label %10, label %20, !prof !9

10:                                               ; preds = %2
  %11 = call i32 @__cxa_guard_acquire(ptr @_ZGVZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS) #3
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %20

13:                                               ; preds = %10
  %14 = load ptr, ptr @OID_GOST28147_ECB, align 8, !tbaa !5
  store ptr %14, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, align 8, !tbaa !5
  %15 = load ptr, ptr @OID_GOST28147_CFB, align 8, !tbaa !5
  store ptr %15, ptr getelementptr inbounds (ptr, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 1), align 8, !tbaa !5
  %16 = load ptr, ptr @OID_AES128_CBC_PAD, align 8, !tbaa !5
  store ptr %16, ptr getelementptr inbounds (ptr, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 2), align 8, !tbaa !5
  %17 = load ptr, ptr @OID_AES192_CBC_PAD, align 8, !tbaa !5
  store ptr %17, ptr getelementptr inbounds (ptr, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 3), align 8, !tbaa !5
  %18 = load ptr, ptr @OID_AES256_CBC_PAD, align 8, !tbaa !5
  store ptr %18, ptr getelementptr inbounds (ptr, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 4), align 8, !tbaa !5
  %19 = load ptr, ptr @OID_DES_EDE3_CBC, align 8, !tbaa !5
  store ptr %19, ptr getelementptr inbounds (ptr, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 5), align 8, !tbaa !5
  call void @__cxa_guard_release(ptr @_ZGVZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS) #3
  br label %20

20:                                               ; preds = %13, %10, %2
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %45

23:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !10
  br label %24

24:                                               ; preds = %39, %23
  %25 = load i64, ptr %6, align 8, !tbaa !10
  %26 = icmp ult i64 %25, 6
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 2, ptr %7, align 4
  br label %42

28:                                               ; preds = %24
  %29 = load i64, ptr %6, align 8, !tbaa !10
  %30 = getelementptr inbounds [6 x ptr], ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 0, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call zeroext i1 @oid_is_equal(ptr noundef %31, ptr noundef %32)
  br i1 %33, label %34, label %38

34:                                               ; preds = %28
  %35 = load i64, ptr %6, align 8, !tbaa !10
  %36 = getelementptr inbounds [6 x ptr], ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 0, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  store ptr %37, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %42

38:                                               ; preds = %28
  br label %39

39:                                               ; preds = %38
  %40 = load i64, ptr %6, align 8, !tbaa !10
  %41 = add i64 %40, 1
  store i64 %41, ptr %6, align 8, !tbaa !10
  br label %24, !llvm.loop !12

42:                                               ; preds = %34, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %43 = load i32, ptr %7, align 4
  switch i32 %43, label %49 [
    i32 2, label %44
    i32 1, label %47
  ]

44:                                               ; preds = %42
  br label %45

45:                                               ; preds = %44, %20
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %46, ptr %3, align 8
  br label %47

47:                                               ; preds = %45, %42
  %48 = load ptr, ptr %3, align 8
  ret ptr %48

49:                                               ; preds = %42
  unreachable
}

; Function Attrs: nounwind
declare i32 @__cxa_guard_acquire(ptr) #3

; Function Attrs: nounwind
declare void @__cxa_guard_release(ptr) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"branch_weights", i32 1, i32 1048575}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

@OID_DES_EDE3_CBC = external local_unnamed_addr global ptr, align 8
@_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS = external hidden local_unnamed_addr global [6 x ptr], align 16
@_ZGVZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS = external hidden global i64, align 8
@OID_GOST28147_ECB = external local_unnamed_addr global ptr, align 8
@OID_GOST28147_CFB = external local_unnamed_addr global ptr, align 8
@OID_AES128_CBC_PAD = external local_unnamed_addr global ptr, align 8
@OID_AES192_CBC_PAD = external local_unnamed_addr global ptr, align 8
@OID_AES256_CBC_PAD = external local_unnamed_addr global ptr, align 8

declare zeroext i1 @oid_is_equal(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11FileStorage14checkCipherOidEPKcS1_(ptr noundef %0, ptr noundef readnone %1) local_unnamed_addr #1 align 2 {
  %3 = load atomic i8, ptr @_ZGVZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS acquire, align 8
  %4 = icmp eq i8 %3, 0
  br i1 %4, label %5, label %14, !prof !5

5:                                                ; preds = %2
  %6 = tail call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS) #3
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %14, label %7

7:                                                ; preds = %5
  %8 = load ptr, ptr @OID_GOST28147_ECB, align 8, !tbaa !6
  store ptr %8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, align 16, !tbaa !6
  %9 = load ptr, ptr @OID_GOST28147_CFB, align 8, !tbaa !6
  store ptr %9, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 8), align 8, !tbaa !6
  %10 = load ptr, ptr @OID_AES128_CBC_PAD, align 8, !tbaa !6
  store ptr %10, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 16), align 16, !tbaa !6
  %11 = load ptr, ptr @OID_AES192_CBC_PAD, align 8, !tbaa !6
  store ptr %11, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 24), align 8, !tbaa !6
  %12 = load ptr, ptr @OID_AES256_CBC_PAD, align 8, !tbaa !6
  store ptr %12, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 32), align 16, !tbaa !6
  %13 = load ptr, ptr @OID_DES_EDE3_CBC, align 8, !tbaa !6
  store ptr %13, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 40), align 8, !tbaa !6
  tail call void @__cxa_guard_release(ptr nonnull @_ZGVZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS) #3
  br label %14

14:                                               ; preds = %7, %5, %2
  %.not11 = icmp eq ptr %0, null
  br i1 %.not11, label %.thread, label %.preheader.preheader

.preheader.preheader:                             ; preds = %14
  %15 = load ptr, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, align 16, !tbaa !6
  %16 = tail call zeroext i1 @oid_is_equal(ptr noundef %15, ptr noundef nonnull %0)
  br i1 %16, label %27, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 8), align 8, !tbaa !6
  %18 = tail call zeroext i1 @oid_is_equal(ptr noundef %17, ptr noundef nonnull %0)
  br i1 %18, label %27, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 16), align 16, !tbaa !6
  %20 = tail call zeroext i1 @oid_is_equal(ptr noundef %19, ptr noundef nonnull %0)
  br i1 %20, label %27, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 24), align 8, !tbaa !6
  %22 = tail call zeroext i1 @oid_is_equal(ptr noundef %21, ptr noundef nonnull %0)
  br i1 %22, label %27, label %.preheader.4

.preheader.4:                                     ; preds = %.preheader.3
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 32), align 16, !tbaa !6
  %24 = tail call zeroext i1 @oid_is_equal(ptr noundef %23, ptr noundef nonnull %0)
  br i1 %24, label %27, label %.preheader.5

.preheader.5:                                     ; preds = %.preheader.4
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 40), align 8, !tbaa !6
  %26 = tail call zeroext i1 @oid_is_equal(ptr noundef %25, ptr noundef nonnull %0)
  br i1 %26, label %27, label %.thread

27:                                               ; preds = %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %.0816.lcssa = phi i64 [ 0, %.preheader.preheader ], [ 1, %.preheader.1 ], [ 2, %.preheader.2 ], [ 3, %.preheader.3 ], [ 4, %.preheader.4 ], [ 5, %.preheader.5 ]
  %28 = getelementptr inbounds [6 x ptr], ptr @_ZZN11FileStorage14checkCipherOidEPKcS1_E17SUPPORTED_CIPHERS, i64 0, i64 %.0816.lcssa
  %29 = load ptr, ptr %28, align 8, !tbaa !6
  br label %.thread

.thread:                                          ; preds = %.preheader.5, %14, %27
  %.1 = phi ptr [ %29, %27 ], [ %1, %14 ], [ %1, %.preheader.5 ]
  ret ptr %.1
}

; Function Attrs: nofree nounwind
declare i32 @__cxa_guard_acquire(ptr) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare void @__cxa_guard_release(ptr) local_unnamed_addr #2

attributes #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 = { mustprogress 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 = { nofree nounwind }
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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass