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

@sig_lock = external hidden global ptr, align 8
@.str = external hidden unnamed_addr constant [75 x i8], align 1
@sigx_app = external hidden global ptr, align 8
@__func__.OBJ_add_sigid = external hidden unnamed_addr constant [14 x i8], align 1
@sig_app = external hidden global ptr, align 8

; Function Attrs: nounwind uwtable
declare hidden i32 @ossl_obj_find_sigid_algs(i32 noundef, ptr noundef, ptr noundef, i32 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: inlinehint nounwind uwtable
declare hidden i32 @obj_sig_init() #2

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

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

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

15:                                               ; preds = %3
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %19

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

19:                                               ; preds = %15
  %20 = call i32 @obj_sig_init()
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %95

23:                                               ; preds = %19
  %24 = call ptr @CRYPTO_malloc(i64 noundef 12, ptr noundef @.str, i32 noundef 158)
  store ptr %24, ptr %8, align 8, !tbaa !9
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %95

27:                                               ; preds = %23
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.nid_triple, ptr %29, i32 0, i32 0
  store i32 %28, ptr %30, align 4, !tbaa !11
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.nid_triple, ptr %32, i32 0, i32 1
  store i32 %31, ptr %33, align 4, !tbaa !13
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.nid_triple, ptr %35, i32 0, i32 2
  store i32 %34, ptr %36, align 4, !tbaa !14
  %37 = load ptr, ptr @sig_lock, align 8, !tbaa !9
  %38 = call i32 @CRYPTO_THREAD_write_lock(ptr noundef %37)
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %42, label %40

40:                                               ; preds = %27
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 165, ptr noundef @__func__.OBJ_add_sigid)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 8, i32 noundef 786704, ptr noundef null)
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  call void @CRYPTO_free(ptr noundef %41, ptr noundef @.str, i32 noundef 166)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %95

42:                                               ; preds = %27
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = call i32 @ossl_obj_find_sigid_algs(i32 noundef %43, ptr noundef %9, ptr noundef %10, i32 noundef 0)
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %57

46:                                               ; preds = %42
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = icmp eq i32 %47, %48
  br i1 %49, label %50, label %54

50:                                               ; preds = %46
  %51 = load i32, ptr %10, align 4, !tbaa !5
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = icmp eq i32 %51, %52
  br label %54

54:                                               ; preds = %50, %46
  %55 = phi i1 [ false, %46 ], [ %53, %50 ]
  %56 = zext i1 %55 to i32
  store i32 %56, ptr %11, align 4, !tbaa !5
  br label %90

57:                                               ; preds = %42
  %58 = load ptr, ptr @sig_app, align 8, !tbaa !9
  %59 = icmp eq ptr %58, null
  br i1 %59, label %60, label %66

60:                                               ; preds = %57
  %61 = call ptr @sk_nid_triple_new(ptr noundef @sig_sk_cmp)
  store ptr %61, ptr @sig_app, align 8, !tbaa !9
  %62 = load ptr, ptr @sig_app, align 8, !tbaa !9
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %65

64:                                               ; preds = %60
  br label %90

65:                                               ; preds = %60
  br label %66

66:                                               ; preds = %65, %57
  %67 = load ptr, ptr @sigx_app, align 8, !tbaa !9
  %68 = icmp eq ptr %67, null
  br i1 %68, label %69, label %75

69:                                               ; preds = %66
  %70 = call ptr @sk_nid_triple_new(ptr noundef @sigx_cmp)
  store ptr %70, ptr @sigx_app, align 8, !tbaa !9
  %71 = load ptr, ptr @sigx_app, align 8, !tbaa !9
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %74

73:                                               ; preds = %69
  br label %90

74:                                               ; preds = %69
  br label %75

75:                                               ; preds = %74, %66
  %76 = load ptr, ptr @sig_app, align 8, !tbaa !9
  %77 = load ptr, ptr %8, align 8, !tbaa !9
  %78 = call i32 @sk_nid_triple_push(ptr noundef %76, ptr noundef %77)
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %81, label %80

80:                                               ; preds = %75
  br label %90

81:                                               ; preds = %75
  %82 = load ptr, ptr @sigx_app, align 8, !tbaa !9
  %83 = load ptr, ptr %8, align 8, !tbaa !9
  %84 = call i32 @sk_nid_triple_push(ptr noundef %82, ptr noundef %83)
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %87, label %86

86:                                               ; preds = %81
  store ptr null, ptr %8, align 8, !tbaa !9
  br label %90

87:                                               ; preds = %81
  %88 = load ptr, ptr @sig_app, align 8, !tbaa !9
  call void @sk_nid_triple_sort(ptr noundef %88)
  %89 = load ptr, ptr @sigx_app, align 8, !tbaa !9
  call void @sk_nid_triple_sort(ptr noundef %89)
  store ptr null, ptr %8, align 8, !tbaa !9
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %87, %86, %80, %73, %64, %54
  %91 = load ptr, ptr %8, align 8, !tbaa !9
  call void @CRYPTO_free(ptr noundef %91, ptr noundef @.str, i32 noundef 204)
  %92 = load ptr, ptr @sig_lock, align 8, !tbaa !9
  %93 = call i32 @CRYPTO_THREAD_unlock(ptr noundef %92)
  %94 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %94, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %95

95:                                               ; preds = %90, %40, %26, %22, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %96 = load i32, ptr %4, align 4
  ret i32 %96
}

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) #3

declare i32 @CRYPTO_THREAD_write_lock(ptr noundef) #3

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

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @sk_nid_triple_sort(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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 8}


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

@sig_lock = external hidden local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [75 x i8], align 1
@sigx_app = external hidden local_unnamed_addr global ptr, align 8
@__func__.OBJ_add_sigid = external hidden unnamed_addr constant [14 x i8], align 1
@sig_app = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare hidden i32 @ossl_obj_find_sigid_algs(i32 noundef, ptr noundef, ptr noundef, i32 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: inlinehint nounwind uwtable
declare hidden i32 @obj_sig_init() local_unnamed_addr #2

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

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

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

8:                                                ; preds = %3
  %9 = tail call i32 @obj_sig_init()
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %53, label %10

10:                                               ; preds = %8
  %11 = tail call ptr @CRYPTO_malloc(i64 noundef 12, ptr noundef nonnull @.str, i32 noundef 158) #4
  %12 = icmp eq ptr %11, null
  br i1 %12, label %53, label %13

13:                                               ; preds = %10
  store i32 %0, ptr %11, align 4, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %11, i64 4
  store i32 %1, ptr %14, align 4, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %11, i64 8
  store i32 %2, ptr %15, align 4, !tbaa !12
  %16 = load ptr, ptr @sig_lock, align 8, !tbaa !13
  %17 = tail call i32 @CRYPTO_THREAD_write_lock(ptr noundef %16) #4
  %.not22 = icmp eq i32 %17, 0
  br i1 %.not22, label %18, label %19

18:                                               ; preds = %13
  tail call void @ERR_new() #4
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 165, ptr noundef nonnull @__func__.OBJ_add_sigid) #4
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 8, i32 noundef 786704, ptr noundef null) #4
  tail call void @CRYPTO_free(ptr noundef nonnull %11, ptr noundef nonnull @.str, i32 noundef 166) #4
  br label %53

19:                                               ; preds = %13
  %20 = call i32 @ossl_obj_find_sigid_algs(i32 noundef %0, ptr noundef nonnull %4, ptr noundef nonnull %5, i32 noundef 0)
  %.not23 = icmp eq i32 %20, 0
  br i1 %.not23, label %28, label %21

21:                                               ; preds = %19
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp eq i32 %22, %1
  %24 = load i32, ptr %5, align 4
  %25 = icmp eq i32 %24, %2
  %26 = select i1 %23, i1 %25, i1 false
  %27 = zext i1 %26 to i32
  br label %50

28:                                               ; preds = %19
  %29 = load ptr, ptr @sig_app, align 8, !tbaa !13
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %34

31:                                               ; preds = %28
  %32 = call ptr @sk_nid_triple_new(ptr noundef nonnull @sig_sk_cmp)
  store ptr %32, ptr @sig_app, align 8, !tbaa !13
  %33 = icmp eq ptr %32, null
  br i1 %33, label %50, label %34

34:                                               ; preds = %31, %28
  %35 = phi ptr [ %32, %31 ], [ %29, %28 ]
  %36 = load ptr, ptr @sigx_app, align 8, !tbaa !13
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %41

38:                                               ; preds = %34
  %39 = call ptr @sk_nid_triple_new(ptr noundef nonnull @sigx_cmp)
  store ptr %39, ptr @sigx_app, align 8, !tbaa !13
  %40 = icmp eq ptr %39, null
  br i1 %40, label %50, label %._crit_edge

._crit_edge:                                      ; preds = %38
  %.pre = load ptr, ptr @sig_app, align 8, !tbaa !13
  br label %41

41:                                               ; preds = %._crit_edge, %34
  %42 = phi ptr [ %.pre, %._crit_edge ], [ %35, %34 ]
  %43 = call i32 @sk_nid_triple_push(ptr noundef %42, ptr noundef nonnull %11)
  %.not24 = icmp eq i32 %43, 0
  br i1 %.not24, label %50, label %44

44:                                               ; preds = %41
  %45 = load ptr, ptr @sigx_app, align 8, !tbaa !13
  %46 = call i32 @sk_nid_triple_push(ptr noundef %45, ptr noundef nonnull %11)
  %.not25 = icmp eq i32 %46, 0
  br i1 %.not25, label %50, label %47

47:                                               ; preds = %44
  %48 = load ptr, ptr @sig_app, align 8, !tbaa !13
  call void @sk_nid_triple_sort(ptr noundef %48)
  %49 = load ptr, ptr @sigx_app, align 8, !tbaa !13
  call void @sk_nid_triple_sort(ptr noundef %49)
  br label %50

50:                                               ; preds = %44, %41, %38, %31, %47, %21
  %.017 = phi ptr [ %11, %21 ], [ %11, %31 ], [ %11, %38 ], [ null, %47 ], [ %11, %41 ], [ null, %44 ]
  %.0 = phi i32 [ %27, %21 ], [ 0, %31 ], [ 0, %38 ], [ 1, %47 ], [ 0, %41 ], [ 0, %44 ]
  call void @CRYPTO_free(ptr noundef %.017, ptr noundef nonnull @.str, i32 noundef 204) #4
  %51 = load ptr, ptr @sig_lock, align 8, !tbaa !13
  %52 = call i32 @CRYPTO_THREAD_unlock(ptr noundef %51) #4
  br label %53

53:                                               ; preds = %10, %8, %3, %50, %18
  %.018 = phi i32 [ %.0, %50 ], [ 0, %18 ], [ 0, %3 ], [ 0, %8 ], [ 0, %10 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  ret i32 %.018
}

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @CRYPTO_THREAD_write_lock(ptr noundef) local_unnamed_addr #3

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

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @sk_nid_triple_sort(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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}


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