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

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

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

; 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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2rw6Camera11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(600) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.rw::CameraChunkData", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #4
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = call noundef i32 @_ZN2rw6Camera13streamGetSizeEv(ptr noundef nonnull align 8 dereferenceable(600) %6)
  %9 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %7, i32 noundef 5, i32 noundef %8)
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %10, i32 noundef 1, i32 noundef 32)
  %12 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 3
  %13 = getelementptr inbounds %"struct.rw::CameraChunkData", ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 8 %12, i64 8, i1 false), !tbaa.struct !9
  %14 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 4
  %15 = getelementptr inbounds %"struct.rw::CameraChunkData", ptr %5, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 8 %14, i64 8, i1 false), !tbaa.struct !9
  %16 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 5
  %17 = load float, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds %"struct.rw::CameraChunkData", ptr %5, i32 0, i32 2
  store float %17, ptr %18, align 4, !tbaa !23
  %19 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 6
  %20 = load float, ptr %19, align 4, !tbaa !25
  %21 = getelementptr inbounds %"struct.rw::CameraChunkData", ptr %5, i32 0, i32 3
  store float %20, ptr %21, align 4, !tbaa !26
  %22 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 7
  %23 = load float, ptr %22, align 8, !tbaa !27
  %24 = getelementptr inbounds %"struct.rw::CameraChunkData", ptr %5, i32 0, i32 4
  store float %23, ptr %24, align 4, !tbaa !28
  %25 = getelementptr inbounds %"struct.rw::Camera", ptr %6, i32 0, i32 8
  %26 = load i32, ptr %25, align 4, !tbaa !29
  %27 = getelementptr inbounds %"struct.rw::CameraChunkData", ptr %5, i32 0, i32 5
  store i32 %26, ptr %27, align 4, !tbaa !30
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call noundef i32 @_ZN2rw6Stream7write32EPKvj(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef %5, i32 noundef 32)
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN2rw10PluginList11streamWriteEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw6Camera9s_plglistE, ptr noundef %30, ptr noundef %6)
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #4
  ret i1 true
}

declare noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef, i32 noundef, i32 noundef) #3

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

declare noundef i32 @_ZN2rw6Stream7write32EPKvj(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i32 noundef) #3

declare void @_ZN2rw10PluginList11streamWriteEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{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 = !{!24, !11, i64 16}
!24 = !{!"_ZTSN2rw15CameraChunkDataE", !17, i64 0, !17, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !18, i64 28}
!25 = !{!13, !11, i64 76}
!26 = !{!24, !11, i64 20}
!27 = !{!13, !11, i64 80}
!28 = !{!24, !11, i64 24}
!29 = !{!13, !18, i64 84}
!30 = !{!24, !18, i64 28}


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

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

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2rw6Camera11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(600) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"struct.rw::CameraChunkData", align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #3
  %4 = tail call noundef i32 @_ZN2rw6Camera13streamGetSizeEv(ptr noundef nonnull align 8 dereferenceable(600) %0)
  %5 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %1, i32 noundef 5, i32 noundef %4)
  %6 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %1, i32 noundef 1, i32 noundef 32)
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = load <2 x i64>, ptr %7, align 8
  store <2 x i64> %8, ptr %3, align 16
  %9 = getelementptr inbounds i8, ptr %0, i64 72
  %10 = getelementptr inbounds i8, ptr %3, i64 16
  %11 = load <2 x float>, ptr %9, align 8, !tbaa !5
  store <2 x float> %11, ptr %10, align 16, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 80
  %13 = load float, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %3, i64 24
  store float %13, ptr %14, align 8, !tbaa !21
  %15 = getelementptr inbounds i8, ptr %0, i64 84
  %16 = load i32, ptr %15, align 4, !tbaa !23
  %17 = getelementptr inbounds i8, ptr %3, i64 28
  store i32 %16, ptr %17, align 4, !tbaa !24
  %18 = call noundef i32 @_ZN2rw6Stream7write32EPKvj(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %3, i32 noundef 32)
  call void @_ZN2rw10PluginList11streamWriteEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw6Camera9s_plglistE, ptr noundef nonnull %1, ptr noundef nonnull %0)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #3
  ret i1 true
}

declare noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

declare noundef i32 @_ZN2rw6Stream7write32EPKvj(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i32 noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"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 = !{!22, !6, i64 24}
!22 = !{!"_ZTSN2rw15CameraChunkDataE", !15, i64 0, !15, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !16, i64 28}
!23 = !{!10, !16, i64 84}
!24 = !{!22, !16, i64 28}


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