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

; 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 double @f64_load(ptr noundef, 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_tan(ptr noundef %0, double noundef %1) #2 {
  %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 i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca double, align 8
  %14 = 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
  store i32 0, ptr %6, align 4, !tbaa !11
  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 4, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.w2c_hermes, ptr %15, i32 0, i32 3
  %17 = load i32, ptr %16, align 8, !tbaa !13
  store i32 %17, ptr %7, align 4, !tbaa !11
  store i32 16, ptr %8, align 4, !tbaa !11
  %18 = load i32, ptr %8, align 4, !tbaa !11
  %19 = load i32, ptr %7, align 4, !tbaa !11
  %20 = sub i32 %19, %18
  store i32 %20, ptr %7, align 4, !tbaa !11
  %21 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %21, ptr %5, align 4, !tbaa !11
  %22 = load i32, ptr %7, align 4, !tbaa !11
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.w2c_hermes, ptr %23, i32 0, i32 3
  store i32 %22, ptr %24, align 8, !tbaa !13
  %25 = load double, ptr %4, align 8, !tbaa !9
  store double %25, ptr %13, align 8, !tbaa !9
  %26 = load double, ptr %13, align 8, !tbaa !9
  %27 = call i64 @i64_reinterpret_f64(double noundef %26)
  store i64 %27, ptr %11, align 8, !tbaa !19
  store i64 32, ptr %12, align 8, !tbaa !19
  %28 = load i64, ptr %12, align 8, !tbaa !19
  %29 = and i64 %28, 63
  %30 = load i64, ptr %11, align 8, !tbaa !19
  %31 = lshr i64 %30, %29
  store i64 %31, ptr %11, align 8, !tbaa !19
  %32 = load i64, ptr %11, align 8, !tbaa !19
  %33 = trunc i64 %32 to i32
  store i32 %33, ptr %7, align 4, !tbaa !11
  store i32 2147483647, ptr %8, align 4, !tbaa !11
  %34 = load i32, ptr %8, align 4, !tbaa !11
  %35 = load i32, ptr %7, align 4, !tbaa !11
  %36 = and i32 %35, %34
  store i32 %36, ptr %7, align 4, !tbaa !11
  %37 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %37, ptr %6, align 4, !tbaa !11
  store i32 1072243195, ptr %8, align 4, !tbaa !11
  %38 = load i32, ptr %7, align 4, !tbaa !11
  %39 = load i32, ptr %8, align 4, !tbaa !11
  %40 = icmp ule i32 %38, %39
  %41 = zext i1 %40 to i32
  store i32 %41, ptr %7, align 4, !tbaa !11
  %42 = load i32, ptr %7, align 4, !tbaa !11
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %61

44:                                               ; preds = %2
  %45 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %45, ptr %7, align 4, !tbaa !11
  store i32 1044381696, ptr %8, align 4, !tbaa !11
  %46 = load i32, ptr %7, align 4, !tbaa !11
  %47 = load i32, ptr %8, align 4, !tbaa !11
  %48 = icmp ult i32 %46, %47
  %49 = zext i1 %48 to i32
  store i32 %49, ptr %7, align 4, !tbaa !11
  %50 = load i32, ptr %7, align 4, !tbaa !11
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %44
  br label %107

53:                                               ; preds = %44
  %54 = load double, ptr %4, align 8, !tbaa !9
  store double %54, ptr %13, align 8, !tbaa !9
  store double 0.000000e+00, ptr %14, align 8, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !11
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load double, ptr %13, align 8, !tbaa !9
  %57 = load double, ptr %14, align 8, !tbaa !9
  %58 = load i32, ptr %9, align 4, !tbaa !11
  %59 = call double @w2c_hermes_0x5F_tan(ptr noundef %55, double noundef %56, double noundef %57, i32 noundef %58)
  store double %59, ptr %13, align 8, !tbaa !9
  %60 = load double, ptr %13, align 8, !tbaa !9
  store double %60, ptr %4, align 8, !tbaa !9
  br label %107

61:                                               ; preds = %2
  %62 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %62, ptr %7, align 4, !tbaa !11
  store i32 2146435072, ptr %8, align 4, !tbaa !11
  %63 = load i32, ptr %7, align 4, !tbaa !11
  %64 = load i32, ptr %8, align 4, !tbaa !11
  %65 = icmp uge i32 %63, %64
  %66 = zext i1 %65 to i32
  store i32 %66, ptr %7, align 4, !tbaa !11
  %67 = load i32, ptr %7, align 4, !tbaa !11
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %76

69:                                               ; preds = %61
  %70 = load double, ptr %4, align 8, !tbaa !9
  store double %70, ptr %13, align 8, !tbaa !9
  %71 = load double, ptr %4, align 8, !tbaa !9
  store double %71, ptr %14, align 8, !tbaa !9
  %72 = load double, ptr %14, align 8, !tbaa !9
  %73 = load double, ptr %13, align 8, !tbaa !9
  %74 = fsub double %73, %72
  store double %74, ptr %13, align 8, !tbaa !9
  %75 = load double, ptr %13, align 8, !tbaa !9
  store double %75, ptr %4, align 8, !tbaa !9
  br label %107

76:                                               ; preds = %61
  %77 = load double, ptr %4, align 8, !tbaa !9
  store double %77, ptr %13, align 8, !tbaa !9
  %78 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %78, ptr %8, align 4, !tbaa !11
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = load double, ptr %13, align 8, !tbaa !9
  %81 = load i32, ptr %8, align 4, !tbaa !11
  %82 = call i32 @w2c_hermes_0x5F_rem_pio2(ptr noundef %79, double noundef %80, i32 noundef %81)
  store i32 %82, ptr %7, align 4, !tbaa !11
  %83 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %83, ptr %6, align 4, !tbaa !11
  %84 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %84, ptr %7, align 4, !tbaa !11
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.w2c_hermes, ptr %85, i32 0, i32 6
  %87 = load i32, ptr %7, align 4, !tbaa !11
  %88 = zext i32 %87 to i64
  %89 = call double @f64_load(ptr noundef %86, i64 noundef %88)
  store double %89, ptr %13, align 8, !tbaa !9
  %90 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %90, ptr %8, align 4, !tbaa !11
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.w2c_hermes, ptr %91, i32 0, i32 6
  %93 = load i32, ptr %8, align 4, !tbaa !11
  %94 = zext i32 %93 to i64
  %95 = add i64 %94, 8
  %96 = call double @f64_load(ptr noundef %92, i64 noundef %95)
  store double %96, ptr %14, align 8, !tbaa !9
  %97 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %97, ptr %9, align 4, !tbaa !11
  store i32 1, ptr %10, align 4, !tbaa !11
  %98 = load i32, ptr %10, align 4, !tbaa !11
  %99 = load i32, ptr %9, align 4, !tbaa !11
  %100 = and i32 %99, %98
  store i32 %100, ptr %9, align 4, !tbaa !11
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = load double, ptr %13, align 8, !tbaa !9
  %103 = load double, ptr %14, align 8, !tbaa !9
  %104 = load i32, ptr %9, align 4, !tbaa !11
  %105 = call double @w2c_hermes_0x5F_tan(ptr noundef %101, double noundef %102, double noundef %103, i32 noundef %104)
  store double %105, ptr %13, align 8, !tbaa !9
  %106 = load double, ptr %13, align 8, !tbaa !9
  store double %106, ptr %4, align 8, !tbaa !9
  br label %107

107:                                              ; preds = %76, %69, %53, %52
  %108 = load i32, ptr %5, align 4, !tbaa !11
  store i32 %108, ptr %7, align 4, !tbaa !11
  store i32 16, ptr %8, align 4, !tbaa !11
  %109 = load i32, ptr %8, align 4, !tbaa !11
  %110 = load i32, ptr %7, align 4, !tbaa !11
  %111 = add i32 %110, %109
  store i32 %111, ptr %7, align 4, !tbaa !11
  %112 = load i32, ptr %7, align 4, !tbaa !11
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.w2c_hermes, ptr %113, i32 0, i32 3
  store i32 %112, ptr %114, align 8, !tbaa !13
  %115 = load double, ptr %4, align 8, !tbaa !9
  store double %115, ptr %13, align 8, !tbaa !9
  %116 = load double, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  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 4, 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 double %116
}

declare double @w2c_hermes_0x5F_tan(ptr noundef, double noundef, double noundef, i32 noundef) #3

declare i32 @w2c_hermes_0x5F_rem_pio2(ptr noundef, double noundef, i32 noundef) #3

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

!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, !12, i64 24}
!14 = !{!"w2c_hermes", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !15, i64 40, !18, i64 80}
!15 = !{!"", !6, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !17, i64 32}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!"", !6, i64 0, !12, i64 8, !12, i64 12}
!19 = !{!16, !16, 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_load(ptr noundef, 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_tan(ptr noundef %0, double noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = add i32 %4, -16
  store i32 %5, ptr %3, align 8, !tbaa !5
  %6 = tail call i64 @i64_reinterpret_f64(double noundef %1)
  %7 = lshr i64 %6, 32
  %8 = trunc nuw i64 %7 to i32
  %9 = and i32 %8, 2147483647
  %10 = icmp ult i32 %9, 1072243196
  br i1 %10, label %11, label %15

11:                                               ; preds = %2
  %12 = icmp ult i32 %9, 1044381696
  br i1 %12, label %28, label %13

13:                                               ; preds = %11
  %14 = tail call double @w2c_hermes_0x5F_tan(ptr noundef nonnull %0, double noundef %1, double noundef 0.000000e+00, i32 noundef 0) #3
  br label %28

15:                                               ; preds = %2
  %16 = icmp ugt i32 %9, 2146435071
  br i1 %16, label %17, label %19

17:                                               ; preds = %15
  %18 = fsub double %1, %1
  br label %28

19:                                               ; preds = %15
  %20 = tail call i32 @w2c_hermes_0x5F_rem_pio2(ptr noundef nonnull %0, double noundef %1, i32 noundef %5) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 40
  %22 = zext i32 %5 to i64
  %23 = tail call double @f64_load(ptr noundef nonnull %21, i64 noundef %22)
  %24 = add nuw nsw i64 %22, 8
  %25 = tail call double @f64_load(ptr noundef nonnull %21, i64 noundef %24)
  %26 = and i32 %20, 1
  %27 = tail call double @w2c_hermes_0x5F_tan(ptr noundef nonnull %0, double noundef %23, double noundef %25, i32 noundef %26) #3
  br label %28

28:                                               ; preds = %11, %19, %17, %13
  %.0 = phi double [ %1, %11 ], [ %14, %13 ], [ %18, %17 ], [ %27, %19 ]
  store i32 %4, ptr %3, align 8, !tbaa !5
  ret double %.0
}

declare double @w2c_hermes_0x5F_tan(ptr noundef, double noundef, double noundef, i32 noundef) local_unnamed_addr #2

declare i32 @w2c_hermes_0x5F_rem_pio2(ptr noundef, double noundef, i32 noundef) local_unnamed_addr #2

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" }
attributes #2 = { "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, !10, i64 24}
!6 = !{!"w2c_hermes", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !11, i64 40, !14, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !7, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !13, i64 32}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12}


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