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

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

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.17 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [87 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_check_all_dh_params(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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

declare i32 @DH_size(ptr noundef) #3

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_dh_compute_shared_secret_as_server(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca %struct.s2n_blob, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  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 2, ptr %8) #6
  store i16 0, ptr %8, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #6
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store ptr null, ptr %11, align 8, !tbaa !5
  br label %14

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

18:                                               ; preds = %14
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %224

19:                                               ; preds = %14
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = call i32 @s2n_stuffer_read_uint16(ptr noundef %23, ptr noundef %8)
  %25 = icmp sgt i32 %24, -1
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %224

27:                                               ; preds = %22
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  %30 = load i16, ptr %8, align 2, !tbaa !9
  %31 = zext i16 %30 to i32
  %32 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 1
  store i32 %31, ptr %32, align 8, !tbaa !13
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 1
  %35 = load i32, ptr %34, align 8, !tbaa !13
  %36 = call ptr @s2n_stuffer_raw_read(ptr noundef %33, i32 noundef %35)
  %37 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 0
  store ptr %36, ptr %37, align 8, !tbaa !15
  br label %38

38:                                               ; preds = %29
  %39 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  %41 = icmp ne ptr %40, null
  br i1 %41, label %75, label %42

42:                                               ; preds = %38
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %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
  store ptr @.str.17, ptr %46, align 8, !tbaa !16
  %47 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %48 = getelementptr inbounds %struct.s2n_debug_info, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !16
  %50 = getelementptr inbounds i8, ptr %49, i64 21
  %51 = call ptr @strrchr(ptr noundef %50, i32 noundef 47) #7
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %60

53:                                               ; preds = %44
  %54 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %55 = getelementptr inbounds %struct.s2n_debug_info, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  %57 = getelementptr inbounds i8, ptr %56, i64 21
  %58 = call ptr @strrchr(ptr noundef %57, i32 noundef 47) #7
  %59 = getelementptr inbounds i8, ptr %58, i64 1
  br label %65

60:                                               ; preds = %44
  %61 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %62 = getelementptr inbounds %struct.s2n_debug_info, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = getelementptr inbounds i8, ptr %63, i64 21
  br label %65

65:                                               ; preds = %60, %53
  %66 = phi ptr [ %59, %53 ], [ %64, %60 ]
  %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 1
  store ptr %66, ptr %68, align 8, !tbaa !18
  %69 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %69, align 4, !tbaa !11
  %70 = call i32 @s2n_calculate_stacktrace()
  br label %71

71:                                               ; preds = %65
  br label %72

72:                                               ; preds = %71
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %224

73:                                               ; No predecessors!
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74, %38
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  %78 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !15
  %80 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 1
  %81 = load i32, ptr %80, align 8, !tbaa !13
  %82 = call ptr @BN_bin2bn(ptr noundef %79, i32 noundef %81, ptr noundef null)
  store ptr %82, ptr %11, align 8, !tbaa !5
  br label %83

83:                                               ; preds = %77
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = icmp ne ptr %84, null
  br i1 %85, label %119, label %86

86:                                               ; preds = %83
  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.18, ptr %90, align 8, !tbaa !16
  %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 !16
  %94 = getelementptr inbounds i8, ptr %93, i64 21
  %95 = call ptr @strrchr(ptr noundef %94, i32 noundef 47) #7
  %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 !16
  %101 = getelementptr inbounds i8, ptr %100, i64 21
  %102 = call ptr @strrchr(ptr noundef %101, i32 noundef 47) #7
  %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 !16
  %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 !18
  %113 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %113, align 4, !tbaa !11
  %114 = call i32 @s2n_calculate_stacktrace()
  br label %115

115:                                              ; preds = %109
  br label %116

116:                                              ; preds = %115
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %224

117:                                              ; No predecessors!
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118, %83
  br label %120

120:                                              ; preds = %119
  br label %121

121:                                              ; preds = %120
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.s2n_dh_params, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !19
  %125 = call i32 @DH_size(ptr noundef %124)
  store i32 %125, ptr %13, align 4, !tbaa !11
  br label %126

126:                                              ; preds = %121
  %127 = load i32, ptr %13, align 4, !tbaa !11
  %128 = icmp sle i32 %127, 2147483647
  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.19, ptr %133, align 8, !tbaa !16
  %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 !16
  %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 !16
  %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 !16
  %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 !18
  %156 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653251, ptr %156, align 4, !tbaa !11
  %157 = call i32 @s2n_calculate_stacktrace()
  br label %158

158:                                              ; preds = %152
  br label %159

159:                                              ; preds = %158
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %223

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
  br label %165

165:                                              ; preds = %164
  %166 = load ptr, ptr %7, align 8, !tbaa !5
  %167 = load i32, ptr %13, align 4, !tbaa !11
  %168 = call i32 @s2n_alloc(ptr noundef %166, i32 noundef %167)
  %169 = icmp sgt i32 %168, -1
  br i1 %169, label %171, label %170

170:                                              ; preds = %165
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %223

171:                                              ; preds = %165
  br label %172

172:                                              ; preds = %171
  br label %173

173:                                              ; preds = %172
  %174 = load ptr, ptr %7, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.s2n_blob, ptr %174, i32 0, i32 0
  %176 = load ptr, ptr %175, align 8, !tbaa !15
  %177 = load ptr, ptr %11, align 8, !tbaa !5
  %178 = load ptr, ptr %5, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.s2n_dh_params, ptr %178, i32 0, i32 0
  %180 = load ptr, ptr %179, align 8, !tbaa !19
  %181 = call i32 @DH_compute_key(ptr noundef %176, ptr noundef %177, ptr noundef %180)
  store i32 %181, ptr %10, align 4, !tbaa !11
  %182 = load i32, ptr %10, align 4, !tbaa !11
  %183 = icmp sle i32 %182, 0
  br i1 %183, label %184, label %218

184:                                              ; preds = %173
  %185 = load ptr, ptr %11, align 8, !tbaa !5
  call void @BN_free(ptr noundef %185)
  br label %186

186:                                              ; preds = %184
  br label %187

187:                                              ; preds = %186
  %188 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %189 = getelementptr inbounds %struct.s2n_debug_info, ptr %188, i32 0, i32 0
  store ptr @.str.20, ptr %189, align 8, !tbaa !16
  %190 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %191 = getelementptr inbounds %struct.s2n_debug_info, ptr %190, i32 0, i32 0
  %192 = load ptr, ptr %191, align 8, !tbaa !16
  %193 = getelementptr inbounds i8, ptr %192, i64 21
  %194 = call ptr @strrchr(ptr noundef %193, i32 noundef 47) #7
  %195 = icmp ne ptr %194, null
  br i1 %195, label %196, label %203

196:                                              ; preds = %187
  %197 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %198 = getelementptr inbounds %struct.s2n_debug_info, ptr %197, i32 0, i32 0
  %199 = load ptr, ptr %198, align 8, !tbaa !16
  %200 = getelementptr inbounds i8, ptr %199, i64 21
  %201 = call ptr @strrchr(ptr noundef %200, i32 noundef 47) #7
  %202 = getelementptr inbounds i8, ptr %201, i64 1
  br label %208

203:                                              ; preds = %187
  %204 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %205 = getelementptr inbounds %struct.s2n_debug_info, ptr %204, i32 0, i32 0
  %206 = load ptr, ptr %205, align 8, !tbaa !16
  %207 = getelementptr inbounds i8, ptr %206, i64 21
  br label %208

208:                                              ; preds = %203, %196
  %209 = phi ptr [ %202, %196 ], [ %207, %203 ]
  %210 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %211 = getelementptr inbounds %struct.s2n_debug_info, ptr %210, i32 0, i32 1
  store ptr %209, ptr %211, align 8, !tbaa !18
  %212 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544329, ptr %212, align 4, !tbaa !11
  %213 = call i32 @s2n_calculate_stacktrace()
  br label %214

214:                                              ; preds = %208
  br label %215

215:                                              ; preds = %214
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %223

216:                                              ; No predecessors!
  br label %217

217:                                              ; preds = %216
  br label %218

218:                                              ; preds = %217, %173
  %219 = load i32, ptr %10, align 4, !tbaa !11
  %220 = load ptr, ptr %7, align 8, !tbaa !5
  %221 = getelementptr inbounds %struct.s2n_blob, ptr %220, i32 0, i32 1
  store i32 %219, ptr %221, align 8, !tbaa !13
  %222 = load ptr, ptr %11, align 8, !tbaa !5
  call void @BN_free(ptr noundef %222)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %223

223:                                              ; preds = %218, %215, %170, %159
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %224

224:                                              ; preds = %223, %116, %72, %26, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #6
  %225 = load i32, ptr %4, align 4
  ret i32 %225
}

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

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

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

declare void @BN_free(ptr noundef) #3

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 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"s2n_blob", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!15 = !{!14, !6, i64 0}
!16 = !{!17, !6, i64 0}
!17 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!18 = !{!17, !6, i64 8}
!19 = !{!20, !6, i64 0}
!20 = !{!"s2n_dh_params", !6, i64 0}


; 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.17 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [87 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_check_all_dh_params(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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #4

declare i32 @DH_size(ptr noundef) local_unnamed_addr #3

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_dh_compute_shared_secret_as_server(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca i16, align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %4) #5
  store i16 0, ptr %4, align 2, !tbaa !5
  %5 = tail call i32 @s2n_check_all_dh_params(ptr noundef %0)
  %6 = icmp sgt i32 %5, -1
  br i1 %6, label %7, label %52

7:                                                ; preds = %3
  %8 = call i32 @s2n_stuffer_read_uint16(ptr noundef %1, ptr noundef nonnull %4) #5
  %9 = icmp sgt i32 %8, -1
  br i1 %9, label %10, label %52

10:                                               ; preds = %7
  %11 = load i16, ptr %4, align 2, !tbaa !5
  %12 = zext i16 %11 to i32
  %13 = call ptr @s2n_stuffer_raw_read(ptr noundef %1, i32 noundef %12) #5
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %14, label %22

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

22:                                               ; preds = %10
  %23 = call ptr @BN_bin2bn(ptr noundef nonnull %13, i32 noundef %12, ptr noundef null) #5
  %.not27 = icmp eq ptr %23, null
  br i1 %.not27, label %24, label %32

24:                                               ; preds = %22
  %25 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.18, ptr %25, align 8, !tbaa !9
  %26 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.18, i64 21), i32 noundef 47) #6
  %.not28 = icmp eq ptr %26, null
  %27 = getelementptr inbounds i8, ptr %26, i64 1
  %28 = select i1 %.not28, ptr getelementptr inbounds (i8, ptr @.str.18, i64 21), ptr %27
  %29 = getelementptr inbounds i8, ptr %25, i64 8
  store ptr %28, ptr %29, align 8, !tbaa !12
  %30 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %30, align 4, !tbaa !13
  %31 = call i32 @s2n_calculate_stacktrace() #5
  br label %52

32:                                               ; preds = %22
  %33 = load ptr, ptr %0, align 8, !tbaa !15
  %34 = call i32 @DH_size(ptr noundef %33) #5
  %35 = call i32 @s2n_alloc(ptr noundef %2, i32 noundef %34) #5
  %36 = icmp sgt i32 %35, -1
  br i1 %36, label %37, label %52

37:                                               ; preds = %32
  %38 = load ptr, ptr %2, align 8, !tbaa !17
  %39 = load ptr, ptr %0, align 8, !tbaa !15
  %40 = call i32 @DH_compute_key(ptr noundef %38, ptr noundef nonnull %23, ptr noundef %39) #5
  %41 = icmp slt i32 %40, 1
  br i1 %41, label %42, label %50

42:                                               ; preds = %37
  call void @BN_free(ptr noundef nonnull %23) #5
  %43 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.20, ptr %43, align 8, !tbaa !9
  %44 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.20, i64 21), i32 noundef 47) #6
  %.not29 = icmp eq ptr %44, null
  %45 = getelementptr inbounds i8, ptr %44, i64 1
  %46 = select i1 %.not29, ptr getelementptr inbounds (i8, ptr @.str.20, i64 21), ptr %45
  %47 = getelementptr inbounds i8, ptr %43, i64 8
  store ptr %46, ptr %47, align 8, !tbaa !12
  %48 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544329, ptr %48, align 4, !tbaa !13
  %49 = call i32 @s2n_calculate_stacktrace() #5
  br label %52

50:                                               ; preds = %37
  %51 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 %40, ptr %51, align 8, !tbaa !19
  call void @BN_free(ptr noundef nonnull %23) #5
  br label %52

52:                                               ; preds = %42, %50, %32, %7, %3, %24, %14
  %.1 = phi i32 [ -1, %24 ], [ -1, %14 ], [ -1, %3 ], [ -1, %7 ], [ -1, %42 ], [ 0, %50 ], [ -1, %32 ]
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #5
  ret i32 %.1
}

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

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

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

declare void @BN_free(ptr noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"s2n_debug_info", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !11, i64 0}
!16 = !{!"s2n_dh_params", !11, i64 0}
!17 = !{!18, !11, i64 0}
!18 = !{!"s2n_blob", !11, i64 0, !14, i64 8, !14, i64 12, !14, i64 16}
!19 = !{!18, !14, i64 8}


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