; LLVM IR from aws/s2n-tls :: crypto (s2n_certificate)

; 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.s2n_debug_info = type { ptr, ptr }
%struct.s2n_stuffer = type { %struct.s2n_blob, i32, i32, i32, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }
%struct.s2n_cert_chain = type { i32, ptr }
%struct.s2n_cert = type { i32, %struct.s2n_pkey, %struct.s2n_cert_info, %struct.s2n_blob, ptr }
%struct.s2n_pkey = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.s2n_cert_info = type { i32, i32, i32, i32, i8 }

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [94 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strrchr(ptr noundef, i32 noundef) #1

declare i32 @s2n_calculate_stacktrace() #2

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_create_cert_chain_from_stuffer(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.s2n_stuffer, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.s2n_blob, align 8
  %12 = alloca ptr, align 8
  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 40, ptr %6) #6
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 40, i1 false)
  br label %13

13:                                               ; preds = %2
  %14 = call i32 @s2n_stuffer_growable_alloc(ptr noundef %6, i32 noundef 2048)
  %15 = icmp sgt i32 %14, -1
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %169

17:                                               ; preds = %13
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.s2n_cert_chain, ptr %20, i32 0, i32 1
  store ptr %21, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %124, %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call zeroext i1 @s2n_stuffer_pem_has_certificate(ptr noundef %23)
  br i1 %24, label %25, label %125

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call i32 @s2n_stuffer_certificate_from_pem(ptr noundef %26, ptr noundef %6)
  store i32 %27, ptr %10, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %25
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %64, label %31

31:                                               ; preds = %28
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  %34 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %35 = getelementptr inbounds %struct.s2n_debug_info, ptr %34, i32 0, i32 0
  store ptr @.str.1, ptr %35, align 8, !tbaa !11
  %36 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %37 = getelementptr inbounds %struct.s2n_debug_info, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds i8, ptr %38, i64 21
  %40 = call ptr @strrchr(ptr noundef %39, i32 noundef 47) #7
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %49

42:                                               ; preds = %33
  %43 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %44 = getelementptr inbounds %struct.s2n_debug_info, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = getelementptr inbounds i8, ptr %45, i64 21
  %47 = call ptr @strrchr(ptr noundef %46, i32 noundef 47) #7
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  br label %54

49:                                               ; preds = %33
  %50 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %51 = getelementptr inbounds %struct.s2n_debug_info, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !11
  %53 = getelementptr inbounds i8, ptr %52, i64 21
  br label %54

54:                                               ; preds = %49, %42
  %55 = phi ptr [ %48, %42 ], [ %53, %49 ]
  %56 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %57 = getelementptr inbounds %struct.s2n_debug_info, ptr %56, i32 0, i32 1
  store ptr %55, ptr %57, align 8, !tbaa !13
  %58 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762057, ptr %58, align 4, !tbaa !9
  %59 = call i32 @s2n_calculate_stacktrace()
  br label %60

60:                                               ; preds = %54
  br label %61

61:                                               ; preds = %60
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %122

62:                                               ; No predecessors!
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63, %28
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #6
  call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 24, i1 false)
  br label %67

67:                                               ; preds = %66
  %68 = call i32 @s2n_alloc(ptr noundef %11, i32 noundef 112)
  %69 = icmp sgt i32 %68, -1
  br i1 %69, label %71, label %70

70:                                               ; preds = %67
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %120

71:                                               ; preds = %67
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  %75 = call i32 @s2n_blob_zero(ptr noundef %11)
  %76 = icmp sgt i32 %75, -1
  br i1 %76, label %78, label %77

77:                                               ; preds = %74
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %120

78:                                               ; preds = %74
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %81 = getelementptr inbounds %struct.s2n_blob, ptr %11, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !14
  store ptr %82, ptr %12, align 8, !tbaa !5
  br label %83

83:                                               ; preds = %80
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.s2n_cert, ptr %84, i32 0, i32 3
  %86 = getelementptr inbounds %struct.s2n_stuffer, ptr %6, i32 0, i32 2
  %87 = load i32, ptr %86, align 4, !tbaa !16
  %88 = getelementptr inbounds %struct.s2n_stuffer, ptr %6, i32 0, i32 1
  %89 = load i32, ptr %88, align 8, !tbaa !18
  %90 = sub i32 %87, %89
  %91 = call i32 @s2n_alloc(ptr noundef %85, i32 noundef %90)
  %92 = icmp sgt i32 %91, -1
  br i1 %92, label %94, label %93

