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

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

; 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: nounwind uwtable
declare hidden double @wasm_fabs(double noundef) #1

; Function Attrs: nounwind uwtable
declare hidden double @wasm_floor(double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.copysign.f64(double, double) #2

; Function Attrs: nounwind uwtable
define dso_local double @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AroundHalfwaysTowardsInfinity0x28double0x29(ptr noundef %0, double noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load double, ptr %4, align 8, !tbaa !9
  store double %9, ptr %7, align 8, !tbaa !9
  %10 = load double, ptr %7, align 8, !tbaa !9
  %11 = call double @wasm_fabs(double noundef %10)
  store double %11, ptr %7, align 8, !tbaa !9
  %12 = load double, ptr %7, align 8, !tbaa !9
  store double %12, ptr %5, align 8, !tbaa !9
  store double 0x4330000000000000, ptr %8, align 8, !tbaa !9
  %13 = load double, ptr %7, align 8, !tbaa !9
  %14 = load double, ptr %8, align 8, !tbaa !9
  %15 = fcmp oge double %13, %14
  %16 = zext i1 %15 to i32
  store i32 %16, ptr %6, align 4, !tbaa !11
  %17 = load i32, ptr %6, align 4, !tbaa !11
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %2
  %20 = load double, ptr %4, align 8, !tbaa !9
  store double %20, ptr %7, align 8, !tbaa !9
  br label %45

21:                                               ; preds = %2
  %22 = load double, ptr %5, align 8, !tbaa !9
  store double %22, ptr %7, align 8, !tbaa !9
  store double 5.000000e-01, ptr %8, align 8, !tbaa !9
  %23 = load double, ptr %7, align 8, !tbaa !9
  %24 = load double, ptr %8, align 8, !tbaa !9
  %25 = fcmp olt double %23, %24
  %26 = zext i1 %25 to i32
  store i32 %26, ptr %6, align 4, !tbaa !11
  %27 = load i32, ptr %6, align 4, !tbaa !11
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %21
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  %30 = load double, ptr %4, align 8, !tbaa !9
  store double %30, ptr %8, align 8, !tbaa !9
  %31 = load double, ptr %7, align 8, !tbaa !9
  %32 = load double, ptr %8, align 8, !tbaa !9
  %33 = call double @llvm.copysign.f64(double %31, double %32)
  store double %33, ptr %7, align 8, !tbaa !9
  br label %46

34:                                               ; preds = %21
  %35 = load double, ptr %4, align 8, !tbaa !9
  store double %35, ptr %7, align 8, !tbaa !9
  store double 5.000000e-01, ptr %8, align 8, !tbaa !9
  %36 = load double, ptr %8, align 8, !tbaa !9
  %37 = load double, ptr %7, align 8, !tbaa !9
  %38 = fadd double %37, %36
  store double %38, ptr %7, align 8, !tbaa !9
  %39 = load double, ptr %7, align 8, !tbaa !9
  %40 = call double @wasm_floor(double noundef %39)
  store double %40, ptr %7, align 8, !tbaa !9
  %41 = load double, ptr %4, align 8, !tbaa !9
  store double %41, ptr %8, align 8, !tbaa !9
  %42 = load double, ptr %7, align 8, !tbaa !9
  %43 = load double, ptr %8, align 8, !tbaa !9
  %44 = call double @llvm.copysign.f64(double %42, double %43)
  store double %44, ptr %7, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %34, %19
  br label %46

46:                                               ; preds = %45, %29
  %47 = load double, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %47
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 speculatable willreturn memory(none) }
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)"}
!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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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
declare hidden double @wasm_fabs(double noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.copysign.f64(double, double) #1

; Function Attrs: nounwind uwtable
define dso_local double @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AroundHalfwaysTowardsInfinity0x28double0x29(ptr nocapture noundef readnone %0, double noundef %1) local_unnamed_addr #0 {
  %3 = tail call double @wasm_fabs(double noundef %1)
  %4 = fcmp ult double %3, 0x4330000000000000
  br i1 %4, label %5, label %13

5:                                                ; preds = %2
  %6 = fcmp olt double %3, 5.000000e-01
  br i1 %6, label %7, label %9

7:                                                ; preds = %5
  %8 = tail call double @llvm.copysign.f64(double 0.000000e+00, double %1)
  br label %13

9:                                                ; preds = %5
  %10 = fadd double %1, 5.000000e-01
  %11 = tail call double @wasm_floor(double noundef %10)
  %12 = tail call double @llvm.copysign.f64(double %11, double %1)
  br label %13

13:                                               ; preds = %2, %9, %7
  %.0 = phi double [ %8, %7 ], [ %12, %9 ], [ %1, %2 ]
  ret double %.0
}

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass