; LLVM IR from facebook/hermes :: API/hermes_sandbox/external (hermes_sandbox_impl_compiled_6)

; 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.w2c_hermes = type { ptr, ptr, ptr, i32, i32, i32, %struct.wasm_rt_memory_t, %struct.wasm_rt_funcref_table_t }
%struct.wasm_rt_memory_t = type { ptr, i64, i64, i64, i8 }
%struct.wasm_rt_funcref_table_t = type { ptr, i32, i32 }
%struct.wasm_rt_funcref_t = type { ptr, ptr, ptr }

@w2c_hermes_t3 = external constant ptr, align 8

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @func_types_eq(ptr noundef, ptr noundef) #1

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

; Function Attrs: noreturn
declare void @wasm_rt_trap(i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_std0x3A0x3A_0x5F20x3A0x3A_0x5Fshared_count0x3A0x3A_0x5Frelease_shared0x5Babi0x3Av150070x5D0x280x29(ptr noundef %0, i32 noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %8 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %8, ptr %6, align 4, !tbaa !9
  store i32 4, ptr %7, align 4, !tbaa !9
  %9 = load i32, ptr %7, align 4, !tbaa !9
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = add i32 %10, %9
  store i32 %11, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = call i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A_0x5Flibcpp_atomic_refcount_decrement0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x260x29(ptr noundef %12, i32 noundef %13)
  store i32 %14, ptr %6, align 4, !tbaa !9
  %15 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %15, ptr %5, align 4, !tbaa !9
  store i32 -1, ptr %7, align 4, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = icmp eq i32 %16, %17
  %19 = zext i1 %18 to i32
  store i32 %19, ptr %6, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %97

22:                                               ; preds = %2
  %23 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %23, ptr %6, align 4, !tbaa !9
  %24 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %24, ptr %7, align 4, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.w2c_hermes, ptr %25, i32 0, i32 6
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = call i32 @i32_load(ptr noundef %26, i64 noundef %28)
  store i32 %29, ptr %7, align 4, !tbaa !9
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.w2c_hermes, ptr %30, i32 0, i32 6
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = zext i32 %32 to i64
  %34 = add i64 %33, 8
  %35 = call i32 @i32_load(ptr noundef %31, i64 noundef %34)
  store i32 %35, ptr %7, align 4, !tbaa !9
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.w2c_hermes, ptr %37, i32 0, i32 7
  %39 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %38, i32 0, i32 2
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = icmp ult i32 %36, %40
  br i1 %41, label %42, label %65

42:                                               ; preds = %22
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.w2c_hermes, ptr %43, i32 0, i32 7
  %45 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %46, i64 %48
  %50 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !18
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %65

53:                                               ; preds = %42
  %54 = load ptr, ptr @w2c_hermes_t3, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.w2c_hermes, ptr %55, i32 0, i32 7
  %57 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !17
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %58, i64 %60
  %62 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  %64 = call zeroext i1 @func_types_eq(ptr noundef %54, ptr noundef %63)
  br label %65

65:                                               ; preds = %53, %42, %22
  %66 = phi i1 [ false, %42 ], [ false, %22 ], [ %64, %53 ]
  %67 = xor i1 %66, true
  %68 = xor i1 %67, true
  %69 = zext i1 %68 to i32
  %70 = sext i32 %69 to i64
  %71 = call i64 @llvm.expect.i64(i64 %70, i64 1)
  %72 = icmp ne i64 %71, 0
  br i1 %72, label %75, label %73

73:                                               ; preds = %65
  call void @wasm_rt_trap(i32 noundef 6) #6
  unreachable

74:                                               ; No predecessors!
  br label %75

75:                                               ; preds = %74, %65
  %76 = phi i1 [ true, %65 ], [ false, %74 ]
  %77 = zext i1 %76 to i32
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.w2c_hermes, ptr %78, i32 0, i32 7
  %80 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !17
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %81, i64 %83
  %85 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !18
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.w2c_hermes, ptr %87, i32 0, i32 7
  %89 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !17
  %91 = load i32, ptr %7, align 4, !tbaa !9
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %90, i64 %92
  %94 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !21
  %96 = load i32, ptr %6, align 4, !tbaa !9
  call void %86(ptr noundef %95, i32 noundef %96)
  br label %97

97:                                               ; preds = %75, %2
  %98 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %98, ptr %6, align 4, !tbaa !9
  store i32 -1, ptr %7, align 4, !tbaa !9
  %99 = load i32, ptr %6, align 4, !tbaa !9
  %100 = load i32, ptr %7, align 4, !tbaa !9
  %101 = icmp eq i32 %99, %100
  %102 = zext i1 %101 to i32
  store i32 %102, ptr %6, align 4, !tbaa !9
  %103 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret i32 %103
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A_0x5Flibcpp_atomic_refcount_decrement0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x260x29(ptr noundef, i32 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 92}
!12 = !{!"w2c_hermes", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !13, i64 40, !16, i64 80}
!13 = !{!"", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !15, i64 32}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12}
!17 = !{!12, !6, i64 80}
!18 = !{!19, !6, i64 8}
!19 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!19, !6, i64 0}
!21 = !{!19, !6, i64 16}


; 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.wasm_rt_funcref_t = type { ptr, ptr, ptr }

@w2c_hermes_t3 = external local_unnamed_addr constant ptr, align 8

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @func_types_eq(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: noreturn
declare void @wasm_rt_trap(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @w2c_hermes_std0x3A0x3A_0x5F20x3A0x3A_0x5Fshared_count0x3A0x3A_0x5Frelease_shared0x5Babi0x3Av150070x5D0x280x29(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = add i32 %1, 4
  %4 = tail call i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A_0x5Flibcpp_atomic_refcount_decrement0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x260x29(ptr noundef %0, i32 noundef %3)
  %5 = icmp eq i32 %4, -1
  br i1 %5, label %6, label %34

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = zext i32 %1 to i64
  %9 = tail call i32 @i32_load(ptr noundef nonnull %7, i64 noundef %8)
  %10 = zext i32 %9 to i64
  %11 = add nuw nsw i64 %10, 8
  %12 = tail call i32 @i32_load(ptr noundef nonnull %7, i64 noundef %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 80
  %14 = getelementptr inbounds i8, ptr %0, i64 92
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp ult i32 %12, %15
  br i1 %16, label %17, label %.critedge, !prof !15

17:                                               ; preds = %6
  %18 = load ptr, ptr %13, align 8, !tbaa !16
  %19 = zext i32 %12 to i64
  %20 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %18, i64 %19
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %.not = icmp eq ptr %22, null
  br i1 %.not, label %.critedge, label %23, !prof !19

23:                                               ; preds = %17
  %24 = load ptr, ptr @w2c_hermes_t3, align 8, !tbaa !20
  %25 = load ptr, ptr %20, align 8, !tbaa !21
  %26 = tail call zeroext i1 @func_types_eq(ptr noundef %24, ptr noundef %25)
  br i1 %26, label %27, label %.critedge, !prof !15

.critedge:                                        ; preds = %17, %6, %23
  tail call void @wasm_rt_trap(i32 noundef 6) #3
  unreachable

27:                                               ; preds = %23
  %28 = load ptr, ptr %13, align 8, !tbaa !16
  %29 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %28, i64 %19
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = getelementptr inbounds i8, ptr %29, i64 16
  %33 = load ptr, ptr %32, align 8, !tbaa !22
  tail call void %31(ptr noundef %33, i32 noundef %1) #4
  br label %34

34:                                               ; preds = %27, %2
  %35 = zext i1 %5 to i32
  ret i32 %35
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A_0x5Flibcpp_atomic_refcount_decrement0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x260x29(ptr noundef, i32 noundef) local_unnamed_addr #2

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 = { 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 = { noreturn nounwind }
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, !10, i64 92}
!6 = !{!"w2c_hermes", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !11, i64 40, !14, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !7, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !13, i64 32}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12}
!15 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!16 = !{!6, !7, i64 80}
!17 = !{!18, !7, i64 8}
!18 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!19 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!20 = !{!7, !7, i64 0}
!21 = !{!18, !7, i64 0}
!22 = !{!18, !7, i64 16}


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