; LLVM IR from mncoppola/rpef :: utilities_src/squashfs2.1/squashfs-2.1-r2 (read_fs)

; 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.squashfs_fragment_entry = type { i32, i32 }
%struct.squashfs_super_block = type <{ i32, i32, i32, i32, i32, i32, i32, i64, i16, i8, i32, i64, i32, i32, i32 }>

@swap = external dso_local global i32, align 4
@stderr = external global ptr, align 8
@.str.26 = external hidden unnamed_addr constant [35 x i8], align 1

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

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

declare void @read_bytes(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

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

; 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #6

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #6

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #7

; Function Attrs: nounwind uwtable
define dso_local i32 @read_fragment_table(i32 noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca %struct.squashfs_fragment_entry, align 1
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i64, align 8
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca i64, align 8
  %32 = alloca ptr, align 8
  %33 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %34 = load ptr, ptr %6, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.squashfs_super_block, ptr %34, i32 0, i32 13
  %36 = load i32, ptr %35, align 1, !tbaa !11
  %37 = zext i32 %36 to i64
  %38 = mul i64 %37, 8
  %39 = add i64 %38, 8192
  %40 = sub i64 %39, 1
  %41 = udiv i64 %40, 8192
  %42 = trunc i64 %41 to i32
  store i32 %42, ptr %9, align 4, !tbaa !5
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = zext i32 %43 to i64
  %45 = call ptr @llvm.stacksave.p0()
  store ptr %45, ptr %10, align 8
  %46 = alloca i32, i64 %44, align 16
  store i64 %44, ptr %11, align 8
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.squashfs_super_block, ptr %47, i32 0, i32 13
  %49 = load i32, ptr %48, align 1, !tbaa !11
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %3
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %248

52:                                               ; preds = %3
  %53 = load ptr, ptr %6, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.squashfs_super_block, ptr %53, i32 0, i32 13
  %55 = load i32, ptr %54, align 1, !tbaa !11
  %56 = zext i32 %55 to i64
  %57 = mul i64 %56, 8
  %58 = call noalias ptr @malloc(i64 noundef %57) #9
  %59 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %58, ptr %59, align 8, !tbaa !9
  %60 = icmp eq ptr %58, null
  br i1 %60, label %61, label %64

61:                                               ; preds = %52
  %62 = load ptr, ptr @stderr, align 8, !tbaa !9
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.26) #8
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %248

64:                                               ; preds = %52
  %65 = load i32, ptr @swap, align 4, !tbaa !5
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %132

67:                                               ; preds = %64
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = zext i32 %68 to i64
  %70 = call ptr @llvm.stacksave.p0()
  store ptr %70, ptr %13, align 8
  %71 = alloca i32, i64 %69, align 16
  store i64 %69, ptr %14, align 8
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = load ptr, ptr %6, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.squashfs_super_block, ptr %73, i32 0, i32 14
  %75 = load i32, ptr %74, align 1, !tbaa !14
  %76 = load ptr, ptr %6, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.squashfs_super_block, ptr %76, i32 0, i32 13
  %78 = load i32, ptr %77, align 1, !tbaa !11
  %79 = zext i32 %78 to i64
  %80 = mul i64 %79, 8
  %81 = add i64 %80, 8192
  %82 = sub i64 %81, 1
  %83 = udiv i64 %82, 8192
  %84 = mul i64 %83, 4
  %85 = trunc i64 %84 to i32
  call void @read_bytes(i32 noundef %72, i32 noundef %75, i32 noundef %85, ptr noundef %71)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %86 = load i32, ptr %9, align 4, !tbaa !5
  %87 = mul nsw i32 %86, 4
  %88 = sext i32 %87 to i64
  call void @llvm.memset.p0.i64(ptr align 16 %46, i8 0, i64 %88, i1 false)
  store i32 0, ptr %15, align 4, !tbaa !5
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %125, %67
  %90 = load i32, ptr %15, align 4, !tbaa !5
  %91 = load i32, ptr %9, align 4, !tbaa !5
  %92 = icmp slt i32 %90, %91
  br i1 %92, label %93, label %130

93:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  %94 = load i32, ptr %16, align 4, !tbaa !5
  %95 = srem i32 %94, 8
  store i32 %95, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #8
  store i64 0, ptr %19, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %96 = load i32, ptr %16, align 4, !tbaa !5
  %97 = sdiv i32 %96, 8
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds i8, ptr %71, i64 %98
  store ptr %99, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #8
  %100 = getelementptr inbounds i8, ptr %19, i64 7
  store ptr %100, ptr %21, align 8, !tbaa !9
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %112, %93
  %102 = load i32, ptr %17, align 4, !tbaa !5
  %103 = load i32, ptr %18, align 4, !tbaa !5
  %104 = add nsw i32 32, %103
  %105 = icmp slt i32 %102, %104
  br i1 %105, label %106, label %115

106:                                              ; preds = %101
  %107 = load ptr, ptr %20, align 8, !tbaa !9
  %108 = getelementptr inbounds i8, ptr %107, i32 1
  store ptr %108, ptr %20, align 8, !tbaa !9
  %109 = load i8, ptr %107, align 1, !tbaa !16
  %110 = load ptr, ptr %21, align 8, !tbaa !9
  %111 = getelementptr inbounds i8, ptr %110, i32 -1
  store ptr %111, ptr %21, align 8, !tbaa !9
  store i8 %109, ptr %110, align 1, !tbaa !16
  br label %112

112:                                              ; preds = %106
  %113 = load i32, ptr %17, align 4, !tbaa !5
  %114 = add nsw i32 %113, 8
  store i32 %114, ptr %17, align 4, !tbaa !5
  br label %101, !llvm.loop !17

115:                                              ; preds = %101
  %116 = load i64, ptr %19, align 8, !tbaa !15
  %117 = load i32, ptr %18, align 4, !tbaa !5
  %118 = sub nsw i32 32, %117
  %119 = zext i32 %118 to i64
  %120 = lshr i64 %116, %119
  %121 = trunc i64 %120 to i32
  %122 = load i32, ptr %15, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds i32, ptr %46, i64 %123
  store i32 %121, ptr %124, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %125

125:                                              ; preds = %115
  %126 = load i32, ptr %15, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %15, align 4, !tbaa !5
  %128 = load i32, ptr %16, align 4, !tbaa !5
  %129 = add nsw i32 %128, 32
  store i32 %129, ptr %16, align 4, !tbaa !5
  br label %89, !llvm.loop !19

130:                                              ; preds = %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  %131 = load ptr, ptr %13, align 8
  call void @llvm.stackrestore.p0(ptr %131)
  br label %147

132:                                              ; preds = %64
  %133 = load i32, ptr %5, align 4, !tbaa !5
  %134 = load ptr, ptr %6, align 8, !tbaa !9
  %135 = getelementptr inbounds %struct.squashfs_super_block, ptr %134, i32 0, i32 14
  %136 = load i32, ptr %135, align 1, !tbaa !14
  %137 = load ptr, ptr %6, align 8, !tbaa !9
  %138 = getelementptr inbounds %struct.squashfs_super_block, ptr %137, i32 0, i32 13
  %139 = load i32, ptr %138, align 1, !tbaa !11
  %140 = zext i32 %139 to i64
  %141 = mul i64 %140, 8
  %142 = add i64 %141, 8192
  %143 = sub i64 %142, 1
  %144 = udiv i64 %143, 8192
  %145 = mul i64 %144, 4
  %146 = trunc i64 %145 to i32
  call void @read_bytes(i32 noundef %133, i32 noundef %136, i32 noundef %146, ptr noundef %46)
  br label %147

147:                                              ; preds = %132, %130
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %166, %147
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = load i32, ptr %9, align 4, !tbaa !5
  %151 = icmp slt i32 %149, %150
  br i1 %151, label %152, label %169

152:                                              ; preds = %148
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #8
  %153 = load i32, ptr %5, align 4, !tbaa !5
  %154 = load i32, ptr %8, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds i32, ptr %46, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = load ptr, ptr %7, align 8, !tbaa !9
  %159 = load ptr, ptr %158, align 8, !tbaa !9
  %160 = load i32, ptr %8, align 4, !tbaa !5
  %161 = mul nsw i32 %160, 8192
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds i8, ptr %159, i64 %162
  %164 = load ptr, ptr %6, align 8, !tbaa !9
  %165 = call i32 @read_block(i32 noundef %153, i32 noundef %157, ptr noundef null, ptr noundef %163, ptr noundef %164)
  store i32 %165, ptr %22, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  br label %166

166:                                              ; preds = %152
  %167 = load i32, ptr %8, align 4, !tbaa !5
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %8, align 4, !tbaa !5
  br label %148, !llvm.loop !20

169:                                              ; preds = %148
  %170 = load i32, ptr @swap, align 4, !tbaa !5
  %171 = icmp ne i32 %170, 0
  br i1 %171, label %172, label %247

172:                                              ; preds = %169
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #8
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %173

173:                                              ; preds = %243, %172
  %174 = load i32, ptr %8, align 4, !tbaa !5
  %175 = load ptr, ptr %6, align 8, !tbaa !9
  %176 = getelementptr inbounds %struct.squashfs_super_block, ptr %175, i32 0, i32 13
  %177 = load i32, ptr %176, align 1, !tbaa !11
  %178 = icmp ult i32 %174, %177
  br i1 %178, label %179, label %246

179:                                              ; preds = %173
  call void @llvm.memset.p0.i64(ptr align 1 %23, i8 0, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #8
  store i32 0, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #8
  store i64 0, ptr %26, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #8
  %180 = load ptr, ptr %7, align 8, !tbaa !9
  %181 = load ptr, ptr %180, align 8, !tbaa !9
  %182 = load i32, ptr %8, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds %struct.squashfs_fragment_entry, ptr %181, i64 %183
  %185 = getelementptr inbounds i8, ptr %184, i64 0
  store ptr %185, ptr %27, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #8
  %186 = getelementptr inbounds i8, ptr %26, i64 7
  store ptr %186, ptr %28, align 8, !tbaa !9
  store i32 0, ptr %24, align 4, !tbaa !5
  br label %187

187:                                              ; preds = %198, %179
  %188 = load i32, ptr %24, align 4, !tbaa !5
  %189 = load i32, ptr %25, align 4, !tbaa !5
  %190 = add nsw i32 32, %189
  %191 = icmp slt i32 %188, %190
  br i1 %191, label %192, label %201

192:                                              ; preds = %187
  %193 = load ptr, ptr %27, align 8, !tbaa !9
  %194 = getelementptr inbounds i8, ptr %193, i32 1
  store ptr %194, ptr %27, align 8, !tbaa !9
  %195 = load i8, ptr %193, align 1, !tbaa !16
  %196 = load ptr, ptr %28, align 8, !tbaa !9
  %197 = getelementptr inbounds i8, ptr %196, i32 -1
  store ptr %197, ptr %28, align 8, !tbaa !9
  store i8 %195, ptr %196, align 1, !tbaa !16
  br label %198

198:                                              ; preds = %192
  %199 = load i32, ptr %24, align 4, !tbaa !5
  %200 = add nsw i32 %199, 8
  store i32 %200, ptr %24, align 4, !tbaa !5
  br label %187, !llvm.loop !21

201:                                              ; preds = %187
  %202 = load i64, ptr %26, align 8, !tbaa !15
  %203 = load i32, ptr %25, align 4, !tbaa !5
  %204 = sub nsw i32 32, %203
  %205 = zext i32 %204 to i64
  %206 = lshr i64 %202, %205
  %207 = trunc i64 %206 to i32
  %208 = getelementptr inbounds %struct.squashfs_fragment_entry, ptr %23, i32 0, i32 0
  store i32 %207, ptr %208, align 1, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #8
  store i32 0, ptr %30, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #8
  store i64 0, ptr %31, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %32) #8
  %209 = load ptr, ptr %7, align 8, !tbaa !9
  %210 = load ptr, ptr %209, align 8, !tbaa !9
  %211 = load i32, ptr %8, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds %struct.squashfs_fragment_entry, ptr %210, i64 %212
  %214 = getelementptr inbounds i8, ptr %213, i64 4
  store ptr %214, ptr %32, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #8
  %215 = getelementptr inbounds i8, ptr %31, i64 7
  store ptr %215, ptr %33, align 8, !tbaa !9
  store i32 0, ptr %29, align 4, !tbaa !5
  br label %216

216:                                              ; preds = %227, %201
  %217 = load i32, ptr %29, align 4, !tbaa !5
  %218 = load i32, ptr %30, align 4, !tbaa !5
  %219 = add nsw i32 32, %218
  %220 = icmp slt i32 %217, %219
  br i1 %220, label %221, label %230

221:                                              ; preds = %216
  %222 = load ptr, ptr %32, align 8, !tbaa !9
  %223 = getelementptr inbounds i8, ptr %222, i32 1
  store ptr %223, ptr %32, align 8, !tbaa !9
  %224 = load i8, ptr %222, align 1, !tbaa !16
  %225 = load ptr, ptr %33, align 8, !tbaa !9
  %226 = getelementptr inbounds i8, ptr %225, i32 -1
  store ptr %226, ptr %33, align 8, !tbaa !9
  store i8 %224, ptr %225, align 1, !tbaa !16
  br label %227

227:                                              ; preds = %221
  %228 = load i32, ptr %29, align 4, !tbaa !5
  %229 = add nsw i32 %228, 8
  store i32 %229, ptr %29, align 4, !tbaa !5
  br label %216, !llvm.loop !24

230:                                              ; preds = %216
  %231 = load i64, ptr %31, align 8, !tbaa !15
  %232 = load i32, ptr %30, align 4, !tbaa !5
  %233 = sub nsw i32 32, %232
  %234 = zext i32 %233 to i64
  %235 = lshr i64 %231, %234
  %236 = trunc i64 %235 to i32
  %237 = getelementptr inbounds %struct.squashfs_fragment_entry, ptr %23, i32 0, i32 1
  store i32 %236, ptr %237, align 1, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 8, ptr %33) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %32) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #8
  %238 = load ptr, ptr %7, align 8, !tbaa !9
  %239 = load ptr, ptr %238, align 8, !tbaa !9
  %240 = load i32, ptr %8, align 4, !tbaa !5
  %241 = sext i32 %240 to i64
  %242 = getelementptr inbounds %struct.squashfs_fragment_entry, ptr %239, i64 %241
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %242, ptr align 1 %23, i64 8, i1 false)
  br label %243

243:                                              ; preds = %230
  %244 = load i32, ptr %8, align 4, !tbaa !5
  %245 = add nsw i32 %244, 1
  store i32 %245, ptr %8, align 4, !tbaa !5
  br label %173, !llvm.loop !26

246:                                              ; preds = %173
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #8
  br label %247

247:                                              ; preds = %246, %169
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %248

248:                                              ; preds = %247, %61, %51
  %249 = load ptr, ptr %10, align 8
  call void @llvm.stackrestore.p0(ptr %249)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  %250 = load i32, ptr %4, align 4
  ret i32 %250
}

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 55}
!12 = !{!"squashfs_super_block", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 30, !6, i64 32, !6, i64 34, !6, i64 36, !6, i64 37, !6, i64 38, !6, i64 39, !13, i64 43, !6, i64 51, !6, i64 55, !6, i64 59}
!13 = !{!"long long", !7, i64 0}
!14 = !{!12, !6, i64 59}
!15 = !{!13, !13, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}
!21 = distinct !{!21, !18}
!22 = !{!23, !6, i64 0}
!23 = !{!"", !6, i64 0, !6, i64 4}
!24 = distinct !{!24, !18}
!25 = !{!23, !6, i64 4}
!26 = distinct !{!26, !18}


; 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.squashfs_fragment_entry = type { i32, i32 }

