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

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

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

; Function Attrs: nounwind uwtable
define dso_local double @w2c_hermes_nextafter(ptr noundef %0, double noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca double, align 8
  %15 = 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 i64 0, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %16 = load double, ptr %4, align 8, !tbaa !9
  store double %16, ptr %14, align 8, !tbaa !9
  %17 = load double, ptr %14, align 8, !tbaa !9
  %18 = call i64 @i64_reinterpret_f64(double noundef %17)
  store i64 %18, ptr %10, align 8, !tbaa !11
  store i64 9223372036854775807, ptr %11, align 8, !tbaa !11
  %19 = load i64, ptr %11, align 8, !tbaa !11
  %20 = load i64, ptr %10, align 8, !tbaa !11
  %21 = and i64 %20, %19
  store i64 %21, ptr %10, align 8, !tbaa !11
  store i64 9218868437227405312, ptr %11, align 8, !tbaa !11
  %22 = load i64, ptr %10, align 8, !tbaa !11
  %23 = load i64, ptr %11, align 8, !tbaa !11
  %24 = icmp ugt i64 %22, %23
  %25 = zext i1 %24 to i32
  store i32 %25, ptr %7, align 4, !tbaa !13
  %26 = load i32, ptr %7, align 4, !tbaa !13
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %33

28:                                               ; preds = %2
  %29 = load double, ptr %4, align 8, !tbaa !9
  store double %29, ptr %14, align 8, !tbaa !9
  store double 0x7FF0000000000000, ptr %15, align 8, !tbaa !9
  %30 = load double, ptr %15, align 8, !tbaa !9
  %31 = load double, ptr %14, align 8, !tbaa !9
  %32 = fadd double %31, %30
  store double %32, ptr %14, align 8, !tbaa !9
  br label %97

33:                                               ; preds = %2
  %34 = load double, ptr %4, align 8, !tbaa !9
  store double %34, ptr %14, align 8, !tbaa !9
  %35 = load double, ptr %14, align 8, !tbaa !9
  %36 = call i64 @i64_reinterpret_f64(double noundef %35)
  store i64 %36, ptr %10, align 8, !tbaa !11
  %37 = load i64, ptr %10, align 8, !tbaa !11
  store i64 %37, ptr %5, align 8, !tbaa !11
  store i64 9218868437227405312, ptr %11, align 8, !tbaa !11
  %38 = load i64, ptr %10, align 8, !tbaa !11
  %39 = load i64, ptr %11, align 8, !tbaa !11
  %40 = icmp ne i64 %38, %39
  %41 = zext i1 %40 to i32
  store i32 %41, ptr %7, align 4, !tbaa !13
  %42 = load i32, ptr %7, align 4, !tbaa !13
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %95

44:                                               ; preds = %33
  store i64 1, ptr %10, align 8, !tbaa !11
  %45 = load i64, ptr %5, align 8, !tbaa !11
  store i64 %45, ptr %11, align 8, !tbaa !11
  store i64 9223372036854775807, ptr %12, align 8, !tbaa !11
  %46 = load i64, ptr %12, align 8, !tbaa !11
  %47 = load i64, ptr %11, align 8, !tbaa !11
  %48 = and i64 %47, %46
  store i64 %48, ptr %11, align 8, !tbaa !11
  %49 = load i64, ptr %11, align 8, !tbaa !11
  store i64 %49, ptr %6, align 8, !tbaa !11
  %50 = load i64, ptr %11, align 8, !tbaa !11
  %51 = icmp ne i64 %50, 0
  %52 = xor i1 %51, true
  %53 = zext i1 %52 to i32
  store i32 %53, ptr %8, align 4, !tbaa !13
  %54 = load i32, ptr %8, align 4, !tbaa !13
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %44
  br label %92

57:                                               ; preds = %44
  %58 = load i64, ptr %5, align 8, !tbaa !11
  store i64 %58, ptr %10, align 8, !tbaa !11
  store i64 1, ptr %11, align 8, !tbaa !11
  %59 = load i64, ptr %11, align 8, !tbaa !11
  %60 = load i64, ptr %10, align 8, !tbaa !11
  %61 = sub i64 %60, %59
  store i64 %61, ptr %10, align 8, !tbaa !11
  %62 = load i64, ptr %6, align 8, !tbaa !11
  store i64 %62, ptr %11, align 8, !tbaa !11
  store i64 9218868437227405312, ptr %12, align 8, !tbaa !11
  %63 = load i64, ptr %11, align 8, !tbaa !11
  %64 = load i64, ptr %12, align 8, !tbaa !11
  %65 = icmp ule i64 %63, %64
  %66 = zext i1 %65 to i32
  store i32 %66, ptr %8, align 4, !tbaa !13
  %67 = load i64, ptr %5, align 8, !tbaa !11
  store i64 %67, ptr %12, align 8, !tbaa !11
  store i64 9218868437227405312, ptr %13, align 8, !tbaa !11
  %68 = load i64, ptr %13, align 8, !tbaa !11
  %69 = load i64, ptr %12, align 8, !tbaa !11
  %70 = xor i64 %69, %68
  store i64 %70, ptr %12, align 8, !tbaa !11
  store i64 0, ptr %13, align 8, !tbaa !11
  %71 = load i64, ptr %12, align 8, !tbaa !11
  %72 = load i64, ptr %13, align 8, !tbaa !11
  %73 = icmp sge i64 %71, %72
  %74 = zext i1 %73 to i32
  %75 = sext i32 %74 to i64
  %76 = trunc i64 %75 to i32
  store i32 %76, ptr %9, align 4, !tbaa !13
  %77 = load i32, ptr %9, align 4, !tbaa !13
  %78 = load i32, ptr %8, align 4, !tbaa !13
  %79 = and i32 %78, %77
  store i32 %79, ptr %8, align 4, !tbaa !13
  %80 = load i32, ptr %8, align 4, !tbaa !13
  %81 = icmp ne i32 %80, 0
  %82 = xor i1 %81, true
  %83 = zext i1 %82 to i32
  store i32 %83, ptr %8, align 4, !tbaa !13
  %84 = load i32, ptr %8, align 4, !tbaa !13
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %87

86:                                               ; preds = %57
  br label %92

87:                                               ; preds = %57
  %88 = load i64, ptr %5, align 8, !tbaa !11
  store i64 %88, ptr %10, align 8, !tbaa !11
  store i64 1, ptr %11, align 8, !tbaa !11
  %89 = load i64, ptr %11, align 8, !tbaa !11
  %90 = load i64, ptr %10, align 8, !tbaa !11
  %91 = add i64 %90, %89
  store i64 %91, ptr %10, align 8, !tbaa !11
  br label %92

92:                                               ; preds = %87, %86, %56
  %93 = load i64, ptr %10, align 8, !tbaa !11
  %94 = call double @f64_reinterpret_i64(i64 noundef %93)
  store double %94, ptr %14, align 8, !tbaa !9
  br label %96

95:                                               ; preds = %33
  store double 0x7FF0000000000000, ptr %14, align 8, !tbaa !9
  br label %96

96:                                               ; preds = %95, %92
  br label %97

97:                                               ; preds = %96, %28
  %98 = load double, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %98
}

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 = { 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)"}
!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 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"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: inlinehint nounwind uwtable
declare hidden double @f64_reinterpret_i64(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local double @w2c_hermes_nextafter(ptr nocapture noundef readnone %0, double noundef %1) local_unnamed_addr #1 {
  %3 = tail call i64 @i64_reinterpret_f64(double noundef %1)
  %4 = and i64 %3, 9223372036854775807
  %5 = icmp ugt i64 %4, 9218868437227405312
  br i1 %5, label %6, label %8

6:                                                ; preds = %2
  %7 = fadd double %1, 0x7FF0000000000000
  br label %17

8:                                                ; preds = %2
  %9 = tail call i64 @i64_reinterpret_f64(double noundef %1)
  %.not = icmp eq i64 %9, 9218868437227405312
  br i1 %.not, label %17, label %10

10:                                               ; preds = %8
  %11 = and i64 %9, 9223372036854775807
  %.not43 = icmp eq i64 %11, 0
  br i1 %.not43, label %15, label %12

12:                                               ; preds = %10
  %13 = icmp ugt i64 %11, 9218868437227405312
  %14 = icmp slt i64 %9, 0
  %.not46 = or i1 %14, %13
  %spec.select.v = select i1 %.not46, i64 -1, i64 1
  %spec.select = add i64 %spec.select.v, %9
  br label %15

15:                                               ; preds = %12, %10
  %.041 = phi i64 [ 1, %10 ], [ %spec.select, %12 ]
  %16 = tail call double @f64_reinterpret_i64(i64 noundef %.041)
  br label %17

17:                                               ; preds = %8, %15, %6
  %.0 = phi double [ %7, %6 ], [ %16, %15 ], [ 0x7FF0000000000000, %8 ]
  ret double %.0
}

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

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