; LLVM IR from h2o/h2o :: deps/mruby/src (etc)

; 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.mrb_value = type { i64 }
%union.mrb_value_ = type { ptr }
%struct.RBasic = type { ptr, ptr, i32 }

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mrb_val_union(i64) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @mrb_float_id(double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @mrb_obj_id(i64 %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca %struct.mrb_value, align 8
  %4 = alloca %union.mrb_value_, align 8
  %5 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  store i64 %0, ptr %5, align 8
  %6 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = and i64 %7, 7
  %9 = icmp ne i64 %8, 0
  br i1 %9, label %53, label %10

10:                                               ; preds = %1
  %11 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %53, label %14

14:                                               ; preds = %10
  %15 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = and i64 %16, 1
  %18 = icmp eq i64 %17, 1
  br i1 %18, label %38, label %19

19:                                               ; preds = %14
  %20 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = and i64 %21, 7
  %23 = icmp ne i64 %22, 0
  br i1 %23, label %42, label %24

24:                                               ; preds = %19
  %25 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %42, label %28

28:                                               ; preds = %24
  %29 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %30 = load i64, ptr %29, align 8
  %31 = call ptr @mrb_val_union(i64 %30)
  %32 = getelementptr inbounds %union.mrb_value_, ptr %4, i32 0, i32 0
  store ptr %31, ptr %32, align 8
  %33 = load ptr, ptr %4, align 8, !tbaa !10
  %34 = getelementptr inbounds %struct.RBasic, ptr %33, i32 0, i32 2
  %35 = load i32, ptr %34, align 8
  %36 = and i32 %35, 255
  %37 = icmp eq i32 %36, 6
  br i1 %37, label %38, label %42

38:                                               ; preds = %28, %14
  %39 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %40 = load i64, ptr %39, align 8
  %41 = call i64 @mrb_integer_func(i64 %40)
  store i64 %41, ptr %2, align 8
  br label %56

42:                                               ; preds = %28, %24, %19
  %43 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %44 = load i64, ptr %43, align 8, !tbaa !5
  %45 = and i64 %44, 3
  %46 = icmp eq i64 %45, 2
  br i1 %46, label %47, label %52

47:                                               ; preds = %42
  %48 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %49 = load i64, ptr %48, align 8
  %50 = call double @mrb_word_boxing_value_float(i64 %49)
  %51 = call i64 @mrb_float_id(double noundef %50)
  store i64 %51, ptr %2, align 8
  br label %56

52:                                               ; preds = %42
  br label %53

53:                                               ; preds = %52, %10, %1
  %54 = getelementptr inbounds %struct.mrb_value, ptr %3, i32 0, i32 0
  %55 = load i64, ptr %54, align 8, !tbaa !5
  store i64 %55, ptr %2, align 8
  br label %56

56:                                               ; preds = %53, %47, %38
  %57 = load i64, ptr %2, align 8
  ret i64 %57
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @mrb_integer_func(i64) #0

; Function Attrs: nounwind uwtable
declare dso_local double @mrb_word_boxing_value_float(i64) #1

attributes #0 = { inlinehint 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 = { 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, !7, i64 0}
!6 = !{!"mrb_value", !7, i64 0}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, 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: inlinehint nounwind uwtable
declare hidden ptr @mrb_val_union(i64) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i64 @mrb_obj_id(i64 %0) local_unnamed_addr #1 {
  %2 = and i64 %0, 7
  %3 = icmp ne i64 %2, 0
  %4 = icmp eq i64 %0, 0
  %or.cond = or i1 %4, %3
  br i1 %or.cond, label %13, label %5

5:                                                ; preds = %1
  %6 = tail call ptr @mrb_val_union(i64 %0)
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load i32, ptr %7, align 8
  %9 = and i32 %8, 255
  %10 = icmp eq i32 %9, 6
  br i1 %10, label %11, label %13

11:                                               ; preds = %5
  %12 = tail call i64 @mrb_integer_func(i64 %0)
  br label %13

13:                                               ; preds = %1, %5, %11
  %.0 = phi i64 [ %12, %11 ], [ %0, %5 ], [ %0, %1 ]
  ret i64 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @mrb_integer_func(i64) local_unnamed_addr #0

attributes #0 = { inlinehint 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 = { 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)"}


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