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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds ptr, ptr %6, i32 1
  store ptr %7, ptr %4, align 8, !tbaa !5
  store ptr %5, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %"struct.rw::Frame", ptr %8, i32 0, i32 6
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %18

12:                                               ; preds = %2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.rw::Frame", ptr %13, i32 0, i32 6
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef %15, ptr noundef %16)
  store ptr %17, ptr %4, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %12, %2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.rw::Frame", ptr %19, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %29

23:                                               ; preds = %18
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.rw::Frame", ptr %24, i32 0, i32 5
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call noundef ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef %26, ptr noundef %27)
  store ptr %28, ptr %4, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %23, %18
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %30
}

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

!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 184}
!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, !6, i64 176}


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

; Function Attrs: mustprogress nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef nonnull ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %8, %2
  %.tr = phi ptr [ %0, %2 ], [ %10, %8 ]
  %.tr12 = phi ptr [ %1, %2 ], [ %.0, %8 ]
  %3 = getelementptr inbounds i8, ptr %.tr12, i64 8
  store ptr %.tr, ptr %.tr12, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %.tr, i64 184
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %8, label %6

6:                                                ; preds = %tailrecurse
  %7 = tail call noundef ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef nonnull %5, ptr noundef nonnull %3)
  br label %8

8:                                                ; preds = %6, %tailrecurse
  %.0 = phi ptr [ %7, %6 ], [ %3, %tailrecurse ]
  %9 = getelementptr inbounds i8, ptr %.tr, i64 176
  %10 = load ptr, ptr %9, align 8, !tbaa !18
  %.not11 = icmp eq ptr %10, null
  br i1 %.not11, label %11, label %tailrecurse

11:                                               ; preds = %8
  ret ptr %.0
}

attributes #0 = { mustprogress nofree nosync nounwind memory(readwrite, inaccessiblemem: none) 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 184}
!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, !6, i64 176}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass