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

; 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.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__._ZN25SignerAttributeCollection6lengthEv = external hidden unnamed_addr constant [7 x i8], align 1
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

12:                                               ; preds = %1
  %13 = load ptr, ptr @logger, align 8, !tbaa !5
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24) %13, i32 noundef 32, ptr noundef @__FUNCTION__._ZN25SignerAttributeCollection6lengthEv, ptr noundef @.str)
          to label %14 unwind label %22

14:                                               ; preds = %12
  %15 = getelementptr inbounds %class.SignerAttributeCollection, ptr %7, i32 0, i32 0
  %16 = invoke noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8) %15)
          to label %17 unwind label %22

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

19:                                               ; preds = %17
  %20 = invoke i32 @CMS_signed_get_attr_count(ptr noundef %18)
          to label %21 unwind label %22

21:                                               ; preds = %19
  store i32 %20, ptr %4, align 4, !tbaa !9
  br label %36

22:                                               ; preds = %33, %31, %28, %26, %19, %17, %14, %12
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %5, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #4
  br label %38

26:                                               ; preds = %1
  %27 = load ptr, ptr @logger, align 8, !tbaa !5
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24) %27, i32 noundef 32, ptr noundef @__FUNCTION__._ZN25SignerAttributeCollection6lengthEv, ptr noundef @.str.1)
          to label %28 unwind label %22

28:                                               ; preds = %26
  %29 = getelementptr inbounds %class.SignerAttributeCollection, ptr %7, i32 0, i32 0
  %30 = invoke noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8) %29)
          to label %31 unwind label %22

31:                                               ; preds = %28
  %32 = invoke noundef ptr @_ZN9SSLObjectI17CMS_SignerInfo_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_count(ptr noundef %32)
          to label %35 unwind label %22

35:                                               ; preds = %33
  store i32 %34, ptr %4, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %35, %21
  %37 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #4
  ret i32 %37

38:                                               ; preds = %22
  %39 = load ptr, ptr %5, align 8
  %40 = load i32, ptr %6, align 4
  %41 = insertvalue { ptr, i32 } poison, ptr %39, 0
  %42 = insertvalue { ptr, i32 } %41, i32 %40, 1
  resume { ptr, i32 } %42
}

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

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

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

declare i32 @CMS_signed_get_attr_count(ptr noundef) #2

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

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

declare i32 @CMS_unsigned_get_attr_count(ptr noundef) #2

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

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

attributes #0 = { 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 #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 "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.LoggerFunction = type { %class.Handle.0, ptr }
%class.Handle.0 = type { ptr }

@logger = external local_unnamed_addr global ptr, align 8
@__FUNCTION__._ZN25SignerAttributeCollection6lengthEv = external hidden unnamed_addr constant [7 x i8], align 1
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

8:                                                ; preds = %1
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24) %7, i32 noundef 32, ptr noundef nonnull @__FUNCTION__._ZN25SignerAttributeCollection6lengthEv, ptr noundef nonnull @.str)
          to label %9 unwind label %15

9:                                                ; preds = %8
  %10 = invoke noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
          to label %11 unwind label %15

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

13:                                               ; preds = %11
  %14 = invoke i32 @CMS_signed_get_attr_count(ptr noundef %12)
          to label %24 unwind label %15

15:                                               ; preds = %22, %20, %18, %17, %13, %11, %9, %8
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  resume { ptr, i32 } %16

17:                                               ; preds = %1
  invoke void (ptr, i32, ptr, ptr, ...) @_ZN6Logger5writeEN11LoggerLevel12LOGGER_LEVELEPKcS3_z(ptr noundef nonnull align 8 dereferenceable(24) %7, i32 noundef 32, ptr noundef nonnull @__FUNCTION__._ZN25SignerAttributeCollection6lengthEv, ptr noundef nonnull @.str.1)
          to label %18 unwind label %15

18:                                               ; preds = %17
  %19 = invoke noundef ptr @_ZNK6HandleI6SignerEptEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
          to label %20 unwind label %15

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

22:                                               ; preds = %20
  %23 = invoke i32 @CMS_unsigned_get_attr_count(ptr noundef %21)
          to label %24 unwind label %15

24:                                               ; preds = %22, %13
  %.0 = phi i32 [ %14, %13 ], [ %23, %22 ]
  call void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #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

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

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

declare i32 @CMS_signed_get_attr_count(ptr noundef) local_unnamed_addr #2

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

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

declare i32 @CMS_unsigned_get_attr_count(ptr noundef) local_unnamed_addr #2

; 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
declare void @_ZN14LoggerFunctionD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

attributes #0 = { 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 #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 "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