; LLVM IR from hcoffey1/worley :: src/WPoint.ll (ZN6WPointC2Ev)

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

%class.WPoint = type { i32, i32, i32, i32, i32, i32, i32 }

@_ZN6WPoint11_pixelWidthE = external dso_local global i32, align 4
@_ZN6WPoint12_pixelHeightE = external dso_local global i32, align 4
@_ZN6WPoint6_depthE = external dso_local global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6WPointC2Ev(ptr noundef nonnull align 4 dereferenceable(28) %0) unnamed_addr #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 = load i32, ptr @_ZN6WPoint11_pixelWidthE, align 4, !tbaa !9
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %6, label %19

6:                                                ; preds = %1
  %7 = call i32 @rand() #2
  %8 = load i32, ptr @_ZN6WPoint11_pixelWidthE, align 4, !tbaa !9
  %9 = srem i32 %7, %8
  %10 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 4
  store i32 %9, ptr %10, align 4, !tbaa !11
  %11 = call i32 @rand() #2
  %12 = load i32, ptr @_ZN6WPoint12_pixelHeightE, align 4, !tbaa !9
  %13 = srem i32 %11, %12
  %14 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 5
  store i32 %13, ptr %14, align 4, !tbaa !13
  %15 = call i32 @rand() #2
  %16 = load i32, ptr @_ZN6WPoint6_depthE, align 4, !tbaa !9
  %17 = srem i32 %15, %16
  %18 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 6
  store i32 %17, ptr %18, align 4, !tbaa !14
  br label %24

19:                                               ; preds = %1
  %20 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 6
  store i32 0, ptr %20, align 4, !tbaa !14
  %21 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 5
  store i32 0, ptr %21, align 4, !tbaa !13
  %22 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 4
  store i32 0, ptr %22, align 4, !tbaa !11
  %23 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 0
  store i32 0, ptr %23, align 4, !tbaa !15
  br label %24

24:                                               ; preds = %19, %6
  ret void
}

; Function Attrs: nounwind
declare i32 @rand() #1

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" }
attributes #1 = { 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 #2 = { 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, !10, i64 16}
!12 = !{!"_ZTS6WPoint", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!13 = !{!12, !10, i64 20}
!14 = !{!12, !10, i64 24}
!15 = !{!12, !10, 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"

@_ZN6WPoint11_pixelWidthE = external dso_local local_unnamed_addr global i32, align 4
@_ZN6WPoint12_pixelHeightE = external dso_local local_unnamed_addr global i32, align 4
@_ZN6WPoint6_depthE = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6WPointC2Ev(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(28) %0) unnamed_addr #0 align 2 {
  %2 = load i32, ptr @_ZN6WPoint11_pixelWidthE, align 4, !tbaa !5
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %15, label %3

3:                                                ; preds = %1
  %4 = tail call i32 @rand() #2
  %5 = load i32, ptr @_ZN6WPoint11_pixelWidthE, align 4, !tbaa !5
  %6 = srem i32 %4, %5
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %6, ptr %7, align 4, !tbaa !9
  %8 = tail call i32 @rand() #2
  %9 = load i32, ptr @_ZN6WPoint12_pixelHeightE, align 4, !tbaa !5
  %10 = srem i32 %8, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %10, ptr %11, align 4, !tbaa !11
  %12 = tail call i32 @rand() #2
  %13 = load i32, ptr @_ZN6WPoint6_depthE, align 4, !tbaa !5
  %14 = srem i32 %12, %13
  br label %18

15:                                               ; preds = %1
  %16 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 0, ptr %16, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 0, ptr %17, align 4, !tbaa !9
  store i32 0, ptr %0, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %15, %3
  %.sink = phi i32 [ 0, %15 ], [ %14, %3 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %.sink, ptr %19, align 4
  ret void
}

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #1

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" }
attributes #1 = { 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 #2 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"_ZTS6WPoint", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24}
!11 = !{!10, !6, i64 20}
!12 = !{!10, !6, i64 0}


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