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

; 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_result = type { i32 }
%struct.s2n_kem_params = type { ptr, %struct.s2n_blob, %struct.s2n_blob, %struct.s2n_blob, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }
%struct.s2n_kem = type { ptr, i32, i16, i16, i16, i16, i16, ptr, ptr, ptr }

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.40 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_kem_generate_keypair(ptr noundef) #0

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

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

declare i32 @s2n_calculate_stacktrace() #3

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_kem_send_public_key(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.s2n_result, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %43, label %12

12:                                               ; preds = %9
  br label %13

13:                                               ; preds = %12
  br label %14

14:                                               ; preds = %13
  %15 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %16 = getelementptr inbounds %struct.s2n_debug_info, ptr %15, i32 0, i32 0
  store ptr @.str.40, ptr %16, align 8, !tbaa !9
  %17 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %18 = getelementptr inbounds %struct.s2n_debug_info, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %19, i64 21
  %21 = call ptr @strrchr(ptr noundef %20, i32 noundef 47) #6
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %30

23:                                               ; preds = %14
  %24 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %25 = getelementptr inbounds %struct.s2n_debug_info, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %26, i64 21
  %28 = call ptr @strrchr(ptr noundef %27, i32 noundef 47) #6
  %29 = getelementptr inbounds i8, ptr %28, i64 1
  br label %35

30:                                               ; preds = %14
  %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
  br label %35

35:                                               ; preds = %30, %23
  %36 = phi ptr [ %29, %23 ], [ %34, %30 ]
  %37 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %38 = getelementptr inbounds %struct.s2n_debug_info, ptr %37, i32 0, i32 1
  store ptr %36, ptr %38, align 8, !tbaa !11
  %39 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %39, align 4, !tbaa !12
  %40 = call i32 @s2n_calculate_stacktrace()
  br label %41

41:                                               ; preds = %35
  store i32 -1, ptr %3, align 4
  br label %215

42:                                               ; No predecessors!
  br label %43

43:                                               ; preds = %42, %9
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %79, label %48

48:                                               ; preds = %45
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  %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 0
  store ptr @.str.41, ptr %52, align 8, !tbaa !9
  %53 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %54 = getelementptr inbounds %struct.s2n_debug_info, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  %56 = getelementptr inbounds i8, ptr %55, i64 21
  %57 = call ptr @strrchr(ptr noundef %56, i32 noundef 47) #6
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %66

59:                                               ; preds = %50
  %60 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %61 = getelementptr inbounds %struct.s2n_debug_info, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = getelementptr inbounds i8, ptr %62, i64 21
  %64 = call ptr @strrchr(ptr noundef %63, i32 noundef 47) #6
  %65 = getelementptr inbounds i8, ptr %64, i64 1
  br label %71

66:                                               ; preds = %50
  %67 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %68 = getelementptr inbounds %struct.s2n_debug_info, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds i8, ptr %69, i64 21
  br label %71

71:                                               ; preds = %66, %59
  %72 = phi ptr [ %65, %59 ], [ %70, %66 ]
  %73 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %74 = getelementptr inbounds %struct.s2n_debug_info, ptr %73, i32 0, i32 1
  store ptr %72, ptr %74, align 8, !tbaa !11
  %75 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %75, align 4, !tbaa !12
  %76 = call i32 @s2n_calculate_stacktrace()
  br label %77

77:                                               ; preds = %71
  store i32 -1, ptr %3, align 4
  br label %215

78:                                               ; No predecessors!
  br label %79

79:                                               ; preds = %78, %45
  br label %80

80:                                               ; preds = %79
  br label %81

81:                                               ; preds = %80
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.s2n_kem_params, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !14
  %85 = icmp ne ptr %84, null
  br i1 %85, label %117, label %86

86:                                               ; preds = %81
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %90 = getelementptr inbounds %struct.s2n_debug_info, ptr %89, i32 0, i32 0
  store ptr @.str.42, ptr %90, align 8, !tbaa !9
  %91 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %92 = getelementptr inbounds %struct.s2n_debug_info, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !9
  %94 = getelementptr inbounds i8, ptr %93, i64 21
  %95 = call ptr @strrchr(ptr noundef %94, i32 noundef 47) #6
  %96 = icmp ne ptr %95, null
  br i1 %96, label %97, label %104

97:                                               ; preds = %88
  %98 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %99 = getelementptr inbounds %struct.s2n_debug_info, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !9
  %101 = getelementptr inbounds i8, ptr %100, i64 21
  %102 = call ptr @strrchr(ptr noundef %101, i32 noundef 47) #6
  %103 = getelementptr inbounds i8, ptr %102, i64 1
  br label %109

104:                                              ; preds = %88
  %105 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %106 = getelementptr inbounds %struct.s2n_debug_info, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !9
  %108 = getelementptr inbounds i8, ptr %107, i64 21
  br label %109

109:                                              ; preds = %104, %97
  %110 = phi ptr [ %103, %97 ], [ %108, %104 ]
  %111 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %112 = getelementptr inbounds %struct.s2n_debug_info, ptr %111, i32 0, i32 1
  store ptr %110, ptr %112, align 8, !tbaa !11
  %113 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %113, align 4, !tbaa !12
  %114 = call i32 @s2n_calculate_stacktrace()
  br label %115

115:                                              ; preds = %109
  store i32 -1, ptr %3, align 4
  br label %215

116:                                              ; No predecessors!
  br label %117

117:                                              ; preds = %116, %81
  br label %118

118:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.s2n_kem_params, ptr %119, i32 0, i32 0
  %121 = load ptr, ptr %120, align 8, !tbaa !14
  store ptr %121, ptr %6, align 8, !tbaa !5
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.s2n_kem_params, ptr %122, i32 0, i32 4
  %124 = load i8, ptr %123, align 8, !tbaa !18, !range !19, !noundef !20
  %125 = trunc i8 %124 to i1
  br i1 %125, label %126, label %138

126:                                              ; preds = %118
  br label %127

127:                                              ; preds = %126
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.s2n_kem, ptr %129, i32 0, i32 3
  %131 = load i16, ptr %130, align 2, !tbaa !21
  %132 = call i32 @s2n_stuffer_write_uint16(ptr noundef %128, i16 noundef zeroext %131)
  %133 = icmp sgt i32 %132, -1
  br i1 %133, label %135, label %134

134:                                              ; preds = %127
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %214

135:                                              ; preds = %127
  br label %136

136:                                              ; preds = %135
  br label %137

137:                                              ; preds = %136
  br label %138

138:                                              ; preds = %137, %118
  %139 = load ptr, ptr %4, align 8, !tbaa !5
  %140 = load ptr, ptr %6, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.s2n_kem, ptr %140, i32 0, i32 3
  %142 = load i16, ptr %141, align 2, !tbaa !21
  %143 = zext i16 %142 to i32
  %144 = call ptr @s2n_stuffer_raw_write(ptr noundef %139, i32 noundef %143)
  %145 = load ptr, ptr %5, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.s2n_kem_params, ptr %145, i32 0, i32 1
  %147 = getelementptr inbounds %struct.s2n_blob, ptr %146, i32 0, i32 0
  store ptr %144, ptr %147, align 8, !tbaa !24
  br label %148

148:                                              ; preds = %138
  %149 = load ptr, ptr %5, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.s2n_kem_params, ptr %149, i32 0, i32 1
  %151 = getelementptr inbounds %struct.s2n_blob, ptr %150, i32 0, i32 0
  %152 = load ptr, ptr %151, align 8, !tbaa !24
  %153 = icmp ne ptr %152, null
  br i1 %153, label %187, label %154

154:                                              ; preds = %148
  br label %155

155:                                              ; preds = %154
  br label %156

156:                                              ; preds = %155
  %157 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %158 = getelementptr inbounds %struct.s2n_debug_info, ptr %157, i32 0, i32 0
  store ptr @.str.43, ptr %158, align 8, !tbaa !9
  %159 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %160 = getelementptr inbounds %struct.s2n_debug_info, ptr %159, i32 0, i32 0
  %161 = load ptr, ptr %160, align 8, !tbaa !9
  %162 = getelementptr inbounds i8, ptr %161, i64 21
  %163 = call ptr @strrchr(ptr noundef %162, i32 noundef 47) #6
  %164 = icmp ne ptr %163, null
  br i1 %164, label %165, label %172

165:                                              ; preds = %156
  %166 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %167 = getelementptr inbounds %struct.s2n_debug_info, ptr %166, i32 0, i32 0
  %168 = load ptr, ptr %167, align 8, !tbaa !9
  %169 = getelementptr inbounds i8, ptr %168, i64 21
  %170 = call ptr @strrchr(ptr noundef %169, i32 noundef 47) #6
  %171 = getelementptr inbounds i8, ptr %170, i64 1
  br label %177

172:                                              ; preds = %156
  %173 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %174 = getelementptr inbounds %struct.s2n_debug_info, ptr %173, i32 0, i32 0
  %175 = load ptr, ptr %174, align 8, !tbaa !9
  %176 = getelementptr inbounds i8, ptr %175, i64 21
  br label %177

177:                                              ; preds = %172, %165
  %178 = phi ptr [ %171, %165 ], [ %176, %172 ]
  %179 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %180 = getelementptr inbounds %struct.s2n_debug_info, ptr %179, i32 0, i32 1
  store ptr %178, ptr %180, align 8, !tbaa !11
  %181 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %181, align 4, !tbaa !12
  %182 = call i32 @s2n_calculate_stacktrace()
  br label %183

183:                                              ; preds = %177
  br label %184

184:                                              ; preds = %183
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %214

185:                                              ; No predecessors!
  br label %186

186:                                              ; preds = %185
  br label %187

187:                                              ; preds = %186, %148
  br label %188

188:                                              ; preds = %187
  br label %189

189:                                              ; preds = %188
  %190 = load ptr, ptr %6, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.s2n_kem, ptr %190, i32 0, i32 3
  %192 = load i16, ptr %191, align 2, !tbaa !21
  %193 = zext i16 %192 to i32
  %194 = load ptr, ptr %5, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.s2n_kem_params, ptr %194, i32 0, i32 1
  %196 = getelementptr inbounds %struct.s2n_blob, ptr %195, i32 0, i32 1
  store i32 %193, ptr %196, align 8, !tbaa !25
  br label %197

197:                                              ; preds = %189
  %198 = load ptr, ptr %5, align 8, !tbaa !5
  %199 = call i32 @s2n_kem_generate_keypair(ptr noundef %198)
  %200 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  store i32 %199, ptr %200, align 4
  %201 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  %202 = load i32, ptr %201, align 4
  %203 = call zeroext i1 @s2n_result_is_ok(i32 %202)
  br i1 %203, label %205, label %204

204:                                              ; preds = %197
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %214

205:                                              ; preds = %197
  br label %206

206:                                              ; preds = %205
  br label %207

207:                                              ; preds = %206
  %208 = load ptr, ptr %5, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.s2n_kem_params, ptr %208, i32 0, i32 1
  %210 = getelementptr inbounds %struct.s2n_blob, ptr %209, i32 0, i32 0
  store ptr null, ptr %210, align 8, !tbaa !24
  %211 = load ptr, ptr %5, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.s2n_kem_params, ptr %211, i32 0, i32 1
  %213 = getelementptr inbounds %struct.s2n_blob, ptr %212, i32 0, i32 1
  store i32 0, ptr %213, align 8, !tbaa !25
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %214

214:                                              ; preds = %207, %204, %184, %134
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %215

215:                                              ; preds = %214, %115, %77, %41
  %216 = load i32, ptr %3, align 4
  ret i32 %216
}

declare i32 @s2n_stuffer_write_uint16(ptr noundef, i16 noundef zeroext) #3

declare ptr @s2n_stuffer_raw_write(ptr noundef, i32 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) #5

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 speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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/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, !6, i64 0}
!15 = !{!"s2n_kem_params", !6, i64 0, !16, i64 8, !16, i64 32, !16, i64 56, !17, i64 80}
!16 = !{!"s2n_blob", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!15, !17, i64 80}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!22, !23, i64 14}
!22 = !{!"s2n_kem", !6, i64 0, !13, i64 8, !23, i64 12, !23, i64 14, !23, i64 16, !23, i64 18, !23, i64 20, !6, i64 24, !6, i64 32, !6, i64 40}
!23 = !{!"short", !7, i64 0}
!24 = !{!15, !6, i64 8}
!25 = !{!15, !13, i64 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"

%struct.s2n_debug_info = type { ptr, ptr }

@_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.40 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_kem_generate_keypair(ptr noundef) local_unnamed_addr #0

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

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

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_kem_send_public_key(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %11

3:                                                ; preds = %2
  %4 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.40, ptr %4, align 8, !tbaa !5
  %5 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.40, i64 21), i32 noundef 47) #5
  %.not23 = icmp eq ptr %5, null
  %6 = getelementptr inbounds i8, ptr %5, i64 1
  %7 = select i1 %.not23, ptr getelementptr inbounds (i8, ptr @.str.40, i64 21), ptr %6
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %7, ptr %8, align 8, !tbaa !10
  %9 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %9, align 4, !tbaa !11
  %10 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %60

11:                                               ; preds = %2
  %.not24 = icmp eq ptr %1, null
  br i1 %.not24, label %12, label %20

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

20:                                               ; preds = %11
  %21 = load ptr, ptr %1, align 8, !tbaa !13
  %.not26 = icmp eq ptr %21, null
  br i1 %.not26, label %22, label %30

22:                                               ; preds = %20
  %23 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.42, ptr %23, align 8, !tbaa !5
  %24 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.42, i64 21), i32 noundef 47) #5
  %.not27 = icmp eq ptr %24, null
  %25 = getelementptr inbounds i8, ptr %24, i64 1
  %26 = select i1 %.not27, ptr getelementptr inbounds (i8, ptr @.str.42, i64 21), ptr %25
  %27 = getelementptr inbounds i8, ptr %23, i64 8
  store ptr %26, ptr %27, align 8, !tbaa !10
  %28 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %28, align 4, !tbaa !11
  %29 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %60

30:                                               ; preds = %20
  %31 = getelementptr inbounds i8, ptr %1, i64 80
  %32 = load i8, ptr %31, align 8, !tbaa !17, !range !18, !noundef !19
  %33 = trunc nuw i8 %32 to i1
  br i1 %33, label %34, label %39

34:                                               ; preds = %30
  %35 = getelementptr inbounds i8, ptr %21, i64 14
  %36 = load i16, ptr %35, align 2, !tbaa !20
  %37 = tail call i32 @s2n_stuffer_write_uint16(ptr noundef nonnull %0, i16 noundef zeroext %36) #6
  %38 = icmp sgt i32 %37, -1
  br i1 %38, label %39, label %60

39:                                               ; preds = %34, %30
  %40 = getelementptr inbounds i8, ptr %21, i64 14
  %41 = load i16, ptr %40, align 2, !tbaa !20
  %42 = zext i16 %41 to i32
  %43 = tail call ptr @s2n_stuffer_raw_write(ptr noundef nonnull %0, i32 noundef %42) #6
  %44 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %43, ptr %44, align 8, !tbaa !23
  %.not28 = icmp eq ptr %43, null
  br i1 %.not28, label %45, label %53

45:                                               ; preds = %39
  %46 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.43, ptr %46, align 8, !tbaa !5
  %47 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.43, i64 21), i32 noundef 47) #5
  %.not29 = icmp eq ptr %47, null
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  %49 = select i1 %.not29, ptr getelementptr inbounds (i8, ptr @.str.43, i64 21), ptr %48
  %50 = getelementptr inbounds i8, ptr %46, i64 8
  store ptr %49, ptr %50, align 8, !tbaa !10
  %51 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %51, align 4, !tbaa !11
  %52 = tail call i32 @s2n_calculate_stacktrace() #6
  br label %60

53:                                               ; preds = %39
  %54 = load i16, ptr %40, align 2, !tbaa !20
  %55 = zext i16 %54 to i32
  %56 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 %55, ptr %56, align 8, !tbaa !24
  %57 = tail call i32 @s2n_kem_generate_keypair(ptr noundef nonnull %1)
  %58 = tail call zeroext i1 @s2n_result_is_ok(i32 %57)
  br i1 %58, label %59, label %60

59:                                               ; preds = %53
  store ptr null, ptr %44, align 8, !tbaa !23
  store i32 0, ptr %56, align 8, !tbaa !24
  br label %60

60:                                               ; preds = %45, %59, %34, %53, %22, %12, %3
  %.1 = phi i32 [ -1, %22 ], [ -1, %12 ], [ -1, %3 ], [ 0, %59 ], [ -1, %45 ], [ -1, %34 ], [ -1, %53 ]
  ret i32 %.1
}

declare i32 @s2n_stuffer_write_uint16(ptr noundef, i16 noundef zeroext) local_unnamed_addr #3

declare ptr @s2n_stuffer_raw_write(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) local_unnamed_addr #4

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 speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = { 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 #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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, !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_kem_params", !7, i64 0, !15, i64 8, !15, i64 32, !15, i64 56, !16, i64 80}
!15 = !{!"s2n_blob", !7, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{!14, !16, i64 80}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!21, !22, i64 14}
!21 = !{!"s2n_kem", !7, i64 0, !12, i64 8, !22, i64 12, !22, i64 14, !22, i64 16, !22, i64 18, !22, i64 20, !7, i64 24, !7, i64 32, !7, i64 40}
!22 = !{!"short", !8, i64 0}
!23 = !{!14, !7, i64 8}
!24 = !{!14, !12, i64 16}


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