; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Random/LARSUBP (subp)

; 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
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef 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 [10001 x i8], align 16
  %6 = alloca i64, align 8
  %7 = alloca [10 x i64], align 16
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 10001, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 1000000007, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 80, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %13

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

17:                                               ; preds = %13
  %18 = getelementptr inbounds [10001 x i8], ptr %5, i64 0, i64 0
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %18)
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %28, %17
  %21 = load i32, ptr %9, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 10
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %31

24:                                               ; preds = %20
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 %26
  store i64 0, ptr %27, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %24
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %9, align 4, !tbaa !5
  br label %20, !llvm.loop !11

31:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %76, %31
  %33 = load i32, ptr %10, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10001 x i8], ptr %5, i64 0, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !13
  %37 = sext i8 %36 to i32
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %79

39:                                               ; preds = %32
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [10001 x i8], ptr %5, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !13
  %44 = sext i8 %43 to i32
  %45 = sub nsw i32 %44, 48
  store i32 %45, ptr %3, align 4, !tbaa !5
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = add nsw i64 %49, 1
  %51 = load i64, ptr %6, align 8, !tbaa !9
  %52 = srem i64 %50, %51
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 %54
  store i64 %52, ptr %55, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %73, %39
  %57 = load i32, ptr %11, align 4, !tbaa !5
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = icmp slt i32 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %76

61:                                               ; preds = %56
  %62 = load i32, ptr %11, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !9
  %66 = load i64, ptr %6, align 8, !tbaa !9
  %67 = srem i64 %65, %66
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %72 = add nsw i64 %71, %67
  store i64 %72, ptr %70, align 8, !tbaa !9
  br label %73

73:                                               ; preds = %61
  %74 = load i32, ptr %11, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %11, align 4, !tbaa !5
  br label %56, !llvm.loop !14

76:                                               ; preds = %60
  %77 = load i32, ptr %10, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %10, align 4, !tbaa !5
  br label %32, !llvm.loop !15

79:                                               ; preds = %32
  %80 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 0
  %81 = load i64, ptr %80, align 16, !tbaa !9
  %82 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 1
  %83 = load i64, ptr %82, align 8, !tbaa !9
  %84 = add nsw i64 %81, %83
  %85 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 2
  %86 = load i64, ptr %85, align 16, !tbaa !9
  %87 = add nsw i64 %84, %86
  %88 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 3
  %89 = load i64, ptr %88, align 8, !tbaa !9
  %90 = add nsw i64 %87, %89
  %91 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 4
  %92 = load i64, ptr %91, align 16, !tbaa !9
  %93 = add nsw i64 %90, %92
  %94 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 5
  %95 = load i64, ptr %94, align 8, !tbaa !9
  %96 = add nsw i64 %93, %95
  %97 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 6
  %98 = load i64, ptr %97, align 16, !tbaa !9
  %99 = add nsw i64 %96, %98
  %100 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 7
  %101 = load i64, ptr %100, align 8, !tbaa !9
  %102 = add nsw i64 %99, %101
  %103 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 8
  %104 = load i64, ptr %103, align 16, !tbaa !9
  %105 = add nsw i64 %102, %104
  %106 = getelementptr inbounds [10 x i64], ptr %7, i64 0, i64 9
  %107 = load i64, ptr %106, align 8, !tbaa !9
  %108 = add nsw i64 %105, %107
  %109 = load i64, ptr %6, align 8, !tbaa !9
  %110 = srem i64 %108, %109
  %111 = load i64, ptr %8, align 8, !tbaa !9
  %112 = add nsw i64 %111, %110
  store i64 %112, ptr %8, align 8, !tbaa !9
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = load i64, ptr %8, align 8, !tbaa !9
  %115 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %113, i64 noundef %114)
  %116 = load i32, ptr %4, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %13, !llvm.loop !16

118:                                              ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 10001, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, 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 = { mustprogress norecurse 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; 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
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca [10001 x i8], align 16
  %3 = alloca [10 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 10001, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %3) #5
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %.not32 = icmp slt i32 %5, 1
  br i1 %.not32, label %._crit_edge36, label %.lr.ph35

.lr.ph35:                                         ; preds = %0
  %6 = getelementptr inbounds i8, ptr %3, i64 64
  %7 = getelementptr inbounds i8, ptr %3, i64 72
  br label %.preheader

.preheader:                                       ; preds = %.lr.ph35, %._crit_edge31
  %.02333 = phi i32 [ 1, %.lr.ph35 ], [ %41, %._crit_edge31 ]
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(80) %3, i8 0, i64 80, i1 false), !tbaa !9
  %9 = load i8, ptr %2, align 16, !tbaa !11
  %.not2528 = icmp eq i8 %9, 0
  br i1 %.not2528, label %._crit_edge31, label %.lr.ph30

.lr.ph30:                                         ; preds = %.preheader, %._crit_edge
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %._crit_edge ], [ 0, %.preheader ]
  %10 = phi i8 [ %25, %._crit_edge ], [ %9, %.preheader ]
  %11 = sext i8 %10 to i32
  %12 = add nsw i32 %11, -48
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = add nsw i64 %15, 1
  %17 = srem i64 %16, 1000000007
  store i64 %17, ptr %14, align 8, !tbaa !9
  %18 = icmp sgt i8 %10, 48
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph30
  %wide.trip.count = zext i32 %12 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %19 = icmp eq i32 %12, 1
  br i1 %19, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 4294967294
  br label %26

._crit_edge.loopexit.unr-lcssa:                   ; preds = %26, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %26 ]
  %.unr = phi i64 [ %17, %.lr.ph ], [ %35, %26 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %20 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 %indvars.iv.unr
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = srem i64 %21, 1000000007
  %23 = add nsw i64 %.unr, %22
  store i64 %23, ptr %14, align 8, !tbaa !9
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.lr.ph30
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %24 = getelementptr inbounds [10001 x i8], ptr %2, i64 0, i64 %indvars.iv.next40
  %25 = load i8, ptr %24, align 1, !tbaa !11
  %.not25 = icmp eq i8 %25, 0
  br i1 %.not25, label %._crit_edge31.loopexit, label %.lr.ph30, !llvm.loop !12

26:                                               ; preds = %26, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %26 ]
  %27 = phi i64 [ %17, %.lr.ph.new ], [ %35, %26 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %26 ]
  %28 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 %indvars.iv
  %29 = load i64, ptr %28, align 16, !tbaa !9
  %30 = srem i64 %29, 1000000007
  %31 = add nsw i64 %27, %30
  store i64 %31, ptr %14, align 8, !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %32 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 %indvars.iv.next
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = srem i64 %33, 1000000007
  %35 = add nsw i64 %31, %34
  store i64 %35, ptr %14, align 8, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %26, !llvm.loop !14

._crit_edge31.loopexit:                           ; preds = %._crit_edge
  %36 = load <8 x i64>, ptr %3, align 16, !tbaa !9
  %.pre48 = load i64, ptr %6, align 16, !tbaa !9
  %.pre49 = load i64, ptr %7, align 8, !tbaa !9
  %37 = call i64 @llvm.vector.reduce.add.v8i64(<8 x i64> %36)
  %op.rdx = add i64 %37, %.pre48
  %op.rdx50 = add i64 %op.rdx, %.pre49
  br label %._crit_edge31

._crit_edge31:                                    ; preds = %._crit_edge31.loopexit, %.preheader
  %38 = phi i64 [ %op.rdx50, %._crit_edge31.loopexit ], [ 0, %.preheader ]
  %39 = srem i64 %38, 1000000007
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.02333, i64 noundef %39)
  %41 = add nuw nsw i32 %.02333, 1
  %42 = load i32, ptr %1, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.02333, %42
  br i1 %.not.not, label %.preheader, label %._crit_edge36, !llvm.loop !15

._crit_edge36:                                    ; preds = %._crit_edge31, %0
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 10001, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v8i64(<8 x i64>) #4

attributes #0 = { mustprogress nofree norecurse 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


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