; LLVM IR from aap/librw :: tools/subrast/subrast.ll (Z19CameraSetViewWindowPN2rw6CameraEfff)

; 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.rw::V2d" = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z19CameraSetViewWindowPN2rw6CameraEfff(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca %"struct.rw::V2d", align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = load float, ptr %6, align 4, !tbaa !9
  %11 = load float, ptr %7, align 4, !tbaa !9
  %12 = fcmp ogt float %10, %11
  br i1 %12, label %13, label %22

13:                                               ; preds = %4
  %14 = load float, ptr %8, align 4, !tbaa !9
  %15 = getelementptr inbounds %"struct.rw::V2d", ptr %9, i32 0, i32 0
  store float %14, ptr %15, align 4, !tbaa !11
  %16 = load float, ptr %8, align 4, !tbaa !9
  %17 = load float, ptr %6, align 4, !tbaa !9
  %18 = load float, ptr %7, align 4, !tbaa !9
  %19 = fdiv float %17, %18
  %20 = fdiv float %16, %19
  %21 = getelementptr inbounds %"struct.rw::V2d", ptr %9, i32 0, i32 1
  store float %20, ptr %21, align 4, !tbaa !13
  br label %31

22:                                               ; preds = %4
  %23 = load float, ptr %8, align 4, !tbaa !9
  %24 = load float, ptr %7, align 4, !tbaa !9
  %25 = load float, ptr %6, align 4, !tbaa !9
  %26 = fdiv float %24, %25
  %27 = fdiv float %23, %26
  %28 = getelementptr inbounds %"struct.rw::V2d", ptr %9, i32 0, i32 0
  store float %27, ptr %28, align 4, !tbaa !11
  %29 = load float, ptr %8, align 4, !tbaa !9
  %30 = getelementptr inbounds %"struct.rw::V2d", ptr %9, i32 0, i32 1
  store float %29, ptr %30, align 4, !tbaa !13
  br label %31

31:                                               ; preds = %22, %13
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw6Camera13setViewWindowEPKNS_3V2dE(ptr noundef nonnull align 8 dereferenceable(600) %32, ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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

declare void @_ZN2rw6Camera13setViewWindowEPKNS_3V2dE(ptr noundef nonnull align 8 dereferenceable(600), ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN2rw3V2dE", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}


; 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.rw::V2d" = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z19CameraSetViewWindowPN2rw6CameraEfff(ptr noundef nonnull %0, float noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = alloca %"struct.rw::V2d", align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = fcmp ogt float %1, %2
  %7 = fdiv float %1, %2
  %8 = fdiv float %3, %7
  %9 = fdiv float %2, %1
  %10 = fdiv float %3, %9
  %.sink13 = select i1 %6, float %3, float %10
  %.sink = select i1 %6, float %8, float %3
  store float %.sink13, ptr %5, align 4
  %11 = getelementptr inbounds i8, ptr %5, i64 4
  store float %.sink, ptr %11, align 4
  call void @_ZN2rw6Camera13setViewWindowEPKNS_3V2dE(ptr noundef nonnull align 8 dereferenceable(600) %0, ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #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

declare void @_ZN2rw6Camera13setViewWindowEPKNS_3V2dE(ptr noundef nonnull align 8 dereferenceable(600), ptr noundef) local_unnamed_addr #2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass