; 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.MList = type { i32, ptr }
%struct.MImagePoint = type { float, float }

@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1

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

60:                                               ; preds = %107, %5
  %61 = load i32, ptr %15, align 4, !tbaa !11
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.MList, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !13
  %65 = icmp slt i32 %61, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %110

67:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.MList, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = load i32, ptr %15, align 4, !tbaa !11
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds ptr, ptr %70, i64 %72
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  store ptr %74, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.MList, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  %78 = load i32, ptr %15, align 4, !tbaa !11
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds ptr, ptr %77, i64 %79
  %81 = load ptr, ptr %80, align 8, !tbaa !5
  store ptr %81, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %82 = load ptr, ptr %16, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.MImagePoint, ptr %82, i32 0, i32 0
  %84 = load float, ptr %83, align 4, !tbaa !16
  store float %84, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %85 = load ptr, ptr %16, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.MImagePoint, ptr %85, i32 0, i32 1
  %87 = load float, ptr %86, align 4, !tbaa !18
  store float %87, ptr %19, align 4, !tbaa !9
  %88 = load float, ptr %13, align 4, !tbaa !9
  %89 = load float, ptr %18, align 4, !tbaa !9
  %90 = load float, ptr %11, align 4, !tbaa !9
  %91 = call float @llvm.fmuladd.f32(float %89, float %90, float %88)
  %92 = load float, ptr %19, align 4, !tbaa !9
  %93 = load float, ptr %12, align 4, !tbaa !9
  %94 = call float @llvm.fmuladd.f32(float %92, float %93, float %91)
  %95 = load ptr, ptr %17, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.MImagePoint, ptr %95, i32 0, i32 0
  store float %94, ptr %96, align 4, !tbaa !16
  %97 = load float, ptr %14, align 4, !tbaa !9
  %98 = load float, ptr %18, align 4, !tbaa !9
  %99 = load float, ptr %12, align 4, !tbaa !9
  %100 = fneg float %98
  %101 = call float @llvm.fmuladd.f32(float %100, float %99, float %97)
  %102 = load float, ptr %19, align 4, !tbaa !9
  %103 = load float, ptr %11, align 4, !tbaa !9
  %104 = call float @llvm.fmuladd.f32(float %102, float %103, float %101)
  %105 = load ptr, ptr %17, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.MImagePoint, ptr %105, i32 0, i32 1
  store float %104, ptr %106, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %107

107:                                              ; preds = %67
  %108 = load i32, ptr %15, align 4, !tbaa !11
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %15, align 4, !tbaa !11
  br label %60, !llvm.loop !19

110:                                              ; preds = %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  ret void
}

; Function Attrs: nounwind
declare double @cos(double noundef) #2

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

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

declare i32 @printf(ptr noundef, ...) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { "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 #5 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"MList", !12, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!17, !10, i64 0}
!17 = !{!"MImagePoint", !10, i64 0, !10, i64 4}
!18 = !{!17, !10, i64 4}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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

@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @m_PolygonRotate(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, float noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #0 {
  %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) #4
  %13 = tail call double @sin(double noundef %11) #4
  %14 = fneg float %3
  %15 = fneg float %4
  %16 = insertelement <2 x double> poison, double %13, i64 0
  %17 = insertelement <2 x double> %16, double %12, i64 1
  %18 = fptrunc <2 x double> %17 to <2 x float>
  %19 = insertelement <2 x float> poison, float %3, i64 0
  %20 = insertelement <2 x float> %19, float %14, i64 1
  %21 = insertelement <2 x float> poison, float %4, i64 0
  %22 = insertelement <2 x float> %21, float %3, i64 1
  %23 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %20, <2 x float> %18, <2 x float> %22)
  %24 = shufflevector <2 x float> %23, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %25 = insertelement <2 x float> poison, float %15, i64 0
  %26 = shufflevector <2 x float> %25, <2 x float> poison, <2 x i32> zeroinitializer
  %27 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %26, <2 x float> %18, <2 x float> %24)
  %28 = fpext float %3 to double
  %29 = fpext float %4 to double
  %30 = extractelement <2 x float> %27, i64 0
  %31 = fpext float %30 to double
  %32 = extractelement <2 x float> %27, i64 1
  %33 = fpext float %32 to double
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %28, double noundef %29, double noundef %31, double noundef %33)
  %35 = load i32, ptr %0, align 8, !tbaa !5
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %37 = getelementptr inbounds i8, ptr %0, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds i8, ptr %1, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %wide.trip.count = zext nneg i32 %35 to i64
  %41 = shufflevector <2 x float> %18, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  br label %42

._crit_edge:                                      ; preds = %42, %5
  ret void

42:                                               ; preds = %.lr.ph, %42
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %42 ]
  %43 = getelementptr inbounds ptr, ptr %38, i64 %indvars.iv
  %44 = load ptr, ptr %43, align 8, !tbaa !12
  %45 = getelementptr inbounds ptr, ptr %40, i64 %indvars.iv
  %46 = load ptr, ptr %45, align 8, !tbaa !12
  %47 = load float, ptr %44, align 4, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %44, i64 4
  %49 = load float, ptr %48, align 4, !tbaa !16
  %50 = fneg float %47
  %51 = insertelement <2 x float> poison, float %47, i64 0
  %52 = insertelement <2 x float> %51, float %50, i64 1
  %53 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %52, <2 x float> %41, <2 x float> %27)
  %54 = insertelement <2 x float> poison, float %49, i64 0
  %55 = shufflevector <2 x float> %54, <2 x float> poison, <2 x i32> zeroinitializer
  %56 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %55, <2 x float> %18, <2 x float> %53)
  store <2 x float> %56, ptr %46, align 4, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %42, !llvm.loop !18
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; 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>) #3

attributes #0 = { nofree 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 = { 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 #2 = { nofree 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"MList", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!10, !10, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"MImagePoint", !15, i64 0, !15, i64 4}
!15 = !{!"float", !8, i64 0}
!16 = !{!14, !15, i64 4}
!17 = !{!15, !15, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass