; LLVM IR from aap/librw :: src/frame.ll (ZN2rw5Frame13updateObjectsEv)

; 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::Frame" = type { %"struct.rw::Object", %"struct.rw::LLLink", %"struct.rw::LinkList", %"struct.rw::Matrix", %"struct.rw::Matrix", ptr, ptr, ptr }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"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::Engine" = type { ptr, ptr, %"struct.rw::LinkList", %"struct.rw::FileFunctions", [13 x ptr], %"struct.rw::Device", ptr }
%"struct.rw::FileFunctions" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Device" = type { float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@_ZN2rw6engineE = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"struct.rw::Frame", ptr %3, i32 0, i32 7
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %"struct.rw::Frame", ptr %5, i32 0, i32 0
  %7 = getelementptr inbounds %"struct.rw::Object", ptr %6, i32 0, i32 3
  %8 = load i8, ptr %7, align 1, !tbaa !18
  %9 = zext i8 %8 to i32
  %10 = and i32 %9, 3
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %18

12:                                               ; preds = %1
  %13 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.rw::Engine", ptr %13, i32 0, i32 2
  %15 = getelementptr inbounds %"struct.rw::Frame", ptr %3, i32 0, i32 7
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %"struct.rw::Frame", ptr %16, i32 0, i32 1
  call void @_ZN2rw8LinkList3addEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %17)
  br label %18

18:                                               ; preds = %12, %1
  %19 = getelementptr inbounds %"struct.rw::Frame", ptr %3, i32 0, i32 7
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds %"struct.rw::Frame", ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %"struct.rw::Object", ptr %21, i32 0, i32 3
  %23 = load i8, ptr %22, align 1, !tbaa !18
  %24 = zext i8 %23 to i32
  %25 = or i32 %24, 3
  %26 = trunc i32 %25 to i8
  store i8 %26, ptr %22, align 1, !tbaa !18
  %27 = getelementptr inbounds %"struct.rw::Frame", ptr %3, i32 0, i32 0
  %28 = getelementptr inbounds %"struct.rw::Object", ptr %27, i32 0, i32 3
  %29 = load i8, ptr %28, align 1, !tbaa !18
  %30 = zext i8 %29 to i32
  %31 = or i32 %30, 12
  %32 = trunc i32 %31 to i8
  store i8 %32, ptr %28, align 1, !tbaa !18
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw8LinkList3addEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #1 align 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" }

!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, !6, i64 192}
!10 = !{!"_ZTSN2rw5FrameE", !11, i64 0, !12, i64 16, !13, i64 32, !14, i64 48, !14, i64 112, !6, i64 176, !6, i64 184, !6, i64 192}
!11 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!12 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!13 = !{!"_ZTSN2rw8LinkListE", !12, i64 0}
!14 = !{!"_ZTSN2rw6MatrixE", !15, i64 0, !17, i64 12, !15, i64 16, !17, i64 28, !15, i64 32, !17, i64 44, !15, i64 48, !17, i64 60}
!15 = !{!"_ZTSN2rw3V3dE", !16, i64 0, !16, i64 4, !16, i64 8}
!16 = !{!"float", !7, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!10, !7, i64 3}


; 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"

@_ZN2rw6engineE = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2rw5Frame13updateObjectsEv(ptr nocapture noundef nonnull align 8 dereferenceable(200) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 192
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 3
  %5 = load i8, ptr %4, align 1, !tbaa !17
  %6 = and i8 %5, 3
  %7 = icmp eq i8 %6, 0
  br i1 %7, label %8, label %12

8:                                                ; preds = %1
  %9 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  %11 = getelementptr inbounds i8, ptr %3, i64 16
  tail call void @_ZN2rw8LinkList3addEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull %11)
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.pre, i64 3
  %.pre1 = load i8, ptr %.phi.trans.insert, align 1, !tbaa !17
  br label %12

12:                                               ; preds = %8, %1
  %13 = phi i8 [ %.pre1, %8 ], [ %5, %1 ]
  %14 = phi ptr [ %.pre, %8 ], [ %3, %1 ]
  %15 = getelementptr inbounds i8, ptr %14, i64 3
  %16 = or i8 %13, 3
  store i8 %16, ptr %15, align 1, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 3
  %18 = load i8, ptr %17, align 1, !tbaa !17
  %19 = or i8 %18, 12
  store i8 %19, ptr %17, align 1, !tbaa !17
  ret void
}

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

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

!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, !10, i64 192}
!6 = !{!"_ZTSN2rw5FrameE", !7, i64 0, !11, i64 16, !12, i64 32, !13, i64 48, !13, i64 112, !10, i64 176, !10, i64 184, !10, i64 192}
!7 = !{!"_ZTSN2rw6ObjectE", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !10, i64 8}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSN2rw6LLLinkE", !10, i64 0, !10, i64 8}
!12 = !{!"_ZTSN2rw8LinkListE", !11, i64 0}
!13 = !{!"_ZTSN2rw6MatrixE", !14, i64 0, !16, i64 12, !14, i64 16, !16, i64 28, !14, i64 32, !16, i64 44, !14, i64 48, !16, i64 60}
!14 = !{!"_ZTSN2rw3V3dE", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"float", !8, i64 0}
!16 = !{!"int", !8, i64 0}
!17 = !{!6, !8, i64 3}
!18 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass