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

; 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.ProfileState = type { ptr, ptr, ptr, %struct.SBuf, i32, i32, i32, %struct.sigaction }
%struct.SBuf = type { %struct.MRef, %struct.MRef, %struct.MRef, %struct.MRef }
%struct.MRef = type { i32 }
%struct.sigaction = type { %union.anon, %struct.__sigset_t, i32, ptr }
%union.anon = type { ptr }
%struct.__sigset_t = type { [16 x i64] }
%struct.lua_State = type { %union.anon.0 }
%union.anon.0 = 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.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.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.5, %struct.MRef, i32 }
%union.anon.5 = 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.8 }
%struct.anon.8 = 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 }

@profile_state = external hidden global %struct.ProfileState, align 8

; 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
define dso_local void @luaJIT_profile_start(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = 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
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr @profile_state, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 10, ptr %10, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %65, %4
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %17, label %66

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i32 1
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load i8, ptr %18, align 1, !tbaa !11
  %21 = sext i8 %20 to i32
  store i32 %21, ptr %11, align 4, !tbaa !9
  %22 = load i32, ptr %11, align 4, !tbaa !9
  switch i32 %22, label %64 [
    i32 105, label %23
    i32 108, label %50
    i32 102, label %50
  ]

23:                                               ; preds = %17
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %36, %23
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = icmp sge i32 %27, 48
  br i1 %28, label %29, label %34

29:                                               ; preds = %24
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = icmp sle i32 %32, 57
  br label %34

34:                                               ; preds = %29, %24
  %35 = phi i1 [ false, %24 ], [ %33, %29 ]
  br i1 %35, label %36, label %45

36:                                               ; preds = %34
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = mul nsw i32 %37, 10
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i32 1
  store ptr %40, ptr %6, align 8, !tbaa !5
  %41 = load i8, ptr %39, align 1, !tbaa !11
  %42 = sext i8 %41 to i32
  %43 = sub nsw i32 %42, 48
  %44 = add nsw i32 %38, %43
  store i32 %44, ptr %10, align 4, !tbaa !9
  br label %24, !llvm.loop !12

45:                                               ; preds = %34
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = icmp sle i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %48, %45
  br label %65

50:                                               ; preds = %17, %17
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.lua_State, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.anon, ptr %53, i32 0, i32 5
  %55 = getelementptr inbounds %struct.MRef, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !11
  %57 = zext i32 %56 to i64
  %58 = inttoptr i64 %57 to ptr
  %59 = getelementptr inbounds i8, ptr %58, i64 -384
  %60 = getelementptr inbounds %struct.GG_State, ptr %59, i32 0, i32 2
  %61 = getelementptr inbounds %struct.jit_State, ptr %60, i32 0, i32 62
  store i32 %51, ptr %61, align 4, !tbaa !14
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = call i32 @lj_trace_flushall(ptr noundef %62)
  br label %65

64:                                               ; preds = %17
  br label %65

65:                                               ; preds = %64, %50, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %13, !llvm.loop !32

66:                                               ; preds = %13
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ProfileState, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !33
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %79

71:                                               ; preds = %66
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  call void @luaJIT_profile_stop(ptr noundef %72)
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ProfileState, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !33
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %78

77:                                               ; preds = %71
  store i32 1, ptr %12, align 4
  br label %104

78:                                               ; preds = %71
  br label %79

79:                                               ; preds = %78, %66
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.lua_State, ptr %80, i32 0, i32 0
  %82 = getelementptr inbounds %struct.anon, ptr %81, i32 0, i32 5
  %83 = getelementptr inbounds %struct.MRef, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !11
  %85 = zext i32 %84 to i64
  %86 = inttoptr i64 %85 to ptr
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.ProfileState, ptr %87, i32 0, i32 0
  store ptr %86, ptr %88, align 8, !tbaa !33
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.ProfileState, ptr %90, i32 0, i32 4
  store i32 %89, ptr %91, align 8, !tbaa !37
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.ProfileState, ptr %93, i32 0, i32 1
  store ptr %92, ptr %94, align 8, !tbaa !38
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ProfileState, ptr %96, i32 0, i32 2
  store ptr %95, ptr %97, align 8, !tbaa !39
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.ProfileState, ptr %98, i32 0, i32 5
  store i32 0, ptr %99, align 4, !tbaa !40
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.ProfileState, ptr %101, i32 0, i32 3
  call void @lj_buf_init(ptr noundef %100, ptr noundef %102)
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  call void @profile_timer_start(ptr noundef %103)
  store i32 0, ptr %12, align 4
  br label %104

104:                                              ; preds = %79, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %105 = load i32, ptr %12, align 4
  switch i32 %105, label %107 [
    i32 0, label %106
    i32 1, label %106
  ]

106:                                              ; preds = %104, %104
  ret void

107:                                              ; preds = %104
  unreachable
}

declare hidden i32 @lj_trace_flushall(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @luaJIT_profile_stop(ptr noundef) #1

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

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

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


; 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.ProfileState = type { ptr, ptr, ptr, %struct.SBuf, i32, i32, i32, %struct.sigaction }
%struct.SBuf = type { %struct.MRef, %struct.MRef, %struct.MRef, %struct.MRef }
%struct.MRef = type { i32 }
%struct.sigaction = type { %union.anon, %struct.__sigset_t, i32, ptr }
%union.anon = type { ptr }
%struct.__sigset_t = type { [16 x i64] }

@profile_state = external hidden global %struct.ProfileState, align 8

; Function Attrs: nounwind uwtable
define dso_local void @luaJIT_profile_start(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = load i8, ptr %1, align 1, !tbaa !5
  %.not36 = icmp eq i8 %5, 0
  br i1 %.not36, label %._crit_edge, label %.lr.ph39

.lr.ph39:                                         ; preds = %4
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  br label %7

7:                                                ; preds = %.lr.ph39, %26
  %8 = phi i8 [ %5, %.lr.ph39 ], [ %27, %26 ]
  %.038 = phi ptr [ %1, %.lr.ph39 ], [ %.2, %26 ]
  %.02537 = phi i32 [ 10, %.lr.ph39 ], [ %.227, %26 ]
  %9 = getelementptr inbounds i8, ptr %.038, i64 1
  switch i8 %8, label %26 [
    i8 105, label %.preheader
    i8 108, label %19
    i8 102, label %19
  ]

.preheader:                                       ; preds = %7
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = add i8 %10, -48
  %or.cond32 = icmp ult i8 %11, 10
  br i1 %or.cond32, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %12 = phi i8 [ %17, %.lr.ph ], [ %10, %.preheader ]
  %.134 = phi ptr [ %14, %.lr.ph ], [ %9, %.preheader ]
  %.12633 = phi i32 [ %16, %.lr.ph ], [ 0, %.preheader ]
  %13 = mul nsw i32 %.12633, 10
  %14 = getelementptr inbounds i8, ptr %.134, i64 1
  %narrow = add nsw i8 %12, -48
  %15 = zext nneg i8 %narrow to i32
  %16 = add nsw i32 %13, %15
  %17 = load i8, ptr %14, align 1, !tbaa !5
  %18 = add i8 %17, -48
  %or.cond = icmp ult i8 %18, 10
  br i1 %or.cond, label %.lr.ph, label %.critedge, !llvm.loop !8

.critedge:                                        ; preds = %.lr.ph, %.preheader
  %.126.lcssa = phi i32 [ 0, %.preheader ], [ %16, %.lr.ph ]
  %.1.lcssa = phi ptr [ %9, %.preheader ], [ %14, %.lr.ph ]
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %.126.lcssa, i32 1)
  br label %26

19:                                               ; preds = %7, %7
  %20 = zext nneg i8 %8 to i32
  %21 = load i32, ptr %6, align 8, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = inttoptr i64 %22 to ptr
  %24 = getelementptr inbounds i8, ptr %23, i64 2924
  store i32 %20, ptr %24, align 4, !tbaa !10
  %25 = tail call i32 @lj_trace_flushall(ptr noundef %0) #4
  br label %26

26:                                               ; preds = %7, %19, %.critedge
  %.227 = phi i32 [ %.02537, %7 ], [ %.02537, %19 ], [ %spec.store.select, %.critedge ]
  %.2 = phi ptr [ %9, %7 ], [ %9, %19 ], [ %.1.lcssa, %.critedge ]
  %27 = load i8, ptr %.2, align 1, !tbaa !5
  %.not = icmp eq i8 %27, 0
  br i1 %.not, label %._crit_edge, label %7, !llvm.loop !30

._crit_edge:                                      ; preds = %26, %4
  %.025.lcssa = phi i32 [ 10, %4 ], [ %.227, %26 ]
  %28 = load ptr, ptr @profile_state, align 8, !tbaa !31
  %.not30 = icmp eq ptr %28, null
  br i1 %.not30, label %31, label %29

29:                                               ; preds = %._crit_edge
  tail call void @luaJIT_profile_stop(ptr noundef %0)
  %30 = load ptr, ptr @profile_state, align 8, !tbaa !31
  %.not31 = icmp eq ptr %30, null
  br i1 %.not31, label %31, label %36

31:                                               ; preds = %29, %._crit_edge
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load i32, ptr %32, align 8, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = inttoptr i64 %34 to ptr
  store ptr %35, ptr @profile_state, align 8, !tbaa !31
  store i32 %.025.lcssa, ptr getelementptr inbounds (i8, ptr @profile_state, i64 40), align 8, !tbaa !35
  store ptr %2, ptr getelementptr inbounds (i8, ptr @profile_state, i64 8), align 8, !tbaa !36
  store ptr %3, ptr getelementptr inbounds (i8, ptr @profile_state, i64 16), align 8, !tbaa !37
  store i32 0, ptr getelementptr inbounds (i8, ptr @profile_state, i64 44), align 4, !tbaa !38
  tail call void @lj_buf_init(ptr noundef %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @profile_state, i64 24))
  tail call void @profile_timer_start(ptr noundef nonnull @profile_state)
  br label %36

36:                                               ; preds = %29, %31
  ret void
}

declare hidden i32 @lj_trace_flushall(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @luaJIT_profile_stop(ptr noundef) local_unnamed_addr #0

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

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

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

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 = { "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 speculatable willreturn memory(none) }
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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !15, i64 3308}
!11 = !{!"GG_State", !12, i64 0, !13, i64 384, !23, i64 800, !6, i64 3312, !6, i64 3440, !6, i64 5384}
!12 = !{!"lua_State", !6, i64 0}
!13 = !{!"global_State", !14, i64 0, !15, i64 8, !15, i64 12, !14, i64 16, !14, i64 24, !16, i64 32, !15, i64 88, !19, i64 92, !20, i64 108, !6, i64 124, !6, i64 125, !6, i64 126, !6, i64 127, !17, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !21, i64 160, !22, i64 184, !15, i64 208, !15, i64 212, !14, i64 216, !14, i64 224, !14, i64 232, !15, i64 240, !15, i64 244, !17, i64 248, !18, i64 252, !18, i64 256, !6, i64 260}
!14 = !{!"any pointer", !6, i64 0}
!15 = !{!"int", !6, i64 0}
!16 = !{!"GCState", !15, i64 0, !15, i64 4, !6, i64 8, !6, i64 9, !6, i64 10, !6, i64 11, !15, i64 12, !17, i64 16, !18, i64 20, !17, i64 24, !17, i64 28, !17, i64 32, !17, i64 36, !15, i64 40, !15, i64 44, !15, i64 48, !15, i64 52}
!17 = !{!"GCRef", !15, i64 0}
!18 = !{!"MRef", !15, i64 0}
!19 = !{!"SBuf", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12}
!20 = !{!"GCstr", !17, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !15, i64 8, !15, i64 12}
!21 = !{!"Node", !6, i64 0, !6, i64 8, !18, i64 16, !18, i64 20}
!22 = !{!"GCupval", !17, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !6, i64 8, !18, i64 16, !15, i64 20}
!23 = !{!"jit_State", !24, i64 0, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !14, i64 128, !15, i64 136, !15, i64 140, !15, i64 144, !6, i64 148, !6, i64 149, !26, i64 150, !6, i64 151, !27, i64 152, !14, i64 176, !15, i64 184, !15, i64 188, !15, i64 192, !15, i64 196, !15, i64 200, !15, i64 204, !15, i64 208, !18, i64 212, !6, i64 216, !14, i64 256, !15, i64 264, !15, i64 268, !15, i64 272, !15, i64 276, !14, i64 280, !14, i64 288, !15, i64 296, !15, i64 300, !6, i64 304, !14, i64 312, !15, i64 320, !15, i64 324, !14, i64 328, !6, i64 336, !6, i64 536, !6, i64 1556, !6, i64 1616, !6, i64 1744, !15, i64 2256, !15, i64 2260, !6, i64 2264, !15, i64 2392, !28, i64 2396, !14, i64 2416, !15, i64 2424, !15, i64 2428, !14, i64 2432, !15, i64 2440, !15, i64 2444, !14, i64 2448, !14, i64 2456, !14, i64 2464, !29, i64 2472, !29, i64 2480, !6, i64 2488, !14, i64 2496, !15, i64 2504, !15, i64 2508}
!24 = !{!"GCtrace", !17, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !15, i64 8, !17, i64 12, !14, i64 16, !15, i64 24, !25, i64 28, !25, i64 30, !14, i64 32, !14, i64 40, !17, i64 48, !18, i64 52, !15, i64 56, !15, i64 60, !14, i64 64, !15, 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", !18, 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 = distinct !{!30, !9}
!31 = !{!32, !14, i64 0}
!32 = !{!"ProfileState", !14, i64 0, !14, i64 8, !14, i64 16, !19, i64 24, !15, i64 40, !15, i64 44, !15, i64 48, !33, i64 56}
!33 = !{!"sigaction", !6, i64 0, !34, i64 8, !15, i64 136, !14, i64 144}
!34 = !{!"", !6, i64 0}
!35 = !{!32, !15, i64 40}
!36 = !{!32, !14, i64 8}
!37 = !{!32, !14, i64 16}
!38 = !{!32, !15, i64 44}


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