; LLVM IR from hanzohasashi33/Competetive_programming :: HackerEarth/Array1D (Monk_And_Power_Of_Time)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [101 x i32], align 16
  %4 = alloca [101 x i32], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 404, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 404, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %22, %0
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %25

17:                                               ; preds = %12
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [101 x i32], ptr %3, i64 0, i64 %19
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %20)
  br label %22

22:                                               ; preds = %17
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %5, align 4, !tbaa !5
  br label %12, !llvm.loop !9

25:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %36, %25
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %39

31:                                               ; preds = %26
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [101 x i32], ptr %4, i64 0, i64 %33
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %34)
  br label %36

36:                                               ; preds = %31
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %6, align 4, !tbaa !5
  br label %26, !llvm.loop !11

39:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %90, %39
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %44, label %91

44:                                               ; preds = %40
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [101 x i32], ptr %3, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [101 x i32], ptr %4, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp eq i32 %48, %52
  br i1 %53, label %54, label %59

54:                                               ; preds = %44
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %9, align 4, !tbaa !5
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %7, align 4, !tbaa !5
  br label %90

59:                                               ; preds = %44
  %60 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %60, ptr %8, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %84, %59
  %62 = load i32, ptr %8, align 4, !tbaa !5
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = sub nsw i32 %63, 1
  %65 = icmp slt i32 %62, %64
  br i1 %65, label %66, label %87

66:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [101 x i32], ptr %3, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  store i32 %70, ptr %10, align 4, !tbaa !5
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [101 x i32], ptr %3, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = load i32, ptr %8, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [101 x i32], ptr %3, i64 0, i64 %77
  store i32 %75, ptr %78, align 4, !tbaa !5
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [101 x i32], ptr %3, i64 0, i64 %82
  store i32 %79, ptr %83, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %84

84:                                               ; preds = %66
  %85 = load i32, ptr %8, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %8, align 4, !tbaa !5
  br label %61, !llvm.loop !12

87:                                               ; preds = %61
  %88 = load i32, ptr %9, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %9, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %87, %54
  br label %40, !llvm.loop !13

91:                                               ; preds = %40
  %92 = load i32, ptr %9, align 4, !tbaa !5
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %92)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 404, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 404, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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

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

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

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

attributes #0 = { 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 #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 = { 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, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !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"

@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca [101 x i32], align 16
  %3 = alloca [101 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 404, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 404, ptr nonnull %3) #3
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.preheader27:                                     ; preds = %.lr.ph
  %7 = icmp sgt i32 %10, 0
  br i1 %7, label %.lr.ph30, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %8 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = icmp slt i64 %indvars.iv.next, %11
  br i1 %12, label %.lr.ph, label %.preheader27, !llvm.loop !9

.preheader26:                                     ; preds = %.lr.ph30
  %13 = icmp sgt i32 %17, 0
  br i1 %13, label %.lr.ph35, label %._crit_edge

.lr.ph35:                                         ; preds = %.preheader26
  %14 = add nsw i32 %17, -1
  %wide.trip.count = sext i32 %14 to i64
  br label %20

.lr.ph30:                                         ; preds = %.preheader27, %.lr.ph30
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %.lr.ph30 ], [ 0, %.preheader27 ]
  %15 = getelementptr inbounds [101 x i32], ptr %3, i64 0, i64 %indvars.iv39
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %15)
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next40, %18
  br i1 %19, label %.lr.ph30, label %.preheader26, !llvm.loop !11

20:                                               ; preds = %.lr.ph35, %.loopexit
  %.02134 = phi i32 [ 0, %.lr.ph35 ], [ %.1, %.loopexit ]
  %.02333 = phi i32 [ 0, %.lr.ph35 ], [ %.124, %.loopexit ]
  %21 = sext i32 %.02333 to i64
  %22 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = getelementptr inbounds [101 x i32], ptr %3, i64 0, i64 %21
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = icmp eq i32 %23, %25
  br i1 %26, label %34, label %.preheader

.preheader:                                       ; preds = %20
  %27 = icmp slt i32 %.02333, %14
  br i1 %27, label %.lr.ph32.preheader, label %.loopexit

