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

; 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
declare dso_local i64 @_Z12getNextPointii6Orienti(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; 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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8setWallsPA14_i5Point6Orienti(ptr noundef %0, i64 %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca %struct.Point, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.Point, align 4
  %10 = alloca i32, align 4
  store i64 %1, ptr %5, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %11 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !15
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = load i32, ptr %8, align 4, !tbaa !11
  %17 = call i64 @_Z12getNextPointii6Orienti(i32 noundef %12, i32 noundef %14, i32 noundef %15, i32 noundef %16)
  store i64 %17, ptr %9, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !11
  %20 = call noundef i32 @_Z15getAbsDirection6Orienti(i32 noundef %18, i32 noundef %19)
  store i32 %20, ptr %10, align 4, !tbaa !9
  %21 = load i32, ptr %10, align 4, !tbaa !9
  switch i32 %21, label %114 [
    i32 100, label %22
    i32 101, label %45
    i32 102, label %68
    i32 103, label %91
  ]

22:                                               ; preds = %4
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [14 x i32], ptr %23, i64 %26
  %28 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !15
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [14 x i32], ptr %27, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = or i32 %32, 2
  store i32 %33, ptr %31, align 4, !tbaa !11
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !13
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [14 x i32], ptr %34, i64 %37
  %39 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !15
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [14 x i32], ptr %38, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = or i32 %43, 8
  store i32 %44, ptr %42, align 4, !tbaa !11
  br label %115

45:                                               ; preds = %4
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !13
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [14 x i32], ptr %46, i64 %49
  %51 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !15
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [14 x i32], ptr %50, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !11
  %56 = or i32 %55, 4
  store i32 %56, ptr %54, align 4, !tbaa !11
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 0
  %59 = load i32, ptr %58, align 4, !tbaa !13
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [14 x i32], ptr %57, i64 %60
  %62 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !15
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [14 x i32], ptr %61, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !11
  %67 = or i32 %66, 1
  store i32 %67, ptr %65, align 4, !tbaa !11
  br label %115

68:                                               ; preds = %4
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %71 = load i32, ptr %70, align 4, !tbaa !13
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [14 x i32], ptr %69, i64 %72
  %74 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !15
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [14 x i32], ptr %73, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !11
  %79 = or i32 %78, 8
  store i32 %79, ptr %77, align 4, !tbaa !11
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !13
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [14 x i32], ptr %80, i64 %83
  %85 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 1
  %86 = load i32, ptr %85, align 4, !tbaa !15
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [14 x i32], ptr %84, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !11
  %90 = or i32 %89, 2
  store i32 %90, ptr %88, align 4, !tbaa !11
  br label %115

91:                                               ; preds = %4
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %94 = load i32, ptr %93, align 4, !tbaa !13
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [14 x i32], ptr %92, i64 %95
  %97 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %98 = load i32, ptr %97, align 4, !tbaa !15
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [14 x i32], ptr %96, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !11
  %102 = or i32 %101, 1
  store i32 %102, ptr %100, align 4, !tbaa !11
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 0
  %105 = load i32, ptr %104, align 4, !tbaa !13
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [14 x i32], ptr %103, i64 %106
  %108 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !15
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [14 x i32], ptr %107, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !11
  %113 = or i32 %112, 4
  store i32 %113, ptr %111, align 4, !tbaa !11
  br label %115

114:                                              ; preds = %4
  br label %115

115:                                              ; preds = %114, %91, %68, %45, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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 = !{!"any pointer", !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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTS5Point", !12, i64 0, !12, i64 4}
!15 = !{!14, !12, 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"

@switch.table._Z8setWallsPA14_i5Point6Orienti = private unnamed_addr constant [4 x i32] [i32 2, i32 4, i32 8, i32 1], align 4
@switch.table._Z8setWallsPA14_i5Point6Orienti.1 = private unnamed_addr constant [4 x i32] [i32 8, i32 1, i32 2, i32 4], align 4

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8setWallsPA14_i5Point6Orienti(ptr nocapture noundef %0, i64 %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %.sroa.018.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.6.0.extract.shift = lshr i64 %1, 32
  %.sroa.6.0.extract.trunc = trunc nuw i64 %.sroa.6.0.extract.shift to i32
  %5 = tail call i64 @_Z12getNextPointii6Orienti(i32 noundef %.sroa.018.0.extract.trunc, i32 noundef %.sroa.6.0.extract.trunc, i32 noundef %2, i32 noundef %3)
  %6 = tail call noundef i32 @_Z15getAbsDirection6Orienti(i32 noundef %2, i32 noundef %3)
  %switch.tableidx = add i32 %6, -100
  %7 = icmp ult i32 %switch.tableidx, 4
  br i1 %7, label %switch.lookup, label %20

switch.lookup:                                    ; preds = %4
  %8 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [4 x i32], ptr @switch.table._Z8setWallsPA14_i5Point6Orienti, i64 0, i64 %8
  %switch.load = load i32, ptr %switch.gep, align 4
  %9 = zext nneg i32 %switch.tableidx to i64
  %switch.gep52 = getelementptr inbounds [4 x i32], ptr @switch.table._Z8setWallsPA14_i5Point6Orienti.1, i64 0, i64 %9
  %switch.load53 = load i32, ptr %switch.gep52, align 4
  %sext = shl i64 %1, 32
  %10 = ashr exact i64 %sext, 32
  %11 = ashr i64 %1, 32
  %12 = getelementptr inbounds [14 x i32], ptr %0, i64 %10, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = or i32 %13, %switch.load
  store i32 %14, ptr %12, align 4, !tbaa !5
  %sext28 = shl i64 %5, 32
  %15 = ashr exact i64 %sext28, 32
  %16 = ashr i64 %5, 32
  %17 = getelementptr inbounds [14 x i32], ptr %0, i64 %15, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = or i32 %18, %switch.load53
  store i32 %19, ptr %17, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %4, %switch.lookup
  ret void
}

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


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