; LLVM IR from aap/librw :: src/ps2/ps2.ll (ZN2rw3ps211printDMAVIFEPNS0_12InstanceDataE)

; 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::ps2::InstanceData" = type { i32, ptr, ptr, ptr }

@.str.24 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [18 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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw3ps211printDMAVIFEPNS0_12InstanceDataE(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %6, i32 0, i32 2
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %9, i32 0, i32 2
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  br label %12

12:                                               ; preds = %80, %1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds i32, ptr %13, i64 0
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = and i32 %15, 65535
  store i32 %16, ptr %5, align 4, !tbaa !12
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds i32, ptr %17, i64 0
  %19 = load i32, ptr %18, align 4, !tbaa !12
  %20 = and i32 %19, 1879048192
  switch i32 %20, label %80 [
    i32 268435456, label %21
    i32 805306368, label %42
    i32 1610612736, label %64
  ]

21:                                               ; preds = %12
  %22 = load i32, ptr %5, align 4, !tbaa !12
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds i32, ptr %23, i64 1
  %25 = load i32, ptr %24, align 4, !tbaa !12
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.32, i32 noundef %22, i32 noundef %25)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds i32, ptr %27, i64 2
  %29 = load i32, ptr %28, align 4, !tbaa !12
  call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %29)
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds i32, ptr %30, i64 3
  %32 = load i32, ptr %31, align 4, !tbaa !12
  call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %32)
  %33 = load i32, ptr %5, align 4, !tbaa !12
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds i32, ptr %34, i64 4
  call void @_ZN2rw3ps2L6dmaVIFEiPj(i32 noundef %33, ptr noundef %35)
  %36 = load i32, ptr %5, align 4, !tbaa !12
  %37 = add i32 1, %36
  %38 = mul i32 %37, 4
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = zext i32 %38 to i64
  %41 = getelementptr inbounds i32, ptr %39, i64 %40
  store ptr %41, ptr %3, align 8, !tbaa !5
  br label %80

42:                                               ; preds = %12
  %43 = load i32, ptr %5, align 4, !tbaa !12
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds i32, ptr %44, i64 1
  %46 = load i32, ptr %45, align 4, !tbaa !12
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.33, i32 noundef %43, i32 noundef %46)
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds i32, ptr %48, i64 2
  %50 = load i32, ptr %49, align 4, !tbaa !12
  call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %50)
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds i32, ptr %51, i64 3
  %53 = load i32, ptr %52, align 4, !tbaa !12
  call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %53)
  %54 = load i32, ptr %5, align 4, !tbaa !12
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds i32, ptr %56, i64 1
  %58 = load i32, ptr %57, align 4, !tbaa !12
  %59 = mul i32 %58, 4
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds i32, ptr %55, i64 %60
  call void @_ZN2rw3ps2L6dmaVIFEiPj(i32 noundef %54, ptr noundef %61)
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds i32, ptr %62, i64 4
  store ptr %63, ptr %3, align 8, !tbaa !5
  br label %80

64:                                               ; preds = %12
  %65 = load i32, ptr %5, align 4, !tbaa !12
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds i32, ptr %66, i64 1
  %68 = load i32, ptr %67, align 4, !tbaa !12
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.34, i32 noundef %65, i32 noundef %68)
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds i32, ptr %70, i64 2
  %72 = load i32, ptr %71, align 4, !tbaa !12
  call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %72)
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds i32, ptr %73, i64 3
  %75 = load i32, ptr %74, align 4, !tbaa !12
  call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %75)
  %76 = load i32, ptr %5, align 4, !tbaa !12
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds i32, ptr %77, i64 4
  call void @_ZN2rw3ps2L6dmaVIFEiPj(i32 noundef %76, ptr noundef %78)
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.24)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void

