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

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

36:                                               ; preds = %3
  %37 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %37, ptr %8, align 4, !tbaa !9
  store i32 3, ptr %9, align 4, !tbaa !9
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = and i32 %39, 31
  %41 = ashr i32 %38, %40
  store i32 %41, ptr %8, align 4, !tbaa !9
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = sitofp i32 %42 to double
  store double %43, ptr %10, align 8, !tbaa !11
  br label %55

44:                                               ; preds = %3
  %45 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %45, ptr %8, align 4, !tbaa !9
  store i32 -8, ptr %9, align 4, !tbaa !9
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = and i32 %47, %46
  store i32 %48, ptr %8, align 4, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.w2c_hermes, ptr %49, i32 0, i32 6
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = add i64 %52, 8
  %54 = call double @f64_load(ptr noundef %50, i64 noundef %53)
  store double %54, ptr %10, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %44, %36
  %56 = load double, ptr %10, align 8, !tbaa !11
  store double %56, ptr %7, align 8, !tbaa !11
  store double 0x41F0000000000000, ptr %11, align 8, !tbaa !11
  %57 = load double, ptr %10, align 8, !tbaa !11
  %58 = load double, ptr %11, align 8, !tbaa !11
  %59 = fcmp olt double %57, %58
  %60 = zext i1 %59 to i32
  store i32 %60, ptr %8, align 4, !tbaa !9
  %61 = load double, ptr %7, align 8, !tbaa !11
  store double %61, ptr %11, align 8, !tbaa !11
  store double 0.000000e+00, ptr %12, align 8, !tbaa !11
  %62 = load double, ptr %11, align 8, !tbaa !11
  %63 = load double, ptr %12, align 8, !tbaa !11
  %64 = fcmp oge double %62, %63
  %65 = zext i1 %64 to i32
  store i32 %65, ptr %9, align 4, !tbaa !9
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = and i32 %67, %66
  store i32 %68, ptr %8, align 4, !tbaa !9
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %108

71:                                               ; preds = %55
  %72 = load double, ptr %7, align 8, !tbaa !11
  store double %72, ptr %10, align 8, !tbaa !11
  %73 = load double, ptr %10, align 8, !tbaa !11
  %74 = load double, ptr %10, align 8, !tbaa !11
  %75 = fcmp une double %73, %74
  %76 = xor i1 %75, true
  %77 = xor i1 %76, true
  %78 = zext i1 %77 to i32
  %79 = sext i32 %78 to i64
  %80 = call i64 @llvm.expect.i64(i64 %79, i64 0)
  %81 = icmp ne i64 %80, 0
  br i1 %81, label %82, label %84

82:                                               ; preds = %71
  call void @wasm_rt_trap(i32 noundef 4) #6
  unreachable

83:                                               ; No predecessors!
  br label %106

84:                                               ; preds = %71
  %85 = load double, ptr %10, align 8, !tbaa !11
  %86 = fcmp ogt double %85, -1.000000e+00
  br i1 %86, label %87, label %90

87:                                               ; preds = %84
  %88 = load double, ptr %10, align 8, !tbaa !11
  %89 = fcmp olt double %88, 0x41F0000000000000
  br label %90

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

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

100:                                              ; No predecessors!
  br label %104

101:                                              ; preds = %90
  %102 = load double, ptr %10, align 8, !tbaa !11
  %103 = fptoui double %102 to i32
  br label %104

104:                                              ; preds = %101, %100
  %105 = phi i32 [ 0, %100 ], [ %103, %101 ]
  br label %106

106:                                              ; preds = %104, %83
  %107 = phi i32 [ 0, %83 ], [ %105, %104 ]
  store i32 %107, ptr %8, align 4, !tbaa !9
  br label %109

108:                                              ; preds = %55
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %108, %106
  %110 = load i32, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret i32 %110
}

; 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: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) #2

; Function Attrs: noreturn
declare void @wasm_rt_trap(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 double @f64_load(ptr noundef, i64 noundef) #2

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 = { 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 = { 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 = { 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, !12, i64 0}
!12 = !{!"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: nounwind uwtable
define dso_local i32 @w2c_hermes_0x28anonymous0x20namespace0x290x3A0x3Aget_array_length0x28HermesABIRuntime0x2A0x2C0x20HermesABIArray0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = zext i32 %2 to i64
  %6 = add nuw nsw i64 %5, 8
  %7 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %6)
  %8 = zext i32 %7 to i64
  %9 = add nuw nsw i64 %8, 32
  %10 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %9)
  %11 = and i32 %10, 7
  %12 = icmp eq i32 %11, 4
  br i1 %12, label %13, label %16

13:                                               ; preds = %3
  %14 = ashr i32 %10, 3
  %15 = sitofp i32 %14 to double
  br label %21

16:                                               ; preds = %3
  %17 = and i32 %10, -8
  %18 = zext i32 %17 to i64
  %19 = add nuw nsw i64 %18, 8
  %20 = tail call double @f64_load(ptr noundef nonnull %4, i64 noundef %19)
  br label %21

21:                                               ; preds = %16, %13
  %.0 = phi double [ %15, %13 ], [ %20, %16 ]
  %22 = fcmp olt double %.0, 0x41F0000000000000
  %23 = fcmp oge double %.0, 0.000000e+00
  %24 = and i1 %22, %23
  br i1 %24, label %25, label %33

25:                                               ; preds = %21
  %26 = fcmp uno double %.0, 0.000000e+00
  br i1 %26, label %27, label %28, !prof !5

27:                                               ; preds = %25
  tail call void @wasm_rt_trap(i32 noundef 4) #3
  unreachable

28:                                               ; preds = %25
  %29 = fcmp ogt double %.0, -1.000000e+00
  br i1 %29, label %31, label %30, !prof !6

30:                                               ; preds = %28
  tail call void @wasm_rt_trap(i32 noundef 2) #3
  unreachable

31:                                               ; preds = %28
  %32 = fptoui double %.0 to i32
  br label %33

33:                                               ; preds = %21, %31
  %.035 = phi i32 [ %32, %31 ], [ 0, %21 ]
  ret i32 %.035
}

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

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

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

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 = { 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 = { noreturn 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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!"branch_weights", !"expected", i32 2000, i32 1}


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