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

; 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 @_ZN6WPoint4stepEv(ptr noundef nonnull align 4 dereferenceable(28) %0) #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 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 1
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 4
  %7 = load i32, ptr %6, align 4, !tbaa !12
  %8 = add nsw i32 %7, %5
  store i32 %8, ptr %6, align 4, !tbaa !12
  %9 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 2
  %10 = load i32, ptr %9, align 4, !tbaa !13
  %11 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 5
  %12 = load i32, ptr %11, align 4, !tbaa !14
  %13 = add nsw i32 %12, %10
  store i32 %13, ptr %11, align 4, !tbaa !14
  %14 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 3
  %15 = load i32, ptr %14, align 4, !tbaa !15
  %16 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 6
  %17 = load i32, ptr %16, align 4, !tbaa !16
  %18 = add nsw i32 %17, %15
  store i32 %18, ptr %16, align 4, !tbaa !16
  %19 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 4
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = load i32, ptr @_ZN6WPoint11_pixelWidthE, align 4, !tbaa !17
  %22 = icmp sge i32 %20, %21
  br i1 %22, label %23, label %30

23:                                               ; preds = %1
  %24 = load i32, ptr @_ZN6WPoint11_pixelWidthE, align 4, !tbaa !17
  %25 = sub nsw i32 %24, 1
  %26 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 4
  store i32 %25, ptr %26, align 4, !tbaa !12
  %27 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = mul nsw i32 %28, -1
  store i32 %29, ptr %27, align 4, !tbaa !9
  br label %40

30:                                               ; preds = %1
  %31 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 4
  %32 = load i32, ptr %31, align 4, !tbaa !12
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %39

34:                                               ; preds = %30
  %35 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 4
  store i32 0, ptr %35, align 4, !tbaa !12
  %36 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !9
  %38 = mul nsw i32 %37, -1
  store i32 %38, ptr %36, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %34, %30
  br label %40

40:                                               ; preds = %39, %23
  %41 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 5
  %42 = load i32, ptr %41, align 4, !tbaa !14
  %43 = load i32, ptr @_ZN6WPoint12_pixelHeightE, align 4, !tbaa !17
  %44 = icmp sge i32 %42, %43
  br i1 %44, label %45, label %52

45:                                               ; preds = %40
  %46 = load i32, ptr @_ZN6WPoint12_pixelHeightE, align 4, !tbaa !17
  %47 = sub nsw i32 %46, 1
  %48 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 5
  store i32 %47, ptr %48, align 4, !tbaa !14
  %49 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 2
  %50 = load i32, ptr %49, align 4, !tbaa !13
  %51 = mul nsw i32 %50, -1
  store i32 %51, ptr %49, align 4, !tbaa !13
  br label %62

52:                                               ; preds = %40
  %53 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 5
  %54 = load i32, ptr %53, align 4, !tbaa !14
  %55 = icmp slt i32 %54, 0
  br i1 %55, label %56, label %61

56:                                               ; preds = %52
  %57 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 5
  store i32 0, ptr %57, align 4, !tbaa !14
  %58 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 2
  %59 = load i32, ptr %58, align 4, !tbaa !13
  %60 = mul nsw i32 %59, -1
  store i32 %60, ptr %58, align 4, !tbaa !13
  br label %61

61:                                               ; preds = %56, %52
  br label %62

62:                                               ; preds = %61, %45
  %63 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 6
  %64 = load i32, ptr %63, align 4, !tbaa !16
  %65 = load i32, ptr @_ZN6WPoint6_depthE, align 4, !tbaa !17
  %66 = icmp sge i32 %64, %65
  br i1 %66, label %67, label %74

67:                                               ; preds = %62
  %68 = load i32, ptr @_ZN6WPoint6_depthE, align 4, !tbaa !17
  %69 = sub nsw i32 %68, 1
  %70 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 6
  store i32 %69, ptr %70, align 4, !tbaa !16
  %71 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 3
  %72 = load i32, ptr %71, align 4, !tbaa !15
  %73 = mul nsw i32 %72, -1
  store i32 %73, ptr %71, align 4, !tbaa !15
  br label %84

74:                                               ; preds = %62
  %75 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 6
  %76 = load i32, ptr %75, align 4, !tbaa !16
  %77 = icmp slt i32 %76, 0
  br i1 %77, label %78, label %83

78:                                               ; preds = %74
  %79 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 6
  store i32 0, ptr %79, align 4, !tbaa !16
  %80 = getelementptr inbounds %class.WPoint, ptr %3, i32 0, i32 3
  %81 = load i32, ptr %80, align 4, !tbaa !15
  %82 = mul nsw i32 %81, -1
  store i32 %82, ptr %80, align 4, !tbaa !15
  br label %83

83:                                               ; preds = %78, %74
  br label %84

84:                                               ; preds = %83, %67
  ret void
}

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

!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, !11, i64 4}
!10 = !{!"_ZTS6WPoint", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !11, i64 20}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !11, i64 24}
!17 = !{!11, !11, 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 nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN6WPoint4stepEv(ptr nocapture noundef nonnull align 4 dereferenceable(28) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i32, ptr %4, align 4, !tbaa !10
  %6 = add nsw i32 %5, %3
  store i32 %6, ptr %4, align 4, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  %10 = load i32, ptr %9, align 4, !tbaa !12
  %11 = add nsw i32 %10, %8
  store i32 %11, ptr %9, align 4, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 12
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load i32, ptr %14, align 4, !tbaa !14
  %16 = add nsw i32 %15, %13
  store i32 %16, ptr %14, align 4, !tbaa !14
  %17 = load i32, ptr @_ZN6WPoint11_pixelWidthE, align 4, !tbaa !15
  %.not = icmp slt i32 %6, %17
  br i1 %.not, label %20, label %18

18:                                               ; preds = %1
  %19 = add nsw i32 %17, -1
  br label %.sink.split

20:                                               ; preds = %1
  %21 = icmp slt i32 %6, 0
  br i1 %21, label %.sink.split, label %23

.sink.split:                                      ; preds = %20, %18
  %.sink = phi i32 [ %19, %18 ], [ 0, %20 ]
  store i32 %.sink, ptr %4, align 4, !tbaa !10
  %22 = sub nsw i32 0, %3
  store i32 %22, ptr %2, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %.sink.split, %20
  %24 = load i32, ptr @_ZN6WPoint12_pixelHeightE, align 4, !tbaa !15
  %.not6 = icmp slt i32 %11, %24
  br i1 %.not6, label %27, label %25

25:                                               ; preds = %23
  %26 = add nsw i32 %24, -1
  br label %.sink.split8

27:                                               ; preds = %23
  %28 = icmp slt i32 %11, 0
  br i1 %28, label %.sink.split8, label %30

.sink.split8:                                     ; preds = %27, %25
  %.sink10 = phi i32 [ %26, %25 ], [ 0, %27 ]
  store i32 %.sink10, ptr %9, align 4, !tbaa !12
  %29 = sub nsw i32 0, %8
  store i32 %29, ptr %7, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %.sink.split8, %27
  %31 = load i32, ptr @_ZN6WPoint6_depthE, align 4, !tbaa !15
  %.not7 = icmp slt i32 %16, %31
  br i1 %.not7, label %34, label %32

32:                                               ; preds = %30
  %33 = add nsw i32 %31, -1
  br label %.sink.split11

34:                                               ; preds = %30
  %35 = icmp slt i32 %16, 0
  br i1 %35, label %.sink.split11, label %37

.sink.split11:                                    ; preds = %34, %32
  %.sink13 = phi i32 [ %33, %32 ], [ 0, %34 ]
  store i32 %.sink13, ptr %14, align 4, !tbaa !14
  %36 = sub nsw i32 0, %13
  store i32 %36, ptr %12, align 4, !tbaa !13
  br label %37

37:                                               ; preds = %.sink.split11, %34
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: 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, !7, i64 4}
!6 = !{!"_ZTS6WPoint", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 16}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 20}
!13 = !{!6, !7, i64 12}
!14 = !{!6, !7, i64 24}
!15 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass