; LLVM IR from tangjz/acm-icpc :: spoj (PAIRDIV)

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

@tot = external dso_local global i32, align 4
@pr = external dso_local global [100001 x i32], align 16
@d = external dso_local global [100001 x i32], align 16
@n = external dso_local global i64, align 8
@a = external dso_local global i64, align 8
@b = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvev() #1

; 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
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %12

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

15:                                               ; preds = %12
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %68

16:                                               ; preds = %12
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %31, label %22

22:                                               ; preds = %16
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %25
  store i32 %23, ptr %26, align 4, !tbaa !5
  %27 = load i32, ptr @tot, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr @tot, align 4, !tbaa !5
  %29 = sext i32 %27 to i64
  %30 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %29
  store i32 %23, ptr %30, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %22, %16
  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
  br label %32

32:                                               ; preds = %60, %31
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = mul nsw i32 %33, %37
  store i32 %38, ptr %5, align 4, !tbaa !5
  %39 = icmp slt i32 %38, 100001
  br i1 %39, label %41, label %40

40:                                               ; preds = %32
  store i32 5, ptr %3, align 4
  br label %63

41:                                               ; preds = %32
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %47
  store i32 %45, ptr %48, align 4, !tbaa !5
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = icmp eq i32 %52, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %41
  store i32 5, ptr %3, align 4
  br label %63

59:                                               ; preds = %41
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %4, align 4, !tbaa !5
  br label %32, !llvm.loop !9

63:                                               ; preds = %58, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %2, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !11

68:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !12
  %69 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6, ptr noundef %7, ptr noundef %9, ptr noundef %8, ptr noundef %10)
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  store i64 %71, ptr @n, align 8, !tbaa !12
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  store i64 %73, ptr @a, align 8, !tbaa !12
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  store i64 %75, ptr @b, align 8, !tbaa !12
  call void @_Z5solvev()
  %76 = load i64, ptr @ans, align 8, !tbaa !12
  %77 = load i64, ptr %11, align 8, !tbaa !12
  %78 = add nsw i64 %77, %76
  store i64 %78, ptr %11, align 8, !tbaa !12
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  store i64 %80, ptr @n, align 8, !tbaa !12
  %81 = load i32, ptr %7, align 4, !tbaa !5
  %82 = sub nsw i32 %81, 1
  %83 = sext i32 %82 to i64
  store i64 %83, ptr @a, align 8, !tbaa !12
  %84 = load i32, ptr %10, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  store i64 %85, ptr @b, align 8, !tbaa !12
  call void @_Z5solvev()
  %86 = load i64, ptr @ans, align 8, !tbaa !12
  %87 = load i64, ptr %11, align 8, !tbaa !12
  %88 = sub nsw i64 %87, %86
  store i64 %88, ptr %11, align 8, !tbaa !12
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  store i64 %90, ptr @n, align 8, !tbaa !12
  %91 = load i32, ptr %9, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  store i64 %92, ptr @a, align 8, !tbaa !12
  %93 = load i32, ptr %8, align 4, !tbaa !5
  %94 = sub nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  store i64 %95, ptr @b, align 8, !tbaa !12
  call void @_Z5solvev()
  %96 = load i64, ptr @ans, align 8, !tbaa !12
  %97 = load i64, ptr %11, align 8, !tbaa !12
  %98 = sub nsw i64 %97, %96
  store i64 %98, ptr %11, align 8, !tbaa !12
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  store i64 %100, ptr @n, align 8, !tbaa !12
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = sub nsw i32 %101, 1
  %103 = sext i32 %102 to i64
  store i64 %103, ptr @a, align 8, !tbaa !12
  %104 = load i32, ptr %8, align 4, !tbaa !5
  %105 = sub nsw i32 %104, 1
  %106 = sext i32 %105 to i64
  store i64 %106, ptr @b, align 8, !tbaa !12
  call void @_Z5solvev()
  %107 = load i64, ptr @ans, align 8, !tbaa !12
  %108 = load i64, ptr %11, align 8, !tbaa !12
  %109 = add nsw i64 %108, %107
  store i64 %109, ptr %11, align 8, !tbaa !12
  %110 = load i64, ptr %11, align 8, !tbaa !12
  %111 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %110)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  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
  %112 = load i32, ptr %1, align 4
  ret i32 %112
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}


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

@tot = external dso_local local_unnamed_addr global i32, align 4
@pr = external dso_local local_unnamed_addr global [100001 x i32], align 16
@d = external dso_local local_unnamed_addr global [100001 x i32], align 16
@n = external dso_local local_unnamed_addr global i64, align 8
@a = external dso_local local_unnamed_addr global i64, align 8
@b = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvev() local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #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
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  br label %44

6:                                                ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %4, ptr noundef nonnull %3, ptr noundef nonnull %5)
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  store i64 %9, ptr @n, align 8, !tbaa !9
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  store i64 %11, ptr @a, align 8, !tbaa !9
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  store i64 %13, ptr @b, align 8, !tbaa !9
  call void @_Z5solvev()
  %14 = load i64, ptr @ans, align 8, !tbaa !9
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  store i64 %16, ptr @n, align 8, !tbaa !9
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = add nsw i32 %17, -1
  %19 = sext i32 %18 to i64
  store i64 %19, ptr @a, align 8, !tbaa !9
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  store i64 %21, ptr @b, align 8, !tbaa !9
  call void @_Z5solvev()
  %22 = load i64, ptr @ans, align 8, !tbaa !9
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  store i64 %24, ptr @n, align 8, !tbaa !9
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  store i64 %26, ptr @a, align 8, !tbaa !9
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = add nsw i32 %27, -1
  %29 = sext i32 %28 to i64
  store i64 %29, ptr @b, align 8, !tbaa !9
  call void @_Z5solvev()
  %30 = load i64, ptr @ans, align 8, !tbaa !9
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  store i64 %32, ptr @n, align 8, !tbaa !9
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, -1
  %35 = sext i32 %34 to i64
  store i64 %35, ptr @a, align 8, !tbaa !9
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = add nsw i32 %36, -1
  %38 = sext i32 %37 to i64
  store i64 %38, ptr @b, align 8, !tbaa !9
  call void @_Z5solvev()
  %39 = load i64, ptr @ans, align 8, !tbaa !9
  %40 = add i64 %22, %30
  %41 = sub i64 %14, %40
  %42 = add nsw i64 %41, %39
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %42)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  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

44:                                               ; preds = %0, %._crit_edge
  %indvars.iv26 = phi i64 [ 2, %0 ], [ %indvars.iv.next27, %._crit_edge ]
  %45 = phi i32 [ %tot.promoted, %0 ], [ %53, %._crit_edge ]
  %46 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %indvars.iv26
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %.not = icmp eq i32 %47, 0
  %48 = trunc nuw nsw i64 %indvars.iv26 to i32
  br i1 %.not, label %49, label %._crit_edge29

49:                                               ; preds = %44
  store i32 %48, ptr %46, align 4, !tbaa !5
  %50 = add nsw i32 %45, 1
  store i32 %50, ptr @tot, align 4, !tbaa !5
  %51 = sext i32 %45 to i64
  %52 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %51
  store i32 %48, ptr %52, align 4, !tbaa !5
  br label %._crit_edge29

._crit_edge29:                                    ; preds = %44, %49
  %53 = phi i32 [ %50, %49 ], [ %45, %44 ]
  %54 = load i32, ptr @pr, align 16, !tbaa !5
  %55 = mul nsw i32 %54, %48
  %56 = icmp slt i32 %55, 100001
  br i1 %56, label %.lr.ph, label %._crit_edge

57:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %58 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %indvars.iv.next
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = mul nsw i32 %59, %48
  %61 = icmp slt i32 %60, 100001
  br i1 %61, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.lr.ph:                                           ; preds = %._crit_edge29, %57
  %indvars.iv = phi i64 [ %indvars.iv.next, %57 ], [ 0, %._crit_edge29 ]
  %62 = phi i32 [ %60, %57 ], [ %55, %._crit_edge29 ]
  %63 = phi i32 [ %59, %57 ], [ %54, %._crit_edge29 ]
  %64 = sext i32 %62 to i64
  %65 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %64
  store i32 %63, ptr %65, align 4, !tbaa !5
  %66 = load i32, ptr %46, align 4, !tbaa !5
  %67 = icmp eq i32 %66, %63
  br i1 %67, label %._crit_edge, label %57

._crit_edge:                                      ; preds = %57, %.lr.ph, %._crit_edge29
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next27, 100001
  br i1 %exitcond.not, label %6, label %44, !llvm.loop !13
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { 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 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass