; LLVM IR from TharushaDinujaya/MicroMouse :: test/mms-cpp (q_test)

; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%struct.Point = type { i32, i32 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca %struct.Point, align 4
  %4 = alloca %struct.Point, align 4
  %5 = alloca %struct.Point, align 4
  %6 = alloca %struct.Point, align 4
  %7 = alloca %struct.Point, align 4
  %8 = alloca %struct.Point, align 4
  %9 = alloca %struct.Point, align 4
  %10 = alloca %struct.Point, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %11 = call noundef ptr @_Z12create_queuei(i32 noundef 5)
  store ptr %11, ptr %2, align 8, !tbaa !5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.Point, ptr %3, i32 0, i32 0
  store i32 1, ptr %13, align 4, !tbaa !9
  %14 = getelementptr inbounds %struct.Point, ptr %3, i32 0, i32 1
  store i32 2, ptr %14, align 4, !tbaa !12
  %15 = load i64, ptr %3, align 4
  call void @_Z7enqueueP5queue5Point(ptr noundef %12, i64 %15)
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Point, ptr %4, i32 0, i32 0
  store i32 3, ptr %17, align 4, !tbaa !9
  %18 = getelementptr inbounds %struct.Point, ptr %4, i32 0, i32 1
  store i32 4, ptr %18, align 4, !tbaa !12
  %19 = load i64, ptr %4, align 4
  call void @_Z7enqueueP5queue5Point(ptr noundef %16, i64 %19)
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  store i32 5, ptr %21, align 4, !tbaa !9
  %22 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  store i32 6, ptr %22, align 4, !tbaa !12
  %23 = load i64, ptr %5, align 4
  call void @_Z7enqueueP5queue5Point(ptr noundef %20, i64 %23)
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Point, ptr %6, i32 0, i32 0
  store i32 3, ptr %25, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.Point, ptr %6, i32 0, i32 1
  store i32 4, ptr %26, align 4, !tbaa !12
  %27 = load i64, ptr %6, align 4
  call void @_Z7enqueueP5queue5Point(ptr noundef %24, i64 %27)
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Point, ptr %7, i32 0, i32 0
  store i32 5, ptr %29, align 4, !tbaa !9
  %30 = getelementptr inbounds %struct.Point, ptr %7, i32 0, i32 1
  store i32 6, ptr %30, align 4, !tbaa !12
  %31 = load i64, ptr %7, align 4
  call void @_Z7enqueueP5queue5Point(ptr noundef %28, i64 %31)
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Point, ptr %8, i32 0, i32 0
  store i32 3, ptr %33, align 4, !tbaa !9
  %34 = getelementptr inbounds %struct.Point, ptr %8, i32 0, i32 1
  store i32 4, ptr %34, align 4, !tbaa !12
  %35 = load i64, ptr %8, align 4
  call void @_Z7enqueueP5queue5Point(ptr noundef %32, i64 %35)
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 0
  store i32 5, ptr %37, align 4, !tbaa !9
  %38 = getelementptr inbounds %struct.Point, ptr %9, i32 0, i32 1
  store i32 6, ptr %38, align 4, !tbaa !12
  %39 = load i64, ptr %9, align 4
  call void @_Z7enqueueP5queue5Point(ptr noundef %36, i64 %39)
  br label %40

40:                                               ; preds = %44, %0
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = call noundef zeroext i1 @_Z5emptyP5queue(ptr noundef %41)
  %43 = xor i1 %42, true
  br i1 %43, label %44, label %55

44:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = call i64 @_Z7dequeueP5queue(ptr noundef %45)
  store i64 %46, ptr %10, align 4
  %47 = getelementptr inbounds %struct.Point, ptr %10, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %48)
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %49, ptr noundef @.str)
  %51 = getelementptr inbounds %struct.Point, ptr %10, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !12
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %50, i32 noundef %52)
  %54 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %40, !llvm.loop !13

55:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %56 = load i32, ptr %1, align 4
  ret i32 %56
}

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

declare noundef ptr @_Z12create_queuei(i32 noundef) #2

declare void @_Z7enqueueP5queue5Point(ptr noundef, i64) #2

declare noundef zeroext i1 @_Z5emptyP5queue(ptr noundef) #2

declare i64 @_Z7dequeueP5queue(ptr noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

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

attributes #0 = { mustprogress norecurse 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 = { "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 = { inlinehint 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 #4 = { 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 #5 = { 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, !11, i64 0}
!10 = !{!"_ZTS5Point", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef ptr @_Z12create_queuei(i32 noundef 5)
  tail call void @_Z7enqueueP5queue5Point(ptr noundef %1, i64 8589934593)
  tail call void @_Z7enqueueP5queue5Point(ptr noundef %1, i64 17179869187)
  tail call void @_Z7enqueueP5queue5Point(ptr noundef %1, i64 25769803781)
  tail call void @_Z7enqueueP5queue5Point(ptr noundef %1, i64 17179869187)
  tail call void @_Z7enqueueP5queue5Point(ptr noundef %1, i64 25769803781)
  tail call void @_Z7enqueueP5queue5Point(ptr noundef %1, i64 17179869187)
  tail call void @_Z7enqueueP5queue5Point(ptr noundef %1, i64 25769803781)
  %2 = tail call noundef zeroext i1 @_Z5emptyP5queue(ptr noundef %1)
  br i1 %2, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %3 = tail call i64 @_Z7dequeueP5queue(ptr noundef %1)
  %.sroa.0.0.extract.trunc = trunc i64 %3 to i32
  %.sroa.4.0.extract.shift = lshr i64 %3, 32
  %.sroa.4.0.extract.trunc = trunc nuw i64 %.sroa.4.0.extract.shift to i32
  %4 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.sroa.0.0.extract.trunc)
  %5 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull @.str)
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %.sroa.4.0.extract.trunc)
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %8 = tail call noundef zeroext i1 @_Z5emptyP5queue(ptr noundef %1)
  br i1 %8, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %0
  ret i32 0
}

declare noundef ptr @_Z12create_queuei(i32 noundef) local_unnamed_addr #1

declare void @_Z7enqueueP5queue5Point(ptr noundef, i64) local_unnamed_addr #1

declare noundef zeroext i1 @_Z5emptyP5queue(ptr noundef) local_unnamed_addr #1

declare i64 @_Z7dequeueP5queue(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

attributes #0 = { mustprogress norecurse 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 = { "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 = { inlinehint 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 #3 = { 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" }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass