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

; 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.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.MRef = type { i32 }
%struct.GCRef = type { 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 }
%union.TValue = type { i64 }
%struct.Node = type { %union.TValue, %union.TValue, %struct.MRef, %struct.MRef }
%struct.GCupval = type { %struct.GCRef, i8, i8, i8, i8, %union.anon.4, %struct.MRef, i32 }
%union.anon.4 = type { %union.TValue }
%struct.GG_State = type { %struct.lua_State, %struct.global_State, %struct.jit_State, [64 x i16], [243 x ptr], [57 x i32] }
%struct.jit_State = type { %struct.GCtrace, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i8, i8, %struct.IRType1, i8, %struct.FoldState, ptr, i32, i32, i32, i32, i32, i32, i32, %struct.MRef, [5 x %union.TValue], ptr, i32, i32, i32, i32, ptr, ptr, i32, i32, i8, ptr, i32, i32, ptr, [100 x i16], [255 x i32], [15 x i32], [16 x ptr], [64 x %struct.HotPenalty], i32, i32, [16 x %struct.BPropEntry], i32, %struct.ScEvEntry, ptr, i32, i32, ptr, i32, i32, ptr, ptr, ptr, i64, i64, %union.TValue, ptr, i32, i32 }
%struct.GCtrace = type { %struct.GCRef, i8, i8, i8, i8, i32, %struct.GCRef, ptr, i32, i16, i16, ptr, ptr, %struct.GCRef, %struct.MRef, i32, i32, ptr, i32, i16, i16, i16, i16, i16, i16, i16, i8, i8 }
%struct.IRType1 = type { i8 }
%struct.FoldState = type { %union.IRIns, %union.IRIns, %union.IRIns }
%union.IRIns = type { %struct.anon.7 }
%struct.anon.7 = type { i32, %struct.IRType1, i8, i8, i8 }
%struct.HotPenalty = type { %struct.MRef, i16, i16 }
%struct.BPropEntry = type { i16, i16, i32 }
%struct.ScEvEntry = type { %struct.MRef, i16, i16, i16, i16, %struct.IRType1, i8 }

; 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

declare hidden i32 @lj_vm_cpcall(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @lua_close(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.lua_State, ptr %5, i32 0, i32 0
  %7 = getelementptr inbounds %struct.anon, ptr %6, i32 0, i32 5
  %8 = getelementptr inbounds %struct.MRef, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = zext i32 %9 to i64
  %11 = inttoptr i64 %10 to ptr
  store ptr %11, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.global_State, ptr %12, i32 0, i32 13
  %14 = getelementptr inbounds %struct.GCRef, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !10
  %16 = zext i32 %15 to i64
  %17 = inttoptr i64 %16 to ptr
  store ptr %17, ptr %2, align 8, !tbaa !5
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  call void @luaJIT_profile_stop(ptr noundef %18)
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.global_State, ptr %19, i32 0, i32 26
  %21 = getelementptr inbounds %struct.GCRef, ptr %20, i32 0, i32 0
  store i32 0, ptr %21, align 8, !tbaa !20
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.lua_State, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct.anon, ptr %24, i32 0, i32 10
  %26 = getelementptr inbounds %struct.MRef, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = inttoptr i64 %28 to ptr
  call void @lj_func_closeuv(ptr noundef %22, ptr noundef %29)
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = call i64 @lj_gc_separateudata(ptr noundef %30, i32 noundef 1)
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 -384
  %34 = getelementptr inbounds %struct.GG_State, ptr %33, i32 0, i32 2
  %35 = getelementptr inbounds %struct.jit_State, ptr %34, i32 0, i32 6
  %36 = load i32, ptr %35, align 8, !tbaa !21
  %37 = and i32 %36, -2
  store i32 %37, ptr %35, align 8, !tbaa !21
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %38, i64 -384
  %40 = getelementptr inbounds %struct.GG_State, ptr %39, i32 0, i32 2
  %41 = getelementptr inbounds %struct.jit_State, ptr %40, i32 0, i32 16
  store i32 0, ptr %41, align 4, !tbaa !31
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  call void @lj_dispatch_update(ptr noundef %42)
  store i32 0, ptr %4, align 4, !tbaa !32
  br label %43

43:                                               ; preds = %92, %1
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.global_State, ptr %44, i32 0, i32 10
  %46 = load i8, ptr %45, align 1, !tbaa !33
  %47 = zext i8 %46 to i32
  %48 = or i32 %47, 16
  %49 = trunc i32 %48 to i8
  store i8 %49, ptr %45, align 1, !tbaa !33
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.lua_State, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon, ptr %51, i32 0, i32 4
  store i8 0, ptr %52, align 1, !tbaa !9
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.lua_State, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct.anon, ptr %54, i32 0, i32 10
  %56 = getelementptr inbounds %struct.MRef, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = inttoptr i64 %58 to ptr
  %60 = getelementptr inbounds %union.TValue, ptr %59, i64 1
  %61 = getelementptr inbounds %union.TValue, ptr %60, i64 0
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.lua_State, ptr %62, i32 0, i32 0
  %64 = getelementptr inbounds %struct.anon, ptr %63, i32 0, i32 8
  store ptr %61, ptr %64, align 8, !tbaa !9
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.lua_State, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds %struct.anon, ptr %66, i32 0, i32 7
  store ptr %61, ptr %67, align 8, !tbaa !9
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.lua_State, ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds %struct.anon, ptr %69, i32 0, i32 13
  store ptr null, ptr %70, align 8, !tbaa !9
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = call i32 @lj_vm_cpcall(ptr noundef %71, ptr noundef null, ptr noundef null, ptr noundef @cpfinalize)
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %92

74:                                               ; preds = %43
  %75 = load i32, ptr %4, align 4, !tbaa !32
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %4, align 4, !tbaa !32
  %77 = icmp sge i32 %76, 10
  br i1 %77, label %78, label %79

78:                                               ; preds = %74
  br label %93

79:                                               ; preds = %74
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = call i64 @lj_gc_separateudata(ptr noundef %80, i32 noundef 1)
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.global_State, ptr %82, i32 0, i32 5
  %84 = getelementptr inbounds %struct.GCState, ptr %83, i32 0, i32 12
  %85 = getelementptr inbounds %struct.GCRef, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !34
  %87 = zext i32 %86 to i64
  %88 = inttoptr i64 %87 to ptr
  %89 = icmp eq ptr %88, null
  br i1 %89, label %90, label %91

90:                                               ; preds = %79
  br label %93

91:                                               ; preds = %79
  br label %92

92:                                               ; preds = %91, %43
  br label %43

93:                                               ; preds = %90, %78
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  call void @close_state(ptr noundef %94)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare void @luaJIT_profile_stop(ptr noundef) #1

declare hidden void @lj_func_closeuv(ptr noundef, ptr noundef) #1

declare hidden i64 @lj_gc_separateudata(ptr noundef, i32 noundef) #1

declare hidden void @lj_dispatch_update(ptr noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 128}
!11 = !{!"global_State", !6, i64 0, !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24, !13, i64 32, !12, i64 88, !16, i64 92, !17, i64 108, !7, i64 124, !7, i64 125, !7, i64 126, !7, i64 127, !14, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !18, i64 160, !19, i64 184, !12, i64 208, !12, i64 212, !6, i64 216, !6, i64 224, !6, i64 232, !12, i64 240, !12, i64 244, !14, i64 248, !15, i64 252, !15, i64 256, !7, i64 260}
!12 = !{!"int", !7, i64 0}
!13 = !{!"GCState", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !12, i64 12, !14, i64 16, !15, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52}
!14 = !{!"GCRef", !12, i64 0}
!15 = !{!"MRef", !12, i64 0}
!16 = !{!"SBuf", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!17 = !{!"GCstr", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !12, i64 8, !12, i64 12}
!18 = !{!"Node", !7, i64 0, !7, i64 8, !15, i64 16, !15, i64 20}
!19 = !{!"GCupval", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !15, i64 16, !12, i64 20}
!20 = !{!11, !12, i64 248}
!21 = !{!22, !12, i64 936}
!22 = !{!"GG_State", !23, i64 0, !11, i64 384, !24, i64 800, !7, i64 3312, !7, i64 3440, !7, i64 5384}
!23 = !{!"lua_State", !7, i64 0}
!24 = !{!"jit_State", !25, i64 0, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !12, i64 136, !12, i64 140, !12, i64 144, !7, i64 148, !7, i64 149, !27, i64 150, !7, i64 151, !28, i64 152, !6, i64 176, !12, i64 184, !12, i64 188, !12, i64 192, !12, i64 196, !12, i64 200, !12, i64 204, !12, i64 208, !15, i64 212, !7, i64 216, !6, i64 256, !12, i64 264, !12, i64 268, !12, i64 272, !12, i64 276, !6, i64 280, !6, i64 288, !12, i64 296, !12, i64 300, !7, i64 304, !6, i64 312, !12, i64 320, !12, i64 324, !6, i64 328, !7, i64 336, !7, i64 536, !7, i64 1556, !7, i64 1616, !7, i64 1744, !12, i64 2256, !12, i64 2260, !7, i64 2264, !12, i64 2392, !29, i64 2396, !6, i64 2416, !12, i64 2424, !12, i64 2428, !6, i64 2432, !12, i64 2440, !12, i64 2444, !6, i64 2448, !6, i64 2456, !6, i64 2464, !30, i64 2472, !30, i64 2480, !7, i64 2488, !6, i64 2496, !12, i64 2504, !12, i64 2508}
!25 = !{!"GCtrace", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !12, i64 8, !14, i64 12, !6, i64 16, !12, i64 24, !26, i64 28, !26, i64 30, !6, i64 32, !6, i64 40, !14, i64 48, !15, i64 52, !12, i64 56, !12, i64 60, !6, i64 64, !12, i64 72, !26, i64 76, !26, i64 78, !26, i64 80, !26, i64 82, !26, i64 84, !26, i64 86, !26, i64 88, !7, i64 90, !7, i64 91}
!26 = !{!"short", !7, i64 0}
!27 = !{!"IRType1", !7, i64 0}
!28 = !{!"FoldState", !7, i64 0, !7, i64 8, !7, i64 16}
!29 = !{!"ScEvEntry", !15, i64 0, !26, i64 4, !26, i64 6, !26, i64 8, !26, i64 10, !27, i64 12, !7, i64 13}
!30 = !{!"long", !7, i64 0}
!31 = !{!22, !12, i64 988}
!32 = !{!12, !12, i64 0}
!33 = !{!11, !7, i64 125}
!34 = !{!11, !12, i64 68}


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

declare hidden i32 @lj_vm_cpcall(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @lua_close(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
.outer:
  %1 = getelementptr inbounds i8, ptr %0, i64 8
  %2 = load i32, ptr %1, align 8, !tbaa !5
  %3 = zext i32 %2 to i64
  %4 = inttoptr i64 %3 to ptr
  %5 = getelementptr inbounds i8, ptr %4, i64 128
  %6 = load i32, ptr %5, align 8, !tbaa !8
  %7 = zext i32 %6 to i64
  %8 = inttoptr i64 %7 to ptr
  tail call void @luaJIT_profile_stop(ptr noundef %8) #2
  %9 = getelementptr inbounds i8, ptr %4, i64 248
  store i32 0, ptr %9, align 8, !tbaa !19
  %10 = getelementptr inbounds i8, ptr %8, i64 36
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = inttoptr i64 %12 to ptr
  tail call void @lj_func_closeuv(ptr noundef %8, ptr noundef %13) #2
  %14 = tail call i64 @lj_gc_separateudata(ptr noundef %4, i32 noundef 1) #2
  %15 = getelementptr inbounds i8, ptr %4, i64 552
  %16 = load i32, ptr %15, align 8, !tbaa !20
  %17 = and i32 %16, -2
  store i32 %17, ptr %15, align 8, !tbaa !20
  %18 = getelementptr inbounds i8, ptr %4, i64 604
  store i32 0, ptr %18, align 4, !tbaa !30
  tail call void @lj_dispatch_update(ptr noundef %4) #2
  %19 = getelementptr inbounds i8, ptr %4, i64 125
  %20 = getelementptr inbounds i8, ptr %8, i64 7
  %21 = getelementptr inbounds i8, ptr %8, i64 24
  %22 = getelementptr inbounds i8, ptr %8, i64 16
  %23 = getelementptr inbounds i8, ptr %8, i64 48
  %24 = getelementptr inbounds i8, ptr %4, i64 68
  br label %25

25:                                               ; preds = %.outer, %25
  %26 = load i8, ptr %19, align 1, !tbaa !31
  %27 = or i8 %26, 16
  store i8 %27, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %28 = load i32, ptr %10, align 4, !tbaa !5
  %29 = zext i32 %28 to i64
  %30 = inttoptr i64 %29 to ptr
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  store ptr %31, ptr %21, align 8, !tbaa !5
  store ptr %31, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %32 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %25

34:                                               ; preds = %25
  %35 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %36 = load i32, ptr %24, align 4, !tbaa !32
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %142, label %.outer.1

.outer.1:                                         ; preds = %34, %.outer.1
  %38 = load i8, ptr %19, align 1, !tbaa !31
  %39 = or i8 %38, 16
  store i8 %39, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = zext i32 %40 to i64
  %42 = inttoptr i64 %41 to ptr
  %43 = getelementptr inbounds i8, ptr %42, i64 8
  store ptr %43, ptr %21, align 8, !tbaa !5
  store ptr %43, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %44 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %.outer.1

46:                                               ; preds = %.outer.1
  %47 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %48 = load i32, ptr %24, align 4, !tbaa !32
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %142, label %.outer.2

.outer.2:                                         ; preds = %46, %.outer.2
  %50 = load i8, ptr %19, align 1, !tbaa !31
  %51 = or i8 %50, 16
  store i8 %51, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %52 = load i32, ptr %10, align 4, !tbaa !5
  %53 = zext i32 %52 to i64
  %54 = inttoptr i64 %53 to ptr
  %55 = getelementptr inbounds i8, ptr %54, i64 8
  store ptr %55, ptr %21, align 8, !tbaa !5
  store ptr %55, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %56 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %.outer.2

58:                                               ; preds = %.outer.2
  %59 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %60 = load i32, ptr %24, align 4, !tbaa !32
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %142, label %.outer.3

.outer.3:                                         ; preds = %58, %.outer.3
  %62 = load i8, ptr %19, align 1, !tbaa !31
  %63 = or i8 %62, 16
  store i8 %63, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %64 = load i32, ptr %10, align 4, !tbaa !5
  %65 = zext i32 %64 to i64
  %66 = inttoptr i64 %65 to ptr
  %67 = getelementptr inbounds i8, ptr %66, i64 8
  store ptr %67, ptr %21, align 8, !tbaa !5
  store ptr %67, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %68 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %.outer.3

70:                                               ; preds = %.outer.3
  %71 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %72 = load i32, ptr %24, align 4, !tbaa !32
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %142, label %.outer.4

.outer.4:                                         ; preds = %70, %.outer.4
  %74 = load i8, ptr %19, align 1, !tbaa !31
  %75 = or i8 %74, 16
  store i8 %75, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %76 = load i32, ptr %10, align 4, !tbaa !5
  %77 = zext i32 %76 to i64
  %78 = inttoptr i64 %77 to ptr
  %79 = getelementptr inbounds i8, ptr %78, i64 8
  store ptr %79, ptr %21, align 8, !tbaa !5
  store ptr %79, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %80 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %.outer.4

82:                                               ; preds = %.outer.4
  %83 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %84 = load i32, ptr %24, align 4, !tbaa !32
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %142, label %.outer.5

.outer.5:                                         ; preds = %82, %.outer.5
  %86 = load i8, ptr %19, align 1, !tbaa !31
  %87 = or i8 %86, 16
  store i8 %87, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %88 = load i32, ptr %10, align 4, !tbaa !5
  %89 = zext i32 %88 to i64
  %90 = inttoptr i64 %89 to ptr
  %91 = getelementptr inbounds i8, ptr %90, i64 8
  store ptr %91, ptr %21, align 8, !tbaa !5
  store ptr %91, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %92 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %93 = icmp eq i32 %92, 0
  br i1 %93, label %94, label %.outer.5

94:                                               ; preds = %.outer.5
  %95 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %96 = load i32, ptr %24, align 4, !tbaa !32
  %97 = icmp eq i32 %96, 0
  br i1 %97, label %142, label %.outer.6

.outer.6:                                         ; preds = %94, %.outer.6
  %98 = load i8, ptr %19, align 1, !tbaa !31
  %99 = or i8 %98, 16
  store i8 %99, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %100 = load i32, ptr %10, align 4, !tbaa !5
  %101 = zext i32 %100 to i64
  %102 = inttoptr i64 %101 to ptr
  %103 = getelementptr inbounds i8, ptr %102, i64 8
  store ptr %103, ptr %21, align 8, !tbaa !5
  store ptr %103, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %104 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %105 = icmp eq i32 %104, 0
  br i1 %105, label %106, label %.outer.6

106:                                              ; preds = %.outer.6
  %107 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %108 = load i32, ptr %24, align 4, !tbaa !32
  %109 = icmp eq i32 %108, 0
  br i1 %109, label %142, label %.outer.7

.outer.7:                                         ; preds = %106, %.outer.7
  %110 = load i8, ptr %19, align 1, !tbaa !31
  %111 = or i8 %110, 16
  store i8 %111, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %112 = load i32, ptr %10, align 4, !tbaa !5
  %113 = zext i32 %112 to i64
  %114 = inttoptr i64 %113 to ptr
  %115 = getelementptr inbounds i8, ptr %114, i64 8
  store ptr %115, ptr %21, align 8, !tbaa !5
  store ptr %115, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %116 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %117 = icmp eq i32 %116, 0
  br i1 %117, label %118, label %.outer.7

118:                                              ; preds = %.outer.7
  %119 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %120 = load i32, ptr %24, align 4, !tbaa !32
  %121 = icmp eq i32 %120, 0
  br i1 %121, label %142, label %.outer.8

.outer.8:                                         ; preds = %118, %.outer.8
  %122 = load i8, ptr %19, align 1, !tbaa !31
  %123 = or i8 %122, 16
  store i8 %123, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %124 = load i32, ptr %10, align 4, !tbaa !5
  %125 = zext i32 %124 to i64
  %126 = inttoptr i64 %125 to ptr
  %127 = getelementptr inbounds i8, ptr %126, i64 8
  store ptr %127, ptr %21, align 8, !tbaa !5
  store ptr %127, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %128 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %129 = icmp eq i32 %128, 0
  br i1 %129, label %130, label %.outer.8

130:                                              ; preds = %.outer.8
  %131 = tail call i64 @lj_gc_separateudata(ptr noundef nonnull %4, i32 noundef 1) #2
  %132 = load i32, ptr %24, align 4, !tbaa !32
  %133 = icmp eq i32 %132, 0
  br i1 %133, label %142, label %.outer.9

.outer.9:                                         ; preds = %130, %.outer.9
  %134 = load i8, ptr %19, align 1, !tbaa !31
  %135 = or i8 %134, 16
  store i8 %135, ptr %19, align 1, !tbaa !31
  store i8 0, ptr %20, align 1, !tbaa !5
  %136 = load i32, ptr %10, align 4, !tbaa !5
  %137 = zext i32 %136 to i64
  %138 = inttoptr i64 %137 to ptr
  %139 = getelementptr inbounds i8, ptr %138, i64 8
  store ptr %139, ptr %21, align 8, !tbaa !5
  store ptr %139, ptr %22, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %140 = tail call i32 @lj_vm_cpcall(ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef nonnull @cpfinalize) #2
  %141 = icmp eq i32 %140, 0
  br i1 %141, label %142, label %.outer.9

142:                                              ; preds = %.outer.9, %130, %118, %106, %94, %82, %70, %58, %46, %34
  tail call void @close_state(ptr noundef nonnull %8)
  ret void
}

declare void @luaJIT_profile_stop(ptr noundef) local_unnamed_addr #0

declare hidden void @lj_func_closeuv(ptr noundef, ptr noundef) local_unnamed_addr #0

declare hidden i64 @lj_gc_separateudata(ptr noundef, i32 noundef) local_unnamed_addr #0

declare hidden void @lj_dispatch_update(ptr noundef) local_unnamed_addr #0

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

attributes #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 = { 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 = { 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 = !{!9, !11, i64 128}
!9 = !{!"global_State", !10, i64 0, !11, i64 8, !11, i64 12, !10, i64 16, !10, i64 24, !12, i64 32, !11, i64 88, !15, i64 92, !16, i64 108, !6, i64 124, !6, i64 125, !6, i64 126, !6, i64 127, !13, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !17, i64 160, !18, i64 184, !11, i64 208, !11, i64 212, !10, i64 216, !10, i64 224, !10, i64 232, !11, i64 240, !11, i64 244, !13, i64 248, !14, i64 252, !14, i64 256, !6, i64 260}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"GCState", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 9, !6, i64 10, !6, i64 11, !11, i64 12, !13, i64 16, !14, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52}
!13 = !{!"GCRef", !11, i64 0}
!14 = !{!"MRef", !11, i64 0}
!15 = !{!"SBuf", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12}
!16 = !{!"GCstr", !13, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !11, i64 8, !11, i64 12}
!17 = !{!"Node", !6, i64 0, !6, i64 8, !14, i64 16, !14, i64 20}
!18 = !{!"GCupval", !13, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !6, i64 8, !14, i64 16, !11, i64 20}
!19 = !{!9, !11, i64 248}
!20 = !{!21, !11, i64 936}
!21 = !{!"GG_State", !22, i64 0, !9, i64 384, !23, i64 800, !6, i64 3312, !6, i64 3440, !6, i64 5384}
!22 = !{!"lua_State", !6, i64 0}
!23 = !{!"jit_State", !24, i64 0, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !11, i64 136, !11, i64 140, !11, i64 144, !6, i64 148, !6, i64 149, !26, i64 150, !6, i64 151, !27, i64 152, !10, i64 176, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !11, i64 200, !11, i64 204, !11, i64 208, !14, i64 212, !6, i64 216, !10, i64 256, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !10, i64 280, !10, i64 288, !11, i64 296, !11, i64 300, !6, i64 304, !10, i64 312, !11, i64 320, !11, i64 324, !10, i64 328, !6, i64 336, !6, i64 536, !6, i64 1556, !6, i64 1616, !6, i64 1744, !11, i64 2256, !11, i64 2260, !6, i64 2264, !11, i64 2392, !28, i64 2396, !10, i64 2416, !11, i64 2424, !11, i64 2428, !10, i64 2432, !11, i64 2440, !11, i64 2444, !10, i64 2448, !10, i64 2456, !10, i64 2464, !29, i64 2472, !29, i64 2480, !6, i64 2488, !10, i64 2496, !11, i64 2504, !11, i64 2508}
!24 = !{!"GCtrace", !13, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !11, i64 8, !13, i64 12, !10, i64 16, !11, i64 24, !25, i64 28, !25, i64 30, !10, i64 32, !10, i64 40, !13, i64 48, !14, i64 52, !11, i64 56, !11, i64 60, !10, i64 64, !11, i64 72, !25, i64 76, !25, i64 78, !25, i64 80, !25, i64 82, !25, i64 84, !25, i64 86, !25, i64 88, !6, i64 90, !6, i64 91}
!25 = !{!"short", !6, i64 0}
!26 = !{!"IRType1", !6, i64 0}
!27 = !{!"FoldState", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!"ScEvEntry", !14, i64 0, !25, i64 4, !25, i64 6, !25, i64 8, !25, i64 10, !26, i64 12, !6, i64 13}
!29 = !{!"long", !6, i64 0}
!30 = !{!21, !11, i64 988}
!31 = !{!9, !6, i64 125}
!32 = !{!9, !11, i64 68}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass