; LLVM IR from TrainingByPackt/CPP-Data-Structures-and-Algorithm-Design-Principles :: Lesson9/Activity23/Activity 23 - Residential Roads.ll (Z10DirectLine5PointS_)

; 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.Point = type { i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z10DirectLine5PointS_(i64 %0, i64 %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca %struct.Point, align 4
  %5 = alloca %struct.Point, align 4
  store i64 %0, ptr %4, align 4
  store i64 %1, ptr %5, align 4
  %6 = getelementptr inbounds %struct.Point, ptr %4, i32 0, i32 0
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i32 %7, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  br label %35

12:                                               ; preds = %2
  %13 = getelementptr inbounds %struct.Point, ptr %4, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !10
  %15 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !10
  %17 = icmp eq i32 %14, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %12
  store i1 true, ptr %3, align 1
  br label %35

19:                                               ; preds = %12
  %20 = getelementptr inbounds %struct.Point, ptr %4, i32 0, i32 0
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sub nsw i32 %21, %23
  %25 = call i32 @llvm.abs.i32(i32 %24, i1 true)
  %26 = getelementptr inbounds %struct.Point, ptr %4, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !10
  %28 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !10
  %30 = sub nsw i32 %27, %29
  %31 = call i32 @llvm.abs.i32(i32 %30, i1 true)
  %32 = icmp eq i32 %25, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %19
  store i1 true, ptr %3, align 1
  br label %35

34:                                               ; preds = %19
  store i1 false, ptr %3, align 1
  br label %35

35:                                               ; preds = %34, %33, %18, %11
  %36 = load i1, ptr %3, align 1
  ret i1 %36
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 0}
!6 = !{!"_ZTS5Point", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_Z10DirectLine5PointS_(i64 %0, i64 %1) local_unnamed_addr #0 {
  %.sroa.03.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.35.0.extract.shift = lshr i64 %0, 32
  %.sroa.0.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.3.0.extract.shift = lshr i64 %1, 32
  %3 = icmp eq i32 %.sroa.03.0.extract.trunc, %.sroa.0.0.extract.trunc
  %4 = icmp eq i64 %.sroa.35.0.extract.shift, %.sroa.3.0.extract.shift
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %11, label %5

5:                                                ; preds = %2
  %.sroa.3.0.extract.trunc = trunc nuw i64 %.sroa.3.0.extract.shift to i32
  %.sroa.35.0.extract.trunc = trunc nuw i64 %.sroa.35.0.extract.shift to i32
  %6 = sub nsw i32 %.sroa.03.0.extract.trunc, %.sroa.0.0.extract.trunc
  %7 = tail call i32 @llvm.abs.i32(i32 %6, i1 true)
  %8 = sub nsw i32 %.sroa.35.0.extract.trunc, %.sroa.3.0.extract.trunc
  %9 = tail call i32 @llvm.abs.i32(i32 %8, i1 true)
  %10 = icmp eq i32 %7, %9
  br label %11

11:                                               ; preds = %5, %2
  %.0 = phi i1 [ true, %2 ], [ %10, %5 ]
  ret i1 %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


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