; LLVM IR from facebook/hermes :: API/hermes_sandbox/external (hermes_sandbox_impl_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: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #1

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

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

25:                                               ; preds = %2
  br label %116

26:                                               ; preds = %2
  store i32 255, ptr %6, align 4, !tbaa !11
  %27 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %27, ptr %5, align 4, !tbaa !11
  %28 = load double, ptr %4, align 8, !tbaa !9
  store double %28, ptr %11, align 8, !tbaa !9
  store double 2.550000e+02, ptr %12, align 8, !tbaa !9
  %29 = load double, ptr %11, align 8, !tbaa !9
  %30 = load double, ptr %12, align 8, !tbaa !9
  %31 = fcmp ogt double %29, %30
  %32 = zext i1 %31 to i32
  store i32 %32, ptr %7, align 4, !tbaa !11
  %33 = load i32, ptr %7, align 4, !tbaa !11
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %26
  br label %116

36:                                               ; preds = %26
  %37 = load double, ptr %4, align 8, !tbaa !9
  store double %37, ptr %10, align 8, !tbaa !9
  store double 5.000000e-01, ptr %11, align 8, !tbaa !9
  %38 = load double, ptr %11, align 8, !tbaa !9
  %39 = load double, ptr %10, align 8, !tbaa !9
  %40 = fadd double %39, %38
  store double %40, ptr %10, align 8, !tbaa !9
  %41 = load double, ptr %10, align 8, !tbaa !9
  store double %41, ptr %4, align 8, !tbaa !9
  store double 0x41F0000000000000, ptr %11, align 8, !tbaa !9
  %42 = load double, ptr %10, align 8, !tbaa !9
  %43 = load double, ptr %11, align 8, !tbaa !9
  %44 = fcmp olt double %42, %43
  %45 = zext i1 %44 to i32
  store i32 %45, ptr %6, align 4, !tbaa !11
  %46 = load double, ptr %4, align 8, !tbaa !9
  store double %46, ptr %11, align 8, !tbaa !9
  store double 0.000000e+00, ptr %12, align 8, !tbaa !9
  %47 = load double, ptr %11, align 8, !tbaa !9
  %48 = load double, ptr %12, align 8, !tbaa !9
  %49 = fcmp oge double %47, %48
  %50 = zext i1 %49 to i32
  store i32 %50, ptr %7, align 4, !tbaa !11
  %51 = load i32, ptr %7, align 4, !tbaa !11
  %52 = load i32, ptr %6, align 4, !tbaa !11
  %53 = and i32 %52, %51
  store i32 %53, ptr %6, align 4, !tbaa !11
  %54 = load i32, ptr %6, align 4, !tbaa !11
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %93

56:                                               ; preds = %36
  %57 = load double, ptr %4, align 8, !tbaa !9
  store double %57, ptr %10, align 8, !tbaa !9
  %58 = load double, ptr %10, align 8, !tbaa !9
  %59 = load double, ptr %10, align 8, !tbaa !9
  %60 = fcmp une double %58, %59
  %61 = xor i1 %60, true
  %62 = xor i1 %61, true
  %63 = zext i1 %62 to i32
  %64 = sext i32 %63 to i64
  %65 = call i64 @llvm.expect.i64(i64 %64, i64 0)
  %66 = icmp ne i64 %65, 0
  br i1 %66, label %67, label %69

67:                                               ; preds = %56
  call void @wasm_rt_trap(i32 noundef 4) #5
  unreachable

68:                                               ; No predecessors!
  br label %91

69:                                               ; preds = %56
  %70 = load double, ptr %10, align 8, !tbaa !9
  %71 = fcmp ogt double %70, -1.000000e+00
  br i1 %71, label %72, label %75

72:                                               ; preds = %69
  %73 = load double, ptr %10, align 8, !tbaa !9
  %74 = fcmp olt double %73, 0x41F0000000000000
  br label %75

75:                                               ; preds = %72, %69
  %76 = phi i1 [ false, %69 ], [ %74, %72 ]
  %77 = xor i1 %76, true
  %78 = xor i1 %77, true
  %79 = xor i1 %78, true
  %80 = zext i1 %79 to i32
  %81 = sext i32 %80 to i64
  %82 = call i64 @llvm.expect.i64(i64 %81, i64 0)
  %83 = icmp ne i64 %82, 0
  br i1 %83, label %84, label %86

84:                                               ; preds = %75
  call void @wasm_rt_trap(i32 noundef 2) #5
  unreachable

85:                                               ; No predecessors!
  br label %89

86:                                               ; preds = %75
  %87 = load double, ptr %10, align 8, !tbaa !9
  %88 = fptoui double %87 to i32
  br label %89

89:                                               ; preds = %86, %85
  %90 = phi i32 [ 0, %85 ], [ %88, %86 ]
  br label %91

91:                                               ; preds = %89, %68
  %92 = phi i32 [ 0, %68 ], [ %90, %89 ]
  store i32 %92, ptr %6, align 4, !tbaa !11
  br label %94

93:                                               ; preds = %36
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %94

94:                                               ; preds = %93, %91
  %95 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %95, ptr %5, align 4, !tbaa !11
  store i32 254, ptr %7, align 4, !tbaa !11
  %96 = load i32, ptr %7, align 4, !tbaa !11
  %97 = load i32, ptr %6, align 4, !tbaa !11
  %98 = and i32 %97, %96
  store i32 %98, ptr %6, align 4, !tbaa !11
  %99 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %99, ptr %7, align 4, !tbaa !11
  %100 = load double, ptr %4, align 8, !tbaa !9
  store double %100, ptr %12, align 8, !tbaa !9
  %101 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %101, ptr %9, align 4, !tbaa !11
  %102 = load i32, ptr %9, align 4, !tbaa !11
  %103 = uitofp i32 %102 to double
  store double %103, ptr %13, align 8, !tbaa !9
  %104 = load double, ptr %12, align 8, !tbaa !9
  %105 = load double, ptr %13, align 8, !tbaa !9
  %106 = fcmp oeq double %104, %105
  %107 = zext i1 %106 to i32
  store i32 %107, ptr %8, align 4, !tbaa !11
  %108 = load i32, ptr %8, align 4, !tbaa !11
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %110, label %112

110:                                              ; preds = %94
  %111 = load i32, ptr %6, align 4, !tbaa !11
  br label %114

112:                                              ; preds = %94
  %113 = load i32, ptr %7, align 4, !tbaa !11
  br label %114

114:                                              ; preds = %112, %110
  %115 = phi i32 [ %111, %110 ], [ %113, %112 ]
  store i32 %115, ptr %6, align 4, !tbaa !11
  br label %116

116:                                              ; preds = %114, %35, %25
  %117 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %117, ptr %5, align 4, !tbaa !11
  %118 = load i32, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 %118
}

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

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AtoUInt8Clamp0x28double0x29(ptr nocapture noundef readnone %0, double noundef %1) local_unnamed_addr #1 {
  %3 = fcmp ult double %1, 5.000000e-01
  br i1 %3, label %19, label %4

4:                                                ; preds = %2
  %5 = fcmp ogt double %1, 2.550000e+02
  br i1 %5, label %19, label %6

6:                                                ; preds = %4
  %7 = fadd double %1, 5.000000e-01
  %8 = fcmp uge double %7, 0x41F0000000000000
  br i1 %8, label %14, label %9

9:                                                ; preds = %6
  %10 = fcmp ule double %7, -1.000000e+00
  br i1 %10, label %11, label %12, !prof !5

11:                                               ; preds = %9
  tail call void @wasm_rt_trap(i32 noundef 2) #2
  unreachable

12:                                               ; preds = %9
  %13 = fptoui double %7 to i32
  br label %14

14:                                               ; preds = %6, %12
  %.0 = phi i32 [ %13, %12 ], [ 0, %6 ]
  %15 = and i32 %.0, 254
  %16 = uitofp i32 %.0 to double
  %17 = fcmp oeq double %7, %16
  %18 = select i1 %17, i32 %15, i32 %.0
  br label %19

19:                                               ; preds = %4, %2, %14
  %.1 = phi i32 [ 0, %2 ], [ 255, %4 ], [ %18, %14 ]
  ret i32 %.1
}

attributes #0 = { 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 #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 = { 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}


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