; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Graphics/R3Viewer.ll (ZN8R3Viewer14TranslateWorldEdRK7R3Pointiiii)

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

%class.R3Vector = type { [3 x double] }
%class.R3Viewer = type { ptr, %class.R3Camera, %class.R2Viewport }
%class.R3Camera = type { %class.R3CoordSystem, double, double, double, double, double, ptr }
%class.R3CoordSystem = type { %class.R3Point, %class.R3Triad }
%class.R3Point = type { [3 x double] }
%class.R3Triad = type { [3 x %class.R3Vector] }
%class.R2Viewport = type { i32, i32, 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK10R2Viewport6HeightEv(ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK10R2Viewport5WidthEv(ptr noundef nonnull align 4 dereferenceable(16)) #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK8R3Camera4XFOVEv(ptr noundef nonnull align 8 dereferenceable(144)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8R3Viewer14TranslateWorldERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

declare void @_ZmlRK8R3Vectord(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), double noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera6OriginEv(ptr noundef nonnull align 8 dereferenceable(144)) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera2UpEv(ptr noundef nonnull align 8 dereferenceable(144)) #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8R3Viewer14TranslateWorldEdRK7R3Pointiiii(ptr noundef nonnull align 8 dereferenceable(168) %0, double noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) unnamed_addr #3 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca %class.R3Vector, align 8
  %19 = alloca %class.R3Vector, align 8
  %20 = alloca %class.R3Vector, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store double %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !11
  store i32 %4, ptr %12, align 4, !tbaa !11
  store i32 %5, ptr %13, align 4, !tbaa !11
  store i32 %6, ptr %14, align 4, !tbaa !11
  %21 = load ptr, ptr %8, align 8
  %22 = load i32, ptr %13, align 4, !tbaa !11
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %28

24:                                               ; preds = %7
  %25 = load i32, ptr %14, align 4, !tbaa !11
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  br label %61

28:                                               ; preds = %24, %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %29 = load double, ptr %9, align 8, !tbaa !9
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.R3Viewer, ptr %21, i32 0, i32 1
  %32 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera6OriginEv(ptr noundef nonnull align 8 dereferenceable(144) %31)
  %33 = call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %30, ptr noundef nonnull align 8 dereferenceable(24) %32)
  %34 = fmul double %29, %33
  %35 = getelementptr inbounds %class.R3Viewer, ptr %21, i32 0, i32 1
  %36 = call noundef double @_ZNK8R3Camera4XFOVEv(ptr noundef nonnull align 8 dereferenceable(144) %35)
  %37 = call double @tan(double noundef %36) #6
  %38 = fmul double %34, %37
  store double %38, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %39 = load double, ptr %15, align 8, !tbaa !9
  %40 = load i32, ptr %13, align 4, !tbaa !11
  %41 = sitofp i32 %40 to double
  %42 = fmul double %39, %41
  %43 = getelementptr inbounds %class.R3Viewer, ptr %21, i32 0, i32 2
  %44 = call noundef i32 @_ZNK10R2Viewport5WidthEv(ptr noundef nonnull align 4 dereferenceable(16) %43)
  %45 = sitofp i32 %44 to double
  %46 = fdiv double %42, %45
  store double %46, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %47 = load double, ptr %15, align 8, !tbaa !9
  %48 = load i32, ptr %14, align 4, !tbaa !11
  %49 = sitofp i32 %48 to double
  %50 = fmul double %47, %49
  %51 = getelementptr inbounds %class.R3Viewer, ptr %21, i32 0, i32 2
  %52 = call noundef i32 @_ZNK10R2Viewport6HeightEv(ptr noundef nonnull align 4 dereferenceable(16) %51)
  %53 = sitofp i32 %52 to double
  %54 = fdiv double %50, %53
  store double %54, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %19) #6
  %55 = getelementptr inbounds %class.R3Viewer, ptr %21, i32 0, i32 1
  %56 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera5RightEv(ptr noundef nonnull align 8 dereferenceable(144) %55)
  %57 = load double, ptr %16, align 8, !tbaa !9
  call void @_ZmlRK8R3Vectord(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %19, ptr noundef nonnull align 8 dereferenceable(24) %56, double noundef %57)
  call void @llvm.lifetime.start.p0(i64 24, ptr %20) #6
  %58 = getelementptr inbounds %class.R3Viewer, ptr %21, i32 0, i32 1
  %59 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera2UpEv(ptr noundef nonnull align 8 dereferenceable(144) %58)
  %60 = load double, ptr %17, align 8, !tbaa !9
  call void @_ZmlRK8R3Vectord(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %20, ptr noundef nonnull align 8 dereferenceable(24) %59, double noundef %60)
  call void @_ZplRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %18, ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull align 8 dereferenceable(24) %20)
  call void @llvm.lifetime.end.p0(i64 24, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %19) #6
  call void @_ZN8R3Viewer14TranslateWorldERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(168) %21, ptr noundef nonnull align 8 dereferenceable(24) %18)
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %61

61:                                               ; preds = %28, %27
  ret void
}

declare noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #4

declare void @_ZplRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera5RightEv(ptr noundef nonnull align 8 dereferenceable(144)) #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 = { mustprogress 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 = { "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 = { inlinehint mustprogress 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 #6 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

%class.R3Vector = type { [3 x double] }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK10R2Viewport6HeightEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK10R2Viewport5WidthEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK8R3Camera4XFOVEv(ptr noundef nonnull align 8 dereferenceable(144)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8R3Viewer14TranslateWorldERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

declare void @_ZmlRK8R3Vectord(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), double noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera6OriginEv(ptr noundef nonnull align 8 dereferenceable(144)) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera2UpEv(ptr noundef nonnull align 8 dereferenceable(144)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8R3Viewer14TranslateWorldEdRK7R3Pointiiii(ptr noundef nonnull align 8 dereferenceable(168) %0, double noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) unnamed_addr #3 align 2 {
  %8 = alloca %class.R3Vector, align 8
  %9 = alloca %class.R3Vector, align 8
  %10 = alloca %class.R3Vector, align 8
  %11 = or i32 %6, %5
  %or.cond = icmp eq i32 %11, 0
  br i1 %or.cond, label %33, label %12

12:                                               ; preds = %7
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera6OriginEv(ptr noundef nonnull align 8 dereferenceable(144) %13)
  %15 = tail call noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %14)
  %16 = fmul double %15, %1
  %17 = tail call noundef double @_ZNK8R3Camera4XFOVEv(ptr noundef nonnull align 8 dereferenceable(144) %13)
  %18 = tail call double @tan(double noundef %17) #6
  %19 = fmul double %16, %18
  %20 = sitofp i32 %5 to double
  %21 = fmul double %19, %20
  %22 = getelementptr inbounds i8, ptr %0, i64 152
  %23 = tail call noundef i32 @_ZNK10R2Viewport5WidthEv(ptr noundef nonnull align 4 dereferenceable(16) %22)
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %21, %24
  %26 = sitofp i32 %6 to double
  %27 = fmul double %19, %26
  %28 = tail call noundef i32 @_ZNK10R2Viewport6HeightEv(ptr noundef nonnull align 4 dereferenceable(16) %22)
  %29 = sitofp i32 %28 to double
  %30 = fdiv double %27, %29
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #6
  %31 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera5RightEv(ptr noundef nonnull align 8 dereferenceable(144) %13)
  call void @_ZmlRK8R3Vectord(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %9, ptr noundef nonnull align 8 dereferenceable(24) %31, double noundef %25)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #6
  %32 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera2UpEv(ptr noundef nonnull align 8 dereferenceable(144) %13)
  call void @_ZmlRK8R3Vectord(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %10, ptr noundef nonnull align 8 dereferenceable(24) %32, double noundef %30)
  call void @_ZplRK8R3VectorS1_(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %8, ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %10)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #6
  call void @_ZN8R3Viewer14TranslateWorldERK8R3Vector(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(24) %8)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #6
  br label %33

33:                                               ; preds = %7, %12
  ret void
}

declare noundef double @_Z10R3DistanceRK7R3PointS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

declare void @_ZplRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8R3Camera5RightEv(ptr noundef nonnull align 8 dereferenceable(144)) local_unnamed_addr #5 align 2

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


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