; LLVM IR from openssl/openssl :: crypto/asn1 (x_algor)

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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @X509_ALGOR_it() #0

; Function Attrs: nounwind uwtable
declare dso_local void @X509_ALGOR_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ossl_X509_ALGOR_from_nid(i32 noundef, i32 noundef, ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ossl_x509_algor_new_from_md(ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_x509_algor_md_to_mgf1(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, 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 ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr null, ptr %7, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr null, ptr %9, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %16, label %12

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call i32 @EVP_MD_is_a(ptr noundef %13, ptr noundef @.str.2)
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %12, %2
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %44

17:                                               ; preds = %12
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call i32 @ossl_x509_algor_new_from_md(ptr noundef %6, ptr noundef %18)
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  br label %37

22:                                               ; preds = %17
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = call ptr @X509_ALGOR_it()
  %25 = call ptr @ASN1_item_pack(ptr noundef %23, ptr noundef %24, ptr noundef %7)
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  br label %37

28:                                               ; preds = %22
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call ptr @ossl_X509_ALGOR_from_nid(i32 noundef 911, i32 noundef 16, ptr noundef %29)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %30, ptr %31, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %36

35:                                               ; preds = %28
  br label %37

36:                                               ; preds = %28
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %36, %35, %27, %21
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ASN1_STRING_free(ptr noundef %38)
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  call void @X509_ALGOR_free(ptr noundef %39)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  %43 = zext i1 %42 to i32
  store i32 %43, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %44

44:                                               ; preds = %37, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %45 = load i32, ptr %3, align 4
  ret i32 %45
}

declare ptr @ASN1_item_pack(ptr noundef, ptr noundef, ptr noundef) #2

declare void @ASN1_STRING_free(ptr noundef) #2

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @X509_ALGOR_it() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @X509_ALGOR_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ossl_X509_ALGOR_from_nid(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ossl_x509_algor_new_from_md(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @EVP_MD_is_a(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_x509_algor_md_to_mgf1(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  store ptr null, ptr %4, align 8, !tbaa !5
  store ptr null, ptr %0, align 8, !tbaa !5
  %5 = icmp eq ptr %1, null
  br i1 %5, label %25, label %6

6:                                                ; preds = %2
  %7 = tail call i32 @EVP_MD_is_a(ptr noundef nonnull %1, ptr noundef nonnull @.str.2) #3
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %8, label %25

8:                                                ; preds = %6
  %9 = call i32 @ossl_x509_algor_new_from_md(ptr noundef nonnull %3, ptr noundef nonnull %1)
  %.not8 = icmp eq i32 %9, 0
  br i1 %.not8, label %19, label %10

10:                                               ; preds = %8
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call ptr @X509_ALGOR_it()
  %13 = call ptr @ASN1_item_pack(ptr noundef %11, ptr noundef %12, ptr noundef nonnull %4) #3
  %14 = icmp eq ptr %13, null
  %.pre9 = load ptr, ptr %4, align 8, !tbaa !5
  br i1 %14, label %19, label %15

15:                                               ; preds = %10
  %16 = call ptr @ossl_X509_ALGOR_from_nid(i32 noundef 911, i32 noundef 16, ptr noundef %.pre9)
  store ptr %16, ptr %0, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %._crit_edge, label %18

._crit_edge:                                      ; preds = %15
  %.pre = load ptr, ptr %4, align 8, !tbaa !5
  br label %19

18:                                               ; preds = %15
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %._crit_edge, %10, %8, %18
  %20 = phi ptr [ %.pre, %._crit_edge ], [ %.pre9, %10 ], [ null, %8 ], [ null, %18 ]
  call void @ASN1_STRING_free(ptr noundef %20) #3
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  call void @X509_ALGOR_free(ptr noundef %21)
  %22 = load ptr, ptr %0, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  %24 = zext i1 %23 to i32
  br label %25

25:                                               ; preds = %2, %6, %19
  %.0 = phi i32 [ %24, %19 ], [ 1, %6 ], [ 1, %2 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i32 %.0
}

declare ptr @ASN1_item_pack(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @ASN1_STRING_free(ptr noundef) local_unnamed_addr #2

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 = { mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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