; LLVM IR from casensiom/fast-image-processing :: src (perspective)

; 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.STextureTriangle = type { [3 x %struct.STextureVector], i32 }
%struct.STextureVector = type { i32, i32, float, float }

; Function Attrs: nounwind uwtable
define dso_local void @set_triangle(ptr dead_on_unwind noalias writable sret(%struct.STextureTriangle) align 4 %0, i32 noundef %1, i32 noundef %2, float noundef %3, float noundef %4, i32 noundef %5, i32 noundef %6, float noundef %7, float noundef %8, i32 noundef %9, i32 noundef %10, float noundef %11, float noundef %12) #0 {
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca float, align 4
  %21 = alloca float, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca float, align 4
  %25 = alloca float, align 4
  %26 = alloca %struct.STextureTriangle, align 4
  %27 = alloca %struct.STextureTriangle, align 8
  %28 = alloca %struct.STextureTriangle, align 4
  %29 = alloca %struct.STextureTriangle, align 8
  store i32 %1, ptr %14, align 4, !tbaa !5
  store i32 %2, ptr %15, align 4, !tbaa !5
  store float %3, ptr %16, align 4, !tbaa !9
  store float %4, ptr %17, align 4, !tbaa !9
  store i32 %5, ptr %18, align 4, !tbaa !5
  store i32 %6, ptr %19, align 4, !tbaa !5
  store float %7, ptr %20, align 4, !tbaa !9
  store float %8, ptr %21, align 4, !tbaa !9
  store i32 %9, ptr %22, align 4, !tbaa !5
  store i32 %10, ptr %23, align 4, !tbaa !5
  store float %11, ptr %24, align 4, !tbaa !9
  store float %12, ptr %25, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 52, ptr %26) #3
  %30 = load i32, ptr %14, align 4, !tbaa !5
  %31 = load i32, ptr %15, align 4, !tbaa !5
  %32 = load i32, ptr %18, align 4, !tbaa !5
  %33 = load i32, ptr %19, align 4, !tbaa !5
  %34 = load i32, ptr %22, align 4, !tbaa !5
  %35 = load i32, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 52, ptr %27) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %27, ptr align 4 %0, i64 52, i1 false), !tbaa.struct !11
  call void @init_triangle(ptr dead_on_unwind writable sret(%struct.STextureTriangle) align 4 %26, ptr noundef byval(%struct.STextureTriangle) align 8 %27, i32 noundef %30, i32 noundef %31, i32 noundef %32, i32 noundef %33, i32 noundef %34, i32 noundef %35)
  call void @llvm.lifetime.end.p0(i64 52, ptr %27) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %26, i64 52, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 52, ptr %26) #3
  call void @llvm.lifetime.start.p0(i64 52, ptr %28) #3
  %36 = load float, ptr %16, align 4, !tbaa !9
  %37 = load float, ptr %17, align 4, !tbaa !9
  %38 = load float, ptr %20, align 4, !tbaa !9
  %39 = load float, ptr %21, align 4, !tbaa !9
  %40 = load float, ptr %24, align 4, !tbaa !9
  %41 = load float, ptr %25, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 52, ptr %29) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %29, ptr align 4 %0, i64 52, i1 false), !tbaa.struct !11
  call void @init_texture(ptr dead_on_unwind writable sret(%struct.STextureTriangle) align 4 %28, ptr noundef byval(%struct.STextureTriangle) align 8 %29, float noundef %36, float noundef %37, float noundef %38, float noundef %39, float noundef %40, float noundef %41)
  call void @llvm.lifetime.end.p0(i64 52, ptr %29) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %28, i64 52, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 52, ptr %28) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_triangle(ptr dead_on_unwind noalias writable sret(%struct.STextureTriangle) align 4, ptr noundef byval(%struct.STextureTriangle) align 8, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_texture(ptr dead_on_unwind noalias writable sret(%struct.STextureTriangle) align 4, ptr noundef byval(%struct.STextureTriangle) align 8, float noundef, float noundef, float noundef, float noundef, float noundef, float noundef) #0

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"float", !7, i64 0}
!11 = !{i64 0, i64 48, !12, i64 48, i64 4, !5}
!12 = !{!7, !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"

%struct.STextureTriangle = type { [3 x %struct.STextureVector], i32 }
%struct.STextureVector = type { i32, i32, float, float }

; Function Attrs: nounwind uwtable
define dso_local void @set_triangle(ptr dead_on_unwind noalias nocapture writable sret(%struct.STextureTriangle) align 4 %0, i32 noundef %1, i32 noundef %2, float noundef %3, float noundef %4, i32 noundef %5, i32 noundef %6, float noundef %7, float noundef %8, i32 noundef %9, i32 noundef %10, float noundef %11, float noundef %12) local_unnamed_addr #0 {
  %14 = alloca %struct.STextureTriangle, align 8
  %15 = alloca %struct.STextureTriangle, align 4
  %16 = alloca %struct.STextureTriangle, align 8
  call void @llvm.lifetime.start.p0(i64 52, ptr nonnull %14) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(52) %14, ptr noundef nonnull align 4 dereferenceable(52) %0, i64 52, i1 false), !tbaa.struct !5
  tail call void @init_triangle(ptr dead_on_unwind nonnull writable sret(%struct.STextureTriangle) align 4 %0, ptr noundef nonnull byval(%struct.STextureTriangle) align 8 %14, i32 noundef %1, i32 noundef %2, i32 noundef %5, i32 noundef %6, i32 noundef %9, i32 noundef %10)
  call void @llvm.lifetime.end.p0(i64 52, ptr nonnull %14) #3
  call void @llvm.lifetime.start.p0(i64 52, ptr nonnull %15) #3
  call void @llvm.lifetime.start.p0(i64 52, ptr nonnull %16) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(52) %16, ptr noundef nonnull align 4 dereferenceable(52) %0, i64 52, i1 false), !tbaa.struct !5
  call void @init_texture(ptr dead_on_unwind nonnull writable sret(%struct.STextureTriangle) align 4 %15, ptr noundef nonnull byval(%struct.STextureTriangle) align 8 %16, float noundef %3, float noundef %4, float noundef %7, float noundef %8, float noundef %11, float noundef %12)
  call void @llvm.lifetime.end.p0(i64 52, ptr nonnull %16) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(52) %0, ptr noundef nonnull align 4 dereferenceable(52) %15, i64 52, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 52, ptr nonnull %15) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_triangle(ptr dead_on_unwind noalias writable sret(%struct.STextureTriangle) align 4, ptr noundef byval(%struct.STextureTriangle) align 8, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @init_texture(ptr dead_on_unwind noalias writable sret(%struct.STextureTriangle) align 4, ptr noundef byval(%struct.STextureTriangle) align 8, float noundef, float noundef, float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #0

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


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass