; LLVM IR from aap/librw :: skeleton/skeleton.ll (ZN2sk10CameraSizeEPN2rw6CameraEPNS0_4RectEff)

; 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 }
%"struct.rw::Camera" = type { %"struct.rw::ObjectWithFrame", ptr, ptr, %"struct.rw::V2d", %"struct.rw::V2d", float, float, float, i32, %"struct.rw::Matrix", float, float, [6 x %"struct.rw::FrustumPlane"], [8 x %"struct.rw::V3d"], %"struct.rw::BBox", ptr, ptr, %"struct.rw::RawMatrix", %"struct.rw::RawMatrix", ptr, %"struct.rw::LLLink", ptr, ptr, ptr, ptr }
%"struct.rw::ObjectWithFrame" = type { %"struct.rw::Object", %"struct.rw::LLLink", ptr }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::Matrix" = type { %"struct.rw::V3d", i32, %"struct.rw::V3d", i32, %"struct.rw::V3d", i32, %"struct.rw::V3d", i32 }
%"struct.rw::V3d" = type { float, float, float }
%"struct.rw::FrustumPlane" = type { %"struct.rw::Plane", i8, i8, i8 }
%"struct.rw::Plane" = type { %"struct.rw::V3d", float }
%"struct.rw::BBox" = type { %"struct.rw::V3d", %"struct.rw::V3d" }
%"struct.rw::RawMatrix" = type { %"struct.rw::V3d", float, %"struct.rw::V3d", float, %"struct.rw::V3d", float, %"struct.rw::V3d", float }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Rect" = 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

declare void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2sk10CameraSizeEPN2rw6CameraEPNS0_4RectEff(ptr noundef %0, ptr noundef %1, float noundef %2, float noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %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 ptr %1, ptr %6, align 8, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.rw::Camera", ptr %10, i32 0, i32 15
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %20

14:                                               ; preds = %4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.rw::Camera", ptr %15, i32 0, i32 15
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %17)
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.rw::Camera", ptr %18, i32 0, i32 15
  store ptr null, ptr %19, align 8, !tbaa !11
  br label %20

20:                                               ; preds = %14, %4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.rw::Camera", ptr %21, i32 0, i32 16
  %23 = load ptr, ptr %22, align 8, !tbaa !22
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %31

25:                                               ; preds = %20
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.rw::Camera", ptr %26, i32 0, i32 16
  %28 = load ptr, ptr %27, align 8, !tbaa !22
  call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %28)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.rw::Camera", ptr %29, i32 0, i32 16
  store ptr null, ptr %30, align 8, !tbaa !22
  br label %31

31:                                               ; preds = %25, %20
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.rw::Rect", ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !23
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.rw::Rect", ptr %35, i32 0, i32 3
  %37 = load i32, ptr %36, align 4, !tbaa !25
  %38 = call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %34, i32 noundef %37, i32 noundef 0, i32 noundef 2, i32 noundef 0)
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.rw::Camera", ptr %39, i32 0, i32 15
  store ptr %38, ptr %40, align 8, !tbaa !11
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.rw::Rect", ptr %41, i32 0, i32 2
  %43 = load i32, ptr %42, align 4, !tbaa !23
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.rw::Rect", ptr %44, i32 0, i32 3
  %46 = load i32, ptr %45, align 4, !tbaa !25
  %47 = call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %43, i32 noundef %46, i32 noundef 0, i32 noundef 1, i32 noundef 0)
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.rw::Camera", ptr %48, i32 0, i32 16
  store ptr %47, ptr %49, align 8, !tbaa !22
  %50 = load float, ptr %7, align 4, !tbaa !9
  %51 = fcmp une float %50, 0.000000e+00
  br i1 %51, label %52, label %92

52:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.rw::Rect", ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 4, !tbaa !23
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.rw::Rect", ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 4, !tbaa !25
  %59 = icmp sgt i32 %55, %58
  br i1 %59, label %60, label %75

60:                                               ; preds = %52
  %61 = load float, ptr %7, align 4, !tbaa !9
  %62 = getelementptr inbounds %"struct.rw::V2d", ptr %9, i32 0, i32 0
  store float %61, ptr %62, align 4, !tbaa !26
  %63 = load float, ptr %7, align 4, !tbaa !9
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.rw::Rect", ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 4, !tbaa !23
  %67 = sitofp i32 %66 to float
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.rw::Rect", ptr %68, i32 0, i32 3
  %70 = load i32, ptr %69, align 4, !tbaa !25
  %71 = sitofp i32 %70 to float
  %72 = fdiv float %67, %71
  %73 = fdiv float %63, %72
  %74 = getelementptr inbounds %"struct.rw::V2d", ptr %9, i32 0, i32 1
  store float %73, ptr %74, align 4, !tbaa !27
  br label %90

75:                                               ; preds = %52
  %76 = load float, ptr %7, align 4, !tbaa !9
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.rw::Rect", ptr %77, i32 0, i32 3
  %79 = load i32, ptr %78, align 4, !tbaa !25
  %80 = sitofp i32 %79 to float
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::Rect", ptr %81, i32 0, i32 2
  %83 = load i32, ptr %82, align 4, !tbaa !23
  %84 = sitofp i32 %83 to float
  %85 = fdiv float %80, %84
  %86 = fdiv float %76, %85
  %87 = getelementptr inbounds %"struct.rw::V2d", ptr %9, i32 0, i32 0
  store float %86, ptr %87, align 4, !tbaa !26
  %88 = load float, ptr %7, align 4, !tbaa !9
  %89 = getelementptr inbounds %"struct.rw::V2d", ptr %9, i32 0, i32 1
  store float %88, ptr %89, align 4, !tbaa !27
  br label %90

90:                                               ; preds = %75, %60
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw6Camera13setViewWindowEPKNS_3V2dE(ptr noundef nonnull align 8 dereferenceable(600) %91, ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %92

92:                                               ; preds = %90, %31
  ret void
}

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

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

!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, !6, i64 400}
!12 = !{!"_ZTSN2rw6CameraE", !13, i64 0, !6, i64 40, !6, i64 48, !16, i64 56, !16, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !17, i64 84, !18, i64 88, !10, i64 152, !10, i64 156, !7, i64 160, !7, i64 280, !20, i64 376, !6, i64 400, !6, i64 408, !21, i64 416, !21, i64 480, !6, i64 544, !15, i64 552, !6, i64 568, !6, i64 576, !6, i64 584, !6, i64 592}
!13 = !{!"_ZTSN2rw15ObjectWithFrameE", !14, i64 0, !15, i64 16, !6, i64 32}
!14 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!15 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!16 = !{!"_ZTSN2rw3V2dE", !10, i64 0, !10, i64 4}
!17 = !{!"int", !7, i64 0}
!18 = !{!"_ZTSN2rw6MatrixE", !19, i64 0, !17, i64 12, !19, i64 16, !17, i64 28, !19, i64 32, !17, i64 44, !19, i64 48, !17, i64 60}
!19 = !{!"_ZTSN2rw3V3dE", !10, i64 0, !10, i64 4, !10, i64 8}
!20 = !{!"_ZTSN2rw4BBoxE", !19, i64 0, !19, i64 12}
!21 = !{!"_ZTSN2rw9RawMatrixE", !19, i64 0, !10, i64 12, !19, i64 16, !10, i64 28, !19, i64 32, !10, i64 44, !19, i64 48, !10, i64 60}
!22 = !{!12, !6, i64 408}
!23 = !{!24, !17, i64 8}
!24 = !{!"_ZTSN2rw4RectE", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12}
!25 = !{!24, !17, i64 12}
!26 = !{!16, !10, i64 0}
!27 = !{!16, !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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

declare noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2sk10CameraSizeEPN2rw6CameraEPNS0_4RectEff(ptr noundef %0, ptr nocapture noundef readonly %1, float noundef %2, float noundef %3) local_unnamed_addr #2 {
  %5 = alloca %"struct.rw::V2d", align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 400
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %9, label %8

8:                                                ; preds = %4
  tail call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %7)
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %8, %4
  %10 = getelementptr inbounds i8, ptr %0, i64 408
  %11 = load ptr, ptr %10, align 8, !tbaa !20
  %.not28 = icmp eq ptr %11, null
  br i1 %.not28, label %13, label %12

12:                                               ; preds = %9
  tail call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %11)
  store ptr null, ptr %10, align 8, !tbaa !20
  br label %13

13:                                               ; preds = %12, %9
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = load i32, ptr %14, align 4, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %1, i64 12
  %17 = load i32, ptr %16, align 4, !tbaa !23
  %18 = tail call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %15, i32 noundef %17, i32 noundef 0, i32 noundef 2, i32 noundef 0)
  store ptr %18, ptr %6, align 8, !tbaa !5
  %19 = load i32, ptr %14, align 4, !tbaa !21
  %20 = load i32, ptr %16, align 4, !tbaa !23
  %21 = tail call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %19, i32 noundef %20, i32 noundef 0, i32 noundef 1, i32 noundef 0)
  store ptr %21, ptr %10, align 8, !tbaa !20
  %22 = fcmp une float %2, 0.000000e+00
  br i1 %22, label %23, label %39

23:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %24 = load i32, ptr %14, align 4, !tbaa !21
  %25 = load i32, ptr %16, align 4, !tbaa !23
  %26 = icmp sgt i32 %24, %25
  br i1 %26, label %27, label %32

27:                                               ; preds = %23
  %28 = sitofp i32 %24 to float
  %29 = sitofp i32 %25 to float
  %30 = fdiv float %28, %29
  %31 = fdiv float %2, %30
  br label %37

32:                                               ; preds = %23
  %33 = sitofp i32 %25 to float
  %34 = sitofp i32 %24 to float
  %35 = fdiv float %33, %34
  %36 = fdiv float %2, %35
  br label %37

37:                                               ; preds = %32, %27
  %.sink29 = phi float [ %2, %27 ], [ %36, %32 ]
  %.sink = phi float [ %31, %27 ], [ %2, %32 ]
  store float %.sink29, ptr %5, align 4
  %38 = getelementptr inbounds i8, ptr %5, i64 4
  store float %.sink, ptr %38, 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
  br label %39

39:                                               ; preds = %37, %13
  ret void
}

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

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

!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, !11, i64 400}
!6 = !{!"_ZTSN2rw6CameraE", !7, i64 0, !11, i64 40, !11, i64 48, !13, i64 56, !13, i64 64, !14, i64 72, !14, i64 76, !14, i64 80, !15, i64 84, !16, i64 88, !14, i64 152, !14, i64 156, !9, i64 160, !9, i64 280, !18, i64 376, !11, i64 400, !11, i64 408, !19, i64 416, !19, i64 480, !11, i64 544, !12, i64 552, !11, i64 568, !11, i64 576, !11, i64 584, !11, i64 592}
!7 = !{!"_ZTSN2rw15ObjectWithFrameE", !8, i64 0, !12, i64 16, !11, i64 32}
!8 = !{!"_ZTSN2rw6ObjectE", !9, i64 0, !9, i64 1, !9, i64 2, !9, i64 3, !11, i64 8}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTSN2rw6LLLinkE", !11, i64 0, !11, i64 8}
!13 = !{!"_ZTSN2rw3V2dE", !14, i64 0, !14, i64 4}
!14 = !{!"float", !9, i64 0}
!15 = !{!"int", !9, i64 0}
!16 = !{!"_ZTSN2rw6MatrixE", !17, i64 0, !15, i64 12, !17, i64 16, !15, i64 28, !17, i64 32, !15, i64 44, !17, i64 48, !15, i64 60}
!17 = !{!"_ZTSN2rw3V3dE", !14, i64 0, !14, i64 4, !14, i64 8}
!18 = !{!"_ZTSN2rw4BBoxE", !17, i64 0, !17, i64 12}
!19 = !{!"_ZTSN2rw9RawMatrixE", !17, i64 0, !14, i64 12, !17, i64 16, !14, i64 28, !17, i64 32, !14, i64 44, !17, i64 48, !14, i64 60}
!20 = !{!6, !11, i64 408}
!21 = !{!22, !15, i64 8}
!22 = !{!"_ZTSN2rw4RectE", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!23 = !{!22, !15, i64 12}


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