; LLVM IR from Trusted-eSign/trusted-crypto :: deps/wrapper/src/cms/signer_attrs.ll (ZN25SignerAttributeCollection5itemsE6HandleI3OIDEi)

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

%class.Handle.2 = type { ptr }
%class.LoggerFunction = type { %class.Handle.0, ptr }
%class.Handle.0 = type { ptr }
%class.SignerAttributeCollection = type <{ %class.Handle, i8, [7 x i8] }>
%class.Handle = type { ptr }

@logger = external global ptr, align 8
@__FUNCTION__._ZN25SignerAttributeCollection5itemsEii = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [31 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN14LoggerFunctionC1EP6LoggerPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #1

declare void @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, ptr noundef, ptr noundef, ...) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9SSLObjectI17CMS_SignerInfo_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

; Function Attrs: nounwind
declare void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN25SignerAttributeCollection5itemsEii(ptr dead_on_unwind noalias writable sret(%class.Handle.2) align 8, ptr noundef nonnull align 8 dereferenceable(9), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN25SignerAttributeCollection5itemsE6HandleI3OIDEi(ptr dead_on_unwind noalias writable sret(%class.Handle.2) align 8 %0, ptr noundef nonnull align 8 dereferenceable(9) %1, ptr noundef %2, i32 noundef %3) #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %class.LoggerFunction, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  %14 = load ptr, ptr @logger, align 8, !tbaa !5
  call void @_ZN14LoggerFunctionC1EP6LoggerPKc(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef %14, ptr noundef @__FUNCTION__._ZN25SignerAttributeCollection5itemsEii)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %15 = getelementptr inbounds %class.SignerAttributeCollection, ptr %13, i32 0, i32 1
  %16 = load i8, ptr %15, align 8, !tbaa !11, !range !15, !noundef !16
  %17 = trunc i8 %16 to i1
  br i1 %17, label %18, label %37

18:                                               ; preds = %4
  %19 = load ptr, ptr @logger, align 8, !tbaa !5
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24) %19, i32 noundef 32, ptr noundef @__FUNCTION__._ZN25SignerAttributeCollection5itemsEii, ptr noundef @.str.7)
          to label %20 unwind label %33

20:                                               ; preds = %18
  %21 = getelementptr inbounds %class.SignerAttributeCollection, ptr %13, i32 0, i32 0
  %22 = invoke noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8) %21)
          to label %23 unwind label %33

23:                                               ; preds = %20
  %24 = invoke noundef ptr @_ZN9SSLObjectI17CMS_SignerInfo_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16) %22)
          to label %25 unwind label %33

25:                                               ; preds = %23
  %26 = invoke noundef ptr @_ZNK6HandleI3OIDEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %27 unwind label %33

27:                                               ; preds = %25
  %28 = invoke noundef ptr @_ZN9SSLObjectI14asn1_object_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16) %26)
          to label %29 unwind label %33

29:                                               ; preds = %27
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = invoke i32 @CMS_signed_get_attr_by_OBJ(ptr noundef %24, ptr noundef %28, i32 noundef %30)
          to label %32 unwind label %33

32:                                               ; preds = %29
  store i32 %31, ptr %10, align 4, !tbaa !9
  br label %52

33:                                               ; preds = %52, %48, %46, %44, %42, %39, %37, %29, %27, %25, %23, %20, %18
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %11, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  br label %56

37:                                               ; preds = %4
  %38 = load ptr, ptr @logger, align 8, !tbaa !5
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24) %38, i32 noundef 32, ptr noundef @__FUNCTION__._ZN25SignerAttributeCollection5itemsEii, ptr noundef @.str.8)
          to label %39 unwind label %33

39:                                               ; preds = %37
  %40 = getelementptr inbounds %class.SignerAttributeCollection, ptr %13, i32 0, i32 0
  %41 = invoke noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8) %40)
          to label %42 unwind label %33

42:                                               ; preds = %39
  %43 = invoke noundef ptr @_ZN9SSLObjectI17CMS_SignerInfo_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16) %41)
          to label %44 unwind label %33

44:                                               ; preds = %42
  %45 = invoke noundef ptr @_ZNK6HandleI3OIDEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %46 unwind label %33

46:                                               ; preds = %44
  %47 = invoke noundef ptr @_ZN9SSLObjectI14asn1_object_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16) %45)
          to label %48 unwind label %33

48:                                               ; preds = %46
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = invoke i32 @CMS_unsigned_get_attr_by_OBJ(ptr noundef %43, ptr noundef %47, i32 noundef %49)
          to label %51 unwind label %33

51:                                               ; preds = %48
  store i32 %50, ptr %10, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %51, %32
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = load i32, ptr %8, align 4, !tbaa !9
  invoke void @_ZN25SignerAttributeCollection5itemsEii(ptr dead_on_unwind writable sret(%class.Handle.2) align 8 %0, ptr noundef nonnull align 8 dereferenceable(9) %13, i32 noundef %53, i32 noundef %54)
          to label %55 unwind label %33

55:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  ret void

56:                                               ; preds = %33
  %57 = load ptr, ptr %11, align 8
  %58 = load i32, ptr %12, align 4
  %59 = insertvalue { ptr, i32 } poison, ptr %57, 0
  %60 = insertvalue { ptr, i32 } %59, i32 %58, 1
  resume { ptr, i32 } %60
}

declare i32 @CMS_signed_get_attr_by_OBJ(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK6HandleI3OIDEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9SSLObjectI14asn1_object_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

declare i32 @CMS_unsigned_get_attr_by_OBJ(ptr noundef, ptr noundef, i32 noundef) #1

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 "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !14, i64 8}
!12 = !{!"_ZTS25SignerAttributeCollection", !13, i64 0, !14, i64 8}
!13 = !{!"_ZTS6HandleI6SignerE", !6, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}


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

%class.Handle.2 = type { ptr }
%class.LoggerFunction = type { %class.Handle.0, ptr }
%class.Handle.0 = type { ptr }

@logger = external local_unnamed_addr global ptr, align 8
@__FUNCTION__._ZN25SignerAttributeCollection5itemsEii = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [31 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN14LoggerFunctionC1EP6LoggerPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #1

declare void @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9SSLObjectI17CMS_SignerInfo_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

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

; Function Attrs: nounwind
declare void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN25SignerAttributeCollection5itemsEii(ptr dead_on_unwind noalias writable sret(%class.Handle.2) align 8, ptr noundef nonnull align 8 dereferenceable(9), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN25SignerAttributeCollection5itemsE6HandleI3OIDEi(ptr dead_on_unwind noalias writable sret(%class.Handle.2) align 8 %0, ptr noundef nonnull align 8 dereferenceable(9) %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %class.LoggerFunction, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  %6 = load ptr, ptr @logger, align 8, !tbaa !5
  call void @_ZN14LoggerFunctionC1EP6LoggerPKc(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %6, ptr noundef nonnull @__FUNCTION__._ZN25SignerAttributeCollection5itemsEii)
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load i8, ptr %7, align 8, !tbaa !9, !range !13, !noundef !14
  %9 = trunc nuw i8 %8 to i1
  %10 = load ptr, ptr @logger, align 8, !tbaa !5
  br i1 %9, label %11, label %24

11:                                               ; preds = %4
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef 32, ptr noundef nonnull @__FUNCTION__._ZN25SignerAttributeCollection5itemsEii, ptr noundef nonnull @.str.7)
          to label %12 unwind label %22

12:                                               ; preds = %11
  %13 = invoke noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
          to label %14 unwind label %22

14:                                               ; preds = %12
  %15 = invoke noundef ptr @_ZN9SSLObjectI17CMS_SignerInfo_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
          to label %16 unwind label %22

16:                                               ; preds = %14
  %17 = invoke noundef ptr @_ZNK6HandleI3OIDEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %18 unwind label %22

18:                                               ; preds = %16
  %19 = invoke noundef ptr @_ZN9SSLObjectI14asn1_object_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16) %17)
          to label %20 unwind label %22

20:                                               ; preds = %18
  %21 = invoke i32 @CMS_signed_get_attr_by_OBJ(ptr noundef %15, ptr noundef %19, i32 noundef %3)
          to label %35 unwind label %22

22:                                               ; preds = %35, %33, %31, %29, %27, %25, %24, %20, %18, %16, %14, %12, %11
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  resume { ptr, i32 } %23

24:                                               ; preds = %4
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef 32, ptr noundef nonnull @__FUNCTION__._ZN25SignerAttributeCollection5itemsEii, ptr noundef nonnull @.str.8)
          to label %25 unwind label %22

25:                                               ; preds = %24
  %26 = invoke noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
          to label %27 unwind label %22

27:                                               ; preds = %25
  %28 = invoke noundef ptr @_ZN9SSLObjectI17CMS_SignerInfo_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16) %26)
          to label %29 unwind label %22

29:                                               ; preds = %27
  %30 = invoke noundef ptr @_ZNK6HandleI3OIDEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %31 unwind label %22

31:                                               ; preds = %29
  %32 = invoke noundef ptr @_ZN9SSLObjectI14asn1_object_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16) %30)
          to label %33 unwind label %22

33:                                               ; preds = %31
  %34 = invoke i32 @CMS_unsigned_get_attr_by_OBJ(ptr noundef %28, ptr noundef %32, i32 noundef %3)
          to label %35 unwind label %22

35:                                               ; preds = %33, %20
  %.0 = phi i32 [ %21, %20 ], [ %34, %33 ]
  invoke void @_ZN25SignerAttributeCollection5itemsEii(ptr dead_on_unwind writable sret(%class.Handle.2) align 8 %0, ptr noundef nonnull align 8 dereferenceable(9) %1, i32 noundef %.0, i32 noundef %3)
          to label %36 unwind label %22

36:                                               ; preds = %35
  call void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret void
}

declare i32 @CMS_signed_get_attr_by_OBJ(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK6HandleI3OIDEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9SSLObjectI14asn1_object_stE8internalEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

declare i32 @CMS_unsigned_get_attr_by_OBJ(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 "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++ TBAA"}
!9 = !{!10, !12, i64 8}
!10 = !{!"_ZTS25SignerAttributeCollection", !11, i64 0, !12, i64 8}
!11 = !{!"_ZTS6HandleI6SignerE", !6, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


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