; 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_dh_params = type { ptr }
%struct.s2n_blob = type { ptr, 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.13 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [87 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: nounwind uwtable
declare dso_local i32 @s2n_dh_params_free(ptr noundef) #5

declare i32 @DH_size(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_dh_params_check(ptr noundef) #5

; 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
declare hidden ptr @s2n_get_Ys_dh_param(ptr noundef) #5

declare i32 @BN_num_bits(ptr noundef) #2

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

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

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

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

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 @s2n_dh_params_check(ptr noundef %16)
  %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 %12, align 4
  br label %286

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 %5, align 8, !tbaa !5
  %25 = call i32 @s2n_dh_params_copy(ptr noundef %24, ptr noundef %8)
  %26 = icmp sgt i32 %25, -1
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %286

28:                                               ; preds = %23
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = call i32 @s2n_dh_generate_ephemeral_key(ptr noundef %8)
  %33 = icmp sgt i32 %32, -1
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %286

35:                                               ; preds = %31
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.s2n_dh_params, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = call i32 @DH_size(ptr noundef %42)
  %44 = call i32 @s2n_alloc(ptr noundef %39, i32 noundef %43)
  %45 = icmp sgt i32 %44, -1
  br i1 %45, label %47, label %46

46:                                               ; preds = %38
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %286

47:                                               ; preds = %38
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %50 = call ptr @s2n_get_Ys_dh_param(ptr noundef %8)
  store ptr %50, ptr %13, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %49
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %87, label %54

54:                                               ; preds = %51
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  %57 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %58 = getelementptr inbounds %struct.s2n_debug_info, ptr %57, i32 0, i32 0
  store ptr @.str.13, ptr %58, align 8, !tbaa !15
  %59 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %60 = getelementptr inbounds %struct.s2n_debug_info, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = getelementptr inbounds i8, ptr %61, i64 21
  %63 = call ptr @strrchr(ptr noundef %62, i32 noundef 47) #7
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %72

65:                                               ; preds = %56
  %66 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %67 = getelementptr inbounds %struct.s2n_debug_info, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = getelementptr inbounds i8, ptr %68, i64 21
  %70 = call ptr @strrchr(ptr noundef %69, i32 noundef 47) #7
  %71 = getelementptr inbounds i8, ptr %70, i64 1
  br label %77

72:                                               ; preds = %56
  %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 0
  %75 = load ptr, ptr %74, align 8, !tbaa !15
  %76 = getelementptr inbounds i8, ptr %75, i64 21
  br label %77

77:                                               ; preds = %72, %65
  %78 = phi ptr [ %71, %65 ], [ %76, %72 ]
  %79 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %80 = getelementptr inbounds %struct.s2n_debug_info, ptr %79, i32 0, i32 1
  store ptr %78, ptr %80, align 8, !tbaa !17
  %81 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %81, align 4, !tbaa !11
  %82 = call i32 @s2n_calculate_stacktrace()
  br label %83

83:                                               ; preds = %77
  br label %84

84:                                               ; preds = %83
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %285

85:                                               ; No predecessors!
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86, %51
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88
  %90 = load ptr, ptr %13, align 8, !tbaa !5
  %91 = call i32 @BN_num_bits(ptr noundef %90)
  %92 = add nsw i32 %91, 7
  %93 = sdiv i32 %92, 8
  %94 = trunc i32 %93 to i16
  store i16 %94, ptr %10, align 2, !tbaa !9
  br label %95

95:                                               ; preds = %89
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = load i16, ptr %10, align 2, !tbaa !9
  %98 = call i32 @s2n_stuffer_write_uint16(ptr noundef %96, i16 noundef zeroext %97)
  %99 = icmp sgt i32 %98, -1
  br i1 %99, label %101, label %100

100:                                              ; preds = %95
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %285

101:                                              ; preds = %95
  br label %102

102:                                              ; preds = %101
  br label %103

103:                                              ; preds = %102
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = load i16, ptr %10, align 2, !tbaa !9
  %106 = zext i16 %105 to i32
  %107 = call ptr @s2n_stuffer_raw_write(ptr noundef %104, i32 noundef %106)
  store ptr %107, ptr %9, align 8, !tbaa !5
  %108 = load ptr, ptr %9, align 8, !tbaa !5
  %109 = icmp eq ptr %108, null
  br i1 %109, label %110, label %158

110:                                              ; preds = %103
  br label %111

111:                                              ; preds = %110
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  %113 = call i32 @s2n_free(ptr noundef %112)
  %114 = icmp sgt i32 %113, -1
  br i1 %114, label %116, label %115

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

116:                                              ; preds = %111
  br label %117

117:                                              ; preds = %116
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118
  %120 = call i32 @s2n_dh_params_free(ptr noundef %8)
  %121 = icmp sgt i32 %120, -1
  br i1 %121, label %123, label %122

122:                                              ; preds = %119
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %285

123:                                              ; preds = %119
  br label %124

124:                                              ; preds = %123
  br label %125

125:                                              ; preds = %124
  br label %126

126:                                              ; preds = %125
  br label %127

127:                                              ; preds = %126
  %128 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %129 = getelementptr inbounds %struct.s2n_debug_info, ptr %128, i32 0, i32 0
  store ptr @.str.14, ptr %129, align 8, !tbaa !15
  %130 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %131 = getelementptr inbounds %struct.s2n_debug_info, ptr %130, i32 0, i32 0
  %132 = load ptr, ptr %131, align 8, !tbaa !15
  %133 = getelementptr inbounds i8, ptr %132, i64 21
  %134 = call ptr @strrchr(ptr noundef %133, i32 noundef 47) #7
  %135 = icmp ne ptr %134, null
  br i1 %135, label %136, label %143

136:                                              ; preds = %127
  %137 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %138 = getelementptr inbounds %struct.s2n_debug_info, ptr %137, i32 0, i32 0
  %139 = load ptr, ptr %138, align 8, !tbaa !15
  %140 = getelementptr inbounds i8, ptr %139, i64 21
  %141 = call ptr @strrchr(ptr noundef %140, i32 noundef 47) #7
  %142 = getelementptr inbounds i8, ptr %141, i64 1
  br label %148

143:                                              ; preds = %127
  %144 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %145 = getelementptr inbounds %struct.s2n_debug_info, ptr %144, i32 0, i32 0
  %146 = load ptr, ptr %145, align 8, !tbaa !15
  %147 = getelementptr inbounds i8, ptr %146, i64 21
  br label %148

148:                                              ; preds = %143, %136
  %149 = phi ptr [ %142, %136 ], [ %147, %143 ]
  %150 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %151 = getelementptr inbounds %struct.s2n_debug_info, ptr %150, i32 0, i32 1
  store ptr %149, ptr %151, align 8, !tbaa !17
  %152 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544330, ptr %152, align 4, !tbaa !11
  %153 = call i32 @s2n_calculate_stacktrace()
  br label %154

154:                                              ; preds = %148
  br label %155

155:                                              ; preds = %154
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %285

156:                                              ; No predecessors!
  br label %157

157:                                              ; preds = %156
  br label %158

158:                                              ; preds = %157, %103
  %159 = load ptr, ptr %13, align 8, !tbaa !5
  %160 = load ptr, ptr %9, align 8, !tbaa !5
  %161 = call i32 @BN_bn2bin(ptr noundef %159, ptr noundef %160)
  %162 = load i16, ptr %10, align 2, !tbaa !9
  %163 = zext i16 %162 to i32
  %164 = icmp ne i32 %161, %163
  br i1 %164, label %165, label %213

165:                                              ; preds = %158
  br label %166

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

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

171:                                              ; preds = %166
  br label %172

172:                                              ; preds = %171
  br label %173

173:                                              ; preds = %172
  br label %174

174:                                              ; preds = %173
  %175 = call i32 @s2n_dh_params_free(ptr noundef %8)
  %176 = icmp sgt i32 %175, -1
  br i1 %176, label %178, label %177

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

178:                                              ; preds = %174
  br label %179

179:                                              ; preds = %178
  br label %180

180:                                              ; preds = %179
  br label %181

181:                                              ; preds = %180
  br label %182

182:                                              ; preds = %181
  %183 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %184 = getelementptr inbounds %struct.s2n_debug_info, ptr %183, i32 0, i32 0
  store ptr @.str.15, ptr %184, align 8, !tbaa !15
  %185 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %186 = getelementptr inbounds %struct.s2n_debug_info, ptr %185, i32 0, i32 0
  %187 = load ptr, ptr %186, align 8, !tbaa !15
  %188 = getelementptr inbounds i8, ptr %187, i64 21
  %189 = call ptr @strrchr(ptr noundef %188, i32 noundef 47) #7
  %190 = icmp ne ptr %189, null
  br i1 %190, label %191, label %198

191:                                              ; preds = %182
  %192 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %193 = getelementptr inbounds %struct.s2n_debug_info, ptr %192, i32 0, i32 0
  %194 = load ptr, ptr %193, align 8, !tbaa !15
  %195 = getelementptr inbounds i8, ptr %194, i64 21
  %196 = call ptr @strrchr(ptr noundef %195, i32 noundef 47) #7
  %197 = getelementptr inbounds i8, ptr %196, i64 1
  br label %203

198:                                              ; preds = %182
  %199 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %200 = getelementptr inbounds %struct.s2n_debug_info, ptr %199, i32 0, i32 0
  %201 = load ptr, ptr %200, align 8, !tbaa !15
  %202 = getelementptr inbounds i8, ptr %201, i64 21
  br label %203

203:                                              ; preds = %198, %191
  %204 = phi ptr [ %197, %191 ], [ %202, %198 ]
  %205 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %206 = getelementptr inbounds %struct.s2n_debug_info, ptr %205, i32 0, i32 1
  store ptr %204, ptr %206, align 8, !tbaa !17
  %207 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544351, ptr %207, align 4, !tbaa !11
  %208 = call i32 @s2n_calculate_stacktrace()
  br label %209

209:                                              ; preds = %203
  br label %210

210:                                              ; preds = %209
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %285

211:                                              ; No predecessors!
  br label %212

212:                                              ; preds = %211
  br label %213

213:                                              ; preds = %212, %158
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %214 = load ptr, ptr %5, align 8, !tbaa !5
  %215 = call ptr @s2n_get_Ys_dh_param(ptr noundef %214)
  store ptr %215, ptr %14, align 8, !tbaa !5
  %216 = load ptr, ptr %7, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.s2n_blob, ptr %216, i32 0, i32 0
  %218 = load ptr, ptr %217, align 8, !tbaa !18
  %219 = load ptr, ptr %14, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.s2n_dh_params, ptr %8, i32 0, i32 0
  %221 = load ptr, ptr %220, align 8, !tbaa !13
  %222 = call i32 @DH_compute_key(ptr noundef %218, ptr noundef %219, ptr noundef %221)
  store i32 %222, ptr %11, align 4, !tbaa !11
  %223 = load i32, ptr %11, align 4, !tbaa !11
  %224 = icmp slt i32 %223, 0
  br i1 %224, label %225, label %273

225:                                              ; preds = %213
  br label %226

226:                                              ; preds = %225
  %227 = load ptr, ptr %7, align 8, !tbaa !5
  %228 = call i32 @s2n_free(ptr noundef %227)
  %229 = icmp sgt i32 %228, -1
  br i1 %229, label %231, label %230

230:                                              ; preds = %226
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %284

231:                                              ; preds = %226
  br label %232

232:                                              ; preds = %231
  br label %233

233:                                              ; preds = %232
  br label %234

234:                                              ; preds = %233
  %235 = call i32 @s2n_dh_params_free(ptr noundef %8)
  %236 = icmp sgt i32 %235, -1
  br i1 %236, label %238, label %237

237:                                              ; preds = %234
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %284

238:                                              ; preds = %234
  br label %239

239:                                              ; preds = %238
  br label %240

240:                                              ; preds = %239
  br label %241

241:                                              ; preds = %240
  br label %242

242:                                              ; preds = %241
  %243 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %244 = getelementptr inbounds %struct.s2n_debug_info, ptr %243, i32 0, i32 0
  store ptr @.str.16, ptr %244, align 8, !tbaa !15
  %245 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %246 = getelementptr inbounds %struct.s2n_debug_info, ptr %245, i32 0, i32 0
  %247 = load ptr, ptr %246, align 8, !tbaa !15
  %248 = getelementptr inbounds i8, ptr %247, i64 21
  %249 = call ptr @strrchr(ptr noundef %248, i32 noundef 47) #7
  %250 = icmp ne ptr %249, null
  br i1 %250, label %251, label %258

251:                                              ; preds = %242
  %252 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %253 = getelementptr inbounds %struct.s2n_debug_info, ptr %252, i32 0, i32 0
  %254 = load ptr, ptr %253, align 8, !tbaa !15
  %255 = getelementptr inbounds i8, ptr %254, i64 21
  %256 = call ptr @strrchr(ptr noundef %255, i32 noundef 47) #7
  %257 = getelementptr inbounds i8, ptr %256, i64 1
  br label %263

258:                                              ; preds = %242
  %259 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %260 = getelementptr inbounds %struct.s2n_debug_info, ptr %259, i32 0, i32 0
  %261 = load ptr, ptr %260, align 8, !tbaa !15
  %262 = getelementptr inbounds i8, ptr %261, i64 21
  br label %263

263:                                              ; preds = %258, %251
  %264 = phi ptr [ %257, %251 ], [ %262, %258 ]
  %265 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %266 = getelementptr inbounds %struct.s2n_debug_info, ptr %265, i32 0, i32 1
  store ptr %264, ptr %266, align 8, !tbaa !17
  %267 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544329, ptr %267, align 4, !tbaa !11
  %268 = call i32 @s2n_calculate_stacktrace()
  br label %269

269:                                              ; preds = %263
  br label %270

270:                                              ; preds = %269
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %284

271:                                              ; No predecessors!
  br label %272

272:                                              ; preds = %271
  br label %273

273:                                              ; preds = %272, %213
  %274 = load i32, ptr %11, align 4, !tbaa !11
  %275 = load ptr, ptr %7, align 8, !tbaa !5
  %276 = getelementptr inbounds %struct.s2n_blob, ptr %275, i32 0, i32 1
  store i32 %274, ptr %276, align 8, !tbaa !20
  br label %277

277:                                              ; preds = %273
  %278 = call i32 @s2n_dh_params_free(ptr noundef %8)
  %279 = icmp sgt i32 %278, -1
  br i1 %279, label %281, label %280

280:                                              ; preds = %277
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %284

281:                                              ; preds = %277
  br label %282

282:                                              ; preds = %281
  br label %283

283:                                              ; preds = %282
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %284

284:                                              ; preds = %283, %280, %270, %237, %230
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %285

285:                                              ; preds = %284, %210, %177, %170, %155, %122, %115, %100, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %286

286:                                              ; preds = %285, %46, %34, %27, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %287 = load i32, ptr %4, align 4
  ret i32 %287
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_dh_params_copy(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_dh_generate_ephemeral_key(ptr noundef) #5

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

declare i32 @s2n_free(ptr noundef) #2

declare i32 @DH_compute_key(ptr noundef, ptr noundef, 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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"s2n_dh_params", !6, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!17 = !{!16, !6, i64 8}
!18 = !{!19, !6, i64 0}
!19 = !{!"s2n_blob", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!20 = !{!19, !12, 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_dh_params = type { 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.13 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [87 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: nounwind uwtable
declare dso_local i32 @s2n_dh_params_free(ptr noundef) local_unnamed_addr #4

declare i32 @DH_size(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_dh_params_check(ptr noundef) local_unnamed_addr #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
declare hidden ptr @s2n_get_Ys_dh_param(ptr noundef) local_unnamed_addr #4

declare i32 @BN_num_bits(ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_dh_compute_shared_secret_as_client(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #4 {
  %4 = alloca %struct.s2n_dh_params, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store i64 0, ptr %4, align 8
  %5 = tail call i32 @s2n_dh_params_check(ptr noundef %0)
  %6 = icmp sgt i32 %5, -1
  br i1 %6, label %7, label %92

7:                                                ; preds = %3
  %8 = call i32 @s2n_dh_params_copy(ptr noundef %0, ptr noundef nonnull %4)
  %9 = icmp sgt i32 %8, -1
  br i1 %9, label %10, label %92

10:                                               ; preds = %7
  %11 = call i32 @s2n_dh_generate_ephemeral_key(ptr noundef nonnull %4)
  %12 = icmp sgt i32 %11, -1
  br i1 %12, label %13, label %92

13:                                               ; preds = %10
  %14 = load ptr, ptr %0, align 8, !tbaa !5
  %15 = call i32 @DH_size(ptr noundef %14) #5
  %16 = call i32 @s2n_alloc(ptr noundef %2, i32 noundef %15) #5
  %17 = icmp sgt i32 %16, -1
  br i1 %17, label %18, label %92

18:                                               ; preds = %13
  %19 = call ptr @s2n_get_Ys_dh_param(ptr noundef nonnull %4)
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %20, label %28

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

28:                                               ; preds = %18
  %29 = call i32 @BN_num_bits(ptr noundef nonnull %19) #5
  %30 = add nsw i32 %29, 7
  %31 = sdiv i32 %30, 8
  %32 = trunc i32 %31 to i16
  %33 = call i32 @s2n_stuffer_write_uint16(ptr noundef %1, i16 noundef zeroext %32) #5
  %34 = icmp sgt i32 %33, -1
  br i1 %34, label %35, label %92

35:                                               ; preds = %28
  %36 = and i32 %31, 65535
  %37 = call ptr @s2n_stuffer_raw_write(ptr noundef %1, i32 noundef %36) #5
  %38 = icmp eq ptr %37, null
  br i1 %38, label %39, label %53

39:                                               ; preds = %35
  %40 = call i32 @s2n_free(ptr noundef %2) #5
  %41 = icmp sgt i32 %40, -1
  br i1 %41, label %42, label %92

42:                                               ; preds = %39
  %43 = call i32 @s2n_dh_params_free(ptr noundef nonnull %4)
  %44 = icmp sgt i32 %43, -1
  br i1 %44, label %45, label %92

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

53:                                               ; preds = %35
  %54 = call i32 @BN_bn2bin(ptr noundef nonnull %19, ptr noundef nonnull %37) #5
  %.not31 = icmp eq i32 %54, %36
  br i1 %.not31, label %69, label %55

55:                                               ; preds = %53
  %56 = call i32 @s2n_free(ptr noundef %2) #5
  %57 = icmp sgt i32 %56, -1
  br i1 %57, label %58, label %92

58:                                               ; preds = %55
  %59 = call i32 @s2n_dh_params_free(ptr noundef nonnull %4)
  %60 = icmp sgt i32 %59, -1
  br i1 %60, label %61, label %92

61:                                               ; preds = %58
  %62 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.15, ptr %62, align 8, !tbaa !10
  %63 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.15, i64 21), i32 noundef 47) #6
  %.not33 = icmp eq ptr %63, null
  %64 = getelementptr inbounds i8, ptr %63, i64 1
  %65 = select i1 %.not33, ptr getelementptr inbounds (i8, ptr @.str.15, i64 21), ptr %64
  %66 = getelementptr inbounds i8, ptr %62, i64 8
  store ptr %65, ptr %66, align 8, !tbaa !12
  %67 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544351, ptr %67, align 4, !tbaa !13
  %68 = call i32 @s2n_calculate_stacktrace() #5
  br label %92

69:                                               ; preds = %53
  %70 = call ptr @s2n_get_Ys_dh_param(ptr noundef nonnull %0)
  %71 = load ptr, ptr %2, align 8, !tbaa !15
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = call i32 @DH_compute_key(ptr noundef %71, ptr noundef %70, ptr noundef %72) #5
  %74 = icmp slt i32 %73, 0
  br i1 %74, label %75, label %89

75:                                               ; preds = %69
  %76 = call i32 @s2n_free(ptr noundef nonnull %2) #5
  %77 = icmp sgt i32 %76, -1
  br i1 %77, label %78, label %92

78:                                               ; preds = %75
  %79 = call i32 @s2n_dh_params_free(ptr noundef nonnull %4)
  %80 = icmp sgt i32 %79, -1
  br i1 %80, label %81, label %92

81:                                               ; preds = %78
  %82 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.16, ptr %82, align 8, !tbaa !10
  %83 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.16, i64 21), i32 noundef 47) #6
  %.not32 = icmp eq ptr %83, null
  %84 = getelementptr inbounds i8, ptr %83, i64 1
  %85 = select i1 %.not32, ptr getelementptr inbounds (i8, ptr @.str.16, i64 21), ptr %84
  %86 = getelementptr inbounds i8, ptr %82, i64 8
  store ptr %85, ptr %86, align 8, !tbaa !12
  %87 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544329, ptr %87, align 4, !tbaa !13
  %88 = call i32 @s2n_calculate_stacktrace() #5
  br label %92

89:                                               ; preds = %69
  %90 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 %73, ptr %90, align 8, !tbaa !17
  %91 = call i32 @s2n_dh_params_free(ptr noundef nonnull %4)
  %.lobit = ashr i32 %91, 31
  br label %92

92:                                               ; preds = %20, %45, %61, %28, %39, %42, %55, %58, %89, %78, %75, %81, %13, %10, %7, %3
  %.2 = phi i32 [ -1, %3 ], [ -1, %7 ], [ -1, %10 ], [ -1, %13 ], [ -1, %45 ], [ -1, %61 ], [ -1, %20 ], [ -1, %28 ], [ -1, %39 ], [ -1, %42 ], [ -1, %55 ], [ -1, %58 ], [ -1, %81 ], [ -1, %75 ], [ -1, %78 ], [ %.lobit, %89 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  ret i32 %.2
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_dh_params_copy(ptr noundef, ptr noundef) local_unnamed_addr #4

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

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

declare i32 @s2n_free(ptr noundef) local_unnamed_addr #2

declare i32 @DH_compute_key(ptr noundef, ptr noundef, 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 = { 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 }
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, !7, i64 0}
!6 = !{!"s2n_dh_params", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"s2n_debug_info", !7, i64 0, !7, i64 8}
!12 = !{!11, !7, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!16, !7, i64 0}
!16 = !{!"s2n_blob", !7, i64 0, !14, i64 8, !14, i64 12, !14, i64 16}
!17 = !{!16, !14, i64 8}


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