93:                                               ; preds = %83
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %119

94:                                               ; preds = %83
  br label %95

95:                                               ; preds = %94
  br label %96

96:                                               ; preds = %95
  br label %97

97:                                               ; preds = %96
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.s2n_cert, ptr %98, i32 0, i32 3
  %100 = call i32 @s2n_stuffer_read(ptr noundef %6, ptr noundef %99)
  %101 = icmp sgt i32 %100, -1
  br i1 %101, label %103, label %102

102:                                              ; preds = %97
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %119

103:                                              ; preds = %97
  br label %104

104:                                              ; preds = %103
  br label %105

105:                                              ; preds = %104
  call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 24, i1 false)
  %106 = load ptr, ptr %12, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.s2n_cert, ptr %106, i32 0, i32 3
  %108 = getelementptr inbounds %struct.s2n_blob, ptr %107, i32 0, i32 1
  %109 = load i32, ptr %108, align 8, !tbaa !19
  %110 = add i32 %109, 3
  %111 = load i32, ptr %9, align 4, !tbaa !9
  %112 = add i32 %111, %110
  store i32 %112, ptr %9, align 4, !tbaa !9
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.s2n_cert, ptr %113, i32 0, i32 4
  store ptr null, ptr %114, align 8, !tbaa !24
  %115 = load ptr, ptr %12, align 8, !tbaa !5
  %116 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %115, ptr %116, align 8, !tbaa !5
  %117 = load ptr, ptr %12, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.s2n_cert, ptr %117, i32 0, i32 4
  store ptr %118, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %7, align 4
  br label %119

119:                                              ; preds = %105, %102, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %120

120:                                              ; preds = %119, %77, %70
  %121 = call i32 @s2n_free(ptr noundef %11)
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #6
  br label %122

122:                                              ; preds = %120, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %123 = load i32, ptr %7, align 4
  switch i32 %123, label %168 [
    i32 0, label %124
  ]

124:                                              ; preds = %122
  br label %22, !llvm.loop !25

125:                                              ; preds = %22
  br label %126

126:                                              ; preds = %125
  %127 = load i32, ptr %9, align 4, !tbaa !9
  %128 = icmp ugt i32 %127, 0
  br i1 %128, label %162, label %129

129:                                              ; preds = %126
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  %132 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %133 = getelementptr inbounds %struct.s2n_debug_info, ptr %132, i32 0, i32 0
  store ptr @.str.2, ptr %133, align 8, !tbaa !11
  %134 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %135 = getelementptr inbounds %struct.s2n_debug_info, ptr %134, i32 0, i32 0
  %136 = load ptr, ptr %135, align 8, !tbaa !11
  %137 = getelementptr inbounds i8, ptr %136, i64 21
  %138 = call ptr @strrchr(ptr noundef %137, i32 noundef 47) #7
  %139 = icmp ne ptr %138, null
  br i1 %139, label %140, label %147

140:                                              ; preds = %131
  %141 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %142 = getelementptr inbounds %struct.s2n_debug_info, ptr %141, i32 0, i32 0
  %143 = load ptr, ptr %142, align 8, !tbaa !11
  %144 = getelementptr inbounds i8, ptr %143, i64 21
  %145 = call ptr @strrchr(ptr noundef %144, i32 noundef 47) #7
  %146 = getelementptr inbounds i8, ptr %145, i64 1
  br label %152

147:                                              ; preds = %131
  %148 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %149 = getelementptr inbounds %struct.s2n_debug_info, ptr %148, i32 0, i32 0
  %150 = load ptr, ptr %149, align 8, !tbaa !11
  %151 = getelementptr inbounds i8, ptr %150, i64 21
  br label %152

152:                                              ; preds = %147, %140
  %153 = phi ptr [ %146, %140 ], [ %151, %147 ]
  %154 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %155 = getelementptr inbounds %struct.s2n_debug_info, ptr %154, i32 0, i32 1
  store ptr %153, ptr %155, align 8, !tbaa !13
  %156 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762062, ptr %156, align 4, !tbaa !9
  %157 = call i32 @s2n_calculate_stacktrace()
  br label %158

158:                                              ; preds = %152
  br label %159

159:                                              ; preds = %158
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %168

160:                                              ; No predecessors!
  br label %161

161:                                              ; preds = %160
  br label %162

162:                                              ; preds = %161, %126
  br label %163

163:                                              ; preds = %162
  br label %164

164:                                              ; preds = %163
  %165 = load i32, ptr %9, align 4, !tbaa !9
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.s2n_cert_chain, ptr %166, i32 0, i32 0
  store i32 %165, ptr %167, align 8, !tbaa !27
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %168

168:                                              ; preds = %164, %159, %122
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %169

169:                                              ; preds = %168, %16
  %170 = call i32 @s2n_stuffer_free(ptr noundef %6)
  call void @llvm.lifetime.end.p0(i64 40, ptr %6) #6
  %171 = load i32, ptr %3, align 4
  ret i32 %171
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

declare i32 @s2n_stuffer_free(ptr noundef) #2

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

declare zeroext i1 @s2n_stuffer_pem_has_certificate(ptr noundef) #2

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

declare i32 @s2n_free(ptr noundef) #2

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

declare i32 @s2n_blob_zero(ptr noundef) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nounwind willreturn memory(read) "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 = { "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 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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, !6, i64 0}
!12 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !6, i64 0}
!15 = !{!"s2n_blob", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!16 = !{!17, !10, i64 28}
!17 = !{!"s2n_stuffer", !15, i64 0, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 36, !10, i64 36}
!18 = !{!17, !10, i64 24}
!19 = !{!20, !10, i64 88}
!20 = !{!"s2n_cert", !10, i64 0, !21, i64 8, !22, i64 56, !15, i64 80, !6, i64 104}
!21 = !{!"s2n_pkey", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!22 = !{!"s2n_cert_info", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !23, i64 16}
!23 = !{!"_Bool", !7, i64 0}
!24 = !{!20, !6, i64 104}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!28, !10, i64 0}
!28 = !{!"s2n_cert_chain", !10, i64 0, !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"

%struct.s2n_debug_info = type { ptr, ptr }
%struct.s2n_stuffer = type { %struct.s2n_blob, i32, i32, i32, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }

@_s2n_debug_info = external thread_local local_unnamed_addr global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local local_unnamed_addr global i32, align 4
@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [94 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @s2n_create_cert_chain_from_stuffer(ptr nocapture noundef writeonly %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca %struct.s2n_stuffer, align 8
  %4 = alloca %struct.s2n_blob, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %3, i8 0, i64 40, i1 false)
  %5 = call i32 @s2n_stuffer_growable_alloc(ptr noundef nonnull %3, i32 noundef 2048) #6
  %6 = icmp sgt i32 %5, -1
  br i1 %6, label %7, label %56

7:                                                ; preds = %2
  %8 = call zeroext i1 @s2n_stuffer_pem_has_certificate(ptr noundef %1) #6
  br i1 %8, label %.lr.ph, label %._crit_edge.thread

.lr.ph:                                           ; preds = %7
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = getelementptr inbounds i8, ptr %3, i64 28
  %11 = getelementptr inbounds i8, ptr %3, i64 24
  br label %12

12:                                               ; preds = %.lr.ph, %40
  %.01943 = phi i32 [ 0, %.lr.ph ], [ %44, %40 ]
  %.02342 = phi ptr [ %9, %.lr.ph ], [ %45, %40 ]
  %13 = call i32 @s2n_stuffer_certificate_from_pem(ptr noundef %1, ptr noundef nonnull %3) #6
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %22, label %.thread

.thread:                                          ; preds = %12
  %15 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.1, ptr %15, align 8, !tbaa !5
  %16 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.1, i64 21), i32 noundef 47) #7
  %.not30 = icmp eq ptr %16, null
  %17 = getelementptr inbounds i8, ptr %16, i64 1
  %18 = select i1 %.not30, ptr getelementptr inbounds (i8, ptr @.str.1, i64 21), ptr %17
  %19 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %18, ptr %19, align 8, !tbaa !10
  %20 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762057, ptr %20, align 4, !tbaa !11
  %21 = call i32 @s2n_calculate_stacktrace() #6
  br label %56

22:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, i8 0, i64 24, i1 false)
  %23 = call i32 @s2n_alloc(ptr noundef nonnull %4, i32 noundef 112) #6
  %24 = icmp sgt i32 %23, -1
  br i1 %24, label %25, label %.thread35

25:                                               ; preds = %22
  %26 = call i32 @s2n_blob_zero(ptr noundef nonnull %4) #6
  %27 = icmp sgt i32 %26, -1
  br i1 %27, label %28, label %.thread35

28:                                               ; preds = %25
  %29 = load ptr, ptr %4, align 8, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %29, i64 80
  %31 = load i32, ptr %10, align 4, !tbaa !15
  %32 = load i32, ptr %11, align 8, !tbaa !17
  %33 = sub i32 %31, %32
  %34 = call i32 @s2n_alloc(ptr noundef nonnull %30, i32 noundef %33) #6
  %35 = icmp sgt i32 %34, -1
  br i1 %35, label %36, label %.thread35

36:                                               ; preds = %28
  %37 = call i32 @s2n_stuffer_read(ptr noundef nonnull %3, ptr noundef nonnull %30) #6
  %38 = icmp sgt i32 %37, -1
  br i1 %38, label %40, label %.thread35

.thread35:                                        ; preds = %22, %25, %28, %36
  %39 = call i32 @s2n_free(ptr noundef nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  br label %56

40:                                               ; preds = %36
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, i8 0, i64 24, i1 false)
  %41 = getelementptr inbounds i8, ptr %29, i64 88
  %42 = load i32, ptr %41, align 8, !tbaa !18
  %43 = add i32 %.01943, 3
  %44 = add i32 %43, %42
  %45 = getelementptr inbounds i8, ptr %29, i64 104
  store ptr null, ptr %45, align 8, !tbaa !23
  store ptr %29, ptr %.02342, align 8, !tbaa !24
  %46 = call i32 @s2n_free(ptr noundef nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  %47 = call zeroext i1 @s2n_stuffer_pem_has_certificate(ptr noundef %1) #6
  br i1 %47, label %12, label %._crit_edge, !llvm.loop !25

._crit_edge:                                      ; preds = %40
  %.not = icmp eq i32 %44, 0
  br i1 %.not, label %._crit_edge.thread, label %55

._crit_edge.thread:                               ; preds = %7, %._crit_edge
  %48 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.2, ptr %48, align 8, !tbaa !5
  %49 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.2, i64 21), i32 noundef 47) #7
  %.not29 = icmp eq ptr %49, null
  %50 = getelementptr inbounds i8, ptr %49, i64 1
  %51 = select i1 %.not29, ptr getelementptr inbounds (i8, ptr @.str.2, i64 21), ptr %50
  %52 = getelementptr inbounds i8, ptr %48, i64 8
  store ptr %51, ptr %52, align 8, !tbaa !10
  %53 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 469762062, ptr %53, align 4, !tbaa !11
  %54 = call i32 @s2n_calculate_stacktrace() #6
  br label %56

55:                                               ; preds = %._crit_edge
  store i32 %44, ptr %0, align 8, !tbaa !27
  br label %56

56:                                               ; preds = %.thread35, %.thread, %._crit_edge.thread, %55, %2
  %.5 = phi i32 [ -1, %2 ], [ 0, %55 ], [ -1, %._crit_edge.thread ], [ -1, %.thread ], [ -1, %.thread35 ]
  %57 = call i32 @s2n_stuffer_free(ptr noundef nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #6
  ret i32 %.5
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

declare i32 @s2n_stuffer_free(ptr noundef) local_unnamed_addr #2

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

declare zeroext i1 @s2n_stuffer_pem_has_certificate(ptr noundef) local_unnamed_addr #2

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

declare i32 @s2n_free(ptr noundef) local_unnamed_addr #2

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

declare i32 @s2n_blob_zero(ptr noundef) local_unnamed_addr #2

declare i32 @s2n_stuffer_read(ptr noundef, 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) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { "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 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 #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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, !7, i64 0}
!6 = !{!"s2n_debug_info", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"s2n_blob", !7, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!15 = !{!16, !12, i64 28}
!16 = !{!"s2n_stuffer", !14, i64 0, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 36, !12, i64 36}
!17 = !{!16, !12, i64 24}
!18 = !{!19, !12, i64 88}
!19 = !{!"s2n_cert", !12, i64 0, !20, i64 8, !21, i64 56, !14, i64 80, !7, i64 104}
!20 = !{!"s2n_pkey", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!21 = !{!"s2n_cert_info", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !22, i64 16}
!22 = !{!"_Bool", !8, i64 0}
!23 = !{!19, !7, i64 104}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!28, !12, i64 0}
!28 = !{!"s2n_cert_chain", !12, i64 0, !7, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass