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

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

; Function Attrs: nounwind uwtable
define hidden i32 @lj_obj_equal(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.anon, ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.anon, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = icmp eq i32 %8, %11
  br i1 %12, label %13, label %36

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.anon, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = icmp uge i32 %16, -3
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  store i32 1, ptr %3, align 4
  br label %55

19:                                               ; preds = %13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.anon, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = icmp ult i32 %22, -65537
  br i1 %23, label %35, label %24

24:                                               ; preds = %19
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.anon, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %struct.GCRef, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.anon, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.GCRef, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !9
  %33 = icmp eq i32 %28, %32
  %34 = zext i1 %33 to i32
  store i32 %34, ptr %3, align 4
  br label %55

35:                                               ; preds = %19
  br label %48

36:                                               ; preds = %2
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.anon, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = icmp ule i32 %39, -65537
  br i1 %40, label %41, label %46

41:                                               ; preds = %36
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.anon, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = icmp ule i32 %44, -65537
  br i1 %45, label %47, label %46

46:                                               ; preds = %41, %36
  store i32 0, ptr %3, align 4
  br label %55

47:                                               ; preds = %41
  br label %48

48:                                               ; preds = %47, %35
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = call double @numberVnum(ptr noundef %49)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call double @numberVnum(ptr noundef %51)
  %53 = fcmp oeq double %50, %52
  %54 = zext i1 %53 to i32
  store i32 %54, ptr %3, align 4
  br label %55

55:                                               ; preds = %48, %46, %24, %18
  %56 = load i32, ptr %3, align 4
  ret i32 %56
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden double @numberVnum(ptr noundef) #1

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 = { 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" }

!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}


; 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: nounwind uwtable
define hidden range(i32 0, 2) i32 @lj_obj_equal(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %4, %6
  br i1 %7, label %8, label %16

8:                                                ; preds = %2
  %9 = icmp ugt i32 %4, -4
  br i1 %9, label %23, label %10

10:                                               ; preds = %8
  %11 = icmp ult i32 %4, -65537
  br i1 %11, label %19, label %12

12:                                               ; preds = %10
  %13 = load i32, ptr %0, align 8, !tbaa !5
  %14 = load i32, ptr %1, align 8, !tbaa !5
  %15 = icmp eq i32 %13, %14
  br label %23

16:                                               ; preds = %2
  %17 = icmp ult i32 %4, -65536
  %18 = icmp ult i32 %6, -65536
  %or.cond = and i1 %17, %18
  br i1 %or.cond, label %19, label %23

19:                                               ; preds = %16, %10
  %20 = tail call double @numberVnum(ptr noundef nonnull %0)
  %21 = tail call double @numberVnum(ptr noundef nonnull %1)
  %22 = fcmp oeq double %20, %21
  br label %23

23:                                               ; preds = %16, %8, %19, %12
  %.0.shrunk = phi i1 [ %22, %19 ], [ %15, %12 ], [ true, %8 ], [ false, %16 ]
  %.0 = zext i1 %.0.shrunk to i32
  ret i32 %.0
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden double @numberVnum(ptr noundef) local_unnamed_addr #1

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 = { 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" }

!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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass