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

; 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_t1 = 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: noreturn
declare void @wasm_rt_trap(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AStorageProvider0x3A0x3AnewStorage0x28char0x20const0x2A0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %14 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %14, ptr %9, align 4, !tbaa !9
  %15 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %15, ptr %10, align 4, !tbaa !9
  %16 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %16, ptr %11, align 4, !tbaa !9
  %17 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %17, ptr %12, align 4, !tbaa !9
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.w2c_hermes, ptr %18, i32 0, i32 6
  %20 = load i32, ptr %12, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = call i32 @i32_load(ptr noundef %19, i64 noundef %21)
  store i32 %22, ptr %12, align 4, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.w2c_hermes, ptr %23, i32 0, i32 6
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = zext i32 %25 to i64
  %27 = add i64 %26, 8
  %28 = call i32 @i32_load(ptr noundef %24, i64 noundef %27)
  store i32 %28, ptr %12, align 4, !tbaa !9
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.w2c_hermes, ptr %30, i32 0, i32 7
  %32 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = icmp ult i32 %29, %33
  br i1 %34, label %35, label %58

35:                                               ; preds = %4
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.w2c_hermes, ptr %36, i32 0, i32 7
  %38 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = load i32, ptr %12, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %39, i64 %41
  %43 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %58

46:                                               ; preds = %35
  %47 = load ptr, ptr @w2c_hermes_t1, align 8, !tbaa !5
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.w2c_hermes, ptr %48, i32 0, i32 7
  %50 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  %52 = load i32, ptr %12, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %51, i64 %53
  %55 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !20
  %57 = call zeroext i1 @func_types_eq(ptr noundef %47, ptr noundef %56)
  br label %58

58:                                               ; preds = %46, %35, %4
  %59 = phi i1 [ false, %35 ], [ false, %4 ], [ %57, %46 ]
  %60 = xor i1 %59, true
  %61 = xor i1 %60, true
  %62 = zext i1 %61 to i32
  %63 = sext i32 %62 to i64
  %64 = call i64 @llvm.expect.i64(i64 %63, i64 1)
  %65 = icmp ne i64 %64, 0
  br i1 %65, label %68, label %66

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

67:                                               ; No predecessors!
  br label %68

68:                                               ; preds = %67, %58
  %69 = phi i1 [ true, %58 ], [ false, %67 ]
  %70 = zext i1 %69 to i32
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.w2c_hermes, ptr %71, i32 0, i32 7
  %73 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !17
  %75 = load i32, ptr %12, align 4, !tbaa !9
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %74, i64 %76
  %78 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %77, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !18
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.w2c_hermes, ptr %80, i32 0, i32 7
  %82 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !17
  %84 = load i32, ptr %12, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %83, i64 %85
  %87 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %86, i32 0, i32 2
  %88 = load ptr, ptr %87, align 8, !tbaa !21
  %89 = load i32, ptr %9, align 4, !tbaa !9
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = load i32, ptr %11, align 4, !tbaa !9
  call void %79(ptr noundef %88, i32 noundef %89, i32 noundef %90, i32 noundef %91)
  %92 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %92, ptr %9, align 4, !tbaa !9
  store i32 8, ptr %10, align 4, !tbaa !9
  store i32 4, ptr %11, align 4, !tbaa !9
  %93 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %93, ptr %12, align 4, !tbaa !9
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.w2c_hermes, ptr %94, i32 0, i32 6
  %96 = load i32, ptr %12, align 4, !tbaa !9
  %97 = zext i32 %96 to i64
  %98 = add i64 %97, 8
  %99 = call i32 @i32_load8_u(ptr noundef %95, i64 noundef %98)
  store i32 %99, ptr %12, align 4, !tbaa !9
  store i32 1, ptr %13, align 4, !tbaa !9
  %100 = load i32, ptr %13, align 4, !tbaa !9
  %101 = load i32, ptr %12, align 4, !tbaa !9
  %102 = and i32 %101, %100
  store i32 %102, ptr %12, align 4, !tbaa !9
  %103 = load i32, ptr %12, align 4, !tbaa !9
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %105, label %107

105:                                              ; preds = %68
  %106 = load i32, ptr %10, align 4, !tbaa !9
  br label %109

107:                                              ; preds = %68
  %108 = load i32, ptr %11, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %107, %105
  %110 = phi i32 [ %106, %105 ], [ %108, %107 ]
  store i32 %110, ptr %10, align 4, !tbaa !9
  %111 = load i32, ptr %10, align 4, !tbaa !9
  %112 = load i32, ptr %9, align 4, !tbaa !9
  %113 = add i32 %112, %111
  store i32 %113, ptr %9, align 4, !tbaa !9
  %114 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %114, ptr %7, align 4, !tbaa !9
  %115 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %115, ptr %10, align 4, !tbaa !9
  %116 = load ptr, ptr %5, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.w2c_hermes, ptr %116, i32 0, i32 6
  %118 = load i32, ptr %10, align 4, !tbaa !9
  %119 = zext i32 %118 to i64
  %120 = call i32 @i32_load(ptr noundef %117, i64 noundef %119)
  store i32 %120, ptr %10, align 4, !tbaa !9
  store i32 1, ptr %11, align 4, !tbaa !9
  %121 = load i32, ptr %11, align 4, !tbaa !9
  %122 = load i32, ptr %10, align 4, !tbaa !9
  %123 = add i32 %122, %121
  store i32 %123, ptr %10, align 4, !tbaa !9
  %124 = load ptr, ptr %5, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.w2c_hermes, ptr %124, i32 0, i32 6
  %126 = load i32, ptr %9, align 4, !tbaa !9
  %127 = zext i32 %126 to i64
  %128 = load i32, ptr %10, align 4, !tbaa !9
  call void @i32_store(ptr noundef %125, i64 noundef %127, i32 noundef %128)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret void
}

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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_t1 = external local_unnamed_addr constant ptr, align 8

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

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

; Function Attrs: nounwind uwtable
define dso_local void @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AStorageProvider0x3A0x3AnewStorage0x28char0x20const0x2A0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = zext i32 %2 to i64
  %7 = tail call i32 @i32_load(ptr noundef nonnull %5, i64 noundef %6)
  %8 = zext i32 %7 to i64
  %9 = add nuw nsw i64 %8, 8
  %10 = tail call i32 @i32_load(ptr noundef nonnull %5, 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 = %4
  %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 @w2c_hermes_t1, align 8, !tbaa !20
  %23 = load ptr, ptr %18, align 8, !tbaa !21
  %24 = tail call zeroext i1 @func_types_eq(ptr noundef %22, ptr noundef %23)
  br i1 %24, label %25, label %.critedge, !prof !15

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

25:                                               ; preds = %21
  %26 = load ptr, ptr %11, align 8, !tbaa !16
  %27 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %26, i64 %17
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  %30 = getelementptr inbounds i8, ptr %27, i64 16
  %31 = load ptr, ptr %30, align 8, !tbaa !22
  tail call void %29(ptr noundef %31, i32 noundef %1, i32 noundef %2, i32 noundef %3) #4
  %32 = zext i32 %1 to i64
  %33 = add nuw nsw i64 %32, 8
  %34 = tail call i32 @i32_load8_u(ptr noundef nonnull %5, i64 noundef %33)
  %35 = and i32 %34, 1
  %.not40 = icmp eq i32 %35, 0
  %36 = select i1 %.not40, i32 4, i32 8
  %37 = add i32 %36, %2
  %38 = zext i32 %37 to i64
  %39 = tail call i32 @i32_load(ptr noundef nonnull %5, i64 noundef %38)
  %40 = add i32 %39, 1
  tail call void @i32_store(ptr noundef nonnull %5, i64 noundef %38, i32 noundef %40)
  ret void
}

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

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

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

attributes #0 = { 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 #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 = { 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