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

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

; 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_load8_u(ptr noundef, i64 noundef) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i32_store(ptr noundef, i64 noundef, i32 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: inlinehint nounwind uwtable
declare hidden void @i64_store(ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @i64_reinterpret_f64(double noundef) #1

declare i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AJSTypedArrayBase0x3A0x3AvalidateTypedArray0x28hermes0x3A0x3Avm0x3A0x3ARuntime0x260x2C0x20hermes0x3A0x3Avm0x3A0x3AHandle0x3Chermes0x3A0x3Avm0x3A0x3AHermesValue0x3E0x2C0x20bool0x29(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

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

37:                                               ; preds = %5
  %38 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %38, ptr %12, align 4, !tbaa !9
  store i32 0, ptr %13, align 4, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.w2c_hermes, ptr %39, i32 0, i32 6
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = load i32, ptr %13, align 4, !tbaa !9
  call void @i32_store(ptr noundef %40, i64 noundef %42, i32 noundef %43)
  br label %127

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

65:                                               ; preds = %44
  br label %112

66:                                               ; preds = %44
  %67 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %67, ptr %12, align 4, !tbaa !9
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.w2c_hermes, ptr %68, i32 0, i32 6
  %70 = load i32, ptr %12, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = add i64 %71, 29
  %73 = call i32 @i32_load8_u(ptr noundef %69, i64 noundef %72)
  store i32 %73, ptr %12, align 4, !tbaa !9
  %74 = load i32, ptr %12, align 4, !tbaa !9
  %75 = icmp ne i32 %74, 0
  %76 = xor i1 %75, true
  %77 = zext i1 %76 to i32
  store i32 %77, ptr %12, align 4, !tbaa !9
  %78 = load i32, ptr %12, align 4, !tbaa !9
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %81

80:                                               ; preds = %66
  br label %112

81:                                               ; preds = %66
  %82 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %82, ptr %12, align 4, !tbaa !9
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.w2c_hermes, ptr %83, i32 0, i32 6
  %85 = load i32, ptr %12, align 4, !tbaa !9
  %86 = zext i32 %85 to i64
  %87 = add i64 %86, 3
  %88 = call i32 @i32_load8_u(ptr noundef %84, i64 noundef %87)
  store i32 %88, ptr %12, align 4, !tbaa !9
  store i32 78813, ptr %13, align 4, !tbaa !9
  %89 = load i32, ptr %13, align 4, !tbaa !9
  %90 = load i32, ptr %12, align 4, !tbaa !9
  %91 = add i32 %90, %89
  store i32 %91, ptr %12, align 4, !tbaa !9
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.w2c_hermes, ptr %92, i32 0, i32 6
  %94 = load i32, ptr %12, align 4, !tbaa !9
  %95 = zext i32 %94 to i64
  %96 = call i32 @i32_load8_u(ptr noundef %93, i64 noundef %95)
  store i32 %96, ptr %12, align 4, !tbaa !9
  %97 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %97, ptr %13, align 4, !tbaa !9
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.w2c_hermes, ptr %98, i32 0, i32 6
  %100 = load i32, ptr %13, align 4, !tbaa !9
  %101 = zext i32 %100 to i64
  %102 = add i64 %101, 24
  %103 = call i32 @i32_load(ptr noundef %99, i64 noundef %102)
  store i32 %103, ptr %13, align 4, !tbaa !9
  %104 = load i32, ptr %13, align 4, !tbaa !9
  %105 = load i32, ptr %12, align 4, !tbaa !9
  %106 = mul i32 %105, %104
  store i32 %106, ptr %12, align 4, !tbaa !9
  %107 = load i32, ptr %12, align 4, !tbaa !9
  %108 = uitofp i32 %107 to double
  store double %108, ptr %17, align 8, !tbaa !13
  %109 = load double, ptr %17, align 8, !tbaa !13
  %110 = call i64 @i64_reinterpret_f64(double noundef %109)
  store i64 %110, ptr %15, align 8, !tbaa !11
  %111 = load i64, ptr %15, align 8, !tbaa !11
  store i64 %111, ptr %11, align 8, !tbaa !11
  br label %112

112:                                              ; preds = %81, %80, %65
  %113 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %113, ptr %12, align 4, !tbaa !9
  %114 = load i64, ptr %11, align 8, !tbaa !11
  store i64 %114, ptr %16, align 8, !tbaa !11
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.w2c_hermes, ptr %115, i32 0, i32 6
  %117 = load i32, ptr %12, align 4, !tbaa !9
  %118 = zext i32 %117 to i64
  %119 = add i64 %118, 8
  %120 = load i64, ptr %16, align 8, !tbaa !11
  call void @i64_store(ptr noundef %116, i64 noundef %119, i64 noundef %120)
  %121 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %121, ptr %12, align 4, !tbaa !9
  store i32 1, ptr %13, align 4, !tbaa !9
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.w2c_hermes, ptr %122, i32 0, i32 6
  %124 = load i32, ptr %12, align 4, !tbaa !9
  %125 = zext i32 %124 to i64
  %126 = load i32, ptr %13, align 4, !tbaa !9
  call void @i32_store(ptr noundef %123, i64 noundef %125, i32 noundef %126)
  br label %127

127:                                              ; preds = %112, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret void
}

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 = { "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 = { 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, !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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}


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

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

; 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 void @i32_store(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @i64_store(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @i64_reinterpret_f64(double noundef) local_unnamed_addr #0

declare i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AJSTypedArrayBase0x3A0x3AvalidateTypedArray0x28hermes0x3A0x3Avm0x3A0x3ARuntime0x260x2C0x20hermes0x3A0x3Avm0x3A0x3AHandle0x3Chermes0x3A0x3Avm0x3A0x3AHermesValue0x3E0x2C0x20bool0x29(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AtypedArrayPrototypeByteLength0x28void0x2A0x2C0x20hermes0x3A0x3Avm0x3A0x3ARuntime0x260x2C0x20hermes0x3A0x3Avm0x3A0x3ANativeArgs0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = zext i32 %4 to i64
  %8 = tail call i32 @i32_load(ptr noundef nonnull %6, i64 noundef %7)
  %9 = tail call i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AJSTypedArrayBase0x3A0x3AvalidateTypedArray0x28hermes0x3A0x3Avm0x3A0x3ARuntime0x260x2C0x20hermes0x3A0x3Avm0x3A0x3AHandle0x3Chermes0x3A0x3Avm0x3A0x3AHermesValue0x3E0x2C0x20bool0x29(ptr noundef %0, i32 noundef %3, i32 noundef %8, i32 noundef 0) #3
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %12

10:                                               ; preds = %5
  %11 = zext i32 %1 to i64
  tail call void @i32_store(ptr noundef nonnull %6, i64 noundef %11, i32 noundef 0)
  br label %36

12:                                               ; preds = %5
  %13 = zext i32 %8 to i64
  %14 = tail call i32 @i32_load(ptr noundef nonnull %6, i64 noundef %13)
  %15 = zext i32 %14 to i64
  %16 = add nuw nsw i64 %15, 20
  %17 = tail call i32 @i32_load(ptr noundef nonnull %6, i64 noundef %16)
  %.not52 = icmp eq i32 %17, 0
  br i1 %.not52, label %33, label %18

18:                                               ; preds = %12
  %19 = zext i32 %17 to i64
  %20 = add nuw nsw i64 %19, 29
  %21 = tail call i32 @i32_load8_u(ptr noundef nonnull %6, i64 noundef %20)
  %.not53 = icmp eq i32 %21, 0
  br i1 %.not53, label %33, label %22

22:                                               ; preds = %18
  %23 = add nuw nsw i64 %15, 3
  %24 = tail call i32 @i32_load8_u(ptr noundef nonnull %6, i64 noundef %23)
  %25 = add i32 %24, 78813
  %26 = zext i32 %25 to i64
  %27 = tail call i32 @i32_load8_u(ptr noundef nonnull %6, i64 noundef %26)
  %28 = add nuw nsw i64 %15, 24
  %29 = tail call i32 @i32_load(ptr noundef nonnull %6, i64 noundef %28)
  %30 = mul i32 %29, %27
  %31 = uitofp i32 %30 to double
  %32 = tail call i64 @i64_reinterpret_f64(double noundef %31)
  br label %33

33:                                               ; preds = %18, %12, %22
  %.0 = phi i64 [ 0, %12 ], [ 0, %18 ], [ %32, %22 ]
  %34 = zext i32 %1 to i64
  %35 = add nuw nsw i64 %34, 8
  tail call void @i64_store(ptr noundef nonnull %6, i64 noundef %35, i64 noundef %.0)
  tail call void @i32_store(ptr noundef nonnull %6, i64 noundef %34, i32 noundef 1)
  br label %36

36:                                               ; preds = %33, %10
  ret void
}

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 = { "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 = { 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)"}


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