.lr.ph32.preheader:                               ; preds = %.preheader
  %28 = sub nsw i64 %wide.trip.count, %21
  %xtraiter = and i64 %28, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph32.prol.loopexit, label %.lr.ph32.prol

.lr.ph32.prol:                                    ; preds = %.lr.ph32.preheader, %.lr.ph32.prol
  %indvars.iv43.prol = phi i64 [ %indvars.iv.next44.prol, %.lr.ph32.prol ], [ %21, %.lr.ph32.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph32.prol ], [ 0, %.lr.ph32.preheader ]
  %29 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv43.prol
  %indvars.iv.next44.prol = add nsw i64 %indvars.iv43.prol, 1
  %30 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv.next44.prol
  %31 = load i32, ptr %30, align 4, !tbaa !5
  store i32 %31, ptr %29, align 4, !tbaa !5
  store i32 %23, ptr %30, align 4, !tbaa !5
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph32.prol.loopexit, label %.lr.ph32.prol, !llvm.loop !12

.lr.ph32.prol.loopexit:                           ; preds = %.lr.ph32.prol, %.lr.ph32.preheader
  %indvars.iv43.unr = phi i64 [ %21, %.lr.ph32.preheader ], [ %indvars.iv.next44.prol, %.lr.ph32.prol ]
  %32 = sub nsw i64 %21, %wide.trip.count
  %33 = icmp ugt i64 %32, -4
  br i1 %33, label %.loopexit, label %.lr.ph32

34:                                               ; preds = %20
  %35 = add nsw i32 %.02333, 1
  br label %.loopexit

.lr.ph32:                                         ; preds = %.lr.ph32.prol.loopexit, %.lr.ph32
  %indvars.iv43 = phi i64 [ %indvars.iv.next44.3, %.lr.ph32 ], [ %indvars.iv43.unr, %.lr.ph32.prol.loopexit ]
  %36 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv43
  %indvars.iv.next44 = add nsw i64 %indvars.iv43, 1
  %37 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv.next44
  %38 = load i32, ptr %37, align 4, !tbaa !5
  store i32 %38, ptr %36, align 4, !tbaa !5
  store i32 %23, ptr %37, align 4, !tbaa !5
  %39 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv.next44
  %indvars.iv.next44.1 = add nsw i64 %indvars.iv43, 2
  %40 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv.next44.1
  %41 = load i32, ptr %40, align 4, !tbaa !5
  store i32 %41, ptr %39, align 4, !tbaa !5
  store i32 %23, ptr %40, align 4, !tbaa !5
  %42 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv.next44.1
  %indvars.iv.next44.2 = add nsw i64 %indvars.iv43, 3
  %43 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv.next44.2
  %44 = load i32, ptr %43, align 4, !tbaa !5
  store i32 %44, ptr %42, align 4, !tbaa !5
  store i32 %23, ptr %43, align 4, !tbaa !5
  %45 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv.next44.2
  %indvars.iv.next44.3 = add nsw i64 %indvars.iv43, 4
  %46 = getelementptr inbounds [101 x i32], ptr %2, i64 0, i64 %indvars.iv.next44.3
  %47 = load i32, ptr %46, align 4, !tbaa !5
  store i32 %47, ptr %45, align 4, !tbaa !5
  store i32 %23, ptr %46, align 4, !tbaa !5
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next44.3, %wide.trip.count
  br i1 %exitcond.not.3, label %.loopexit, label %.lr.ph32, !llvm.loop !14

.loopexit:                                        ; preds = %.lr.ph32.prol.loopexit, %.lr.ph32, %.preheader, %34
  %.124 = phi i32 [ %35, %34 ], [ %.02333, %.preheader ], [ %.02333, %.lr.ph32 ], [ %.02333, %.lr.ph32.prol.loopexit ]
  %.1 = add nuw nsw i32 %.02134, 1
  %48 = icmp slt i32 %.124, %17
  br i1 %48, label %20, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.loopexit, %0, %.preheader27, %.preheader26
  %.021.lcssa = phi i32 [ 0, %.preheader26 ], [ 0, %.preheader27 ], [ 0, %0 ], [ %.1, %.loopexit ]
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.021.lcssa)
  call void @llvm.lifetime.end.p0(i64 404, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 404, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  ret i32 0
}

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

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

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

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass