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

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; 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 float @Perspective_x(i32 noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %8, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %7, align 8, !tbaa !9
  %10 = getelementptr inbounds float, ptr %9, i64 0
  %11 = load float, ptr %10, align 4, !tbaa !11
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = sitofp i32 %12 to float
  %14 = load ptr, ptr %7, align 8, !tbaa !9
  %15 = getelementptr inbounds float, ptr %14, i64 1
  %16 = load float, ptr %15, align 4, !tbaa !11
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = sitofp i32 %17 to float
  %19 = fmul float %16, %18
  %20 = call float @llvm.fmuladd.f32(float %11, float %13, float %19)
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = getelementptr inbounds float, ptr %21, i64 2
  %23 = load float, ptr %22, align 4, !tbaa !11
  %24 = fadd float %20, %23
  %25 = load ptr, ptr %7, align 8, !tbaa !9
  %26 = getelementptr inbounds float, ptr %25, i64 6
  %27 = load float, ptr %26, align 4, !tbaa !11
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = sitofp i32 %28 to float
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = getelementptr inbounds float, ptr %30, i64 7
  %32 = load float, ptr %31, align 4, !tbaa !11
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = sitofp i32 %33 to float
  %35 = fmul float %32, %34
  %36 = call float @llvm.fmuladd.f32(float %27, float %29, float %35)
  %37 = fadd float %36, 1.000000e+00
  %38 = fdiv float %24, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret float %38
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local float @Perspective_x(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load float, ptr %2, align 4, !tbaa !5
  %5 = sitofp i32 %0 to float
  %6 = getelementptr inbounds i8, ptr %2, i64 4
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = sitofp i32 %1 to float
  %9 = getelementptr inbounds i8, ptr %2, i64 8
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %2, i64 24
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %2, i64 28
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = insertelement <2 x float> poison, float %7, i64 0
  %16 = insertelement <2 x float> %15, float %14, i64 1
  %17 = insertelement <2 x float> poison, float %8, i64 0
  %18 = shufflevector <2 x float> %17, <2 x float> poison, <2 x i32> zeroinitializer
  %19 = fmul <2 x float> %16, %18
  %20 = insertelement <2 x float> poison, float %4, i64 0
  %21 = insertelement <2 x float> %20, float %12, i64 1
  %22 = insertelement <2 x float> poison, float %5, i64 0
  %23 = shufflevector <2 x float> %22, <2 x float> poison, <2 x i32> zeroinitializer
  %24 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %21, <2 x float> %23, <2 x float> %19)
  %25 = insertelement <2 x float> <float poison, float 1.000000e+00>, float %10, i64 0
  %26 = fadd <2 x float> %25, %24
  %27 = extractelement <2 x float> %26, i64 0
  %28 = extractelement <2 x float> %26, i64 1
  %29 = fdiv float %27, %28
  ret float %29
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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