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

; 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.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.R3Vector = type { [3 x double] }
%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: 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 @_ZN8R3Viewer10ScaleWorldERK7R3Pointd(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(24), double noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8R3Viewer10ScaleWorldEdRK7R3Pointiiii(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 #2 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
  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
  %17 = load ptr, ptr %8, align 8
  %18 = load i32, ptr %13, align 4, !tbaa !11
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %24

20:                                               ; preds = %7
  %21 = load i32, ptr %14, align 4, !tbaa !11
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %45

24:                                               ; preds = %20, %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %25 = load i32, ptr %13, align 4, !tbaa !11
  %26 = sitofp i32 %25 to double
  %27 = getelementptr inbounds %class.R3Viewer, ptr %17, i32 0, i32 2
  %28 = call noundef i32 @_ZNK10R2Viewport5WidthEv(ptr noundef nonnull align 4 dereferenceable(16) %27)
  %29 = sitofp i32 %28 to double
  %30 = fdiv double %26, %29
  %31 = load i32, ptr %14, align 4, !tbaa !11
  %32 = sitofp i32 %31 to double
  %33 = getelementptr inbounds %class.R3Viewer, ptr %17, i32 0, i32 2
  %34 = call noundef i32 @_ZNK10R2Viewport6HeightEv(ptr noundef nonnull align 4 dereferenceable(16) %33)
  %35 = sitofp i32 %34 to double
  %36 = fdiv double %32, %35
  %37 = fadd double %30, %36
  store double %37, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %38 = load double, ptr %9, align 8, !tbaa !9
  %39 = fmul double 2.000000e+00, %38
  %40 = load double, ptr %15, align 8, !tbaa !9
  %41 = fmul double %39, %40
  %42 = call double @exp(double noundef %41) #4
  store double %42, ptr %16, align 8, !tbaa !9
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = load double, ptr %16, align 8, !tbaa !9
  call void @_ZN8R3Viewer10ScaleWorldERK7R3Pointd(ptr noundef nonnull align 8 dereferenceable(168) %17, ptr noundef nonnull align 8 dereferenceable(24) %43, double noundef %44)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %45

45:                                               ; preds = %24, %23
  ret void
}

; Function Attrs: nounwind
declare double @exp(double noundef) #3

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 = { 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 #3 = { 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 #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++ 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"

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8R3Viewer10ScaleWorldEdRK7R3Pointiiii(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 #1 align 2 {
  %8 = or i32 %6, %5
  %or.cond = icmp eq i32 %8, 0
  br i1 %or.cond, label %25, label %9

9:                                                ; preds = %7
  %10 = insertelement <2 x i32> poison, i32 %5, i64 0
  %11 = insertelement <2 x i32> %10, i32 %6, i64 1
  %12 = sitofp <2 x i32> %11 to <2 x double>
  %13 = getelementptr inbounds i8, ptr %0, i64 152
  %14 = tail call noundef i32 @_ZNK10R2Viewport5WidthEv(ptr noundef nonnull align 4 dereferenceable(16) %13)
  %15 = tail call noundef i32 @_ZNK10R2Viewport6HeightEv(ptr noundef nonnull align 4 dereferenceable(16) %13)
  %16 = insertelement <2 x i32> poison, i32 %14, i64 0
  %17 = insertelement <2 x i32> %16, i32 %15, i64 1
  %18 = sitofp <2 x i32> %17 to <2 x double>
  %19 = fdiv <2 x double> %12, %18
  %shift = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %20 = fadd <2 x double> %19, %shift
  %21 = extractelement <2 x double> %20, i64 0
  %22 = fmul double %1, 2.000000e+00
  %23 = fmul double %22, %21
  %24 = tail call double @exp(double noundef %23) #3
  tail call void @_ZN8R3Viewer10ScaleWorldERK7R3Pointd(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(24) %2, double noundef %24)
  br label %25

25:                                               ; preds = %7, %9
  ret void
}

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

attributes #0 = { 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 #1 = { 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 #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 = { 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,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass