; LLVM IR from upupming/algorithm :: upupming/1091.ll (Z7inQueueiiiRSt5queueI3posSt5dequeIS0_SaIS0_EEE)

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

@m = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@l = external dso_local global i32, align 4
@a = external dso_local global [1300 x [140 x [100 x i32]]], align 16
@visited = external dso_local global [1300 x [140 x [100 x i8]]], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7inQueueiiiRSt5queueI3posSt5dequeIS0_SaIS0_EEE(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(80) %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %struct.pos, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !9
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 0
  br i1 %11, label %30, label %12

12:                                               ; preds = %4
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = load i32, ptr @m, align 4, !tbaa !5
  %15 = icmp sge i32 %13, %14
  br i1 %15, label %30, label %16

16:                                               ; preds = %12
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %30, label %19

19:                                               ; preds = %16
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp sge i32 %20, %21
  br i1 %22, label %30, label %23

23:                                               ; preds = %19
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp slt i32 %24, 0
  br i1 %25, label %30, label %26

26:                                               ; preds = %23
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = load i32, ptr @l, align 4, !tbaa !5
  %29 = icmp sge i32 %27, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %26, %23, %19, %16, %12, %4
  br label %73

31:                                               ; preds = %26
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [1300 x [140 x [100 x i32]]], ptr @a, i64 0, i64 %33
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [140 x [100 x i32]], ptr %34, i64 0, i64 %36
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100 x i32], ptr %37, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %55, label %43

43:                                               ; preds = %31
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1300 x [140 x [100 x i8]]], ptr @visited, i64 0, i64 %45
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [140 x [100 x i8]], ptr %46, i64 0, i64 %48
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100 x i8], ptr %49, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !11, !range !13, !noundef !14
  %54 = trunc i8 %53 to i1
  br i1 %54, label %55, label %56

55:                                               ; preds = %43, %31
  br label %73

56:                                               ; preds = %43
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1300 x [140 x [100 x i8]]], ptr @visited, i64 0, i64 %58
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [140 x [100 x i8]], ptr %59, i64 0, i64 %61
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100 x i8], ptr %62, i64 0, i64 %64
  store i8 1, ptr %65, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #2
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = getelementptr inbounds %struct.pos, ptr %9, i32 0, i32 0
  store i32 %66, ptr %67, align 4, !tbaa !15
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = getelementptr inbounds %struct.pos, ptr %9, i32 0, i32 1
  store i32 %68, ptr %69, align 4, !tbaa !17
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = getelementptr inbounds %struct.pos, ptr %9, i32 0, i32 2
  store i32 %70, ptr %71, align 4, !tbaa !18
  %72 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZNSt5queueI3posSt5dequeIS0_SaIS0_EEE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(80) %72, ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #2
  br label %73

73:                                               ; preds = %56, %55, %30
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI3posSt5dequeIS0_SaIS0_EEE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(12)) #0 align 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 = { 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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS3pos", !6, i64 0, !6, i64 4, !6, i64 8}
!17 = !{!16, !6, i64 4}
!18 = !{!16, !6, i64 8}


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

%struct.pos = type { i32, i32, i32 }

@m = external dso_local local_unnamed_addr global i32, align 4
@n = external dso_local local_unnamed_addr global i32, align 4
@l = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local local_unnamed_addr global [1300 x [140 x [100 x i32]]], align 16
@visited = external dso_local local_unnamed_addr global [1300 x [140 x [100 x i8]]], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7inQueueiiiRSt5queueI3posSt5dequeIS0_SaIS0_EEE(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(80) %3) local_unnamed_addr #0 {
  %5 = alloca %struct.pos, align 4
  %6 = icmp slt i32 %0, 0
  br i1 %6, label %30, label %7

7:                                                ; preds = %4
  %8 = load i32, ptr @m, align 4, !tbaa !5
  %9 = icmp sle i32 %8, %0
  %10 = icmp slt i32 %1, 0
  %or.cond = or i1 %10, %9
  br i1 %or.cond, label %30, label %11

11:                                               ; preds = %7
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, %1
  %14 = icmp sgt i32 %2, -1
  %or.cond3.not26 = and i1 %14, %13
  %15 = load i32, ptr @l, align 4
  %.not = icmp sgt i32 %15, %2
  %or.cond23 = select i1 %or.cond3.not26, i1 %.not, i1 false
  br i1 %or.cond23, label %16, label %30

16:                                               ; preds = %11
  %17 = zext nneg i32 %0 to i64
  %18 = zext nneg i32 %1 to i64
  %19 = zext nneg i32 %2 to i64
  %20 = getelementptr inbounds [1300 x [140 x [100 x i32]]], ptr @a, i64 0, i64 %17, i64 %18, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %30, label %23

23:                                               ; preds = %16
  %24 = getelementptr inbounds [1300 x [140 x [100 x i8]]], ptr @visited, i64 0, i64 %17, i64 %18, i64 %19
  %25 = load i8, ptr %24, align 1, !tbaa !9, !range !11, !noundef !12
  %26 = trunc nuw i8 %25 to i1
  br i1 %26, label %30, label %27

27:                                               ; preds = %23
  store i8 1, ptr %24, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #2
  store i32 %0, ptr %5, align 4, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %1, ptr %28, align 4, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %2, ptr %29, align 4, !tbaa !16
  call void @_ZNSt5queueI3posSt5dequeIS0_SaIS0_EEE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 4 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #2
  br label %30

30:                                               ; preds = %16, %23, %4, %7, %11, %27
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI3posSt5dequeIS0_SaIS0_EEE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS3pos", !6, i64 0, !6, i64 4, !6, i64 8}
!15 = !{!14, !6, i64 4}
!16 = !{!14, !6, i64 8}


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