; LLVM IR from Tunghohin/Competitive_Coding :: Luogu (p1068)

; 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 [5 x i8], align 1
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@k = external dso_local global [10002 x [102 x i32]], align 16
@s = external dso_local global [102 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [7 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 i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %10 = load i32, ptr @m, align 4, !tbaa !5
  %11 = sitofp i32 %10 to double
  %12 = fmul double %11, 1.500000e+00
  %13 = call double @llvm.floor.f64(double %12)
  %14 = fptosi double %13 to i32
  store i32 %14, ptr @m, align 4, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %34, %0
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %37

19:                                               ; preds = %15
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2, ptr noundef %3)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [10002 x [102 x i32]], ptr @k, i64 0, i64 %22
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [102 x i32], ptr %23, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %26, align 4, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [102 x i32], ptr @s, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %31, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %19
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %5, align 4, !tbaa !5
  br label %15, !llvm.loop !9

37:                                               ; preds = %15
  store i32 100, ptr %5, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %49, %37
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = load i32, ptr @m, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %42, label %52

42:                                               ; preds = %38
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [102 x i32], ptr @s, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add nsw i32 %46, %47
  store i32 %48, ptr %4, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %42
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = add nsw i32 %50, -1
  store i32 %51, ptr %5, align 4, !tbaa !5
  br label %38, !llvm.loop !11

52:                                               ; preds = %38
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %54, i32 noundef %55)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %8, align 4, !tbaa !5
  store i32 100, ptr %5, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %85, %52
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = icmp sge i32 %60, %61
  br i1 %62, label %63, label %88

63:                                               ; preds = %59
  store i32 1000, ptr %6, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %81, %63
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = icmp sle i32 %65, 10000
  br i1 %66, label %67, label %84

67:                                               ; preds = %64
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [10002 x [102 x i32]], ptr @k, i64 0, i64 %69
  %71 = load i32, ptr %5, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [102 x i32], ptr %70, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %80

76:                                               ; preds = %67
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %77, i32 noundef %78)
  br label %80

80:                                               ; preds = %76, %67
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %6, align 4, !tbaa !5
  br label %64, !llvm.loop !12

84:                                               ; preds = %64
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %5, align 4, !tbaa !5
  %87 = add nsw i32 %86, -1
  store i32 %87, ptr %5, align 4, !tbaa !5
  br label %59, !llvm.loop !13

88:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  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 speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

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

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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 [5 x i8], align 1
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@k = external dso_local local_unnamed_addr global [10002 x [102 x i32]], align 16
@s = external dso_local local_unnamed_addr global [102 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [7 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 i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %4 = load i32, ptr @m, align 4, !tbaa !5
  %5 = sitofp i32 %4 to double
  %6 = fmul double %5, 1.500000e+00
  %7 = tail call double @llvm.floor.f64(double %6)
  %8 = fptosi double %7 to i32
  store i32 %8, ptr @m, align 4, !tbaa !5
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.preheader20

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

.preheader20:                                     ; preds = %.preheader20.loopexit, %0
  %11 = phi i32 [ %.pre, %.preheader20.loopexit ], [ %8, %0 ]
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph24, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %.preheader20
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 101, i32 noundef 0)
  br label %._crit_edge29

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01821 = phi i32 [ %25, %.lr.ph ], [ 0, %0 ]
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [10002 x [102 x i32]], ptr @k, i64 0, i64 %16, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %19, align 4, !tbaa !5
  %22 = getelementptr inbounds [102 x i32], ptr @s, i64 0, i64 %18
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %22, align 4, !tbaa !5
  %25 = add nuw nsw i32 %.01821, 1
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %.lr.ph, label %.preheader20.loopexit, !llvm.loop !9

.lr.ph24:                                         ; preds = %.preheader20, %.lr.ph24
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph24 ], [ 100, %.preheader20 ]
  %.023 = phi i32 [ %30, %.lr.ph24 ], [ 0, %.preheader20 ]
  %28 = getelementptr inbounds [102 x i32], ptr @s, i64 0, i64 %indvars.iv
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = add nsw i32 %29, %.023
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %31 = icmp slt i32 %30, %11
  br i1 %31, label %.lr.ph24, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph24
  %32 = trunc nsw i64 %indvars.iv.next to i32
  %33 = add nsw i32 %32, 1
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %33, i32 noundef %30)
  %.not.not27 = icmp slt i64 %indvars.iv, 101
  br i1 %.not.not27, label %.preheader.preheader, label %._crit_edge29

.preheader.preheader:                             ; preds = %._crit_edge
  %sext = shl i64 %indvars.iv.next, 32
  %35 = ashr exact i64 %sext, 32
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %44
  %indvars.iv35 = phi i64 [ 100, %.preheader.preheader ], [ %indvars.iv.next36, %44 ]
  %36 = trunc nsw i64 %indvars.iv35 to i32
  br label %37

37:                                               ; preds = %.preheader, %43
  %indvars.iv32 = phi i64 [ 1000, %.preheader ], [ %indvars.iv.next33, %43 ]
  %38 = getelementptr inbounds [10002 x [102 x i32]], ptr @k, i64 0, i64 %indvars.iv32, i64 %indvars.iv35
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %.not = icmp eq i32 %39, 0
  br i1 %.not, label %43, label %40

40:                                               ; preds = %37
  %41 = trunc nuw nsw i64 %indvars.iv32 to i32
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %41, i32 noundef %36)
  br label %43

43:                                               ; preds = %37, %40
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next33, 10001
  br i1 %exitcond.not, label %44, label %37, !llvm.loop !12

44:                                               ; preds = %43
  %indvars.iv.next36 = add nsw i64 %indvars.iv35, -1
  %.not.not = icmp sgt i64 %indvars.iv.next36, %35
  br i1 %.not.not, label %.preheader, label %._crit_edge29, !llvm.loop !13

._crit_edge29:                                    ; preds = %44, %._crit_edge.thread, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  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 speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(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

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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}


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