; LLVM IR from jingweizhanghuai/Morn :: src/image (morn_image_geometry)

; 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.MImagePoint = type { float, float }

; 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
declare double @cos(double noundef) #1

; Function Attrs: nounwind
declare double @sin(double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nounwind uwtable
define dso_local void @m_PointRotate(ptr noundef %0, ptr noundef %1, float noundef %2, float noundef %3, float noundef %4) #3 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  store float %4, ptr %10, align 4, !tbaa !9
  %15 = load float, ptr %8, align 4, !tbaa !9
  %16 = fpext float %15 to double
  %17 = fmul double %16, 0x400921FB54442D18
  %18 = fdiv double %17, 1.800000e+02
  %19 = fsub double 0.000000e+00, %18
  %20 = fptrunc double %19 to float
  store float %20, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %21 = load float, ptr %8, align 4, !tbaa !9
  %22 = fpext float %21 to double
  %23 = call double @cos(double noundef %22) #4
  %24 = fptrunc double %23 to float
  store float %24, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %25 = load float, ptr %8, align 4, !tbaa !9
  %26 = fpext float %25 to double
  %27 = call double @sin(double noundef %26) #4
  %28 = fptrunc double %27 to float
  store float %28, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.MImagePoint, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !11
  store float %31, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.MImagePoint, ptr %32, i32 0, i32 1
  %34 = load float, ptr %33, align 4, !tbaa !13
  store float %34, ptr %14, align 4, !tbaa !9
  %35 = load float, ptr %9, align 4, !tbaa !9
  %36 = load float, ptr %13, align 4, !tbaa !9
  %37 = load float, ptr %9, align 4, !tbaa !9
  %38 = fsub float %36, %37
  %39 = load float, ptr %11, align 4, !tbaa !9
  %40 = call float @llvm.fmuladd.f32(float %38, float %39, float %35)
  %41 = load float, ptr %14, align 4, !tbaa !9
  %42 = load float, ptr %10, align 4, !tbaa !9
  %43 = fsub float %41, %42
  %44 = load float, ptr %12, align 4, !tbaa !9
  %45 = call float @llvm.fmuladd.f32(float %43, float %44, float %40)
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.MImagePoint, ptr %46, i32 0, i32 0
  store float %45, ptr %47, align 4, !tbaa !11
  %48 = load float, ptr %10, align 4, !tbaa !9
  %49 = load float, ptr %13, align 4, !tbaa !9
  %50 = load float, ptr %9, align 4, !tbaa !9
  %51 = fsub float %49, %50
  %52 = load float, ptr %12, align 4, !tbaa !9
  %53 = fneg float %51
  %54 = call float @llvm.fmuladd.f32(float %53, float %52, float %48)
  %55 = load float, ptr %14, align 4, !tbaa !9
  %56 = load float, ptr %10, align 4, !tbaa !9
  %57 = fsub float %55, %56
  %58 = load float, ptr %11, align 4, !tbaa !9
  %59 = call float @llvm.fmuladd.f32(float %57, float %58, float %54)
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.MImagePoint, ptr %60, i32 0, i32 1
  store float %59, ptr %61, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 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 }

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"MImagePoint", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}


; 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: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @m_PointRotate(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, float noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #1 {
  %6 = fpext float %2 to double
  %7 = fmul double %6, 0x400921FB54442D18
  %8 = fdiv double %7, 1.800000e+02
  %9 = fsub double 0.000000e+00, %8
  %10 = fptrunc double %9 to float
  %11 = fpext float %10 to double
  %12 = tail call double @cos(double noundef %11) #3
  %13 = tail call double @sin(double noundef %11) #3
  %14 = load float, ptr %0, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %16 = load float, ptr %15, align 4, !tbaa !10
  %17 = fsub float %14, %3
  %18 = fsub float %16, %4
  %19 = fneg float %17
  %20 = insertelement <2 x double> poison, double %13, i64 0
  %21 = insertelement <2 x double> %20, double %12, i64 1
  %22 = fptrunc <2 x double> %21 to <2 x float>
  %23 = insertelement <2 x float> poison, float %19, i64 0
  %24 = insertelement <2 x float> %23, float %17, i64 1
  %25 = insertelement <2 x float> poison, float %4, i64 0
  %26 = insertelement <2 x float> %25, float %3, i64 1
  %27 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %24, <2 x float> %22, <2 x float> %26)
  %28 = shufflevector <2 x float> %27, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %29 = insertelement <2 x float> poison, float %18, i64 0
  %30 = shufflevector <2 x float> %29, <2 x float> poison, <2 x i32> zeroinitializer
  %31 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %30, <2 x float> %22, <2 x float> %28)
  store <2 x float> %31, ptr %1, align 4, !tbaa !11
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #2

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 nofree nounwind willreturn memory(write, argmem: readwrite) 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, !7, i64 0}
!6 = !{!"MImagePoint", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass