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

; 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.CCallState = type { ptr, i32, i8, i8, i8, i8, [8 x %union.FPRArg], [6 x i64], [32 x i64] }
%union.FPRArg = type { [2 x double] }
%union.TValue = type { i64 }
%struct.GCcdata = type { %struct.GCRef, i8, i8, i16 }
%struct.GCRef = type { i32 }
%struct.CType = type { i32, i32, i16, i16, %struct.GCRef }
%struct.CTState = type { ptr, i32, i32, ptr, ptr, ptr, ptr, %struct.CCallback, [128 x i16] }
%struct.CCallback = type { [8 x %union.FPRCBArg], [8 x i64], ptr, ptr, ptr, i32, i32, i32 }
%union.FPRCBArg = type { double }
%struct.anon = type { %union.anon, i32 }
%union.anon = type { %struct.GCRef }
%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.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.2, %struct.MRef, i32 }
%union.anon.2 = 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
define hidden i32 @lj_ccall_func(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.CCallState, align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %union.TValue, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call ptr @ctype_cts(ptr noundef %14)
  store ptr %15, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.GCcdata, ptr %17, i32 0, i32 3
  %19 = load i16, ptr %18, align 2, !tbaa !9
  %20 = zext i16 %19 to i32
  %21 = call ptr @ctype_raw(ptr noundef %16, i32 noundef %20)
  store ptr %21, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 8, ptr %8, align 4, !tbaa !14
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.CType, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !15
  %25 = lshr i32 %24, 28
  %26 = icmp eq i32 %25, 2
  br i1 %26, label %27, label %34

27:                                               ; preds = %2
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.CType, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !17
  store i32 %30, ptr %8, align 4, !tbaa !14
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = call ptr @ctype_rawchild(ptr noundef %31, ptr noundef %32)
  store ptr %33, ptr %7, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %27, %2
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.CType, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 4, !tbaa !15
  %38 = lshr i32 %37, 28
  %39 = icmp eq i32 %38, 6
  br i1 %39, label %40, label %128

40:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 448, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.GCcdata, ptr %41, i64 1
  %43 = load i32, ptr %8, align 4, !tbaa !14
  %44 = call ptr @cdata_getptr(ptr noundef %42, i32 noundef %43)
  %45 = getelementptr inbounds %struct.CCallState, ptr %9, i32 0, i32 0
  store ptr %44, ptr %45, align 16, !tbaa !18
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = call i32 @ccall_set_args(ptr noundef %46, ptr noundef %47, ptr noundef %48, ptr noundef %9)
  store i32 %49, ptr %10, align 4, !tbaa !14
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = ptrtoint ptr %50 to i64
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.CTState, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !20
  %55 = ptrtoint ptr %54 to i64
  %56 = sub nsw i64 %51, %55
  %57 = inttoptr i64 %56 to ptr
  store ptr %57, ptr %7, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.CTState, ptr %58, i32 0, i32 7
  %60 = getelementptr inbounds %struct.CCallback, ptr %59, i32 0, i32 7
  store i32 -1, ptr %60, align 8, !tbaa !23
  call void @lj_vm_ffi_call(ptr noundef %9)
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.CTState, ptr %61, i32 0, i32 7
  %63 = getelementptr inbounds %struct.CCallback, ptr %62, i32 0, i32 7
  %64 = load i32, ptr %63, align 8, !tbaa !23
  %65 = icmp ne i32 %64, -1
  br i1 %65, label %66, label %75

66:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %67 = getelementptr inbounds %struct.CCallState, ptr %9, i32 0, i32 0
  %68 = load ptr, ptr %67, align 16, !tbaa !18
  call void @setlightudV(ptr noundef %12, ptr noundef %68)
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.CTState, ptr %70, i32 0, i32 6
  %72 = load ptr, ptr %71, align 8, !tbaa !24
  %73 = call ptr @lj_tab_set(ptr noundef %69, ptr noundef %72, ptr noundef %12)
  %74 = getelementptr inbounds %struct.anon, ptr %73, i32 0, i32 1
  store i32 -3, ptr %74, align 4, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %75

75:                                               ; preds = %66, %40
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = ptrtoint ptr %76 to i64
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.CTState, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !20
  %81 = ptrtoint ptr %80 to i64
  %82 = add nsw i64 %77, %81
  %83 = inttoptr i64 %82 to ptr
  store ptr %83, ptr %7, align 8, !tbaa !5
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = call i32 @ccall_get_results(ptr noundef %84, ptr noundef %85, ptr noundef %86, ptr noundef %9, ptr noundef %11)
  %88 = load i32, ptr %10, align 4, !tbaa !14
  %89 = add nsw i32 %88, %87
  store i32 %89, ptr %10, align 4, !tbaa !14
  br label %90

90:                                               ; preds = %125, %75
  %91 = load i32, ptr %10, align 4, !tbaa !14
  %92 = add nsw i32 %91, -1
  store i32 %92, ptr %10, align 4, !tbaa !14
  %93 = icmp sgt i32 %91, 0
  br i1 %93, label %94, label %126

94:                                               ; preds = %90
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.lua_State, ptr %95, i32 0, i32 0
  %97 = getelementptr inbounds %struct.anon.5, ptr %96, i32 0, i32 5
  %98 = getelementptr inbounds %struct.MRef, ptr %97, i32 0, i32 0
  %99 = load i32, ptr %98, align 8, !tbaa !25
  %100 = zext i32 %99 to i64
  %101 = inttoptr i64 %100 to ptr
  %102 = getelementptr inbounds %struct.global_State, ptr %101, i32 0, i32 5
  %103 = getelementptr inbounds %struct.GCState, ptr %102, i32 0, i32 0
  %104 = load i32, ptr %103, align 8, !tbaa !26
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.lua_State, ptr %105, i32 0, i32 0
  %107 = getelementptr inbounds %struct.anon.5, 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 !25
  %110 = zext i32 %109 to i64
  %111 = inttoptr i64 %110 to ptr
  %112 = getelementptr inbounds %struct.global_State, ptr %111, i32 0, i32 5
  %113 = getelementptr inbounds %struct.GCState, ptr %112, i32 0, i32 1
  %114 = load i32, ptr %113, align 4, !tbaa !34
  %115 = icmp uge i32 %104, %114
  %116 = xor i1 %115, true
  %117 = xor i1 %116, true
  %118 = zext i1 %117 to i32
  %119 = sext i32 %118 to i64
  %120 = call i64 @llvm.expect.i64(i64 %119, i64 0)
  %121 = icmp ne i64 %120, 0
  br i1 %121, label %122, label %125

122:                                              ; preds = %94
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  %124 = call i32 @lj_gc_step(ptr noundef %123)
  br label %125

125:                                              ; preds = %122, %94
  br label %90, !llvm.loop !35

126:                                              ; preds = %90
  %127 = load i32, ptr %11, align 4, !tbaa !14
  store i32 %127, ptr %3, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 448, ptr %9) #5
  br label %129

128:                                              ; preds = %34
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %129

129:                                              ; preds = %128, %126
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %130 = load i32, ptr %3, align 4
  ret i32 %130
}

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

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

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

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

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

declare hidden void @lj_vm_ffi_call(ptr noundef) #3

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

declare hidden ptr @lj_tab_set(ptr noundef, ptr noundef, ptr noundef) #3

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

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

declare hidden i32 @lj_gc_step(ptr 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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = !{!10, !13, i64 6}
!10 = !{!"GCcdata", !11, i64 0, !7, i64 4, !7, i64 5, !13, i64 6}
!11 = !{!"GCRef", !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{!16, !12, i64 0}
!16 = !{!"CType", !12, i64 0, !12, i64 4, !13, i64 8, !13, i64 10, !11, i64 12}
!17 = !{!16, !12, i64 4}
!18 = !{!19, !6, i64 0}
!19 = !{!"CCallState", !6, i64 0, !12, i64 8, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 144, !7, i64 192}
!20 = !{!21, !6, i64 0}
!21 = !{!"CTState", !6, i64 0, !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !22, i64 48, !7, i64 216}
!22 = !{!"CCallback", !7, i64 0, !7, i64 64, !6, i64 128, !6, i64 136, !6, i64 144, !12, i64 152, !12, i64 156, !12, i64 160}
!23 = !{!21, !12, i64 208}
!24 = !{!21, !6, i64 40}
!25 = !{!7, !7, i64 0}
!26 = !{!27, !12, i64 32}
!27 = !{!"global_State", !6, i64 0, !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24, !28, i64 32, !12, i64 88, !30, i64 92, !31, i64 108, !7, i64 124, !7, i64 125, !7, i64 126, !7, i64 127, !11, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !32, i64 160, !33, i64 184, !12, i64 208, !12, i64 212, !6, i64 216, !6, i64 224, !6, i64 232, !12, i64 240, !12, i64 244, !11, i64 248, !29, i64 252, !29, i64 256, !7, i64 260}
!28 = !{!"GCState", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !12, i64 12, !11, i64 16, !29, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52}
!29 = !{!"MRef", !12, i64 0}
!30 = !{!"SBuf", !29, i64 0, !29, i64 4, !29, i64 8, !29, i64 12}
!31 = !{!"GCstr", !11, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !12, i64 8, !12, i64 12}
!32 = !{!"Node", !7, i64 0, !7, i64 8, !29, i64 16, !29, i64 20}
!33 = !{!"GCupval", !11, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !29, i64 16, !12, i64 20}
!34 = !{!27, !12, i64 36}
!35 = distinct !{!35, !36}
!36 = !{!"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"

%struct.CCallState = type { ptr, i32, i8, i8, i8, i8, [8 x %union.FPRArg], [6 x i64], [32 x i64] }
%union.FPRArg = type { [2 x double] }
%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
define hidden i32 @lj_ccall_func(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca %struct.CCallState, align 16
  %4 = alloca i32, align 4
  %5 = alloca %union.TValue, align 8
  %6 = tail call ptr @ctype_cts(ptr noundef %0)
  %7 = getelementptr inbounds i8, ptr %1, i64 6
  %8 = load i16, ptr %7, align 2, !tbaa !5
  %9 = zext i16 %8 to i32
  %10 = tail call ptr @ctype_raw(ptr noundef %6, i32 noundef %9)
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %.mask = and i32 %11, -268435456
  %12 = icmp eq i32 %.mask, 536870912
  br i1 %12, label %13, label %17

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %10, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !14
  %16 = tail call ptr @ctype_rawchild(ptr noundef %6, ptr noundef nonnull %10)
  %.pre = load i32, ptr %16, align 4, !tbaa !12
  br label %17

17:                                               ; preds = %13, %2
  %18 = phi i32 [ %.pre, %13 ], [ %11, %2 ]
  %.030 = phi ptr [ %16, %13 ], [ %10, %2 ]
  %.029 = phi i32 [ %15, %13 ], [ 8, %2 ]
  %.mask32 = and i32 %18, -268435456
  %19 = icmp eq i32 %.mask32, 1610612736
  br i1 %19, label %20, label %59

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 448, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %21 = getelementptr inbounds i8, ptr %1, i64 8
  %22 = tail call ptr @cdata_getptr(ptr noundef nonnull %21, i32 noundef %.029)
  store ptr %22, ptr %3, align 16, !tbaa !15
  %23 = call i32 @ccall_set_args(ptr noundef %0, ptr noundef %6, ptr noundef nonnull %.030, ptr noundef nonnull %3)
  %24 = ptrtoint ptr %.030 to i64
  %25 = load ptr, ptr %6, align 8, !tbaa !18
  %26 = ptrtoint ptr %25 to i64
  %27 = sub i64 %24, %26
  %28 = getelementptr inbounds i8, ptr %6, i64 208
  store i32 -1, ptr %28, align 8, !tbaa !21
  call void @lj_vm_ffi_call(ptr noundef nonnull %3) #4
  %29 = load i32, ptr %28, align 8, !tbaa !21
  %.not = icmp eq i32 %29, -1
  br i1 %.not, label %36, label %30

30:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %31 = load ptr, ptr %3, align 16, !tbaa !15
  call void @setlightudV(ptr noundef nonnull %5, ptr noundef %31)
  %32 = getelementptr inbounds i8, ptr %6, i64 40
  %33 = load ptr, ptr %32, align 8, !tbaa !22
  %34 = call ptr @lj_tab_set(ptr noundef %0, ptr noundef %33, ptr noundef nonnull %5) #4
  %35 = getelementptr inbounds i8, ptr %34, i64 4
  store i32 -3, ptr %35, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %36

36:                                               ; preds = %30, %20
  %37 = load ptr, ptr %6, align 8, !tbaa !18
  %38 = ptrtoint ptr %37 to i64
  %39 = add nsw i64 %27, %38
  %40 = inttoptr i64 %39 to ptr
  %41 = call i32 @ccall_get_results(ptr noundef %0, ptr noundef nonnull %6, ptr noundef %40, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %42 = add nsw i32 %41, %23
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %36
  %44 = getelementptr inbounds i8, ptr %0, i64 8
  br label %45

45:                                               ; preds = %.lr.ph, %56
  %.in = phi i32 [ %42, %.lr.ph ], [ %46, %56 ]
  %46 = add nsw i32 %.in, -1
  %47 = load i32, ptr %44, align 8, !tbaa !23
  %48 = zext i32 %47 to i64
  %49 = inttoptr i64 %48 to ptr
  %50 = getelementptr inbounds i8, ptr %49, i64 32
  %51 = load i32, ptr %50, align 8, !tbaa !24
  %52 = getelementptr inbounds i8, ptr %49, i64 36
  %53 = load i32, ptr %52, align 4, !tbaa !32
  %.not33 = icmp ult i32 %51, %53
  br i1 %.not33, label %56, label %54, !prof !33

54:                                               ; preds = %45
  %55 = call i32 @lj_gc_step(ptr noundef nonnull %0) #4
  br label %56

56:                                               ; preds = %54, %45
  %57 = icmp ugt i32 %.in, 1
  br i1 %57, label %45, label %._crit_edge, !llvm.loop !34

._crit_edge:                                      ; preds = %56, %36
  %58 = load i32, ptr %4, align 4, !tbaa !36
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 448, ptr nonnull %3) #4
  br label %59

59:                                               ; preds = %17, %._crit_edge
  %.031 = phi i32 [ %58, %._crit_edge ], [ -1, %17 ]
  ret i32 %.031
}

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

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

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

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

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

declare hidden void @lj_vm_ffi_call(ptr noundef) local_unnamed_addr #3

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

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

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

declare hidden i32 @lj_gc_step(ptr noundef) local_unnamed_addr #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 = { 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, !11, i64 6}
!6 = !{!"GCcdata", !7, i64 0, !9, i64 4, !9, i64 5, !11, i64 6}
!7 = !{!"GCRef", !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"short", !9, i64 0}
!12 = !{!13, !8, i64 0}
!13 = !{!"CType", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 10, !7, i64 12}
!14 = !{!13, !8, i64 4}
!15 = !{!16, !17, i64 0}
!16 = !{!"CCallState", !17, i64 0, !8, i64 8, !9, i64 12, !9, i64 13, !9, i64 14, !9, i64 15, !9, i64 16, !9, i64 144, !9, i64 192}
!17 = !{!"any pointer", !9, i64 0}
!18 = !{!19, !17, i64 0}
!19 = !{!"CTState", !17, i64 0, !8, i64 8, !8, i64 12, !17, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !20, i64 48, !9, i64 216}
!20 = !{!"CCallback", !9, i64 0, !9, i64 64, !17, i64 128, !17, i64 136, !17, i64 144, !8, i64 152, !8, i64 156, !8, i64 160}
!21 = !{!19, !8, i64 208}
!22 = !{!19, !17, i64 40}
!23 = !{!9, !9, i64 0}
!24 = !{!25, !8, i64 32}
!25 = !{!"global_State", !17, i64 0, !8, i64 8, !8, i64 12, !17, i64 16, !17, i64 24, !26, i64 32, !8, i64 88, !28, i64 92, !29, i64 108, !9, i64 124, !9, i64 125, !9, i64 126, !9, i64 127, !7, i64 128, !9, i64 136, !9, i64 144, !9, i64 152, !30, i64 160, !31, i64 184, !8, i64 208, !8, i64 212, !17, i64 216, !17, i64 224, !17, i64 232, !8, i64 240, !8, i64 244, !7, i64 248, !27, i64 252, !27, i64 256, !9, i64 260}
!26 = !{!"GCState", !8, i64 0, !8, i64 4, !9, i64 8, !9, i64 9, !9, i64 10, !9, i64 11, !8, i64 12, !7, i64 16, !27, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !8, i64 40, !8, i64 44, !8, i64 48, !8, i64 52}
!27 = !{!"MRef", !8, i64 0}
!28 = !{!"SBuf", !27, i64 0, !27, i64 4, !27, i64 8, !27, i64 12}
!29 = !{!"GCstr", !7, i64 0, !9, i64 4, !9, i64 5, !9, i64 6, !9, i64 7, !8, i64 8, !8, i64 12}
!30 = !{!"Node", !9, i64 0, !9, i64 8, !27, i64 16, !27, i64 20}
!31 = !{!"GCupval", !7, i64 0, !9, i64 4, !9, i64 5, !9, i64 6, !9, i64 7, !9, i64 8, !27, i64 16, !8, i64 20}
!32 = !{!25, !8, i64 36}
!33 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = !{!8, !8, i64 0}


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