; LLVM IR from zeux/meshoptimizer :: src (vertexcodec)

; 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"

@.str = external hidden unnamed_addr constant [38 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel = external hidden unnamed_addr constant [104 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [57 x i8], align 1
@_ZN7meshoptL20gEncodeVertexVersionE = external hidden global i32, align 4
@.str.6 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local i64 @meshopt_encodeVertexBufferLevel(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca [256 x i8], align 16
  %21 = alloca [256 x i8], align 16
  %22 = alloca i64, align 8
  %23 = alloca [64 x i8], align 16
  %24 = alloca i64, align 8
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i64, align 8
  %28 = alloca i64, align 8
  %29 = alloca i64, align 8
  %30 = alloca i64, align 8
  %31 = alloca i64, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i64 %1, ptr %10, align 8, !tbaa !9
  store ptr %2, ptr %11, align 8, !tbaa !5
  store i64 %3, ptr %12, align 8, !tbaa !9
  store i64 %4, ptr %13, align 8, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !11
  store i32 %6, ptr %15, align 4, !tbaa !11
  %32 = load i64, ptr %13, align 8, !tbaa !9
  %33 = icmp ugt i64 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %7
  %35 = load i64, ptr %13, align 8, !tbaa !9
  %36 = icmp ule i64 %35, 256
  br label %37

37:                                               ; preds = %34, %7
  %38 = phi i1 [ false, %7 ], [ %36, %34 ]
  br i1 %38, label %39, label %40

39:                                               ; preds = %37
  br label %42

40:                                               ; preds = %37
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.2, i32 noundef 1650, ptr noundef @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #6
  unreachable

41:                                               ; No predecessors!
  br label %42

42:                                               ; preds = %41, %39
  %43 = load i64, ptr %13, align 8, !tbaa !9
  %44 = urem i64 %43, 4
  %45 = icmp eq i64 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  br label %49

47:                                               ; preds = %42
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 1651, ptr noundef @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #6
  unreachable

48:                                               ; No predecessors!
  br label %49

49:                                               ; preds = %48, %46
  %50 = load i32, ptr %14, align 4, !tbaa !11
  %51 = icmp sge i32 %50, 0
  br i1 %51, label %52, label %55

52:                                               ; preds = %49
  %53 = load i32, ptr %14, align 4, !tbaa !11
  %54 = icmp sle i32 %53, 9
  br label %55

55:                                               ; preds = %52, %49
  %56 = phi i1 [ false, %49 ], [ %54, %52 ]
  br i1 %56, label %57, label %58

57:                                               ; preds = %55
  br label %60

58:                                               ; preds = %55
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 1652, ptr noundef @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #6
  unreachable

59:                                               ; No predecessors!
  br label %60

60:                                               ; preds = %59, %57
  %61 = load i32, ptr %15, align 4, !tbaa !11
  %62 = icmp slt i32 %61, 0
  br i1 %62, label %66, label %63

63:                                               ; preds = %60
  %64 = load i32, ptr %15, align 4, !tbaa !11
  %65 = icmp ule i32 %64, 1
  br label %66

66:                                               ; preds = %63, %60
  %67 = phi i1 [ true, %60 ], [ %65, %63 ]
  br i1 %67, label %68, label %69

68:                                               ; preds = %66
  br label %71

69:                                               ; preds = %66
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.2, i32 noundef 1653, ptr noundef @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #6
  unreachable

70:                                               ; No predecessors!
  br label %71

71:                                               ; preds = %70, %68
  %72 = load i32, ptr %15, align 4, !tbaa !11
  %73 = icmp slt i32 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %71
  %75 = load i32, ptr @_ZN7meshoptL20gEncodeVertexVersionE, align 4, !tbaa !11
  br label %78

76:                                               ; preds = %71
  %77 = load i32, ptr %15, align 4, !tbaa !11
  br label %78

78:                                               ; preds = %76, %74
  %79 = phi i32 [ %75, %74 ], [ %77, %76 ]
  store i32 %79, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %80, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %81, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = load i64, ptr %10, align 8, !tbaa !9
  %84 = getelementptr inbounds i8, ptr %82, i64 %83
  store ptr %84, ptr %18, align 8, !tbaa !5
  %85 = load ptr, ptr %18, align 8, !tbaa !5
  %86 = load ptr, ptr %17, align 8, !tbaa !5
  %87 = ptrtoint ptr %85 to i64
  %88 = ptrtoint ptr %86 to i64
  %89 = sub i64 %87, %88
  %90 = icmp ult i64 %89, 1
  br i1 %90, label %91, label %92

91:                                               ; preds = %78
  store i64 0, ptr %8, align 8
  store i32 1, ptr %19, align 4
  br label %307

92:                                               ; preds = %78
  %93 = load i32, ptr %15, align 4, !tbaa !11
  %94 = or i32 160, %93
  %95 = trunc i32 %94 to i8
  %96 = load ptr, ptr %17, align 8, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %96, i32 1
  store ptr %97, ptr %17, align 8, !tbaa !5
  store i8 %95, ptr %96, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 256, ptr %20) #7
  call void @llvm.memset.p0.i64(ptr align 16 %20, i8 0, i64 256, i1 false)
  %98 = load i64, ptr %12, align 8, !tbaa !9
  %99 = icmp ugt i64 %98, 0
  br i1 %99, label %100, label %104

100:                                              ; preds = %92
  %101 = getelementptr inbounds [256 x i8], ptr %20, i64 0, i64 0
  %102 = load ptr, ptr %16, align 8, !tbaa !5
  %103 = load i64, ptr %13, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %101, ptr align 1 %102, i64 %103, i1 false)
  br label %104

104:                                              ; preds = %100, %92
  call void @llvm.lifetime.start.p0(i64 256, ptr %21) #7
  call void @llvm.memset.p0.i64(ptr align 16 %21, i8 0, i64 256, i1 false)
  %105 = getelementptr inbounds [256 x i8], ptr %21, i64 0, i64 0
  %106 = getelementptr inbounds [256 x i8], ptr %20, i64 0, i64 0
  %107 = load i64, ptr %13, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %105, ptr align 16 %106, i64 %107, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  %108 = load i64, ptr %13, align 8, !tbaa !9
  %109 = call noundef i64 @_ZN7meshoptL18getVertexBlockSizeEm(i64 noundef %108)
  store i64 %109, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 64, ptr %23) #7
  call void @llvm.memset.p0.i64(ptr align 16 %23, i8 0, i64 64, i1 false)
  %110 = load i32, ptr %15, align 4, !tbaa !11
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %112, label %174

112:                                              ; preds = %104
  %113 = load i32, ptr %14, align 4, !tbaa !11
  %114 = icmp sgt i32 %113, 1
  br i1 %114, label %115, label %174

115:                                              ; preds = %112
  %116 = load i64, ptr %12, align 8, !tbaa !9
  %117 = icmp ugt i64 %116, 1
  br i1 %117, label %118, label %174

118:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  store i64 0, ptr %24, align 8, !tbaa !9
  br label %119

119:                                              ; preds = %170, %118
  %120 = load i64, ptr %24, align 8, !tbaa !9
  %121 = load i64, ptr %13, align 8, !tbaa !9
  %122 = icmp ult i64 %120, %121
  br i1 %122, label %124, label %123

123:                                              ; preds = %119
  store i32 2, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  br label %173

124:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  %125 = load i32, ptr %14, align 4, !tbaa !11
  %126 = icmp sge i32 %125, 3
  br i1 %126, label %127, label %133

127:                                              ; preds = %124
  %128 = load ptr, ptr %16, align 8, !tbaa !5
  %129 = load i64, ptr %12, align 8, !tbaa !9
  %130 = load i64, ptr %13, align 8, !tbaa !9
  %131 = load i64, ptr %24, align 8, !tbaa !9
  %132 = call noundef i32 @_ZN7meshoptL14estimateRotateEPKhmmmm(ptr noundef %128, i64 noundef %129, i64 noundef %130, i64 noundef %131, i64 noundef 16)
  br label %134

133:                                              ; preds = %124
  br label %134

134:                                              ; preds = %133, %127
  %135 = phi i32 [ %132, %127 ], [ 0, %133 ]
  store i32 %135, ptr %25, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  %136 = load ptr, ptr %16, align 8, !tbaa !5
  %137 = load i64, ptr %12, align 8, !tbaa !9
  %138 = load i64, ptr %13, align 8, !tbaa !9
  %139 = load i64, ptr %24, align 8, !tbaa !9
  %140 = load i64, ptr %22, align 8, !tbaa !9
  %141 = load i32, ptr %14, align 4, !tbaa !11
  %142 = icmp sge i32 %141, 3
  %143 = zext i1 %142 to i64
  %144 = select i1 %142, i32 3, i32 2
  %145 = load i32, ptr %25, align 4, !tbaa !11
  %146 = call noundef i32 @_ZN7meshoptL15estimateChannelEPKhmmmmmii(ptr noundef %136, i64 noundef %137, i64 noundef %138, i64 noundef %139, i64 noundef %140, i64 noundef 3, i32 noundef %144, i32 noundef %145)
  store i32 %146, ptr %26, align 4, !tbaa !11
  %147 = load i32, ptr %26, align 4, !tbaa !11
  %148 = icmp ult i32 %147, 2
  br i1 %148, label %159, label %149

149:                                              ; preds = %134
  %150 = load i32, ptr %26, align 4, !tbaa !11
  %151 = and i32 %150, 3
  %152 = icmp eq i32 %151, 2
  br i1 %152, label %153, label %157

153:                                              ; preds = %149
  %154 = load i32, ptr %26, align 4, !tbaa !11
  %155 = ashr i32 %154, 4
  %156 = icmp ult i32 %155, 8
  br label %157

157:                                              ; preds = %153, %149
  %158 = phi i1 [ false, %149 ], [ %156, %153 ]
  br label %159

159:                                              ; preds = %157, %134
  %160 = phi i1 [ true, %134 ], [ %158, %157 ]
  br i1 %160, label %161, label %162

161:                                              ; preds = %159
  br label %164

162:                                              ; preds = %159
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 1687, ptr noundef @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #6
  unreachable

163:                                              ; No predecessors!
  br label %164

164:                                              ; preds = %163, %161
  %165 = load i32, ptr %26, align 4, !tbaa !11
  %166 = trunc i32 %165 to i8
  %167 = load i64, ptr %24, align 8, !tbaa !9
  %168 = udiv i64 %167, 4
  %169 = getelementptr inbounds [64 x i8], ptr %23, i64 0, i64 %168
  store i8 %166, ptr %169, align 1, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  br label %170

170:                                              ; preds = %164
  %171 = load i64, ptr %24, align 8, !tbaa !9
  %172 = add i64 %171, 4
  store i64 %172, ptr %24, align 8, !tbaa !9
  br label %119, !llvm.loop !14

173:                                              ; preds = %123
  br label %174

174:                                              ; preds = %173, %115, %112, %104
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #7
  store i64 0, ptr %27, align 8, !tbaa !9
  br label %175

175:                                              ; preds = %216, %174
  %176 = load i64, ptr %27, align 8, !tbaa !9
  %177 = load i64, ptr %12, align 8, !tbaa !9
  %178 = icmp ult i64 %176, %177
  br i1 %178, label %179, label %217

179:                                              ; preds = %175
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #7
  %180 = load i64, ptr %27, align 8, !tbaa !9
  %181 = load i64, ptr %22, align 8, !tbaa !9
  %182 = add i64 %180, %181
  %183 = load i64, ptr %12, align 8, !tbaa !9
  %184 = icmp ult i64 %182, %183
  br i1 %184, label %185, label %187

185:                                              ; preds = %179
  %186 = load i64, ptr %22, align 8, !tbaa !9
  br label %191

187:                                              ; preds = %179
  %188 = load i64, ptr %12, align 8, !tbaa !9
  %189 = load i64, ptr %27, align 8, !tbaa !9
  %190 = sub i64 %188, %189
  br label %191

191:                                              ; preds = %187, %185
  %192 = phi i64 [ %186, %185 ], [ %190, %187 ]
  store i64 %192, ptr %28, align 8, !tbaa !9
  %193 = load ptr, ptr %17, align 8, !tbaa !5
  %194 = load ptr, ptr %18, align 8, !tbaa !5
  %195 = load ptr, ptr %16, align 8, !tbaa !5
  %196 = load i64, ptr %27, align 8, !tbaa !9
  %197 = load i64, ptr %13, align 8, !tbaa !9
  %198 = mul i64 %196, %197
  %199 = getelementptr inbounds i8, ptr %195, i64 %198
  %200 = load i64, ptr %28, align 8, !tbaa !9
  %201 = load i64, ptr %13, align 8, !tbaa !9
  %202 = getelementptr inbounds [256 x i8], ptr %21, i64 0, i64 0
  %203 = getelementptr inbounds [64 x i8], ptr %23, i64 0, i64 0
  %204 = load i32, ptr %15, align 4, !tbaa !11
  %205 = load i32, ptr %14, align 4, !tbaa !11
  %206 = call noundef ptr @_ZN7meshoptL17encodeVertexBlockEPhS0_PKhmmS0_S2_ii(ptr noundef %193, ptr noundef %194, ptr noundef %199, i64 noundef %200, i64 noundef %201, ptr noundef %202, ptr noundef %203, i32 noundef %204, i32 noundef %205)
  store ptr %206, ptr %17, align 8, !tbaa !5
  %207 = load ptr, ptr %17, align 8, !tbaa !5
  %208 = icmp ne ptr %207, null
  br i1 %208, label %210, label %209

209:                                              ; preds = %191
  store i64 0, ptr %8, align 8
  store i32 1, ptr %19, align 4
  br label %214

210:                                              ; preds = %191
  %211 = load i64, ptr %28, align 8, !tbaa !9
  %212 = load i64, ptr %27, align 8, !tbaa !9
  %213 = add i64 %212, %211
  store i64 %213, ptr %27, align 8, !tbaa !9
  store i32 0, ptr %19, align 4
  br label %214

214:                                              ; preds = %210, %209
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #7
  %215 = load i32, ptr %19, align 4
  switch i32 %215, label %306 [
    i32 0, label %216
  ]

216:                                              ; preds = %214
  br label %175, !llvm.loop !16

217:                                              ; preds = %175
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #7
  %218 = load i64, ptr %13, align 8, !tbaa !9
  %219 = load i32, ptr %15, align 4, !tbaa !11
  %220 = icmp eq i32 %219, 0
  br i1 %220, label %221, label %222

221:                                              ; preds = %217
  br label %225

222:                                              ; preds = %217
  %223 = load i64, ptr %13, align 8, !tbaa !9
  %224 = udiv i64 %223, 4
  br label %225

225:                                              ; preds = %222, %221
  %226 = phi i64 [ 0, %221 ], [ %224, %222 ]
  %227 = add i64 %218, %226
  store i64 %227, ptr %29, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #7
  %228 = load i32, ptr %15, align 4, !tbaa !11
  %229 = icmp eq i32 %228, 0
  %230 = zext i1 %229 to i64
  %231 = select i1 %229, i64 32, i64 24
  store i64 %231, ptr %30, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #7
  %232 = load i64, ptr %29, align 8, !tbaa !9
  %233 = load i64, ptr %30, align 8, !tbaa !9
  %234 = icmp ult i64 %232, %233
  br i1 %234, label %235, label %237

235:                                              ; preds = %225
  %236 = load i64, ptr %30, align 8, !tbaa !9
  br label %239

237:                                              ; preds = %225
  %238 = load i64, ptr %29, align 8, !tbaa !9
  br label %239

239:                                              ; preds = %237, %235
  %240 = phi i64 [ %236, %235 ], [ %238, %237 ]
  store i64 %240, ptr %31, align 8, !tbaa !9
  %241 = load ptr, ptr %18, align 8, !tbaa !5
  %242 = load ptr, ptr %17, align 8, !tbaa !5
  %243 = ptrtoint ptr %241 to i64
  %244 = ptrtoint ptr %242 to i64
  %245 = sub i64 %243, %244
  %246 = load i64, ptr %31, align 8, !tbaa !9
  %247 = icmp ult i64 %245, %246
  br i1 %247, label %248, label %249

248:                                              ; preds = %239
  store i64 0, ptr %8, align 8
  store i32 1, ptr %19, align 4
  br label %305

249:                                              ; preds = %239
  %250 = load i64, ptr %29, align 8, !tbaa !9
  %251 = load i64, ptr %31, align 8, !tbaa !9
  %252 = icmp ult i64 %250, %251
  br i1 %252, label %253, label %263

253:                                              ; preds = %249
  %254 = load ptr, ptr %17, align 8, !tbaa !5
  %255 = load i64, ptr %31, align 8, !tbaa !9
  %256 = load i64, ptr %29, align 8, !tbaa !9
  %257 = sub i64 %255, %256
  call void @llvm.memset.p0.i64(ptr align 1 %254, i8 0, i64 %257, i1 false)
  %258 = load i64, ptr %31, align 8, !tbaa !9
  %259 = load i64, ptr %29, align 8, !tbaa !9
  %260 = sub i64 %258, %259
  %261 = load ptr, ptr %17, align 8, !tbaa !5
  %262 = getelementptr inbounds i8, ptr %261, i64 %260
  store ptr %262, ptr %17, align 8, !tbaa !5
  br label %263

263:                                              ; preds = %253, %249
  %264 = load ptr, ptr %17, align 8, !tbaa !5
  %265 = getelementptr inbounds [256 x i8], ptr %20, i64 0, i64 0
  %266 = load i64, ptr %13, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %264, ptr align 16 %265, i64 %266, i1 false)
  %267 = load i64, ptr %13, align 8, !tbaa !9
  %268 = load ptr, ptr %17, align 8, !tbaa !5
  %269 = getelementptr inbounds i8, ptr %268, i64 %267
  store ptr %269, ptr %17, align 8, !tbaa !5
  %270 = load i32, ptr %15, align 4, !tbaa !11
  %271 = icmp ne i32 %270, 0
  br i1 %271, label %272, label %281

272:                                              ; preds = %263
  %273 = load ptr, ptr %17, align 8, !tbaa !5
  %274 = getelementptr inbounds [64 x i8], ptr %23, i64 0, i64 0
  %275 = load i64, ptr %13, align 8, !tbaa !9
  %276 = udiv i64 %275, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %273, ptr align 16 %274, i64 %276, i1 false)
  %277 = load i64, ptr %13, align 8, !tbaa !9
  %278 = udiv i64 %277, 4
  %279 = load ptr, ptr %17, align 8, !tbaa !5
  %280 = getelementptr inbounds i8, ptr %279, i64 %278
  store ptr %280, ptr %17, align 8, !tbaa !5
  br label %281

281:                                              ; preds = %272, %263
  %282 = load ptr, ptr %17, align 8, !tbaa !5
  %283 = load ptr, ptr %9, align 8, !tbaa !5
  %284 = load i64, ptr %29, align 8, !tbaa !9
  %285 = getelementptr inbounds i8, ptr %283, i64 %284
  %286 = icmp uge ptr %282, %285
  br i1 %286, label %287, label %288

287:                                              ; preds = %281
  br label %290

288:                                              ; preds = %281
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.2, i32 noundef 1726, ptr noundef @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #6
  unreachable

289:                                              ; No predecessors!
  br label %290

290:                                              ; preds = %289, %287
  %291 = load ptr, ptr %17, align 8, !tbaa !5
  %292 = load ptr, ptr %9, align 8, !tbaa !5
  %293 = load i64, ptr %10, align 8, !tbaa !9
  %294 = getelementptr inbounds i8, ptr %292, i64 %293
  %295 = icmp ule ptr %291, %294
  br i1 %295, label %296, label %297

296:                                              ; preds = %290
  br label %299

297:                                              ; preds = %290
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 1727, ptr noundef @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #6
  unreachable

298:                                              ; No predecessors!
  br label %299

299:                                              ; preds = %298, %296
  %300 = load ptr, ptr %17, align 8, !tbaa !5
  %301 = load ptr, ptr %9, align 8, !tbaa !5
  %302 = ptrtoint ptr %300 to i64
  %303 = ptrtoint ptr %301 to i64
  %304 = sub i64 %302, %303
  store i64 %304, ptr %8, align 8
  store i32 1, ptr %19, align 4
  br label %305

305:                                              ; preds = %299, %248
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #7
  br label %306

306:                                              ; preds = %305, %214
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #7
  call void @llvm.lifetime.end.p0(i64 64, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 256, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 256, ptr %20) #7
  br label %307

307:                                              ; preds = %306, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  %308 = load i64, ptr %8, align 8
  ret i64 %308
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN7meshoptL18getVertexBlockSizeEm(i64 noundef) #5

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN7meshoptL14estimateRotateEPKhmmmm(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN7meshoptL15estimateChannelEPKhmmmmmii(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZN7meshoptL17encodeVertexBlockEPhS0_PKhmmS0_S2_ii(ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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"

@.str = external hidden unnamed_addr constant [38 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel = external hidden unnamed_addr constant [104 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [57 x i8], align 1
@_ZN7meshoptL20gEncodeVertexVersionE = external hidden local_unnamed_addr global i32, align 4
@.str.6 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local i64 @meshopt_encodeVertexBufferLevel(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = alloca [256 x i8], align 16
  %9 = alloca [256 x i8], align 16
  %10 = alloca [64 x i8], align 16
  %11 = add i64 %4, -1
  %12 = icmp ult i64 %11, 256
  br i1 %12, label %14, label %13

13:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, i32 noundef 1650, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #7
  unreachable

14:                                               ; preds = %7
  %15 = and i64 %4, 3
  %16 = icmp eq i64 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 1651, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #7
  unreachable

18:                                               ; preds = %14
  %19 = icmp ult i32 %5, 10
  br i1 %19, label %21, label %20

20:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.2, i32 noundef 1652, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #7
  unreachable

21:                                               ; preds = %18
  %22 = icmp slt i32 %6, 2
  br i1 %22, label %24, label %23

23:                                               ; preds = %21
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, i32 noundef 1653, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #7
  unreachable

24:                                               ; preds = %21
  %25 = icmp slt i32 %6, 0
  %26 = load i32, ptr @_ZN7meshoptL20gEncodeVertexVersionE, align 4
  %27 = select i1 %25, i32 %26, i32 %6
  %28 = getelementptr inbounds i8, ptr %0, i64 %1
  %29 = ptrtoint ptr %28 to i64
  %30 = ptrtoint ptr %0 to i64
  %31 = icmp eq i64 %1, 0
  br i1 %31, label %100, label %32

32:                                               ; preds = %24
  %33 = trunc i32 %27 to i8
  %34 = or i8 %33, -96
  %35 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %34, ptr %0, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %8)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %8, i8 0, i64 256, i1 false)
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %8, ptr align 1 %2, i64 %4, i1 false)
  br label %37

37:                                               ; preds = %36, %32
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %9) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %9, i8 0, i64 256, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %9, ptr nonnull align 16 %8, i64 %4, i1 false)
  %38 = tail call noundef i64 @_ZN7meshoptL18getVertexBlockSizeEm(i64 noundef %4)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %10) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %10, i8 0, i64 64, i1 false)
  %39 = icmp ne i32 %27, 0
  %40 = icmp ugt i32 %5, 1
  %41 = icmp ugt i64 %3, 1
  %42 = and i1 %41, %40
  %or.cond126 = and i1 %42, %39
  br i1 %or.cond126, label %.lr.ph, label %.loopexit123.preheader

.lr.ph:                                           ; preds = %37
  %43 = icmp ugt i32 %5, 2
  br i1 %43, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.critedge.us
  %.0111125.us = phi i64 [ %52, %.critedge.us ], [ 0, %.lr.ph ]
  %44 = tail call noundef i32 @_ZN7meshoptL14estimateRotateEPKhmmmm(ptr noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %.0111125.us, i64 noundef 16)
  %45 = tail call noundef i32 @_ZN7meshoptL15estimateChannelEPKhmmmmmii(ptr noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %.0111125.us, i64 noundef %38, i64 noundef 3, i32 noundef 3, i32 noundef %44)
  %46 = icmp ult i32 %45, 2
  %47 = and i32 %45, -125
  %48 = icmp eq i32 %47, 2
  %or.cond.us = or i1 %46, %48
  br i1 %or.cond.us, label %.critedge.us, label %.split.us

.critedge.us:                                     ; preds = %.lr.ph.split.us
  %49 = trunc nuw i32 %45 to i8
  %50 = lshr exact i64 %.0111125.us, 2
  %51 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 %50
  store i8 %49, ptr %51, align 1, !tbaa !5
  %52 = add nuw nsw i64 %.0111125.us, 4
  %53 = icmp ult i64 %52, %4
  br i1 %53, label %.lr.ph.split.us, label %.loopexit123.preheader, !llvm.loop !8

.lr.ph.split:                                     ; preds = %.lr.ph, %.critedge
  %.0111125 = phi i64 [ %61, %.critedge ], [ 0, %.lr.ph ]
  %54 = tail call noundef i32 @_ZN7meshoptL15estimateChannelEPKhmmmmmii(ptr noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %.0111125, i64 noundef %38, i64 noundef 3, i32 noundef 2, i32 noundef 0)
  %55 = icmp ult i32 %54, 2
  %56 = and i32 %54, -125
  %57 = icmp eq i32 %56, 2
  %or.cond = or i1 %55, %57
  br i1 %or.cond, label %.critedge, label %.split.us

.split.us:                                        ; preds = %.lr.ph.split, %.lr.ph.split.us
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 1687, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #7
  unreachable

.critedge:                                        ; preds = %.lr.ph.split
  %58 = trunc nuw i32 %54 to i8
  %59 = lshr exact i64 %.0111125, 2
  %60 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 %59
  store i8 %58, ptr %60, align 1, !tbaa !5
  %61 = add nuw nsw i64 %.0111125, 4
  %62 = icmp ult i64 %61, %4
  br i1 %62, label %.lr.ph.split, label %.loopexit123.preheader, !llvm.loop !8

.loopexit123.preheader:                           ; preds = %.critedge, %.critedge.us, %37
  br label %.loopexit123

.loopexit123:                                     ; preds = %.loopexit123.preheader, %64
  %.0109 = phi i64 [ %72, %64 ], [ 0, %.loopexit123.preheader ]
  %.0105 = phi ptr [ %71, %64 ], [ %35, %.loopexit123.preheader ]
  %63 = icmp ult i64 %.0109, %3
  br i1 %63, label %64, label %73

64:                                               ; preds = %.loopexit123
  %65 = add i64 %.0109, %38
  %66 = icmp ult i64 %65, %3
  %67 = sub i64 %3, %.0109
  %68 = select i1 %66, i64 %38, i64 %67
  %69 = mul i64 %.0109, %4
  %70 = getelementptr inbounds i8, ptr %2, i64 %69
  %71 = call noundef ptr @_ZN7meshoptL17encodeVertexBlockEPhS0_PKhmmS0_S2_ii(ptr noundef nonnull %.0105, ptr noundef nonnull %28, ptr noundef %70, i64 noundef %68, i64 noundef %4, ptr noundef nonnull %9, ptr noundef nonnull %10, i32 noundef %27, i32 noundef %5)
  %.not121.not = icmp eq ptr %71, null
  %72 = add i64 %68, %.0109
  br i1 %.not121.not, label %.loopexit, label %.loopexit123, !llvm.loop !10

73:                                               ; preds = %.loopexit123
  %74 = icmp eq i32 %27, 0
  %75 = lshr exact i64 %4, 2
  %76 = select i1 %74, i64 0, i64 %75
  %77 = add nuw nsw i64 %76, %4
  %78 = select i1 %74, i64 32, i64 24
  %79 = call i64 @llvm.umax.i64(i64 %77, i64 %78)
  %80 = ptrtoint ptr %.0105 to i64
  %81 = sub i64 %29, %80
  %82 = icmp ult i64 %81, %79
  br i1 %82, label %.loopexit, label %83

83:                                               ; preds = %73
  %84 = icmp ult i64 %77, %78
  br i1 %84, label %85, label %88

85:                                               ; preds = %83
  %86 = sub nsw i64 %79, %77
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %.0105, i8 0, i64 %86, i1 false)
  %87 = getelementptr inbounds i8, ptr %.0105, i64 %86
  br label %88

88:                                               ; preds = %85, %83
  %.1106 = phi ptr [ %87, %85 ], [ %.0105, %83 ]
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.1106, ptr nonnull align 16 %8, i64 %4, i1 false)
  %89 = getelementptr inbounds i8, ptr %.1106, i64 %4
  br i1 %39, label %90, label %92

90:                                               ; preds = %88
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %89, ptr nonnull align 16 %10, i64 %75, i1 false)
  %91 = getelementptr inbounds i8, ptr %89, i64 %75
  br label %92

92:                                               ; preds = %90, %88
  %.2107 = phi ptr [ %91, %90 ], [ %89, %88 ]
  %93 = getelementptr inbounds i8, ptr %0, i64 %77
  %.not119 = icmp ult ptr %.2107, %93
  br i1 %.not119, label %94, label %95

94:                                               ; preds = %92
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.2, i32 noundef 1726, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #7
  unreachable

95:                                               ; preds = %92
  %.not120 = icmp ugt ptr %.2107, %28
  br i1 %.not120, label %96, label %97

96:                                               ; preds = %95
  call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 1727, ptr noundef nonnull @__PRETTY_FUNCTION__.meshopt_encodeVertexBufferLevel) #7
  unreachable

97:                                               ; preds = %95
  %98 = ptrtoint ptr %.2107 to i64
  %99 = sub i64 %98, %30
  br label %.loopexit

.loopexit:                                        ; preds = %64, %97, %73
  %.3 = phi i64 [ %99, %97 ], [ 0, %73 ], [ 0, %64 ]
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %10) #8
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %9) #8
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %8)
  br label %100

100:                                              ; preds = %24, %.loopexit
  %.4 = phi i64 [ %.3, %.loopexit ], [ 0, %24 ]
  ret i64 %.4
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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 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: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN7meshoptL18getVertexBlockSizeEm(i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN7meshoptL14estimateRotateEPKhmmmm(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN7meshoptL15estimateChannelEPKhmmmmmii(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZN7meshoptL17encodeVertexBlockEPhS0_PKhmmS0_S2_ii(ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

attributes #0 = { mustprogress 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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { noreturn nounwind }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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