; LLVM IR from artagnon/phoenixfs :: pack (unmap_write_idx)

; 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.packed_git = type { [4096 x i8], [4096 x i8], ptr, ptr, i64, i64, i32 }
%struct.pack_idx_header = type { i32, i32 }
%struct.pack_idx_entry = type { [20 x i8], i64, i64 }

@packroot = external hidden global %struct.packed_git, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1
@loaded_pack = external hidden global i8, align 1
@.str.31 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [35 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: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) #1

declare void @print_sha1(ptr noundef, ptr noundef) #2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

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

declare i32 @fclose(ptr noundef) #2

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

declare void @die(ptr noundef, ...) #2

; Function Attrs: nounwind
declare i32 @munmap(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @unmap_write_idx(ptr noundef %0, i32 noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.pack_idx_header, align 4
  %10 = alloca i64, align 8
  %11 = alloca [40 x i8], align 16
  %12 = alloca [256 x i32], align 16
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i64, align 8
  %24 = alloca [2 x i32], align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %64

27:                                               ; preds = %2
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %28, ptr %5, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %29, ptr %6, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds ptr, ptr %30, i64 %32
  store ptr %33, ptr %7, align 8, !tbaa !5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %57, %27
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %60

38:                                               ; preds = %34
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i32, ptr %13, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds ptr, ptr %39, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.pack_idx_entry, ptr %43, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !13
  %46 = load i64, ptr %10, align 8, !tbaa !11
  %47 = icmp sgt i64 %45, %46
  br i1 %47, label %48, label %56

48:                                               ; preds = %38
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load i32, ptr %13, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds ptr, ptr %49, i64 %51
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.pack_idx_entry, ptr %53, i32 0, i32 1
  %55 = load i64, ptr %54, align 8, !tbaa !13
  store i64 %55, ptr %10, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %48, %38
  br label %57

57:                                               ; preds = %56
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %13, align 4, !tbaa !9
  br label %34, !llvm.loop !15

60:                                               ; preds = %34
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load i32, ptr %4, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  call void @qsort(ptr noundef %61, i64 noundef %63, i64 noundef 8, ptr noundef @sha1_compare)
  br label %65

64:                                               ; preds = %2
  store ptr null, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %64, %60
  %66 = load i8, ptr @loaded_pack, align 1, !tbaa !17, !range !19, !noundef !20
  %67 = trunc i8 %66 to i1
  br i1 %67, label %68, label %72

68:                                               ; preds = %65
  %69 = load ptr, ptr getelementptr inbounds (%struct.packed_git, ptr @packroot, i32 0, i32 3), align 8, !tbaa !21
  %70 = load i64, ptr getelementptr inbounds (%struct.packed_git, ptr @packroot, i32 0, i32 5), align 8, !tbaa !23
  %71 = call i32 @munmap(ptr noundef %69, i64 noundef %70) #5
  br label %72

72:                                               ; preds = %68, %65
  %73 = call noalias ptr @fopen(ptr noundef getelementptr inbounds (%struct.packed_git, ptr @packroot, i32 0, i32 1), ptr noundef @.str.12)
  store ptr %73, ptr %14, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %76, label %75

75:                                               ; preds = %72
  call void (ptr, ...) @die(ptr noundef @.str.31, ptr noundef getelementptr inbounds (%struct.packed_git, ptr @packroot, i32 0, i32 1))
  br label %76

76:                                               ; preds = %75, %72
  %77 = call i32 @__bswap_32(i32 noundef -9154717)
  %78 = getelementptr inbounds %struct.pack_idx_header, ptr %9, i32 0, i32 0
  store i32 %77, ptr %78, align 4, !tbaa !24
  %79 = call i32 @__bswap_32(i32 noundef 2)
  %80 = getelementptr inbounds %struct.pack_idx_header, ptr %9, i32 0, i32 1
  store i32 %79, ptr %80, align 4, !tbaa !26
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = call i64 @fwrite(ptr noundef %9, i64 noundef 8, i64 noundef 1, ptr noundef %81)
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %122, %76
  %84 = load i32, ptr %13, align 4, !tbaa !9
  %85 = icmp slt i32 %84, 256
  br i1 %85, label %86, label %125

86:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %87, ptr %15, align 8, !tbaa !5
  br label %88

88:                                               ; preds = %108, %86
  %89 = load ptr, ptr %15, align 8, !tbaa !5
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = icmp ult ptr %89, %90
  br i1 %91, label %92, label %109

92:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %93 = load ptr, ptr %15, align 8, !tbaa !5
  %94 = load ptr, ptr %93, align 8, !tbaa !5
  store ptr %94, ptr %16, align 8, !tbaa !5
  %95 = load ptr, ptr %16, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.pack_idx_entry, ptr %95, i32 0, i32 0
  %97 = getelementptr inbounds [20 x i8], ptr %96, i64 0, i64 0
  %98 = load i8, ptr %97, align 8, !tbaa !27
  %99 = zext i8 %98 to i32
  %100 = load i32, ptr %13, align 4, !tbaa !9
  %101 = icmp ne i32 %99, %100
  br i1 %101, label %102, label %103

102:                                              ; preds = %92
  store i32 9, ptr %17, align 4
  br label %106

103:                                              ; preds = %92
  %104 = load ptr, ptr %15, align 8, !tbaa !5
  %105 = getelementptr inbounds ptr, ptr %104, i32 1
  store ptr %105, ptr %15, align 8, !tbaa !5
  store i32 0, ptr %17, align 4
  br label %106

106:                                              ; preds = %103, %102
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %107 = load i32, ptr %17, align 4
  switch i32 %107, label %243 [
    i32 0, label %108
    i32 9, label %109
  ]

108:                                              ; preds = %106
  br label %88, !llvm.loop !28

109:                                              ; preds = %106, %88
  %110 = load ptr, ptr %15, align 8, !tbaa !5
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = ptrtoint ptr %110 to i64
  %113 = ptrtoint ptr %111 to i64
  %114 = sub i64 %112, %113
  %115 = sdiv exact i64 %114, 8
  %116 = trunc i64 %115 to i32
  %117 = call i32 @__bswap_32(i32 noundef %116)
  %118 = load i32, ptr %13, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [256 x i32], ptr %12, i64 0, i64 %119
  store i32 %117, ptr %120, align 4, !tbaa !9
  %121 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %121, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %122

122:                                              ; preds = %109
  %123 = load i32, ptr %13, align 4, !tbaa !9
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %13, align 4, !tbaa !9
  br label %83, !llvm.loop !29

125:                                              ; preds = %83
  %126 = load ptr, ptr %14, align 8, !tbaa !5
  %127 = call i64 @fwrite(ptr noundef %12, i64 noundef 1024, i64 noundef 1, ptr noundef %126)
  %128 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %128, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %129

129:                                              ; preds = %142, %125
  %130 = load i32, ptr %13, align 4, !tbaa !9
  %131 = load i32, ptr %4, align 4, !tbaa !9
  %132 = icmp slt i32 %130, %131
  br i1 %132, label %133, label %145

133:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %134 = load ptr, ptr %6, align 8, !tbaa !5
  %135 = getelementptr inbounds ptr, ptr %134, i32 1
  store ptr %135, ptr %6, align 8, !tbaa !5
  %136 = load ptr, ptr %134, align 8, !tbaa !5
  store ptr %136, ptr %18, align 8, !tbaa !5
  %137 = load ptr, ptr %18, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.pack_idx_entry, ptr %137, i32 0, i32 0
  %139 = getelementptr inbounds [20 x i8], ptr %138, i64 0, i64 0
  %140 = load ptr, ptr %14, align 8, !tbaa !5
  %141 = call i64 @fwrite(ptr noundef %139, i64 noundef 20, i64 noundef 1, ptr noundef %140)
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %142

142:                                              ; preds = %133
  %143 = load i32, ptr %13, align 4, !tbaa !9
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %13, align 4, !tbaa !9
  br label %129, !llvm.loop !30

145:                                              ; preds = %129
  store i32 0, ptr %8, align 4, !tbaa !9
  %146 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %146, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %147

147:                                              ; preds = %192, %145
  %148 = load i32, ptr %13, align 4, !tbaa !9
  %149 = load i32, ptr %4, align 4, !tbaa !9
  %150 = icmp slt i32 %148, %149
  br i1 %150, label %151, label %195

151:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %152 = load ptr, ptr %6, align 8, !tbaa !5
  %153 = getelementptr inbounds ptr, ptr %152, i32 1
  store ptr %153, ptr %6, align 8, !tbaa !5
  %154 = load ptr, ptr %152, align 8, !tbaa !5
  store ptr %154, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %155 = load ptr, ptr %19, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.pack_idx_entry, ptr %155, i32 0, i32 1
  %157 = load i64, ptr %156, align 8, !tbaa !13
  %158 = icmp sle i64 %157, 2147483647
  br i1 %158, label %159, label %163

159:                                              ; preds = %151
  %160 = load ptr, ptr %19, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.pack_idx_entry, ptr %160, i32 0, i32 1
  %162 = load i64, ptr %161, align 8, !tbaa !13
  br label %168

163:                                              ; preds = %151
  %164 = load i32, ptr %8, align 4, !tbaa !9
  %165 = add i32 %164, 1
  store i32 %165, ptr %8, align 4, !tbaa !9
  %166 = or i32 -2147483648, %164
  %167 = zext i32 %166 to i64
  br label %168

168:                                              ; preds = %163, %159
  %169 = phi i64 [ %162, %159 ], [ %167, %163 ]
  %170 = trunc i64 %169 to i32
  store i32 %170, ptr %20, align 4, !tbaa !9
  %171 = load i32, ptr %20, align 4, !tbaa !9
  %172 = call i32 @__bswap_32(i32 noundef %171)
  store i32 %172, ptr %20, align 4, !tbaa !9
  %173 = getelementptr inbounds [40 x i8], ptr %11, i64 0, i64 0
  %174 = load ptr, ptr %19, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.pack_idx_entry, ptr %174, i32 0, i32 0
  %176 = getelementptr inbounds [20 x i8], ptr %175, i64 0, i64 0
  call void @print_sha1(ptr noundef %173, ptr noundef %176)
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %177 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %177, ptr %21, align 8, !tbaa !5
  %178 = load ptr, ptr %21, align 8, !tbaa !5
  %179 = icmp ne ptr %178, null
  br i1 %179, label %180, label %189

180:                                              ; preds = %168
  %181 = load ptr, ptr %21, align 8, !tbaa !5
  %182 = getelementptr inbounds [40 x i8], ptr %11, i64 0, i64 0
  %183 = load ptr, ptr %19, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.pack_idx_entry, ptr %183, i32 0, i32 1
  %185 = load i64, ptr %184, align 8, !tbaa !13
  %186 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %181, ptr noundef @.str.32, i32 noundef 416, ptr noundef %182, i64 noundef %185) #5
  %187 = load ptr, ptr %21, align 8, !tbaa !5
  %188 = call i32 @fclose(ptr noundef %187)
  br label %189

189:                                              ; preds = %180, %168
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  %190 = load ptr, ptr %14, align 8, !tbaa !5
  %191 = call i64 @fwrite(ptr noundef %20, i64 noundef 4, i64 noundef 1, ptr noundef %190)
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %192

192:                                              ; preds = %189
  %193 = load i32, ptr %13, align 4, !tbaa !9
  %194 = add nsw i32 %193, 1
  store i32 %194, ptr %13, align 4, !tbaa !9
  br label %147, !llvm.loop !31

195:                                              ; preds = %147
  %196 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %196, ptr %6, align 8, !tbaa !5
  br label %197

197:                                              ; preds = %225, %195
  %198 = load i32, ptr %8, align 4, !tbaa !9
  %199 = icmp ne i32 %198, 0
  br i1 %199, label %200, label %226

200:                                              ; preds = %197
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %201 = load ptr, ptr %6, align 8, !tbaa !5
  %202 = getelementptr inbounds ptr, ptr %201, i32 1
  store ptr %202, ptr %6, align 8, !tbaa !5
  %203 = load ptr, ptr %201, align 8, !tbaa !5
  store ptr %203, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  %204 = load ptr, ptr %22, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.pack_idx_entry, ptr %204, i32 0, i32 1
  %206 = load i64, ptr %205, align 8, !tbaa !13
  store i64 %206, ptr %23, align 8, !tbaa !11
  %207 = load i64, ptr %23, align 8, !tbaa !11
  %208 = icmp ugt i64 %207, 2147483647
  br i1 %208, label %209, label %225

209:                                              ; preds = %200
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  %210 = load i64, ptr %23, align 8, !tbaa !11
  %211 = lshr i64 %210, 32
  %212 = trunc i64 %211 to i32
  %213 = call i32 @__bswap_32(i32 noundef %212)
  %214 = getelementptr inbounds [2 x i32], ptr %24, i64 0, i64 0
  store i32 %213, ptr %214, align 4, !tbaa !9
  %215 = load i64, ptr %23, align 8, !tbaa !11
  %216 = and i64 %215, 4294967295
  %217 = trunc i64 %216 to i32
  %218 = call i32 @__bswap_32(i32 noundef %217)
  %219 = getelementptr inbounds [2 x i32], ptr %24, i64 0, i64 1
  store i32 %218, ptr %219, align 4, !tbaa !9
  %220 = getelementptr inbounds [2 x i32], ptr %24, i64 0, i64 0
  %221 = load ptr, ptr %14, align 8, !tbaa !5
  %222 = call i64 @fwrite(ptr noundef %220, i64 noundef 8, i64 noundef 1, ptr noundef %221)
  %223 = load i32, ptr %8, align 4, !tbaa !9
  %224 = add i32 %223, -1
  store i32 %224, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  br label %225

225:                                              ; preds = %209, %200
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  br label %197, !llvm.loop !32

226:                                              ; preds = %197
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %227

227:                                              ; preds = %237, %226
  %228 = load i32, ptr %13, align 4, !tbaa !9
  %229 = load i32, ptr %4, align 4, !tbaa !9
  %230 = icmp slt i32 %228, %229
  br i1 %230, label %231, label %240

231:                                              ; preds = %227
  %232 = load ptr, ptr %3, align 8, !tbaa !5
  %233 = load i32, ptr %13, align 4, !tbaa !9
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds ptr, ptr %232, i64 %234
  %236 = load ptr, ptr %235, align 8, !tbaa !5
  call void @free(ptr noundef %236) #5
  br label %237

237:                                              ; preds = %231
  %238 = load i32, ptr %13, align 4, !tbaa !9
  %239 = add nsw i32 %238, 1
  store i32 %239, ptr %13, align 4, !tbaa !9
  br label %227, !llvm.loop !33

240:                                              ; preds = %227
  %241 = load ptr, ptr %14, align 8, !tbaa !5
  %242 = call i32 @fclose(ptr noundef %241)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void

243:                                              ; preds = %106
  unreachable
}

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @sha1_compare(ptr noundef, ptr noundef) #4

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 24}
!14 = !{!"pack_idx_entry", !7, i64 0, !12, i64 24, !12, i64 32}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !18, i64 0}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!22, !6, i64 8200}
!22 = !{!"packed_git", !7, i64 0, !7, i64 4096, !6, i64 8192, !6, i64 8200, !12, i64 8208, !12, i64 8216, !10, i64 8224}
!23 = !{!22, !12, i64 8216}
!24 = !{!25, !10, i64 0}
!25 = !{!"pack_idx_header", !10, i64 0, !10, i64 4}
!26 = !{!25, !10, i64 4}
!27 = !{!7, !7, i64 0}
!28 = distinct !{!28, !16}
!29 = distinct !{!29, !16}
!30 = distinct !{!30, !16}
!31 = distinct !{!31, !16}
!32 = distinct !{!32, !16}
!33 = distinct !{!33, !16}


; 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.packed_git = type { [4096 x i8], [4096 x i8], ptr, ptr, i64, i64, i32 }
%struct.pack_idx_header = type { i32, i32 }

@packroot = external hidden global %struct.packed_git, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1
@loaded_pack = external hidden local_unnamed_addr global i8, align 1
@.str.31 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [35 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) local_unnamed_addr #1

declare void @print_sha1(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #3

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

declare void @die(ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @munmap(ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @unmap_write_idx(ptr noundef %0, i32 noundef %1) local_unnamed_addr #5 {
  %3 = alloca %struct.pack_idx_header, align 4
  %4 = alloca [40 x i8], align 16
  %5 = alloca [256 x i32], align 16
  %6 = alloca i32, align 4
  %7 = alloca [2 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #8
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %5) #8
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %10, label %._crit_edge

._crit_edge:                                      ; preds = %2
  %8 = sext i32 %1 to i64
  %9 = getelementptr inbounds ptr, ptr %0, i64 %8
  tail call void @qsort(ptr noundef %0, i64 noundef %8, i64 noundef 8, ptr noundef nonnull @sha1_compare) #8
  br label %10

10:                                               ; preds = %2, %._crit_edge
  %.067 = phi ptr [ %9, %._crit_edge ], [ null, %2 ]
  %.0 = phi ptr [ %0, %._crit_edge ], [ null, %2 ]
  %11 = load i8, ptr @loaded_pack, align 1, !tbaa !5, !range !9, !noundef !10
  %12 = trunc nuw i8 %11 to i1
  br i1 %12, label %13, label %17

13:                                               ; preds = %10
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @packroot, i64 8200), align 8, !tbaa !11
  %15 = load i64, ptr getelementptr inbounds (i8, ptr @packroot, i64 8216), align 8, !tbaa !16
  %16 = tail call i32 @munmap(ptr noundef %14, i64 noundef %15) #8
  br label %17

17:                                               ; preds = %13, %10
  %18 = tail call noalias ptr @fopen(ptr noundef nonnull getelementptr inbounds (i8, ptr @packroot, i64 4096), ptr noundef nonnull @.str.12)
  %.not89 = icmp eq ptr %18, null
  br i1 %.not89, label %19, label %20

19:                                               ; preds = %17
  tail call void (ptr, ...) @die(ptr noundef nonnull @.str.31, ptr noundef nonnull getelementptr inbounds (i8, ptr @packroot, i64 4096)) #8
  br label %20

20:                                               ; preds = %19, %17
  %21 = tail call i32 @__bswap_32(i32 noundef -9154717)
  store i32 %21, ptr %3, align 4, !tbaa !17
  %22 = tail call i32 @__bswap_32(i32 noundef 2)
  %23 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %22, ptr %23, align 4, !tbaa !19
  %24 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 8, i64 noundef 1, ptr noundef %18)
  %25 = ptrtoint ptr %.0 to i64
  br label %.preheader95

.preheader95:                                     ; preds = %20, %33
  %indvars.iv = phi i64 [ 0, %20 ], [ %indvars.iv.next, %33 ]
  %.199 = phi ptr [ %.0, %20 ], [ %.080, %33 ]
  br label %26

26:                                               ; preds = %.preheader95, %28
  %.080 = phi ptr [ %32, %28 ], [ %.199, %.preheader95 ]
  %27 = icmp ult ptr %.080, %.067
  br i1 %27, label %28, label %33

28:                                               ; preds = %26
  %29 = load ptr, ptr %.080, align 8, !tbaa !20
  %30 = load i8, ptr %29, align 8, !tbaa !21
  %31 = zext i8 %30 to i64
  %.not92 = icmp eq i64 %indvars.iv, %31
  %32 = getelementptr inbounds i8, ptr %.080, i64 8
  br i1 %.not92, label %26, label %33

33:                                               ; preds = %28, %26
  %34 = ptrtoint ptr %.080 to i64
  %35 = sub i64 %34, %25
  %36 = lshr exact i64 %35, 3
  %37 = trunc i64 %36 to i32
  %38 = tail call i32 @__bswap_32(i32 noundef %37)
  %39 = getelementptr inbounds [256 x i32], ptr %5, i64 0, i64 %indvars.iv
  store i32 %38, ptr %39, align 4, !tbaa !22
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 256
  br i1 %exitcond.not, label %40, label %.preheader95, !llvm.loop !23

40:                                               ; preds = %33
  %41 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 1024, i64 noundef 1, ptr noundef %18)
  %42 = icmp sgt i32 %1, 0
  br i1 %42, label %.lr.ph103, label %._crit_edge114

.preheader94:                                     ; preds = %.lr.ph103
  br i1 %42, label %.lr.ph107, label %._crit_edge114

.lr.ph103:                                        ; preds = %40, %.lr.ph103
  %.2101 = phi ptr [ %43, %.lr.ph103 ], [ %.0, %40 ]
  %.277100 = phi i32 [ %46, %.lr.ph103 ], [ 0, %40 ]
  %43 = getelementptr inbounds i8, ptr %.2101, i64 8
  %44 = load ptr, ptr %.2101, align 8, !tbaa !20
  %45 = tail call i64 @fwrite(ptr noundef %44, i64 noundef 20, i64 noundef 1, ptr noundef %18)
  %46 = add nuw nsw i32 %.277100, 1
  %exitcond117.not = icmp eq i32 %46, %1
  br i1 %exitcond117.not, label %.preheader94, label %.lr.ph103, !llvm.loop !25

.preheader93:                                     ; preds = %64
  %.not90108 = icmp eq i32 %.169, 0
  br i1 %.not90108, label %.preheader, label %.lr.ph111

.lr.ph111:                                        ; preds = %.preheader93
  %47 = getelementptr inbounds i8, ptr %7, i64 4
  br label %67

.lr.ph107:                                        ; preds = %.preheader94, %64
  %.3106 = phi ptr [ %48, %64 ], [ %.0, %.preheader94 ]
  %.068105 = phi i32 [ %.169, %64 ], [ 0, %.preheader94 ]
  %.378104 = phi i32 [ %66, %64 ], [ 0, %.preheader94 ]
  %48 = getelementptr inbounds i8, ptr %.3106, i64 8
  %49 = load ptr, ptr %.3106, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  %50 = getelementptr inbounds i8, ptr %49, i64 24
  %51 = load i64, ptr %50, align 8, !tbaa !26
  %52 = icmp sgt i64 %51, 2147483647
  %53 = or i32 %.068105, -2147483648
  %54 = zext i32 %53 to i64
  %55 = zext i1 %52 to i32
  %.169 = add i32 %.068105, %55
  %56 = select i1 %52, i64 %54, i64 %51
  %57 = trunc i64 %56 to i32
  %58 = call i32 @__bswap_32(i32 noundef %57)
  store i32 %58, ptr %6, align 4, !tbaa !22
  call void @print_sha1(ptr noundef nonnull %4, ptr noundef %49) #8
  %59 = call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  %.not91 = icmp eq ptr %59, null
  br i1 %.not91, label %64, label %60

60:                                               ; preds = %.lr.ph107
  %61 = load i64, ptr %50, align 8, !tbaa !26
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %59, ptr noundef nonnull @.str.32, i32 noundef 416, ptr noundef nonnull %4, i64 noundef %61) #8
  %63 = call i32 @fclose(ptr noundef nonnull %59)
  br label %64

64:                                               ; preds = %60, %.lr.ph107
  %65 = call i64 @fwrite(ptr noundef nonnull %6, i64 noundef 4, i64 noundef 1, ptr noundef %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #8
  %66 = add nuw nsw i32 %.378104, 1
  %exitcond118.not = icmp eq i32 %66, %1
  br i1 %exitcond118.not, label %.preheader93, label %.lr.ph107, !llvm.loop !28

.preheader:                                       ; preds = %81, %.preheader93
  br i1 %42, label %.lr.ph113.preheader, label %._crit_edge114

.lr.ph113.preheader:                              ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.lr.ph113

67:                                               ; preds = %.lr.ph111, %81
  %.4110 = phi ptr [ %.0, %.lr.ph111 ], [ %68, %81 ]
  %.270109 = phi i32 [ %.169, %.lr.ph111 ], [ %.371, %81 ]
  %68 = getelementptr inbounds i8, ptr %.4110, i64 8
  %69 = load ptr, ptr %.4110, align 8, !tbaa !20
  %70 = getelementptr inbounds i8, ptr %69, i64 24
  %71 = load i64, ptr %70, align 8, !tbaa !26
  %72 = icmp ugt i64 %71, 2147483647
  br i1 %72, label %73, label %81

73:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  %74 = lshr i64 %71, 32
  %75 = trunc nuw i64 %74 to i32
  %76 = call i32 @__bswap_32(i32 noundef %75)
  store i32 %76, ptr %7, align 4, !tbaa !22
  %77 = trunc i64 %71 to i32
  %78 = call i32 @__bswap_32(i32 noundef %77)
  store i32 %78, ptr %47, align 4, !tbaa !22
  %79 = call i64 @fwrite(ptr noundef nonnull %7, i64 noundef 8, i64 noundef 1, ptr noundef %18)
  %80 = add i32 %.270109, -1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  br label %81

81:                                               ; preds = %73, %67
  %.371 = phi i32 [ %80, %73 ], [ %.270109, %67 ]
  %.not90 = icmp eq i32 %.371, 0
  br i1 %.not90, label %.preheader, label %67, !llvm.loop !29

.lr.ph113:                                        ; preds = %.lr.ph113.preheader, %.lr.ph113
  %indvars.iv119 = phi i64 [ 0, %.lr.ph113.preheader ], [ %indvars.iv.next120, %.lr.ph113 ]
  %82 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv119
  %83 = load ptr, ptr %82, align 8, !tbaa !20
  call void @free(ptr noundef %83) #8
  %indvars.iv.next120 = add nuw nsw i64 %indvars.iv119, 1
  %exitcond122.not = icmp eq i64 %indvars.iv.next120, %wide.trip.count
  br i1 %exitcond122.not, label %._crit_edge114, label %.lr.ph113, !llvm.loop !30

._crit_edge114:                                   ; preds = %.lr.ph113, %.preheader94, %40, %.preheader
  %84 = call i32 @fclose(ptr noundef %18)
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  ret void
}

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #6

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

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #7

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !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, !13, i64 8200}
!12 = !{!"packed_git", !7, i64 0, !7, i64 4096, !13, i64 8192, !13, i64 8200, !14, i64 8208, !14, i64 8216, !15, i64 8224}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!12, !14, i64 8216}
!17 = !{!18, !15, i64 0}
!18 = !{!"pack_idx_header", !15, i64 0, !15, i64 4}
!19 = !{!18, !15, i64 4}
!20 = !{!13, !13, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!15, !15, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = !{!27, !14, i64 24}
!27 = !{!"pack_idx_entry", !7, i64 0, !14, i64 24, !14, i64 32}
!28 = distinct !{!28, !24}
!29 = distinct !{!29, !24}
!30 = distinct !{!30, !24}


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