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

; 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: 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 i32 @i32_load(ptr noundef, i64 noundef) #1

; 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 void @w2c_hermes_std0x3A0x3A_0x5F20x3A0x3A_0x5Fshared_weak_count0x3A0x3A_0x5Frelease_weak0x280x29(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) #6
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %8 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %8, ptr %6, align 4, !tbaa !9
  store i32 8, 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 i32, ptr %6, align 4, !tbaa !9
  store i32 %12, ptr %5, align 4, !tbaa !9
  store i32 2, ptr %7, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = call i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A0x28anonymous0x20namespace0x290x3A0x3A_0x5Flibcpp_atomic_load0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x20const0x2A0x2C0x20int0x29(ptr noundef %13, i32 noundef %14, i32 noundef %15)
  store i32 %16, ptr %6, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %32

19:                                               ; preds = %2
  %20 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %20, ptr %6, align 4, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = call i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A_0x5Flibcpp_atomic_refcount_decrement0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x260x29(ptr noundef %21, i32 noundef %22)
  store i32 %23, ptr %6, align 4, !tbaa !9
  store i32 -1, ptr %7, align 4, !tbaa !9
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = icmp ne i32 %24, %25
  %27 = zext i1 %26 to i32
  store i32 %27, ptr %6, align 4, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %19
  br label %107

31:                                               ; preds = %19
  br label %32

32:                                               ; preds = %31, %2
  %33 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %33, ptr %6, align 4, !tbaa !9
  %34 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %34, ptr %7, align 4, !tbaa !9
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.w2c_hermes, ptr %35, i32 0, i32 6
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = call i32 @i32_load(ptr noundef %36, i64 noundef %38)
  store i32 %39, ptr %7, align 4, !tbaa !9
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.w2c_hermes, ptr %40, i32 0, i32 6
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = add i64 %43, 16
  %45 = call i32 @i32_load(ptr noundef %41, i64 noundef %44)
  store i32 %45, ptr %7, align 4, !tbaa !9
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.w2c_hermes, ptr %47, i32 0, i32 7
  %49 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = icmp ult i32 %46, %50
  br i1 %51, label %52, label %75

52:                                               ; preds = %32
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.w2c_hermes, ptr %53, i32 0, i32 7
  %55 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %75

63:                                               ; preds = %52
  %64 = load ptr, ptr @w2c_hermes_t3, align 8, !tbaa !5
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.w2c_hermes, ptr %65, i32 0, i32 7
  %67 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !17
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %68, i64 %70
  %72 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !20
  %74 = call zeroext i1 @func_types_eq(ptr noundef %64, ptr noundef %73)
  br label %75

75:                                               ; preds = %63, %52, %32
  %76 = phi i1 [ false, %52 ], [ false, %32 ], [ %74, %63 ]
  %77 = xor i1 %76, true
  %78 = xor i1 %77, true
  %79 = zext i1 %78 to i32
  %80 = sext i32 %79 to i64
  %81 = call i64 @llvm.expect.i64(i64 %80, i64 1)
  %82 = icmp ne i64 %81, 0
  br i1 %82, label %85, label %83

83:                                               ; preds = %75
  call void @wasm_rt_trap(i32 noundef 6) #7
  unreachable

84:                                               ; No predecessors!
  br label %85

85:                                               ; preds = %84, %75
  %86 = phi i1 [ true, %75 ], [ false, %84 ]
  %87 = zext i1 %86 to i32
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.w2c_hermes, ptr %88, i32 0, i32 7
  %90 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !17
  %92 = load i32, ptr %7, align 4, !tbaa !9
  %93 = zext i32 %92 to i64
  %94 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %91, i64 %93
  %95 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %94, i32 0, i32 1
  %96 = load ptr, ptr %95, align 8, !tbaa !18
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.w2c_hermes, ptr %97, i32 0, i32 7
  %99 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !17
  %101 = load i32, ptr %7, align 4, !tbaa !9
  %102 = zext i32 %101 to i64
  %103 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %100, i64 %102
  %104 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %103, i32 0, i32 2
  %105 = load ptr, ptr %104, align 8, !tbaa !21
  %106 = load i32, ptr %6, align 4, !tbaa !9
  call void %96(ptr noundef %105, i32 noundef %106)
  br label %107

107:                                              ; preds = %85, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  ret void
}

declare i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A0x28anonymous0x20namespace0x290x3A0x3A_0x5Flibcpp_atomic_load0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x20const0x2A0x2C0x20int0x29(ptr noundef, i32 noundef, i32 noundef) #5

declare i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A_0x5Flibcpp_atomic_refcount_decrement0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x260x29(ptr noundef, i32 noundef) #5

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 = { "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 #6 = { nounwind }
attributes #7 = { 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 void @w2c_hermes_std0x3A0x3A_0x5F20x3A0x3A_0x5Fshared_weak_count0x3A0x3A_0x5Frelease_weak0x280x29(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = add i32 %1, 8
  %4 = tail call i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A0x28anonymous0x20namespace0x290x3A0x3A_0x5Flibcpp_atomic_load0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x20const0x2A0x2C0x20int0x29(ptr noundef %0, i32 noundef %3, i32 noundef 2) #4
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %7, label %5

5:                                                ; preds = %2
  %6 = tail call i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A_0x5Flibcpp_atomic_refcount_decrement0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x260x29(ptr noundef %0, i32 noundef %3) #4
  %.not30 = icmp eq i32 %6, -1
  br i1 %.not30, label %7, label %35

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

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

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

.critedge:                                        ; preds = %18, %7, %24
  tail call void @wasm_rt_trap(i32 noundef 6) #5
  unreachable

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

35:                                               ; preds = %5, %28
  ret void
}

declare i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A0x28anonymous0x20namespace0x290x3A0x3A_0x5Flibcpp_atomic_load0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x20const0x2A0x2C0x20int0x29(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

declare i32 @w2c_hermes_long0x20std0x3A0x3A_0x5F20x3A0x3A_0x5Flibcpp_atomic_refcount_decrement0x5Babi0x3Av150070x5D0x3Clong0x3E0x28long0x260x29(ptr noundef, i32 noundef) local_unnamed_addr #3

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 = { "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, !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