80:                                               ; preds = %42, %21, %12
  br label %12, !llvm.loop !13
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rw3ps2L7sendVIFEj(i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rw3ps2L6dmaVIFEiPj(i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { 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 16}
!10 = !{!"_ZTSN2rw3ps212InstanceDataE", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@.str.24 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [18 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw3ps211printDMAVIFEPNS0_12InstanceDataE(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  br label %.outer

.outer:                                           ; preds = %.outer.backedge, %1
  %.0.ph = phi ptr [ %3, %1 ], [ %.0.ph.be, %.outer.backedge ]
  %4 = load i32, ptr %.0.ph, align 4, !tbaa !11
  %5 = and i32 %4, 1879048192
  br label %6

6:                                                ; preds = %.outer, %6
  switch i32 %5, label %6 [
    i32 268435456, label %7
    i32 805306368, label %21
    i32 1610612736, label %35
  ], !llvm.loop !12

7:                                                ; preds = %6
  %8 = and i32 %4, 65535
  %9 = getelementptr inbounds i8, ptr %.0.ph, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.32, i32 noundef %8, i32 noundef %10)
  %12 = getelementptr inbounds i8, ptr %.0.ph, i64 8
  %13 = load i32, ptr %12, align 4, !tbaa !11
  tail call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %13)
  %14 = getelementptr inbounds i8, ptr %.0.ph, i64 12
  %15 = load i32, ptr %14, align 4, !tbaa !11
  tail call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %15)
  %16 = getelementptr inbounds i8, ptr %.0.ph, i64 16
  tail call void @_ZN2rw3ps2L6dmaVIFEiPj(i32 noundef %8, ptr noundef nonnull %16)
  %17 = shl nuw nsw i32 %8, 2
  %18 = add nuw nsw i32 %17, 4
  %19 = zext nneg i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr %.0.ph, i64 %19
  br label %.outer.backedge

21:                                               ; preds = %6
  %22 = and i32 %4, 65535
  %23 = getelementptr inbounds i8, ptr %.0.ph, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.33, i32 noundef %22, i32 noundef %24)
  %26 = getelementptr inbounds i8, ptr %.0.ph, i64 8
  %27 = load i32, ptr %26, align 4, !tbaa !11
  tail call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %27)
  %28 = getelementptr inbounds i8, ptr %.0.ph, i64 12
  %29 = load i32, ptr %28, align 4, !tbaa !11
  tail call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %29)
  %30 = load i32, ptr %23, align 4, !tbaa !11
  %31 = shl i32 %30, 2
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %3, i64 %32
  tail call void @_ZN2rw3ps2L6dmaVIFEiPj(i32 noundef %22, ptr noundef %33)
  %34 = getelementptr inbounds i8, ptr %.0.ph, i64 16
  br label %.outer.backedge

.outer.backedge:                                  ; preds = %21, %7
  %.0.ph.be = phi ptr [ %20, %7 ], [ %34, %21 ]
  br label %.outer, !llvm.loop !12

35:                                               ; preds = %6
  %36 = and i32 %4, 65535
  %37 = getelementptr inbounds i8, ptr %.0.ph, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.34, i32 noundef %36, i32 noundef %38)
  %40 = getelementptr inbounds i8, ptr %.0.ph, i64 8
  %41 = load i32, ptr %40, align 4, !tbaa !11
  tail call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %41)
  %42 = getelementptr inbounds i8, ptr %.0.ph, i64 12
  %43 = load i32, ptr %42, align 4, !tbaa !11
  tail call void @_ZN2rw3ps2L7sendVIFEj(i32 noundef %43)
  %44 = getelementptr inbounds i8, ptr %.0.ph, i64 16
  tail call void @_ZN2rw3ps2L6dmaVIFEiPj(i32 noundef %36, ptr noundef nonnull %44)
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24)
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rw3ps2L7sendVIFEj(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rw3ps2L6dmaVIFEiPj(i32 noundef, ptr noundef) local_unnamed_addr #1

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

!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 16}
!6 = !{!"_ZTSN2rw3ps212InstanceDataE", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass