; 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 }
%struct.RData = type { ptr, ptr, i32, ptr, ptr, ptr }
%struct.mrb_data_type = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @mrb_data_check_type(ptr noundef %0, i64 %1, ptr noundef %2) #1 {
  %4 = alloca %struct.mrb_value, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %union.mrb_value_, align 8
  %8 = alloca %union.mrb_value_, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %union.mrb_value_, align 8
  %11 = getelementptr inbounds %struct.mrb_value, ptr %4, i32 0, i32 0
  store i64 %1, ptr %11, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.mrb_value, ptr %4, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = and i64 %13, 7
  %15 = icmp ne i64 %14, 0
  br i1 %15, label %30, label %16

16:                                               ; preds = %3
  %17 = getelementptr inbounds %struct.mrb_value, ptr %4, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %30, label %20

20:                                               ; preds = %16
  %21 = getelementptr inbounds %struct.mrb_value, ptr %4, i32 0, i32 0
  %22 = load i64, ptr %21, align 8
  %23 = call ptr @mrb_val_union(i64 %22)
  %24 = getelementptr inbounds %union.mrb_value_, ptr %7, i32 0, i32 0
  store ptr %23, ptr %24, align 8
  %25 = load ptr, ptr %7, align 8, !tbaa !12
  %26 = getelementptr inbounds %struct.RBasic, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 8
  %28 = and i32 %27, 255
  %29 = icmp eq i32 %28, 20
  br i1 %29, label %34, label %30

30:                                               ; preds = %20, %16, %3
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mrb_value, ptr %4, i32 0, i32 0
  %33 = load i64, ptr %32, align 8
  call void @mrb_check_type(ptr noundef %31, i64 %33, i32 noundef 20)
  br label %34

34:                                               ; preds = %30, %20
  %35 = getelementptr inbounds %struct.mrb_value, ptr %4, i32 0, i32 0
  %36 = load i64, ptr %35, align 8
  %37 = call ptr @mrb_val_union(i64 %36)
  %38 = getelementptr inbounds %union.mrb_value_, ptr %8, i32 0, i32 0
  store ptr %37, ptr %38, align 8
  %39 = load ptr, ptr %8, align 8, !tbaa !12
  %40 = getelementptr inbounds %struct.RData, ptr %39, i32 0, i32 4
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = icmp ne ptr %41, %42
  br i1 %43, label %44, label %77

44:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %45 = getelementptr inbounds %struct.mrb_value, ptr %4, i32 0, i32 0
  %46 = load i64, ptr %45, align 8
  %47 = call ptr @mrb_val_union(i64 %46)
  %48 = getelementptr inbounds %union.mrb_value_, ptr %10, i32 0, i32 0
  store ptr %47, ptr %48, align 8
  %49 = load ptr, ptr %10, align 8, !tbaa !12
  %50 = getelementptr inbounds %struct.RData, ptr %49, i32 0, i32 4
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  store ptr %51, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %66

54:                                               ; preds = %44
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = call i32 @mrb_intern_static(ptr noundef %57, ptr noundef @.str, i64 noundef 9)
  %59 = call ptr @mrb_exc_get_id(ptr noundef %56, i32 noundef %58)
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.mrb_data_type, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.mrb_data_type, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  call void (ptr, ptr, ptr, ...) @mrb_raisef(ptr noundef %55, ptr noundef %59, ptr noundef @.str.1, ptr noundef %62, ptr noundef %65) #6
  unreachable

66:                                               ; preds = %44
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = call i32 @mrb_intern_static(ptr noundef %69, ptr noundef @.str, i64 noundef 9)
  %71 = call ptr @mrb_exc_get_id(ptr noundef %68, i32 noundef %70)
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mrb_data_type, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !16
  %75 = getelementptr inbounds %struct.mrb_value, ptr %4, i32 0, i32 0
  %76 = load i64, ptr %75, align 8
  call void (ptr, ptr, ptr, ...) @mrb_raisef(ptr noundef %67, ptr noundef %71, ptr noundef @.str.2, i64 %76, ptr noundef %74) #6
  unreachable

77:                                               ; preds = %34
  ret void
}

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

declare void @mrb_check_type(ptr noundef, i64, i32 noundef) #3

; Function Attrs: noreturn
declare void @mrb_raisef(ptr noundef, ptr noundef, ptr noundef, ...) #4

declare ptr @mrb_exc_get_id(ptr noundef, i32 noundef) #3

declare i32 @mrb_intern_static(ptr noundef, ptr noundef, i64 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 = { 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 #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 "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 #5 = { nounwind }
attributes #6 = { 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, !11, i64 0}
!10 = !{!"mrb_value", !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !6, i64 32}
!14 = !{!"RData", !6, i64 0, !6, i64 8, !15, i64 16, !15, i64 17, !15, i64 17, !6, i64 24, !6, i64 32, !6, i64 40}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !6, i64 0}
!17 = !{!"mrb_data_type", !6, i64 0, !6, i64 8}


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

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1

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

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

13:                                               ; preds = %7, %3
  tail call void @mrb_check_type(ptr noundef %0, i64 %1, i32 noundef 20) #4
  br label %14

14:                                               ; preds = %13, %7
  %15 = tail call ptr @mrb_val_union(i64 %1)
  %16 = getelementptr inbounds i8, ptr %15, i64 32
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %.not = icmp eq ptr %17, %2
  br i1 %.not, label %29, label %18

18:                                               ; preds = %14
  %19 = tail call ptr @mrb_val_union(i64 %1)
  %20 = getelementptr inbounds i8, ptr %19, i64 32
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %.not25 = icmp eq ptr %21, null
  %22 = tail call i32 @mrb_intern_static(ptr noundef %0, ptr noundef nonnull @.str, i64 noundef 9) #4
  %23 = tail call ptr @mrb_exc_get_id(ptr noundef %0, i32 noundef %22) #4
  br i1 %.not25, label %27, label %24

24:                                               ; preds = %18
  %25 = load ptr, ptr %21, align 8, !tbaa !11
  %26 = load ptr, ptr %2, align 8, !tbaa !11
  tail call void (ptr, ptr, ptr, ...) @mrb_raisef(ptr noundef %0, ptr noundef %23, ptr noundef nonnull @.str.1, ptr noundef %25, ptr noundef %26) #5
  unreachable

27:                                               ; preds = %18
  %28 = load ptr, ptr %2, align 8, !tbaa !11
  tail call void (ptr, ptr, ptr, ...) @mrb_raisef(ptr noundef %0, ptr noundef %23, ptr noundef nonnull @.str.2, i64 %1, ptr noundef %28) #5
  unreachable

29:                                               ; preds = %14
  ret void
}

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

declare void @mrb_check_type(ptr noundef, i64, i32 noundef) local_unnamed_addr #2

; Function Attrs: noreturn
declare void @mrb_raisef(ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #3

declare ptr @mrb_exc_get_id(ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @mrb_intern_static(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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 = { 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 #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 = { 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 #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 32}
!6 = !{!"RData", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 17, !10, i64 17, !7, i64 24, !7, i64 32, !7, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"mrb_data_type", !7, i64 0, !7, i64 8}


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