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

; 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_ecc_preferences = type { i8, ptr }
%struct.s2n_ecc_named_curve = type { i16, i32, ptr, i8, ptr }

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.57 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [91 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

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

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

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 @s2n_connection_get_ecc_preferences(ptr noundef %16, ptr noundef %8)
  %18 = icmp sgt i32 %17, -1
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %178

20:                                               ; preds = %15
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %59, label %26

26:                                               ; preds = %23
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  %29 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %30 = getelementptr inbounds %struct.s2n_debug_info, ptr %29, i32 0, i32 0
  store ptr @.str.57, ptr %30, align 8, !tbaa !9
  %31 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %32 = getelementptr inbounds %struct.s2n_debug_info, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %33, i64 21
  %35 = call ptr @strrchr(ptr noundef %34, i32 noundef 47) #7
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %44

37:                                               ; preds = %28
  %38 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %39 = getelementptr inbounds %struct.s2n_debug_info, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds i8, ptr %40, i64 21
  %42 = call ptr @strrchr(ptr noundef %41, i32 noundef 47) #7
  %43 = getelementptr inbounds i8, ptr %42, i64 1
  br label %49

44:                                               ; preds = %28
  %45 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %46 = getelementptr inbounds %struct.s2n_debug_info, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds i8, ptr %47, i64 21
  br label %49

49:                                               ; preds = %44, %37
  %50 = phi ptr [ %43, %37 ], [ %48, %44 ]
  %51 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %52 = getelementptr inbounds %struct.s2n_debug_info, ptr %51, i32 0, i32 1
  store ptr %50, ptr %52, align 8, !tbaa !11
  %53 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %53, align 4, !tbaa !12
  %54 = call i32 @s2n_calculate_stacktrace()
  br label %55

55:                                               ; preds = %49
  br label %56

56:                                               ; preds = %55
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %178

57:                                               ; No predecessors!
  br label %58

58:                                               ; preds = %57
  br label %59

59:                                               ; preds = %58, %23
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #6
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 40, i1 false)
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = call i32 @s2n_stuffer_init(ptr noundef %10, ptr noundef %63)
  %65 = icmp sgt i32 %64, -1
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %177

67:                                               ; preds = %62
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  br label %70

70:                                               ; preds = %69
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = call i32 @s2n_stuffer_write(ptr noundef %10, ptr noundef %71)
  %73 = icmp sgt i32 %72, -1
  br i1 %73, label %75, label %74

74:                                               ; preds = %70
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %177

75:                                               ; preds = %70
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !14
  br label %78

78:                                               ; preds = %139, %77
  %79 = load i64, ptr %11, align 8, !tbaa !14
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.s2n_ecc_preferences, ptr %80, i32 0, i32 0
  %82 = load i8, ptr %81, align 8, !tbaa !16
  %83 = zext i8 %82 to i64
  %84 = icmp ult i64 %79, %83
  br i1 %84, label %86, label %85

85:                                               ; preds = %78
  store i32 14, ptr %9, align 4
  br label %142

86:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.s2n_ecc_preferences, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !18
  %90 = load i64, ptr %11, align 8, !tbaa !14
  %91 = getelementptr inbounds ptr, ptr %89, i64 %90
  %92 = load ptr, ptr %91, align 8, !tbaa !5
  store ptr %92, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !12
  br label %93

93:                                               ; preds = %123, %86
  %94 = load i32, ptr %13, align 4, !tbaa !12
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.s2n_blob, ptr %95, i32 0, i32 1
  %97 = load i32, ptr %96, align 8, !tbaa !19
  %98 = udiv i32 %97, 2
  %99 = icmp ult i32 %94, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %93
  store i32 17, ptr %9, align 4
  br label %126

101:                                              ; preds = %93
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #6
  store i16 0, ptr %14, align 2, !tbaa !21
  br label %102

102:                                              ; preds = %101
  %103 = call i32 @s2n_stuffer_read_uint16(ptr noundef %10, ptr noundef %14)
  %104 = icmp sgt i32 %103, -1
  br i1 %104, label %106, label %105

