; LLVM IR from FOSS-UCSC/FOSSALGO :: data-structures/ds-que/c (queue)

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

@front = external dso_local global i32, align 4
@rear = external dso_local global i32, align 4
@array = external dso_local global [10 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@i = external dso_local global i32, align 4
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

declare i32 @printf(ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local void @display() #1 {
  %1 = load i32, ptr @rear, align 4, !tbaa !5
  %2 = icmp eq i32 %1, -1
  br i1 %2, label %3, label %5

3:                                                ; preds = %0
  %4 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %55

5:                                                ; preds = %0
  %6 = load i32, ptr @front, align 4, !tbaa !5
  %7 = load i32, ptr @rear, align 4, !tbaa !5
  %8 = icmp slt i32 %6, %7
  br i1 %8, label %9, label %25

9:                                                ; preds = %5
  %10 = load i32, ptr @front, align 4, !tbaa !5
  store i32 %10, ptr @i, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %21, %9
  %12 = load i32, ptr @i, align 4, !tbaa !5
  %13 = load i32, ptr @rear, align 4, !tbaa !5
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %15, label %24

15:                                               ; preds = %11
  %16 = load i32, ptr @i, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [10 x i32], ptr @array, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %19)
  br label %21

21:                                               ; preds = %15
  %22 = load i32, ptr @i, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @i, align 4, !tbaa !5
  br label %11, !llvm.loop !9

24:                                               ; preds = %11
  br label %54

25:                                               ; preds = %5
  %26 = load i32, ptr @front, align 4, !tbaa !5
  store i32 %26, ptr @i, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %36, %25
  %28 = load i32, ptr @i, align 4, !tbaa !5
  %29 = icmp slt i32 %28, 10
  br i1 %29, label %30, label %39

30:                                               ; preds = %27
  %31 = load i32, ptr @i, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [10 x i32], ptr @array, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %34)
  br label %36

36:                                               ; preds = %30
  %37 = load i32, ptr @i, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr @i, align 4, !tbaa !5
  br label %27, !llvm.loop !11

39:                                               ; preds = %27
  store i32 0, ptr @i, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %50, %39
  %41 = load i32, ptr @i, align 4, !tbaa !5
  %42 = load i32, ptr @rear, align 4, !tbaa !5
  %43 = icmp sle i32 %41, %42
  br i1 %43, label %44, label %53

44:                                               ; preds = %40
  %45 = load i32, ptr @i, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [10 x i32], ptr @array, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %48)
  br label %50

50:                                               ; preds = %44
  %51 = load i32, ptr @i, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr @i, align 4, !tbaa !5
  br label %40, !llvm.loop !12

53:                                               ; preds = %40
  br label %54

54:                                               ; preds = %53, %24
  br label %55

55:                                               ; preds = %54, %3
  ret void
}

attributes #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 = { 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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

@front = external dso_local local_unnamed_addr global i32, align 4
@rear = external dso_local local_unnamed_addr global i32, align 4
@array = external dso_local local_unnamed_addr global [10 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [18 x i8], align 1
@i = external dso_local local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @display() local_unnamed_addr #1 {
  %1 = load i32, ptr @rear, align 4, !tbaa !5
  %2 = icmp eq i32 %1, -1
  br i1 %2, label %3, label %5

3:                                                ; preds = %0
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.loopexit

5:                                                ; preds = %0
  %6 = load i32, ptr @front, align 4, !tbaa !5
  %7 = icmp slt i32 %6, %1
  store i32 %6, ptr @i, align 4, !tbaa !5
  br i1 %7, label %.lr.ph17, label %.preheader10

.preheader10:                                     ; preds = %5
  %8 = icmp slt i32 %6, 10
  br i1 %8, label %.lr.ph, label %.preheader8

.lr.ph17:                                         ; preds = %5, %.lr.ph17
  %storemerge616 = phi i32 [ %14, %.lr.ph17 ], [ %6, %5 ]
  %9 = sext i32 %storemerge616 to i64
  %10 = getelementptr inbounds [10 x i32], ptr @array, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %11)
  %13 = load i32, ptr @i, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  store i32 %14, ptr @i, align 4, !tbaa !5
  %15 = load i32, ptr @rear, align 4, !tbaa !5
  %.not7.not = icmp slt i32 %13, %15
  br i1 %.not7.not, label %.lr.ph17, label %.loopexit, !llvm.loop !9

.preheader8.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr @rear, align 4, !tbaa !5
  br label %.preheader8

.preheader8:                                      ; preds = %.preheader8.loopexit, %.preheader10
  %16 = phi i32 [ %.pre, %.preheader8.loopexit ], [ %1, %.preheader10 ]
  store i32 0, ptr @i, align 4, !tbaa !5
  %.not12 = icmp slt i32 %16, 0
  br i1 %.not12, label %.loopexit, label %.lr.ph14

.lr.ph:                                           ; preds = %.preheader10, %.lr.ph
  %storemerge11 = phi i32 [ %22, %.lr.ph ], [ %6, %.preheader10 ]
  %17 = sext i32 %storemerge11 to i64
  %18 = getelementptr inbounds [10 x i32], ptr @array, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %19)
  %21 = load i32, ptr @i, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr @i, align 4, !tbaa !5
  %23 = icmp slt i32 %21, 9
  br i1 %23, label %.lr.ph, label %.preheader8.loopexit, !llvm.loop !11

.lr.ph14:                                         ; preds = %.preheader8, %.lr.ph14
  %storemerge513 = phi i32 [ %29, %.lr.ph14 ], [ 0, %.preheader8 ]
  %24 = sext i32 %storemerge513 to i64
  %25 = getelementptr inbounds [10 x i32], ptr @array, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %26)
  %28 = load i32, ptr @i, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr @i, align 4, !tbaa !5
  %30 = load i32, ptr @rear, align 4, !tbaa !5
  %.not.not = icmp slt i32 %28, %30
  br i1 %.not.not, label %.lr.ph14, label %.loopexit, !llvm.loop !12

.loopexit:                                        ; preds = %.lr.ph14, %.lr.ph17, %.preheader8, %3
  ret void
}

attributes #0 = { nofree nounwind "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 = { nofree 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SimplifyCFGPass,TailCallElimPass