@swap = external dso_local local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.26 = external hidden unnamed_addr constant [35 x i8], align 1

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

declare void @read_bytes(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @read_fragment_table(i32 noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 55
  %5 = load i32, ptr %4, align 1, !tbaa !5
  %6 = zext i32 %5 to i64
  %7 = shl nuw nsw i64 %6, 3
  %8 = add nuw nsw i64 %7, 8191
  %9 = lshr i64 %8, 13
  %10 = trunc nuw nsw i64 %9 to i32
  %11 = alloca i32, i64 %9, align 16
  %12 = icmp eq i32 %5, 0
  br i1 %12, label %.loopexit, label %13

13:                                               ; preds = %3
  %14 = tail call noalias ptr @malloc(i64 noundef %7) #7
  store ptr %14, ptr %2, align 8, !tbaa !11
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %19

16:                                               ; preds = %13
  %17 = load ptr, ptr @stderr, align 8, !tbaa !11
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.26) #8
  br label %.loopexit

19:                                               ; preds = %13
  %20 = load i32, ptr @swap, align 4, !tbaa !13
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %44, label %.lr.ph

.lr.ph:                                           ; preds = %19
  %21 = tail call ptr @llvm.stacksave.p0()
  %22 = alloca i32, i64 %9, align 16
  %23 = getelementptr inbounds i8, ptr %1, i64 59
  %24 = load i32, ptr %23, align 1, !tbaa !14
  %25 = load i32, ptr %4, align 1, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = shl nuw nsw i64 %26, 3
  %28 = add nuw nsw i64 %27, 8191
  %29 = lshr i64 %28, 11
  %30 = trunc nuw nsw i64 %29 to i32
  %31 = and i32 %30, 33554428
  call void @read_bytes(i32 noundef %0, i32 noundef %24, i32 noundef %31, ptr noundef nonnull %22) #9
  %32 = shl nuw nsw i64 %9, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %11, i8 0, i64 %32, i1 false)
  br label %33

33:                                               ; preds = %.lr.ph, %33
  %indvars.iv91 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next92, %33 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %33 ]
  %34 = lshr exact i64 %indvars.iv91, 3
  %35 = getelementptr inbounds i8, ptr %22, i64 %34
  %36 = getelementptr inbounds i8, ptr %35, i64 1
  %37 = load i8, ptr %35, align 4, !tbaa !15
  %38 = getelementptr inbounds i8, ptr %35, i64 2
  %39 = load i8, ptr %36, align 1, !tbaa !15
  %40 = getelementptr inbounds i8, ptr %35, i64 3
  %41 = load i8, ptr %38, align 2, !tbaa !15
  %42 = load i8, ptr %40, align 1, !tbaa !15
  %.sroa.7113.0.insert.ext = zext i8 %37 to i32
  %.sroa.7113.0.insert.shift = shl nuw i32 %.sroa.7113.0.insert.ext, 24
  %.sroa.6112.0.insert.ext = zext i8 %39 to i32
  %.sroa.6112.0.insert.shift = shl nuw nsw i32 %.sroa.6112.0.insert.ext, 16
  %.sroa.6112.0.insert.insert = or disjoint i32 %.sroa.7113.0.insert.shift, %.sroa.6112.0.insert.shift
  %.sroa.5111.0.insert.ext = zext i8 %41 to i32
  %.sroa.5111.0.insert.shift = shl nuw nsw i32 %.sroa.5111.0.insert.ext, 8
  %.sroa.5111.0.insert.insert = or disjoint i32 %.sroa.6112.0.insert.insert, %.sroa.5111.0.insert.shift
  %.sroa.4110.0.insert.ext = zext i8 %42 to i32
  %.sroa.4110.0.insert.insert = or disjoint i32 %.sroa.5111.0.insert.insert, %.sroa.4110.0.insert.ext
  %43 = getelementptr inbounds i32, ptr %11, i64 %indvars.iv
  store i32 %.sroa.4110.0.insert.insert, ptr %43, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 32
  %exitcond.not = icmp eq i64 %indvars.iv.next, %9
  br i1 %exitcond.not, label %._crit_edge, label %33, !llvm.loop !16

._crit_edge:                                      ; preds = %33
  call void @llvm.stackrestore.p0(ptr %21)
  br label %.lr.ph78.preheader

44:                                               ; preds = %19
  %45 = getelementptr inbounds i8, ptr %1, i64 59
  %46 = load i32, ptr %45, align 1, !tbaa !14
  %47 = lshr i64 %8, 11
  %48 = trunc nuw nsw i64 %47 to i32
  %49 = and i32 %48, 33554428
  call void @read_bytes(i32 noundef %0, i32 noundef %46, i32 noundef %49, ptr noundef nonnull %11) #9
  br label %.lr.ph78.preheader

.lr.ph78.preheader:                               ; preds = %._crit_edge, %44
  %umax = call i32 @llvm.umax.i32(i32 %10, i32 1)
  %wide.trip.count99 = zext nneg i32 %umax to i64
  br label %.lr.ph78

.lr.ph78:                                         ; preds = %.lr.ph78.preheader, %.lr.ph78
  %indvars.iv96 = phi i64 [ 0, %.lr.ph78.preheader ], [ %indvars.iv.next97, %.lr.ph78 ]
  %50 = getelementptr inbounds i32, ptr %11, i64 %indvars.iv96
  %51 = load i32, ptr %50, align 4, !tbaa !13
  %52 = load ptr, ptr %2, align 8, !tbaa !11
  %53 = shl nsw i64 %indvars.iv96, 13
  %54 = getelementptr inbounds i8, ptr %52, i64 %53
  %55 = call i32 @read_block(i32 noundef %0, i32 noundef %51, ptr noundef null, ptr noundef %54, ptr noundef %1)
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %exitcond100.not = icmp eq i64 %indvars.iv.next97, %wide.trip.count99
  br i1 %exitcond100.not, label %._crit_edge79, label %.lr.ph78, !llvm.loop !18

._crit_edge79:                                    ; preds = %.lr.ph78
  %56 = load i32, ptr @swap, align 4, !tbaa !13
  %.not70 = icmp eq i32 %56, 0
  br i1 %.not70, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %._crit_edge79
  %57 = load i32, ptr %4, align 1, !tbaa !5
  %.not90 = icmp eq i32 %57, 0
  br i1 %.not90, label %.loopexit, label %.lr.ph87

.lr.ph87:                                         ; preds = %.preheader, %.lr.ph87
  %indvars.iv101 = phi i64 [ %indvars.iv.next102, %.lr.ph87 ], [ 0, %.preheader ]
  %58 = load ptr, ptr %2, align 8, !tbaa !11
  %59 = getelementptr inbounds %struct.squashfs_fragment_entry, ptr %58, i64 %indvars.iv101
  %60 = getelementptr inbounds i8, ptr %59, i64 1
  %61 = load i8, ptr %59, align 1, !tbaa !15
  %62 = getelementptr inbounds i8, ptr %59, i64 2
  %63 = load i8, ptr %60, align 1, !tbaa !15
  %64 = getelementptr inbounds i8, ptr %59, i64 3
  %65 = load i8, ptr %62, align 1, !tbaa !15
  %66 = load i8, ptr %64, align 1, !tbaa !15
  %.sroa.7108.0.insert.ext = zext i8 %61 to i32
  %.sroa.7108.0.insert.shift = shl nuw i32 %.sroa.7108.0.insert.ext, 24
  %.sroa.6107.0.insert.ext = zext i8 %63 to i32
  %.sroa.6107.0.insert.shift = shl nuw nsw i32 %.sroa.6107.0.insert.ext, 16
  %.sroa.6107.0.insert.insert = or disjoint i32 %.sroa.7108.0.insert.shift, %.sroa.6107.0.insert.shift
  %.sroa.5106.0.insert.ext = zext i8 %65 to i32
  %.sroa.5106.0.insert.shift = shl nuw nsw i32 %.sroa.5106.0.insert.ext, 8
  %.sroa.5106.0.insert.insert = or disjoint i32 %.sroa.6107.0.insert.insert, %.sroa.5106.0.insert.shift
  %.sroa.4105.0.insert.ext = zext i8 %66 to i32
  %.sroa.4105.0.insert.insert = or disjoint i32 %.sroa.5106.0.insert.insert, %.sroa.4105.0.insert.ext
  %67 = getelementptr inbounds %struct.squashfs_fragment_entry, ptr %58, i64 %indvars.iv101, i32 1
  %68 = getelementptr inbounds i8, ptr %67, i64 1
  %69 = load i8, ptr %67, align 1, !tbaa !15
  %70 = getelementptr inbounds i8, ptr %67, i64 2
  %71 = load i8, ptr %68, align 1, !tbaa !15
  %72 = getelementptr inbounds i8, ptr %67, i64 3
  %73 = load i8, ptr %70, align 1, !tbaa !15
  %74 = load i8, ptr %72, align 1, !tbaa !15
  %.sroa.7.0.insert.ext = zext i8 %69 to i32
  %.sroa.7.0.insert.shift = shl nuw i32 %.sroa.7.0.insert.ext, 24
  %.sroa.6.0.insert.ext = zext i8 %71 to i32
  %.sroa.6.0.insert.shift = shl nuw nsw i32 %.sroa.6.0.insert.ext, 16
  %.sroa.6.0.insert.insert = or disjoint i32 %.sroa.7.0.insert.shift, %.sroa.6.0.insert.shift
  %.sroa.5.0.insert.ext = zext i8 %73 to i32
  %.sroa.5.0.insert.shift = shl nuw nsw i32 %.sroa.5.0.insert.ext, 8
  %.sroa.5.0.insert.insert = or disjoint i32 %.sroa.6.0.insert.insert, %.sroa.5.0.insert.shift
  %.sroa.4.0.insert.ext = zext i8 %74 to i32
  %.sroa.4.0.insert.insert = or disjoint i32 %.sroa.5.0.insert.insert, %.sroa.4.0.insert.ext
  store i32 %.sroa.4105.0.insert.insert, ptr %59, align 1
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %59, i64 4
  store i32 %.sroa.4.0.insert.insert, ptr %.sroa.5.0..sroa_idx, align 1
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %75 = load i32, ptr %4, align 1, !tbaa !5
  %76 = zext i32 %75 to i64
  %77 = icmp ult i64 %indvars.iv.next102, %76
  br i1 %77, label %.lr.ph87, label %.loopexit, !llvm.loop !19

.loopexit:                                        ; preds = %.lr.ph87, %.preheader, %._crit_edge79, %3, %16
  %.058 = phi i32 [ 0, %16 ], [ 1, %3 ], [ 1, %._crit_edge79 ], [ 1, %.preheader ], [ 1, %.lr.ph87 ]
  ret i32 %.058
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #6

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 = { nofree 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: write) }
attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { cold nounwind }
attributes #9 = { 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 55}
!6 = !{!"squashfs_super_block", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 30, !7, i64 32, !7, i64 34, !7, i64 36, !7, i64 37, !7, i64 38, !7, i64 39, !10, i64 43, !7, i64 51, !7, i64 55, !7, i64 59}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 59}
!15 = !{!8, !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}


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