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

; 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.FGN_STATE = type { i64, i8, ptr, i32, %union.pthread_rwlock_t }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%struct.s2n_debug_info = type { ptr, ptr }
%struct.s2n_result = type { i32 }

@fgn_state = external hidden global %struct.FGN_STATE, align 8
@.str = external hidden unnamed_addr constant [97 x i8], align 1
@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@ignore_fork_detection_for_testing = external hidden global i8, align 1
@.str.1 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [97 x i8], align 1

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

4:                                                ; preds = %1
  %5 = call i32 @pthread_once(ptr noundef getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 3), ptr noundef @s2n_initialise_fork_detection_methods)
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %39, label %7

7:                                                ; preds = %4
  br label %8

8:                                                ; preds = %7
  br label %9

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

18:                                               ; preds = %9
  %19 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %20 = getelementptr inbounds %struct.s2n_debug_info, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %21, i64 21
  %23 = call ptr @strrchr(ptr noundef %22, i32 noundef 47) #5
  %24 = getelementptr inbounds i8, ptr %23, i64 1
  br label %30

25:                                               ; preds = %9
  %26 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %27 = getelementptr inbounds %struct.s2n_debug_info, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds i8, ptr %28, i64 21
  br label %30

30:                                               ; preds = %25, %18
  %31 = phi ptr [ %24, %18 ], [ %29, %25 ]
  %32 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %33 = getelementptr inbounds %struct.s2n_debug_info, ptr %32, i32 0, i32 1
  store ptr %31, ptr %33, align 8, !tbaa !11
  %34 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653264, ptr %34, align 4, !tbaa !12
  %35 = call i32 @s2n_calculate_stacktrace()
  br label %36

36:                                               ; preds = %30
  %37 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %37, align 4, !tbaa !14
  br label %331

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38, %4
  br label %40

40:                                               ; preds = %39
  %41 = load i8, ptr @ignore_fork_detection_for_testing, align 1, !tbaa !16, !range !18, !noundef !19
  %42 = trunc i8 %41 to i1
  %43 = zext i1 %42 to i32
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %45, label %83

45:                                               ; preds = %40
  br label %46

46:                                               ; preds = %45
  %47 = call zeroext i1 (...) @s2n_in_unit_test()
  br i1 %47, label %80, label %48

48:                                               ; preds = %46
  br label %49

49:                                               ; preds = %48
  br label %50

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

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

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

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

77:                                               ; preds = %71
  %78 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %78, align 4, !tbaa !14
  br label %331

79:                                               ; No predecessors!
  br label %80

80:                                               ; preds = %79, %46
  br label %81

81:                                               ; preds = %80
  %82 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 0, ptr %82, align 4, !tbaa !14
  br label %331

83:                                               ; preds = %40
  br label %84

84:                                               ; preds = %83
  %85 = load i8, ptr getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 1), align 8, !tbaa !20, !range !18, !noundef !19
  %86 = trunc i8 %85 to i1
  %87 = zext i1 %86 to i32
  %88 = icmp eq i32 %87, 1
  br i1 %88, label %121, label %89

89:                                               ; preds = %84
  br label %90

90:                                               ; preds = %89
  br label %91

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

100:                                              ; preds = %91
  %101 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %102 = getelementptr inbounds %struct.s2n_debug_info, ptr %101, i32 0, i32 0
  %103 = load ptr, ptr %102, align 8, !tbaa !9
  %104 = getelementptr inbounds i8, ptr %103, i64 21
  %105 = call ptr @strrchr(ptr noundef %104, i32 noundef 47) #5
  %106 = getelementptr inbounds i8, ptr %105, i64 1
  br label %112

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

112:                                              ; preds = %107, %100
  %113 = phi ptr [ %106, %100 ], [ %111, %107 ]
  %114 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %115 = getelementptr inbounds %struct.s2n_debug_info, ptr %114, i32 0, i32 1
  store ptr %113, ptr %115, align 8, !tbaa !11
  %116 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653264, ptr %116, align 4, !tbaa !12
  %117 = call i32 @s2n_calculate_stacktrace()
  br label %118

118:                                              ; preds = %112
  %119 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %119, align 4, !tbaa !14
  br label %331

120:                                              ; No predecessors!
  br label %121

121:                                              ; preds = %120, %84
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122
  %124 = call i32 @pthread_rwlock_rdlock(ptr noundef getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 4)) #6
  %125 = icmp eq i32 %124, 0
  br i1 %125, label %158, label %126

126:                                              ; preds = %123
  br label %127

127:                                              ; preds = %126
  br label %128

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

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

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

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

155:                                              ; preds = %149
  %156 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %156, align 4, !tbaa !14
  br label %331

157:                                              ; No predecessors!
  br label %158

158:                                              ; preds = %157, %123
  br label %159

159:                                              ; preds = %158
  %160 = load i64, ptr @fgn_state, align 8, !tbaa !23
  %161 = load ptr, ptr %3, align 8, !tbaa !5
  store i64 %160, ptr %161, align 8, !tbaa !24
  %162 = load ptr, ptr getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 2), align 8, !tbaa !25
  %163 = load volatile i8, ptr %162, align 1, !tbaa !26
  %164 = sext i8 %163 to i32
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %166, label %205

166:                                              ; preds = %159
  br label %167

167:                                              ; preds = %166
  %168 = call i32 @pthread_rwlock_unlock(ptr noundef getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 4)) #6
  %169 = icmp eq i32 %168, 0
  br i1 %169, label %202, label %170

170:                                              ; preds = %167
  br label %171

171:                                              ; preds = %170
  br label %172

172:                                              ; preds = %171
  %173 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %174 = getelementptr inbounds %struct.s2n_debug_info, ptr %173, i32 0, i32 0
  store ptr @.str.4, ptr %174, align 8, !tbaa !9
  %175 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %176 = getelementptr inbounds %struct.s2n_debug_info, ptr %175, i32 0, i32 0
  %177 = load ptr, ptr %176, align 8, !tbaa !9
  %178 = getelementptr inbounds i8, ptr %177, i64 21
  %179 = call ptr @strrchr(ptr noundef %178, i32 noundef 47) #5
  %180 = icmp ne ptr %179, null
  br i1 %180, label %181, label %188

181:                                              ; preds = %172
  %182 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %183 = getelementptr inbounds %struct.s2n_debug_info, ptr %182, i32 0, i32 0
  %184 = load ptr, ptr %183, align 8, !tbaa !9
  %185 = getelementptr inbounds i8, ptr %184, i64 21
  %186 = call ptr @strrchr(ptr noundef %185, i32 noundef 47) #5
  %187 = getelementptr inbounds i8, ptr %186, i64 1
  br label %193

188:                                              ; preds = %172
  %189 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %190 = getelementptr inbounds %struct.s2n_debug_info, ptr %189, i32 0, i32 0
  %191 = load ptr, ptr %190, align 8, !tbaa !9
  %192 = getelementptr inbounds i8, ptr %191, i64 21
  br label %193

193:                                              ; preds = %188, %181
  %194 = phi ptr [ %187, %181 ], [ %192, %188 ]
  %195 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %196 = getelementptr inbounds %struct.s2n_debug_info, ptr %195, i32 0, i32 1
  store ptr %194, ptr %196, align 8, !tbaa !11
  %197 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653265, ptr %197, align 4, !tbaa !12
  %198 = call i32 @s2n_calculate_stacktrace()
  br label %199

199:                                              ; preds = %193
  %200 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %200, align 4, !tbaa !14
  br label %331

201:                                              ; No predecessors!
  br label %202

202:                                              ; preds = %201, %167
  br label %203

203:                                              ; preds = %202
  %204 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 0, ptr %204, align 4, !tbaa !14
  br label %331

205:                                              ; preds = %159
  br label %206

206:                                              ; preds = %205
  %207 = call i32 @pthread_rwlock_unlock(ptr noundef getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 4)) #6
  %208 = icmp eq i32 %207, 0
  br i1 %208, label %241, label %209

209:                                              ; preds = %206
  br label %210

210:                                              ; preds = %209
  br label %211

211:                                              ; preds = %210
  %212 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %213 = getelementptr inbounds %struct.s2n_debug_info, ptr %212, i32 0, i32 0
  store ptr @.str.5, ptr %213, align 8, !tbaa !9
  %214 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %215 = getelementptr inbounds %struct.s2n_debug_info, ptr %214, i32 0, i32 0
  %216 = load ptr, ptr %215, align 8, !tbaa !9
  %217 = getelementptr inbounds i8, ptr %216, i64 21
  %218 = call ptr @strrchr(ptr noundef %217, i32 noundef 47) #5
  %219 = icmp ne ptr %218, null
  br i1 %219, label %220, label %227

220:                                              ; preds = %211
  %221 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %222 = getelementptr inbounds %struct.s2n_debug_info, ptr %221, i32 0, i32 0
  %223 = load ptr, ptr %222, align 8, !tbaa !9
  %224 = getelementptr inbounds i8, ptr %223, i64 21
  %225 = call ptr @strrchr(ptr noundef %224, i32 noundef 47) #5
  %226 = getelementptr inbounds i8, ptr %225, i64 1
  br label %232

227:                                              ; preds = %211
  %228 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %229 = getelementptr inbounds %struct.s2n_debug_info, ptr %228, i32 0, i32 0
  %230 = load ptr, ptr %229, align 8, !tbaa !9
  %231 = getelementptr inbounds i8, ptr %230, i64 21
  br label %232

232:                                              ; preds = %227, %220
  %233 = phi ptr [ %226, %220 ], [ %231, %227 ]
  %234 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %235 = getelementptr inbounds %struct.s2n_debug_info, ptr %234, i32 0, i32 1
  store ptr %233, ptr %235, align 8, !tbaa !11
  %236 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653265, ptr %236, align 4, !tbaa !12
  %237 = call i32 @s2n_calculate_stacktrace()
  br label %238

238:                                              ; preds = %232
  %239 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %239, align 4, !tbaa !14
  br label %331

240:                                              ; No predecessors!
  br label %241

241:                                              ; preds = %240, %206
  br label %242

242:                                              ; preds = %241
  br label %243

243:                                              ; preds = %242
  %244 = call i32 @pthread_rwlock_wrlock(ptr noundef getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 4)) #6
  %245 = icmp eq i32 %244, 0
  br i1 %245, label %278, label %246

246:                                              ; preds = %243
  br label %247

247:                                              ; preds = %246
  br label %248

248:                                              ; preds = %247
  %249 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %250 = getelementptr inbounds %struct.s2n_debug_info, ptr %249, i32 0, i32 0
  store ptr @.str.6, ptr %250, align 8, !tbaa !9
  %251 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %252 = getelementptr inbounds %struct.s2n_debug_info, ptr %251, i32 0, i32 0
  %253 = load ptr, ptr %252, align 8, !tbaa !9
  %254 = getelementptr inbounds i8, ptr %253, i64 21
  %255 = call ptr @strrchr(ptr noundef %254, i32 noundef 47) #5
  %256 = icmp ne ptr %255, null
  br i1 %256, label %257, label %264

257:                                              ; preds = %248
  %258 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %259 = getelementptr inbounds %struct.s2n_debug_info, ptr %258, i32 0, i32 0
  %260 = load ptr, ptr %259, align 8, !tbaa !9
  %261 = getelementptr inbounds i8, ptr %260, i64 21
  %262 = call ptr @strrchr(ptr noundef %261, i32 noundef 47) #5
  %263 = getelementptr inbounds i8, ptr %262, i64 1
  br label %269

264:                                              ; preds = %248
  %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 0
  %267 = load ptr, ptr %266, align 8, !tbaa !9
  %268 = getelementptr inbounds i8, ptr %267, i64 21
  br label %269

269:                                              ; preds = %264, %257
  %270 = phi ptr [ %263, %257 ], [ %268, %264 ]
  %271 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %272 = getelementptr inbounds %struct.s2n_debug_info, ptr %271, i32 0, i32 1
  store ptr %270, ptr %272, align 8, !tbaa !11
  %273 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653265, ptr %273, align 4, !tbaa !12
  %274 = call i32 @s2n_calculate_stacktrace()
  br label %275

275:                                              ; preds = %269
  %276 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %276, align 4, !tbaa !14
  br label %331

277:                                              ; No predecessors!
  br label %278

278:                                              ; preds = %277, %243
  br label %279

279:                                              ; preds = %278
  %280 = load i64, ptr @fgn_state, align 8, !tbaa !23
  %281 = load ptr, ptr %3, align 8, !tbaa !5
  store i64 %280, ptr %281, align 8, !tbaa !24
  %282 = load ptr, ptr getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 2), align 8, !tbaa !25
  %283 = load volatile i8, ptr %282, align 1, !tbaa !26
  %284 = sext i8 %283 to i32
  %285 = icmp eq i32 %284, 0
  br i1 %285, label %286, label %292

286:                                              ; preds = %279
  %287 = load ptr, ptr getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 2), align 8, !tbaa !25
  store volatile i8 1, ptr %287, align 1, !tbaa !26
  %288 = load i64, ptr @fgn_state, align 8, !tbaa !23
  %289 = add i64 %288, 1
  store i64 %289, ptr @fgn_state, align 8, !tbaa !23
  %290 = load i64, ptr @fgn_state, align 8, !tbaa !23
  %291 = load ptr, ptr %3, align 8, !tbaa !5
  store i64 %290, ptr %291, align 8, !tbaa !24
  br label %292

292:                                              ; preds = %286, %279
  br label %293

293:                                              ; preds = %292
  %294 = call i32 @pthread_rwlock_unlock(ptr noundef getelementptr inbounds (%struct.FGN_STATE, ptr @fgn_state, i32 0, i32 4)) #6
  %295 = icmp eq i32 %294, 0
  br i1 %295, label %328, label %296

296:                                              ; preds = %293
  br label %297

297:                                              ; preds = %296
  br label %298

298:                                              ; preds = %297
  %299 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %300 = getelementptr inbounds %struct.s2n_debug_info, ptr %299, i32 0, i32 0
  store ptr @.str.7, ptr %300, align 8, !tbaa !9
  %301 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %302 = getelementptr inbounds %struct.s2n_debug_info, ptr %301, i32 0, i32 0
  %303 = load ptr, ptr %302, align 8, !tbaa !9
  %304 = getelementptr inbounds i8, ptr %303, i64 21
  %305 = call ptr @strrchr(ptr noundef %304, i32 noundef 47) #5
  %306 = icmp ne ptr %305, null
  br i1 %306, label %307, label %314

307:                                              ; preds = %298
  %308 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %309 = getelementptr inbounds %struct.s2n_debug_info, ptr %308, i32 0, i32 0
  %310 = load ptr, ptr %309, align 8, !tbaa !9
  %311 = getelementptr inbounds i8, ptr %310, i64 21
  %312 = call ptr @strrchr(ptr noundef %311, i32 noundef 47) #5
  %313 = getelementptr inbounds i8, ptr %312, i64 1
  br label %319

314:                                              ; preds = %298
  %315 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %316 = getelementptr inbounds %struct.s2n_debug_info, ptr %315, i32 0, i32 0
  %317 = load ptr, ptr %316, align 8, !tbaa !9
  %318 = getelementptr inbounds i8, ptr %317, i64 21
  br label %319

319:                                              ; preds = %314, %307
  %320 = phi ptr [ %313, %307 ], [ %318, %314 ]
  %321 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %322 = getelementptr inbounds %struct.s2n_debug_info, ptr %321, i32 0, i32 1
  store ptr %320, ptr %322, align 8, !tbaa !11
  %323 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653265, ptr %323, align 4, !tbaa !12
  %324 = call i32 @s2n_calculate_stacktrace()
  br label %325

325:                                              ; preds = %319
  %326 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 -1, ptr %326, align 4, !tbaa !14
  br label %331

327:                                              ; No predecessors!
  br label %328

328:                                              ; preds = %327, %293
  br label %329

329:                                              ; preds = %328
  %330 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  store i32 0, ptr %330, align 4, !tbaa !14
  br label %331

331:                                              ; preds = %329, %325, %275, %238, %203, %199, %155, %118, %81, %77, %36
  %332 = getelementptr inbounds %struct.s2n_result, ptr %2, i32 0, i32 0
  %333 = load i32, ptr %332, align 4
  ret i32 %333
}

declare i32 @pthread_once(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @s2n_initialise_fork_detection_methods() #0

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

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

declare i32 @s2n_calculate_stacktrace() #1

declare zeroext i1 @s2n_in_unit_test(...) #1

; Function Attrs: nounwind
declare i32 @pthread_rwlock_rdlock(ptr noundef) #4

; Function Attrs: nounwind
declare i32 @pthread_rwlock_unlock(ptr noundef) #4

; Function Attrs: nounwind
declare i32 @pthread_rwlock_wrlock(ptr noundef) #4

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind willreturn memory(read) }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !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, !17, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!21, !17, i64 8}
!21 = !{!"FGN_STATE", !22, i64 0, !17, i64 8, !6, i64 16, !13, i64 24, !7, i64 32}
!22 = !{!"long", !7, i64 0}
!23 = !{!21, !22, i64 0}
!24 = !{!22, !22, i64 0}
!25 = !{!21, !6, i64 16}
!26 = !{!7, !7, 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.FGN_STATE = type { i64, i8, ptr, i32, %union.pthread_rwlock_t }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%struct.s2n_debug_info = type { ptr, ptr }

@fgn_state = external hidden global %struct.FGN_STATE, align 8
@.str = external hidden unnamed_addr constant [97 x i8], align 1
@_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
@ignore_fork_detection_for_testing = external hidden local_unnamed_addr global i8, align 1
@.str.1 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [97 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_get_fork_generation_number(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
  %2 = tail call i32 @pthread_once(ptr noundef nonnull getelementptr inbounds (i8, ptr @fgn_state, i64 24), ptr noundef nonnull @s2n_initialise_fork_detection_methods) #5
  %3 = icmp eq i32 %2, 0
  br i1 %3, label %4, label %.sink.split

4:                                                ; preds = %1
  %5 = load i8, ptr @ignore_fork_detection_for_testing, align 1, !tbaa !5, !range !9, !noundef !10
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %7, label %9

7:                                                ; preds = %4
  %8 = tail call zeroext i1 (...) @s2n_in_unit_test() #5
  br i1 %8, label %44, label %.sink.split

9:                                                ; preds = %4
  %10 = load i8, ptr getelementptr inbounds (i8, ptr @fgn_state, i64 8), align 8, !tbaa !11, !range !9, !noundef !10
  %11 = trunc nuw i8 %10 to i1
  br i1 %11, label %12, label %.sink.split

12:                                               ; preds = %9
  %13 = tail call i32 @pthread_rwlock_rdlock(ptr noundef nonnull getelementptr inbounds (i8, ptr @fgn_state, i64 32)) #5
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %.sink.split

15:                                               ; preds = %12
  %16 = load i64, ptr @fgn_state, align 8, !tbaa !16
  store i64 %16, ptr %0, align 8, !tbaa !17
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @fgn_state, i64 16), align 8, !tbaa !18
  %18 = load volatile i8, ptr %17, align 1, !tbaa !19
  %.not12 = icmp eq i8 %18, 0
  %19 = tail call i32 @pthread_rwlock_unlock(ptr noundef nonnull getelementptr inbounds (i8, ptr @fgn_state, i64 32)) #5
  %20 = icmp eq i32 %19, 0
  br i1 %.not12, label %22, label %21

21:                                               ; preds = %15
  br i1 %20, label %44, label %.sink.split

22:                                               ; preds = %15
  br i1 %20, label %23, label %.sink.split

23:                                               ; preds = %22
  %24 = tail call i32 @pthread_rwlock_wrlock(ptr noundef nonnull getelementptr inbounds (i8, ptr @fgn_state, i64 32)) #5
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %.sink.split

26:                                               ; preds = %23
  %27 = load i64, ptr @fgn_state, align 8, !tbaa !16
  store i64 %27, ptr %0, align 8, !tbaa !17
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @fgn_state, i64 16), align 8, !tbaa !18
  %29 = load volatile i8, ptr %28, align 1, !tbaa !19
  %30 = icmp eq i8 %29, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %26
  store volatile i8 1, ptr %28, align 1, !tbaa !19
  %32 = load i64, ptr @fgn_state, align 8, !tbaa !16
  %33 = add i64 %32, 1
  store i64 %33, ptr @fgn_state, align 8, !tbaa !16
  store i64 %33, ptr %0, align 8, !tbaa !17
  br label %34

34:                                               ; preds = %26, %31
  %35 = tail call i32 @pthread_rwlock_unlock(ptr noundef nonnull getelementptr inbounds (i8, ptr @fgn_state, i64 32)) #5
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %44, label %.sink.split

.sink.split:                                      ; preds = %34, %23, %22, %21, %12, %9, %7, %1
  %.str.7.sink = phi ptr [ @.str, %1 ], [ @.str.1, %7 ], [ @.str.2, %9 ], [ @.str.3, %12 ], [ @.str.4, %21 ], [ @.str.5, %22 ], [ @.str.6, %23 ], [ @.str.7, %34 ]
  %.sink26 = phi ptr [ getelementptr inbounds (i8, ptr @.str, i64 21), %1 ], [ getelementptr inbounds (i8, ptr @.str.1, i64 21), %7 ], [ getelementptr inbounds (i8, ptr @.str.2, i64 21), %9 ], [ getelementptr inbounds (i8, ptr @.str.3, i64 21), %12 ], [ getelementptr inbounds (i8, ptr @.str.4, i64 21), %21 ], [ getelementptr inbounds (i8, ptr @.str.5, i64 21), %22 ], [ getelementptr inbounds (i8, ptr @.str.6, i64 21), %23 ], [ getelementptr inbounds (i8, ptr @.str.7, i64 21), %34 ]
  %.sink = phi i32 [ 402653264, %1 ], [ 469762090, %7 ], [ 402653264, %9 ], [ 402653265, %12 ], [ 402653265, %21 ], [ 402653265, %22 ], [ 402653265, %23 ], [ 402653265, %34 ]
  %37 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr %.str.7.sink, ptr %37, align 8, !tbaa !20
  %38 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %.sink26, i32 noundef 47) #6
  %.not15 = icmp eq ptr %38, null
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  %40 = select i1 %.not15, ptr %.sink26, ptr %39
  %41 = getelementptr inbounds i8, ptr %37, i64 8
  store ptr %40, ptr %41, align 8, !tbaa !22
  %42 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 %.sink, ptr %42, align 4, !tbaa !23
  %43 = tail call i32 @s2n_calculate_stacktrace() #5
  br label %44

44:                                               ; preds = %.sink.split, %34, %21, %7
  %.sroa.0.0 = phi i32 [ 0, %7 ], [ 0, %21 ], [ 0, %34 ], [ -1, %.sink.split ]
  ret i32 %.sroa.0.0
}

declare i32 @pthread_once(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @s2n_initialise_fork_detection_methods() #0

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

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

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #1

declare zeroext i1 @s2n_in_unit_test(...) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @pthread_rwlock_rdlock(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare i32 @pthread_rwlock_unlock(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare i32 @pthread_rwlock_wrlock(ptr noundef) local_unnamed_addr #4

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { nounwind "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, !6, i64 0}
!6 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !6, i64 8}
!12 = !{!"FGN_STATE", !13, i64 0, !6, i64 8, !14, i64 16, !15, i64 24, !7, i64 32}
!13 = !{!"long", !7, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!12, !13, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !14, i64 16}
!19 = !{!7, !7, i64 0}
!20 = !{!21, !14, i64 0}
!21 = !{!"s2n_debug_info", !14, i64 0, !14, i64 8}
!22 = !{!21, !14, i64 8}
!23 = !{!15, !15, i64 0}


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