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

; 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::Atomic" = type { %"struct.rw::ObjectWithFrame", ptr, %"struct.rw::Sphere", %"struct.rw::Sphere", 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::Sphere" = type { %"struct.rw::V3d", float }
%"struct.rw::V3d" = type { float, float, float }
%"struct.rw::LLLink" = type { ptr, ptr }
%"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::MaterialList" = type { ptr, i32, i32 }
%"struct.rw::InstanceDataHeader" = type { i32 }
%"class.rw::Pipeline" = type { i32, i32, 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.3 = external hidden unnamed_addr constant [8 x i8], align 1
@_ZN2rw9debugFileE = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 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 void @_ZN2rw4wdgl13printPipeinfoEPNS_6AtomicE(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %"struct.rw::Atomic", ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %10, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.rw::Geometry", ptr %11, i32 0, i32 13
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  %14 = icmp eq ptr %13, null
  br i1 %14, label %22, label %15

15:                                               ; preds = %1
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.rw::Geometry", ptr %16, i32 0, i32 13
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = getelementptr inbounds %"struct.rw::InstanceDataHeader", ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 4, !tbaa !22
  %21 = icmp ne i32 %20, 11
  br i1 %21, label %22, label %23

22:                                               ; preds = %15, %1
  store i32 1, ptr %4, align 4
  br label %71

23:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !24
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.rw::Atomic", ptr %24, i32 0, i32 6
  %26 = load ptr, ptr %25, align 8, !tbaa !25
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %34

28:                                               ; preds = %23
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.rw::Atomic", ptr %29, i32 0, i32 6
  %31 = load ptr, ptr %30, align 8, !tbaa !25
  %32 = getelementptr inbounds %"class.rw::Pipeline", ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !26
  store i32 %33, ptr %5, align 4, !tbaa !24
  br label %34

34:                                               ; preds = %28, %23
  %35 = load ptr, ptr @_ZN2rw9debugFileE, align 8, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !24
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, ptr noundef %35, i32 noundef %36)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.rw::Geometry", ptr %38, i32 0, i32 13
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  store ptr %40, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !24
  br label %41

41:                                               ; preds = %66, %34
  %42 = load i32, ptr %7, align 4, !tbaa !24
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !28
  %46 = icmp slt i32 %42, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %41
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %69

48:                                               ; preds = %41
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !30
  %52 = load i32, ptr %7, align 4, !tbaa !24
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds %"struct.rw::wdgl::AttribDesc", ptr %51, i64 %53
  %55 = getelementptr inbounds %"struct.rw::wdgl::AttribDesc", ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 4, !tbaa !31
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.rw::wdgl::InstanceDataHeader", ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !30
  %60 = load i32, ptr %7, align 4, !tbaa !24
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds %"struct.rw::wdgl::AttribDesc", ptr %59, i64 %61
  %63 = getelementptr inbounds %"struct.rw::wdgl::AttribDesc", ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !33
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %56, i32 noundef %64)
  br label %66

66:                                               ; preds = %48
  %67 = load i32, ptr %7, align 4, !tbaa !24
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %7, align 4, !tbaa !24
  br label %41, !llvm.loop !34

69:                                               ; preds = %47
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  store i32 0, ptr %4, align 4
  br label %71

71:                                               ; preds = %69, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %72 = load i32, ptr %4, align 4
  switch i32 %72, label %74 [
    i32 0, label %73
    i32 1, label %73
  ]

73:                                               ; preds = %71, %71
  ret void

74:                                               ; preds = %71
  unreachable
}

declare i32 @printf(ptr noundef, ...) #2

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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"_ZTSN2rw6AtomicE", !11, i64 0, !6, i64 40, !14, i64 48, !14, i64 64, !6, i64 80, !13, i64 88, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!11 = !{!"_ZTSN2rw15ObjectWithFrameE", !12, i64 0, !13, i64 16, !6, i64 32}
!12 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!13 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!14 = !{!"_ZTSN2rw6SphereE", !15, i64 0, !16, i64 12}
!15 = !{!"_ZTSN2rw3V3dE", !16, i64 0, !16, i64 4, !16, i64 8}
!16 = !{!"float", !7, i64 0}
!17 = !{!18, !6, i64 152}
!18 = !{!"_ZTSN2rw8GeometryE", !12, i64 0, !19, i64 16, !20, i64 20, !19, i64 24, !19, i64 28, !19, i64 32, !19, i64 36, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !21, i64 128, !6, i64 144, !6, i64 152, !19, i64 160}
!19 = !{!"int", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!"_ZTSN2rw12MaterialListE", !6, i64 0, !19, i64 8, !19, i64 12}
!22 = !{!23, !19, i64 0}
!23 = !{!"_ZTSN2rw18InstanceDataHeaderE", !19, i64 0}
!24 = !{!19, !19, i64 0}
!25 = !{!10, !6, i64 104}
!26 = !{!27, !19, i64 0}
!27 = !{!"_ZTSN2rw8PipelineE", !19, i64 0, !19, i64 4, !19, i64 8}
!28 = !{!29, !19, i64 4}
!29 = !{!"_ZTSN2rw4wdgl18InstanceDataHeaderE", !23, i64 0, !19, i64 4, !6, i64 8, !19, i64 16, !6, i64 24, !19, i64 32, !19, i64 36}
!30 = !{!29, !6, i64 8}
!31 = !{!32, !19, i64 0}
!32 = !{!"_ZTSN2rw4wdgl10AttribDescE", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12, !19, i64 16, !19, i64 20}
!33 = !{!32, !19, i64 4}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}


; 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::wdgl::AttribDesc" = type { i32, i32, i32, i32, i32, i32 }

@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@_ZN2rw9debugFileE = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_ZN2rw4wdgl13printPipeinfoEPNS_6AtomicE(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 152
  %5 = load ptr, ptr %4, align 8, !tbaa !16
  %6 = icmp eq ptr %5, null
  br i1 %6, label %33, label %7

7:                                                ; preds = %1
  %8 = load i32, ptr %5, align 4, !tbaa !21
  %.not = icmp eq i32 %8, 11
  br i1 %.not, label %9, label %33

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 104
  %11 = load ptr, ptr %10, align 8, !tbaa !23
  %.not16 = icmp eq ptr %11, null
  br i1 %.not16, label %14, label %12

12:                                               ; preds = %9
  %13 = load i32, ptr %11, align 8, !tbaa !24
  br label %14

14:                                               ; preds = %12, %9
  %.013 = phi i32 [ %13, %12 ], [ 0, %9 ]
  %15 = load ptr, ptr @_ZN2rw9debugFileE, align 8, !tbaa !26
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef %15, i32 noundef %.013)
  %17 = load ptr, ptr %4, align 8, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %17, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !27
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %14
  %21 = getelementptr inbounds i8, ptr %17, i64 8
  br label %23

._crit_edge:                                      ; preds = %23, %14
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %33

23:                                               ; preds = %.lr.ph, %23
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %23 ]
  %24 = load ptr, ptr %21, align 8, !tbaa !29
  %25 = getelementptr inbounds %"struct.rw::wdgl::AttribDesc", ptr %24, i64 %indvars.iv
  %26 = load i32, ptr %25, align 4, !tbaa !30
  %27 = getelementptr inbounds i8, ptr %25, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !32
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %26, i32 noundef %28)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load i32, ptr %18, align 4, !tbaa !27
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %indvars.iv.next, %31
  br i1 %32, label %23, label %._crit_edge, !llvm.loop !33

33:                                               ; preds = %1, %7, %._crit_edge
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { mustprogress nofree 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 #1 = { nofree nounwind "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, !11, i64 40}
!6 = !{!"_ZTSN2rw6AtomicE", !7, i64 0, !11, i64 40, !13, i64 48, !13, i64 64, !11, i64 80, !12, i64 88, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128}
!7 = !{!"_ZTSN2rw15ObjectWithFrameE", !8, i64 0, !12, i64 16, !11, i64 32}
!8 = !{!"_ZTSN2rw6ObjectE", !9, i64 0, !9, i64 1, !9, i64 2, !9, i64 3, !11, i64 8}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTSN2rw6LLLinkE", !11, i64 0, !11, i64 8}
!13 = !{!"_ZTSN2rw6SphereE", !14, i64 0, !15, i64 12}
!14 = !{!"_ZTSN2rw3V3dE", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"float", !9, i64 0}
!16 = !{!17, !11, i64 152}
!17 = !{!"_ZTSN2rw8GeometryE", !8, i64 0, !18, i64 16, !19, i64 20, !18, i64 24, !18, i64 28, !18, i64 32, !18, i64 36, !11, i64 40, !11, i64 48, !9, i64 56, !11, i64 120, !20, i64 128, !11, i64 144, !11, i64 152, !18, i64 160}
!18 = !{!"int", !9, i64 0}
!19 = !{!"short", !9, i64 0}
!20 = !{!"_ZTSN2rw12MaterialListE", !11, i64 0, !18, i64 8, !18, i64 12}
!21 = !{!22, !18, i64 0}
!22 = !{!"_ZTSN2rw18InstanceDataHeaderE", !18, i64 0}
!23 = !{!6, !11, i64 104}
!24 = !{!25, !18, i64 0}
!25 = !{!"_ZTSN2rw8PipelineE", !18, i64 0, !18, i64 4, !18, i64 8}
!26 = !{!11, !11, i64 0}
!27 = !{!28, !18, i64 4}
!28 = !{!"_ZTSN2rw4wdgl18InstanceDataHeaderE", !22, i64 0, !18, i64 4, !11, i64 8, !18, i64 16, !11, i64 24, !18, i64 32, !18, i64 36}
!29 = !{!28, !11, i64 8}
!30 = !{!31, !18, i64 0}
!31 = !{!"_ZTSN2rw4wdgl10AttribDescE", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16, !18, i64 20}
!32 = !{!31, !18, i64 4}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass