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

; 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.CType = type { i32, i32, i16, i16, %struct.GCRef }
%struct.GCRef = type { i32 }
%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 }

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

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

; Function Attrs: nounwind uwtable
define hidden void @lj_cdata_set(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #2 {
  %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
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.CType, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = lshr i32 %13, 28
  %15 = icmp eq i32 %14, 11
  br i1 %15, label %16, label %17

16:                                               ; preds = %5
  br label %88

17:                                               ; preds = %5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.CType, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = lshr i32 %20, 28
  %22 = icmp eq i32 %21, 10
  br i1 %22, label %23, label %37

23:                                               ; preds = %17
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.CType, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = or i32 %26, %27
  %29 = and i32 %28, 33554432
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %23
  br label %88

32:                                               ; preds = %23
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  call void @lj_cconv_bf_tv(ptr noundef %33, ptr noundef %34, ptr noundef %35, ptr noundef %36)
  br label %97

37:                                               ; preds = %17
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = call ptr @ctype_child(ptr noundef %39, ptr noundef %40)
  store ptr %41, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.CType, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = and i32 %44, -260046848
  %46 = icmp eq i32 %45, 545259520
  br i1 %46, label %47, label %53

47:                                               ; preds = %38
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  store ptr %49, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = call ptr @ctype_child(ptr noundef %50, ptr noundef %51)
  store ptr %52, ptr %7, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %47, %38
  br label %54

54:                                               ; preds = %75, %53
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.CType, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 4, !tbaa !11
  %58 = lshr i32 %57, 28
  %59 = icmp eq i32 %58, 8
  br i1 %59, label %60, label %74

60:                                               ; preds = %54
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.CType, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 4, !tbaa !11
  %64 = lshr i32 %63, 16
  %65 = and i32 %64, 255
  %66 = icmp eq i32 %65, 1
  br i1 %66, label %67, label %73

67:                                               ; preds = %60
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.CType, ptr %68, i32 0, i32 1
  %70 = load i32, ptr %69, align 4, !tbaa !15
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = or i32 %71, %70
  store i32 %72, ptr %10, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %67, %60
  br label %75

74:                                               ; preds = %54
  br label %79

75:                                               ; preds = %73
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = call ptr @ctype_child(ptr noundef %76, ptr noundef %77)
  store ptr %78, ptr %7, align 8, !tbaa !5
  br label %54

79:                                               ; preds = %74
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.CType, ptr %80, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !11
  %83 = load i32, ptr %10, align 4, !tbaa !9
  %84 = or i32 %82, %83
  %85 = and i32 %84, 33554432
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %92

87:                                               ; preds = %79
  br label %88

88:                                               ; preds = %87, %31, %16
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.CTState, ptr %89, i32 0, i32 3
  %91 = load ptr, ptr %90, align 8, !tbaa !16
  call void @lj_err_caller(ptr noundef %91, i32 noundef 3581) #4
  unreachable

92:                                               ; preds = %79
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  call void @lj_cconv_ct_tv(ptr noundef %93, ptr noundef %94, ptr noundef %95, ptr noundef %96, i32 noundef 0)
  br label %97

97:                                               ; preds = %92, %32
  ret void
}

declare hidden void @lj_cconv_bf_tv(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare hidden void @lj_cconv_ct_tv(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

attributes #0 = { 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 #1 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { noreturn }

!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 = !{!12, !10, i64 0}
!12 = !{!"CType", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 10, !14, i64 12}
!13 = !{!"short", !7, i64 0}
!14 = !{!"GCRef", !10, i64 0}
!15 = !{!12, !10, i64 4}
!16 = !{!17, !6, i64 16}
!17 = !{!"CTState", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !18, i64 48, !7, i64 216}
!18 = !{!"CCallback", !7, i64 0, !7, i64 64, !6, i64 128, !6, i64 136, !6, i64 144, !10, i64 152, !10, i64 156, !10, i64 160}


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

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

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

; Function Attrs: nounwind uwtable
define hidden void @lj_cdata_set(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #2 {
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = lshr i32 %6, 28
  switch i32 %7, label %12 [
    i32 11, label %36
    i32 10, label %8
  ]

8:                                                ; preds = %5
  %9 = or i32 %6, %4
  %10 = and i32 %9, 33554432
  %.not30 = icmp eq i32 %10, 0
  br i1 %.not30, label %11, label %36

11:                                               ; preds = %8
  tail call void @lj_cconv_bf_tv(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3) #4
  br label %40

12:                                               ; preds = %5
  %13 = tail call ptr @ctype_child(ptr noundef %0, ptr noundef nonnull %1)
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = and i32 %14, -260046848
  %16 = icmp eq i32 %15, 545259520
  br i1 %16, label %17, label %20

17:                                               ; preds = %12
  %18 = load ptr, ptr %2, align 8, !tbaa !12
  %19 = tail call ptr @ctype_child(ptr noundef %0, ptr noundef nonnull %13)
  %.pre = load i32, ptr %19, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %17, %12
  %21 = phi i32 [ %.pre, %17 ], [ %14, %12 ]
  %.028 = phi ptr [ %18, %17 ], [ %2, %12 ]
  %.026 = phi ptr [ %19, %17 ], [ %13, %12 ]
  %.mask31 = and i32 %21, -268435456
  %22 = icmp eq i32 %.mask31, -2147483648
  br i1 %22, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %20, %30
  %23 = phi i32 [ %32, %30 ], [ %21, %20 ]
  %.033 = phi i32 [ %.1, %30 ], [ %4, %20 ]
  %.12732 = phi ptr [ %31, %30 ], [ %.026, %20 ]
  %24 = and i32 %23, 16711680
  %25 = icmp eq i32 %24, 65536
  br i1 %25, label %26, label %30

26:                                               ; preds = %.lr.ph
  %27 = getelementptr inbounds i8, ptr %.12732, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !14
  %29 = or i32 %28, %.033
  br label %30

30:                                               ; preds = %.lr.ph, %26
  %.1 = phi i32 [ %29, %26 ], [ %.033, %.lr.ph ]
  %31 = tail call ptr @ctype_child(ptr noundef %0, ptr noundef nonnull %.12732)
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %.mask = and i32 %32, -268435456
  %33 = icmp eq i32 %.mask, -2147483648
  br i1 %33, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %30, %20
  %.127.lcssa = phi ptr [ %.026, %20 ], [ %31, %30 ]
  %.0.lcssa = phi i32 [ %4, %20 ], [ %.1, %30 ]
  %.lcssa = phi i32 [ %21, %20 ], [ %32, %30 ]
  %34 = or i32 %.lcssa, %.0.lcssa
  %35 = and i32 %34, 33554432
  %.not = icmp eq i32 %35, 0
  br i1 %.not, label %39, label %36

36:                                               ; preds = %5, %._crit_edge, %8
  %37 = getelementptr inbounds i8, ptr %0, i64 16
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  tail call void @lj_err_caller(ptr noundef %38, i32 noundef 3581) #5
  unreachable

39:                                               ; preds = %._crit_edge
  tail call void @lj_cconv_ct_tv(ptr noundef %0, ptr noundef nonnull %.127.lcssa, ptr noundef %.028, ptr noundef %3, i32 noundef 0) #4
  br label %40

40:                                               ; preds = %39, %11
  ret void
}

declare hidden void @lj_cconv_bf_tv(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare hidden void @lj_cconv_ct_tv(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { "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 }
attributes #5 = { noreturn nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"CType", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 10, !11, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"GCRef", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!6, !7, i64 4}
!15 = !{!16, !13, i64 16}
!16 = !{!"CTState", !13, i64 0, !7, i64 8, !7, i64 12, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !17, i64 48, !8, i64 216}
!17 = !{!"CCallback", !8, i64 0, !8, i64 64, !13, i64 128, !13, i64 136, !13, i64 144, !7, i64 152, !7, i64 156, !7, i64 160}


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