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

; 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.4 }
%union.anon.4 = type { %struct.anon.5, [320 x i8] }
%struct.anon.5 = 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.GG_State = type { %struct.lua_State, %struct.global_State, %struct.jit_State, [64 x i16], [243 x ptr], [57 x 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.6, %struct.MRef, i32 }
%union.anon.6 = type { %union.TValue }
%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.0 }
%struct.anon.0 = 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 }

@.str = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: 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 void @trace_flushroot(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define hidden i32 @lj_trace_flushall(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.lua_State, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %struct.anon.5, ptr %10, i32 0, i32 5
  %12 = getelementptr inbounds %struct.MRef, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = zext i32 %13 to i64
  %15 = inttoptr i64 %14 to ptr
  %16 = getelementptr inbounds i8, ptr %15, i64 -384
  %17 = getelementptr inbounds %struct.GG_State, ptr %16, i32 0, i32 2
  store ptr %17, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 -800
  %20 = getelementptr inbounds %struct.GG_State, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %struct.global_State, ptr %20, i32 0, i32 10
  %22 = load i8, ptr %21, align 1, !tbaa !10
  %23 = zext i8 %22 to i32
  %24 = and i32 %23, 64
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %1
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %117

27:                                               ; preds = %1
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.jit_State, ptr %28, i32 0, i32 36
  %30 = load i32, ptr %29, align 4, !tbaa !29
  %31 = zext i32 %30 to i64
  %32 = sub nsw i64 %31, 1
  store i64 %32, ptr %5, align 8, !tbaa !30
  br label %33

33:                                               ; preds = %70, %27
  %34 = load i64, ptr %5, align 8, !tbaa !30
  %35 = icmp sgt i64 %34, 0
  br i1 %35, label %36, label %73

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.jit_State, ptr %37, i32 0, i32 34
  %39 = load ptr, ptr %38, align 8, !tbaa !31
  %40 = load i64, ptr %5, align 8, !tbaa !30
  %41 = getelementptr inbounds %struct.GCRef, ptr %39, i64 %40
  %42 = getelementptr inbounds %struct.GCRef, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 4, !tbaa !32
  %44 = zext i32 %43 to i64
  %45 = inttoptr i64 %44 to ptr
  store ptr %45, ptr %7, align 8, !tbaa !5
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %69

48:                                               ; preds = %36
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.GCtrace, ptr %49, i32 0, i32 23
  %51 = load i16, ptr %50, align 4, !tbaa !33
  %52 = zext i16 %51 to i32
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %48
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  call void @trace_flushroot(ptr noundef %55, ptr noundef %56)
  br label %57

57:                                               ; preds = %54, %48
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.GCtrace, ptr %59, i32 0, i32 22
  store i16 0, ptr %60, align 2, !tbaa !34
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.GCtrace, ptr %61, i32 0, i32 21
  store i16 0, ptr %62, align 8, !tbaa !35
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.jit_State, ptr %63, i32 0, i32 34
  %65 = load ptr, ptr %64, align 8, !tbaa !31
  %66 = load i64, ptr %5, align 8, !tbaa !30
  %67 = getelementptr inbounds %struct.GCRef, ptr %65, i64 %66
  %68 = getelementptr inbounds %struct.GCRef, ptr %67, i32 0, i32 0
  store i32 0, ptr %68, align 4, !tbaa !32
  br label %69

69:                                               ; preds = %57, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %70

70:                                               ; preds = %69
  %71 = load i64, ptr %5, align 8, !tbaa !30
  %72 = add nsw i64 %71, -1
  store i64 %72, ptr %5, align 8, !tbaa !30
  br label %33, !llvm.loop !36

73:                                               ; preds = %33
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.jit_State, ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds %struct.GCtrace, ptr %75, i32 0, i32 21
  store i16 0, ptr %76, align 8, !tbaa !38
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.jit_State, ptr %77, i32 0, i32 35
  store i32 0, ptr %78, align 8, !tbaa !39
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.jit_State, ptr %79, i32 0, i32 42
  %81 = getelementptr inbounds [64 x %struct.HotPenalty], ptr %80, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %81, i8 0, i64 512, i1 false)
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  call void @lj_mcode_free(ptr noundef %82)
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  call void @lj_ir_k64_freeall(ptr noundef %83)
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.jit_State, ptr %84, i32 0, i32 41
  %86 = getelementptr inbounds [16 x ptr], ptr %85, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %86, i8 0, i64 128, i1 false)
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.lua_State, ptr %87, i32 0, i32 0
  %89 = getelementptr inbounds %struct.anon.5, ptr %88, i32 0, i32 5
  %90 = getelementptr inbounds %struct.MRef, ptr %89, i32 0, i32 0
  %91 = load i32, ptr %90, align 8, !tbaa !9
  %92 = zext i32 %91 to i64
  %93 = inttoptr i64 %92 to ptr
  %94 = getelementptr inbounds %struct.global_State, ptr %93, i32 0, i32 12
  %95 = load i8, ptr %94, align 1, !tbaa !40
  %96 = zext i8 %95 to i32
  %97 = and i32 %96, 2
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %116

99:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = call i64 @lj_vmevent_prepare(ptr noundef %100, i32 noundef -1765235911)
  store i64 %101, ptr %8, align 8, !tbaa !30
  %102 = load i64, ptr %8, align 8, !tbaa !30
  %103 = icmp ne i64 %102, 0
  br i1 %103, label %104, label %115

104:                                              ; preds = %99
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.lua_State, ptr %106, i32 0, i32 0
  %108 = getelementptr inbounds %struct.anon.5, ptr %107, i32 0, i32 8
  %109 = load ptr, ptr %108, align 8, !tbaa !9
  %110 = getelementptr inbounds %union.TValue, ptr %109, i32 1
  store ptr %110, ptr %108, align 8, !tbaa !9
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = call ptr @lj_str_new(ptr noundef %111, ptr noundef @.str, i64 noundef 5)
  call void @setstrV(ptr noundef %105, ptr noundef %109, ptr noundef %112)
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = load i64, ptr %8, align 8, !tbaa !30
  call void @lj_vmevent_call(ptr noundef %113, i64 noundef %114)
  br label %115

115:                                              ; preds = %104, %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %116

116:                                              ; preds = %115, %73
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %117

117:                                              ; preds = %116, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %118 = load i32, ptr %2, align 4
  ret i32 %118
}

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

declare hidden void @lj_mcode_free(ptr noundef) #3

declare hidden void @lj_ir_k64_freeall(ptr noundef) #3

declare hidden i64 @lj_vmevent_prepare(ptr noundef, i32 noundef) #3

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

declare hidden ptr @lj_str_new(ptr noundef, ptr noundef, i64 noundef) #3

declare hidden void @lj_vmevent_call(ptr noundef, i64 noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 509}
!11 = !{!"GG_State", !12, i64 0, !13, i64 384, !22, i64 800, !7, i64 3312, !7, i64 3440, !7, i64 5384}
!12 = !{!"lua_State", !7, i64 0}
!13 = !{!"global_State", !6, i64 0, !14, i64 8, !14, i64 12, !6, i64 16, !6, i64 24, !15, i64 32, !14, i64 88, !18, i64 92, !19, i64 108, !7, i64 124, !7, i64 125, !7, i64 126, !7, i64 127, !16, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !20, i64 160, !21, i64 184, !14, i64 208, !14, i64 212, !6, i64 216, !6, i64 224, !6, i64 232, !14, i64 240, !14, i64 244, !16, i64 248, !17, i64 252, !17, i64 256, !7, i64 260}
!14 = !{!"int", !7, i64 0}
!15 = !{!"GCState", !14, i64 0, !14, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !14, i64 12, !16, i64 16, !17, i64 20, !16, i64 24, !16, i64 28, !16, i64 32, !16, i64 36, !14, i64 40, !14, i64 44, !14, i64 48, !14, i64 52}
!16 = !{!"GCRef", !14, i64 0}
!17 = !{!"MRef", !14, i64 0}
!18 = !{!"SBuf", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12}
!19 = !{!"GCstr", !16, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !14, i64 8, !14, i64 12}
!20 = !{!"Node", !7, i64 0, !7, i64 8, !17, i64 16, !17, i64 20}
!21 = !{!"GCupval", !16, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !17, i64 16, !14, i64 20}
!22 = !{!"jit_State", !23, i64 0, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !14, i64 136, !14, i64 140, !14, i64 144, !7, i64 148, !7, i64 149, !25, i64 150, !7, i64 151, !26, i64 152, !6, i64 176, !14, i64 184, !14, i64 188, !14, i64 192, !14, i64 196, !14, i64 200, !14, i64 204, !14, i64 208, !17, i64 212, !7, i64 216, !6, i64 256, !14, i64 264, !14, i64 268, !14, i64 272, !14, i64 276, !6, i64 280, !6, i64 288, !14, i64 296, !14, i64 300, !7, i64 304, !6, i64 312, !14, i64 320, !14, i64 324, !6, i64 328, !7, i64 336, !7, i64 536, !7, i64 1556, !7, i64 1616, !7, i64 1744, !14, i64 2256, !14, i64 2260, !7, i64 2264, !14, i64 2392, !27, i64 2396, !6, i64 2416, !14, i64 2424, !14, i64 2428, !6, i64 2432, !14, i64 2440, !14, i64 2444, !6, i64 2448, !6, i64 2456, !6, i64 2464, !28, i64 2472, !28, i64 2480, !7, i64 2488, !6, i64 2496, !14, i64 2504, !14, i64 2508}
!23 = !{!"GCtrace", !16, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !14, i64 8, !16, i64 12, !6, i64 16, !14, i64 24, !24, i64 28, !24, i64 30, !6, i64 32, !6, i64 40, !16, i64 48, !17, i64 52, !14, i64 56, !14, i64 60, !6, i64 64, !14, i64 72, !24, i64 76, !24, i64 78, !24, i64 80, !24, i64 82, !24, i64 84, !24, i64 86, !24, i64 88, !7, i64 90, !7, i64 91}
!24 = !{!"short", !7, i64 0}
!25 = !{!"IRType1", !7, i64 0}
!26 = !{!"FoldState", !7, i64 0, !7, i64 8, !7, i64 16}
!27 = !{!"ScEvEntry", !17, i64 0, !24, i64 4, !24, i64 6, !24, i64 8, !24, i64 10, !25, i64 12, !7, i64 13}
!28 = !{!"long", !7, i64 0}
!29 = !{!22, !14, i64 324}
!30 = !{!28, !28, i64 0}
!31 = !{!22, !6, i64 312}
!32 = !{!16, !14, i64 0}
!33 = !{!23, !24, i64 84}
!34 = !{!23, !24, i64 82}
!35 = !{!23, !24, i64 80}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!22, !24, i64 80}
!39 = !{!22, !14, i64 320}
!40 = !{!13, !7, i64 127}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.GCRef = type { i32 }

@.str = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden void @trace_flushroot(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define hidden range(i32 0, 2) i32 @lj_trace_flushall(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = zext i32 %3 to i64
  %5 = inttoptr i64 %4 to ptr
  %6 = getelementptr inbounds i8, ptr %5, i64 416
  %7 = getelementptr inbounds i8, ptr %5, i64 125
  %8 = load i8, ptr %7, align 1, !tbaa !8
  %9 = and i8 %8, 64
  %.not = icmp eq i8 %9, 0
  br i1 %.not, label %10, label %54

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %5, i64 740
  %12 = load i32, ptr %11, align 4, !tbaa !28
  %13 = icmp ugt i32 %12, 1
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10
  %14 = zext i32 %12 to i64
  %15 = getelementptr inbounds i8, ptr %5, i64 728
  %.pre = load ptr, ptr %15, align 8, !tbaa !29
  br label %16

16:                                               ; preds = %.lr.ph, %33
  %17 = phi ptr [ %.pre, %.lr.ph ], [ %34, %33 ]
  %18 = phi ptr [ %.pre, %.lr.ph ], [ %35, %33 ]
  %.03037.in = phi i64 [ %14, %.lr.ph ], [ %.03037, %33 ]
  %.03037 = add nsw i64 %.03037.in, -1
  %19 = getelementptr inbounds %struct.GCRef, ptr %18, i64 %.03037
  %20 = load i32, ptr %19, align 4, !tbaa !30
  %21 = zext i32 %20 to i64
  %22 = inttoptr i64 %21 to ptr
  %.not35 = icmp eq i32 %20, 0
  br i1 %.not35, label %33, label %23

23:                                               ; preds = %16
  %24 = getelementptr inbounds i8, ptr %22, i64 84
  %25 = load i16, ptr %24, align 4, !tbaa !31
  %26 = icmp eq i16 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  tail call void @trace_flushroot(ptr noundef nonnull %6, ptr noundef nonnull %22)
  %.pre38 = load ptr, ptr %15, align 8, !tbaa !29
  br label %28

28:                                               ; preds = %27, %23
  %29 = phi ptr [ %.pre38, %27 ], [ %17, %23 ]
  %30 = getelementptr inbounds i8, ptr %22, i64 82
  store i16 0, ptr %30, align 2, !tbaa !32
  %31 = getelementptr inbounds i8, ptr %22, i64 80
  store i16 0, ptr %31, align 8, !tbaa !33
  %32 = getelementptr inbounds %struct.GCRef, ptr %29, i64 %.03037
  store i32 0, ptr %32, align 4, !tbaa !30
  br label %33

33:                                               ; preds = %28, %16
  %34 = phi ptr [ %29, %28 ], [ %17, %16 ]
  %35 = phi ptr [ %29, %28 ], [ %18, %16 ]
  %36 = icmp ugt i64 %.03037.in, 2
  br i1 %36, label %16, label %._crit_edge, !llvm.loop !34

._crit_edge:                                      ; preds = %33, %10
  %37 = getelementptr inbounds i8, ptr %5, i64 496
  store i16 0, ptr %37, align 8, !tbaa !36
  %38 = getelementptr inbounds i8, ptr %5, i64 736
  store i32 0, ptr %38, align 8, !tbaa !37
  %39 = getelementptr inbounds i8, ptr %5, i64 2160
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(512) %39, i8 0, i64 512, i1 false)
  tail call void @lj_mcode_free(ptr noundef nonnull %6) #4
  tail call void @lj_ir_k64_freeall(ptr noundef nonnull %6) #4
  %40 = getelementptr inbounds i8, ptr %5, i64 2032
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %40, i8 0, i64 128, i1 false)
  %41 = load i32, ptr %2, align 8, !tbaa !5
  %42 = zext i32 %41 to i64
  %43 = inttoptr i64 %42 to ptr
  %44 = getelementptr inbounds i8, ptr %43, i64 127
  %45 = load i8, ptr %44, align 1, !tbaa !38
  %46 = and i8 %45, 2
  %.not33 = icmp eq i8 %46, 0
  br i1 %.not33, label %54, label %47

47:                                               ; preds = %._crit_edge
  %48 = tail call i64 @lj_vmevent_prepare(ptr noundef nonnull %0, i32 noundef -1765235911) #4
  %.not34 = icmp eq i64 %48, 0
  br i1 %.not34, label %54, label %49

49:                                               ; preds = %47
  %50 = getelementptr inbounds i8, ptr %0, i64 24
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 8
  store ptr %52, ptr %50, align 8, !tbaa !5
  %53 = tail call ptr @lj_str_new(ptr noundef nonnull %0, ptr noundef nonnull @.str, i64 noundef 5) #4
  tail call void @setstrV(ptr noundef nonnull %0, ptr noundef %51, ptr noundef %53)
  tail call void @lj_vmevent_call(ptr noundef nonnull %0, i64 noundef %48) #4
  br label %54

54:                                               ; preds = %._crit_edge, %49, %47, %1
  %.0 = phi i32 [ 1, %1 ], [ 0, %47 ], [ 0, %49 ], [ 0, %._crit_edge ]
  ret i32 %.0
}

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

declare hidden void @lj_mcode_free(ptr noundef) local_unnamed_addr #2

declare hidden void @lj_ir_k64_freeall(ptr noundef) local_unnamed_addr #2

declare hidden i64 @lj_vmevent_prepare(ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare hidden ptr @lj_str_new(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare hidden void @lj_vmevent_call(ptr noundef, i64 noundef) local_unnamed_addr #2

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


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