; LLVM IR from HarshCasper/NeoAlgo :: C/graphs (BFS)

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

@n = external dso_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@g = external dso_local global [20 x [20 x i32]], align 16
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [24 x i8], align 1

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

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

; Function Attrs: inlinehint nounwind uwtable
declare i32 @getchar() #2

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @create() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  store i8 121, ptr %3, align 1, !tbaa !5
  %4 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %5 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n)
  store i32 0, ptr %1, align 4, !tbaa !8
  br label %8

8:                                                ; preds = %28, %0
  %9 = load i32, ptr %1, align 4, !tbaa !8
  %10 = load i32, ptr @n, align 4, !tbaa !8
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %12, label %31

12:                                               ; preds = %8
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %13

13:                                               ; preds = %24, %12
  %14 = load i32, ptr %2, align 4, !tbaa !8
  %15 = load i32, ptr @n, align 4, !tbaa !8
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %17, label %27

17:                                               ; preds = %13
  %18 = load i32, ptr %1, align 4, !tbaa !8
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [20 x [20 x i32]], ptr @g, i64 0, i64 %19
  %21 = load i32, ptr %2, align 4, !tbaa !8
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [20 x i32], ptr %20, i64 0, i64 %22
  store i32 0, ptr %23, align 4, !tbaa !8
  br label %24

24:                                               ; preds = %17
  %25 = load i32, ptr %2, align 4, !tbaa !8
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !8
  br label %13, !llvm.loop !10

27:                                               ; preds = %13
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %1, align 4, !tbaa !8
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %1, align 4, !tbaa !8
  br label %8, !llvm.loop !12

31:                                               ; preds = %8
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  br label %33

33:                                               ; preds = %62, %31
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.12, ptr noundef %1, ptr noundef %2)
  %36 = load i32, ptr %1, align 4, !tbaa !8
  %37 = load i32, ptr @n, align 4, !tbaa !8
  %38 = icmp sge i32 %36, %37
  br i1 %38, label %43, label %39

39:                                               ; preds = %33
  %40 = load i32, ptr %2, align 4, !tbaa !8
  %41 = load i32, ptr @n, align 4, !tbaa !8
  %42 = icmp sge i32 %40, %41
  br i1 %42, label %43, label %45

43:                                               ; preds = %39, %33
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  br label %58

45:                                               ; preds = %39
  %46 = load i32, ptr %1, align 4, !tbaa !8
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [20 x [20 x i32]], ptr @g, i64 0, i64 %47
  %49 = load i32, ptr %2, align 4, !tbaa !8
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [20 x i32], ptr %48, i64 0, i64 %50
  store i32 1, ptr %51, align 4, !tbaa !8
  %52 = load i32, ptr %2, align 4, !tbaa !8
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [20 x [20 x i32]], ptr @g, i64 0, i64 %53
  %55 = load i32, ptr %1, align 4, !tbaa !8
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [20 x i32], ptr %54, i64 0, i64 %56
  store i32 1, ptr %57, align 4, !tbaa !8
  br label %58

58:                                               ; preds = %45, %43
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  %60 = call i32 @getchar()
  %61 = trunc i32 %60 to i8
  store i8 %61, ptr %3, align 1, !tbaa !5
  br label %62

62:                                               ; preds = %58
  %63 = load i8, ptr %3, align 1, !tbaa !5
  %64 = sext i8 %63 to i32
  %65 = icmp eq i32 %64, 121
  br i1 %65, label %33, label %66, !llvm.loop !13

66:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


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

@n = external dso_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@g = external dso_local local_unnamed_addr global [20 x [20 x i32]], align 16
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [24 x i8], align 1

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

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

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @getchar() local_unnamed_addr #2

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @create() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.preheader.us.preheader, label %._crit_edge9

.preheader.us.preheader:                          ; preds = %0
  %9 = zext nneg i32 %7 to i64
  %10 = shl nuw nsw i64 %9, 2
  %xtraiter = and i64 %9, 7
  %11 = icmp ult i32 %7, 8
  br i1 %11, label %._crit_edge9.loopexit.unr-lcssa, label %.preheader.us.preheader.new

.preheader.us.preheader.new:                      ; preds = %.preheader.us.preheader
  %unroll_iter = and i64 %9, 2147483640
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us, %.preheader.us.preheader.new
  %indvar = phi i64 [ 0, %.preheader.us.preheader.new ], [ %indvar.next.7, %.preheader.us ]
  %niter = phi i64 [ 0, %.preheader.us.preheader.new ], [ %niter.next.7, %.preheader.us ]
  %12 = mul nuw nsw i64 %indvar, 80
  %scevgep = getelementptr i8, ptr @g, i64 %12
  tail call void @llvm.memset.p0.i64(ptr align 16 %scevgep, i8 0, i64 %10, i1 false), !tbaa !5
  %13 = mul nuw i64 %indvar, 80
  %14 = or disjoint i64 %13, 80
  %scevgep.1 = getelementptr i8, ptr @g, i64 %14
  tail call void @llvm.memset.p0.i64(ptr align 16 %scevgep.1, i8 0, i64 %10, i1 false), !tbaa !5
  %15 = mul nuw i64 %indvar, 80
  %gep = getelementptr i8, ptr getelementptr (i8, ptr @g, i64 160), i64 %15
  tail call void @llvm.memset.p0.i64(ptr align 16 %gep, i8 0, i64 %10, i1 false), !tbaa !5
  %16 = mul nuw i64 %indvar, 80
  %gep17 = getelementptr i8, ptr getelementptr (i8, ptr @g, i64 240), i64 %16
  tail call void @llvm.memset.p0.i64(ptr align 16 %gep17, i8 0, i64 %10, i1 false), !tbaa !5
  %17 = mul nuw i64 %indvar, 80
  %gep18 = getelementptr i8, ptr getelementptr (i8, ptr @g, i64 320), i64 %17
  tail call void @llvm.memset.p0.i64(ptr align 16 %gep18, i8 0, i64 %10, i1 false), !tbaa !5
  %18 = mul nuw i64 %indvar, 80
  %gep19 = getelementptr i8, ptr getelementptr (i8, ptr @g, i64 400), i64 %18
  tail call void @llvm.memset.p0.i64(ptr align 16 %gep19, i8 0, i64 %10, i1 false), !tbaa !5
  %19 = mul nuw i64 %indvar, 80
  %gep20 = getelementptr i8, ptr getelementptr (i8, ptr @g, i64 480), i64 %19
  tail call void @llvm.memset.p0.i64(ptr align 16 %gep20, i8 0, i64 %10, i1 false), !tbaa !5
  %20 = mul nuw i64 %indvar, 80
  %gep21 = getelementptr i8, ptr getelementptr (i8, ptr @g, i64 560), i64 %20
  tail call void @llvm.memset.p0.i64(ptr align 16 %gep21, i8 0, i64 %10, i1 false), !tbaa !5
  %indvar.next.7 = add nuw nsw i64 %indvar, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge9.loopexit.unr-lcssa, label %.preheader.us, !llvm.loop !9

._crit_edge9.loopexit.unr-lcssa:                  ; preds = %.preheader.us, %.preheader.us.preheader
  %indvar.unr = phi i64 [ 0, %.preheader.us.preheader ], [ %indvar.next.7, %.preheader.us ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge9, label %.preheader.us.epil

.preheader.us.epil:                               ; preds = %._crit_edge9.loopexit.unr-lcssa, %.preheader.us.epil
  %indvar.epil = phi i64 [ %indvar.next.epil, %.preheader.us.epil ], [ %indvar.unr, %._crit_edge9.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.us.epil ], [ 0, %._crit_edge9.loopexit.unr-lcssa ]
  %21 = mul nuw nsw i64 %indvar.epil, 80
  %scevgep.epil = getelementptr i8, ptr @g, i64 %21
  tail call void @llvm.memset.p0.i64(ptr align 16 %scevgep.epil, i8 0, i64 %10, i1 false), !tbaa !5
  %indvar.next.epil = add nuw nsw i64 %indvar.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge9, label %.preheader.us.epil, !llvm.loop !11

._crit_edge9:                                     ; preds = %._crit_edge9.loopexit.unr-lcssa, %.preheader.us.epil, %0
  %storemerge.lcssa = phi i32 [ 0, %0 ], [ %7, %.preheader.us.epil ], [ %7, %._crit_edge9.loopexit.unr-lcssa ]
  store i32 %storemerge.lcssa, ptr %1, align 4, !tbaa !5
  store i32 %7, ptr %2, align 4, !tbaa !5
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  br label %23

23:                                               ; preds = %37, %._crit_edge9
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.12, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %.not = icmp slt i32 %26, %27
  br i1 %.not, label %28, label %30

28:                                               ; preds = %23
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %.not4 = icmp slt i32 %29, %27
  br i1 %.not4, label %32, label %30

30:                                               ; preds = %28, %23
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  br label %37

32:                                               ; preds = %28
  %33 = sext i32 %26 to i64
  %34 = sext i32 %29 to i64
  %35 = getelementptr inbounds [20 x [20 x i32]], ptr @g, i64 0, i64 %33, i64 %34
  store i32 1, ptr %35, align 4, !tbaa !5
  %36 = getelementptr inbounds [20 x [20 x i32]], ptr @g, i64 0, i64 %34, i64 %33
  store i32 1, ptr %36, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %32, %30
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  %39 = call i32 @getchar()
  %sext.mask = and i32 %39, 255
  %40 = icmp eq i32 %sext.mask, 121
  br i1 %40, label %23, label %41, !llvm.loop !13

41:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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" }
attributes #3 = { 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" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass