; LLVM IR from openssl/openssl :: crypto/objects (obj_xref)

; 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.nid_triple = type { i32, i32, i32 }

@sigoid_srt_xref = external hidden constant [48 x ptr], align 16
@sig_lock = external hidden global ptr, align 8
@.str = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.OBJ_find_sigid_by_algs = external hidden unnamed_addr constant [23 x i8], align 1
@sigx_app = external hidden global ptr, align 8

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

15:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %63

16:                                               ; preds = %3
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = getelementptr inbounds %struct.nid_triple, ptr %8, i32 0, i32 1
  store i32 %17, ptr %18, align 4, !tbaa !11
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = getelementptr inbounds %struct.nid_triple, ptr %8, i32 0, i32 2
  store i32 %19, ptr %20, align 4, !tbaa !13
  %21 = call ptr @OBJ_bsearch_sigx(ptr noundef %9, ptr noundef @sigoid_srt_xref, i32 noundef 48)
  store ptr %21, ptr %10, align 8, !tbaa !5
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %53

24:                                               ; preds = %16
  %25 = call i32 @obj_sig_init()
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %63

28:                                               ; preds = %24
  %29 = load ptr, ptr @sig_lock, align 8, !tbaa !5
  %30 = call i32 @CRYPTO_THREAD_read_lock(ptr noundef %29)
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 127, ptr noundef @__func__.OBJ_find_sigid_by_algs)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 8, i32 noundef 786703, ptr noundef null)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %63

33:                                               ; preds = %28
  %34 = load ptr, ptr @sigx_app, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %46

36:                                               ; preds = %33
  %37 = load ptr, ptr @sigx_app, align 8, !tbaa !5
  %38 = call i32 @sk_nid_triple_find(ptr noundef %37, ptr noundef %8)
  store i32 %38, ptr %11, align 4, !tbaa !9
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = icmp sge i32 %39, 0
  br i1 %40, label %41, label %45

41:                                               ; preds = %36
  %42 = load ptr, ptr @sigx_app, align 8, !tbaa !5
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = call ptr @sk_nid_triple_value(ptr noundef %42, i32 noundef %43)
  store ptr %44, ptr %9, align 8, !tbaa !5
  store ptr %9, ptr %10, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %41, %36
  br label %46

46:                                               ; preds = %45, %33
  %47 = load ptr, ptr @sig_lock, align 8, !tbaa !5
  %48 = call i32 @CRYPTO_THREAD_unlock(ptr noundef %47)
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = icmp eq ptr %49, null
  br i1 %50, label %51, label %52

51:                                               ; preds = %46
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %63

52:                                               ; preds = %46
  br label %53

53:                                               ; preds = %52, %16
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %62

56:                                               ; preds = %53
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.nid_triple, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 4, !tbaa !14
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 %60, ptr %61, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %56, %53
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %63

63:                                               ; preds = %62, %51, %32, %27, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #4
  %64 = load i32, ptr %4, align 4
  ret i32 %64
}

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @obj_sig_init() #2

declare i32 @CRYPTO_THREAD_read_lock(ptr noundef) #3

declare void @ERR_new() #3

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) #3

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @sk_nid_triple_find(ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @sk_nid_triple_value(ptr noundef, i32 noundef) #2

declare i32 @CRYPTO_THREAD_unlock(ptr noundef) #3

; 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 = { inlinehint 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 #3 = { "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 #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, 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"

%struct.nid_triple = type { i32, i32, i32 }

@sigoid_srt_xref = external hidden constant [48 x ptr], align 16
@sig_lock = external hidden local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.OBJ_find_sigid_by_algs = external hidden unnamed_addr constant [23 x i8], align 1
@sigx_app = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @OBJ_find_sigid_by_algs(ptr noundef writeonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.nid_triple, align 4
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store ptr %4, ptr %5, align 8, !tbaa !5
  %6 = icmp eq i32 %2, 0
  br i1 %6, label %34, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 %1, ptr %8, align 4, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %2, ptr %9, align 4, !tbaa !12
  %10 = call ptr @OBJ_bsearch_sigx(ptr noundef nonnull %5, ptr noundef nonnull @sigoid_srt_xref, i32 noundef 48)
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %30

12:                                               ; preds = %7
  %13 = call i32 @obj_sig_init()
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %34, label %14

14:                                               ; preds = %12
  %15 = load ptr, ptr @sig_lock, align 8, !tbaa !5
  %16 = call i32 @CRYPTO_THREAD_read_lock(ptr noundef %15) #4
  %.not17 = icmp eq i32 %16, 0
  br i1 %.not17, label %17, label %18

17:                                               ; preds = %14
  call void @ERR_new() #4
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 127, ptr noundef nonnull @__func__.OBJ_find_sigid_by_algs) #4
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 8, i32 noundef 786703, ptr noundef null) #4
  br label %34

18:                                               ; preds = %14
  %19 = load ptr, ptr @sigx_app, align 8, !tbaa !5
  %.not18 = icmp eq ptr %19, null
  br i1 %.not18, label %.thread, label %20

20:                                               ; preds = %18
  %21 = call i32 @sk_nid_triple_find(ptr noundef nonnull %19, ptr noundef nonnull %4)
  %22 = icmp sgt i32 %21, -1
  br i1 %22, label %25, label %.thread

.thread:                                          ; preds = %20, %18
  %23 = load ptr, ptr @sig_lock, align 8, !tbaa !5
  %24 = call i32 @CRYPTO_THREAD_unlock(ptr noundef %23) #4
  br label %34

25:                                               ; preds = %20
  %26 = load ptr, ptr @sigx_app, align 8, !tbaa !5
  %27 = call ptr @sk_nid_triple_value(ptr noundef %26, i32 noundef %21)
  store ptr %27, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr @sig_lock, align 8, !tbaa !5
  %29 = call i32 @CRYPTO_THREAD_unlock(ptr noundef %28) #4
  br label %30

30:                                               ; preds = %25, %7
  %.1 = phi ptr [ %5, %25 ], [ %10, %7 ]
  %.not19 = icmp eq ptr %0, null
  br i1 %.not19, label %34, label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %.1, align 8, !tbaa !5
  %33 = load i32, ptr %32, align 4, !tbaa !13
  store i32 %33, ptr %0, align 4, !tbaa !14
  br label %34

34:                                               ; preds = %.thread, %30, %31, %12, %3, %17
  %.0 = phi i32 [ 0, %17 ], [ 0, %3 ], [ 0, %12 ], [ 1, %31 ], [ 1, %30 ], [ 0, %.thread ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  ret i32 %.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: nounwind uwtable
declare hidden ptr @OBJ_bsearch_sigx(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @obj_sig_init() local_unnamed_addr #2

declare i32 @CRYPTO_THREAD_read_lock(ptr noundef) local_unnamed_addr #3

declare void @ERR_new() local_unnamed_addr #3

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @sk_nid_triple_find(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @sk_nid_triple_value(ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @CRYPTO_THREAD_unlock(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { "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 #4 = { 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, !11, i64 4}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 0}
!14 = !{!11, !11, i64 0}


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