; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (5722)

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

@a = external dso_local global [100010 x i32], align 16
@b = external dso_local global [100010 x i32], align 16
@l = external dso_local global [100010 x i32], align 16
@r = external dso_local global [100010 x i32], align 16
@pre = external dso_local global [100010 x i32], align 16
@sum = external dso_local global [400040 x i32], align 16
@sig = external dso_local global [400040 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dealii(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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

8:                                                ; preds = %97, %0
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr %5, align 4, !tbaa !5
  %11 = icmp ne i32 %9, 0
  br i1 %11, label %12, label %100

12:                                               ; preds = %8
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3, ptr noundef %4)
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %30, %12
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = icmp sle i32 %15, %16
  br i1 %17, label %18, label %33

18:                                               ; preds = %14
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100010 x i32], ptr @a, i64 0, i64 %20
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %21)
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100010 x i32], ptr @a, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100010 x i32], ptr @b, i64 0, i64 %28
  store i32 %26, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %18
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

33:                                               ; preds = %14
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z4dealii(i32 noundef %34, i32 noundef %35)
  store i64 0, ptr %6, align 8, !tbaa !11
  call void @llvm.memset.p0.i64(ptr align 16 @sig, i8 0, i64 1600160, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @sum, i8 0, i64 1600160, i1 false)
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %94, %33
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %40, label %97

40:                                               ; preds = %36
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100010 x i32], ptr @pre, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %72

46:                                               ; preds = %40
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [100010 x i32], ptr @pre, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100010 x i32], ptr @r, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %72

55:                                               ; preds = %46
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [100010 x i32], ptr @pre, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100010 x i32], ptr @l, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100010 x i32], ptr @pre, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100010 x i32], ptr @r, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  call void @_Z6updataiiiiii(i32 noundef 1, i32 noundef 1, i32 noundef %56, i32 noundef %64, i32 noundef %71, i32 noundef -1)
  br label %72

72:                                               ; preds = %55, %46, %40
  %73 = load i32, ptr %2, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [100010 x i32], ptr @r, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %89

78:                                               ; preds = %72
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100010 x i32], ptr @l, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100010 x i32], ptr @r, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  call void @_Z6updataiiiiii(i32 noundef 1, i32 noundef 1, i32 noundef %79, i32 noundef %84, i32 noundef %88, i32 noundef 1)
  br label %89

89:                                               ; preds = %78, %72
  %90 = load i32, ptr getelementptr inbounds ([400040 x i32], ptr @sum, i64 0, i64 1), align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = load i64, ptr %6, align 8, !tbaa !11
  %93 = add nsw i64 %92, %91
  store i64 %93, ptr %6, align 8, !tbaa !11
  br label %94

94:                                               ; preds = %89
  %95 = load i32, ptr %2, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %2, align 4, !tbaa !5
  br label %36, !llvm.loop !13

97:                                               ; preds = %36
  %98 = load i64, ptr %6, align 8, !tbaa !11
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %98)
  br label %8, !llvm.loop !14

100:                                              ; preds = %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

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

attributes #0 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { "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 #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 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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"

@a = external dso_local global [100010 x i32], align 16
@b = external dso_local local_unnamed_addr global [100010 x i32], align 16
@l = external dso_local local_unnamed_addr global [100010 x i32], align 16
@r = external dso_local local_unnamed_addr global [100010 x i32], align 16
@pre = external dso_local local_unnamed_addr global [100010 x i32], align 16
@sum = external dso_local local_unnamed_addr global [400040 x i32], align 16
@sig = external dso_local local_unnamed_addr global [400040 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dealii(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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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: mustprogress uwtable
declare dso_local void @_Z6updataiiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = 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
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3)
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr %3, align 4, !tbaa !5
  %.not36 = icmp eq i32 %5, 0
  br i1 %.not36, label %._crit_edge39, label %.lr.ph38

.lr.ph38:                                         ; preds = %0, %._crit_edge34
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %.not2227 = icmp slt i32 %8, 1
  br i1 %.not2227, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph38, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph38 ]
  %9 = getelementptr inbounds [100010 x i32], ptr @a, i64 0, i64 %indvars.iv
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %9)
  %11 = load i32, ptr %9, align 4, !tbaa !5
  %12 = getelementptr inbounds [100010 x i32], ptr @b, i64 0, i64 %indvars.iv
  store i32 %11, ptr %12, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %.not22.not = icmp slt i64 %indvars.iv, %14
  br i1 %.not22.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph38
  %.lcssa = phi i32 [ %8, %.lr.ph38 ], [ %13, %.lr.ph ]
  %15 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z4dealii(i32 noundef %.lcssa, i32 noundef %15)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600160) @sig, i8 0, i64 1600160, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600160) @sum, i8 0, i64 1600160, i1 false)
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %.not2329 = icmp slt i32 %16, 1
  br i1 %.not2329, label %._crit_edge34, label %.lr.ph33

.lr.ph33:                                         ; preds = %._crit_edge, %34
  %.pre4647 = phi i32 [ %.pre4648, %34 ], [ %16, %._crit_edge ]
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %34 ], [ 1, %._crit_edge ]
  %.031 = phi i64 [ %37, %34 ], [ 0, %._crit_edge ]
  %17 = getelementptr inbounds [100010 x i32], ptr @pre, i64 0, i64 %indvars.iv43
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not24 = icmp eq i32 %18, 0
  br i1 %.not24, label %27, label %19

19:                                               ; preds = %.lr.ph33
  %20 = sext i32 %18 to i64
  %21 = getelementptr inbounds [100010 x i32], ptr @r, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %.not25 = icmp eq i32 %22, 0
  br i1 %.not25, label %27, label %23

23:                                               ; preds = %19
  %24 = getelementptr inbounds [100010 x i32], ptr @l, i64 0, i64 %20
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  call void @_Z6updataiiiiii(i32 noundef 1, i32 noundef 1, i32 noundef %.pre4647, i32 noundef %26, i32 noundef %22, i32 noundef -1)
  %.pre46.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %23, %19, %.lr.ph33
  %.pre46 = phi i32 [ %.pre46.pre, %23 ], [ %.pre4647, %19 ], [ %.pre4647, %.lr.ph33 ]
  %28 = getelementptr inbounds [100010 x i32], ptr @r, i64 0, i64 %indvars.iv43
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %.not26 = icmp eq i32 %29, 0
  br i1 %.not26, label %34, label %30

30:                                               ; preds = %27
  %31 = getelementptr inbounds [100010 x i32], ptr @l, i64 0, i64 %indvars.iv43
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  call void @_Z6updataiiiiii(i32 noundef 1, i32 noundef 1, i32 noundef %.pre46, i32 noundef %33, i32 noundef %29, i32 noundef 1)
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %30, %27
  %.pre4648 = phi i32 [ %.pre, %30 ], [ %.pre46, %27 ]
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @sum, i64 4), align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = add nsw i64 %.031, %36
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %38 = sext i32 %.pre4648 to i64
  %.not23.not = icmp slt i64 %indvars.iv43, %38
  br i1 %.not23.not, label %.lr.ph33, label %._crit_edge34, !llvm.loop !11

._crit_edge34:                                    ; preds = %34, %._crit_edge
  %.0.lcssa = phi i64 [ 0, %._crit_edge ], [ %37, %34 ]
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %.0.lcssa)
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = add nsw i32 %40, -1
  store i32 %41, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %40, 0
  br i1 %.not, label %._crit_edge39, label %.lr.ph38, !llvm.loop !12

._crit_edge39:                                    ; preds = %._crit_edge34, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  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
}

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

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

attributes #0 = { mustprogress 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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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 #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}


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