; LLVM IR from aap/librw :: src/gl/wdgl.ll (ZN2rw4wdgl14readNativeDataEPNS_6StreamEiPvii)

; 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::Geometry" = type { %"struct.rw::Object", i32, i16, i32, i32, i32, i32, ptr, ptr, [8 x ptr], ptr, %"struct.rw::MaterialList", ptr, ptr, i32 }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::MaterialList" = type { ptr, i32, i32 }
%"struct.rw::InstanceDataHeader" = type { i32 }
%"struct.rw::wdgl::InstanceDataHeader" = type { %"struct.rw::InstanceDataHeader", i32, ptr, i32, ptr, i32, i32 }
%"struct.rw::wdgl::AttribDesc" = type { i32, i32, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [75 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [75 x i8], align 1

; 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: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw4wdgl14readNativeDataEPNS_6StreamEiPvii(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %13, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %14 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef 40, i32 noundef 196623, ptr noundef @.str)
  store ptr %14, ptr %12, align 8, !tbaa !5
  %15 = load ptr, ptr %12, align 8, !tbaa !5
  %16 = load ptr, ptr %11, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.rw::Geometry", ptr %16, i32 0, i32 13
  store ptr %15, ptr %17, align 8, !tbaa !11
  %18 = load ptr, ptr %12, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.rw::InstanceDataHeader", ptr %18, i32 0, i32 0
  store i32 11, ptr %19, align 8, !tbaa !16
  %20 = load ptr, ptr %12, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %20, i32 0, i32 5
  store i32 0, ptr %21, align 8, !tbaa !18
  %22 = load ptr, ptr %12, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %22, i32 0, i32 6
  store i32 0, ptr %23, align 4, !tbaa !20
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %26, i32 0, i32 1
  store i32 %25, ptr %27, align 4, !tbaa !21
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !21
  %31 = sext i32 %30 to i64
  %32 = mul i64 %31, 24
  %33 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %32, i32 noundef 196623, ptr noundef @.str.1)
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %34, i32 0, i32 2
  store ptr %33, ptr %35, align 8, !tbaa !22
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %37, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !22
  %40 = load ptr, ptr %12, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !21
  %43 = sext i32 %42 to i64
  %44 = mul i64 %43, 24
  %45 = trunc i64 %44 to i32
  %46 = call noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef %39, i32 noundef %45)
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !22
  %50 = getelementptr inbounds %"struct.rw::wdgl::AttribDesc", ptr %49, i64 0
  %51 = getelementptr inbounds %"struct.rw::wdgl::AttribDesc", ptr %50, i32 0, i32 4
  %52 = load i32, ptr %51, align 4, !tbaa !23
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.rw::Geometry", ptr %53, i32 0, i32 4
  %55 = load i32, ptr %54, align 4, !tbaa !25
  %56 = mul i32 %52, %55
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %57, i32 0, i32 3
  store i32 %56, ptr %58, align 8, !tbaa !26
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %59, i32 0, i32 3
  %61 = load i32, ptr %60, align 8, !tbaa !26
  %62 = zext i32 %61 to i64
  %63 = mul i64 %62, 1
  %64 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %63, i32 noundef 196623, ptr noundef @.str.2)
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %65, i32 0, i32 4
  store ptr %64, ptr %66, align 8, !tbaa !27
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %68, i32 0, i32 4
  %70 = load ptr, ptr %69, align 8, !tbaa !27
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %71, i32 0, i32 3
  %73 = load i32, ptr %72, align 8, !tbaa !26
  %74 = load ptr, ptr %67, align 8, !tbaa !28
  %75 = getelementptr inbounds ptr, ptr %74, i64 4
  %76 = load ptr, ptr %75, align 8
  %77 = call noundef i32 %76(ptr noundef nonnull align 8 dereferenceable(8) %67, ptr noundef %70, i32 noundef %73)
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret ptr %78
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #2

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

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

attributes #0 = { 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 = { inlinehint 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 152}
!12 = !{!"_ZTSN2rw8GeometryE", !13, i64 0, !10, i64 16, !14, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !15, i64 128, !6, i64 144, !6, i64 152, !10, i64 160}
!13 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!"_ZTSN2rw12MaterialListE", !6, i64 0, !10, i64 8, !10, i64 12}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTSN2rw18InstanceDataHeaderE", !10, i64 0}
!18 = !{!19, !10, i64 32}
!19 = !{!"_ZTSN2rw4wdgl18InstanceDataHeaderE", !17, i64 0, !10, i64 4, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !10, i64 36}
!20 = !{!19, !10, i64 36}
!21 = !{!19, !10, i64 4}
!22 = !{!19, !6, i64 8}
!23 = !{!24, !10, i64 16}
!24 = !{!"_ZTSN2rw4wdgl10AttribDescE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!25 = !{!12, !10, i64 28}
!26 = !{!19, !10, i64 16}
!27 = !{!19, !6, i64 24}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !8, i64 0}


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

@.str = external hidden unnamed_addr constant [75 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [75 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw4wdgl14readNativeDataEPNS_6StreamEiPvii(ptr noundef returned %0, i32 noundef %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef 40, i32 noundef 196623, ptr noundef nonnull @.str)
  %7 = getelementptr inbounds i8, ptr %2, i64 152
  store ptr %6, ptr %7, align 8, !tbaa !5
  store i32 11, ptr %6, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %6, i64 32
  store i32 0, ptr %8, align 8, !tbaa !16
  %9 = getelementptr inbounds i8, ptr %6, i64 36
  store i32 0, ptr %9, align 4, !tbaa !18
  %10 = tail call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %11 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 %10, ptr %11, align 4, !tbaa !19
  %12 = sext i32 %10 to i64
  %13 = mul nsw i64 %12, 24
  %14 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %13, i32 noundef 196623, ptr noundef nonnull @.str.1)
  %15 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %14, ptr %15, align 8, !tbaa !20
  %16 = load i32, ptr %11, align 4, !tbaa !19
  %17 = mul i32 %16, 24
  %18 = tail call noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %14, i32 noundef %17)
  %19 = load ptr, ptr %15, align 8, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %21 = load i32, ptr %20, align 4, !tbaa !21
  %22 = getelementptr inbounds i8, ptr %2, i64 28
  %23 = load i32, ptr %22, align 4, !tbaa !23
  %24 = mul i32 %23, %21
  %25 = getelementptr inbounds i8, ptr %6, i64 16
  store i32 %24, ptr %25, align 8, !tbaa !24
  %26 = zext i32 %24 to i64
  %27 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %26, i32 noundef 196623, ptr noundef nonnull @.str.2)
  %28 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr %27, ptr %28, align 8, !tbaa !25
  %29 = load i32, ptr %25, align 8, !tbaa !24
  %30 = load ptr, ptr %0, align 8, !tbaa !26
  %31 = getelementptr inbounds i8, ptr %30, i64 32
  %32 = load ptr, ptr %31, align 8
  %33 = tail call noundef i32 %32(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %27, i32 noundef %29)
  ret ptr %0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

declare noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i32 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 = { inlinehint 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" }

!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 152}
!6 = !{!"_ZTSN2rw8GeometryE", !7, i64 0, !11, i64 16, !12, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !10, i64 40, !10, i64 48, !8, i64 56, !10, i64 120, !13, i64 128, !10, i64 144, !10, i64 152, !11, i64 160}
!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 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"_ZTSN2rw12MaterialListE", !10, i64 0, !11, i64 8, !11, i64 12}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTSN2rw18InstanceDataHeaderE", !11, i64 0}
!16 = !{!17, !11, i64 32}
!17 = !{!"_ZTSN2rw4wdgl18InstanceDataHeaderE", !15, i64 0, !11, i64 4, !10, i64 8, !11, i64 16, !10, i64 24, !11, i64 32, !11, i64 36}
!18 = !{!17, !11, i64 36}
!19 = !{!17, !11, i64 4}
!20 = !{!17, !10, i64 8}
!21 = !{!22, !11, i64 16}
!22 = !{!"_ZTSN2rw4wdgl10AttribDescE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!23 = !{!6, !11, i64 28}
!24 = !{!17, !11, i64 16}
!25 = !{!17, !10, i64 24}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !9, i64 0}


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