; LLVM IR from aap/librw :: src/camera.ll (ZN2rw6Camera5cloneEv)

; 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::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"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::V2d" = type { float, float }
%"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 }

@_ZN2rw6Camera9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Camera6createEv() #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw6Camera5cloneEv(ptr noundef nonnull align 8 dereferenceable(600) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %7 = call noundef ptr @_ZN2rw6Camera6createEv()
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %59

11:                                               ; preds = %1
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.rw::Camera", ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds %"struct.rw::ObjectWithFrame", ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 0
  %16 = getelementptr inbounds %"struct.rw::ObjectWithFrame", ptr %15, i32 0, i32 0
  call void @_ZN2rw6Object4copyEPS0_(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %16)
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call noundef ptr @_ZNK2rw6Camera8getFrameEv(ptr noundef nonnull align 8 dereferenceable(600) %6)
  call void @_ZN2rw6Camera8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(600) %17, ptr noundef %18)
  %19 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.rw::Camera", ptr %20, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 8 %19, i64 8, i1 false), !tbaa.struct !9
  %22 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 4
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.rw::Camera", ptr %23, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %24, ptr align 8 %22, i64 8, i1 false), !tbaa.struct !9
  %25 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 5
  %26 = load float, ptr %25, align 8, !tbaa !12
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.rw::Camera", ptr %27, i32 0, i32 5
  store float %26, ptr %28, align 8, !tbaa !12
  %29 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 6
  %30 = load float, ptr %29, align 4, !tbaa !23
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.rw::Camera", ptr %31, i32 0, i32 6
  store float %30, ptr %32, align 4, !tbaa !23
  %33 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 7
  %34 = load float, ptr %33, align 8, !tbaa !24
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.rw::Camera", ptr %35, i32 0, i32 7
  store float %34, ptr %36, align 8, !tbaa !24
  %37 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 8
  %38 = load i32, ptr %37, align 4, !tbaa !25
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.rw::Camera", ptr %39, i32 0, i32 8
  store i32 %38, ptr %40, align 4, !tbaa !25
  %41 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 15
  %42 = load ptr, ptr %41, align 8, !tbaa !26
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.rw::Camera", ptr %43, i32 0, i32 15
  store ptr %42, ptr %44, align 8, !tbaa !26
  %45 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 16
  %46 = load ptr, ptr %45, align 8, !tbaa !27
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.rw::Camera", ptr %47, i32 0, i32 16
  store ptr %46, ptr %48, align 8, !tbaa !27
  %49 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 21
  %50 = load ptr, ptr %49, align 8, !tbaa !28
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %56

52:                                               ; preds = %11
  %53 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 21
  %54 = load ptr, ptr %53, align 8, !tbaa !28
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN2rw5World9addCameraEPNS_6CameraE(ptr noundef nonnull align 8 dereferenceable(64) %54, ptr noundef %55)
  br label %56

56:                                               ; preds = %52, %11
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw6Camera9s_plglistE, ptr noundef %57, ptr noundef %6)
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %58, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %59

59:                                               ; preds = %56, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %60 = load ptr, ptr %2, align 8
  ret ptr %60
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6Object4copyEPS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw6Camera8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(600), ptr noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw6Camera8getFrameEv(ptr noundef nonnull align 8 dereferenceable(600)) #2 align 2

; 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) #3

declare void @_ZN2rw5World9addCameraEPNS_6CameraE(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) #4

declare void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) #4

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


; 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::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }

@_ZN2rw6Camera9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Camera6createEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw6Camera5cloneEv(ptr noundef nonnull align 8 dereferenceable(600) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef ptr @_ZN2rw6Camera6createEv()
  %3 = icmp eq ptr %2, null
  br i1 %3, label %28, label %4

4:                                                ; preds = %1
  tail call void @_ZN2rw6Object4copyEPS0_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull %0)
  %5 = tail call noundef ptr @_ZNK2rw6Camera8getFrameEv(ptr noundef nonnull align 8 dereferenceable(600) %0)
  tail call void @_ZN2rw6Camera8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(600) %2, ptr noundef %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = getelementptr inbounds i8, ptr %2, i64 56
  %8 = load i64, ptr %6, align 8
  store i64 %8, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  %10 = getelementptr inbounds i8, ptr %2, i64 64
  %11 = load i64, ptr %9, align 8
  store i64 %11, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr %0, i64 72
  %13 = getelementptr inbounds i8, ptr %2, i64 72
  %14 = load <2 x float>, ptr %12, align 8, !tbaa !5
  store <2 x float> %14, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 80
  %16 = load float, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %2, i64 80
  store float %16, ptr %17, align 8, !tbaa !9
  %18 = getelementptr inbounds i8, ptr %0, i64 84
  %19 = load i32, ptr %18, align 4, !tbaa !21
  %20 = getelementptr inbounds i8, ptr %2, i64 84
  store i32 %19, ptr %20, align 4, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %0, i64 400
  %22 = getelementptr inbounds i8, ptr %2, i64 400
  %23 = load <2 x ptr>, ptr %21, align 8, !tbaa !22
  store <2 x ptr> %23, ptr %22, align 8, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %0, i64 568
  %25 = load ptr, ptr %24, align 8, !tbaa !23
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %27, label %26

26:                                               ; preds = %4
  tail call void @_ZN2rw5World9addCameraEPNS_6CameraE(ptr noundef nonnull align 8 dereferenceable(64) %25, ptr noundef nonnull %2)
  br label %27

27:                                               ; preds = %26, %4
  tail call void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw6Camera9s_plglistE, ptr noundef nonnull %2, ptr noundef nonnull %0)
  br label %28

28:                                               ; preds = %1, %27
  ret ptr %2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6Object4copyEPS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw6Camera8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(600), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw6Camera8getFrameEv(ptr noundef nonnull align 8 dereferenceable(600)) local_unnamed_addr #1 align 2

declare void @_ZN2rw5World9addCameraEPNS_6CameraE(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) local_unnamed_addr #2

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 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 = { "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" }

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


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