; LLVM IR from TharushaDinujaya/MicroMouse :: src/solver.ll (Z12getNextPointii6Orienti)

; 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 uwtable
define dso_local i64 @_Z12getNextPointii6Orienti(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca %struct.Point, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %12 = load i32, ptr %8, align 4, !tbaa !9
  %13 = load i32, ptr %9, align 4, !tbaa !5
  %14 = call noundef i32 @_Z15getAbsDirection6Orienti(i32 noundef %12, i32 noundef %13)
  store i32 %14, ptr %10, align 4, !tbaa !9
  %15 = load i32, ptr %10, align 4, !tbaa !9
  switch i32 %15, label %40 [
    i32 100, label %16
    i32 101, label %22
    i32 102, label %28
    i32 103, label %34
  ]

16:                                               ; preds = %4
  %17 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %18 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %18, ptr %17, align 4, !tbaa !11
  %19 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %19, align 4, !tbaa !13
  store i32 1, ptr %11, align 4
  br label %44

22:                                               ; preds = %4
  %23 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %23, align 4, !tbaa !11
  %26 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %27 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %27, ptr %26, align 4, !tbaa !13
  store i32 1, ptr %11, align 4
  br label %44

28:                                               ; preds = %4
  %29 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %30 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %30, ptr %29, align 4, !tbaa !11
  %31 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = sub nsw i32 %32, 1
  store i32 %33, ptr %31, align 4, !tbaa !13
  store i32 1, ptr %11, align 4
  br label %44

34:                                               ; preds = %4
  %35 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  store i32 %37, ptr %35, align 4, !tbaa !11
  %38 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %39 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %39, ptr %38, align 4, !tbaa !13
  store i32 1, ptr %11, align 4
  br label %44

40:                                               ; preds = %4
  br label %41

41:                                               ; preds = %40
  %42 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  store i32 -1, ptr %42, align 4, !tbaa !11
  %43 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  store i32 -1, ptr %43, align 4, !tbaa !13
  store i32 1, ptr %11, align 4
  br label %44

44:                                               ; preds = %41, %34, %28, %22, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %45 = load i64, ptr %5, align 4
  ret i64 %45
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z15getAbsDirection6Orienti(i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS6Orient", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS5Point", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, 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 nounwind uwtable
define dso_local i64 @_Z12getNextPointii6Orienti(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call noundef i32 @_Z15getAbsDirection6Orienti(i32 noundef %2, i32 noundef %3)
  switch i32 %5, label %14 [
    i32 100, label %6
    i32 101, label %8
    i32 102, label %10
    i32 103, label %12
  ]

6:                                                ; preds = %4
  %7 = add nsw i32 %1, 1
  br label %14

8:                                                ; preds = %4
  %9 = add nsw i32 %0, 1
  br label %14

10:                                               ; preds = %4
  %11 = add nsw i32 %1, -1
  br label %14

12:                                               ; preds = %4
  %13 = add nsw i32 %0, -1
  br label %14

14:                                               ; preds = %4, %12, %10, %8, %6
  %.sroa.0.0 = phi i32 [ %13, %12 ], [ %0, %10 ], [ %9, %8 ], [ %0, %6 ], [ -1, %4 ]
  %.sroa.6.0 = phi i32 [ %1, %12 ], [ %11, %10 ], [ %1, %8 ], [ %7, %6 ], [ -1, %4 ]
  %.sroa.6.0.insert.ext = zext i32 %.sroa.6.0 to i64
  %.sroa.6.0.insert.shift = shl nuw i64 %.sroa.6.0.insert.ext, 32
  %.sroa.0.0.insert.ext = zext i32 %.sroa.0.0 to i64
  %.sroa.0.0.insert.insert = or disjoint i64 %.sroa.6.0.insert.shift, %.sroa.0.0.insert.ext
  ret i64 %.sroa.0.0.insert.insert
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z15getAbsDirection6Orienti(i32 noundef, i32 noundef) local_unnamed_addr #0

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


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