; LLVM IR from facebook/hermes :: API/hermes_sandbox/external (hermes_sandbox_impl_opt_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: 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) #2

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

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

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

27:                                               ; preds = %4
  br label %121

28:                                               ; preds = %4
  %29 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %29, ptr %9, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.w2c_hermes, ptr %30, i32 0, i32 6
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = zext i32 %32 to i64
  %34 = add i64 %33, 56
  %35 = call i32 @i32_load(ptr noundef %31, i64 noundef %34)
  store i32 %35, ptr %9, align 4, !tbaa !9
  %36 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %36, ptr %6, align 4, !tbaa !9
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  %39 = xor i1 %38, true
  %40 = zext i1 %39 to i32
  store i32 %40, ptr %9, align 4, !tbaa !9
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %28
  br label %121

44:                                               ; preds = %28
  %45 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %45, ptr %9, align 4, !tbaa !9
  %46 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %46, ptr %10, align 4, !tbaa !9
  %47 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %47, ptr %11, align 4, !tbaa !9
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.w2c_hermes, ptr %48, i32 0, i32 6
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = call i32 @i32_load(ptr noundef %49, i64 noundef %51)
  store i32 %52, ptr %11, align 4, !tbaa !9
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.w2c_hermes, ptr %53, i32 0, i32 6
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = add i64 %56, 8
  %58 = call i32 @i32_load(ptr noundef %54, i64 noundef %57)
  store i32 %58, ptr %11, align 4, !tbaa !9
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.w2c_hermes, ptr %60, i32 0, i32 7
  %62 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !11
  %64 = icmp ult i32 %59, %63
  br i1 %64, label %65, label %88

65:                                               ; preds = %44
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.w2c_hermes, ptr %66, i32 0, i32 7
  %68 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !17
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %69, i64 %71
  %73 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %72, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !18
  %75 = icmp ne ptr %74, null
  br i1 %75, label %76, label %88

76:                                               ; preds = %65
  %77 = load ptr, ptr @w2c_hermes_t0, align 8, !tbaa !5
  %78 = load ptr, ptr %5, 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 %11, 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 0
  %86 = load ptr, ptr %85, align 8, !tbaa !20
  %87 = call zeroext i1 @func_types_eq(ptr noundef %77, ptr noundef %86)
  br label %88

88:                                               ; preds = %76, %65, %44
  %89 = phi i1 [ false, %65 ], [ false, %44 ], [ %87, %76 ]
  %90 = xor i1 %89, true
  %91 = xor i1 %90, true
  %92 = zext i1 %91 to i32
  %93 = sext i32 %92 to i64
  %94 = call i64 @llvm.expect.i64(i64 %93, i64 1)
  %95 = icmp ne i64 %94, 0
  br i1 %95, label %98, label %96

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

97:                                               ; No predecessors!
  br label %98

98:                                               ; preds = %97, %88
  %99 = phi i1 [ true, %88 ], [ false, %97 ]
  %100 = zext i1 %99 to i32
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.w2c_hermes, ptr %101, i32 0, i32 7
  %103 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %102, i32 0, i32 0
  %104 = load ptr, ptr %103, align 8, !tbaa !17
  %105 = load i32, ptr %11, align 4, !tbaa !9
  %106 = zext i32 %105 to i64
  %107 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %104, i64 %106
  %108 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %107, i32 0, i32 1
  %109 = load ptr, ptr %108, align 8, !tbaa !18
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.w2c_hermes, ptr %110, i32 0, i32 7
  %112 = getelementptr inbounds %struct.wasm_rt_funcref_table_t, ptr %111, i32 0, i32 0
  %113 = load ptr, ptr %112, align 8, !tbaa !17
  %114 = load i32, ptr %11, align 4, !tbaa !9
  %115 = zext i32 %114 to i64
  %116 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %113, i64 %115
  %117 = getelementptr inbounds %struct.wasm_rt_funcref_t, ptr %116, i32 0, i32 2
  %118 = load ptr, ptr %117, align 8, !tbaa !21
  %119 = load i32, ptr %9, align 4, !tbaa !9
  %120 = load i32, ptr %10, align 4, !tbaa !9
  call void %109(ptr noundef %118, i32 noundef %119, i32 noundef %120)
  br label %121

121:                                              ; preds = %98, %43, %27
  %122 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %122, ptr %9, align 4, !tbaa !9
  %123 = load i32, ptr %9, align 4, !tbaa !9
  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 i32 %123
}

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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: noreturn
declare void @wasm_rt_trap(i32 noundef) local_unnamed_addr #1

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

; 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) local_unnamed_addr #2 {
  %5 = tail call i32 @w2c_hermes_hermes0x3A0x3ASourceErrorManager0x3A0x3AfindBufferLineAndLoc0x28llvh0x3A0x3ASMLoc0x2C0x20hermes0x3A0x3ASourceErrorManager0x3A0x3ASourceCoords0x260x29(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %38, label %6

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

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

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

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

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

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

38:                                               ; preds = %6, %4, %31
  ret i32 %5
}

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