; LLVM IR from paintdream/DontStarveLuaJIT :: src/luajit/src (lj_meta)

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

%union.TValue = type { i64 }
%struct.anon.1 = type { %union.anon.2, i32 }
%union.anon.2 = type { %struct.GCRef }
%struct.GCRef = type { i32 }
%struct.GCtab = type { %struct.GCRef, i8, i8, i8, i8, %struct.MRef, %struct.GCRef, %struct.GCRef, ptr, %struct.MRef, i32, i32 }
%struct.MRef = type { i32 }
%struct.GChead = type { %struct.GCRef, i8, i8, i8, i8, %struct.GCRef, %struct.GCRef, %struct.GCRef }
%struct.lua_State = type { %union.anon }
%union.anon = type { %struct.anon, [320 x i8] }
%struct.anon = type { %struct.GCRef, i8, i8, i8, i8, %struct.MRef, %struct.GCRef, ptr, ptr, %struct.MRef, %struct.MRef, %struct.GCRef, %struct.GCRef, ptr, i32 }
%struct.global_State = type { ptr, i32, i32, ptr, ptr, %struct.GCState, i32, %struct.SBuf, %struct.GCstr, i8, i8, i8, i8, %struct.GCRef, %union.TValue, %union.TValue, %union.TValue, %struct.Node, %struct.GCupval, i32, i32, ptr, ptr, ptr, i32, i32, %struct.GCRef, %struct.MRef, %struct.MRef, [38 x %struct.GCRef] }
%struct.GCState = type { i32, i32, i8, i8, i8, i8, i32, %struct.GCRef, %struct.MRef, %struct.GCRef, %struct.GCRef, %struct.GCRef, %struct.GCRef, i32, i32, i32, i32 }
%struct.SBuf = type { %struct.MRef, %struct.MRef, %struct.MRef, %struct.MRef }
%struct.GCstr = type { %struct.GCRef, i8, i8, i8, i8, i32, i32 }
%struct.Node = type { %union.TValue, %union.TValue, %struct.MRef, %struct.MRef }
%struct.GCupval = type { %struct.GCRef, i8, i8, i8, i8, %union.anon.0, %struct.MRef, i32 }
%union.anon.0 = type { %union.TValue }

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

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @copyTV(ptr noundef, ptr noundef, ptr noundef) #2

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

declare hidden ptr @lj_tab_get(ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: noreturn
declare hidden void @lj_err_optype(ptr noundef, ptr noundef, i32 noundef) #5

; Function Attrs: nounwind uwtable
declare hidden ptr @mmcall(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: noreturn
declare hidden void @lj_err_msg(ptr noundef, i32 noundef) #5

; Function Attrs: nounwind uwtable
define hidden ptr @lj_meta_tset(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %union.TValue, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %224, %3
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 100
  br i1 %16, label %17, label %227

17:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.anon.1, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = icmp eq i32 %20, -12
  %22 = xor i1 %21, true
  %23 = xor i1 %22, true
  %24 = zext i1 %23 to i32
  %25 = sext i32 %24 to i64
  %26 = call i64 @llvm.expect.i64(i64 %25, i64 1)
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %28, label %193

28:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.anon.1, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.GCRef, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = zext i32 %32 to i64
  %34 = inttoptr i64 %33 to ptr
  store ptr %34, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = call ptr @lj_tab_get(ptr noundef %35, ptr noundef %36, ptr noundef %37)
  store ptr %38, ptr %12, align 8, !tbaa !5
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.anon.1, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %42 = icmp eq i32 %41, -1
  %43 = xor i1 %42, true
  %44 = xor i1 %43, true
  %45 = xor i1 %44, true
  %46 = zext i1 %45 to i32
  %47 = sext i32 %46 to i64
  %48 = call i64 @llvm.expect.i64(i64 %47, i64 1)
  %49 = icmp ne i64 %48, 0
  br i1 %49, label %50, label %76

50:                                               ; preds = %28
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.GCtab, ptr %51, i32 0, i32 3
  store i8 0, ptr %52, align 2, !tbaa !12
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.GChead, ptr %53, i32 0, i32 1
  %55 = load i8, ptr %54, align 4, !tbaa !11
  %56 = zext i8 %55 to i32
  %57 = and i32 %56, 4
  %58 = icmp ne i32 %57, 0
  %59 = xor i1 %58, true
  %60 = xor i1 %59, true
  %61 = zext i1 %60 to i32
  %62 = sext i32 %61 to i64
  %63 = call i64 @llvm.expect.i64(i64 %62, i64 0)
  %64 = icmp ne i64 %63, 0
  br i1 %64, label %65, label %74

65:                                               ; preds = %50
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.lua_State, ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds %struct.anon, ptr %67, i32 0, i32 5
  %69 = getelementptr inbounds %struct.MRef, ptr %68, i32 0, i32 0
  %70 = load i32, ptr %69, align 8, !tbaa !11
  %71 = zext i32 %70 to i64
  %72 = inttoptr i64 %71 to ptr
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  call void @lj_gc_barrierback(ptr noundef %72, ptr noundef %73)
  br label %74

74:                                               ; preds = %65, %50
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %75, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %190

76:                                               ; preds = %28
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.GCtab, ptr %77, i32 0, i32 7
  %79 = getelementptr inbounds %struct.GCRef, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !16
  %81 = zext i32 %80 to i64
  %82 = inttoptr i64 %81 to ptr
  %83 = icmp eq ptr %82, null
  br i1 %83, label %84, label %85

84:                                               ; preds = %76
  br label %121

85:                                               ; preds = %76
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.GCtab, ptr %86, i32 0, i32 7
  %88 = getelementptr inbounds %struct.GCRef, ptr %87, i32 0, i32 0
  %89 = load i32, ptr %88, align 8, !tbaa !16
  %90 = zext i32 %89 to i64
  %91 = inttoptr i64 %90 to ptr
  %92 = getelementptr inbounds %struct.GCtab, ptr %91, i32 0, i32 3
  %93 = load i8, ptr %92, align 2, !tbaa !11
  %94 = zext i8 %93 to i32
  %95 = and i32 %94, 2
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %98

97:                                               ; preds = %85
  br label %119

98:                                               ; preds = %85
  %99 = load ptr, ptr %11, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.GCtab, ptr %99, i32 0, i32 7
  %101 = getelementptr inbounds %struct.GCRef, ptr %100, i32 0, i32 0
  %102 = load i32, ptr %101, align 8, !tbaa !16
  %103 = zext i32 %102 to i64
  %104 = inttoptr i64 %103 to ptr
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.lua_State, ptr %105, i32 0, i32 0
  %107 = getelementptr inbounds %struct.anon, ptr %106, i32 0, i32 5
  %108 = getelementptr inbounds %struct.MRef, ptr %107, i32 0, i32 0
  %109 = load i32, ptr %108, align 8, !tbaa !11
  %110 = zext i32 %109 to i64
  %111 = inttoptr i64 %110 to ptr
  %112 = getelementptr inbounds %struct.global_State, ptr %111, i32 0, i32 29
  %113 = getelementptr inbounds [38 x %struct.GCRef], ptr %112, i64 0, i64 1
  %114 = getelementptr inbounds %struct.GCRef, ptr %113, i32 0, i32 0
  %115 = load i32, ptr %114, align 4, !tbaa !17
  %116 = zext i32 %115 to i64
  %117 = inttoptr i64 %116 to ptr
  %118 = call ptr @lj_meta_cache(ptr noundef %104, i32 noundef 1, ptr noundef %117)
  br label %119

119:                                              ; preds = %98, %97
  %120 = phi ptr [ null, %97 ], [ %118, %98 ]
  br label %121

121:                                              ; preds = %119, %84
  %122 = phi ptr [ null, %84 ], [ %120, %119 ]
  store ptr %122, ptr %10, align 8, !tbaa !5
  %123 = icmp ne ptr %122, null
  br i1 %123, label %188, label %124

124:                                              ; preds = %121
  %125 = load ptr, ptr %11, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.GCtab, ptr %125, i32 0, i32 3
  store i8 0, ptr %126, align 2, !tbaa !12
  %127 = load ptr, ptr %11, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.GChead, ptr %127, i32 0, i32 1
  %129 = load i8, ptr %128, align 4, !tbaa !11
  %130 = zext i8 %129 to i32
  %131 = and i32 %130, 4
  %132 = icmp ne i32 %131, 0
  %133 = xor i1 %132, true
  %134 = xor i1 %133, true
  %135 = zext i1 %134 to i32
  %136 = sext i32 %135 to i64
  %137 = call i64 @llvm.expect.i64(i64 %136, i64 0)
  %138 = icmp ne i64 %137, 0
  br i1 %138, label %139, label %148

139:                                              ; preds = %124
  %140 = load ptr, ptr %5, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.lua_State, ptr %140, i32 0, i32 0
  %142 = getelementptr inbounds %struct.anon, ptr %141, i32 0, i32 5
  %143 = getelementptr inbounds %struct.MRef, ptr %142, i32 0, i32 0
  %144 = load i32, ptr %143, align 8, !tbaa !11
  %145 = zext i32 %144 to i64
  %146 = inttoptr i64 %145 to ptr
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  call void @lj_gc_barrierback(ptr noundef %146, ptr noundef %147)
  br label %148

148:                                              ; preds = %139, %124
  %149 = load ptr, ptr %12, align 8, !tbaa !5
  %150 = load ptr, ptr %5, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.lua_State, ptr %150, i32 0, i32 0
  %152 = getelementptr inbounds %struct.anon, ptr %151, i32 0, i32 5
  %153 = getelementptr inbounds %struct.MRef, ptr %152, i32 0, i32 0
  %154 = load i32, ptr %153, align 8, !tbaa !11
  %155 = zext i32 %154 to i64
  %156 = inttoptr i64 %155 to ptr
  %157 = getelementptr inbounds %struct.global_State, ptr %156, i32 0, i32 17
  %158 = getelementptr inbounds %struct.Node, ptr %157, i32 0, i32 0
  %159 = icmp ne ptr %149, %158
  br i1 %159, label %160, label %162

160:                                              ; preds = %148
  %161 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %161, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %190

162:                                              ; preds = %148
  %163 = load ptr, ptr %7, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.anon.1, ptr %163, i32 0, i32 1
  %165 = load i32, ptr %164, align 4, !tbaa !11
  %166 = icmp eq i32 %165, -1
  br i1 %166, label %167, label %169

167:                                              ; preds = %162
  %168 = load ptr, ptr %5, align 8, !tbaa !5
  call void @lj_err_msg(ptr noundef %168, i32 noundef 173) #7
  unreachable

169:                                              ; preds = %162
  %170 = load ptr, ptr %7, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.anon.1, ptr %170, i32 0, i32 1
  %172 = load i32, ptr %171, align 4, !tbaa !11
  %173 = icmp ult i32 %172, -65537
  br i1 %173, label %174, label %182

174:                                              ; preds = %169
  %175 = load ptr, ptr %7, align 8, !tbaa !5
  %176 = load double, ptr %175, align 8, !tbaa !11
  %177 = load ptr, ptr %7, align 8, !tbaa !5
  %178 = load double, ptr %177, align 8, !tbaa !11
  %179 = fcmp une double %176, %178
  br i1 %179, label %180, label %182

180:                                              ; preds = %174
  %181 = load ptr, ptr %5, align 8, !tbaa !5
  call void @lj_err_msg(ptr noundef %181, i32 noundef 154) #7
  unreachable

182:                                              ; preds = %174, %169
  br label %183

183:                                              ; preds = %182
  %184 = load ptr, ptr %5, align 8, !tbaa !5
  %185 = load ptr, ptr %11, align 8, !tbaa !5
  %186 = load ptr, ptr %7, align 8, !tbaa !5
  %187 = call ptr @lj_tab_newkey(ptr noundef %184, ptr noundef %185, ptr noundef %186)
  store ptr %187, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %190

188:                                              ; preds = %121
  br label %189

189:                                              ; preds = %188
  store i32 0, ptr %13, align 4
  br label %190

190:                                              ; preds = %189, %183, %160, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %191 = load i32, ptr %13, align 4
  switch i32 %191, label %221 [
    i32 0, label %192
  ]

192:                                              ; preds = %190
  br label %204

193:                                              ; preds = %17
  %194 = load ptr, ptr %5, align 8, !tbaa !5
  %195 = load ptr, ptr %6, align 8, !tbaa !5
  %196 = call ptr @lj_meta_lookup(ptr noundef %194, ptr noundef %195, i32 noundef 1)
  store ptr %196, ptr %10, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.anon.1, ptr %196, i32 0, i32 1
  %198 = load i32, ptr %197, align 4, !tbaa !11
  %199 = icmp eq i32 %198, -1
  br i1 %199, label %200, label %203

200:                                              ; preds = %193
  %201 = load ptr, ptr %5, align 8, !tbaa !5
  %202 = load ptr, ptr %6, align 8, !tbaa !5
  call void @lj_err_optype(ptr noundef %201, ptr noundef %202, i32 noundef 403) #7
  unreachable

203:                                              ; preds = %193
  br label %204

204:                                              ; preds = %203, %192
  %205 = load ptr, ptr %10, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.anon.1, ptr %205, i32 0, i32 1
  %207 = load i32, ptr %206, align 4, !tbaa !11
  %208 = icmp eq i32 %207, -9
  br i1 %208, label %209, label %218

209:                                              ; preds = %204
  %210 = load ptr, ptr %5, align 8, !tbaa !5
  %211 = load ptr, ptr %10, align 8, !tbaa !5
  %212 = load ptr, ptr %6, align 8, !tbaa !5
  %213 = load ptr, ptr %7, align 8, !tbaa !5
  %214 = call ptr @mmcall(ptr noundef %210, ptr noundef @lj_cont_nop, ptr noundef %211, ptr noundef %212, ptr noundef %213)
  %215 = load ptr, ptr %5, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.lua_State, ptr %215, i32 0, i32 0
  %217 = getelementptr inbounds %struct.anon, ptr %216, i32 0, i32 8
  store ptr %214, ptr %217, align 8, !tbaa !11
  store ptr null, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %221

218:                                              ; preds = %204
  %219 = load ptr, ptr %5, align 8, !tbaa !5
  %220 = load ptr, ptr %10, align 8, !tbaa !5
  call void @copyTV(ptr noundef %219, ptr noundef %8, ptr noundef %220)
  store ptr %8, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %13, align 4
  br label %221

221:                                              ; preds = %218, %209, %190
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %222 = load i32, ptr %13, align 4
  switch i32 %222, label %229 [
    i32 0, label %223
  ]

223:                                              ; preds = %221
  br label %224

224:                                              ; preds = %223
  %225 = load i32, ptr %9, align 4, !tbaa !9
  %226 = add nsw i32 %225, 1
  store i32 %226, ptr %9, align 4, !tbaa !9
  br label %14, !llvm.loop !18

227:                                              ; preds = %14
  %228 = load ptr, ptr %5, align 8, !tbaa !5
  call void @lj_err_msg(ptr noundef %228, i32 noundef 381) #7
  unreachable

229:                                              ; preds = %221
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %230 = load ptr, ptr %4, align 8
  ret ptr %230
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @lj_gc_barrierback(ptr noundef, ptr noundef) #2

declare hidden ptr @lj_tab_newkey(ptr noundef, ptr noundef, ptr noundef) #4

declare hidden void @lj_cont_nop() #4

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

!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 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 6}
!13 = !{!"GCtab", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !15, i64 8, !14, i64 12, !14, i64 16, !6, i64 24, !15, i64 32, !10, i64 36, !10, i64 40}
!14 = !{!"GCRef", !10, i64 0}
!15 = !{!"MRef", !10, i64 0}
!16 = !{!13, !10, i64 16}
!17 = !{!14, !10, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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

%union.TValue = type { i64 }

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @lj_meta_cache(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @lj_meta_lookup(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @copyTV(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare hidden ptr @lj_tab_get(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: noreturn
declare hidden void @lj_err_optype(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

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

; Function Attrs: noreturn
declare hidden void @lj_err_msg(ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define hidden ptr @lj_meta_tset(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
.peel.begin:
  %3 = alloca %union.TValue, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, -12
  br i1 %7, label %13, label %8, !prof !8

8:                                                ; preds = %.peel.begin
  %9 = tail call ptr @lj_meta_lookup(ptr noundef %0, ptr noundef nonnull %1, i32 noundef 1)
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = icmp eq i32 %11, -1
  br i1 %12, label %.loopexit, label %39

13:                                               ; preds = %.peel.begin
  %14 = load i32, ptr %1, align 8, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = inttoptr i64 %15 to ptr
  %17 = tail call ptr @lj_tab_get(ptr noundef %0, ptr noundef %16, ptr noundef %2) #5
  %18 = getelementptr inbounds i8, ptr %17, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %.not.peel = icmp eq i32 %19, -1
  br i1 %.not.peel, label %20, label %.loopexit99, !prof !9

20:                                               ; preds = %13
  %21 = getelementptr inbounds i8, ptr %16, i64 16
  %22 = load i32, ptr %21, align 8, !tbaa !10
  %23 = zext i32 %22 to i64
  %24 = inttoptr i64 %23 to ptr
  %25 = icmp eq i32 %22, 0
  br i1 %25, label %.thread, label %26

26:                                               ; preds = %20
  %27 = getelementptr inbounds i8, ptr %24, i64 6
  %28 = load i8, ptr %27, align 2, !tbaa !5
  %29 = and i8 %28, 2
  %.not63.peel = icmp eq i8 %29, 0
  br i1 %.not63.peel, label %30, label %.thread

30:                                               ; preds = %26
  %31 = load i32, ptr %4, align 8, !tbaa !5
  %32 = zext i32 %31 to i64
  %33 = inttoptr i64 %32 to ptr
  %34 = getelementptr inbounds i8, ptr %33, i64 264
  %35 = load i32, ptr %34, align 4, !tbaa !16
  %36 = zext i32 %35 to i64
  %37 = inttoptr i64 %36 to ptr
  %38 = tail call ptr @lj_meta_cache(ptr noundef nonnull %24, i32 noundef 1, ptr noundef %37)
  %.not64.peel = icmp eq ptr %38, null
  br i1 %.not64.peel, label %.thread, label %._crit_edge

._crit_edge:                                      ; preds = %30
  %.phi.trans.insert = getelementptr inbounds i8, ptr %38, i64 4
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %._crit_edge, %8
  %40 = phi i32 [ %11, %8 ], [ %.pre, %._crit_edge ]
  %.255.peel = phi ptr [ %9, %8 ], [ %38, %._crit_edge ]
  %41 = icmp eq i32 %40, -9
  br i1 %41, label %.loopexit100, label %.peel.next

.peel.next:                                       ; preds = %39
  call void @copyTV(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %.255.peel)
  %42 = getelementptr inbounds i8, ptr %3, i64 4
  br label %43

43:                                               ; preds = %.peel.next, %116
  %.05788 = phi i32 [ 1, %.peel.next ], [ %117, %116 ]
  %44 = load i32, ptr %42, align 4, !tbaa !5
  %45 = icmp eq i32 %44, -12
  br i1 %45, label %46, label %106, !prof !8

46:                                               ; preds = %43
  %47 = load i32, ptr %3, align 8, !tbaa !5
  %48 = zext i32 %47 to i64
  %49 = inttoptr i64 %48 to ptr
  %50 = call ptr @lj_tab_get(ptr noundef %0, ptr noundef %49, ptr noundef %2) #5
  %51 = getelementptr inbounds i8, ptr %50, i64 4
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %.not = icmp eq i32 %52, -1
  br i1 %.not, label %61, label %.loopexit99, !prof !17

.loopexit99:                                      ; preds = %46, %13
  %.lcssa91 = phi ptr [ %16, %13 ], [ %49, %46 ]
  %.lcssa = phi ptr [ %17, %13 ], [ %50, %46 ]
  %53 = getelementptr inbounds i8, ptr %.lcssa91, i64 6
  store i8 0, ptr %53, align 2, !tbaa !18
  %54 = getelementptr inbounds i8, ptr %.lcssa91, i64 4
  %55 = load i8, ptr %54, align 4, !tbaa !5
  %56 = and i8 %55, 4
  %.not67 = icmp eq i8 %56, 0
  br i1 %.not67, label %.thread70, label %57, !prof !8

57:                                               ; preds = %.loopexit99
  %58 = load i32, ptr %4, align 8, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = inttoptr i64 %59 to ptr
  call void @lj_gc_barrierback(ptr noundef %60, ptr noundef nonnull %.lcssa91)
  br label %.thread70

61:                                               ; preds = %46
  %62 = getelementptr inbounds i8, ptr %49, i64 16
  %63 = load i32, ptr %62, align 8, !tbaa !10
  %64 = zext i32 %63 to i64
  %65 = inttoptr i64 %64 to ptr
  %66 = icmp eq i32 %63, 0
  br i1 %66, label %.thread, label %67

67:                                               ; preds = %61
  %68 = getelementptr inbounds i8, ptr %65, i64 6
  %69 = load i8, ptr %68, align 2, !tbaa !5
  %70 = and i8 %69, 2
  %.not63 = icmp eq i8 %70, 0
  br i1 %.not63, label %71, label %.thread

71:                                               ; preds = %67
  %72 = load i32, ptr %4, align 8, !tbaa !5
  %73 = zext i32 %72 to i64
  %74 = inttoptr i64 %73 to ptr
  %75 = getelementptr inbounds i8, ptr %74, i64 264
  %76 = load i32, ptr %75, align 4, !tbaa !16
  %77 = zext i32 %76 to i64
  %78 = inttoptr i64 %77 to ptr
  %79 = call ptr @lj_meta_cache(ptr noundef nonnull %65, i32 noundef 1, ptr noundef %78)
  %.not64 = icmp eq ptr %79, null
  br i1 %.not64, label %.thread, label %._crit_edge103

._crit_edge103:                                   ; preds = %71
  %.phi.trans.insert104 = getelementptr inbounds i8, ptr %79, i64 4
  %.pre105 = load i32, ptr %.phi.trans.insert104, align 4, !tbaa !5
  br label %111

.thread:                                          ; preds = %67, %61, %71, %30, %26, %20
  %.lcssa92 = phi ptr [ %16, %20 ], [ %16, %26 ], [ %16, %30 ], [ %49, %71 ], [ %49, %61 ], [ %49, %67 ]
  %.lcssa90 = phi ptr [ %17, %20 ], [ %17, %26 ], [ %17, %30 ], [ %50, %71 ], [ %50, %61 ], [ %50, %67 ]
  %80 = getelementptr inbounds i8, ptr %.lcssa92, i64 6
  store i8 0, ptr %80, align 2, !tbaa !18
  %81 = getelementptr inbounds i8, ptr %.lcssa92, i64 4
  %82 = load i8, ptr %81, align 4, !tbaa !5
  %83 = and i8 %82, 4
  %.not65 = icmp eq i8 %83, 0
  br i1 %.not65, label %88, label %84, !prof !8

84:                                               ; preds = %.thread
  %85 = load i32, ptr %4, align 8, !tbaa !5
  %86 = zext i32 %85 to i64
  %87 = inttoptr i64 %86 to ptr
  call void @lj_gc_barrierback(ptr noundef %87, ptr noundef nonnull %.lcssa92)
  br label %88

88:                                               ; preds = %84, %.thread
  %89 = load i32, ptr %4, align 8, !tbaa !5
  %90 = zext i32 %89 to i64
  %91 = inttoptr i64 %90 to ptr
  %92 = getelementptr inbounds i8, ptr %91, i64 160
  %.not66 = icmp eq ptr %.lcssa90, %92
  br i1 %.not66, label %93, label %.thread70

93:                                               ; preds = %88
  %94 = getelementptr inbounds i8, ptr %2, i64 4
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = icmp eq i32 %95, -1
  br i1 %96, label %97, label %98

97:                                               ; preds = %93
  call void @lj_err_msg(ptr noundef nonnull %0, i32 noundef 173) #6
  unreachable

98:                                               ; preds = %93
  %99 = icmp ult i32 %95, -65537
  br i1 %99, label %100, label %104

100:                                              ; preds = %98
  %101 = load double, ptr %2, align 8, !tbaa !5
  %102 = fcmp uno double %101, 0.000000e+00
  br i1 %102, label %103, label %104

103:                                              ; preds = %100
  call void @lj_err_msg(ptr noundef nonnull %0, i32 noundef 154) #6
  unreachable

104:                                              ; preds = %98, %100
  %105 = call ptr @lj_tab_newkey(ptr noundef nonnull %0, ptr noundef nonnull %.lcssa92, ptr noundef nonnull %2) #5
  br label %.thread70

106:                                              ; preds = %43
  %107 = call ptr @lj_meta_lookup(ptr noundef %0, ptr noundef nonnull %3, i32 noundef 1)
  %108 = getelementptr inbounds i8, ptr %107, i64 4
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = icmp eq i32 %109, -1
  br i1 %110, label %.loopexit, label %111

.loopexit:                                        ; preds = %106, %8
  %.05189.lcssa = phi ptr [ %1, %8 ], [ %3, %106 ]
  call void @lj_err_optype(ptr noundef %0, ptr noundef nonnull %.05189.lcssa, i32 noundef 403) #6
  unreachable

111:                                              ; preds = %._crit_edge103, %106
  %112 = phi i32 [ %109, %106 ], [ %.pre105, %._crit_edge103 ]
  %.255 = phi ptr [ %107, %106 ], [ %79, %._crit_edge103 ]
  %113 = icmp eq i32 %112, -9
  br i1 %113, label %.loopexit100, label %116

.loopexit100:                                     ; preds = %111, %39
  %.255.lcssa = phi ptr [ %.255.peel, %39 ], [ %.255, %111 ]
  %.05189.lcssa95 = phi ptr [ %1, %39 ], [ %3, %111 ]
  %114 = call ptr @mmcall(ptr noundef %0, ptr noundef nonnull @lj_cont_nop, ptr noundef nonnull %.255.lcssa, ptr noundef nonnull %.05189.lcssa95, ptr noundef %2)
  %115 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %114, ptr %115, align 8, !tbaa !5
  br label %.thread70

116:                                              ; preds = %111
  call void @copyTV(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %.255)
  %117 = add nuw nsw i32 %.05788, 1
  %exitcond.not = icmp eq i32 %117, 100
  br i1 %exitcond.not, label %.loopexit101, label %43, !llvm.loop !19

.loopexit101:                                     ; preds = %116
  call void @lj_err_msg(ptr noundef %0, i32 noundef 381) #6
  unreachable

.thread70:                                        ; preds = %88, %.loopexit99, %57, %104, %.loopexit100
  %.3.ph = phi ptr [ null, %.loopexit100 ], [ %.lcssa90, %88 ], [ %.lcssa, %.loopexit99 ], [ %.lcssa, %57 ], [ %105, %104 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret ptr %.3.ph
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @lj_gc_barrierback(ptr noundef, ptr noundef) local_unnamed_addr #2

declare hidden ptr @lj_tab_newkey(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare hidden void @lj_cont_nop() #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { alwaysinline 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 #3 = { "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 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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/C++ TBAA"}
!8 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!9 = !{!"branch_weights", i32 1, i32 2000}
!10 = !{!11, !13, i64 16}
!11 = !{!"GCtab", !12, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !14, i64 8, !12, i64 12, !12, i64 16, !15, i64 24, !14, i64 32, !13, i64 36, !13, i64 40}
!12 = !{!"GCRef", !13, i64 0}
!13 = !{!"int", !6, i64 0}
!14 = !{!"MRef", !13, i64 0}
!15 = !{!"any pointer", !6, i64 0}
!16 = !{!12, !13, i64 0}
!17 = !{!"branch_weights", i32 2000, i32 2000}
!18 = !{!11, !6, i64 6}
!19 = distinct !{!19, !20, !21}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.peeled.count", i32 1}


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