; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Random/INCSEQ (inc)

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

@bit = external dso_local global [51 x [100002 x i32]], align 16
@num = external dso_local global [10000 x i32], align 16
@dp = external dso_local global [51 x i32], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3getii(i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6updateiii(i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %10

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

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %23

15:                                               ; preds = %10
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [10000 x i32], ptr @num, i64 0, i64 %17
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %18)
  br label %20

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

23:                                               ; preds = %14
  call void @llvm.memset.p0.i64(ptr align 16 @bit, i8 0, i64 20400408, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %75, %23
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %78

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

30:                                               ; preds = %45, %29
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %48

35:                                               ; preds = %30
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [10000 x i32], ptr @num, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = call noundef i32 @_Z3getii(i32 noundef %36, i32 noundef %40)
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [51 x i32], ptr @dp, i64 0, i64 %43
  store i32 %41, ptr %44, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %35
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %7, align 4, !tbaa !5
  br label %30, !llvm.loop !11

48:                                               ; preds = %34
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [10000 x i32], ptr @num, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  call void @_Z6updateiii(i32 noundef 0, i32 noundef %53, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %71, %48
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = icmp slt i32 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  store i32 11, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %74

59:                                               ; preds = %54
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [10000 x i32], ptr @num, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = sub nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [51 x i32], ptr @dp, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  call void @_Z6updateiii(i32 noundef %60, i32 noundef %65, i32 noundef %70)
  br label %71

71:                                               ; preds = %59
  %72 = load i32, ptr %8, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %8, align 4, !tbaa !5
  br label %54, !llvm.loop !12

74:                                               ; preds = %58
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %5, align 4, !tbaa !5
  br label %24, !llvm.loop !13

78:                                               ; preds = %28
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = sub nsw i32 %79, 1
  %81 = call noundef i32 @_Z3getii(i32 noundef %80, i32 noundef 100001)
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %81)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %83 = load i32, ptr %1, align 4
  ret i32 %83
}

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

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

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

attributes #0 = { mustprogress 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 = { 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 #3 = { "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++ 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"

@bit = external dso_local local_unnamed_addr global [51 x [100002 x i32]], align 16
@num = external dso_local global [10000 x i32], align 16
@dp = external dso_local local_unnamed_addr global [51 x i32], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3getii(i32 noundef, i32 noundef) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6updateiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %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 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(20400408) @bit, i8 0, i64 20400408, i1 false)
  %.pre4041 = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge29

._crit_edge:                                      ; preds = %.lr.ph
  %6 = icmp sgt i32 %9, 0
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(20400408) @bit, i8 0, i64 20400408, i1 false)
  %.pre40 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %6, label %.preheader, label %._crit_edge29

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

.preheader:                                       ; preds = %._crit_edge, %._crit_edge27
  %12 = phi i32 [ %32, %._crit_edge27 ], [ %.pre40, %._crit_edge ]
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %._crit_edge27 ], [ 0, %._crit_edge ]
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph22, label %._crit_edge23

.lr.ph22:                                         ; preds = %.preheader
  %14 = getelementptr inbounds [10000 x i32], ptr @num, i64 0, i64 %indvars.iv37
  br label %24

._crit_edge29:                                    ; preds = %._crit_edge27, %._crit_edge.thread, %._crit_edge
  %15 = phi i32 [ %.pre40, %._crit_edge ], [ %.pre4041, %._crit_edge.thread ], [ %32, %._crit_edge27 ]
  %16 = add nsw i32 %15, -1
  %17 = call noundef i32 @_Z3getii(i32 noundef %16, i32 noundef 100001)
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %17)
  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 i32 0

._crit_edge23:                                    ; preds = %24, %.preheader
  %19 = getelementptr inbounds [10000 x i32], ptr @num, i64 0, i64 %indvars.iv37
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  call void @_Z6updateiii(i32 noundef 0, i32 noundef %21, i32 noundef 1)
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = icmp sgt i32 %22, 1
  br i1 %23, label %.lr.ph26, label %._crit_edge27

24:                                               ; preds = %.lr.ph22, %24
  %indvars.iv31 = phi i64 [ 0, %.lr.ph22 ], [ %indvars.iv.next32, %24 ]
  %25 = load i32, ptr %14, align 4, !tbaa !5
  %26 = trunc nuw nsw i64 %indvars.iv31 to i32
  %27 = call noundef i32 @_Z3getii(i32 noundef %26, i32 noundef %25)
  %28 = getelementptr inbounds [51 x i32], ptr @dp, i64 0, i64 %indvars.iv31
  store i32 %27, ptr %28, align 4, !tbaa !5
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv.next32, %30
  br i1 %31, label %24, label %._crit_edge23, !llvm.loop !11

._crit_edge27:                                    ; preds = %.lr.ph26, %._crit_edge23
  %32 = phi i32 [ %22, %._crit_edge23 ], [ %42, %.lr.ph26 ]
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next38, %34
  br i1 %35, label %.preheader, label %._crit_edge29, !llvm.loop !12

.lr.ph26:                                         ; preds = %._crit_edge23, %.lr.ph26
  %indvars.iv34 = phi i64 [ %indvars.iv.next35, %.lr.ph26 ], [ 1, %._crit_edge23 ]
  %36 = load i32, ptr %19, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  %38 = add nsw i64 %indvars.iv34, -1
  %39 = getelementptr inbounds [51 x i32], ptr @dp, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = trunc nuw nsw i64 %indvars.iv34 to i32
  call void @_Z6updateiii(i32 noundef %41, i32 noundef %37, i32 noundef %40)
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = icmp slt i64 %indvars.iv.next35, %43
  br i1 %44, label %.lr.ph26, label %._crit_edge27, !llvm.loop !13
}

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

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

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

attributes #0 = { mustprogress 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 = { mustprogress 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 #3 = { 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 #4 = { mustprogress 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++ 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