; LLVM IR from littlefs-project/littlefs :: bd (lfs_emubd)

; 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.timespec = type { i64, i64 }
%struct.lfs_config = type { ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32 }
%struct.lfs_emubd = type { ptr, i64, i64, i64, i32, i32, ptr, ptr, ptr }
%struct.lfs_emubd_config = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, i8, ptr, i64, i64, i64 }
%struct.lfs_emubd_block = type { i32, i32, [0 x i8] }
%struct.lfs_emubd_disk = type { i32, i32, ptr }

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__.lfs_emubd_prog = external hidden unnamed_addr constant [96 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [39 x i8], align 1

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #1

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

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

; Function Attrs: nounwind uwtable
define dso_local i32 @lfs_emubd_prog(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) #5 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca %struct.timespec, align 8
  %22 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.lfs_config, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  store ptr %25, ptr %12, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = load ptr, ptr %12, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.lfs_emubd, ptr %27, i32 0, i32 8
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds %struct.lfs_emubd_config, ptr %29, i32 0, i32 3
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = icmp ult i32 %26, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %5
  br label %35

34:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 345, ptr noundef @__PRETTY_FUNCTION__.lfs_emubd_prog) #8
  unreachable

35:                                               ; preds = %33
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.lfs_emubd, ptr %37, i32 0, i32 8
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = getelementptr inbounds %struct.lfs_emubd_config, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !19
  %42 = urem i32 %36, %41
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %35
  br label %46

45:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 346, ptr noundef @__PRETTY_FUNCTION__.lfs_emubd_prog) #8
  unreachable

46:                                               ; preds = %44
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.lfs_emubd, ptr %48, i32 0, i32 8
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = getelementptr inbounds %struct.lfs_emubd_config, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !19
  %53 = urem i32 %47, %52
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %46
  br label %57

56:                                               ; preds = %46
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 347, ptr noundef @__PRETTY_FUNCTION__.lfs_emubd_prog) #8
  unreachable

57:                                               ; preds = %55
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = add i32 %58, %59
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.lfs_emubd, ptr %61, i32 0, i32 8
  %63 = load ptr, ptr %62, align 8, !tbaa !13
  %64 = getelementptr inbounds %struct.lfs_emubd_config, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 8, !tbaa !20
  %66 = icmp ule i32 %60, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %57
  br label %69

68:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 348, ptr noundef @__PRETTY_FUNCTION__.lfs_emubd_prog) #8
  unreachable

69:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.lfs_emubd, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !21
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds ptr, ptr %73, i64 %75
  %77 = call ptr @lfs_emubd_mutblock(ptr noundef %70, ptr noundef %76)
  store ptr %77, ptr %13, align 8, !tbaa !5
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  %79 = icmp ne ptr %78, null
  br i1 %79, label %81, label %80

80:                                               ; preds = %69
  store i32 -12, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %287

81:                                               ; preds = %69
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.lfs_emubd, ptr %82, i32 0, i32 8
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = getelementptr inbounds %struct.lfs_emubd_config, ptr %84, i32 0, i32 5
  %86 = load i32, ptr %85, align 4, !tbaa !22
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %123

88:                                               ; preds = %81
  %89 = load ptr, ptr %13, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.lfs_emubd_block, ptr %89, i32 0, i32 1
  %91 = load i32, ptr %90, align 4, !tbaa !9
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.lfs_emubd, ptr %92, i32 0, i32 8
  %94 = load ptr, ptr %93, align 8, !tbaa !13
  %95 = getelementptr inbounds %struct.lfs_emubd_config, ptr %94, i32 0, i32 5
  %96 = load i32, ptr %95, align 4, !tbaa !22
  %97 = icmp uge i32 %91, %96
  br i1 %97, label %98, label %123

98:                                               ; preds = %88
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.lfs_emubd, ptr %99, i32 0, i32 8
  %101 = load ptr, ptr %100, align 8, !tbaa !13
  %102 = getelementptr inbounds %struct.lfs_emubd_config, ptr %101, i32 0, i32 6
  %103 = load i32, ptr %102, align 8, !tbaa !23
  %104 = icmp eq i32 %103, 0
  br i1 %104, label %105, label %106

105:                                              ; preds = %98
  store i32 -84, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %287

106:                                              ; preds = %98
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.lfs_emubd, ptr %107, i32 0, i32 8
  %109 = load ptr, ptr %108, align 8, !tbaa !13
  %110 = getelementptr inbounds %struct.lfs_emubd_config, ptr %109, i32 0, i32 6
  %111 = load i32, ptr %110, align 8, !tbaa !23
  %112 = icmp eq i32 %111, 3
  br i1 %112, label %120, label %113

113:                                              ; preds = %106
  %114 = load ptr, ptr %12, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.lfs_emubd, ptr %114, i32 0, i32 8
  %116 = load ptr, ptr %115, align 8, !tbaa !13
  %117 = getelementptr inbounds %struct.lfs_emubd_config, ptr %116, i32 0, i32 6
  %118 = load i32, ptr %117, align 8, !tbaa !23
  %119 = icmp eq i32 %118, 4
  br i1 %119, label %120, label %121

120:                                              ; preds = %113, %106
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %287

121:                                              ; preds = %113
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122, %88, %81
  %124 = load ptr, ptr %12, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.lfs_emubd, ptr %124, i32 0, i32 8
  %126 = load ptr, ptr %125, align 8, !tbaa !13
  %127 = getelementptr inbounds %struct.lfs_emubd_config, ptr %126, i32 0, i32 4
  %128 = load i32, ptr %127, align 8, !tbaa !24
  %129 = icmp ne i32 %128, -1
  br i1 %129, label %130, label %159

130:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %131

131:                                              ; preds = %155, %130
  %132 = load i32, ptr %15, align 4, !tbaa !9
  %133 = load i32, ptr %11, align 4, !tbaa !9
  %134 = icmp ult i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %158

136:                                              ; preds = %131
  %137 = load ptr, ptr %13, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.lfs_emubd_block, ptr %137, i32 0, i32 2
  %139 = load i32, ptr %9, align 4, !tbaa !9
  %140 = load i32, ptr %15, align 4, !tbaa !9
  %141 = add i32 %139, %140
  %142 = zext i32 %141 to i64
  %143 = getelementptr inbounds [0 x i8], ptr %138, i64 0, i64 %142
  %144 = load i8, ptr %143, align 1, !tbaa !25
  %145 = zext i8 %144 to i32
  %146 = load ptr, ptr %12, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.lfs_emubd, ptr %146, i32 0, i32 8
  %148 = load ptr, ptr %147, align 8, !tbaa !13
  %149 = getelementptr inbounds %struct.lfs_emubd_config, ptr %148, i32 0, i32 4
  %150 = load i32, ptr %149, align 8, !tbaa !24
  %151 = icmp eq i32 %145, %150
  br i1 %151, label %152, label %153

152:                                              ; preds = %136
  br label %154

153:                                              ; preds = %136
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 375, ptr noundef @__PRETTY_FUNCTION__.lfs_emubd_prog) #8
  unreachable

154:                                              ; preds = %152
  br label %155

155:                                              ; preds = %154
  %156 = load i32, ptr %15, align 4, !tbaa !9
  %157 = add i32 %156, 1
  store i32 %157, ptr %15, align 4, !tbaa !9
  br label %131, !llvm.loop !26

158:                                              ; preds = %135
  br label %159

159:                                              ; preds = %158, %123
  %160 = load ptr, ptr %13, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.lfs_emubd_block, ptr %160, i32 0, i32 2
  %162 = load i32, ptr %9, align 4, !tbaa !9
  %163 = zext i32 %162 to i64
  %164 = getelementptr inbounds [0 x i8], ptr %161, i64 0, i64 %163
  %165 = load ptr, ptr %10, align 8, !tbaa !5
  %166 = load i32, ptr %11, align 4, !tbaa !9
  %167 = zext i32 %166 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %164, ptr align 1 %165, i64 %167, i1 false)
  %168 = load ptr, ptr %12, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.lfs_emubd, ptr %168, i32 0, i32 7
  %170 = load ptr, ptr %169, align 8, !tbaa !28
  %171 = icmp ne ptr %170, null
  br i1 %171, label %172, label %220

172:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %173 = load ptr, ptr %12, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.lfs_emubd, ptr %173, i32 0, i32 7
  %175 = load ptr, ptr %174, align 8, !tbaa !28
  %176 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %175, i32 0, i32 1
  %177 = load i32, ptr %176, align 4, !tbaa !29
  %178 = load i32, ptr %8, align 4, !tbaa !9
  %179 = zext i32 %178 to i64
  %180 = load ptr, ptr %12, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.lfs_emubd, ptr %180, i32 0, i32 8
  %182 = load ptr, ptr %181, align 8, !tbaa !13
  %183 = getelementptr inbounds %struct.lfs_emubd_config, ptr %182, i32 0, i32 2
  %184 = load i32, ptr %183, align 8, !tbaa !20
  %185 = zext i32 %184 to i64
  %186 = mul nsw i64 %179, %185
  %187 = load i32, ptr %9, align 4, !tbaa !9
  %188 = zext i32 %187 to i64
  %189 = add nsw i64 %186, %188
  %190 = call i64 @lseek(i32 noundef %177, i64 noundef %189, i32 noundef 0) #7
  store i64 %190, ptr %16, align 8, !tbaa !31
  %191 = load i64, ptr %16, align 8, !tbaa !31
  %192 = icmp slt i64 %191, 0
  br i1 %192, label %193, label %198

193:                                              ; preds = %172
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %194 = call ptr @__errno_location() #9
  %195 = load i32, ptr %194, align 4, !tbaa !9
  %196 = sub nsw i32 0, %195
  store i32 %196, ptr %17, align 4, !tbaa !9
  %197 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %197, ptr %6, align 4
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %217

198:                                              ; preds = %172
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %199 = load ptr, ptr %12, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.lfs_emubd, ptr %199, i32 0, i32 7
  %201 = load ptr, ptr %200, align 8, !tbaa !28
  %202 = getelementptr inbounds %struct.lfs_emubd_disk, ptr %201, i32 0, i32 1
  %203 = load i32, ptr %202, align 4, !tbaa !29
  %204 = load ptr, ptr %10, align 8, !tbaa !5
  %205 = load i32, ptr %11, align 4, !tbaa !9
  %206 = zext i32 %205 to i64
  %207 = call i64 @write(i32 noundef %203, ptr noundef %204, i64 noundef %206)
  store i64 %207, ptr %18, align 8, !tbaa !31
  %208 = load i64, ptr %18, align 8, !tbaa !31
  %209 = icmp slt i64 %208, 0
  br i1 %209, label %210, label %215

210:                                              ; preds = %198
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  %211 = call ptr @__errno_location() #9
  %212 = load i32, ptr %211, align 4, !tbaa !9
  %213 = sub nsw i32 0, %212
  store i32 %213, ptr %19, align 4, !tbaa !9
  %214 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %214, ptr %6, align 4
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %216

215:                                              ; preds = %198
  store i32 0, ptr %14, align 4
  br label %216

216:                                              ; preds = %215, %210
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %217

217:                                              ; preds = %216, %193
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  %218 = load i32, ptr %14, align 4
  switch i32 %218, label %287 [
    i32 0, label %219
  ]

219:                                              ; preds = %217
  br label %220

220:                                              ; preds = %219, %159
  %221 = load i32, ptr %11, align 4, !tbaa !9
  %222 = zext i32 %221 to i64
  %223 = load ptr, ptr %12, align 8, !tbaa !5
  %224 = getelementptr inbounds %struct.lfs_emubd, ptr %223, i32 0, i32 2
  %225 = load i64, ptr %224, align 8, !tbaa !32
  %226 = add i64 %225, %222
  store i64 %226, ptr %224, align 8, !tbaa !32
  %227 = load ptr, ptr %12, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.lfs_emubd, ptr %227, i32 0, i32 8
  %229 = load ptr, ptr %228, align 8, !tbaa !13
  %230 = getelementptr inbounds %struct.lfs_emubd_config, ptr %229, i32 0, i32 14
  %231 = load i64, ptr %230, align 8, !tbaa !33
  %232 = icmp ne i64 %231, 0
  br i1 %232, label %233, label %260

233:                                              ; preds = %220
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  %234 = getelementptr inbounds %struct.timespec, ptr %21, i32 0, i32 0
  %235 = load ptr, ptr %12, align 8, !tbaa !5
  %236 = getelementptr inbounds %struct.lfs_emubd, ptr %235, i32 0, i32 8
  %237 = load ptr, ptr %236, align 8, !tbaa !13
  %238 = getelementptr inbounds %struct.lfs_emubd_config, ptr %237, i32 0, i32 14
  %239 = load i64, ptr %238, align 8, !tbaa !33
  %240 = udiv i64 %239, 1000000000
  store i64 %240, ptr %234, align 8, !tbaa !34
  %241 = getelementptr inbounds %struct.timespec, ptr %21, i32 0, i32 1
  %242 = load ptr, ptr %12, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.lfs_emubd, ptr %242, i32 0, i32 8
  %244 = load ptr, ptr %243, align 8, !tbaa !13
  %245 = getelementptr inbounds %struct.lfs_emubd_config, ptr %244, i32 0, i32 14
  %246 = load i64, ptr %245, align 8, !tbaa !33
  %247 = urem i64 %246, 1000000000
  store i64 %247, ptr %241, align 8, !tbaa !36
  %248 = call i32 @nanosleep(ptr noundef %21, ptr noundef null)
  store i32 %248, ptr %20, align 4, !tbaa !9
  %249 = load i32, ptr %20, align 4, !tbaa !9
  %250 = icmp ne i32 %249, 0
  br i1 %250, label %251, label %256

251:                                              ; preds = %233
  %252 = call ptr @__errno_location() #9
  %253 = load i32, ptr %252, align 4, !tbaa !9
  %254 = sub nsw i32 0, %253
  store i32 %254, ptr %20, align 4, !tbaa !9
  %255 = load i32, ptr %20, align 4, !tbaa !9
  store i32 %255, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %257

256:                                              ; preds = %233
  store i32 0, ptr %14, align 4
  br label %257

257:                                              ; preds = %256, %251
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  %258 = load i32, ptr %14, align 4
  switch i32 %258, label %287 [
    i32 0, label %259
  ]

259:                                              ; preds = %257
  br label %260

260:                                              ; preds = %259, %220
  %261 = load ptr, ptr %12, align 8, !tbaa !5
  %262 = getelementptr inbounds %struct.lfs_emubd, ptr %261, i32 0, i32 4
  %263 = load i32, ptr %262, align 8, !tbaa !37
  %264 = icmp ugt i32 %263, 0
  br i1 %264, label %265, label %286

265:                                              ; preds = %260
  %266 = load ptr, ptr %12, align 8, !tbaa !5
  %267 = getelementptr inbounds %struct.lfs_emubd, ptr %266, i32 0, i32 4
  %268 = load i32, ptr %267, align 8, !tbaa !37
  %269 = sub i32 %268, 1
  store i32 %269, ptr %267, align 8, !tbaa !37
  %270 = load ptr, ptr %12, align 8, !tbaa !5
  %271 = getelementptr inbounds %struct.lfs_emubd, ptr %270, i32 0, i32 4
  %272 = load i32, ptr %271, align 8, !tbaa !37
  %273 = icmp eq i32 %272, 0
  br i1 %273, label %274, label %285

274:                                              ; preds = %265
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  %275 = load ptr, ptr %7, align 8, !tbaa !5
  %276 = call i32 @lfs_emubd_powerloss(ptr noundef %275)
  store i32 %276, ptr %22, align 4, !tbaa !9
  %277 = load i32, ptr %22, align 4, !tbaa !9
  %278 = icmp ne i32 %277, 0
  br i1 %278, label %279, label %281

279:                                              ; preds = %274
  %280 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %280, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %282

281:                                              ; preds = %274
  store i32 0, ptr %14, align 4
  br label %282

282:                                              ; preds = %281, %279
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  %283 = load i32, ptr %14, align 4
  switch i32 %283, label %287 [
    i32 0, label %284
  ]

284:                                              ; preds = %282
  br label %285

285:                                              ; preds = %284, %265
  br label %286

286:                                              ; preds = %285, %260
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %287

287:                                              ; preds = %286, %282, %257, %217, %120, %105, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %288 = load i32, ptr %6, align 4
  ret i32 %288
}

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

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) #6

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(none) "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 = { noreturn 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 "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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind willreturn memory(none) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"lfs_config", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112}
!13 = !{!14, !6, i64 56}
!14 = !{!"lfs_emubd", !6, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !6, i64 56}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !10, i64 12}
!17 = !{!"lfs_emubd_config", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !6, i64 48, !18, i64 56, !6, i64 64, !15, i64 72, !15, i64 80, !15, i64 88}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{!17, !10, i64 4}
!20 = !{!17, !10, i64 8}
!21 = !{!14, !6, i64 0}
!22 = !{!17, !10, i64 20}
!23 = !{!17, !10, i64 24}
!24 = !{!17, !10, i64 16}
!25 = !{!7, !7, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!14, !6, i64 48}
!29 = !{!30, !10, i64 4}
!30 = !{!"lfs_emubd_disk", !10, i64 0, !10, i64 4, !6, i64 8}
!31 = !{!15, !15, i64 0}
!32 = !{!14, !15, i64 16}
!33 = !{!17, !15, i64 80}
!34 = !{!35, !15, i64 0}
!35 = !{!"timespec", !15, i64 0, !15, i64 8}
!36 = !{!35, !15, i64 8}
!37 = !{!14, !10, i64 32}


; 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.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__.lfs_emubd_prog = external hidden unnamed_addr constant [96 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #0

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare i32 @nanosleep(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local i32 @lfs_emubd_prog(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3, i32 noundef %4) local_unnamed_addr #5 {
  %6 = alloca %struct.timespec, align 8
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 56
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %9, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !14
  %12 = icmp ugt i32 %11, %1
  br i1 %12, label %14, label %13

13:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 345, ptr noundef nonnull @__PRETTY_FUNCTION__.lfs_emubd_prog) #7
  unreachable

14:                                               ; preds = %5
  %15 = getelementptr inbounds i8, ptr %9, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !17
  %17 = urem i32 %2, %16
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 346, ptr noundef nonnull @__PRETTY_FUNCTION__.lfs_emubd_prog) #7
  unreachable

20:                                               ; preds = %14
  %21 = urem i32 %4, %16
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 347, ptr noundef nonnull @__PRETTY_FUNCTION__.lfs_emubd_prog) #7
  unreachable

24:                                               ; preds = %20
  %25 = add i32 %4, %2
  %26 = getelementptr inbounds i8, ptr %9, i64 8
  %27 = load i32, ptr %26, align 8, !tbaa !18
  %.not = icmp ugt i32 %25, %27
  br i1 %.not, label %28, label %29

28:                                               ; preds = %24
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 348, ptr noundef nonnull @__PRETTY_FUNCTION__.lfs_emubd_prog) #7
  unreachable

29:                                               ; preds = %24
  %30 = load ptr, ptr %7, align 8, !tbaa !19
  %31 = zext i32 %1 to i64
  %32 = getelementptr inbounds ptr, ptr %30, i64 %31
  %33 = tail call ptr @lfs_emubd_mutblock(ptr noundef nonnull %0, ptr noundef %32)
  %.not75 = icmp eq ptr %33, null
  br i1 %.not75, label %.thread, label %34

34:                                               ; preds = %29
  %35 = load ptr, ptr %8, align 8, !tbaa !11
  %36 = getelementptr inbounds i8, ptr %35, i64 20
  %37 = load i32, ptr %36, align 4, !tbaa !20
  %.not76 = icmp eq i32 %37, 0
  br i1 %.not76, label %45, label %38

38:                                               ; preds = %34
  %39 = getelementptr inbounds i8, ptr %33, i64 4
  %40 = load i32, ptr %39, align 4, !tbaa !21
  %.not77 = icmp ult i32 %40, %37
  br i1 %.not77, label %45, label %41

41:                                               ; preds = %38
  %42 = getelementptr inbounds i8, ptr %35, i64 24
  %43 = load i32, ptr %42, align 8, !tbaa !22
  switch i32 %43, label %45 [
    i32 0, label %.thread
    i32 3, label %44
    i32 4, label %44
  ]

44:                                               ; preds = %41, %41
  br label %.thread

45:                                               ; preds = %41, %38, %34
  %46 = getelementptr inbounds i8, ptr %35, i64 16
  %47 = load i32, ptr %46, align 8, !tbaa !23
  %.not78 = icmp ne i32 %47, -1
  %48 = icmp ne i32 %4, 0
  %or.cond = and i1 %.not78, %48
  br i1 %or.cond, label %.lr.ph, label %..loopexit_crit_edge

..loopexit_crit_edge:                             ; preds = %45
  %.pre = zext i32 %4 to i64
  br label %.loopexit

.lr.ph:                                           ; preds = %45
  %49 = getelementptr inbounds i8, ptr %33, i64 8
  %wide.trip.count = zext i32 %4 to i64
  br label %51

50:                                               ; preds = %51
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %51, !llvm.loop !24

51:                                               ; preds = %.lr.ph, %50
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %50 ]
  %52 = trunc nuw i64 %indvars.iv to i32
  %53 = add i32 %52, %2
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds [0 x i8], ptr %49, i64 0, i64 %54
  %56 = load i8, ptr %55, align 1, !tbaa !26
  %57 = zext i8 %56 to i32
  %58 = icmp eq i32 %47, %57
  br i1 %58, label %50, label %59

59:                                               ; preds = %51
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 375, ptr noundef nonnull @__PRETTY_FUNCTION__.lfs_emubd_prog) #7
  unreachable

.loopexit:                                        ; preds = %50, %..loopexit_crit_edge
  %.pre-phi = phi i64 [ %.pre, %..loopexit_crit_edge ], [ %wide.trip.count, %50 ]
  %60 = getelementptr inbounds i8, ptr %33, i64 8
  %61 = zext i32 %2 to i64
  %62 = getelementptr inbounds [0 x i8], ptr %60, i64 0, i64 %61
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %62, ptr align 1 %3, i64 %.pre-phi, i1 false)
  %63 = getelementptr inbounds i8, ptr %7, i64 48
  %64 = load ptr, ptr %63, align 8, !tbaa !27
  %.not79 = icmp eq ptr %64, null
  br i1 %.not79, label %90, label %65

65:                                               ; preds = %.loopexit
  %66 = getelementptr inbounds i8, ptr %64, i64 4
  %67 = load i32, ptr %66, align 4, !tbaa !28
  %68 = load ptr, ptr %8, align 8, !tbaa !11
  %69 = getelementptr inbounds i8, ptr %68, i64 8
  %70 = load i32, ptr %69, align 8, !tbaa !18
  %71 = zext i32 %70 to i64
  %72 = mul nuw nsw i64 %71, %31
  %73 = add nuw nsw i64 %72, %61
  %74 = tail call i64 @lseek(i32 noundef %67, i64 noundef %73, i32 noundef 0) #8
  %75 = icmp slt i64 %74, 0
  br i1 %75, label %76, label %80

76:                                               ; preds = %65
  %77 = tail call ptr @__errno_location() #9
  %78 = load i32, ptr %77, align 4, !tbaa !21
  %79 = sub nsw i32 0, %78
  br label %.thread

80:                                               ; preds = %65
  %81 = load ptr, ptr %63, align 8, !tbaa !27
  %82 = getelementptr inbounds i8, ptr %81, i64 4
  %83 = load i32, ptr %82, align 4, !tbaa !28
  %84 = tail call i64 @write(i32 noundef %83, ptr noundef %3, i64 noundef %.pre-phi) #8
  %85 = icmp sgt i64 %84, -1
  br i1 %85, label %90, label %86

86:                                               ; preds = %80
  %87 = tail call ptr @__errno_location() #9
  %88 = load i32, ptr %87, align 4, !tbaa !21
  %89 = sub nsw i32 0, %88
  br label %.thread

90:                                               ; preds = %80, %.loopexit
  %91 = getelementptr inbounds i8, ptr %7, i64 16
  %92 = load i64, ptr %91, align 8, !tbaa !30
  %93 = add i64 %92, %.pre-phi
  store i64 %93, ptr %91, align 8, !tbaa !30
  %94 = load ptr, ptr %8, align 8, !tbaa !11
  %95 = getelementptr inbounds i8, ptr %94, i64 80
  %96 = load i64, ptr %95, align 8, !tbaa !31
  %.not80 = icmp eq i64 %96, 0
  br i1 %.not80, label %.thread86, label %97

97:                                               ; preds = %90
  %98 = udiv i64 %96, 1000000000
  store i64 %98, ptr %6, align 8, !tbaa !32
  %99 = getelementptr inbounds i8, ptr %6, i64 8
  %100 = urem i64 %96, 1000000000
  store i64 %100, ptr %99, align 8, !tbaa !34
  %101 = call i32 @nanosleep(ptr noundef nonnull %6, ptr noundef null) #8
  %.not81 = icmp eq i32 %101, 0
  br i1 %.not81, label %.thread86, label %102

102:                                              ; preds = %97
  %103 = tail call ptr @__errno_location() #9
  %104 = load i32, ptr %103, align 4, !tbaa !21
  %105 = sub nsw i32 0, %104
  br label %.thread

.thread86:                                        ; preds = %97, %90
  %106 = getelementptr inbounds i8, ptr %7, i64 32
  %107 = load i32, ptr %106, align 8, !tbaa !35
  %.not82 = icmp eq i32 %107, 0
  br i1 %.not82, label %113, label %108

108:                                              ; preds = %.thread86
  %109 = add i32 %107, -1
  store i32 %109, ptr %106, align 8, !tbaa !35
  %110 = icmp eq i32 %109, 0
  br i1 %110, label %111, label %113

111:                                              ; preds = %108
  %112 = call i32 @lfs_emubd_powerloss(ptr noundef nonnull %0)
  %.not83 = icmp eq i32 %112, 0
  br i1 %.not83, label %113, label %.thread

113:                                              ; preds = %108, %111, %.thread86
  br label %.thread

.thread:                                          ; preds = %86, %76, %102, %41, %29, %111, %113, %44
  %.6 = phi i32 [ 0, %44 ], [ 0, %113 ], [ %112, %111 ], [ %105, %102 ], [ -12, %29 ], [ -84, %41 ], [ %89, %86 ], [ %79, %76 ]
  ret i32 %.6
}

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

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #6

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

attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nofree "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 = { noreturn 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 "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 #7 = { noreturn nounwind }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }

!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 = !{!"lfs_config", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !7, i64 72, !7, i64 80, !7, i64 88, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 56}
!12 = !{!"lfs_emubd", !7, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 48, !7, i64 56}
!13 = !{!"long", !8, i64 0}
!14 = !{!15, !10, i64 12}
!15 = !{!"lfs_emubd_config", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !7, i64 40, !7, i64 48, !16, i64 56, !7, i64 64, !13, i64 72, !13, i64 80, !13, i64 88}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{!15, !10, i64 4}
!18 = !{!15, !10, i64 8}
!19 = !{!12, !7, i64 0}
!20 = !{!15, !10, i64 20}
!21 = !{!10, !10, i64 0}
!22 = !{!15, !10, i64 24}
!23 = !{!15, !10, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!8, !8, i64 0}
!27 = !{!12, !7, i64 48}
!28 = !{!29, !10, i64 4}
!29 = !{!"lfs_emubd_disk", !10, i64 0, !10, i64 4, !7, i64 8}
!30 = !{!12, !13, i64 16}
!31 = !{!15, !13, i64 80}
!32 = !{!33, !13, i64 0}
!33 = !{!"timespec", !13, i64 0, !13, i64 8}
!34 = !{!33, !13, i64 8}
!35 = !{!12, !10, i64 32}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass