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

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

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

37:                                               ; preds = %3
  %38 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %38, ptr %9, align 4, !tbaa !11
  %39 = load i32, ptr %9, align 4, !tbaa !11
  %40 = icmp ne i32 %39, 0
  %41 = xor i1 %40, true
  %42 = zext i1 %41 to i32
  store i32 %42, ptr %9, align 4, !tbaa !11
  %43 = load i32, ptr %9, align 4, !tbaa !11
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %82

45:                                               ; preds = %37
  %46 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %46, ptr %9, align 4, !tbaa !11
  %47 = load double, ptr %5, align 8, !tbaa !9
  store double %47, ptr %15, align 8, !tbaa !9
  store double 0.000000e+00, ptr %16, align 8, !tbaa !9
  %48 = load double, ptr %15, align 8, !tbaa !9
  %49 = load double, ptr %16, align 8, !tbaa !9
  %50 = fcmp oeq double %48, %49
  %51 = zext i1 %50 to i32
  store i32 %51, ptr %10, align 4, !tbaa !11
  %52 = load i32, ptr %10, align 4, !tbaa !11
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %45
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %75

55:                                               ; preds = %45
  %56 = load double, ptr %5, align 8, !tbaa !9
  store double %56, ptr %15, align 8, !tbaa !9
  store double 0x43F0000000000000, ptr %16, align 8, !tbaa !9
  %57 = load double, ptr %16, align 8, !tbaa !9
  %58 = load double, ptr %15, align 8, !tbaa !9
  %59 = fmul double %58, %57
  store double %59, ptr %15, align 8, !tbaa !9
  %60 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %60, ptr %11, align 4, !tbaa !11
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load double, ptr %15, align 8, !tbaa !9
  %63 = load i32, ptr %11, align 4, !tbaa !11
  %64 = call double @w2c_hermes_frexp(ptr noundef %61, double noundef %62, i32 noundef %63)
  store double %64, ptr %15, align 8, !tbaa !9
  %65 = load double, ptr %15, align 8, !tbaa !9
  store double %65, ptr %5, align 8, !tbaa !9
  %66 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %66, ptr %10, align 4, !tbaa !11
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.w2c_hermes, ptr %67, i32 0, i32 6
  %69 = load i32, ptr %10, align 4, !tbaa !11
  %70 = zext i32 %69 to i64
  %71 = call i32 @i32_load(ptr noundef %68, i64 noundef %70)
  store i32 %71, ptr %10, align 4, !tbaa !11
  store i32 -64, ptr %11, align 4, !tbaa !11
  %72 = load i32, ptr %11, align 4, !tbaa !11
  %73 = load i32, ptr %10, align 4, !tbaa !11
  %74 = add i32 %73, %72
  store i32 %74, ptr %10, align 4, !tbaa !11
  br label %75

75:                                               ; preds = %55, %54
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.w2c_hermes, ptr %76, i32 0, i32 6
  %78 = load i32, ptr %9, align 4, !tbaa !11
  %79 = zext i32 %78 to i64
  %80 = load i32, ptr %10, align 4, !tbaa !11
  call void @i32_store(ptr noundef %77, i64 noundef %79, i32 noundef %80)
  %81 = load double, ptr %5, align 8, !tbaa !9
  store double %81, ptr %14, align 8, !tbaa !9
  br label %105

82:                                               ; preds = %37
  %83 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %83, ptr %9, align 4, !tbaa !11
  %84 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %84, ptr %10, align 4, !tbaa !11
  store i32 1022, ptr %11, align 4, !tbaa !11
  %85 = load i32, ptr %11, align 4, !tbaa !11
  %86 = load i32, ptr %10, align 4, !tbaa !11
  %87 = sub i32 %86, %85
  store i32 %87, ptr %10, align 4, !tbaa !11
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.w2c_hermes, ptr %88, i32 0, i32 6
  %90 = load i32, ptr %9, align 4, !tbaa !11
  %91 = zext i32 %90 to i64
  %92 = load i32, ptr %10, align 4, !tbaa !11
  call void @i32_store(ptr noundef %89, i64 noundef %91, i32 noundef %92)
  %93 = load i64, ptr %8, align 8, !tbaa !13
  store i64 %93, ptr %12, align 8, !tbaa !13
  store i64 -9218868437227405313, ptr %13, align 8, !tbaa !13
  %94 = load i64, ptr %13, align 8, !tbaa !13
  %95 = load i64, ptr %12, align 8, !tbaa !13
  %96 = and i64 %95, %94
  store i64 %96, ptr %12, align 8, !tbaa !13
  store i64 4602678819172646912, ptr %13, align 8, !tbaa !13
  %97 = load i64, ptr %13, align 8, !tbaa !13
  %98 = load i64, ptr %12, align 8, !tbaa !13
  %99 = or i64 %98, %97
  store i64 %99, ptr %12, align 8, !tbaa !13
  %100 = load i64, ptr %12, align 8, !tbaa !13
  %101 = call double @f64_reinterpret_i64(i64 noundef %100)
  store double %101, ptr %14, align 8, !tbaa !9
  br label %104

102:                                              ; preds = %3
  %103 = load double, ptr %5, align 8, !tbaa !9
  store double %103, ptr %14, align 8, !tbaa !9
  br label %104

104:                                              ; preds = %102, %82
  br label %105

105:                                              ; preds = %104, %75
  %106 = load double, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  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 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret double %106
}

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 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !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_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 i64 @i64_reinterpret_f64(double noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local double @w2c_hermes_frexp(ptr noundef %0, double noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = tail call i64 @i64_reinterpret_f64(double noundef %1)
  %5 = lshr i64 %4, 52
  %6 = trunc nuw nsw i64 %5 to i32
  %7 = and i32 %6, 2047
  switch i32 %7, label %19 [
    i32 2047, label %26
    i32 0, label %8
  ]

8:                                                ; preds = %3
  %9 = fcmp oeq double %1, 0.000000e+00
  br i1 %9, label %._crit_edge, label %10

._crit_edge:                                      ; preds = %8
  %.pre = zext i32 %2 to i64
  br label %17

10:                                               ; preds = %8
  %11 = fmul double %1, 0x43F0000000000000
  %12 = tail call double @w2c_hermes_frexp(ptr noundef %0, double noundef %11, i32 noundef %2)
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = zext i32 %2 to i64
  %15 = tail call i32 @i32_load(ptr noundef nonnull %13, i64 noundef %14)
  %16 = add i32 %15, -64
  br label %17

17:                                               ; preds = %._crit_edge, %10
  %.pre-phi = phi i64 [ %.pre, %._crit_edge ], [ %14, %10 ]
  %.052 = phi double [ %1, %._crit_edge ], [ %12, %10 ]
  %.051 = phi i32 [ 0, %._crit_edge ], [ %16, %10 ]
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @i32_store(ptr noundef nonnull %18, i64 noundef %.pre-phi, i32 noundef %.051)
  br label %26

19:                                               ; preds = %3
  %20 = add nsw i32 %7, -1022
  %21 = getelementptr inbounds i8, ptr %0, i64 40
  %22 = zext i32 %2 to i64
  tail call void @i32_store(ptr noundef nonnull %21, i64 noundef %22, i32 noundef %20)
  %23 = and i64 %4, -9218868437227405313
  %24 = or disjoint i64 %23, 4602678819172646912
  %25 = tail call double @f64_reinterpret_i64(i64 noundef %24)
  br label %26

26:                                               ; preds = %3, %19, %17
  %.0 = phi double [ %.052, %17 ], [ %25, %19 ], [ %1, %3 ]
  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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass