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

; 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_map = type { i32, i32, i32, ptr }
%struct.s2n_map_entry = type { %struct.s2n_blob, %struct.s2n_blob }
%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.4 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [86 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: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @s2n_map_embiggen(ptr noundef, i32 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 i32 @s2n_map_slot(ptr noundef, ptr noundef, ptr noundef) #5

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_map_put(ptr noundef %0, ptr noundef %1, ptr noundef %2) #5 {
  %4 = alloca %struct.s2n_result, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.s2n_result, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.s2n_result, align 4
  %11 = 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
  br label %12

12:                                               ; preds = %3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %47, label %15

15:                                               ; preds = %12
  br label %16

16:                                               ; preds = %15
  br label %17

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

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

33:                                               ; preds = %17
  %34 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %35 = getelementptr inbounds %struct.s2n_debug_info, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds i8, ptr %36, i64 21
  br label %38

38:                                               ; preds = %33, %26
  %39 = phi ptr [ %32, %26 ], [ %37, %33 ]
  %40 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %41 = getelementptr inbounds %struct.s2n_debug_info, ptr %40, i32 0, i32 1
  store ptr %39, ptr %41, align 8, !tbaa !11
  %42 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %42, align 4, !tbaa !12
  %43 = call i32 @s2n_calculate_stacktrace()
  br label %44

44:                                               ; preds = %38
  %45 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %45, align 4, !tbaa !14
  br label %252

46:                                               ; No predecessors!
  br label %47

47:                                               ; preds = %46, %12
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.s2n_map, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 8, !tbaa !16
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %86

54:                                               ; preds = %49
  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.5, ptr %58, align 8, !tbaa !9
  %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 !9
  %62 = getelementptr inbounds i8, ptr %61, i64 21
  %63 = call ptr @strrchr(ptr noundef %62, i32 noundef 47) #6
  %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 !9
  %69 = getelementptr inbounds i8, ptr %68, i64 21
  %70 = call ptr @strrchr(ptr noundef %69, i32 noundef 47) #6
  %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 !9
  %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 !11
  %81 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653226, ptr %81, align 4, !tbaa !12
  %82 = call i32 @s2n_calculate_stacktrace()
  br label %83

83:                                               ; preds = %77
  %84 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %84, align 4, !tbaa !14
  br label %252

85:                                               ; No predecessors!
  br label %86

86:                                               ; preds = %85, %49
  br label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.s2n_map, ptr %88, i32 0, i32 0
  %90 = load i32, ptr %89, align 8, !tbaa !18
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.s2n_map, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !19
  %94 = mul i32 %93, 2
  %95 = icmp ult i32 %90, %94
  br i1 %95, label %96, label %112

96:                                               ; preds = %87
  br label %97

97:                                               ; preds = %96
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.s2n_map, ptr %99, i32 0, i32 0
  %101 = load i32, ptr %100, align 8, !tbaa !18
  %102 = mul i32 %101, 2
  %103 = call i32 @s2n_map_embiggen(ptr noundef %98, i32 noundef %102)
  %104 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  store i32 %103, ptr %104, align 4
  %105 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  %106 = load i32, ptr %105, align 4
  %107 = call zeroext i1 @s2n_result_is_ok(i32 %106)
  br i1 %107, label %110, label %108

108:                                              ; preds = %97
  %109 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %109, align 4, !tbaa !14
  br label %252

110:                                              ; preds = %97
  br label %111

111:                                              ; preds = %110
  br label %112

112:                                              ; preds = %111, %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !12
  br label %113

113:                                              ; preds = %112
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = call i32 @s2n_map_slot(ptr noundef %114, ptr noundef %115, ptr noundef %9)
  %117 = getelementptr inbounds %struct.s2n_result, ptr %10, i32 0, i32 0
  store i32 %116, ptr %117, align 4
  %118 = getelementptr inbounds %struct.s2n_result, ptr %10, i32 0, i32 0
  %119 = load i32, ptr %118, align 4
  %120 = call zeroext i1 @s2n_result_is_ok(i32 %119)
  br i1 %120, label %123, label %121

121:                                              ; preds = %113
  %122 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %122, align 4, !tbaa !14
  store i32 1, ptr %11, align 4
  br label %251

123:                                              ; preds = %113
  br label %124

124:                                              ; preds = %123
  br label %125

125:                                              ; preds = %124
  br label %126

126:                                              ; preds = %170, %125
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.s2n_map, ptr %127, i32 0, i32 3
  %129 = load ptr, ptr %128, align 8, !tbaa !20
  %130 = load i32, ptr %9, align 4, !tbaa !12
  %131 = zext i32 %130 to i64
  %132 = getelementptr inbounds %struct.s2n_map_entry, ptr %129, i64 %131
  %133 = getelementptr inbounds %struct.s2n_map_entry, ptr %132, i32 0, i32 0
  %134 = getelementptr inbounds %struct.s2n_blob, ptr %133, i32 0, i32 1
  %135 = load i32, ptr %134, align 8, !tbaa !21
  %136 = icmp ne i32 %135, 0
  br i1 %136, label %137, label %213

137:                                              ; preds = %126
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.s2n_blob, ptr %138, i32 0, i32 1
  %140 = load i32, ptr %139, align 8, !tbaa !24
  %141 = load ptr, ptr %5, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.s2n_map, ptr %141, i32 0, i32 3
  %143 = load ptr, ptr %142, align 8, !tbaa !20
  %144 = load i32, ptr %9, align 4, !tbaa !12
  %145 = zext i32 %144 to i64
  %146 = getelementptr inbounds %struct.s2n_map_entry, ptr %143, i64 %145
  %147 = getelementptr inbounds %struct.s2n_map_entry, ptr %146, i32 0, i32 0
  %148 = getelementptr inbounds %struct.s2n_blob, ptr %147, i32 0, i32 1
  %149 = load i32, ptr %148, align 8, !tbaa !21
  %150 = icmp ne i32 %140, %149
  br i1 %150, label %170, label %151

151:                                              ; preds = %137
  %152 = load ptr, ptr %6, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.s2n_blob, ptr %152, i32 0, i32 0
  %154 = load ptr, ptr %153, align 8, !tbaa !25
  %155 = load ptr, ptr %5, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.s2n_map, ptr %155, i32 0, i32 3
  %157 = load ptr, ptr %156, align 8, !tbaa !20
  %158 = load i32, ptr %9, align 4, !tbaa !12
  %159 = zext i32 %158 to i64
  %160 = getelementptr inbounds %struct.s2n_map_entry, ptr %157, i64 %159
  %161 = getelementptr inbounds %struct.s2n_map_entry, ptr %160, i32 0, i32 0
  %162 = getelementptr inbounds %struct.s2n_blob, ptr %161, i32 0, i32 0
  %163 = load ptr, ptr %162, align 8, !tbaa !26
  %164 = load ptr, ptr %6, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.s2n_blob, ptr %164, i32 0, i32 1
  %166 = load i32, ptr %165, align 8, !tbaa !24
  %167 = zext i32 %166 to i64
  %168 = call i32 @memcmp(ptr noundef %154, ptr noundef %163, i64 noundef %167) #6
  %169 = icmp ne i32 %168, 0
  br i1 %169, label %170, label %178

170:                                              ; preds = %151, %137
  %171 = load i32, ptr %9, align 4, !tbaa !12
  %172 = add i32 %171, 1
  store i32 %172, ptr %9, align 4, !tbaa !12
  %173 = load ptr, ptr %5, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.s2n_map, ptr %173, i32 0, i32 0
  %175 = load i32, ptr %174, align 8, !tbaa !18
  %176 = load i32, ptr %9, align 4, !tbaa !12
  %177 = urem i32 %176, %175
  store i32 %177, ptr %9, align 4, !tbaa !12
  br label %126, !llvm.loop !27

178:                                              ; preds = %151
  br label %179

179:                                              ; preds = %178
  %180 = load ptr, ptr %5, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.s2n_map, ptr %180, i32 0, i32 3
  %182 = load ptr, ptr %181, align 8, !tbaa !20
  %183 = load i32, ptr %9, align 4, !tbaa !12
  %184 = zext i32 %183 to i64
  %185 = getelementptr inbounds %struct.s2n_map_entry, ptr %182, i64 %184
  %186 = getelementptr inbounds %struct.s2n_map_entry, ptr %185, i32 0, i32 0
  %187 = call i32 @s2n_free(ptr noundef %186)
  %188 = icmp sgt i32 %187, -1
  br i1 %188, label %191, label %189

189:                                              ; preds = %179
  %190 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %190, align 4, !tbaa !14
  store i32 1, ptr %11, align 4
  br label %251

191:                                              ; preds = %179
  br label %192

192:                                              ; preds = %191
  br label %193

193:                                              ; preds = %192
  br label %194

194:                                              ; preds = %193
  %195 = load ptr, ptr %5, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.s2n_map, ptr %195, i32 0, i32 3
  %197 = load ptr, ptr %196, align 8, !tbaa !20
  %198 = load i32, ptr %9, align 4, !tbaa !12
  %199 = zext i32 %198 to i64
  %200 = getelementptr inbounds %struct.s2n_map_entry, ptr %197, i64 %199
  %201 = getelementptr inbounds %struct.s2n_map_entry, ptr %200, i32 0, i32 1
  %202 = call i32 @s2n_free(ptr noundef %201)
  %203 = icmp sgt i32 %202, -1
  br i1 %203, label %206, label %204

204:                                              ; preds = %194
  %205 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %205, align 4, !tbaa !14
  store i32 1, ptr %11, align 4
  br label %251

206:                                              ; preds = %194
  br label %207

207:                                              ; preds = %206
  br label %208

208:                                              ; preds = %207
  %209 = load ptr, ptr %5, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.s2n_map, ptr %209, i32 0, i32 1
  %211 = load i32, ptr %210, align 4, !tbaa !19
  %212 = add i32 %211, -1
  store i32 %212, ptr %210, align 4, !tbaa !19
  br label %213

213:                                              ; preds = %208, %126
  br label %214

214:                                              ; preds = %213
  %215 = load ptr, ptr %6, align 8, !tbaa !5
  %216 = load ptr, ptr %5, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.s2n_map, ptr %216, i32 0, i32 3
  %218 = load ptr, ptr %217, align 8, !tbaa !20
  %219 = load i32, ptr %9, align 4, !tbaa !12
  %220 = zext i32 %219 to i64
  %221 = getelementptr inbounds %struct.s2n_map_entry, ptr %218, i64 %220
  %222 = getelementptr inbounds %struct.s2n_map_entry, ptr %221, i32 0, i32 0
  %223 = call i32 @s2n_dup(ptr noundef %215, ptr noundef %222)
  %224 = icmp sgt i32 %223, -1
  br i1 %224, label %227, label %225

225:                                              ; preds = %214
  %226 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %226, align 4, !tbaa !14
  store i32 1, ptr %11, align 4
  br label %251

227:                                              ; preds = %214
  br label %228

228:                                              ; preds = %227
  br label %229

229:                                              ; preds = %228
  br label %230

230:                                              ; preds = %229
  %231 = load ptr, ptr %7, align 8, !tbaa !5
  %232 = load ptr, ptr %5, align 8, !tbaa !5
  %233 = getelementptr inbounds %struct.s2n_map, ptr %232, i32 0, i32 3
  %234 = load ptr, ptr %233, align 8, !tbaa !20
  %235 = load i32, ptr %9, align 4, !tbaa !12
  %236 = zext i32 %235 to i64
  %237 = getelementptr inbounds %struct.s2n_map_entry, ptr %234, i64 %236
  %238 = getelementptr inbounds %struct.s2n_map_entry, ptr %237, i32 0, i32 1
  %239 = call i32 @s2n_dup(ptr noundef %231, ptr noundef %238)
  %240 = icmp sgt i32 %239, -1
  br i1 %240, label %243, label %241

241:                                              ; preds = %230
  %242 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 -1, ptr %242, align 4, !tbaa !14
  store i32 1, ptr %11, align 4
  br label %251

243:                                              ; preds = %230
  br label %244

244:                                              ; preds = %243
  br label %245

245:                                              ; preds = %244
  %246 = load ptr, ptr %5, align 8, !tbaa !5
  %247 = getelementptr inbounds %struct.s2n_map, ptr %246, i32 0, i32 1
  %248 = load i32, ptr %247, align 4, !tbaa !19
  %249 = add i32 %248, 1
  store i32 %249, ptr %247, align 4, !tbaa !19
  %250 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  store i32 0, ptr %250, align 4, !tbaa !14
  store i32 1, ptr %11, align 4
  br label %251

251:                                              ; preds = %245, %241, %225, %204, %189, %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %252

252:                                              ; preds = %251, %108, %83, %44
  %253 = getelementptr inbounds %struct.s2n_result, ptr %4, i32 0, i32 0
  %254 = load i32, ptr %253, align 4
  ret i32 %254
}

declare i32 @s2n_free(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 = { 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 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, !13, i64 0}
!15 = !{!"", !13, i64 0}
!16 = !{!17, !13, i64 8}
!17 = !{!"s2n_map", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16}
!18 = !{!17, !13, i64 0}
!19 = !{!17, !13, i64 4}
!20 = !{!17, !6, i64 16}
!21 = !{!22, !13, i64 8}
!22 = !{!"s2n_map_entry", !23, i64 0, !23, i64 24}
!23 = !{!"s2n_blob", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!24 = !{!23, !13, i64 8}
!25 = !{!23, !6, i64 0}
!26 = !{!22, !6, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


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

@_s2n_debug_info = external thread_local local_unnamed_addr global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [86 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: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i32 @s2n_map_embiggen(ptr noundef, i32 noundef) local_unnamed_addr #5

; 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 i32 @s2n_map_slot(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_map_put(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #5 {
  %4 = alloca i32, align 4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %13

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

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load i32, ptr %14, align 8, !tbaa !13
  %.not31 = icmp eq i32 %15, 0
  br i1 %.not31, label %24, label %16

16:                                               ; preds = %13
  %17 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.5, ptr %17, align 8, !tbaa !5
  %18 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.5, i64 21), i32 noundef 47) #7
  %.not35 = icmp eq ptr %18, null
  %19 = getelementptr inbounds i8, ptr %18, i64 1
  %20 = select i1 %.not35, ptr getelementptr inbounds (i8, ptr @.str.5, i64 21), ptr %19
  %21 = getelementptr inbounds i8, ptr %17, i64 8
  store ptr %20, ptr %21, align 8, !tbaa !10
  %22 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653226, ptr %22, align 4, !tbaa !11
  %23 = tail call i32 @s2n_calculate_stacktrace() #8
  br label %91

24:                                               ; preds = %13
  %25 = load i32, ptr %0, align 8, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %0, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !16
  %28 = shl i32 %27, 1
  %29 = icmp ult i32 %25, %28
  br i1 %29, label %30, label %34

30:                                               ; preds = %24
  %31 = shl i32 %25, 1
  %32 = tail call i32 @s2n_map_embiggen(ptr noundef nonnull %0, i32 noundef %31)
  %33 = tail call zeroext i1 @s2n_result_is_ok(i32 %32)
  br i1 %33, label %34, label %91

34:                                               ; preds = %30, %24
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  store i32 0, ptr %4, align 4, !tbaa !11
  %35 = call i32 @s2n_map_slot(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %4)
  %36 = call zeroext i1 @s2n_result_is_ok(i32 %35)
  br i1 %36, label %.preheader, label %90

.preheader:                                       ; preds = %34
  %37 = getelementptr inbounds i8, ptr %0, i64 16
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %.promoted = load i32, ptr %4, align 4, !tbaa !11
  %39 = zext i32 %.promoted to i64
  %40 = getelementptr inbounds %struct.s2n_map_entry, ptr %38, i64 %39
  %41 = getelementptr inbounds i8, ptr %40, i64 8
  %42 = load i32, ptr %41, align 8, !tbaa !18
  %.not3239 = icmp eq i32 %42, 0
  br i1 %.not3239, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %43 = getelementptr inbounds i8, ptr %1, i64 8
  %44 = load i32, ptr %43, align 8, !tbaa !21
  %45 = zext i32 %44 to i64
  br label %46

46:                                               ; preds = %.lr.ph, %53
  %47 = phi i32 [ %42, %.lr.ph ], [ %60, %53 ]
  %48 = phi ptr [ %40, %.lr.ph ], [ %58, %53 ]
  %49 = phi i32 [ %.promoted, %.lr.ph ], [ %56, %53 ]
  %.not33 = icmp eq i32 %44, %47
  br i1 %.not33, label %50, label %53

50:                                               ; preds = %46
  %51 = load ptr, ptr %1, align 8, !tbaa !22
  %52 = load ptr, ptr %48, align 8, !tbaa !23
  %bcmp = call i32 @bcmp(ptr %51, ptr %52, i64 %45)
  %.not34 = icmp eq i32 %bcmp, 0
  br i1 %.not34, label %61, label %53

53:                                               ; preds = %50, %46
  %54 = add i32 %49, 1
  %55 = load i32, ptr %0, align 8, !tbaa !15
  %56 = urem i32 %54, %55
  store i32 %56, ptr %4, align 4, !tbaa !11
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds %struct.s2n_map_entry, ptr %38, i64 %57
  %59 = getelementptr inbounds i8, ptr %58, i64 8
  %60 = load i32, ptr %59, align 8, !tbaa !18
  %.not32 = icmp eq i32 %60, 0
  br i1 %.not32, label %.loopexit, label %46, !llvm.loop !24

61:                                               ; preds = %50
  %62 = call i32 @s2n_free(ptr noundef nonnull %48) #8
  %63 = icmp sgt i32 %62, -1
  br i1 %63, label %64, label %90

64:                                               ; preds = %61
  %65 = load ptr, ptr %37, align 8, !tbaa !17
  %66 = load i32, ptr %4, align 4, !tbaa !11
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds %struct.s2n_map_entry, ptr %65, i64 %67, i32 1
  %69 = call i32 @s2n_free(ptr noundef nonnull %68) #8
  %70 = icmp sgt i32 %69, -1
  br i1 %70, label %71, label %90

71:                                               ; preds = %64
  %72 = load i32, ptr %26, align 4, !tbaa !16
  %73 = add i32 %72, -1
  store i32 %73, ptr %26, align 4, !tbaa !16
  %.pre = load ptr, ptr %37, align 8, !tbaa !17
  %.pre41 = load i32, ptr %4, align 4, !tbaa !11
  br label %.loopexit

.loopexit:                                        ; preds = %53, %.preheader, %71
  %74 = phi i32 [ %.pre41, %71 ], [ %.promoted, %.preheader ], [ %56, %53 ]
  %75 = phi ptr [ %.pre, %71 ], [ %38, %.preheader ], [ %38, %53 ]
  %76 = zext i32 %74 to i64
  %77 = getelementptr inbounds %struct.s2n_map_entry, ptr %75, i64 %76
  %78 = call i32 @s2n_dup(ptr noundef %1, ptr noundef %77) #8
  %79 = icmp sgt i32 %78, -1
  br i1 %79, label %80, label %90

80:                                               ; preds = %.loopexit
  %81 = load ptr, ptr %37, align 8, !tbaa !17
  %82 = load i32, ptr %4, align 4, !tbaa !11
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds %struct.s2n_map_entry, ptr %81, i64 %83, i32 1
  %85 = call i32 @s2n_dup(ptr noundef %2, ptr noundef nonnull %84) #8
  %86 = icmp sgt i32 %85, -1
  br i1 %86, label %87, label %90

87:                                               ; preds = %80
  %88 = load i32, ptr %26, align 4, !tbaa !16
  %89 = add i32 %88, 1
  store i32 %89, ptr %26, align 4, !tbaa !16
  br label %90

90:                                               ; preds = %80, %.loopexit, %64, %61, %34, %87
  %.sroa.024.0 = phi i32 [ 0, %87 ], [ -1, %34 ], [ -1, %61 ], [ -1, %64 ], [ -1, %.loopexit ], [ -1, %80 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  br label %91

91:                                               ; preds = %30, %90, %16, %5
  %.sroa.024.1 = phi i32 [ -1, %16 ], [ %.sroa.024.0, %90 ], [ -1, %5 ], [ -1, %30 ]
  ret i32 %.sroa.024.1
}

declare i32 @s2n_free(ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #6

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 = { 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 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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { 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, !12, i64 8}
!14 = !{!"s2n_map", !12, i64 0, !12, i64 4, !12, i64 8, !7, i64 16}
!15 = !{!14, !12, i64 0}
!16 = !{!14, !12, i64 4}
!17 = !{!14, !7, i64 16}
!18 = !{!19, !12, i64 8}
!19 = !{!"s2n_map_entry", !20, i64 0, !20, i64 24}
!20 = !{!"s2n_blob", !7, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!21 = !{!20, !12, i64 8}
!22 = !{!20, !7, i64 0}
!23 = !{!19, !7, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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