105:                                              ; preds = %102
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %120

106:                                              ; preds = %102
  br label %107

107:                                              ; preds = %106
  br label %108

108:                                              ; preds = %107
  %109 = load ptr, ptr %12, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.s2n_ecc_named_curve, ptr %109, i32 0, i32 0
  %111 = load i16, ptr %110, align 8, !tbaa !23
  %112 = zext i16 %111 to i32
  %113 = load i16, ptr %14, align 2, !tbaa !21
  %114 = zext i16 %113 to i32
  %115 = icmp eq i32 %112, %114
  br i1 %115, label %116, label %119

116:                                              ; preds = %108
  %117 = load ptr, ptr %12, align 8, !tbaa !5
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %117, ptr %118, align 8, !tbaa !5
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %120

119:                                              ; preds = %108
  store i32 0, ptr %9, align 4
  br label %120

120:                                              ; preds = %119, %116, %105
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #6
  %121 = load i32, ptr %9, align 4
  switch i32 %121, label %126 [
    i32 0, label %122
  ]

122:                                              ; preds = %120
  br label %123

123:                                              ; preds = %122
  %124 = load i32, ptr %13, align 4, !tbaa !12
  %125 = add i32 %124, 1
  store i32 %125, ptr %13, align 4, !tbaa !12
  br label %93, !llvm.loop !25

126:                                              ; preds = %120, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  %127 = load i32, ptr %9, align 4
  switch i32 %127, label %136 [
    i32 17, label %128
  ]

128:                                              ; preds = %126
  br label %129

129:                                              ; preds = %128
  %130 = call i32 @s2n_stuffer_reread(ptr noundef %10)
  %131 = icmp sgt i32 %130, -1
  br i1 %131, label %133, label %132

132:                                              ; preds = %129
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %136

133:                                              ; preds = %129
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134
  store i32 0, ptr %9, align 4
  br label %136

136:                                              ; preds = %135, %132, %126
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  %137 = load i32, ptr %9, align 4
  switch i32 %137, label %142 [
    i32 0, label %138
  ]

138:                                              ; preds = %136
  br label %139

139:                                              ; preds = %138
  %140 = load i64, ptr %11, align 8, !tbaa !14
  %141 = add i64 %140, 1
  store i64 %141, ptr %11, align 8, !tbaa !14
  br label %78, !llvm.loop !27

142:                                              ; preds = %136, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %143 = load i32, ptr %9, align 4
  switch i32 %143, label %177 [
    i32 14, label %144
  ]

144:                                              ; preds = %142
  br label %145

145:                                              ; preds = %144
  br label %146

146:                                              ; preds = %145
  %147 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %148 = getelementptr inbounds %struct.s2n_debug_info, ptr %147, i32 0, i32 0
  store ptr @.str.58, ptr %148, align 8, !tbaa !9
  %149 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %150 = getelementptr inbounds %struct.s2n_debug_info, ptr %149, i32 0, i32 0
  %151 = load ptr, ptr %150, align 8, !tbaa !9
  %152 = getelementptr inbounds i8, ptr %151, i64 21
  %153 = call ptr @strrchr(ptr noundef %152, i32 noundef 47) #7
  %154 = icmp ne ptr %153, null
  br i1 %154, label %155, label %162

155:                                              ; preds = %146
  %156 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %157 = getelementptr inbounds %struct.s2n_debug_info, ptr %156, i32 0, i32 0
  %158 = load ptr, ptr %157, align 8, !tbaa !9
  %159 = getelementptr inbounds i8, ptr %158, i64 21
  %160 = call ptr @strrchr(ptr noundef %159, i32 noundef 47) #7
  %161 = getelementptr inbounds i8, ptr %160, i64 1
  br label %167

162:                                              ; preds = %146
  %163 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %164 = getelementptr inbounds %struct.s2n_debug_info, ptr %163, i32 0, i32 0
  %165 = load ptr, ptr %164, align 8, !tbaa !9
  %166 = getelementptr inbounds i8, ptr %165, i64 21
  br label %167

167:                                              ; preds = %162, %155
  %168 = phi ptr [ %161, %155 ], [ %166, %162 ]
  %169 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %170 = getelementptr inbounds %struct.s2n_debug_info, ptr %169, i32 0, i32 1
  store ptr %168, ptr %170, align 8, !tbaa !11
  %171 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544356, ptr %171, align 4, !tbaa !12
  %172 = call i32 @s2n_calculate_stacktrace()
  br label %173

173:                                              ; preds = %167
  br label %174

174:                                              ; preds = %173
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %177

175:                                              ; No predecessors!
  br label %176

176:                                              ; preds = %175
  store i32 0, ptr %9, align 4
  br label %177

177:                                              ; preds = %176, %174, %142, %74, %66
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #6
  br label %178

178:                                              ; preds = %177, %56, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %179 = load i32, ptr %9, align 4
  switch i32 %179, label %182 [
    i32 0, label %180
    i32 1, label %180
  ]

180:                                              ; preds = %178, %178
  %181 = load i32, ptr %4, align 4
  ret i32 %181

182:                                              ; preds = %178
  unreachable
}

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

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

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

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

declare i32 @s2n_stuffer_reread(ptr noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #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, !6, i64 0}
!10 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !7, i64 0}
!17 = !{!"s2n_ecc_preferences", !7, i64 0, !6, i64 8}
!18 = !{!17, !6, i64 8}
!19 = !{!20, !13, i64 8}
!20 = !{!"s2n_blob", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!21 = !{!22, !22, i64 0}
!22 = !{!"short", !7, i64 0}
!23 = !{!24, !22, i64 0}
!24 = !{!"s2n_ecc_named_curve", !22, i64 0, !13, i64 4, !6, i64 8, !7, i64 16, !6, i64 24}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}


; 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.57 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [91 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @s2n_ecc_evp_find_supported_curve(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #5 {
  %4 = alloca ptr, align 8
  %5 = alloca %struct.s2n_stuffer, align 8
  %6 = alloca i16, align 2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  store ptr null, ptr %4, align 8, !tbaa !5
  %7 = call i32 @s2n_connection_get_ecc_preferences(ptr noundef %0, ptr noundef nonnull %4) #6
  %8 = icmp sgt i32 %7, -1
  br i1 %8, label %9, label %60

9:                                                ; preds = %3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %11, label %19

11:                                               ; preds = %9
  %12 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.57, ptr %12, align 8, !tbaa !9
  %13 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.57, i64 21), i32 noundef 47) #7
  %.not27 = icmp eq ptr %13, null
  %14 = getelementptr inbounds i8, ptr %13, i64 1
  %15 = select i1 %.not27, ptr getelementptr inbounds (i8, ptr @.str.57, i64 21), ptr %14
  %16 = getelementptr inbounds i8, ptr %12, i64 8
  store ptr %15, ptr %16, align 8, !tbaa !11
  %17 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %17, align 4, !tbaa !12
  %18 = call i32 @s2n_calculate_stacktrace() #6
  br label %60

19:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %5, i8 0, i64 40, i1 false)
  %20 = call i32 @s2n_stuffer_init(ptr noundef nonnull %5, ptr noundef %1) #6
  %21 = icmp sgt i32 %20, -1
  br i1 %21, label %22, label %.loopexit

22:                                               ; preds = %19
  %23 = call i32 @s2n_stuffer_write(ptr noundef nonnull %5, ptr noundef %1) #6
  %24 = icmp sgt i32 %23, -1
  br i1 %24, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %22
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 8, !tbaa !14
  %.not2944.not = icmp eq i8 %26, 0
  br i1 %.not2944.not, label %.thread38, label %.lr.ph46

.lr.ph46:                                         ; preds = %.preheader
  %27 = getelementptr inbounds i8, ptr %1, i64 8
  br label %33

28:                                               ; preds = %._crit_edge
  %29 = add nuw nsw i64 %.02045, 1
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 8, !tbaa !14
  %32 = zext i8 %31 to i64
  %.not29 = icmp ult i64 %29, %32
  br i1 %.not29, label %33, label %.thread38, !llvm.loop !16

33:                                               ; preds = %.lr.ph46, %28
  %34 = phi ptr [ %25, %.lr.ph46 ], [ %30, %28 ]
  %.02045 = phi i64 [ 0, %.lr.ph46 ], [ %29, %28 ]
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = getelementptr inbounds ptr, ptr %36, i64 %.02045
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = load i32, ptr %27, align 8, !tbaa !19
  %.not2842.not = icmp ult i32 %39, 2
  br i1 %.not2842.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %33, %47
  %.043 = phi i32 [ %48, %47 ], [ 0, %33 ]
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %6) #6
  store i16 0, ptr %6, align 2, !tbaa !21
  %40 = call i32 @s2n_stuffer_read_uint16(ptr noundef nonnull %5, ptr noundef nonnull %6) #6
  %41 = icmp sgt i32 %40, -1
  br i1 %41, label %42, label %.thread35

42:                                               ; preds = %.lr.ph
  %43 = load i16, ptr %38, align 8, !tbaa !23
  %44 = load i16, ptr %6, align 2, !tbaa !21
  %45 = icmp eq i16 %43, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  store ptr %38, ptr %2, align 8, !tbaa !5
  br label %.thread35

.thread35:                                        ; preds = %.lr.ph, %46
  %.2.ph = phi i32 [ 0, %46 ], [ -1, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %6) #6
  br label %.loopexit

47:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %6) #6
  %48 = add nuw nsw i32 %.043, 1
  %49 = load i32, ptr %27, align 8, !tbaa !19
  %50 = lshr i32 %49, 1
  %.not28 = icmp ult i32 %48, %50
  br i1 %.not28, label %.lr.ph, label %._crit_edge, !llvm.loop !25

._crit_edge:                                      ; preds = %47, %33
  %51 = call i32 @s2n_stuffer_reread(ptr noundef nonnull %5) #6
  %52 = icmp sgt i32 %51, -1
  br i1 %52, label %28, label %.loopexit

.thread38:                                        ; preds = %28, %.preheader
  %53 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.58, ptr %53, align 8, !tbaa !9
  %54 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.58, i64 21), i32 noundef 47) #7
  %.not30 = icmp eq ptr %54, null
  %55 = getelementptr inbounds i8, ptr %54, i64 1
  %56 = select i1 %.not30, ptr getelementptr inbounds (i8, ptr @.str.58, i64 21), ptr %55
  %57 = getelementptr inbounds i8, ptr %53, i64 8
  store ptr %56, ptr %57, align 8, !tbaa !11
  %58 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544356, ptr %58, align 4, !tbaa !12
  %59 = call i32 @s2n_calculate_stacktrace() #6
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge, %.thread35, %22, %19, %.thread38
  %.6 = phi i32 [ -1, %.thread38 ], [ -1, %19 ], [ -1, %22 ], [ %.2.ph, %.thread35 ], [ -1, %._crit_edge ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #6
  br label %60

60:                                               ; preds = %3, %.loopexit, %11
  %.7 = phi i32 [ %.6, %.loopexit ], [ -1, %11 ], [ -1, %3 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  ret i32 %.7
}

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

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

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

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

declare i32 @s2n_stuffer_reread(ptr noundef) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #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, !6, i64 0}
!10 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"s2n_ecc_preferences", !7, i64 0, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!15, !6, i64 8}
!19 = !{!20, !13, i64 8}
!20 = !{!"s2n_blob", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!21 = !{!22, !22, i64 0}
!22 = !{!"short", !7, i64 0}
!23 = !{!24, !22, i64 0}
!24 = !{!"s2n_ecc_named_curve", !22, i64 0, !13, i64 4, !6, i64 8, !7, i64 16, !6, i64 24}
!25 = distinct !{!25, !17}


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