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

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

@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @w2c_hermes_0x28anonymous0x20namespace0x290x3A0x3AHostObjectWrapper0x3A0x3A0x7EHostObjectWrapper0x280x290x2E1(ptr noundef %0, i32 noundef %1) #0 {
  %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 265896, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.w2c_hermes, ptr %9, i32 0, i32 6
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = zext i32 %11 to i64
  %13 = load i32, ptr %7, align 4, !tbaa !9
  call void @i32_store(ptr noundef %10, i64 noundef %12, i32 noundef %13)
  %14 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %14, ptr %6, align 4, !tbaa !9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.w2c_hermes, ptr %15, i32 0, i32 6
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  %19 = add i64 %18, 8
  %20 = call i32 @i32_load(ptr noundef %16, i64 noundef %19)
  store i32 %20, ptr %6, align 4, !tbaa !9
  %21 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %21, ptr %5, align 4, !tbaa !9
  %22 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %22, ptr %7, align 4, !tbaa !9
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.w2c_hermes, ptr %23, i32 0, i32 6
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = zext i32 %25 to i64
  %27 = call i32 @i32_load(ptr noundef %24, i64 noundef %26)
  store i32 %27, ptr %7, align 4, !tbaa !9
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.w2c_hermes, ptr %28, i32 0, i32 6
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = call i32 @i32_load(ptr noundef %29, i64 noundef %31)
  store i32 %32, ptr %7, align 4, !tbaa !9
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.w2c_hermes, ptr %34, i32 0, i32 7
  %36 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = icmp ult i32 %33, %37
  br i1 %38, label %39, label %61

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

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

61:                                               ; preds = %50, %39, %2
  %62 = phi i1 [ false, %39 ], [ false, %2 ], [ %60, %50 ]
  %63 = xor i1 %62, true
  %64 = xor i1 %63, true
  %65 = zext i1 %64 to i32
  %66 = sext i32 %65 to i64
  %67 = call i64 @llvm.expect.i64(i64 %66, i64 1)
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %71, label %69

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

70:                                               ; No predecessors!
  br label %71

71:                                               ; preds = %70, %61
  %72 = phi i1 [ true, %61 ], [ false, %70 ]
  %73 = zext i1 %72 to i32
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.w2c_hermes, ptr %74, i32 0, i32 7
  %76 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !17
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = zext i32 %78 to i64
  %80 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %77, i64 %79
  %81 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !18
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.w2c_hermes, ptr %83, i32 0, i32 7
  %85 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %84, i32 0, i32 0
  %86 = load ptr, ptr %85, align 8, !tbaa !17
  %87 = load i32, ptr %7, align 4, !tbaa !9
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %86, i64 %88
  %90 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %89, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !21
  %92 = load i32, ptr %6, align 4, !tbaa !9
  call void %82(ptr noundef %91, i32 noundef %92)
  %93 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %93, ptr %6, align 4, !tbaa !9
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = load i32, ptr %6, align 4, !tbaa !9
  %96 = call i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AHostObjectProxy0x3A0x3A0x7EHostObjectProxy0x280x29(ptr noundef %94, i32 noundef %95)
  store i32 %96, ptr %6, align 4, !tbaa !9
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = load i32, ptr %6, align 4, !tbaa !9
  call void @w2c_hermes_operator0x20delete0x28void0x2A0x29(ptr noundef %97, i32 noundef %98)
  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
}

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i32_store(ptr noundef, i64 noundef, i32 noundef) #3

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

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

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

declare void @w2c_hermes_operator0x20delete0x28void0x2A0x29(ptr noundef, i32 noundef) #5

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 }

@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @w2c_hermes_0x28anonymous0x20namespace0x290x3A0x3AHostObjectWrapper0x3A0x3A0x7EHostObjectWrapper0x280x290x2E1(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = zext i32 %1 to i64
  tail call void @i32_store(ptr noundef nonnull %3, i64 noundef %4, i32 noundef 265896)
  %5 = add nuw nsw i64 %4, 8
  %6 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %5)
  %7 = zext i32 %6 to i64
  %8 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %7)
  %9 = zext i32 %8 to i64
  %10 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %9)
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = getelementptr inbounds i8, ptr %0, i64 92
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = icmp ult i32 %10, %13
  br i1 %14, label %15, label %.critedge, !prof !15

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

21:                                               ; preds = %15
  %22 = load ptr, ptr %18, align 8, !tbaa !20
  %23 = tail call zeroext i1 @func_types_eq(ptr noundef nonnull @.str.3, ptr noundef %22)
  br i1 %23, label %24, label %.critedge, !prof !15

.critedge:                                        ; preds = %15, %2, %21
  tail call void @wasm_rt_trap(i32 noundef 6) #4
  unreachable

24:                                               ; preds = %21
  %25 = load ptr, ptr %11, align 8, !tbaa !16
  %26 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %25, i64 %17
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %26, i64 16
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  tail call void %28(ptr noundef %30, i32 noundef %6) #5
  %31 = tail call i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AHostObjectProxy0x3A0x3A0x7EHostObjectProxy0x280x29(ptr noundef nonnull %0, i32 noundef %1) #5
  tail call void @w2c_hermes_operator0x20delete0x28void0x2A0x29(ptr noundef nonnull %0, i32 noundef %31) #5
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i32_store(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

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

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

declare void @w2c_hermes_operator0x20delete0x28void0x2A0x29(ptr noundef, i32 noundef) local_unnamed_addr #3

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

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 = { 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 = { 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 nounwind }
attributes #5 = { 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 = !{!18, !7, i64 0}
!21 = !{!18, !7, i64 16}


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