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

; 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_t0 = 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: 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_hermes0x3A0x3ASourceErrorManager0x3A0x3AfindBufferLineAndLoc0x28llvh0x3A0x3ASMLoc0x2C0x20hermes0x3A0x3ASourceErrorManager0x3A0x3ASourceCoords0x260x2C0x20bool0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #4 {
  %6 = alloca ptr, align 8
  %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 %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  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 %7, align 4, !tbaa !9
  store i32 %14, ptr %11, align 4, !tbaa !9
  %15 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %15, ptr %12, align 4, !tbaa !9
  %16 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %16, ptr %13, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = load i32, ptr %12, align 4, !tbaa !9
  %20 = load i32, ptr %13, align 4, !tbaa !9
  %21 = call i32 @w2c_hermes_hermes0x3A0x3ASourceErrorManager0x3A0x3AfindBufferLineAndLoc0x28llvh0x3A0x3ASMLoc0x2C0x20hermes0x3A0x3ASourceErrorManager0x3A0x3ASourceCoords0x260x29(ptr noundef %17, i32 noundef %18, i32 noundef %19, i32 noundef %20)
  store i32 %21, ptr %11, align 4, !tbaa !9
  %22 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %22, ptr %8, align 4, !tbaa !9
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  %25 = xor i1 %24, true
  %26 = zext i1 %25 to i32
  store i32 %26, ptr %11, align 4, !tbaa !9
  %27 = load i32, ptr %11, align 4, !tbaa !9
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %5
  br label %132

30:                                               ; preds = %5
  %31 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %31, ptr %11, align 4, !tbaa !9
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = icmp ne i32 %32, 0
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  store i32 %35, ptr %11, align 4, !tbaa !9
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %30
  br label %132

39:                                               ; preds = %30
  %40 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %40, ptr %11, align 4, !tbaa !9
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.w2c_hermes, ptr %41, i32 0, i32 6
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = add i64 %44, 56
  %46 = call i32 @i32_load(ptr noundef %42, i64 noundef %45)
  store i32 %46, ptr %11, align 4, !tbaa !9
  %47 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %47, ptr %7, align 4, !tbaa !9
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = icmp ne i32 %48, 0
  %50 = xor i1 %49, true
  %51 = zext i1 %50 to i32
  store i32 %51, ptr %11, align 4, !tbaa !9
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %39
  br label %132

55:                                               ; preds = %39
  %56 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %56, ptr %11, align 4, !tbaa !9
  %57 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %57, ptr %12, align 4, !tbaa !9
  %58 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %58, ptr %13, align 4, !tbaa !9
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.w2c_hermes, ptr %59, i32 0, i32 6
  %61 = load i32, ptr %13, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = call i32 @i32_load(ptr noundef %60, i64 noundef %62)
  store i32 %63, ptr %13, align 4, !tbaa !9
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.w2c_hermes, ptr %64, i32 0, i32 6
  %66 = load i32, ptr %13, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = add i64 %67, 8
  %69 = call i32 @i32_load(ptr noundef %65, i64 noundef %68)
  store i32 %69, ptr %13, align 4, !tbaa !9
  %70 = load i32, ptr %13, align 4, !tbaa !9
  %71 = load ptr, ptr %6, 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 2
  %74 = load i32, ptr %73, align 4, !tbaa !11
  %75 = icmp ult i32 %70, %74
  br i1 %75, label %76, label %99

76:                                               ; preds = %55
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.w2c_hermes, ptr %77, i32 0, i32 7
  %79 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !17
  %81 = load i32, ptr %13, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %80, i64 %82
  %84 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %84, align 8, !tbaa !18
  %86 = icmp ne ptr %85, null
  br i1 %86, label %87, label %99

87:                                               ; preds = %76
  %88 = load ptr, ptr @w2c_hermes_t0, align 8, !tbaa !5
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.w2c_hermes, ptr %89, i32 0, i32 7
  %91 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !17
  %93 = load i32, ptr %13, align 4, !tbaa !9
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %92, i64 %94
  %96 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !20
  %98 = call zeroext i1 @func_types_eq(ptr noundef %88, ptr noundef %97)
  br label %99

99:                                               ; preds = %87, %76, %55
  %100 = phi i1 [ false, %76 ], [ false, %55 ], [ %98, %87 ]
  %101 = xor i1 %100, true
  %102 = xor i1 %101, true
  %103 = zext i1 %102 to i32
  %104 = sext i32 %103 to i64
  %105 = call i64 @llvm.expect.i64(i64 %104, i64 1)
  %106 = icmp ne i64 %105, 0
  br i1 %106, label %109, label %107

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

108:                                              ; No predecessors!
  br label %109

109:                                              ; preds = %108, %99
  %110 = phi i1 [ true, %99 ], [ false, %108 ]
  %111 = zext i1 %110 to i32
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.w2c_hermes, ptr %112, i32 0, i32 7
  %114 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %113, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8, !tbaa !17
  %116 = load i32, ptr %13, align 4, !tbaa !9
  %117 = zext i32 %116 to i64
  %118 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %115, i64 %117
  %119 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %118, i32 0, i32 1
  %120 = load ptr, ptr %119, align 8, !tbaa !18
  %121 = load ptr, ptr %6, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.w2c_hermes, ptr %121, i32 0, i32 7
  %123 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !17
  %125 = load i32, ptr %13, align 4, !tbaa !9
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %124, i64 %126
  %128 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %127, i32 0, i32 2
  %129 = load ptr, ptr %128, align 8, !tbaa !21
  %130 = load i32, ptr %11, align 4, !tbaa !9
  %131 = load i32, ptr %12, align 4, !tbaa !9
  call void %120(ptr noundef %129, i32 noundef %130, i32 noundef %131)
  br label %132

132:                                              ; preds = %109, %54, %38, %29
  %133 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %133, ptr %11, align 4, !tbaa !9
  %134 = load i32, ptr %11, align 4, !tbaa !9
  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
  ret i32 %134
}

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_t0 = 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
declare dso_local i32 @w2c_hermes_hermes0x3A0x3ASourceErrorManager0x3A0x3AfindBufferLineAndLoc0x28llvh0x3A0x3ASMLoc0x2C0x20hermes0x3A0x3ASourceErrorManager0x3A0x3ASourceCoords0x260x29(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_hermes0x3A0x3ASourceErrorManager0x3A0x3AfindBufferLineAndLoc0x28llvh0x3A0x3ASMLoc0x2C0x20hermes0x3A0x3ASourceErrorManager0x3A0x3ASourceCoords0x260x2C0x20bool0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #2 {
  %6 = tail call i32 @w2c_hermes_hermes0x3A0x3ASourceErrorManager0x3A0x3AfindBufferLineAndLoc0x28llvh0x3A0x3ASMLoc0x2C0x20hermes0x3A0x3ASourceErrorManager0x3A0x3ASourceCoords0x260x29(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3)
  %.not = icmp eq i32 %6, 0
  %.not39 = icmp eq i32 %4, 0
  %or.cond = or i1 %.not39, %.not
  br i1 %or.cond, label %39, label %7

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = zext i32 %1 to i64
  %10 = add nuw nsw i64 %9, 56
  %11 = tail call i32 @i32_load(ptr noundef nonnull %8, i64 noundef %10)
  %.not40 = icmp eq i32 %11, 0
  br i1 %.not40, label %39, label %12

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

22:                                               ; preds = %12
  %23 = load ptr, ptr %18, align 8, !tbaa !16
  %24 = zext i32 %17 to i64
  %25 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %23, i64 %24
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %.not41 = icmp eq ptr %27, null
  br i1 %.not41, label %.critedge, label %28, !prof !19

28:                                               ; preds = %22
  %29 = load ptr, ptr @w2c_hermes_t0, align 8, !tbaa !20
  %30 = load ptr, ptr %25, align 8, !tbaa !21
  %31 = tail call zeroext i1 @func_types_eq(ptr noundef %29, ptr noundef %30)
  br i1 %31, label %32, label %.critedge, !prof !15

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

32:                                               ; preds = %28
  %33 = load ptr, ptr %18, align 8, !tbaa !16
  %34 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %33, i64 %24
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %37 = getelementptr inbounds i8, ptr %34, i64 16
  %38 = load ptr, ptr %37, align 8, !tbaa !22
  tail call void %36(ptr noundef %38, i32 noundef %11, i32 noundef %3) #4
  br label %39

39:                                               ; preds = %7, %5, %32
  ret i32 %6
}

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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass